Please somebody help to use three external interrupt in PIC18F4520..
i tried something... the interrupts are working(i tested it with LED) but the integer mic_num is not updating....
Code: Select all
#define LED PORTD.F0
unsigned int mic_num = 0;
void interrupt()
{
if(INTCON.F1 == 1)
{
mic_num = 1;
}
else if(INTCON3.F0 == 1)
{
mic_num = 2;
}
else if(INTCON3.F1 == 1)
{
mic_num = 3;
}
}
void main()
{
TRISD = 0x00;
TRISC = 0x00;
TRISB = 0xFF;
LED =1;
delay_ms(1000);
LED =0;
PORTC = 0;
INTCON = 0b10010000;
INTCON2 = 0b01110000;
INTCON3 = 0b00011000;
RCON.IPEN = 0;
while(1)
{
if(mic_num > 0)
{
LED = 1;
}
}
}