0 TO 2024 wasn't giving you enough range.
You have PTPER at 2024. PTMRPS at 16. Plug these into the above, and you get 0.00648.Code:' At 20MHz, to figure a PWM frequency of 19.455kHz ' ' TPWM = time period of PWM frequency ' PTPER = 12-bit period register PTPERL and PTPERH ' PTMRPS = PWM time base prescaler ' ' (PTPER+1)*PTMRPS 257 ' TPWM = ---------------- = ------------ = 0.0000514 ' Fosc/4 5000000 ' ' Frequency = 1/TPWM = 1/0.0000514 = 19.455kHz ' ' PWM resolution (bits resolution for duty cycle) ' ' log(PTPER+1)*4) 3.01 ' Resolution = ------------------ = ----------- = 10 bits ' .301 .301
1/0.00648 = 154.32 so you have a PWM frequency arouund 154hZ.
Your resolution is about 13-bits. %0001111111111111 = 8191.
So 8000 instead of 2024 is just giving you full range duty cycle.




Bookmarks