AnsweredAssumed Answered

possible bug in UART code generation cubemx 4.7.1

Question asked by noobee on Apr 30, 2015
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;

in particular, if the parity is EVEN or ODD, then i think the wordlength needs to be UART_WORDLENGTH_9B. otherwise, the parity bit would be written on over the 8th bit (replacing the MSB) and not as a new 9th bit.