I've been scratching my head over this for an hour or so and finally nailed down that it's obviously an interrupt issue.
Basically what I'm needed is a timer every 25 microseconds to update an LED Matrix, and then I'm using the Wire library to read in a Wii nunchuk data.
If I disable the TimerOne, I get no issues, however I need that 25uS clock cycle for my LEDs.
void setup()
{
Serial.begin(57600);
Serial.println("Booting up.....");
is_connected = 0;
nunchuck_pre_init();
Timer1.initialize( 25 ); // initialize timer1, 25 microseconds refresh rate.
// Adjust as you please. Too slow makes LEDs flicker.
// Too fast and the interrupt may chew into your processing speed!
Timer1.attachInterrupt( ShipLED ) ; // attaches routine to drive LEDs
}
In loop() I'm pretty much just polling for nunchuk data which looks something like:
static void nunchuck_get_data()
{
send_zero (3); // send the request for next bytes
cnt = 0;
Wire.requestFrom (WII_NUNCHUCK_TWI_ADR, WII_TELEGRAM_LEN); // request data from nunchuck
while (Wire.available ())
{
outbuf[cnt] = nunchuk_decode_byte (Wire.receive ()); // receive byte as an integer
cnt++;
}
if (cnt >= 5)
{
nunchuck_save ();
}
cnt = 0;
clearTwiInputBuffer();
}
Is there any way to get around this? Thanks!
Chris