cancel
Showing results for 
Search instead for 
Did you mean: 

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

Yang Yang
Associate II

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

11 REPLIES 11

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


@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 on "Accept as Solution" on the reply which solved your issue or answered your question.