cancel
Showing results for 
Search instead for 
Did you mean: 

Setting Lower Priority for USB set CDC_Receive_FS interrupt and callback

LMorr.3
Senior II

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,

1 ACCEPTED SOLUTION

Accepted Solutions
gbm
Lead II

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.

View solution in original post

5 REPLIES 5
Pavel A.
Evangelist III

Just try it.

LMorr.3
Senior II

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.

gbm
Lead II

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.

Pavel A.
Evangelist III

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.

 

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.