arduino / arduino/ArduinoCore-avr

Interrupt still enabled after boot loader [imported]

Open
#218 0 comments 0 reactions 1 assignee Claimed by @cmaglie View on GitHub
Dominant language
C
Stars
1.5k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

This is [Issue 1096](http://code.google.com/p/arduino/issues/detail?id=1096) moved from a Google Code project.
Added by 2012-11-04T20:44:19.000Z by [jonatan....@gmail.com](http://code.google.com/u/107931523280006486231/).
Please review that bug for more context and additional comments, but update this bug.

Original labels: Type-Defect, Priority-Medium
### Original description

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.