cancel
Showing results for 
Search instead for 
Did you mean: 

possible bug in UART code generation cubemx 4.7.1

noobee
Associate II
Posted on April 30, 2015 at 14:48

was trying to configure the UART to the Futaba SBUS spec (100000/8E2) and cubemx generated the following initialization code:

void MX_USART1_UART_Init(void)
{
huart1.Instance = USART1;
huart1.Init.BaudRate = 100000;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_2;
huart1.Init.Parity = UART_PARITY_EVEN;
huart1.Init.Mode = UART_MODE_TX_RX;
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
HAL_UART_Init(&huart1);
}

in particular, if the parity is EVEN or ODD, then i think the wordlength needs to be

UART_WORDLENGTH_

9

B.otherwise, the parity bit would be written on over the 8th bit (replacing the MSB) and not as a new 9th bit. thanks
0 REPLIES 0