Skip to main content
noobee
Associate II
April 30, 2015
Question

possible bug in UART code generation cubemx 4.7.1

  • April 30, 2015
  • 0 replies
  • 454 views
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
    This topic has been closed for replies.