cancel
Showing results for 
Search instead for 
Did you mean: 

TIMER2 interrupt not working .

AVINASH PATHAK
Associate II

I am trying to blink an led on stm32l476rg nucleo board using CMSIS core and startup file in Keil.

I am able to run the Timer2 ,it runs untill it overflows .After overflowing I am trying to clear the SR register in the Timer2 interrupt but after the timer2 overflows ,the CNT regsiter value toggle between 0 and 1 and SR register is not cleared(It gets value of 0x0000001F) as shown in debug window of Keil.

Any help will be appreciated.

0690X00000ARAVoQAP.png

Thank you.

2 REPLIES 2

Paste code, preferably with the Code Snippet tool </> and not screen shots.

The Update interrupt is cleared with TIM2->SR = ~1; // Don't use the RMW form

You'll also need some fencing instruction, like __DSB() to clear the write buffers so it doesn't immediately reenter.

Set TIM2->PSC = 0, and then TIM2->ARR = 79999999, or something usable. You cannot use super high frequency interrupts, and you wouldn't be able to perceive an LED blink at 1 MHz, use some common sense.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
AVINASH PATHAK
Associate II

Great! You seems to be master in STM MCUs! Can you also elaborate a little about using __DSB() and how to use it?

Thank you for answering.