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
>
>
>
>
>
>
>
>Message
Re: [lpc2000] Re: Frequency counter
2005-06-10 by Martin Maurer
Attachments
- No local attachments were found for this message.