This method works very well for low frequencies, but it can have
substantial error at high frequency where multiple interrupts are
running. The interrupt latency will cause a slight delay in capturing
the time base. If this is always the same, it washes out. But if
another - higher priority - task sometimes runs, there will be jitter in
the latency - causing jitter in the frequency measurement.
Using counters for high frequency works well, but with high load. Using
edge-edge timers works very well for low frequencies.
_____
From: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com] On Behalf
Of Martin Maurer
Sent: Thursday, June 09, 2005 10:29 PM
To: lpc2000@yahoogroups.com
Subject: Re: [lpc2000] Re: Frequency counter
Hello,
i don't know if there is any hardware support for this ?
Here are two not elegant solutions, but give you perhaps an idea !
Easiest way without hardware support: Measure the time between line
going
low->high and second low->high.
WaitForPinLow();
WaitForPinHigh();
for(t1 = 0; t1 < BigTimeoutValue; t1++)
{
WaitForPinLow();
}
for(t2 = 0; t2 < BigTimeoutValue; t2++)
{
WaitForPinHigh();
}
According to values t1 and t2 (in sum) you can get the frequency.
BUT: This is very compiler dependant, if it does any optimization,
values
can change !
Better use one of the timers: Start a timer with high frequency, read it
out
the first time low->high and read it out the second time low->high. Then
you
can calculate the frequency.
Regards,
Martin
----- Original Message -----
From: "lehighuboy" <garrett.j.young@...>
To: <lpc2000@yahoogroups.com>
Sent: Friday, June 10, 2005 7:18 AM
Subject: [lpc2000] Re: Frequency counter
>I need to read the frequency of a 50% duty cycle waveform from 0 to
> 200kHz (+/- 1Hz) using the LPC2129. Any suggestions?
>
> Thanks, Garrett
>
> --- In lpc2000@yahoogroups.com, "lehighuboy" <garrett.j.young@g...>
> wrote:
>> Does anyone have sample code that counts pulses for a fixed time
>> duration (frequency counter)?
>>
>> Thanks, Garrett
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
_____
Yahoo! Groups Links
* To visit your group on the web, go to:
http://groups.yahoo.com/group/lpc2000/
* To unsubscribe from this group, send an email to:
lpc2000-unsubscribe@yahoogroups.com
<mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe>
* Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service <http://docs.yahoo.com/info/terms/> .
[Non-text portions of this message have been removed]Message
RE: [lpc2000] Re: Frequency counter
2005-06-10 by Dan Beadle
Attachments
- No local attachments were found for this message.