FXAS21002 stops acquiring new data after short time

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FXAS21002 stops acquiring new data after short time

1,197 Views
benjaminbush
Contributor II

I've verified functionality (CTRL_REQ1 = 0x03) and had data communicating with a micro-controller. After a while acquisitions stop. I have verified that the active bit is still enabled and i2c communication is still working (WHO_AM_I still returns 0xD7). I've even tried doing a software reset and reenabling the chip, but nothing changes. It just resends the last data acquisition. Any ideas on how to get it acquiring again? 

0 Kudos
9 Replies

854 Views
benjaminbush
Contributor II

and to be clear I check the CTRL_REG1 which shows 0x03 (so it should be acquiring data).

I also switched the code to the following

FXASReadByte(DR_STATUS, recvdata);

if(recvdata[0]){
FXASReadBytes(0x01,senddata+13,6);

}

Finally This code is triggered only every 10 mS, and with default values for the FXAS at 800 hz, it should sample gyroscope data faster than that.

Thanks for your help

0 Kudos

854 Views
benjaminbush
Contributor II

Hey Tomas,

        I could really use some help on this, I've been waiting for over 2 weeks for resolution of this problem. Any help would be appreciated.

Benjamin

0 Kudos

854 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Benjamin,

I am afraid it is hard to find the root cause without seeing what is going on the bus and/or having your complete source code.

 

I would also recommend trying to use interrupts instead of periodic polling at 100Hz.

Best regards,

Tomas

0 Kudos

854 Views
benjaminbush
Contributor II

Hey Tomas,

        I'm willing to send the complete source code, but only on a ticket. I'm also willing to probe the lines. At what point in the code do you need me to probe?

0 Kudos

854 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Benjamin,

OK, please send me your source code through a standart ticket. We need to see what is going on on the bus when something happens and no new data is acquired.

Best regards,

Tomas

0 Kudos

854 Views
benjaminbush
Contributor II

Hey Tomas,

        Your code will only read data when it says there is new data is available, which is not the problem I'm talking about. My code returns DR_STATUS first and then I can check it if the data is new (register 0x00 goes to DR_STATUS unless configured differently, which I have not done). The issue is that there is never any new data after a couple minutes of operation. As in my code works (I get gyroscope data) until something happens and no new data is acquired. I retried it today, and once again communication if fine, but no new data gets generated. Why does no new data get generated when it used to work? I've attached the waveform for the following command

FXASReadByte(FXAS21002_WHOAMI, recvdata+1);

 WHOAMI_FXAS.jpg

0 Kudos

854 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Benjamin,

Sorry for our late response.

 

Does the problem still persist? If so, please share here or send me your complete source code. It might be also helpful to see what is going on on the bus if you have a logic analyzer or an oscilloscope.

Best regards,

Tomas

0 Kudos

854 Views
benjaminbush
Contributor II

The problem still persists. Here is the pertinent code

uint8_t FXASWriteByte(uint8_t regaddr, uint8_t u8data)
{
TWIStart();
if (TWIGetStatus() != 0x08){
return ERROR_START;
}

TWIWrite((FXAS_ADDR << 1));
if (TWIGetStatus() != 0x18){
return ERROR_TRANSMIT;
}
//send the register
TWIWrite(regaddr);
if (TWIGetStatus() != 0x28){
return ERROR_TRANSMIT;
}
//write byte to register
TWIWrite(u8data);
if (TWIGetStatus() != 0x28){
TWIStop();
return ERROR_TRANSMIT;
}
TWIStop();
return 0;
}

uint8_t FXASReadBytes(uint8_t regaddr, uint8_t *u8data, uint8_t len)
{
uint8_t count = 0;

TWIStart();
if (TWIGetStatus() != 0x08){
return ERROR_START;
}


TWIWrite((FXAS_ADDR << 1));
if (TWIGetStatus() != 0x18){
return ERROR_TRANSMIT;
}
//send the register
TWIWrite(regaddr);
if (TWIGetStatus() != 0x28){
return ERROR_TRANSMIT;
}

TWIStart();
if (TWIGetStatus() != 0x10){
return ERROR_RESTART;
}

//FXOS_address with 1 in the read portion
TWIWrite((FXAS_ADDR << 1)|1);
if (TWIGetStatus() != 0x40){
return ERROR_TRANSMIT;
}

while(count++ < len-1){
*u8data++ = TWIReadACK();
if (TWIGetStatus() != 0x50){
return ERROR_READ;
}
}

*u8data = TWIReadNACK();
if (TWIGetStatus() != 0x58){
return ERROR_READ;
}

TWIStop();
return SUCCESS;
}

uint8_t senddata[24] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

int main(void){

FXASWriteByte(CTRL_REG1,0x03);

FXASReadBytes(FXAS21002_STATUS,senddata,8);

}

As I said in the previous post, the i2c communication seems to be working fine, just the data doesn't seem to be acquired. I'm wondering if this is more of a hardware/layout issue

0 Kudos

854 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Benjamin,

It is hard to debug your communication routines, it would be much easier using a logic analyzer or an oscilloscope.

 

However, looking at your main() function, the way you are trying to get the data is not correct. Basically there are two possibilities to read the current XYZ data. First is using the INTx pin for an interrupt when a new data is ready and the second option is reading the ZYXDR bit in the DR_STATUS register (0x07). Actually this polling technique requires less configuration of the device and is very simple to implement.  

 

So basically the code might be like this:

 

for (;;)

{

            DR_STATUS = IIC_RegRead(0x07);

            if (DR_STATUS & 0x08)

            {

                        IIC_RegsRead(0x01, 6, GyroData);                    // Read data output registers 0x01-0x06             

            }

            // Perform other necessary operations   

}

 

Hope it helps!

Best regards,

Tomas

0 Kudos