I have a quick question regarding using interrupts. I am using one of the timers to attach an interrupt handler to poll my SPI device (Playstation2 controller) since there is no way for the SPI device to trigger an external interrupt. I want to poll this device approximately 100 times a second.
I have the interrupt handler working as expected, and the entire handler takes 0.8mS to execute (The device is slow, has to be bit-banged at about 100kHz). I left the overflow at 65535, but set the pre-scalar at 10 so that it will overflow about 110 times a second, roughly what my desired polling rate is. For debugging, I am dumping stuff over SerialUSB configured at 115200baud. Everything works as expected.
The gotcha, however, is that I am trying to also send commands to the Maple via SerialUSB and doing something like
if (SerialUSB.available())
{
command = SerialUSB.read();
processCommand(command);
command = 0;
}
I notice that the processCommand does not appear to get called. In fact, I can set the LED pin high right before i do the SerialUSB.read() and the LED never triggers. This tells me that Maple never sees data in the SerialUSB buffer. :(
Granted, I will not be using SerialUSB in the finished project, I am only using it for debugging. I am curious, however, as to why it is not working as expected.