Sign In

EXTERNAL INTERRUPT DO NOT EXECUTE INTERRUPT SERVICE ROUTINE PROPERLY

ASTHA MODAK modakastha@gmail.com India

Hardware: PIC18F4550 Microcontroller Using Pickit2 Software: C Project Using C18 Compiler Through Mplab

I want to execute IR sensor using pic18f4550.
I have given the output of my IR sensor To the external interrupt INT1 of my pic18f4550.
i have configured that on every rising edge of the INT1 execute the interrupt routine .
The interrupt routine is just blinking of LEd on Every rising edge.
But my interrupt gets executed whenever i connect my IR sensor output to the INT0 without even Changing anything on IR output.
Just a connection betweent the INT0 and IR output executes My Interrupt routine.
My IR sensor GIves 5 volt OUtput when it detects the obstacle or otherwise gives me 0.
IR sensor works properly.

Images

Program

#include<p18f4550.h>

#pragma config FOSC =HS
#pragma config LVP =OFF
#pragma config WDT = OFF
#pragma config PBADEN = OFF


void my_isr(void);
void INT0_ISR(void); 
#pragma interrupt my_isr
void my_isr(void)
{
	if(INTCON3bits.INT1IF==1 )
{

	INT0_ISR();
	}

}

	#pragma code hi_priori =0x0008
	void hi_priori(void)
	{
		_asm
		GOTO my_isr
		_endasm
		}
		#pragma code
void main()
{  
TRISD=0X00;
PORTD=0X00;
PORTDbits.RD1=1;

TRISBbits.TRISB1=1;
PORTBbits.RB0=0;
RCONbits.IPEN = 1; //Allow interrupts
INTCON3bits.INT1IF=0;
INTCON3bits.INT1IE=1;
INTCON2bits.INTEDG1=0;
INTCON3bits.INT1IP=1;
INTCONbits.GIE=1;
while(1);
}
void delay(unsigned int time)
{
unsigned int i,j;
for(i=0;i<time;i++)
for(j=0;j<274;j++);
}


void INT0_ISR(void	)
{  
LATDbits.LATD3 =1 ;
        delay(1000);    
  LATDbits.LATD3 = 0;       
 delay(1000);
INTCON3bits.INT1IF=0;
}






Replies

R Avinash Gupta
2017-03-27 05:22:20
"But my interrupt gets executed whenever i connect my IR sensor output to the INT0 without even Changing anything on IR output."

Does this please the LED start to blink and keep on blinking?

Post a reply to ASTHA MODAK

Think you can help ASTHA MODAK ? Then post your thoughts that might help ASTHA MODAK. You will earn a lot of reputation in the technical community.

If your program is in multiple files, then ZIP the entire folder and attach below

Images and Screenshots

These helps other better understand your suggestion.