I'm creating a LCD frequency generator.
When TIMER1
reaches a set value, it's set to toggle Pin 9 (via OC1A
).
Accidentally, I left the TIMER1
"interrupt on compare match A" enabled, but never defined the TIMER1_COMPA_vect
interrupt vector.
This made the Uno reset itself - but not running through the bootloader, just the program part - whenever TIMER1_COMPA_vect
would've been called.
Once I defined the ISR, even without it having any content, it would run as expected.
Is there a default content for ISRs, which resets the device / starts just after the bootloader? Shouldn't the compiler detect a completely missing ISR?
1 Answer 1
The compiler cannot detect a missing ISR since it is very difficult, in the general case, to tell whether any particular interrupt-enable bit has been set by the program.
The avr-libc library does indeed provide a "catch-all" ISR and, as stated by the manual,
the default action is to reset the device by jumping to the reset vector.
If you don't like this behavior, you can override this catch-all with your own, as explained in the manual (search for "Catch-all interrupt vector").
-
Very interesting, that solves my confusion - thank you.towe– towe07/02/2019 13:13:11Commented Jul 2, 2019 at 13:13