three external interrupts PIC18f4520

General discussion on mikroC.
Post Reply
Author
Message
r_guna_sekar
Posts: 8
Joined: 05 Jul 2010 18:41

three external interrupts PIC18f4520

#1 Post by r_guna_sekar » 24 Sep 2011 13:50

hi

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;
             }
      }
}

r_guna_sekar
Posts: 8
Joined: 05 Jul 2010 18:41

Re: three external interrupts PIC18f4520

#2 Post by r_guna_sekar » 27 Sep 2011 18:43

i solved this by another forum support...

By adding

Code: Select all

ADCON1 = 7;                          //Disable ADC
CMCON = 7;                           //Disable comparator

Post Reply

Return to “mikroC General”