Go Down

Topic: Wire.h and timer interrupts (Read 1 time) previous topic - next topic



I am trying to read an ADXL accelerometer via I2C using the Wire library at regular intervals.  A periodic interrupt to fill a global buffer seems like a reasonable solution, but calls to Wire.endTransmission() crashes if called from within an interrupt service routine.  The amount of data I am reading is pretty minimal and the read takes only about 1 millisecond.  I am running the ISR at intervals of about 10 msec, so I think timing is not a problem.

Does anyone have ideas about why the Wire library and ISR might interfere with on another?  Thank you,



I  have the same problem, want to read from I2C inside an ISR. I found out that Wire use interrupts and inside an ISR interrupts are disabled.
Would be nice to find a solution to this but my knowledge in this subject is not so great  :-/

Ran Talbott

If your loop() routine is fairly short,  and you don't need really precise intervals between readings,  you could have the ISR set a global variable,  and take a reading in loop() when the flag is set.

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!

via Egeo 16
Torino, 10131