TinyCircuits

Triggering Arduino interrupt 1 from accelerometer slope interrupt

Hi everyone. Hoping you can help me out. 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:

1) Soldered a jumper between INT1 on the shield to pin 3 on a proto1 breakout board.
2) Mapped the INT1 pin on the BMA250 to the slope interrupt
3) Set the interrupt pins on the BMA250 to latch
4) Enabled the slope interrupt on X/Y/Z
5) 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 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:

Code: [Select]
#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("----");   
}


Re: Triggering Arduino interrupt 1 from accelerometer slope interrupt
« Reply #1 on: April 03, 2015, 03:29:15 PM »
Hi Bentwookie,
Hopefully you've found the problem by now, but just in case, hear is what I've found. I loaded up your sketch and the BMA250 appears to be triggering on INT1 just fine (goes from 0 to 3 V when triggered). The issue may be with your sketch, specifically interrupt handling. CAVEAT: I'm actually using an Arduino Uno and a BMA250 breakout from DSS circuits. I probed INT1 with an oscilloscope to verify it is triggering correctly, then wired INT1 to int.1 on the UNO (digital pin 3). Works great. Good luck, and thanks for your code!
Kevin