cancel
Showing results for 
Search instead for 
Did you mean: 

Can not get data interrupts or data generation working properly

Herb
Associate

We are so frustrated right now, we have spent days reading the data sheets, which has many errors, and the app note 3308 which is random and sketchy at best, but we are stuck with this part on a production design and need to implement the most basic functions and it just will not work.

We are simply trying to get coherent data out of this accelerometer, but the data fluctuates all over the place, we are unable to get it to generate a data ready or XYZ ready interrupt, tried every combination we could derive from the one app not and ds., interrupt never triggers.

We went to polling the status register, it always stays at 0x00. I can read data from the X,Y,Z registers, but since we cannot do it coherently, we get random fluctuations in our data, we are running into a time limitation and need real assistance with this problem, please do just refer us back to the examples, they do not function.

Here is our current configuration, setup for a motion detection interrupt, and then we plan to poll the XYZ data to get active acceleration information. This was our plan B, we intended to run in either motion detection mode, or data gather mode, but again, could never get the data interrupt to fire. Plan B will work, but again, no bits ever set in the STATUS reg.

  // Detect motion above on any axis above the threshold

  case LIS3DH_INERTIA_int:

    accelFunction = LIS3DH_INERTIA_int;

    // store in EE prom

    EE_write(EEM_PAGE0, EEM_I_Int, TRUE);

    //EEpromWriteByte(0, EEM_I_Int, TRUE);

    // control reg 2

    // hp filter, int activity on INT1

    apiResult = AccelWriteByte(LIS3DH_CTRL_REG2, 0x01);

    if (apiResult != TRANSFER_CMPLT)

    {

      Status = Status | MER;

      return;

    }

    // control reg 3

    // IA1 interrupt on

    apiResult = AccelWriteByte(LIS3DH_CTRL_REG3, 0x40);

    if (apiResult != TRANSFER_CMPLT)

    {

      Status = Status | MER;

      return;

    }

    // control reg 4

    // FS = +/-2g

    // block update

    // high res 12 bit max values 1024 -> -1024

    apiResult = AccelWriteByte(LIS3DH_CTRL_REG4, 0x88);

    if (apiResult != TRANSFER_CMPLT)

    {

      Status = Status | MER;

      return;

    }

    // control reg 5

    // Interrupt latched

    apiResult = AccelWriteByte(LIS3DH_CTRL_REG5, 0x08);

    if (apiResult != TRANSFER_CMPLT)

    {

      Status = Status | MER;

      return;

    }

    // control reg 6

    apiResult = AccelWriteByte(LIS3DH_CTRL_REG6, 0x00);

    if (apiResult != TRANSFER_CMPLT)

    {

      Status = Status | MER;

      return;

    }

    apiResult = AccelWriteByte(LIS3DH_REFERENCE, 0x00);

    if (apiResult != TRANSFER_CMPLT)

    {

      Status = Status | MER;

      return;

    }

    // IA1 int threshold

    // 1lsb - ~16mg, 0x10 is 256mg

    apiResult = EE_read(EEM_PAGE0, EEM_THR);

    volatile uint8 THR = (uint8)I2C_Byte;

    // Store in Accel EE

    apiResult = AccelWriteByte(LIS3DH_INT1_THS, THR);

    if (apiResult != TRANSFER_CMPLT)

    {

      Status = Status | MER;

      return;

    }

     

    // IA1 int duration

    // 0 ODR

//    apiResult = EE_read(EEM_PAGE0, EEM_DUR);

//    uint8 DUR = I2C_Byte;

    // Calculate the DUR based on THR value

    volatile float perc = (float)(THR - 127) / (float)(255 - 127);

    volatile float newVal = ((5 - 1) * perc) + 1;

    volatile uint8 DUR = (uint8) newVal;

    apiResult = AccelWriteByte(LIS3DH_INT1_DUR, DUR);

    if (apiResult != TRANSFER_CMPLT)

    {

      Status = Status | MER;

      return;

    }

    // Duumy read of reference to reset HPF

    apiResult = AccelReadByte(LIS3DH_REFERENCE);

    if (apiResult != TRANSFER_CMPLT)

    {

      Status = Status | MER;

      return;

    }

     

    // IA1 int configuration

    // OR function all all axis

    // Enable all Axis

    apiResult = AccelWriteByte(LIS3DH_INT1_CFG, 0x2A);

    if (apiResult != TRANSFER_CMPLT)

    {

      Status = Status | MER;

      return;

    }

     

    // control reg 5

    // Interrupt latched

    apiResult = AccelWriteByte(LIS3DH_CTRL_REG5, 0x08);

    if (apiResult != TRANSFER_CMPLT)

    {

      Status = Status | MER;

      return;

    }

    // control reg 1

    // 100 sps all

    // not in LMP

    // XYZ on

    apiResult = AccelWriteByte(LIS3DH_CTRL_REG1, 0x57);

    if (apiResult != TRANSFER_CMPLT)

    {

      Status = Status | MER;

      return;

    }

    break; // Inertia interrupt

Also, here is the data polling routine, the status register never return any other value but 0x00

    // Polling movement

    AccelReadByte(LIS3DH_STATUS_REG);

     

    volatile uint8 temp = I2C_Byte;

     

    if((temp&0x08)!=FALSE&&(temp&0x80)==FALSE)

      {

       // go read and filter the data and place in array

       XYZ_Flag = FALSE;

       XYZ_data();

       SendNotification((uint8 *)&AccelReading, CYBLE_PROTECTED_ACCELEROMETER_CHAR_HANDLE, ACCEL_READING_DATA_LEN);

      }

0 REPLIES 0