For a project I am trying to read data from a Bosch BNO055 with the I2C connection every 20 ms. For reading data at the correct frequency I am using a timer (I tried MsTimer2, TimerOne, TimerThree, milis() and elapsedMilis). However everytime I call the function Wire.endTransmission for the I2C connection, the program seems to stop.
Does somebody know why this happens? And/or does know a solution to this problem?
Thanks!
void startLoop(){
Wire.beginTransmission(BNO055); // Could also be left out, no difference.
Wire.write(EUL_DATA_X_LSB); // Could also be left out, no difference.
Wire.endTransmission(); // If this line is commentated out, it works fine.
Serial.println("Hello");
}
It looks to me that you might be calling something that requires interrupts to be enabled, inside an ISR.
Like Serial.print().
Wire.beginTransmission(BNO055); // Could also be left out, no difference.
Perhaps you ought to pay some attention to what these functions ACTUALLY do. This sets up a buffer to hold some data. Of course not doing that won't cause the ISR problems.
Wire.write(EUL_DATA_X_LSB); // Could also be left out, no difference.
Put some data in the buffer. Of course not doing that won't cause the ISR problems.
Wire.endTransmission(); // If this line is commentated out, it works fine.
Actually communicate with the device, sending the data in the buffer. If you don't do that, and you don't have a problem, then just stop doing it.
If you stop doing it, and you have a problem, then you need to stop pissing and moaning and figure out why the Arduino can't talk to the device!