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

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

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


From: Omar Choudary
Subject: [avr-gcc-list] Possibly wrong code generated using _BV macro
Date: Wed, 4 Jan 2012 21:06:23 +0000

Hello,

I wanted to use the _BV macro to set the JTD bit in MCUCR in order to
disable the JTAG interface and
allow the PF4-PF7 pins for other use.

The listing result is this:

    MCUCR |= _BV(JTD); // needs to be done twice
    9cf2:   85 b7           in  r24, 0x35   ; 53
    9cf4:   80 68           ori r24, 0x80   ; 128
    9cf6:   85 bf           out 0x35, r24   ; 53
    MCUCR |= _BV(JTD);
    9cf8:   85 b7           in  r24, 0x35   ; 53
    9cfa:   80 68           ori r24, 0x80   ; 128
    9cfc:   85 bf           out 0x35, r24   ; 53

As you can see the instruction is xoring a temporary value instead of
using the expected sbi.

On the other hand if I use the same approach for a normal port
register I get the desired result:
    DDRF |= _BV(PF4);
    2d66:   84 9a           sbi 0x10, 4 ; 16
    PORTF |= _BV(PF4);
    2d68:   8c 9a           sbi 0x11, 4 ; 17


Any ideas why _BV works for a port register but not for MCUCR?
I'm using AT90USB1287, avr-gcc 4.5.2.

Thanks,
  Omar



reply via email to

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