cancel
Showing results for 
Search instead for 
Did you mean: 

Problem about APB1 Clock Configuration for Timer

CTR.1
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions
berendi
Principal

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.

View solution in original post

6 REPLIES 6
berendi
Principal

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.

TDK
Guru

You want PSC=0 and ARR=59999.

Timer update frequency is TIMER_CLOCK / (PSC + 1) / (ARR + 1).

If you feel a post has answered your question, please click "Accept as Solution".

What is

>difference between my timer interrupts

and how exactly do you determine it?

JW

I have volatile boolen variable and I used keil logic analyzer. As you can see bottom time between high and low 0693W000000VJb3QAG.png

CTR.1
Associate II

Thank you.

Thank you