AnsweredAssumed Answered

STM32CubeMX 4.25 UART4 and UART5 not enabled, missing in generated code

Question asked by Tom Kuschel on Apr 5, 2018
Latest reply on Apr 11, 2018 by houda ghabri

Using STM32CubeMX 4.25.0,

and MCU STM32L4A6QGIx,

Prerequisites: USART1-USART3 and UART4 to UART5 are using the LL driver selection via Project Settings > Advanced Settings (changed from HAL to LL library).

 

The generated code for USART1 to USART3, work out of the box. But with UART4 and UART5, the generated code in file usart.c needs an extra line to enable the UART. You've to add the extra (red) line, e.g.

 

/* UART4 init function */

void MX_UART4_Init(void)

{

  LL_USART_InitTypeDef UART_InitStruct;

  LL_GPIO_InitTypeDef GPIO_InitStruct;

  /* Peripheral clock enable */

  LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_UART4);

  /**UART4 GPIO Configuration

  PC10 ------> UART4_TX

  PC11 ------> UART4_RX

  */

  GPIO_InitStruct.Pin = ONEWIRE_TX_Pin|ONEWIRE_RXn_Pin;

  GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;

  GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;

  GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;

  GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;

  GPIO_InitStruct.Alternate = LL_GPIO_AF_8;

  LL_GPIO_Init(GPIOC, &GPIO_InitStruct);

  UART_InitStruct.BaudRate = 9600;

  UART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B;

  UART_InitStruct.StopBits = LL_USART_STOPBITS_1;

  UART_InitStruct.Parity = LL_USART_PARITY_NONE;

  UART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX;

  UART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_NONE;

  UART_InitStruct.OverSampling = LL_USART_OVERSAMPLING_16;

  LL_USART_Init(UART4, &UART_InitStruct);

  LL_USART_Enable(UART4);

}

Where can I report this bug?

BR Tom

Outcomes