Buck Converter design with NMos

You need a feedback loop that controls the PWM in "real time".

Also as srnet mentions, you cannot afford a code crash.