2023-12-26 05:39 AM - edited 2023-12-26 05:39 AM
Hello,
I've used TIM2 to count to 100000 every second. With this i hope to make a very accurate millisecond timer. I can see the counter succesfully going to 1s and then i reset it manually using the RTC interrupt.
Now i want to use an output compare with no output to trigger an interrupt. But i can't do it. Please someone help me.
Solved! Go to Solution.
2023-12-26 07:06 AM - edited 2023-12-26 07:10 AM
Sorry, ...so you cannot use TIM1 or 8 ?
If it has to be tim2 : check, it calls TIM2_IRQ at all ?
+ check flags:
2023-12-26 06:01 AM
Hi,
did you enable the compare INT at all ?
(here enabled ! )
then you get it in xx_it.c
2023-12-26 06:23 AM
Hey thanks for responding.
Yes i did, but for this advanced timer there is only a global interrupt.
2023-12-26 07:06 AM - edited 2023-12-26 07:10 AM
Sorry, ...so you cannot use TIM1 or 8 ?
If it has to be tim2 : check, it calls TIM2_IRQ at all ?
+ check flags:
2023-12-26 09:24 AM
Best way to time accurately is to set a free-running 32-bit counter using period=0xFFFFFFFF and do your time calculations using a difference of current value vs starting value. No need to restart the timer every 1s. Doing so makes the math more difficult.
If you're set on doing it this way, put your reset code in HAL_TIM_PeriodElapsedCallback which gets called on the update event, provided you have interrupts enabled.
2023-12-28 09:14 AM
Eventually just used TIM1, thanks anyway!