This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

serial ISR doesn't run

Hello,

the ISR runs only for the first time. I'm not sure if the settings for the interrupt are correct. Can anyone explain me the difference between ASC0_RIC_IR and ASC0_RIC

thanks for help

Rainer

void rs232_open()
{

ASC0_CON = 0x8011; // set serial mode // Baudrate Generator disabled,Baudrate timer prescaled divide by 2 // even parity, ignore Parity, Receiver enabled REN = 1, One Stop Bit // 8 Bit data asyncron Mode

ASC0_BG = 0x81; // set baudrate fix Input Clock Dividers // 19200Baud 0x40/0x41 // 9600Baud 0x81/0x82

ASC0_TIC = 0x80; // set transmit interrupt flag ASC0_RIC = 0x45; // delete receive interrupt flag

}

void int_232_serv() interrupt intreg = 43
{

register BYTE c; ASC0_RIC_IE=0; // Receive interrupt disabled

c = ASC0_RBUF;

Receive = TRUE;

ASC0_RIC_IR = 0; ASC0_RIC_IE = 1;
}

Parents
  • Hello,

    has anyone a example for a loop back serial ISR routine for the xc161 Controller like the example for the 8051

    void rs232_open( )
    {

    PCON = 0x80; SCON = 0x50; RCAP2H = 0xFF ;

    RCAP2L = 0xFA ; // T2CON = 0x34 ; // baud ES = 1;
    }

    void int_232_serv() interrupt 4 { register BYTE c, nextp;

    if( RI ) { // receiver interrupt c = S0BUF;

    RI = 0 ; } else if( TI ) { // transmitter interrupt

    S0BUF = c; TI = 0 ; } }

    Thanks for help

    Rainer

Reply
  • Hello,

    has anyone a example for a loop back serial ISR routine for the xc161 Controller like the example for the 8051

    void rs232_open( )
    {

    PCON = 0x80; SCON = 0x50; RCAP2H = 0xFF ;

    RCAP2L = 0xFA ; // T2CON = 0x34 ; // baud ES = 1;
    }

    void int_232_serv() interrupt 4 { register BYTE c, nextp;

    if( RI ) { // receiver interrupt c = S0BUF;

    RI = 0 ; } else if( TI ) { // transmitter interrupt

    S0BUF = c; TI = 0 ; } }

    Thanks for help

    Rainer

Children
  • Here is an example for the XC16x:

    #include <xc161.h>
    #include <intrins.h>
    
    void ASC0_Init(void) {
      /* Configuration ASC0 Baudrate Generator to 9600 Baud (20MHz clock) */
      ASC0_BG = 0x0040u;
    
      /* 8-bit data asychronous operation with one stop bit receiver is enabled */
      ASC0_CON = 0x0011u;
    
      /* P3.10 is used for ASC Transmit Data Output */
      /* P3.11 is used for ASC0 Receive data Input  */
      ALTSEL0P3 |= 0x0400u;
      _bfld_ (P3, 0x0C00u,0x0400u);             /* set output for Tx pin */
      _bfld_ (DP3,0x0C00u,0x0400u);     /* write diections for tx and Rx */
    
      /* Tx interrupt, (ILVL) = 13,(GLVL) = 1,(GPX) = 0 */
      ASC0_TIC = 0x0075u;
    
      /* Rx interrupt, (ILVL) = 13,(GLVL) = 0,(GPX) = 0 */
      ASC0_RIC = 0x0074u;
    
      ASC0_CON |= 0x8000u;  /* enable baud rate generator */
    }
    
    
    void ASC0_TxISr(void) interrupt 0x2A {
      /* not needed in this example */
    }
    
    
    void ASC0_RxIsr(void) interrupt 0x2B {
      ASC0_TBUF = ASC0_RBUF; /* echo byte back */
    }
    
    
    /* entry point*/
    void main(void) {
    
      ASC0_Init();  /* initialize the serial port */
    
      PSW_IEN = 1;  /* globally enable interrupts */
    
      for(;;);      /* loop forever */
    }