I don't know how to change the UART's baudrate for an LPC4370 microcontroller. I am using an example program from LPCExpresso to change the baudrate, from the board.c file. It has a function as follows:
Chip_UART_SetBaud(DEBUG_UART, 115200);
I have also included the function definition below:
uint32_t Chip_UART_SetBaud(LPC_USART_T *pUART, uint32_t baudrate)
{
uint32_t div, divh, divl, clkin;
/* Determine UART clock in rate without FDR */
clkin = Chip_Clock_GetRate(Chip_UART_GetClockIndex(pUART));
div = clkin / (baudrate * 16);
/* High and low halves of the divider */
divh = div / 256;
divl = div - (divh * 256);
Chip_UART_EnableDivisorAccess(pUART);
Chip_UART_SetDivisorLatches(pUART, divl, divh);
Chip_UART_DisableDivisorAccess(pUART);
/* Fractional FDR alreadt setup for 1 in UART init */
return clkin / div;
}
As seen, the baud rate is set by dividing the clkin by div. I am trying to achieve a baud rate higher than 115200, and it doesn't really work as it does for transferring data serially to an Arduino, as it does at 115200. I am new to using the microcontroller, any help would be greatly appreciated.
Thanks!
Hello Visweshwar Srinivasan,
Please refer to the formula that is shown in the user guide section 40.6.12 to see which is the maximum baud rate you can reach depending on the peripheral clock.
Hope it helps!
Victor.
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------