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

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

Re: [avr-gcc-list] Possibly wrong code generated using _BV macro


From: Omar Choudary
Subject: Re: [avr-gcc-list] Possibly wrong code generated using _BV macro
Date: Thu, 5 Jan 2012 13:20:14 +0000

Thanks for that.

However the approach I mentioned earlier works fine as well, even if it
takes 3 clocks per assignment, since you are supposed to write the
JTD bit twice within 4 clocks.

Omar

On Thu, Jan 5, 2012 at 7:31 AM, Joerg Wunsch <address@hidden> wrote:
> Omar Choudary <address@hidden> wrote:
>
>> Sorry for writing too early.
>
> In that case, it makes sense to either write the value
> directly:
>
>  MCUCR = _BV(JTD);
>  MCUCR = _BV(JTD);
>
> (usually, you are expected to know the entire contents of that
> register at this point ;-), or use a temporary variable rather than |=
> directly on MCUCR:
>
>  uint8_t tmpval = MCUCR;
>  tmpval |= _BV(JTD);
>  MCUCR = tmpval;
>  MCUCR = tmpval;
>
> The |= requests MCUCR to be read and written back each time (due to
> its volatileness).
> --
> cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL
>
> http://www.sax.de/~joerg/                        NIC: JW11-RIPE
> Never trust an operating system you don't have sources for. ;-)
>
> _______________________________________________
> AVR-GCC-list mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/avr-gcc-list



reply via email to

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