Max. allowed delay between interrupts?
Posted: 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):
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?
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?