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:17 AM - edited 2024-12-23 06:18 AM
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
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.