avr-chat
[Top][All Lists]
Advanced

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

Re: [avr-chat] Atmega128, JTAG and ADC


From: Richard Urwin
Subject: Re: [avr-chat] Atmega128, JTAG and ADC
Date: Mon, 18 Jul 2005 00:47:40 +0100
User-agent: KMail/1.5.3

On Sunday 17 Jul 2005 11:39 pm, Brian Dean wrote:
> On Sun, Jul 17, 2005 at 12:48:58AM -0700, Larry Barello wrote:
> > if (MCUCSR & _BV(JTRF) != 1)
> > {
> >  MCUCSR |= _BV(JTD);
> >  MCUCSR |= _BV(JTD);
> > }
> >
> > But find that no matter what the code is executed.
>
> Your expression will never be false, since JTRF is bit 4, not bit 0.
> I think you want:
>
>     if ((MCUCRS & _BV(JTRF)) != _BV(JTRF)) {
>       ...
>     }
>

I think == 0 might be even better.
No need to give the compiler a hernia trying to optimise your code. 
Especially when the shorter versions is more readable.

-- 
Richard Urwin




reply via email to

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