Timeline for STM32F103 simple countdown timer (with no interrupts)
Current License: CC BY-SA 3.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 21, 2015 at 16:44 | comment | added | Amomum | If you don't want to use interrupts and want to avoid rollover, you can poll the corresponding flag in TIM2->SR register; specifically zero bit will be set up on reload event and will stay up until you clear it yourself. That's the proper way to do it, not the threshold. In stm32 every interrupt has a corresponding flag in some status register. Counting down is also possible, just set bit 4 in TIM2->CR1 to 1. | |
Sep 2, 2014 at 11:10 | vote | accept | Jon Mills | ||
Aug 8, 2014 at 9:21 | vote | accept | Jon Mills | ||
Sep 2, 2014 at 11:10 | |||||
Aug 7, 2014 at 7:22 | history | edited | Jon Mills | CC BY-SA 3.0 |
Added comment
|
Aug 7, 2014 at 7:21 | comment | added | Jon Mills | That's a good idea Hanno, thanks. I don't need too much resolution/accuracy on the timer, so slowing it down would be fine, and reduce the risk of a missed rollover. | |
Aug 6, 2014 at 19:49 | comment | added | JimmyB | Now you still can slow down the timer and lower your threshold correspondingly to, like, 10. Then you have all the time in the world to detect the overflow before the timer reaches 0xffff or whatever. | |
Aug 6, 2014 at 15:14 | comment | added | Jon Mills | Yes - I'd omitted that code from my example above, its RCC->APB1ENR |= RCC_APB1ENR_TIM2EN; | |
Aug 6, 2014 at 12:03 | comment | added | Dzarda | I'm no STM expert, but aren't you supposed to turn the clock on for the timer first? | |
Aug 6, 2014 at 11:15 | history | answered | Jon Mills | CC BY-SA 3.0 |