STM32Cube  Version 2.0
Create Projects for STM32H7 Series with STM32Cube HAL and STM32CubeMX
 All Files Functions Variables Macros Pages
CMSIS-Driver USBD_OTG Setup

The CMSIS-Driver USBD_OTG requires:

  • Setup of USB clock to 48MHz
  • Configuration of USB_OTG_FS as Device_Only

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

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

Pinout tab

  1. Configure USBD mode
    • Peripherals USB_OTG_FS: Mode=Device_Only

Clock Configuration tab

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

Configuration tab

  1. Under Connectivity open USB_FS Configuration:
    • Parameter Settings: not used
    • User Constants: not used
    • NVIC Settings: disable interrupts
      Interrupt Table Enabled Preemption Priority Sub Priority
      USB OTG FS global interrupt OFF 0 0
      - GPIO Settings: review settings, no changes required
      Pin Name Signal on Pin GPIO Pin State GPIO mode GPIO Pull-up/Pull..Maximum out Fast Mode User Label
      PA11 USB_OTG_FS_DM n/a Alternate No pull-up and no..Very High n/a .
      PA12 USB_OTG_FS_DP n/a Alternate No pull-up and no..Very High n/a .
      - Click OK to close the USB_OTG_FS Configuration dialog

Generate source code by click on Generate source code tool on toolbar, or select project Generate Code, or or press keys Ctrl + Shift + G.