We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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; }
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 */ }