Skip to main content
Visitor II
December 23, 2024
Solved

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

  • December 23, 2024
  • 3 replies
  • 1610 views

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.
    Best answer by mƎALLEm

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

    3 replies

    Super User
    December 23, 2024

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

    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

     

    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

    Yang YangAuthor
    Visitor II
    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

    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.