[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Possibly wrong code generated using _BV macro
From: |
Joerg Wunsch |
Subject: |
Re: [avr-gcc-list] Possibly wrong code generated using _BV macro |
Date: |
Thu, 5 Jan 2012 08:31:26 +0100 (MET) |
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. ;-)