2026-03-26 10:05 PM - last edited on 2026-03-27 3:18 AM by mƎALLEm
Board:B-L4S5I-Iot-01A discovery kit
MCU: STM32L4s5Vit6
Hello ,
We have an application in which we are using the USB_OTG interface configured in host-only mode with the USB CDC class.
Our requirement is to receive data at a rate of once per second through this interface. However, upon configuring the USB CDC class, the USB_OTG_FS global interrupt gets enabled automatically.
In our application, we want to minimize the use of interrupts, as frequent interrupts may impact overall system performance. Therefore, we would prefer a polling-based approach, where data can be read only when required rather than being interrupt-driven.
Could you please advise if it is possible to:
Any guidance or recommended approach for achieving this would be highly appreciated.
Thank you.
2026-03-27 1:06 AM
It is possible to use polling for USB, it just doesn't make too much sense for any reasonable application. The statement "frequent interrupts may impact overall system performance" is not true -> actually the use of polling is what reduces the system performance.
My favorite citation from Zephyr RTOS documentation:
"Use threads to handle processing that cannot be handled in an ISR."
2026-03-27 3:03 AM
Putting aside the question of "impact overall system performance", in which I agree with @gbm :
Any system which is purely interrupt-based is very simple to convert to polled: simply poll for the flag(s) which trigger the interrupt, and if set, call the original interrupt service routine.
Whether this would work properly is another question - in case of USB host, probably yes.
JW
2026-03-27 5:54 AM
Hi @DdAz
I assume in device mode, you can use SOF interrupt callback associated to bInterval time base. In interrupt transfer, the host can poll the device only based on defined endpoint bInterval value, host should ensure polling at this rate.
According to STM32CubeL4 USB Host examples, the host stack always uses interrupts. I have not seen any official example of a polling only USB host driver in Cube; implementing one would likely require custom LL/HAL code.
I assume, you can start with L4 HAL to disable global interrupt here.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.