avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] Simple question


From: Mark Williams (MWP)
Subject: [avr-gcc-list] Simple question
Date: Mon, 31 Mar 2003 18:54:09 +0930
User-agent: Mutt/1.5.3i

A very basic question... im just having one of those days where i cant see the 
obvious
answer.

I want to do somthing like:

u16 counter=0;

void main(void)
{
        u16 delay;
        while(1)
        {
                if (counter >= delay)
                {
                        //do stuff
                        delay = counter + 1000;
                }
        }
}

INTERRUPT(SIG_OUTPUT_COMPARE2)
{
        counter++;
}

But obviously this wont handle counter overflows too well.  Whats the best way 
to deal with
the overflows, so that the delay still functions properly?  I only want to have 
the counter
increment in the INT as itll be running rather fast, and will chew too much 
processor time
if i start putting compares in there.

Thanks for any tips.
Mark.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]