I need to turn on my serial interrupt , receive data, process the data and send new data through serial. Then the process is repeated. In order to have one data is processed at a time, i need to turn on and turn off my serial interrupt . Turn off after i have received data and turn back on again when i have finished process and send new data. But how would that be possible. i have tried below code by trying to disable serial interrupt at interrupt subroutine and turn it back on at the main routine, but is not working. Have anyone of you have across the same problem or Can someone share any idea..
Many thanks
At interrupt sub routine...
Code: Select all
void Interrupt(){
if (PIR1.RCIF) { //if (release==0) { // test the interrupt for uart rx
rxchar= UART1_Read(); // read the received data,
if (rxchar=='A') { valid=1;}
if (valid==1) { rxku[u]=rxchar;
u++; //
if (rxchar=='\n'){PIE1.RC1IE = 0; //enable USART receiver interrupt bit
INTCON.PEIE = 0; //enable peripheral interrupt bit
INTCON.GIE = 0; // All port A pins are configured as inputs
//RCON.IPEN=0;
IPR1.RC1IP=0;u=0;valid=0;RCIF_bit=0;}
test=rxku[0];
acc=rxku[1];
acc1=rxku[2];
// acpd1=(int)rxku[2];
tq=rxku[3];
tq1=rxku[4];
speed=rxku[5];
speed1=rxku[6]; }
Lo(ftqref) = acc; // d equals 0x1234AA78
Hi(ftqref)= acc1;
Lo(ftqact)=tq;
Hi(ftqact)=tq1;
Lo(fspeed)=speed;
Hi(fspeed)=speed1; // }
RCIF_bit=0;
}
}
Code: Select all
while(1) {
blink=~blink;
count =count+1;
if(count==1){state=1;}
if (count >=2000){count=0;}
driving();
//display();
my_delay1(); // display();
PIE1.RC1IE = 1; //enable USART receiver interrupt bit
INTCON.PEIE = 1; //enable peripheral interrupt bit
INTCON.GIE = 1; // All port A pins are configured as inputs
RCON.IPEN=0;
IPR1.RC1IP=1;
} }