2024-12-23 03:05 AM - edited 2024-12-23 03:09 AM
Hello, ST experts
For some reason, PA12 of STM32U595VGT6 is set to GPIO at start up. But I can not find how to set PA12 to USB_DP again in any alternate function of AF1 to AF15.
BR
Yang
Solved! Go to Solution.
2024-12-23 06:31 AM - edited 2024-12-23 06:35 AM
@Yang Yang wrote:
Hello
Maybe I miss something. At powerup PA12 is configured to GPIO. And then it is need to be set to OTG_USB_DP. The code to set PA12 as GPIO looks like below
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_12;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
I mean what should I do to set PA12 as OTG_USB_DP after these codes. Does HAL_GPIO_DeInit(GPIOA, GPIO_PIN_12) works?
BR
Yang
If you meant by this you already configured the IO as inputs then you need to switch to USB function, yes. and enable/configure the USB after.
2024-12-23 03:25 AM
Get CubeMX to configure it, then examine the code that it generates?
2024-12-23 03:26 AM - edited 2024-12-23 03:26 AM
Hello,
The issue is not clear.
I can set PA11 and PA12 for USB in CubeMx for STM32U595.
PS: There is no STM32U595VGT6 part number
2024-12-23 04:13 AM - edited 2024-12-23 04:15 AM
HELLO @Yang Yang
Infact, PA11 and PA12 provide OTG_HS additional functions, and they are not alternate functions:
When you enable the USB_OTG_HS (as done by my college @SofLit ) those Pins are automatically set to OTG_HS additional 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.
2024-12-23 05:27 AM
Hello, ST experts
Yes, actually I found that OTG_HS_DP is additional function. But I don't know how to configure it. In cubemx generated framework is that done by MX_USB_OTG_HS_PCD_Init()?
BR
Yang
2024-12-23 05:38 AM
@Yang Yang wrote:
Yes, actually I found that OTG_HS_DP is additional function. But I don't know how to configure it. In cubemx generated framework is that done by MX_USB_OTG_HS_PCD_Init()?
You can use CubeMx and configure USB pins as I showed above.
2024-12-23 05:48 AM
Hello @Yang Yang
It is not required to add the code to configure the USB DP/DM as those pins are directly connected to USB as soon as this peripheral is enabled.
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.
2024-12-23 05:49 AM
Hello ST experts
In cubemx generated code framework, Does HAL_GPIO_DeInit(GPIOA, GPIO_PIN_12) can set PA12 to OTG_HS_DP function?
BR
Yang
2024-12-23 05:53 AM
The pins config is not generated. These pins are used directly by the USB as soon as the USB is enabled.
2024-12-23 05:59 AM - edited 2024-12-23 05:59 AM
PA12 is internally set to OTG_HS_DP as soon as you Enable your USB_OTG as i said on my second comment (no code needed to do that).
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.