Skip to main content
Graduate II
December 14, 2023
Solved

Setting Lower Priority for USB set CDC_Receive_FS interrupt and callback

  • December 14, 2023
  • 4 replies
  • 2847 views

Hi,

I have configured a USB virtual com port on an STM32F373 successfully.  

I noticed the priority for the CDC_Receive_FS interrupt/callback seems to be set to the highest level.  I currently have a timer interrupt ( time critical event ) which cannot be delayed or interrupted by the USB interrupt.  Is it ok to set the USB priority to a lower level than my timer's priority?  

My timer interrupt needs to handle a time-critical task but is very short so I'm thinking it should not interfere with the USB handling CDC_Receive_FS quickly enough to prevent a USB overflow.

What is the best way to set the USB's interrupt priority lower than the timer's interrupt priority?

Thank you,

    This topic has been closed for replies.
    Best answer by gbm

    1. In CubeMX you may set interrupt priorities in NVIC settings.

    2. USB is not time-critical, it's insensitive to millisecond-range delays. I usually set the USB IRQ priority to one of the lowest level, maybe 1 or 2 above the lowest which I use for software-generated IRQs.

    4 replies

    Super User
    December 14, 2023

    Just try it.

    LMorr.3Author
    Graduate II
    December 15, 2023

    The solution for me was to set to a lower priority in the HAL_PCD_MspInit function found in the CubeMX generated USB_DEVICE/Target/usbd_conf.c file.  The uC's built-in USB FS peripheral does not appear to require it run at the highest level priority, but difficult to simulate/trigger interrupts interrupting other interrupts to confirm.  Seems to work well.

    gbmAnswer
    Graduate
    December 15, 2023

    1. In CubeMX you may set interrupt priorities in NVIC settings.

    2. USB is not time-critical, it's insensitive to millisecond-range delays. I usually set the USB IRQ priority to one of the lowest level, maybe 1 or 2 above the lowest which I use for software-generated IRQs.

    LMorr.3Author
    Graduate II
    December 15, 2023

    Thanks for pointing me to the NVIC settings.  That seems to be the best place to set all my interrupt levels instead of scattering them through code.  

    Good to know you also lower the USB priority and confirm the working ms delay range.

     

    Super User
    December 15, 2023

    difficult to simulate/trigger interrupts interrupting other interrupts to confirm.  

    On Cortex-M, not hard at all. Any NVIC interrupt entry can be triggered by software.