how to turn on and off serial interrupt

General discussion on mikroC.
Post Reply
Author
Message
saharul
Posts: 489
Joined: 08 Jul 2010 08:11

how to turn on and off serial interrupt

#1 Post by saharul » 26 Jun 2018 09:27

Hi,

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 :D :D :D :D

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;
}
 }
At main code

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

hexreader
Posts: 1784
Joined: 27 Jun 2010 12:07
Location: England

Re: how to turn on and off serial interrupt

#2 Post by hexreader » 01 Jul 2018 01:26

ZIP the whole of your project folder and post here.

Then we will know:

1) Your MCU

2) Your configuration settings

3) Your complete code

Do this every time you have a problem to solve.

Might also need schematic in some cases... , but not in this case
Start every day with a smile...... (get it over with) :)

Post Reply

Return to “mikroC General”