Skip to main content
ATiwa.3
Associate
Mar 31, 2022 5:06 AM UTC
Question

Hi. I am very new for ST mcus.. Here, I am trying to set set timer2 for interrupt. Assigned PE2 for toggle, In STM32Cube IDE, set clock, enabled tim2 global interrupt. but I am not getting timer interrupt under void HAL_TI();

..

This topic has been closed for replies.

5 replies

LCE
Principal III
Mar 31, 2022 5:15 AM UTC

Check if the timer has started at all by reading its control register CR1 (reg TIM2->CR1, bit TIM_CR1_CEN).

TDK
Mar 31, 2022 12:51 PM UTC

What is HAL_TI() and why are you expecting interrupts there?

Some source code would be explanatory.

The timer update interrupt would call HAL_TIM_PeriodElapsedCallback.

"If you feel a post has answered your question, please click ""Accept as Solution""."
ATiwa.3
ATiwa.3Author
Associate
Mar 31, 2022 2:07 PM UTC

Hi Thanks for your reply. The routine was HAL_TIM_PeriodElapsedCallback(); but due to less available character space, only  HAL_TI(); was blw to write.

I think I am missing something very minute but very critical parameter. I tried with all possible clock configs, prescalers, postscallers for 1us tick period, but unable to get interrupt.

Can you please help me out by some Enable Routine by special function registers?

Tesla DeLorean
Guru
Mar 31, 2022 6:01 PM UTC

Interrupting at 1 MHz (1us) is not practical.

If you want to measure elapsed time with this granularity, free run in maximal count, and read the count value, deltaing the different from current vs initial value.

>>..but due to less available character space

Don't put the entire question in the title/summary, but rather in the body field for the question itself. You can also Edit posts, see V icon in upper right of message areas.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
waclawek.jan
Super User
Mar 31, 2022 5:08 PM UTC

Does PE2 toggle?

Observe the TIM registers, mainly DIER (is the Update interrupt enabled?). Some generic hints to solve interrupts not firing here.

JW