I've read the datasheet about PWM but I'm having troubles understanding how the PWM period is calculated.
For example, in the code example provided, the first pair of PWM are configured to be operating at 40 kHz. That would match the equation given in the datasheet, where clock = 16Mhz, Nprescale=2 and the given PWM0LEN is 200.
The thing is that when I'm trying to view this operation running in the scope, I see that the frequency is not 40 kHz at all. See picture:
You can see that the period is about 3.2 ms which ain't close to 1/40000 = 0.000025
(In the picture is represented PWM1 and PWM0 outputs).
Any help will be welcome.