STM32-OTG-CDC

From Embedded Workshop
Jump to navigation Jump to search

Using STM32CubeMX, Choose:

  • New Project-> Start My project from ST Board -> ACCESS TO BOARD SELECTOR -> in Commercial Part Number box, type "NUCLEO-F446RE"
  • Double-click the NUCLEO-F446RE board in the lower right section
  • "Initialize all peripherals with their default Mode ?" - Select "Yes"
  • "Pinout & Configuration" tab, select Connectivity -> USB_OTG_FS -> Mode -> Device_Only
At this point, USB pins get selected and configured
PA11  "USB_OTG_FS_DM"
PA12  "USB_OTG_FS_DP"
  • "Pinout & Configuration" tab, select Middeleware -> USB_DEVICE -> "Class For FS IP" -> "Communication Device Class (Virtual Port Com)"
  • "Pinout & Configuration" tab, select Connectivity -> UART2 - This should already be selected, and configured as follows:
Mode: Asynchronous
Hardware Flow Control (RS232): Disable
Basic Parameters
  Baud Rate: 115200
  Word Length: 8 Bits (including Parity)
  Parity: None
  Stop Bits: 1
Advanced Parameters
  Data Direction: Receive and Transmit
  Over Sampling: 16 Samples

UART2 will be used as a serial debug port, already connected to the STM32-F103 JTAG hardware, to function as a USB Com Port
  • "Clock Configuration" tab - a pop-up dialog, Clock configuration, asks "Do you want to run automatic clock issues solver "?, select "Yes"
For USB, a 48 MHz clock is required.  The automatic clock solver should adjust parameters such that the output clock, "To USB (MHz)" indicates 48 MHz.
The STM32-F446RE has plenty of clock dividers, and three PLLs, and will divide the 72MHz clock from "PLL" by 3, creating a 48MHz USB clock.
Links to reference material:
https://www.youtube.com/watch?v=h9T0RTu9Muc&ab_channel=STMicroelectronics  - 48 minutes, poor audio
https://www.youtube.com/watch?v=7oED-m34EKk&ab_channel=MutexEmbedded-Education - 8 min, 44 seconds,