Code: Select all
// Tests AutoWakeup so we can use it for power saving mode.
#define ledPin PB5
void setup() {
pinMode(ledPin, OUTPUT_FAST);
digitalWrite(ledPin, HIGH); // Turn off the LED
AWU->APR = 62; // Set up to wake up in 0.5 seconds
AWU->TBR = 11;
}
void loop() {
digitalWrite(ledPin, LOW); // Turn on the LED
delay(1000);
digitalWrite(ledPin, HIGH); // Turn off the LED
AWU->CSR = 0x10;
halt();
digitalWrite(ledPin, HIGH); // Turn off the LED
for (;;); // Loop here forever
}
volatile unsigned char reg;
INTERRUPT_HANDLER(AWU_IRQHandler, ITC_IRQ_AWU)
{
reg = AWU->CSR; // Reading AWU_CSR1 register clears the interrupt flag.
}
I looked at the assembly code that is generated, and it is solid. I looked at the .hex file, and the interrupt vector table has 0's where I would have expected the call to my interrupt handler to be, at offset 800C.
Code: Select all
:108000008200806B8200000082000000820000007D
:10801000820000008200812A820081308200813645
I have tried every incantation I could think of or find in the code anywhere.
- IMPLEMENT_ISR(AWU_InterruptHandler, ITC_IRQ_AWU)
- void AWU_IRQHandler(void) __interrupt(ITC_IRQ_AWU)
- void AWU_IRQHandler(void) __interrupt(1) __naked
Code: Select all
:108000008200806B8200000082000000820080D12C
:10801000820000008200812A820081308200813645
But I don't want to have to disassemble hex code, calculate the checksum, and modify the hex every time I recompile my project. So the question is, how am I supposed to do it? And why does it seem to work for the External interrupt and the UART, but not the AWU?