Skip to main content
Yang Yang
Associate III
December 23, 2024
Solved

how to set PA11&PA12 to USB_OTG_HS pin after it is set to GPIO

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

This topic has been closed for replies.
mƎALLEm
mƎALLEmBest answer
ST Technical Moderator
December 23, 2024

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

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.

11 replies

Andrew Neil
Super User
December 23, 2024

Get CubeMX to configure it, then examine the code that it generates?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
mƎALLEm
ST Technical Moderator
December 23, 2024

Hello,

The issue is not clear.

I can set PA11 and PA12 for USB in CubeMx for STM32U595.

SofLit_0-1734953121645.png

PS: There is no STM32U595VGT6 part number

 

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
STTwo-32
ST Technical Moderator
December 23, 2024

HELLO @Yang Yang 

Infact, PA11 and PA12 provide OTG_HS additional functions, and they are not alternate functions:

STTwo32_0-1734956103732.png

When you enable the USB_OTG_HS (as done by my college @mƎALLEm ) 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.
Yang Yang
Yang YangAuthor
Associate III
December 23, 2024

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

mƎALLEm
ST Technical Moderator
December 23, 2024

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

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.