Max. allowed delay between interrupts?

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
Posts: 2
Joined: Sat Jul 11, 2015 12:10 am

Max. allowed delay between interrupts?

Post by rsn8887 » Sat Jul 11, 2015 12:37 am

I found conflicting docs about interrupt latency in V-USB.

In usbdrv.h is a statement that interrupts should not be disabled for longer 25 us. On the V-USB troubleshooting page, it states that there can be a few milliseconds.

In my project RetroAdapterMod (a mod of Paul Qureshi's RetroAdapter), I am using some microsecond timing that is crucial to communicate with PSX and Gamecube controllers.

I use only interrupt-based USB communication to send the controller data to the host:
(the real code is more involved, but this is the basic idea):

Code: Select all

for (;;)
   if (usbInterruptIsReady())
     readGCData(); //<--- this is a timing critical assembler routine that can not be disturbed, changes report

Without the cli() and sei() I was getting random and host-dependent bitflips in the report variable. My guess is that the cycle timing in the readGCData function was disturbed by interrupts. After adding the cli() and sei() it works perfect. But I am worried about stability and compatibility with different hosts, because I disable interrupts for a potentially long time of several ms or more.

Is this the correct way to do this?

Rank 4
Rank 4
Posts: 481
Joined: Mon Aug 25, 2008 8:45 pm

Re: Max. allowed delay between interrupts?

Post by ulao » Mon Jul 13, 2015 11:43 pm

Key word is "worried". If the USB is "interrupted" in any way it will not work, thus if it's working stop worrying ;)

BTW: that comment was for an older v-usb build, I believe currently there is no restriction, however if you set the poll rate to 8ms then you need to finish all work with in 8 ms.

for a much better approach see Rapheals work ... dex_en.php
Yes this is for GameCube/n64 but read "USB Sync."

PSX code is much less of a concern and very easy to work with. Especially if you use the ISP.

Post Reply