3 Replies Latest reply on Aug 16, 2016 4:41 AM by MrMa_286121

    PWM Pre scaler is not showing consistent behaviour


      I am using two PWM modules both driven by the same clock.


      PWM1 period = 99


      PWM2 period = 9


      Therefore in each cycle of PWM1, there are 10 cycles of PWM2. Everything works just perfect till here and the oscilloscope shows perfectly alligned outputs as expected.


      Now, when I prescale PWM1 by 2x in the initial property window, PWM2 should complete 20 cycles in each one cycle of PWM1. It indeed does, BUT there is a phase shift of one clock period between PWM1 and PWM2. It doesn't end here. Instead of setting the prescaler to 2x in the initialization window, if I use the SetPrescaler() function in the code, the phase shift disappears!


      In short, the PWM module works differently depending upon whether the Prescaler value has been set in the components initialization window  or whether it is set through programming.


      Why is this happening?


      Thank you...