2023-10-11 3:43 AM
Hello!
I'm trying to setup up timer6, i need to use it at different frequencies at different times. To test the timer i toggle an output pin in the ISR and measure the frequency with an oscilloscope, but the frequency is consistently off by about 10%.
Any suggestions to why this is? My solution would be to multiply the wanted frequency by some calibration factor.
I would like a frequency of 2 Hz, so the timer interrupts should be at 4 Hz to toggle on and off.
The timer setup is:
32 MHz PLLCLK
Prescaler = 125
Period = 64000
Solved! Go to Solution.
2023-10-11 3:56 AM - edited 2023-10-11 3:59 AM
Use N-1 values to divide by N
124 to divide by 125
63999 for divide by 64000
2023-10-11 3:56 AM - edited 2023-10-11 3:59 AM
Use N-1 values to divide by N
124 to divide by 125
63999 for divide by 64000
2023-10-11 4:05 AM
Of course, thanks!
Now it's is off by 0.5 % but i guess that's because of the error tolerance of the clock=?
2023-10-11 6:56 AM
0.5% is within the tolerance of the internal HSI, if that's what you're using as a clock. A crystal will provide a much more accurate clock, to tens of ppm or so. The HSI can also be trimmed, but is not going to be stable long term or across temperatures.
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.