cancel
Showing results for 
Search instead for 
Did you mean: 

BaudRate not correct while using USART on NUCLEO-L053R8

Lingjun Kong
Associate III
Posted on August 23, 2017 at 00:22

I'm using NUCLEO-L053R8  for USART communication. 

below is the configuration of usart2, which connects to the st-link as a COM to PC.

0690X00000607wwQAA.png

static void MX_USART2_UART_Init(void)

{

huart2.Instance = USART2;

huart2.Init.BaudRate = 115200;

huart2.Init.WordLength = UART_WORDLENGTH_8B;

huart2.Init.StopBits = UART_STOPBITS_1;

huart2.Init.Parity = UART_PARITY_NONE;

huart2.Init.Mode = UART_MODE_TX_RX;

huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;

huart2.Init.OverSampling = UART_OVERSAMPLING_16;

huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;

huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;

if (HAL_UART_Init(&huart2) != HAL_OK)

{

_Error_Handler(__FILE__, __LINE__);

}

}

using HAL_UART_Transmit(huart, (uint8_t *)dataString , 1, 0xFF); to trans the data.

But in the terminal, when using 115200 to receive the data, it is not correct.

to trans hello word : ''h68 e65 l6C l6C o6F  20 w77 o6F r72 d64 !21 ''

when using 115200 to receive the data, it received ''80 9E 66 1E 9E E0 9E FE 9E 00 78 7E FE 9E 18 3E 78 06 78  ''

But if I change the receive Baud Rate to 57600(half of 115200), the RX is correct.

Why?

0690X00000607XmQAI.png

#cortex-m0 #keil #uart #st #usart #st-link #stm32l0 #cortex-m #st-link
2 REPLIES 2
ArjunKumar
Associate

Hi Lingjun,

I also facing the same issue on Nucleo-L053r8 Board, please give me the solution for this if you already rectified.

Thanks

Posting to a 6-Year old zombie thread, that's pretty hopeful..

Check the RCC Oscillator code has HSE in BYPASS mode.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..