ezieragabriel / arduino

Automatically exported from code.google.com/p/arduino
Other
0 stars 0 forks source link

Interrupt still enabled after boot loader #1096

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The bootloader of Arduino Leonardo seems to not clear the USB interrupts before 
handing over to the main code.

To reproduce, create a minimal C-program like this:

    int main(int argc, char* argv[])
    {
        DDRC = 128;
        PORTC = 0;

        sei();

        while(1) {
            _delay_ms(100);
            PORTC = 128;
            _delay_ms(100);
            PORTC = 0;
        }

        return 0;
    }

Compile and transmit using avr-gcc and avrdude.

The status LED should blink, but it doesn't. But if you remove the call to 
sei() it works as expected.

I've found that the USB interrupts are still enabled when main is entered, 
which causes an unimplemented interrupt handler to called. The workaround is to 
either implement the interrupt handler or disable USB interrupts before sei() 
is called.

Original issue reported on code.google.com by jonatan....@gmail.com on 4 Nov 2012 at 8:44