[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-gcc-list] How to accurately measure a square wave frequency
From: |
Rune Christensen |
Subject: |
RE: [avr-gcc-list] How to accurately measure a square wave frequency |
Date: |
Fri, 22 Oct 2004 10:44:08 +0200 |
Hello
Have you looked at the capture system of the timer. The timer should be able
to create a timestamp for the pos edge and neg edge of the signal.
|-----------| |-----------
| | |
-----| |------------------|
old new new
pos neq pos
newpos_timestamp - oldpos_timestamp = 1/frequency
newneq_timestamp / (newpos_timestamp - oldpos_timestamp) = duty cycle
Best regards
Rune Christensen
> -----Original Message-----
> From: address@hidden
> [mailto:address@hidden On Behalf Of system default
> Sent: Friday, October 22, 2004 10:26 AM
> To: address@hidden
> Subject: [avr-gcc-list] How to accurately measure a square
> wave frequency
>
>
> Hi all,
> My name is Joe, I am new to the list and AVR-GCC.
> I am using an ATMega32, and would like to measure a
> pulse on a pin. I was originally using a basic compiler
> that had a high level function called PulseIn.
> This function returned the time in 10uS ticks of the
> high and low parts of the square wave.
>
> I need something smilar to this so i can calculate the
> frequency. I have never used AVR-GCC before so I am
> unsure how to do this. I am using a 4Mhz crystal, If I use
> a loop of some sort with a delay of 10uS how much error
> will the code overhead cause? Does anyone already have
> a method to determin the frequency of a pulse?
> Or know a good method to do this?
>
> Note: It must work on a range from ~100Hz to ~60kHz
>
> Thank you very much.
>
> -Joe
>
> _______________________________________________
> avr-gcc-list mailing list
> address@hidden
> http://www.avr1.org/mailman/listinfo/avr-gcc-list
>
---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0443-2, 21-10-2004
Tested on: 22-10-2004 10:44:08
avast! - copyright (c) 2000-2004 ALWIL Software.
http://www.avast.com