2023-12-14 12:55 PM
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,
Solved! Go to Solution.
2023-12-15 08:15 AM
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.
2023-12-14 02:38 PM
Just try it.
2023-12-15 06:58 AM
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.
2023-12-15 08:15 AM
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.
2023-12-15 12:23 PM
> 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.
2023-12-15 12:26 PM - edited 2023-12-15 12:26 PM
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.