cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G061C8U6 UART Generated Config is Incorrect

NN.2
Associate II

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?

1 ACCEPTED SOLUTION

Accepted Solutions
NN.2
Associate II

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 */

View solution in original post

9 REPLIES 9

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
Up vote any posts that you find helpful, it shows what's working..

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.

> 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

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

JW

There is no I2C enabled.

NN.2
Associate II

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 */

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 Accept as Solution on the reply which solved your issue or answered your question.

Sara BEN HADJ YAHYA
ST Employee

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.

@Sara BEN HADJ YAHYA​ 

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