PWM driving of a DC/DC Converter with Arduino nano

Hi, well here it is.

I drafted it from memory alone because everything is still at my workplace, but it should be right.

The switch is manual and it's positions, determining wether the battery loads or unloads, are given to the arduino through pins 2 and 3. Anyway, it's really the PWM i'm having a problem with, and (I suppose) the timer routine.