Showing results for 
Search instead for 
Did you mean: 

STM32F401 USB CDC stuck in IRQ loop

Associate II
Posted on February 18, 2015 at 10:27


I'm using the USB Host library 2.1.0 (with USB_OTG_FS) on an STM32F401CD. Using the USB CDC code I'm having the following issue:

When the STM32 is connected to a PC but no application on the PC has the port open, the STM32 gets stuck in an interrupt loop:

  • USBD_OTG_ISR_Handler (at inepint handler)
  • DCD_HandleInEP_ISR (at emptyintr handler)
  • DCD_WriteEmptyTxFifo

Every single time the interrupt exits, it is called again - meaning absolutely no other code is able to run until a terminal application is connected.

It's all open source and on GitHub - the relevant function is here:

Do you have any idea what could be causing this problem?

I also have a second question about turning off the USB peripheral. When it's disconnected from USB my device goes to sleep - and obviously USB needs powering down to reduce power consumption. Are there any examples of doing this? Whenever I have tried I haven't get been able to power down USB and bring it back up in a usable state.


- Gordon

#vcp #stm32 #usb #cdc #sleep
Associate II
Posted on February 18, 2015 at 10:54

Just stepped through more: you get repeats of 5x DCD_WriteEmptyTxFifo and then 1x usbd_cdc_SOF... But so often that no code can run outside of IRQs.

It appears to happen because right at the start, Handle_USBAsynchXfer has sent some data with DCD_EP_Tx.

However, I also use this firmware on an STM32F103 (with the USB library for that) and that does exactly the same thing but is able to keep working perfectly fine.