eefinni
Newbie level 3

Hi all, I had tried all means to exit the ISR but it seems impossible.. I'd read about RETFIE but it is for ASM. I had also read about instructions set for RETFIE but I don't know how to implement it.
Is there anyway to exit from the ISR?
Here is my code:
Is there anyway to exit from the ISR?
Here is my code:
PHP:
//Define compiler error message.
#ifndef __CPU_16F877__
#error "This program is tailored for PIC16F877 controller"
#endif
//Include required header file.
#include "io16f877.h" //the hardware register defination file.
#include "USART.h"
#include "DELAYS.h"
//List out all inputs and outputs
#define LED_1 RA0
#define LED_2 RA1
#define LED_3 RA2
#define IR RC1
#define RED RB5
#define Yellow RB6
volatile unsigned int DataCount;
volatile unsigned char DATA[3];
/**********************************************************************
This function initializes the IO ports.
**********************************************************************/
void initialize_IO_ports(void)
{
//set the digital IO ports as per requirement.
ADCON1 = 0x07; //set PortA as digital I/O
TRISA = 0x00; //PortA as output.
TRISB = 0x00;
TRISC = 0x8F;
//clear the output ports at the beginning.
PORTA = 0x00;
PORTC=0x00;
PORTB=0x00;
}
#pragma vector=0x04
__interrupt void isr(void)
{
//if(DataCount==0)
// PCL=PCLATH;
//if(RCIF)
//{
RCIE=0;
DATA[DataCount]=RCREG;
if(DataCount!=2)
DataCount++;
CREN=0;
RCIF=0;
//}
if(DATA[0]=='0')
LED_1=1;
if(DATA[1]=='1')
LED_2=1;
if(DATA[2]=='2')
LED_3=1;
//if(DataCount==2)
// PCLATH=(PCL+1);
//if(DataCount==2)
//if(DataCount==2)
//GIE=0;
//RCIF=1;
//STATUS=0x009;
//DelayUs(1);
//DelayUs(1);
Yellow=1;
DelayMs(100);
Yellow=0;
RCIE=1;
//INDF=0x009;
//DelayMs(100);
//GIE=1;
return;
//break;
}
// define the main function
void main()
{
int i,k=0;
char send[3];
RCIF=0;
GIE=1;
PEIE=1;
send[0]='0';
send[1]='2';
send[2]='2';
// initialization of the peripherals to be used by
// calling the respective initialization functions.
initialize_IO_ports();
init_uart();
while(1)
{
if(IR==1)
{
k++;
RED=1;
}
if(k==1)
{
GIE=1;
for(i=0;i<3;i++)
{
CREN=1;
while(TXIF==0);
TXREG=send[i];
DelayMs(10);
}
}
if(k==2)
{
GIE=1;
send[0]='0';
send[1]='1';
send[2]='2';
for(i=0;i<3;i++)
{
CREN=1;
while(TXIF==0);
TXREG=send[i];
DelayMs(10);
}
}
if(k==3)
{
GIE=1;
k=0;
Yellow=1;
send[0]='1';
send[1]='1';
send[2]='2';
for(i=0;i<3;i++)
{
CREN=1;
while(TXIF==0);
TXREG=send[i];
DelayMs(10);
}
}
/*
if(DATA[0]=='0')
LED_1=1;
if(DATA[1]=='1')
LED_2=1;
if(DATA[2]=='2')
LED_3=1;
*/
DelayMs(100);
} //endWhile.
}//endmain