Skip to main content
heveskar
Senior
April 23, 2024
Solved

Code generation - wrong alternate function with partial USB and SDMMC initialization

  • April 23, 2024
  • 2 replies
  • 2066 views

Relevant to this post, created new one per @STTwo-32's recommendation.

When some USB and SDMMC pins are in the GUI set to alternate function without their respective peripherals active, then there is code generated in MX_GPIO_Init() function that renders FDCAN1 nonfunctional.

Here is what's needed:

MCU STM32H723ZGT

In the GUI - Pins PD0 and PD1 mapped to FDCAN1 (RX, TX) with the peripheral enabled.

Pins PB14, PB15, PD6, PD7, PG11, PG12 mapped to SDMMC (D0, D1, CK, CMD, D2, D3) without the peripheral enabled.

PA11, PA12 to USB DM and DP without the peripheral enabled.

This code is generated in MX_GPIO_Init() which sets PA11 and PA12 to incorrect alternate function.

...
/*Configure GPIO pins : PB14 PB15 */
GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF9_SDMMC2;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

/*Configure GPIO pins : PA11 PA12 */
GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

Now FDCAN1 on pins PD0 and PD1 is not working.

IDE version: 1.15.0

heveskar_1-1713862855320.png

 

STM32CubeMX version: 6.11.0

heveskar_2-1713862855319.png

 

Best answer by STTwo-32

Hello @heveskar 

The problem is that the function "GPIO_InitStruct.Alternate" is not generated for USB pins. I've escalated this internally for correction under ticket number 179725.

For the FDCAN, you can find the configuration on the stm32h7xx_hal_msp.c file of your project.

Best Regards.

STTwo-32

2 replies

AScha.3
Super User
April 23, 2024

>This code is generated in MX_GPIO_Init() which sets PA11 and PA12 to incorrect alternate function.

Whats incorrect here ?

+

>Now FDCAN1 on pins PD0 and PD1 is not working.

How you know ?

+

Could you attach your ioc file, to see, whats there ?

"If you feel a post has answered your question, please click ""Accept as Solution""."
heveskar
heveskarAuthor
Senior
April 23, 2024

> What's incorrect?

Missing initialization of .Alternate member.

> How you know?

Because it happened in our project.

> Could you attach ioc file?

Why? I described the exact steps what has to be there in order to generate this code. Nothing else is needed.

Your responses are not helpful at all, the same way you were lecturing me about ADC clocks in my other post when I was clearly right.

AScha.3
Super User
April 23, 2024

Sorry for tying to help you. I never will do again.

"If you feel a post has answered your question, please click ""Accept as Solution""."
STTwo-32
STTwo-32Best answer
Technical Moderator
April 23, 2024

Hello @heveskar 

The problem is that the function "GPIO_InitStruct.Alternate" is not generated for USB pins. I've escalated this internally for correction under ticket number 179725.

For the FDCAN, you can find the configuration on the stm32h7xx_hal_msp.c file of your project.

Best Regards.

STTwo-32

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.
heveskar
heveskarAuthor
Senior
April 23, 2024

@STTwo-32 Thank you. 

STTwo-32
Technical Moderator
April 26, 2024

Hello @heveskar 

The configuration does not get generated For the USB functions since those are additional and not alternate functions.

Best Regards.

STTwo-32

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.