cancel
Showing results for 
Search instead for 
Did you mean: 

Code Generation Bug in STM32CubeMX ? Unable to generate UART (one wire half-duplex mode) pin configuration, resulting in the inability to use UART.

Swei.1885
Associate

0690X00000Arfm7QAB.png

0690X00000ArfmWQAR.png

MUC: STM32G031G8Ux

STM32CubeMX version: 5.4.0

Package version: STM32Cube FW_G0 V1.3.0

Keil version: v5.28

--------------------------------------------------------------------

void MX_USART1_UART_Init(void)

{

 huart1.Instance = USART1;

 huart1.Init.BaudRate = 38400;

 huart1.Init.WordLength = UART_WORDLENGTH_8B;

 huart1.Init.StopBits = UART_STOPBITS_1;

 huart1.Init.Parity = UART_PARITY_NONE;

 huart1.Init.Mode = UART_MODE_TX_RX;

 huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;

 huart1.Init.OverSampling = UART_OVERSAMPLING_16;

 huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;

 huart1.Init.ClockPrescaler = UART_PRESCALER_DIV1;

 huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_TXINVERT_INIT|UART_ADVFEATURE_RXINVERT_INIT;

 huart1.AdvancedInit.TxPinLevelInvert = UART_ADVFEATURE_TXINV_ENABLE;

 huart1.AdvancedInit.RxPinLevelInvert = UART_ADVFEATURE_RXINV_ENABLE;

 if (HAL_HalfDuplex_Init(&huart1) != HAL_OK)

 {

  Error_Handler();

 }

 if (HAL_UARTEx_SetTxFifoThreshold(&huart1, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)

 {

  Error_Handler();

 }

 if (HAL_UARTEx_SetRxFifoThreshold(&huart1, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)

 {

  Error_Handler();

 }

 if (HAL_UARTEx_DisableFifoMode(&huart1) != HAL_OK)

 {

  Error_Handler();

 }

}

void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)

{

 if(uartHandle->Instance==USART1)

 {

 /* USER CODE BEGIN USART1_MspInit 0 */

 /* USER CODE END USART1_MspInit 0 */

  /* USART1 clock enable */

  __HAL_RCC_USART1_CLK_ENABLE();

--------------------------------------------------------------------------

The pin configuration is not generated here,

Is this a Bug?

---------------------------------------------------------------------------

  /* USART1 interrupt Init */

  HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);

  HAL_NVIC_EnableIRQ(USART1_IRQn);

 /* USER CODE BEGIN USART1_MspInit 1 */

 /* USER CODE END USART1_MspInit 1 */

 }

}

2 REPLIES 2
Khouloud ZEMMELI
ST Employee

​Hello @Swei.1885​ ,

Thanks for your feedback,

It will be internally checked.

Best Regards,

Khouloud

Khouloud ZEMMELI
ST Employee

@Swei.1885​  Issue will be fixed in the next release.

Regards,

Khouloud​