cancel
Showing results for 
Search instead for 
Did you mean: 

how do you tune up timers, do you have problems to get the right frequency

MNapi
Senior III

I have STM32F446RE which is 180 Mhz, APB1 is running at 90 Mhz which is the timer clock

for prescaler 7 it is 1.04 Mhz

6 is 1.19 Mhz

8 is 922 Khz

I would assume that I could divide 90 Mhz by 90 to get nice 1 Mhz but it does not seem to be the case. I wonder why

I use CubeMx to setup timers.

2 REPLIES 2

The values are programmed as N-1 values, the silicon does a compare, the logic's easy to implement.

For 1MHz output

Prescaler = 0; // DIV 1

Period = 90 - 1; // DIV 90

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Interrupting a 1 MHz will be problematic, use the TIM to output to a pin, or toggle it.

If the clocks are still wrong, printf("%d\n", SystemCoreClock); and see what the processor thinks it is running at. For example off 8 MHz HSE , or 16 MHz HSI

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..