Skip to main content
NN.2
Associate
June 10, 2022
Solved

STM32G061C8U6 UART Generated Config is Incorrect

  • June 10, 2022
  • 9 replies
  • 3588 views

STM32CubeIDE Version: 1.9.0

Hal MCU : v1.5.1

Chip: STM32G061C8U6 

If you enable USART1 in asynchronous mode for pins PA9 and PA10 the auto generated code incorrectly sets the port to AF0 when it should be AF1 see datasheet table 13 or port.png.

When set to the correct port it transmits but at very low amplitude of a few mv. See scpoe.png

Setting the pins to PB7 and PB8 UART works fine.

How to get it working for pins PA9 and PA10?

This topic has been closed for replies.
Best answer by NN.2

The issue has been fixed. Two things need to be added.

The GPIO alternative function goes to the wrong port.

/* USER CODE BEGIN USART1_MspInit 0 */
	 GPIO_InitStruct.Alternate = GPIO_AF1_USART1; // Auto generated code is wrong
 /* USER CODE END USART1_MspInit 0 */

Also explicitly disabling the pin remapping

 /* USER CODE BEGIN MspInit 1 */
  HAL_SYSCFG_EnableRemap(SYSCFG_REMAP_PA11);
  HAL_SYSCFG_EnableRemap(SYSCFG_REMAP_PA12);
  HAL_SYSCFG_DisableRemap(SYSCFG_REMAP_PA11);
  HAL_SYSCFG_DisableRemap(SYSCFG_REMAP_PA12);
  /* USER CODE END MspInit 1 */

9 replies

Tesla DeLorean
Guru
June 10, 2022

STM32G061C8U6, that's the UFQFPN 48

Make sure the PA11/PA12 (USB) usage of these pins is deconflicted

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
NN.2
NN.2Author
Associate
June 10, 2022

I have these configured as GPIO outputs and these work as expected.

I tried creating a brand new project with just UART1 enabled and I get the same behaviour.

Under the SYS menu Use PA9 instead of PA11 and PA10 instead of PA12 is disabled.

waclawek.jan
Super User
June 10, 2022

> auto generated code incorrectly sets the port to AF0

That's the usual risk of relying on autogenerated code.

> When set to the correct port it transmits but at very low amplitude of a few mv.

Read out and check/post relevant GPIO and SYSCFG registers content.

What hardware is this? Did you measure directly on the pin? Isn't there a bad solder joint? Isn't there something else connected to this pin?

JW

waclawek.jan
Super User
June 10, 2022

Also, don't you have some of the I2C enabled?

JW

NN.2
NN.2Author
Associate
June 10, 2022

There is no I2C enabled.

NN.2
NN.2AuthorBest answer
Associate
June 14, 2022

The issue has been fixed. Two things need to be added.

The GPIO alternative function goes to the wrong port.

/* USER CODE BEGIN USART1_MspInit 0 */
	 GPIO_InitStruct.Alternate = GPIO_AF1_USART1; // Auto generated code is wrong
 /* USER CODE END USART1_MspInit 0 */

Also explicitly disabling the pin remapping

 /* USER CODE BEGIN MspInit 1 */
  HAL_SYSCFG_EnableRemap(SYSCFG_REMAP_PA11);
  HAL_SYSCFG_EnableRemap(SYSCFG_REMAP_PA12);
  HAL_SYSCFG_DisableRemap(SYSCFG_REMAP_PA11);
  HAL_SYSCFG_DisableRemap(SYSCFG_REMAP_PA12);
  /* USER CODE END MspInit 1 */

Amel NASRI
ST Technical Moderator
June 16, 2022

Hi @NN.2​ ,

Thanks for bringing this issue to our attention and also for sharing the solution you found.

I add @Sara BEN HADJ YAHYA​ here so that she can take care of reporting this issue to STM32CubeMX development team in order to take the corrective actions.

-Amel

To give better visibility on the answered topics, please click on "Best Answer" on the reply which solved your issue or answered your question.
Sara BEN HADJ YAHYA
ST Technical Moderator
June 17, 2022

Hello @NN.2​ ,

Thanks for your feedback,

This is a known issue and it is already reported to be fixed. I will keep you posted.

Internal ticket number: 119027(This is an internal tracking number and is not accessible or usable by customers).

Sorry for the inconveniences,

Sara.

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.
NN.2
NN.2Author
Associate
June 22, 2022

@Sara BEN HADJ YAHYA​ 

Were you able to replicate the issue on your end? Any further progress?