cancel
Showing results for 
Search instead for 
Did you mean: 

idea to meaure wide range of input frequency?

hg-chen
Associate II
Posted on September 09, 2004 at 03:37

idea to meaure wide range of input frequency?

4 REPLIES 4
hg-chen
Associate II
Posted on September 08, 2004 at 03:05

input frequency range widely from 0.01Hz to 5KHz,

timer overflow will happen, and input capture is used,

but both interrupt share the same vector ,

this may lead to critical condition that overflow counting is not correct,

how to avoid this problem?

or any better method to measure wide range of input frequency?
chander
Associate II
Posted on September 08, 2004 at 03:36

In the interrupt routine, you can check the Input Capture status register to confirm that whether the interrupt occured due to Input Capture or Counter overflow.

hg-chen
Associate II
Posted on September 08, 2004 at 09:35

1, input capture and timer overflow ,which gets the higer priority?

2,any sample code to measure events go beyond the timer range (FFFCH)

using TOF with interrupt?
chander
Associate II
Posted on September 09, 2004 at 03:37

1> Both have the same priority,

2> I don't have the sample code , but the algorithm can be as follows:

______________________________________________________________

MAIN: enable the Input Capture interupt.

a=0;

INTERRPT ROUTINE:

If (interrupt is due to input capture)

First time: Start the counter

Second time: Stop the counter and read the value.

Else (//means the interrupt is due to counter overflow)

a++;

_________________________________________________________________

In this way, you can measure the total time taken between two Rising edges of the signal at the input capture pin. And from this you can easily calculate the frequency.

[ This message was edited by: chander on 09-09-2004 07:08 ]