cancel
Showing results for 
Search instead for 
Did you mean: 

USB on STM32H503

romp
Associate
I'm having problems enabling USB on STM32H503 and I'm hoping there's a simple solution that you can point me to.
 
The problem happens on both my custom board (STM32H503CBT6-based), as well as on MB1814B (STM32H503RBT6-based).  Here's the simplest repro:
  1. in STM32CubeIDE, latest available version (1.17.0), create new STM32 project for STM32H503RBT6 core
  2. in .ioc, enable I-Cache, SWD, and USB.  In "Middleware and Software Packs", the USBX section, enable "Core System", "Device CoreStack FS", "CDC ACM"
  3. close .ioc, build the project
  4. connect MB1814B to the host on both sides
  5. flash the compiled firmware
 
Result:
  • the host only sees the piped-through-SWD-end Virtual COM, but fails to see the USB connection on the device side
  • the onboard firmware fails to invoke the USB interrupt
  • the core fails to initiate hardware handshake

Similar steps on my custom H503CBT-based device result in similar outcomes: no USB connection, no IRQ ever being invoked, no hardware handshake

To give you an idea of my experience level, previously I designed, built, brought up and shipped several STM32-based devices that use USB CDC stack.  The devices were based on F4, G0, and G4 cores.  This is the first time I'm using H5 core.

Troubleshooting steps I've done on my board:
  1. in debugger, verified that all the obvious IDE-generated init functions are called (they are), the clock and IRQ are enabled (they are), the IRQ vector points to my `USB_DRD_FS_IRQHandler()` handler and not the weak handler (ditto), and that the registers contain the expected values at the start of the forever loop (they do, as far as I can tell)
  2. verified power on all VDD pins (3v3 nominal, 3v282 - 3v297 measured), verified my board for shorts, etc.  Removed the LDO and powered the board from the bench, verified power consumed
  3. swapped the microcontroller on my board just in case
  4. removed the USB ESD protection from my board, just in case
  5. removed all other devices from my board, just in case
  6. hooked up USB_DM and USB_DP lines (PA11 and PA12) to oscilloscope -- no signals on these lines
  7. tried to clock USB from both the HSI48 and HSE (25 MHz-based)
  8. changed the core's clock between 25 MHz and 250 MHz
  9. swapped the USBX to the old USB stack that I last used few months ago on STM32G0 -- same result
  10. swapped the USBX to the same old USB stack taken from https://github.com/STMicroelectronics/stm32-mw-usb-device/tree/2022e75b01a499b17acd17d28691b1ed5bbef2dc -- same result

Troubleshooting I've done on MB1814B:
  1. verified that the jumpers are set correctly for the USB Device configuration: SB1, SB7, SB14 -- off, SB4 and SB8 -- short
  2. verified power before and after plugging the device-side USB-C
  3. found that the board has silkscreen for R34 and R35 mixed up
  4. verified that other devices on the board work fine: PWM, UART, I2C
 
Thank you very much for looking into it!
1 REPLY 1
romp
Associate

So, turns out enabling SOF fixes this problem on both devices:

hpcd_USB_DRD_FS.Init.Sof_enable = ENABLE;

// ...

HAL_PCD_Init(&hpcd_USB_DRD_FS);

Is there a way to enable USB without SOF?