Wire and Timer Interrupt conflict?

Hi all,

I'm trying to get accelerometer data from a Wii nunchuk as described in: http://www.windmeadow.com/node/42

The code there puts the "Wire.requestFrom (0x52, 6)" request in the loop() function. I would like to make the request from a timed interrupt service routine. However, as soon as I put "Wire.requestFrom (0x52, 6);" into my ISR, the program crashes --- it does not go pass the "Wire.requestFrom (0x52, 6);" line of code.

Is there some inherent conflict between accessing wire data and timed interrupts?

Please help. THX! :-?

Is there some inherent conflict between accessing wire data and timed interrupts?

Do the wire routines require interrupts enabled? While a interrupt service routine is executing, all other interrupts are disabled unless you re-enable them inside the timer ISR function.

Lefty

Thank you that solved the problem! Yes, the wire routine IS interrupt driven (TWI)... so I just made sure inside my ISR I have "sei();" as the first line which keeps the interrupts enabled. now I have a "nested interrupt"... where TWI routines are called within my TIMER2 ISR.

thanks for the tip.

Doing a whole lot inside an interrupt is usually a bad idea. I'd suggest setting a flag in the interrupt, and testing the flag in loop(). There are more sophisticated approaches, adding a "job" to a queue, but setting a flag should be fine for this.

Gorilla could you elaborate any on the more sophisticated approaches you mentioned. i am having the same problem, but all of the things executing inside my code do really need to be inserted into the loop at that time, and cannot wait for the loop to return to check a flag.