USART2 on STM32L431 does not support parity with CubeMx
Hello
I'm using a stm32L431. here the documentation :
https://www.st.com/en/microcontrollers-microprocessors/stm32l4x1.html#documentation
HSI is enabled at 16MHz for USART2, used to receive a 1200Bd signal (7bit data + even parity + 1 stop).
I receive wrong characters because of the trim. of parity
I already asked a question about the TRIM but that's not the problem
https://community.st.com/s/question/0D53W00001iwHrbSAE/how-to-trim-the-stm32-hsi-easily
I connect a USB converter (With FT232) on the RX of UART2 to send data to the stm32
I use CubeMx to configure UART2
>> Case 1 that works : (no parity)
Configuration by CubeMX :
huart2.Instance = USART2;
huart2.Init.BaudRate = 1200;
huart2.Init.WordLength = UART_WORDLENGTH_8B;
huart2.Init.StopBits = UART_STOPBITS_1;
huart2.Init.Parity = UART_PARITY_NONE;
huart2.Init.Mode = UART_MODE_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)
Teraterm configuration :
I receive the data without fault...
>> Case 2 not working : (even parity)
Configuration by CubeMX :
huart2.Instance = USART2;
huart2.Init.BaudRate = 1200;
huart2.Init.WordLength = UART_WORDLENGTH_8B; // including parity
huart2.Init.StopBits = UART_STOPBITS_1;
huart2.Init.Parity = UART_PARITY_EVEN;
huart2.Init.Mode = UART_MODE_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)
Teraterm configuration :
Here I receive wrong things, part of the characters are correct, another incoherent
I know that the probability is high that the problem is between the keyboard and the chair but... I'm standing, without a chair! so it can come from a concern of HAL as for the TRIM which is strangely managed?
Thanks in advance