Skip to main content
NikDobro
Associate II
October 19, 2018
Solved

Nucleo-144 (stm32f767). USB FS. Changing pins DP, DM from PA11, PA12, to PB14, PB15 doesn't work.

  • October 19, 2018
  • 2 replies
  • 1177 views

Hi, collegs!

I have NUCLEO-144 (STM32F767) board. I started USB-HID example. It worked. Then I have change in "HAL_PCD_MspInit" function pins from pins DP, DM from PA11, PA12, to PB14, PB15.

On my own board with STM32F767 USB is connected to this pins.

I just want to see, that DP pin is pulled up after initialization and usb start (without V power detection).

So, I was very wounder! After changes, initialization and usb start. The pin PA12 (DP) is pulled up!!! And pin PB15 isn't!

I have no idea why it works so...

In datasheet PA11 (OTG_FS_DM), PA12 (OTG_FS_DP), PB14 (OTG_HS_DM), PB15 (OTG_HS_DP).

May be the problem is in that difference FS (Pins A), HS (Pins B)?

I have change only "HAL_PCD_MspInit" function.

void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
{
 GPIO_InitTypeDef GPIO_InitStruct;
 
 /* Configure USB FS GPIOs */
// __HAL_RCC_GPIOA_CLK_ENABLE();
 
// /* Configure DM DP Pins */
// GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12);
// GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
// GPIO_InitStruct.Pull = GPIO_NOPULL;
// GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
// GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
// HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 
 
 __HAL_RCC_GPIOB_CLK_ENABLE();
 
/* Configure DM DP Pins */
 GPIO_InitStruct.Pin = (GPIO_PIN_14 | GPIO_PIN_15);
 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 GPIO_InitStruct.Pull = GPIO_NOPULL;
 GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
 GPIO_InitStruct.Alternate = GPIO_AF12_OTG_HS_FS;
 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 
 
 /* Enable USB FS Clocks */
 __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
 
 /* Set USBFS Interrupt priority */
 HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0);
 
 /* Enable USBFS Interrupt */
 HAL_NVIC_EnableIRQ(OTG_FS_IRQn);
}

Can anybody help me? Why I have no DP up signal after usb start.

    This topic has been closed for replies.
    Best answer by Tesla DeLorean

    >>May be the problem is in that difference FS (Pins A), HS (Pins B)?

    Well they are two entirely separate controllers, so you'd need to carry that through the code completely.

    It is referred to as HS_FS because it is capable of doing both modes, on its pins, not on the pins of both controllers.

    2 replies

    Tesla DeLorean
    Tesla DeLoreanBest answer
    Guru
    October 19, 2018

    >>May be the problem is in that difference FS (Pins A), HS (Pins B)?

    Well they are two entirely separate controllers, so you'd need to carry that through the code completely.

    It is referred to as HS_FS because it is capable of doing both modes, on its pins, not on the pins of both controllers.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    NikDobro
    NikDobroAuthor
    Associate II
    October 19, 2018

    Yeap! That was a good point!

    I've change

    1. the "instance" in usb handle type structure to "USB_OTG_HS";
    2. Enable USB HS Clocks in "HAL_PCD_MspInit" function.

    And it works! Now I have PA12 not working and PB15 is working. So what I wanted.

    Thanks!

    USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev)
    {
     /* Set LL Driver parameters */
     hpcd.Instance = USB_OTG_HS;
     hpcd.Init.dev_endpoints = 4;
     hpcd.Init.use_dedicated_ep1 = 0;
     hpcd.Init.ep0_mps = 0x40;
     hpcd.Init.dma_enable = 0;
     hpcd.Init.low_power_enable = 1;
     hpcd.Init.phy_itface = PCD_PHY_EMBEDDED;
     hpcd.Init.Sof_enable = 0;
     hpcd.Init.speed = PCD_SPEED_FULL;
     hpcd.Init.vbus_sensing_enable = 0;
     hpcd.Init.lpm_enable = 0;
     
     /* Link The driver to the stack */
     hpcd.pData = pdev;
     pdev->pData = &hpcd;
     
     /* Initialize LL Driver */
     HAL_PCD_Init(&hpcd);
     
     HAL_PCDEx_SetRxFiFo(&hpcd, 0x80);
     HAL_PCDEx_SetTxFiFo(&hpcd, 0, 0x40);
     HAL_PCDEx_SetTxFiFo(&hpcd, 1, 0x80);
     
     return USBD_OK;
    }
     
    void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
    {
     GPIO_InitTypeDef GPIO_InitStruct;
     
     /* Configure USB FS GPIOs */
    // __HAL_RCC_GPIOA_CLK_ENABLE();
     
    // /* Configure DM DP Pins */
    // GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12);
    // GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    // GPIO_InitStruct.Pull = GPIO_NOPULL;
    // GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
    // GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
    // HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 
     
     __HAL_RCC_GPIOB_CLK_ENABLE();
     
    /* Configure DM DP Pins */
     GPIO_InitStruct.Pin = (GPIO_PIN_14 | GPIO_PIN_15);
     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
     GPIO_InitStruct.Pull = GPIO_NOPULL;
     GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
     GPIO_InitStruct.Alternate = GPIO_AF12_OTG_HS_FS;
     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 
     
     /* Enable USB HS Clocks */
     __HAL_RCC_USB_OTG_HS_CLK_ENABLE();
     
     /* Set USBFS Interrupt priority */
     HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0);
     
     /* Enable USBFS Interrupt */
     HAL_NVIC_EnableIRQ(OTG_FS_IRQn);
    }