I figured out the solution to the original question myself now: Apparently writing to serial within the requestEvent messes with the i2c bus.
I guess it's some kind of problem arising from the collision of ISRs.
Posts made by mdittgen
-
RE: Arduino Dock: I2C and Serial
-
Arduino Dock: I2C and Serial
Hey all,
I'm fairly new to the Omega platform but quite amazed by the versatility.
I've been trying to receive measurement data acquired by the Arduino on the Arduino Dock 2.
The Omega acts as the master, the arduino as a "regular" i2c slave.It's working fine, however I've experienced problems when trying to also send debug output via the serial interface.
Here's my arduino sketch:
#include <Wire.h> byte reg = 0; void setup() { // put your setup code here, to run once: Wire.begin(0x09); Serial.begin(9600); Wire.onReceive(receiveEvent); Wire.onRequest(requestEvent); } void loop() { // put your main code here, to run repeatedly: } void receiveEvent() { reg = Wire.read(); } void requestEvent() { Wire.write(reg); //Serial.println("Hello World"); }
I can detect the slave by executing i2cdetect -y 0, and i2cdump -y 0 0x09 will give me the expected output where each register has the value of its address.
However as soon as I uncomment the Serial.println, the read fails. i2cdump will just show garbage and i2cget weirdly fails every other execution, where the other one returns 0x00.
Does anyone have an idea on why the serial interface interferes with the i2c interface?
I'm quite sure I did this before on a regular arduino, so I'm surprised it doesn't work.