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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

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

3,460 次查看
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);
}
标签 (1)
2 回复数

2,592 次查看
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 项奖励
回复

2,592 次查看
lpcware
NXP Employee
NXP Employee
bump