I am trying to get interrupt on change working on my dsPIC33F. Specifically a dsPIC33FJ128GP802.
I want an interrupt on change event to fire when RB6 or RB7 change.
Here is my code, for MPLAB C30:
I know the pin works because when the code in main is uncommented I get an output on RB15, which has a lot of jitter but shows me the pin input works.
Any help appreciated!! Thanks.
I want an interrupt on change event to fire when RB6 or RB7 change.
Here is my code, for MPLAB C30:
Rich (BB code):
void setup_IOC_sync_pins()
{
SET_CPU_IPL(0);
TRISBbits.TRISB6 = 1;
TRISBbits.TRISB7 = 1;
IFS1bits.CNIF = 0;
IPC4bits.CNIP = 7; // high priority interrupt
IEC1bits.CNIE = 1;
CNEN2bits.CN22IE = 1;
CNEN2bits.CN23IE = 1;
}
void disable_IOC_sync_pins()
{
//IEC1bits.CNIE = 0;
CNEN2bits.CN22IE = 0;
CNEN2bits.CN23IE = 0;
}
void _ISR _CNInterrupt()
{
disable_IOC_sync_pins();
// 4 heartbeat pulses
heartbeat();
setup_IOC_sync_pins();
}
void setup()
{
PLLFBD = 38; // M=40
CLKDIVbits.PLLPOST = 0; // N1=2
CLKDIVbits.PLLPRE = 0; // N2=2
setup_IOC_sync_pins();
TRISBbits.TRISB5 = 1;
TRISBbits.TRISB6 = 1;
TRISBbits.TRISB7 = 1;
TRISBbits.TRISB8 = 1;
}
int main()
{
setup();
heartbeat();
heartbeat();
heartbeat();
heartbeat();
heartbeat();
heartbeat();
heartbeat();
heartbeat();
char l = 0;
while(1)
{
// char b = PORTBbits.RB6;
// if(b != l)
// heartbeat_short();
// l = b;
}
return 0;
}
Any help appreciated!! Thanks.
Last edited: