Go Down

Topic: Update I2C reference page (Read 790 times) previous topic - next topic

Keshka

After a day of debugging and finally finding a post in the forum I discover that: "You can't use the I2C routines inside an interrupt service routine(ISR). This is because they use a timer that requires the interrupts to be running and inside an ISR interrupts are disabled."

This should be included on the page http://arduino.cc/en/Reference/Wire

Keshka

retrolefty


After a day of debugging and finally finding a post in the forum I discover that: "You can't use the I2C routines inside an interrupt service routine(ISR). This is because they use a timer that requires the interrupts to be running and inside an ISR interrupts are disabled."

This should be included on the page http://arduino.cc/en/Reference/Wire

Keshka


That's the same reason a simple delay(xxxx) command won't work inside a ISR routine unless you re-enable the global interrupt bit, which can then be a very complex situation where you have nested ISR working. So it's not a fault of the I2C library as such. Even trying to do serial.read inside a ISR will not function.

The general recommendation and practice is that user ISR routines should be as short and simple as possible, just set or reset global flag variables and let the main loop function deal with what that means and should be done. It's like living in a house with lots of people but a single bathroom, do your business and get out.  ;)

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy