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

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

Re: [avr-gcc-list] Mega32 wierdness


From: Richard Urwin
Subject: Re: [avr-gcc-list] Mega32 wierdness
Date: Sun, 23 Jan 2005 15:29:44 +0000
User-agent: KMail/1.5.3

On Sunday 23 Jan 2005 1:56 pm, Trampas wrote:
> Jonny,
>
> I can not see anything wrong with your code, why don't you post the
> listing?
>
>
> Also you want to be careful when changing variables that are used in
> interrupt routines. That is you need to make sure that the changes to
> the variables happen in one cycle, which should be the case for your
> code.

No, it is a problem:

>>   if(timer_step > 10)
>>   {
>>    timer_step = 0;
>>   }

If the interrupt occurs between the if and the assignment then you will 
lose a count. It's better to put this code in the interrupt routine and 
set a flag for the background code to pick up. Even then you would have 
to be careful.

-- 
Richard Urwin


reply via email to

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