AnsweredAssumed Answered

FXAS21000 stops working

Question asked by Alexander Agudelo on Jan 2, 2017
Latest reply on Aug 16, 2018 by Alexander Agudelo

Hi guys, I'm working with the FXAS21000 and after following the bare metal example project I was able to get some readings out of the device. The problem, however, is that after a few readings (<5) the device stops working. I noticed that the interrupt pin remains low. Since I'm using INT2 as an external interrupt to know when to read the registers, my code just stops working. If I ignore the interrupt pin and just read the OUT_X_MSB register, I do get the correct readings.

 

I understand that just reading the 6 data bytes starting at OUT_X_MSB should reset the interrupt flag (Datasheet: "Reading the INT_SRC_FLAG register does not reset any event-flag source bits; they are reset by reading the appropriate event source register"), but that doesn't seem to be the case. The datasheet also states that "...The content of this register (0x0B) is reset upon a transition from Standby to Active or from Ready to Active modes", so I decided to switch from "active" to "ready" mode before reading and back to "active" after reading the contents of the registers, this seems to fix the issue but is not ideal since I need 3 operations just to read the data.

 

#define FXAS21000_DR_SHIFT2(x) (x << 2)
#define FXAS21000_REG1_DR_MSK 0x1C

void FXAS21000::init(){
    writeRegister(FXAS21000_CTRL_REG1, FXAS21000_REG1_SFT_RST); // Factory default
    wait(1_ms);
    // Enter in standby mode
    uint8_t reg = getRegister(FXAS21000_CTRL_REG1);
    writeRegister(FXAS21000_CTRL_REG1, reg & ~FXAS21000_REG1_STANDBY);
    // Set the Full scale mode at 800dps
    // High pass filter disabled
    writeRegister(FXAS21000_CTRL_REG0, 0x01);
    // Enable data ready interrupts
    writeRegister(FXAS21000_CTRL_REG2, (1 << 2));
    // Set a low sampling rate to start with (Mode_25Hz)
    reg = getRegister(FXAS21000_CTRL_REG1) & ~FXAS21000_REG1_DR_MSK;
    writeRegister(FXAS21000_CTRL_REG1, reg | (FXAS21000_REG1_DR_MSK & FXAS21000_DR_SHIFT2(3)));
    // Back to active mode
    reg = getRegister(FXAS21000_CTRL_REG1) & ~FXAS21000_REG1_STANDBY;
    int r = writeRegister(FXAS21000_CTRL_REG1, reg | FXAS21000_REG1_ACTIVE);
}

int FXAS21000::read(int16_t * t){
    uint8_t d[7];
    int r = read( FXAS21000_STATUS, d, 7);
    if(r <= 0){
        return r;
    }

    t[0] = ((d[1] * 256) + ((unsigned short) d[2]));
    t[1] = ((d[3] * 256) + ((unsigned short) d[4]));
    t[2] = ((d[5] * 256) + ((unsigned short) d[6]));
}

 

Has anybody encountered a similar issue? any help would be really appreciated!

 

Thanks, 

 

 

A.

Outcomes