Skip to main content
Associate
February 11, 2026
Solved

CubeMX incorrectly generating code for STM32U0 MCO2

  • February 11, 2026
  • 1 reply
  • 233 views

I'm trying to generate code using CubeMX for the Nucleo-U031R8 demo board to output a clock signal to the MCO2 pin. But the generated MX_GPIO_Init function makes the following assignment:

GPIO_InitStruct.Alternate = GPIO_AF0_TRACE;

Naturally, the compiler throws an error: "GPIO_AF0_TRACE undeclared".

If I manually change the code to the following:

GPIO_InitStruct.Alternate = GPIO_AF0_MCO2;

...the code compiles without errors.

Is it possible to fix this bug in the next CubeMX release?

Best answer by Mahmoud Ben Romdhane

Hello @flammmable_new 

 

Let me thank you for bringing this issue to our attention.

The issue has been escalated internally to the dedicated team for further investigation and resolution (Ticket 227030).This is an internal tracking number and is not accessible or usable by customers.)

AS WA I recommend that you change the code manually.

HAL Driver:

GPIO_InitStruct.Alternate = GPIO_AF0_MCO2;

LL Driver:

GPIO_InitStruct.Alternate = LL_GPIO_AF_0;

 

Thanks

Mahmoud

1 reply

Technical Moderator
February 11, 2026

Hello @flammmable_new 

Let me thank you for posting.

For more investigation, I suggest that you provide your IOC.File.

Thank

Mahmoud 

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.
Associate
February 11, 2026
Technical Moderator
February 11, 2026

Hello @flammmable_new 

 

Let me thank you for bringing this issue to our attention.

The issue has been escalated internally to the dedicated team for further investigation and resolution (Ticket 227030).This is an internal tracking number and is not accessible or usable by customers.)

AS WA I recommend that you change the code manually.

HAL Driver:

GPIO_InitStruct.Alternate = GPIO_AF0_MCO2;

LL Driver:

GPIO_InitStruct.Alternate = LL_GPIO_AF_0;

 

Thanks

Mahmoud

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.