cancel
Showing results for 
Search instead for 
Did you mean: 

Input Capture on very high frequency

Ngai yuk kong
Associate II
Posted on May 29, 2018 at 09:43

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.
17 REPLIES 17
T J
Lead
Posted on May 29, 2018 at 10:51

how much higher than 400khz ?

AvaTar
Lead
Posted on May 29, 2018 at 11:06

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.

Posted on May 29, 2018 at 10:54

over 600kHz

Posted on May 29, 2018 at 11:00

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

Posted on May 29, 2018 at 11:11

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 

S.Ma
Principal
Posted on May 29, 2018 at 13:17

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...

Posted on May 29, 2018 at 11:48

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..............

Posted on May 29, 2018 at 12:05

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.

Posted on May 29, 2018 at 12:06

... 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.