I am using SparkFun BNO080 breakout board, connected to Arduino Uno using Qwiic cable and INT pin is connected to Arduino Pin3. Arduino is connected to a PC via USB.
I am trying to log multiple reports at a very high frequency using the interrupt. To calculate timestamps for each data, I need to know when interrupts are happening.
I am trying the following code:
#include <Wire.h>
#include "src/SparkFun_BNO080_Arduino_Library.h" // Click here to get the library: http://librarymanager/All#SparkFun_BNO080
BNO080 myIMU;
// pin used for interrupts
byte imuINTPin = 3;
volatile bool interruptDetected = false;
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.println("BNO080 Read Example");
delay(100); // Wait for BNO to boot
Wire.begin();
// imuINTPin is used as an active-low interrupt. myIMU.begin() configures the pinMode as INPUT_PULLUP
if (myIMU.begin(BNO080_DEFAULT_ADDRESS, Wire, imuINTPin) == false)
{
Serial.println("BNO080 not detected at default I2C address. Check your jumpers and the hookup guide. Freezing...");
while (1);
}
Wire.setClock(400000); //Increase I2C data rate to 400kHz
delay(100); //make sure BNO is ready for interrupt.
// prepare interrupt on falling edge (= signal of new data available)
attachInterrupt(digitalPinToInterrupt(imuINTPin), interrupt_handler, FALLING);
// enable interrupts right away to not miss first reports
interrupts();
myIMU.enableDebugging(Serial); //Output debug messages to the Serial port. Serial1, SerialUSB, etc is also allowed.
//Enable dynamic calibration for accel, gyro, and mag
myIMU.calibrateAll(); //Turn on cal for Accel, Gyro, and Mag
myIMU.enableAccelerometer(5); //Send data update every 5ms //10 bytes
myIMU.enableGyro(5); //Send data update every 5ms //10 bytes
myIMU.enableMagnetometer(10); //Send data update every 10ms //10 bytes
myIMU.enableRotationVector(5); //Send data update every 5ms //12 bytes
}
// This function is called whenever an interrupt is detected by the Arduino
void interrupt_handler()
{
interruptDetected = true;
}
void loop()
{
if (interruptDetected)
{
interruptDetected = false;
myIMU.getReadings();
//myIMU.printPacket(); //custom method to print packets.
}
}
It seems I can’t figure out how Interrupts are happening.
Can you please help me to understand how will be the interrupt signal in my case? PaulZC suggested me to ask in this forum, so I am hoping to get some help.
Thanks in advance.