Hi Circuiteers. I can't find an answer to this. All I want to do is wake my PIC24F04KL device when a button is pressed. I thought I'd get away with the below
in init()
in main()
However this results in a device reset on a button press. To make it work I have to define the interrupt vector below
I thought in the past I've got away without doing this, but perhaps that was on a PIC16 or PIC18, or perhaps I'm misremembering entirely
in init()
Code:
// IoC
IFS1bits.CNIF = 0; // clear CN IF
IEC1bits.CNIE = 1; // change notification
CNEN2bits.CN29IE = 1; // pin 5, button
Code:
while(1)
{
Sleep();
IFS1bits.CNIF = 0; // clear CN IF
LED = 1;
__delay_ms(10);
LED = 0;
}
Code:
void __attribute__((__interrupt__, auto_psv )) _ISR _CNInterrupt (void)
{
IFS1bits.CNIF = 0; // clear CN IF
}