Baud Rate Issue LPC1857

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

Baud Rate Issue LPC1857

Jump to solution
1,056 Views
rubensjunior
Contributor IV

 

Dear colleagues,
I'm having trouble making a baud rate setting. I use communication with a UART at 115200 bps, but when I need to change the baud rate for another one, my code doesn't work. I can set the baudrate value only once, then I must restart the microcontroller to be able to change the baud rate. But I need to change the baud rate while running the firmware.
I really appreciate the help.

 

Chip_UART_SetBaud(LPC_UART1, baudrate);

/* Determines and sets best dividers to get a target bit rate */
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(UART_BClock[Chip_UART_GetIndex(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;
}

LPC18xx

0 Kudos
Reply
1 Solution
1,035 Views
RaRo
NXP TechSupport
NXP TechSupport

Hello @rubensjunior,

Could you please try to deinitialize the UART before changing the baudrate using Chip_UART_Deinit( )?

After the baudrate change, please re-initialize the module with Chip_UART_Init( ).

Regards, Raul.

View solution in original post

0 Kudos
Reply
1 Reply
1,036 Views
RaRo
NXP TechSupport
NXP TechSupport

Hello @rubensjunior,

Could you please try to deinitialize the UART before changing the baudrate using Chip_UART_Deinit( )?

After the baudrate change, please re-initialize the module with Chip_UART_Init( ).

Regards, Raul.

0 Kudos
Reply