AtomSoft
Well-Known Member
Wow interrupts are simple here:
Code:
#include "p30F4013.h"
//#include <p30fxxxx.h>
_FOSC(FRC_PLL4);
_FWDT(WDT_OFF)
_FBORPOR(MCLR_EN & PWRT_OFF)
_FGS(CODE_PROT_OFF)
void INT_Init(void);
void __attribute__((__interrupt__)) _INT0Interrupt(void);
#define SW1 PORTAbits.RA11
char isSet;
int main(void)
{
isSet = 0;
TRISB = 0;
LATB = 0;
INT_Init();
while(1)
{
if(isSet == 1)
LATBbits.LATB0 = 1;
else
LATBbits.LATB0 = 0;
}
}
void INT_Init(void)
{
INTCON2 = 0x0001; //Setup INT0 pin to interupt on falling edge
IFS0bits.INT0IF = 0; //Reset INT0 interrupt flag
IEC0bits.INT0IE = 1; //Enable INT0 Interrupt Service Routine
TRISAbits.TRISA11 = 1;
}
void __attribute__((__interrupt__)) _INT0Interrupt(void)
{
while (SW1 == 1);
if(isSet == 0)
isSet = 1;
else
isSet = 0;
IFS0bits.INT0IF = 0;
}