cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G474RE General purpose timer (TIM16)

Vueko
Associate III

Greetings,

I am trying to set TIM16 on 1us period but the smallest period I am able to achieve is 4us here is the values of my prescaler and auto-reload register(ARR). I am working with the HAL.

SysClk = 170MHz

PSC = 16 (+1 will be added) 

ARR = 9 (+1 will be added) 

So the counter period is: SysClk/(PSC + 1)(ARR+1)  => 170Mhz/(16+1)(9+1) = 1Mhz

I am expected to be at the callback (HAL_TIM_PeriodElapsedCallback) function at this frequency but instead I am at 250Khz

I am pretty sure this timer should be able to go to 1us period and even smaller than that. What am I doing wrong????

1 ACCEPTED SOLUTION

Accepted Solutions
AScha.3
Chief III

Hi,

going to INT and then to callback in less than 1 us ?  Your cpu running on Warp Speed ?

If not, but on 170MHz , then think: INT on ARM cpu is 12 clks , then jump to callback, then HAL ...1..2us,

then jump back, 12 clks to restore registers. So in 4us can come back...good. And maybe 100% cpu load here.

If you want do anything else in your program, then try with 1ms INT/callback speed.

Or 10 us just for test. :)

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

View solution in original post

1 REPLY 1
AScha.3
Chief III

Hi,

going to INT and then to callback in less than 1 us ?  Your cpu running on Warp Speed ?

If not, but on 170MHz , then think: INT on ARM cpu is 12 clks , then jump to callback, then HAL ...1..2us,

then jump back, 12 clks to restore registers. So in 4us can come back...good. And maybe 100% cpu load here.

If you want do anything else in your program, then try with 1ms INT/callback speed.

Or 10 us just for test. :)

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