2025-02-05 12:49 AM - last edited on 2025-02-05 01:01 AM by Andrew Neil
Hi
Can you tell me how I can calculate a value for ARR for timer 2(32bit timer) and timer3(16bit timer)
I am using STM32F407 APB1 timer clock is 12MHz prescaler is 6
2025-02-05 02:44 AM - edited 2025-02-05 03:34 AM
Timer settings seems to be right. Have you done clock configuration in CubeMX? Please check if time clock (APB1 Timer clocks) is really 72 MHz.
Set CKD in (TIMx_CR1) as 00 should be correct
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-02-05 02:54 AM
2025-02-05 03:00 AM
Sounds like you're clocking at 100 or 108 MHz, not 72
Check your PLL and HSE relationships
2025-02-05 03:34 AM
hi
Can you suggest me a code in which there is generated interrupt using any timer
2025-02-05 03:38 AM - edited 2025-02-05 03:41 AM
@Ash1 wrote:
hi
Can you suggest me a code in which there is generated interrupt using any timer
Time base with interrupt:
PS: No ioc file available for this example.
2025-02-05 03:48 AM - edited 2025-02-05 03:48 AM
@Ash1 wrote:Can you suggest me a code in which there is generated interrupt using any timer
The code posted by @SofLit in the very first reply !
2025-02-05 04:57 AM - edited 2025-02-05 05:27 AM
Hi
I have recheked my configuration and found it was 84mhz timer clock instead of 72Mhz
so for 10 second I am loading 0x98967F in ARR and 83 i have loaded in PSC register but still timer is generating UIF flag sometimes in 7 seconds 4 seconds 2 seconds .can you help me Why I am facing this irregular intervals of setting UIF flag
Note :Do i have to set URS bit also in CR1 will it effec
2025-02-05 10:45 AM
You should be able to set it up once, and it will keep knocking at the right period.
Do you change anything in the interrupt handler or callback?
If you have SysTick running you could record HAL_GetTick() on the update interrupt, perhaps print there, or in your main() loop, or toggle a GPIO.
At long periodicity it will be a challenge to scope
I tend to code directly in HAL, without the code generators, it's not hard to set up the TIM in timebase mode. Soflit's code should suffice.
For long term you need 32-bit like TIM2 / TIM5, or you can use 16-bit or SysTick to count off smaller periods, or count-down a queue/list of software timers, say millisecond counts.