2020-04-03 07:23 AM
Hi Everyone !
I have a problem for calculating timer for 1ms. I attached configuration for clock and timer.
As I understand Timer2 uses APB1 Clock Bus but for timer it will be APB1x2 if APB1 prescaler is not " 1 "
So when I use Prescaler 59999 for 60Mhz APB1 Timer clock difference between my timer interrupts are 2 ms.
When I use Prescaler 29999 for 60Mhz APB1 Timer clock(which I attached) difference between my timer interrupts are 1 ms.
Is there any timer configuration calculation problem ? I have never meet this problem before other STM mcus.
My Firmware is STM32Cube_FW_L4V1.13.0
Thanks in advanced
Solved! Go to Solution.
2020-04-03 08:27 AM
Check the details in the reference manual instead of trusting a barely documented tool and library that it does what you think it should do.
Timers count from 0 to the value in the ARR register (the timer is disabled when ARR=0).
So a timer will generate an update interrupt at every other prescaled clock cycle when ARR=1, and can't generate update interrupts at every single input clock cycle.
2020-04-03 08:27 AM
Check the details in the reference manual instead of trusting a barely documented tool and library that it does what you think it should do.
Timers count from 0 to the value in the ARR register (the timer is disabled when ARR=0).
So a timer will generate an update interrupt at every other prescaled clock cycle when ARR=1, and can't generate update interrupts at every single input clock cycle.
2020-04-03 08:31 AM
You want PSC=0 and ARR=59999.
Timer update frequency is TIMER_CLOCK / (PSC + 1) / (ARR + 1).
2020-04-03 10:09 AM
What is
>difference between my timer interrupts
and how exactly do you determine it?
JW
2020-04-03 01:01 PM
I have volatile boolen variable and I used keil logic analyzer. As you can see bottom time between high and low
2020-04-03 01:50 PM
Thank you.
2020-04-03 01:50 PM
Thank you