2015-01-08 04:37 AM
Hello
I'm looking for a solution to get the time between to input signals in microsecond resolution. But I do not want to use an interrupt counting up all microseconds. Is there a convenient solution / method? #stm32f42015-01-08 05:37 AM
Isn't this the typical task for Timer Capture?
JW2015-01-08 05:42 AM
In hardware TIM Input Capture, in software use a free running counter, ideally at 32-bit one.
For processor level ticks there's DWT_CYCCNT, for something you can divide to 1MHz (or whatever) a 32-bit TIMx->CNT[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Systick%20Delay%20functions&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/AllItems.aspx¤tviews=29]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fcortex_mx_stm32%2fSystick%20Delay%20functions&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https%3A%2F%2Fmy.st.com%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2FAllItems.aspx¤tviews=292015-01-08 11:06 AM
Yes, but there are just two 32 bit timers and I need some more measuring a longer period between the input signals.
2015-01-08 11:44 AM
Yes, but there are just two 32 bit timers and I need some more measuring a longer period between the input signals.
Not much I can do about the silicon, for software solutions you'd just need one. Don't each have 4 channel latches? For hardware they share a synchronous clock, so you can still capture with fine granularity with the 16-bit ones, and then figure the rollover.2015-01-08 11:03 PM
There are 4 captures per timer in the 32-bit timers.
16-bit timers can be chained and then captured simultaneously by connecting the same input signal to both timers' input, although there may be some work needed to figure out the exact behaviour if the capture occurs at around the master's rollover. JW2015-01-09 02:34 AM
I'm using six inputs for input capture (pwm) and six outputs for pwm. All independent at one time.
2015-01-09 04:19 AM
Yes PWM Input would need one timer per ''channel'' as it resets the timer and uses channels 1 and 2 of the timer for period and duty. 16-bit timers would be quite adequate for 50 Hz signals, absent a description of the nature of the signals you're using.
For straight Input Capture mode the timer does not reset, and you can time stamp the edges, two 32-bit timers with 4 channels would support 8 unique inputs. A 32-bit timer clocked a 1 MHz would rollover in ~4295 seconds, at 84 MHz ~51 seconds. You'd take delta measurements to compute frequency and duty.2015-01-09 08:01 AM
This could be a way to solve the requirement. Thanks. It may take some time for my next answer. Thanks.
2015-06-18 03:54 AM
The solution I've found to use microsecond resolution on 16 bit timers is to use the update event irq.
Each time when the CNT overflows an UEV is generated. This irq get caught and a separate 32bit variable gets incremented by 0x00010000. Beware that the UEV can be caused by other conditions.