2019-02-22 08:26 AM
Hi all!
I am using STM32F427 with HAL. I have to communicate with other devices using communication protocol over RS-232 interface (USART). The protocol is using 7 data bits, odd parity. I am struggling to make it work.
There is a setting for WordLength with 2 options:
- UART_WORDLENGTH_8B
- UART_WORDLENGTH_9B
But how to set it be equal to 7 data bits?
Here is USART configuration:
// Initialize communication settings
// Communication Parameters: 7 Data, 1 Stop, Odd Parity
// USART Receiver: On
// USART Transmitter: On
// TX, RX interrupts: enabled
// USART Mode: Asynchronous
huart.Init.WordLength = UART_WORDLENGTH_8B;
huart.Init.StopBits = UART_STOPBITS_1;
huart.Init.Parity = UART_PARITY_ODD;
huart.Init.Mode = UART_MODE_TX_RX;
huart.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart.Init.OverSampling = UART_OVERSAMPLING_16;
Seems that it is not working.
Can anyone suggest some solution please?
2019-02-22 09:44 AM
2019-02-22 12:18 PM
>>Seems that it is not working.
Not working how specifically?
You might have to mask the lower 7-bits on the USART->DR read, but the 8-bit mode means 7+1 as the parity bit is included in the budget.