natraj20
Member level 3
Whenever i execute a program in the PIC controller, each of the functions in the interrupt service routine gets executed once at the start or during power on reset. Let me know what should i disable to stop executing.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#pragma code
#pragma interrupt InterruptServiceHigh
void InterruptServiceHigh(void)
{
if(y == 1)
{
if(INTCONbits.INT0IF)
{
x = 0;
while(x <= 2)
{
PORTE = 0x01;
Delay10KTCYx(120); // Delay of 1 sec with 12 MHz
PORTE = 0x02;
Delay10KTCYx(120);
x++;
}
PORTE = 0x00;
INTCONbits.INT0IF = 0;
}
}
}
_T3IF = 0; // clear any pending interrupt
_T3IE = 1; // T3 enable interrupt
Interrupt flag bits are set when an interrupt
condition occurs, regardless of the state of
its corresponding enable bit or the global
interrupt enable bit. User software should
ensure the appropriate interrupt flag bits
are clear prior to enabling an interrupt.
This feature allows for software polling.
#include <p18f47j53.h>
#include <delays.h>
#include <portb.h>
#pragma config OSC = HS
#pragma config WDTEN = OFF
#pragma config XINST = OFF
int x,y;
void InterruptServiceHigh(void);
void InterruptServiceLow(void);
void main(void)
{
INTCONbits.INT0IF = 0;
INTCONbits.INT0IE = 1;
INTCON2bits.INTEDG0 = 1;
RPINR2 = 5;
INTCON3bits.INT2IF = 0;
INTCON3bits.INT2IE = 1;
INTCON3bits.INT2IP = 1;
INTCON2bits.INTEDG2 = 1;
INTCON2bits.RBPU = 0;
EnablePullups();
TRISE = 0;
TRISBbits.TRISB0 = 1;
TRISBbits.TRISB2 = 1;
ANCON1bits.PCFG8 = 1;
ANCON1bits.PCFG12 = 1;
RCONbits.IPEN = 1;
INTCONbits.GIE = 1;
INTCONbits.PEIE = 1;
while(1)
{
PORTE = 0x03;
}
}
// Interrupt Service Routine
// High priority interrupt vector
#pragma code InterruptVectorHigh = 0x08
void InterruptVectorHigh(void)
{
_asm
goto InterruptServiceHigh
_endasm
}
// Low priority interrupt vector
#pragma code InterruptVectorLow = 0x18
void InterruptVectorLow(void)
{
_asm
goto InterruptServiceLow
_endasm
}
// Interrupt pragma for high priority
#pragma code
#pragma interrupt InterruptServiceHigh
void InterruptServiceHigh(void)
{
if(INTCONbits.INT0IF)
{
x = 0;
while(x <= 2)
{
PORTE = 0x01;
Delay10KTCYx(120); // Delay of 1 sec with 12 MHz
PORTE = 0x02;
Delay10KTCYx(120);
x++;
}
PORTE = 0x00;
INTCONbits.INT0IF = 0;
}
if(INTCON3bits.INT2IF)
{
x = 0;
while(x <= 2)
{
PORTE = 0x00;
Delay10KTCYx(120); // Delay of 1 sec with 12 MHz
PORTE = 0x03;
Delay10KTCYx(120);
x++;
}
PORTE = 0x00;
INTCON3bits.INT2IF = 0;
} // return from high priority interrupt
}
// Interrupt pragma for low priority
#pragma code
#pragma interrupt InterruptServiceLow
void InterruptServiceLow(void)
{
// function statements
// return from low priority interrupt
}