Baud Rate Issue LPC1857

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

Baud Rate Issue LPC1857

跳至解决方案
987 次查看
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 项奖励
回复
1 解答
966 次查看
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 项奖励
回复
1 回复
967 次查看
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 项奖励
回复