Page 1 of 1

Max. allowed delay between interrupts?

Posted: Sat Jul 11, 2015 12:37 am
by rsn8887
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 (;;)
{
   usbPoll();
   if (usbInterruptIsReady())
   {
     cli();
     readGCData(); //<--- this is a timing critical assembler routine that can not be disturbed, changes report
     sei();
     USBSetInterrupt(report,len);
   }
}


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?

Re: Max. allowed delay between interrupts?

Posted: Mon Jul 13, 2015 11:43 pm
by ulao
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 http://www.raphnet.net/electronique/gc_ ... 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.