2024-05-02 10:30 AM
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????
Solved! Go to Solution.
2024-05-02 10:58 AM - edited 2024-05-03 06:48 AM
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. :)
2024-05-02 10:58 AM - edited 2024-05-03 06:48 AM
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. :)