cancel
Showing results for 
Search instead for 
Did you mean: 

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

heveskar
Senior

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
STTwo-32
ST Employee

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.

View solution in original post

7 REPLIES 7
AScha.3
Chief II

>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".

> 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.

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
ST Employee

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.

@STTwo-32 Thank you. 

@AScha.3 I did not want to be rude, just that your second comment on my second post was not really helpful in my opinion. Sometimes comments on discussion forums on internet seem to be more arrogant than they really are. I am glad you were trying to help, sorry.  

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.