UART2 initialization infinite loop
ID: LPCBARESDK-710
Status: Fixed
First reported: 6.0.14.1114
Fixed in: 6.0.20.1338
Description
UART2 initialization can enter an infinite loop when a pin is assigned to UART2_RX. Activity on UART2_RX can keep the UART periphreal in a busy state, blocking the initialization.
Workaround
The modification below will prevent the infinite loop from occuring, reading the UART_RBR_THR_DLL register will clear the UART_BUSY bit in this case.
In \sdk\platform\driver\uart\uart.c
, change:
void uart_baudrate_setf(uart_t *uart_id, UART_BAUDRATE baud_rate)
{
// Wait as long as UART is in busy state
- while(uart_is_busy_getf(uart_id));
+ volatile uint16_t tmp; // Volatile to make sure it doens't get optimized away.
+ while(uart_is_busy_getf(uart_id)){
+ tmp = GetWord16(&uart_id->UART_RBR_THR_DLL_REGF);
+ }
// Set Divisor Latch Access Bit in LCR register to access DLL & DLH registers
uart_dlab_setf(uart_id, UART_BIT_EN);
// Set fraction byte of baud rate
SetWord16(&uart_id->UART_DLF_REGF, 0xFF & baud_rate);
// Set low byte of baud rate
SetWord16(&uart_id->UART_RBR_THR_DLL_REGF, 0xFF & baud_rate >> 8);
// Set high byte of baud rate
SetWord16(&uart_id->UART_IER_DLH_REGF, 0xFF & baud_rate >> 16);
// Reset Divisor Latch Access Bit in LCR register
uart_dlab_setf(uart_id, UART_BIT_DIS);
}