2018-05-29 12:43 AM
Hi All,
I am now working on STM32F071 running at 48MHz. I would like to use timer to capture a signal at frequency higher than 400KHz.
Originally I use the input capture interrupt to read the period and duty cycle. The method is ok up to 4xxKHz. Then when the signal frequency becomes higher (600kHz for example), my software in main loop does not have chance to run at all.
I want to ask:
1. Is there any one shot input capture mode so that the software will not keep entering the input capture interrupt ? (if yes, how to set?)
2. What normally people will do if they require to continuously monitor a very high frequency input signal using input capture mode?
Thank you very much.
Note: this post was migrated and contained many threaded conversations, some content may be missing.2018-05-29 01:51 AM
how much higher than 400khz ?
2018-05-29 02:06 AM
It sounds like your core is saturated with the high interrupt load. How long and complex is the handler routine ?
Nonetheless, the core will saturate at one point only from the entry/exit.
You could check every tenth value to make it easier to keep up
Would have suggested it, too.
Perhaps you can enable the capture interrupt every once in a while (e.g. once per millisecond) for a single-shot.
2018-05-29 03:54 AM
over 600kHz
2018-05-29 04:00 AM
use a high speed 32 bit counter with prescaler of 1.
DMA the input capture values into a 1K circular buffer.
the DMA pointer is your 'flag'
then use a foreground process check the pointer has changed, to calculate what you need.
in the foreground
You could check every tenth value to make it easier to keep up
2018-05-29 04:11 AM
sounds like i have three options:
1. Use DMA to effectively lower down the interrupt
2. Use one shot by manually disable the interrupt inside the input capture ISR
3. Polling the capture results periodically
2018-05-29 04:17 AM
If only the frequency measurement is needed, typically prescale the frequency before it is measured.
If the signal is prescaled by 8, the measured frequency will be 8 times slower (and accurate).
Otherwise, I would simply activate the input capture when I want a one measurement done. Once the 1 or 2 input capture interrupt are done to yield a result, make the interrupt self-disable itself. The main loop will then know there is a measurement available, read it and decide when is a good time to launch another measurement.
The trade-off is the response time to frequency change, which would be small here.
Make sense?
Different scheme would be needed to measure the duty cycle...
2018-05-29 04:48 AM
One more thing I want to know:
Is there any side-effect if the input capture overflow flag is set?
I see the flag is set but the data seems like still correct..............
2018-05-29 05:05 AM
its just a flag to let you cascade another counter block, if you need very high resolution for long periods.
you can ignore it for short periods.
2018-05-29 05:06 AM
... or update to a M3 or M4 with higher performance.
Not sure what you want to do with the measured duty cycle time at each cycle.