I m trying to design buck-boost convertor controlled by PIC controller. PIC is simply generating a pulse for switching. I m unable to understand why the output is not coming right. for duty cycle I used the formula D= Vo/(Vo-Vi) and frequency of pulse is 21Khz.