2019-09-12 05:24 PM
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.
Thank you.
2019-09-12 07:30 PM
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.
2019-09-12 11:58 PM
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.