STM32Cube  Version 2.0
Create Projects for STM32F2 Series with STM32Cube HAL and STM32CubeMX
 All Files Pages
CMSIS-Driver USBH_HS Setup

The CMSIS-Driver USBH_HS requires:

  • Setup of USB clock to 48MHz (if internal Full-speed Phy is used)
  • Configuration of USB_OTG_HS
  • Optional Configuration for VBUS Power Pin:
    • Configure arbitrary pin in GPIO_Output mode and add User Label: USB_OTG_HS_VBUS_Power
  • Optional Configuration for Overcurrent Pin:
    • Configure arbitrary pin in GPIO_Input mode and add User Label: USB_OTG_HS_Overcurrent
Note
The User Label name is used to connect the CMSIS-Driver to the GPIO pin.

Valid settings for various evaluation boards are listed in the table below:

Peripheral Resource MCBSTM32F200 STM3220G-EVAL
USB_OTG_HS Mode External Phy:Host_Only External Phy:Host_Only
VBUS Power output pin PC2 n/a
Overcurrent input pin n/a n/a

For different boards, refer to the hardware schematics to reflect correct setup values.

The STM32CubeMX configuration for MCBSTM32F200 with steps for Pinout, Clock, and System Configuration are listed below. Enter the values that are marked bold.

Pinout tab

  1. Configure USBH mode
    • Peripherals USB_OTG_HS: External Phy: Mode=Host_Only
  2. Configure USB_OTG_HS_VBUS_Power pin:
    • Click in chip diagram on pin PC2 and select GPIO_Output

Clock Configuration tab

  1. AHB frequency should be higher than 30 MHz

Configuration tab

  1. Under Connectivity open USB_OTG_HS Configuration:
    • DMA Settings: not used
    • GPIO Settings: review settings, no changes required
      Pin Name Signal on Pin GPIO mode GPIO Pull-up/Pull..Maximum out User Label
      PA3 USB_OTG_HS_ULPI_D0 Alternate No pull-up and no..High .
      PA5 USB_OTG_HS_ULPI_CK Alternate No pull-up and no..High .
      PB0 USB_OTG_HS_ULPI_D1 Alternate No pull-up and no..High .
      PB1 USB_OTG_HS_ULPI_D2 Alternate No pull-up and no..High .
      PB5 USB_OTG_HS_ULPI_D7 Alternate No pull-up and no..High .
      PB10 USB_OTG_HS_ULPI_D3 Alternate No pull-up and no..High .
      PB11 USB_OTG_HS_ULPI_D4 Alternate No pull-up and no..High .
      PB12 USB_OTG_HS_ULPI_D5 Alternate No pull-up and no..High .
      PB13 USB_OTG_HS_ULPI_D6 Alternate No pull-up and no..High .
      PC0 USB_OTG_HS_ULPI_STP Alternate No pull-up and no..High .
      PI11 USB_OTG_HS_ULPI_DIR Alternate No pull-up and no..High .
      PH4 USB_OTG_HS_ULPI_NXT Alternate No pull-up and no..High .
      - NVIC Settings: enable interrupts
      Interrupt Table Enable Preemption Priority Sub Priority
      USB On The Go HS global interrupt ON 0 0
      - Parameter Settings: not used
    • User Constants: not used
    • Click OK to close the USB_OTG_HS Configuration dialog
  2. Under System open GPIO Pin Configuration
    • Enter user label for USB_OTG_HS_Overcurrent pin
      Pin Name Signal on Pin GPIO mode GPIO Pull-up/Pull..Maximum out User Label
      PC2 n/a Output Push Pull No pull-up and no..n/a USB_OTG_HS_VBUS_Power
    • Click OK to close the Pin Configuration dialog