Timer question, STM32WB55x series, modifying CNT register causes unexpected interrupt firing
Hi, the timers of my STM32WB55x aren't working exactly as I anticipated.
Symptoms: By conventional wisdom that I accumulated when using other MCUs under different brands, if the CNT is modified to a different value, the counter should keep counting from that new, modified value.
Except this is not the case. If I modify the CNT register to pretty much any value, the CNT value in Keil's watch window will immediately be reduced to a really tiny, close-to-zero value and an interrupt will immediately be triggered.
But, if I modify the ARR register, the counter seem to be able to count a length that is slightly shorter than desired one, instead of a period that is precisely as expected, I came to this conclusion by measuring it with a stopwatch. It's not perfect but at least it works... somehow.
In short, if I want to modify the timer cycle on the fly, I need to modify the ARR register instead of the CNT register.
My questions are :
- Have I forgot to set/reset certain bit(s) which caused this? (the immediate firing)
- How should I solve this issue if I want to modify the timer cycle dynamically?
Please help and thanks!
Stephan
