Check your eyes! (Hot air is coming
)
The PWM timer uses 5us clock (each step is 5us). For example, for the default 200ms, the timer period would be 40.000 (40.000*5=200.000us=200ms)
PWM is the value compared against the timer counter that generates the duty cycle. So for 50% power, the PWM value would be 40.000/2.
The timer counts always up to 40.000, the pwm output is enabled as long as the counter is below the compare value.
So in this case (For 50% at 200ms), the pwm would be enabled until the counter reaches 20.000. In that moment the pwm is set low, and the timer keeps counting up until 40.000.
Then, it resets and a new cycle starts.
As you rise the PWM frequency this value will be lower, ex. 10ms would be 2.000, 50% would be 1.000.
You can esily see how the pwm loses precision as the frequency increases, although you have a broad adjustment range in any case, from 0.05% at 10ms, to 0,0025% at 200ms.