overcoming 30ms usb requiremnet.

Skip to first unread message


Sep 8, 2021, 12:29:11 PM9/8/21
to LUFA Library Support List

I see the USB_USBTask requires an update every 30ms or less but I have to issue some long waits in my code. Some around 500ms. Is there some way to tell the USB host that I'm busy. I thought about using an ISR but I really need to avoid any interrupts.  During this 500ms I do a lot of time sensitive code.

One of the biggest issues with v-USB I had was that when doing anything that was time sensitive, like a PWM signal around 100ns pulses would fail if the CPU had to issue an interrupt to keep the host happy. Will I have this same general issue with LUFA? If so can I detect if a int interrupt occurred so I can flag the communication as dirty or can I return NAK and tell the host I'm busy.

Parallel to that, is there any safe way of delaying 500ms without the USB dropping.

Dean Camera

Sep 18, 2021, 12:06:26 AM9/18/21
to lufa-s...@googlegroups.com, ulao

Hi Ulao,

Unfortunately no, you're limited to the timeouts specified in the USB specification, which are (from what I remember) quite short in some cases -- around 50ms or so per packet during a control request transaction, with a more generous timeout for the period between the initial control request setup packet being sent by the host and acknowledged by the device.

Interrupts are the way to go here if you really need it, usually by driving your time-sensitive code using interrupts with the main loop running the USB code. PWM is generally produced by the on-chip hardware timers rather than bit-banged with software to ensure that it remains glitch free.

- Dean

You received this message because you are subscribed to the Google Groups "LUFA Library Support List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lufa-support...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lufa-support/c38d2b36-46d4-46bf-8678-ef3550588d4cn%40googlegroups.com.


Sep 18, 2021, 4:53:22 PM9/18/21
to LUFA Library Support List
Alright, understood, IIRC, there was a way to know when an ISR was fired? If so I could use that to make my data dirty. 
Reply all
Reply to author
0 new messages