[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] generating a delay
From: |
Royce Pereira |
Subject: |
Re: [avr-gcc-list] generating a delay |
Date: |
Mon, 24 Oct 2005 17:53:02 +0530 |
User-agent: |
Opera M2/9.0 (Win32) |
Hi,
On Mon, 24 Oct 2005 12:37:40 +0530, varsha <address@hidden>
wrote:
what is the proper way to write a delay routine?
I use this:
//========================
void delay(unsigned count)
{
while(count--);
return;
}
//========================
for really long delays, one may used an unsigned long instead of unsigned.
For accurate delays it's better to set up a hardware timer, with interrupt
enabled.
I always have a 1ms tick, which I can use for various chores like
keyboard/display scanning. or for clocking one or more software sub-timers
which may be used for beeping a buzzer, or flashing an LED @ 1 Hz, etc.
--Royce.
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/