Pulse counter without interrupts
Posted: Mon Dec 30, 2019 6:19 pm
I am looking to do pulse counting that does not rely on interrupts on a STM32. I have some other communication and functions that I would worry might cause missed pulses if they have a higher priority, or the counter interrupt those important functions.
My hope is to use one of the counters with external sources and then periodically read the counter, calculate the pulses based on the delta from the last time the counter was read (Also compensate for rollover).
I was looking at the encoder functionality which seems to be supported on some of the timers (Ch1 and CH2), but not sure of the reason for this. The Datasheet says TIM2, TIM3, TIM4, and TIM5 should all handle encoder mode. My plan is to use a STM32F413 so I of course worry some changes between that and the Pyboard F405 will cause issues.
I have not really needed to use timers for much other than PWM outputs, and was hoping somebody with more experience would have some thoughts on how to best implement this.
Another post covers a lot of what I need to know, but that was about 5 years old and I am digging around hoping or assuming some things have changed or improved with the timer libraries.
viewtopic.php?f=2&t=346&p=1814&hilit=et ... nter#p1814
There is also this one that shows some basics on using the Encoder mode, which seems the most promising.
viewtopic.php?t=1735
Now maybe just using the Encoder setup with the two timers active is the quickest and easiest path.
My hope is to use one of the counters with external sources and then periodically read the counter, calculate the pulses based on the delta from the last time the counter was read (Also compensate for rollover).
I was looking at the encoder functionality which seems to be supported on some of the timers (Ch1 and CH2), but not sure of the reason for this. The Datasheet says TIM2, TIM3, TIM4, and TIM5 should all handle encoder mode. My plan is to use a STM32F413 so I of course worry some changes between that and the Pyboard F405 will cause issues.
I have not really needed to use timers for much other than PWM outputs, and was hoping somebody with more experience would have some thoughts on how to best implement this.
Another post covers a lot of what I need to know, but that was about 5 years old and I am digging around hoping or assuming some things have changed or improved with the timer libraries.
viewtopic.php?f=2&t=346&p=1814&hilit=et ... nter#p1814
There is also this one that shows some basics on using the Encoder mode, which seems the most promising.
viewtopic.php?t=1735
Now maybe just using the Encoder setup with the two timers active is the quickest and easiest path.