AnsweredAssumed Answered

[STM32L4] timer interrupt starts immediately

Question asked by Noyb on Oct 4, 2016
Latest reply on Oct 5, 2016 by Noyb
Hi, using TIM1 to get a simple 1ms delay (MCU@24MHz, PSC=24, ARR=1000) the interrupt triggers almost as soon as I set CR1:CEN=1.

I've found that I'm not the only one having this problem, have followed the advice given here and there, but still no luck.

1- Start peripheral (RCC)
2- Reset peripheral
3- Set registers (SR, CR1, SMCR, BDTR, CNT, ARR, PSC)
4- Do some read back to ensure propagation
5- Tried the EGR:UG=1 trick
6- Tried the CR1:URS=1 trick
7- Interrupt is cleared at the beginning of the ISR
8- Start the timer, interrupt triggers within 50us (about 1200 cycles)

This is rather hard to get this thing working without deploying a whole army.

Outcomes