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

The CMSIS-Driver USBH_FS requires:

  • Setup of USB clk to 48MHz
  • Configuration of USB_OTG_FS
  • Optional Configuration for VBUS Power Pin:
    • Configure arbitrary pin in GPIO_Output mode and add User Label: USB_OTG_FS_VBUS_Power
  • Optional Configuration for Overcurrent Pin:
    • Configure arbitrary pin in GPIO_Input mode and add User Label: USB_OTG_FS_Overcurrent
Note
The User Label name is used to connect the CMSIS-Driver to the GPIO pin.

The example below uses correct settings for STM32F746G-Discovery Board:

  • USB_OTG_FS Mode: Host_Only
  • VBUS Power Pin: PD5
  • Overcurrent Pin: PD4

The STM32CubeMX configuration 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_FS: Mode=Host_Only
  2. Configure USB_OTG_FS_VBUS_Power pin:
    • Click in chip diagram on pin PD5 and select GPIO_Output
  3. Configure USB_OTG_FS_Overcurrent pin:
    • Click in chip diagram on pin PD4 and select GPIO_Input

Clock Configuration tab

  1. Configure USB Clock: "To USB (MHz)": 48

Configuration tab

  1. Under Connectivity open USB_OTG_FS 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
      PA11 USB_OTG_FS_DM Alternate No pull-up and no..High .
      PA12 USB_OTG_FS_DP Alternate No pull-up and no..High .
      - NVIC Settings: enable interrupts
      Interrupt Table Enable Preemption Priority Sub Priority
      USB On The Go FS global interrupt ON 0 0
      - Parameter Settings: not used
    • User Constants: not used
    • Click OK to close the USB_OTG_FS Configuration dialog
  2. Under System open GPIO Pin Configuration
    • Enter user label for USB_OTG_FS_VBUS_Power and USB_OTG_FS_Overcurrent pin
      Pin Name Signal on Pin GPIO mode GPIO Pull-up/Pull..Maximum out User Label
      PD5 n/a Output Push Pull No pull-up and no..n/a USB_OTG_FS_VBUS_Power
      PD4 n/a Input mode No pull-up and no..n/a USB_OTG_FS_Overcurrent
    • Click OK to close the Pin Configuration dialog