I tried this code for one push button which after some playing around to enable an interrupt from F8 but to no avail.
Code: Select all
int flag=0;
void main(){
ANSELA=0;
ANSELF=0;
TRISA=0;
LATA=0xFF;
TRISF8_bit=1; //button input
Unlock_IOLOCK();
PPS_Mapping(58, _INPUT, _INT1);
//RPINR0bits.INT1R = 58;
Lock_IOLOCK();
IFS0bits.INT1IF=0; //clear interrupt flag
INTCONbits.INT1EP=0; //interrupt edge
IPC2bits.INT1IP=1; //interrupt priority
IEC0bits.INT1IE=1; //enable external interrupt
EnableInterrupts();
while(1){
if (flag==1){
flag=0;
LATA=~PORTA;
}
}
}
void EXT_INT1() iv IVT_EXTERNAL_1 ics ICS_AUTO
{
flag=1;
IFS0.INT1IF =0;
}
What am i doing wrong?
thanks