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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

2,513 Views
lpcware
NXP Employee
NXP Employee
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);
}
Labels (1)
2 Replies

1,645 Views
Proteus
Contributor I

Thanks for posting this alexgoldstone...  I had been unknowingly plagued by this bug but didn't manage to catch it happening till I found your thread...

0 Kudos

1,645 Views
lpcware
NXP Employee
NXP Employee
bump