lpcware

PWM timer prescaler purpose

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by wella-tabor on Sun Dec 01 04:57:24 MST 2013
Hello,

does anybody know the meaning of the prescaler in LPC1788 pwm? I cannot imagine the purpose for PWM freq > 1 HZ. The MR0 is a 32 bit register, enabling to achieve up to ~4GHz, or ~35s (PWM clock = 120 MHz).

Let's compute the MR0
MR0 = INT(PWM_clock / ((1 + prescaler) * desired_freq))), INT is a function that returns integral part of the result
error =  PWM_clock / ((1 + prescaler) * MR0)) - desired_freq

The error is zero if we solve this equation PWM_clock MOD ((1 + prescaler) * desired_freq) = 0, however if the PWM_clock MOD desired_freq != 0, such (1 + prescaler) does not exist. The best option is to set the prescaler to 0.

Or maybe I am wrong....

Best
Martin






Outcomes