Pages: [1]   Go Down
Author Topic: Update I2C reference page  (Read 730 times)
0 Members and 1 Guest are viewing this topic.
Summerville, Oregon
Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
I like this little thing!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 362
Posts: 17305
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.  smiley-wink
Logged

Pages: [1]   Go Up
Jump to: