Hi All
I want some feedback as to whether what I am doing is correct. I am using a DS80C320 with a Phillips SC28L198 8 channel UART. 2 interrupts are triggered by the internal UARTS, 1 by the phillips chip and another by timer 0. I have found that for reliable operation i must turn all interrupts off when servicing the internal uart interrupts, and when putting a character into the ring buffer for transmission. Can anyone see any problem with this? Does anyone with a similar setup do it differently? Do I have to disable all interrupts, or only a few?Below is two snippits of code as an example: ................. // // uputch - // // Puts a character out of a serial port // void uputch(unsigned char chan,unsigned char data) { unsigned char oldie;
oldie = IE; IE = 0; wdog(); switch(chan) { //Internal UARTS case INTUART_1: tx_buff[chan][tx_inptr[chan]] = data; tx_inptr[chan]++; tx_inptr[chan] &= TXBUF_SIZE; if (sending_flg[1] == 0) { sending_flg[1] = 1; TI_1 = 1; } break; case INTUART_0: tx_buff[chan][tx_inptr[chan]] = data; tx_inptr[chan]++; tx_inptr[chan] &= TXBUF_SIZE;
if (sending_flg[0] == 0) { sending_flg[0] = 1; TI_0 = 1; } break;
//Philips UARTS case EXTUART_7: case EXTUART_6: case EXTUART_5: case EXTUART_4: case EXTUART_3: case EXTUART_2: case EXTUART_1: case EXTUART_0: tx_buff[chan][tx_inptr[chan]] = data; tx_inptr[chan]++; tx_inptr[chan] &= TXBUF_SIZE; //Enable TX FIFO empty interrupt *IMR_WR_PTR[chan] = 0x03; break; } IE = oldie; }
...........
// // uart1_isr - // // Interrupt routine for internal UART 1 // interrupt void uart1_isr(void) { unsigned char oldie;
oldie = IE; IE = 0;
if (RI_1) { RI_1 = 0; rx_buff[INTUART_1][rx_inptr[INTUART_1]] = SBUF1; rx_inptr[INTUART_1]++; rx_inptr[INTUART_1] &= RXBUF_SIZE; } if (TI_1) { TI_1 = 0; if (!isempty_tx(INTUART_1)) { SBUF1 = tx_buff[INTUART_1][tx_outptr[INTUART_1]]; tx_outptr[INTUART_1]++; tx_outptr[INTUART_1] &= TXBUF_SIZE; } else { sending_flg[1] = 0; } } IE = oldie; } ...........
tia Ross