Hi everyone. Hoping you can help me out. I have a TinyDuino (which I believe to have the same interrupt setup as an Uno) and an accelerometer shield which uses a BMW250. Here's a pointer to the various specs:
https://tiny-circuits.com/shop/tinyshield-accelerometer/
I'm trying to setup the accelerometer shield up such that when it detects any motion, it triggers interrupt 1 on the arduino (with the eventual goal of that waking it from sleep). What I believe I've done:
- Soldered a jumper between INT1 on the shield to pin 3 on a proto1 breakout board.
- Mapped the INT1 pin on the BMA250 to the slope interrupt
- Set the interrupt pins on the BMA250 to latch
- Enabled the slope interrupt on X/Y/Z
- Added a handler for interrupt 1 on the Arduino
If I run all that, I don't ever see my interrupt fire on the Arduino. If using Wire, I poll and request 1 byte from 0x09 (status registers), I can see that slope_int is changing as I expect.
Any thoughts on what it takes to get the INT1 pin on the BMA250 to go high?
My code so far:
#include <Wire.h>
#define BMA250_I2CADDR 0x18
#define BMA250_RANGE 0x03 // 0x03 = 2g, 0x05 = 4g, 0x08 = 8g, 0x0C = 16g
#define BMA250_BW 0x08 // 7.81Hz (update time of 64ms)
void handleInterrupt1()
{
interrupted = 1;
}
void setup()
{
Wire.begin();
Serial.begin(115200);
BMA250Init();
attachInterrupt(1,handleInterrupt1,CHANGE); // Catch up and down
}
void loop()
{
BMA250ReadInter();
if (interrupted) {
Serial.println("INTERRUPTED");
interrupted = 0;
}
delay(100);
}
void BMA250Init()
{
// Setup the range measurement setting
Wire.beginTransmission(BMA250_I2CADDR);
Wire.write(0x0F);
Wire.write(BMA250_RANGE);
Wire.endTransmission();
// Map slope interrupt to pin 1
Wire.beginTransmission(BMA250_I2CADDR);
Wire.write(0x19);
Wire.write(0x04);
Wire.endTransmission();
// latch interrupt
Wire.beginTransmission(BMA250_I2CADDR);
Wire.write(0x21);
Wire.write(0x011b);
Wire.endTransmission();
// Setup the bandwidth
Wire.beginTransmission(BMA250_I2CADDR);
Wire.write(0x10);
Wire.write(BMA250_BW);
Wire.endTransmission();
// Enable interrupt
Wire.beginTransmission(BMA250_I2CADDR);
Wire.write(0x16);
Wire.write(0x07);
Wire.endTransmission();
}
int BMA250ReadInter()
{
uint8_t interruptStatus;
// Read the 7 data bytes from the BMA250
Wire.beginTransmission(BMA250_I2CADDR);
Wire.write(0x09);
Wire.endTransmission();
Wire.requestFrom(BMA250_I2CADDR,1);
interruptStatus = Wire.read();
Serial.print("interruptStatus: ");
Serial.print(interruptStatus);
Serial.println("----");
}
Thanks for any advice you can give me!