I wrote a external interrupt code for PIC18LF47k40 on MPLAB X IDE to toggle a LED when rising edge will be occurred. It is not working, but the same type code for PIC18F452 is working fine, only I modified the Register. Can you please help me why my below code for PIC18LF47K0 is not working?
below my code:
Please help me to solve this. Thanks
Mod edit: code tags - JohnInTX
below my code:
C:
#define _XTAL_FREQ 16000000
#include <xc.h>
#include <pic18lf47k40.h>
#include <stdio.h>
void main(void)
{
TRISDbits.TRISD6=0; //RD pin as output declaration
PORTDbits.RD6=1;
TRISBbits.TRISB2=1; /* Make INT2 pin as an input pin*/
ANSELBbits.ANSELB2 = 0; //making digital input
INTCONbits.GIE=1; /* Enable Global Interrupt*/
INTCONbits.INT2EDG=1; /* Set Interrupt on rising Edge*/
PIE0bits.INT2IE=0; /* Enable INT2 external interrupt*/
PIE0bits. IOCIE=1; //enable interrout on change
PIR0bits.INT2IF=0; // Clear the interrupt flag
while(1)
{
}
}
void __interrupt() isr(void)
{
PORTDbits.RD6^=0; //making togle RD6 pin
PIR0bits.INT2IF=0; // Clear the interrupt fla
}
Mod edit: code tags - JohnInTX
Last edited by a moderator: