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

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

Re: [avr-gcc-list] Simple question


From: Lorne Gutz
Subject: Re: [avr-gcc-list] Simple question
Date: Mon, 31 Mar 2003 08:43:05 -0500

On Monday 31 March 2003 04:24, Mark Williams (MWP) wrote:
> 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;

this must be volatile

> void main(void)
> {
>       u16 delay ;
      set delay = some constant.

>       while(1)
>       {
>               if (counter >= delay)
>               {
>                       //do stuff
>                       delay = counter + 1000;
        then here set counter = 0;  instead of the above.

>               }
>       }
> }
>
> 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.
>
> _______________________________________________
> avr-gcc-list mailing list
> address@hidden
> http://www.avr1.org/mailman/listinfo/avr-gcc-list



reply via email to

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