lpcware

Bug Report : UART Ring Buffer : Interrupt Handler : LPCOpen v2.19 : LPC824

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Dec 20, 2016 by Diego Spinola
Content originally posted in LPCWare by alexgoldstone on Fri Mar 04 10:29:20 MST 2016
The Chip_UART_SendRB function correctly disables the TXRDY interrupt when you are filling the transmit buffer.

Chip_UART_IRQRBHandler only checks the TXRDY status and does not first check if the interrupt is enabled.

This means that if you get an RX Interrupt while you are filling the FIFO then Chip_UART_IRQRBHandler incorrectly calls Chip_UART_TXIntHandlerRB causing the buffer pointers to overflow.

The Chip_UART_IRQRBHandler should be changed from:


/* UART receive/transmit interrupt handler for ring buffers */
void Chip_UART_IRQRBHandler(LPC_USART_T *pUART, RINGBUFF_T *pRXRB, RINGBUFF_T *pTXRB)
{
/* Handle transmit interrupt if enabled */
if ((Chip_UART_GetStatus(pUART) & UART_STAT_TXRDY) != 0) {
Chip_UART_TXIntHandlerRB(pUART, pTXRB);

/* Disable transmit interrupt if the ring buffer is empty */
if (RingBuffer_IsEmpty(pTXRB)) {
Chip_UART_IntDisable(pUART, UART_INTEN_TXRDY);
}
}

/* Handle receive interrupt */
Chip_UART_RXIntHandlerRB(pUART, pRXRB);
}


to:


/* UART receive/transmit interrupt handler for ring buffers */
void Chip_UART_IRQRBHandler(LPC_USART_T *pUART, RINGBUFF_T *pRXRB, RINGBUFF_T *pTXRB)
{
/* Handle transmit interrupt if enabled */
[color=#f00]if ((Chip_UART_GetIntsEnabled(pUART) & UART_INTEN_TXRDY) != 0) {[/color]
if ((Chip_UART_GetStatus(pUART) & UART_STAT_TXRDY) != 0) {
Chip_UART_TXIntHandlerRB(pUART, pTXRB);

/* Disable transmit interrupt if the ring buffer is empty */
if (RingBuffer_IsEmpty(pTXRB)) {
Chip_UART_IntDisable(pUART, UART_INTEN_TXRDY);
}
}
[color=#f00]}[/color]

/* Handle receive interrupt */
Chip_UART_RXIntHandlerRB(pUART, pRXRB);
}

Outcomes