Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - bentwookie

Pages: 1
1
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("----");   
}


Pages: 1
SMF spam blocked by CleanTalk