cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F2 USB HOST interrupt flood

jean
Senior

Hello,

I get an issue with the USB HOST configured on my STM32F2

This USB HOST driver works well in my case, but it appears that the interrupt OTG_HS_IRQHandler is called too frequently (when I plug a device on the USB HOST post) and it's flooding my CPU, resulting by consuming about 40% of my CPU usage (checked on my oscilloscope).

I've already had the same issue when working on a STM32H7, and reading the post https://community.st.com/t5/stm32-mcus-products/stm32f4-stm32f7-usb-host-core-interrupt-flood/td-p/436225 helped to found this ST driver hack to fix this issue. The hack consist of re-enable NAK interrupt in HAL_HCD_IRQHandler

When doing the same hack in the STM32F2 driver, the issue is not fixed :

/* Handle Host SOF Interrupts */
    if(__HAL_HCD_GET_FLAG(hhcd, USB_OTG_GINTSTS_SOF))
    {
      /* workaround for the interrupts flood issue: re-enable NAK interrupt */
      for (i = 0U; i < hhcd->Init.Host_channels; i++) USBx_HC(i)->HCINTMSK |= USB_OTG_HCINT_NAK; 

      HAL_HCD_SOF_Callback(hhcd);
      __HAL_HCD_CLEAR_FLAG(hhcd, USB_OTG_GINTSTS_SOF);
    }

Do you have ideas of how I can fix this CPU load overhead?

Thanks!

0 REPLIES 0