FXLS8471Q spi auto detect

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

FXLS8471Q spi auto detect

1,756 Views
davidsherman
Senior Contributor I

Hello, I'm running into some problems getting the fxls8471q to wake up in spi mode.  I have RST tied to vss.  The SA0 line is going to a pin on the MK10DN512VLL10 which happens to power up as an analog input.  Although it is somewhat floating, there is a weak pull up.  How exactly does the FXLS8471Q determine that pin is floating?  Is it trying to pull up/pull down weakly?  I see INT1 going low for 500nS, but I only see SA0 rising to VDD over a period of 2mS.  Apparently it is waking up up in I2C mode, because I can't read anything from the WHO_AM_I register.

Labels (1)
0 Kudos
9 Replies

1,123 Views
carloscanal
Contributor II

Hello:
I'm working with a FXLS8471Q accelerometer, and I can not read properly the "Who am I" in SPI mode, read the 0xC4 value and not the 0x6A value (also using an oscilloscope, clearly identify the 0xC4 value) I have another identical plate hardware and software, I have no problem, I go perfectly.
The only difference is that the first board uses a FXLS8471Q acquired Mouser, and the second is a free sample of Freescale. My great confusion, is that I have already armed more than 10 board and all has the same drawback, reading "Who am I" is 0xC4.
Someone has the same problem ?.
regards
Carlos

0 Kudos

1,123 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Carlos,

I have not heard of a similar problem before.

Could you please post here your scope traces illustrating what is going on the SPI bus when you read the WHO_AM_I register?

Regards,

Tomas

1,123 Views
carloscanal
Contributor II

Hi Tomas:
After several changes to the code and the addition of delays in communication routines SPI, I could solve the problem.
Thank you very much for your kindness and concern.
Regards
Carlos

0 Kudos

1,123 Views
anthonyduhamel
NXP Employee
NXP Employee

Hello David,

I used the FXL8471Q accelerometer on a FRDM-KL25 board+ MULTIB shield.

If you want to take a look at the schematic, I attached a sample of the hardware below:

Capture.PNG

If the FXLS8471Q doesn't boot in SPI mode, you can reset the sensor by toggling the RST pin. That's totally normal the INT1 goes to low for 500ns, it indicates that the sensor has successfully complete its reset sequence.

I think your schematic is good, it's probably a software issue.

I suggest you to check your spi communication, can you share your code with us?

The SPI communication with the FXLS8471Q is very specific, did you check the SPI specifications in the datasheet?

A SPI command is 2bytes + DATA. Note that you must specify the Read/Write operation

1st Byte

bit7bit6bit5bit4bit3bit2bit1bit0
W/R (Write=1/Read=0 )DATA[6]DATA[5]DATA[4]DATA[3]  DATA[2] DATA[1]  DATA[0]  

2nd Byte

bit7bit6bit5bit4bit3bit2bit1bit0
DATA[7]X (don't care)X (don't care)X (don't care)  X (don't care)X (don't care)X (don't care) X (don't care)

For example if you want to:

- read the WHO_AM_I register you must send through the SPI:  0x0D00 + clocking for response

- write in the CTRL_REG1 : 0xAA00 + value to write into

Here a code snippet of an mbed project I did :

#define FXLS8471Q_CTRL_REG1            0x2A

#define FXLS8471Q_CTRL_REG2            0x2B

#define FXLS8471Q_XYZ_DATA_CFG      0x0E

#define FXLS8471Q_WHO_AM_I              0x0D

#define FXLS8471Q_WHO_AM_I_VAL      0x6A

bool FXLS8471Q::vInit()

{

    bool __b_result=false;

    uint8_t __u8_temp=0xFF;

    _t_spi.frequency(1000000);

    /* Check presence of the sensor to prevent SPI issues*/

    if(bRead(FXLS8471Q_WHO_AM_I,&__u8_temp,1))  

    if(__u8_temp == FXLS8471Q_WHO_AM_I_VAL)      //Check Sensor ID answer

  

    /* Configure the sensor */

    if(bWrite(FXLS8471Q_CTRL_REG1  ,0x0))        //Standby mode

    if(bWrite(FXLS8471Q_XYZ_DATA_CFG,0x2))        //0.976mg/LSB  

    if(bWrite(FXLS8471Q_CTRL_REG2  ,0x01))      //Low noise

    if(bWrite(FXLS8471Q_CTRL_REG1  ,0x01))      //Set ODR to 800Hz & active mode

    {

        __b_result= true;

    }

                                      

    return __b_result;

}

bool FXLS8471Q::bWrite(uint8_t __u8_register, uint8_t __u8_InValue)

{

  uint8_t __au8_txBuffer[3];

  

    bool __b_result = false;

    __au8_txBuffer[0] =  (__u8_register&0x7F) | (0x1<<7);

    __au8_txBuffer[1] = __u8_register&0x80;

    __au8_txBuffer[2] = __u8_InValue;

  

    _t_cs = 0;

    _t_spi.write(  (__u8_register&0x7F) | (0x1<<7) ) ;

    _t_spi.write(__u8_register&0x80);

    _t_spi.write(__u8_InValue) ;

    _t_cs  =  1;

  

    __b_result = true;

    return __b_result;

}

bool FXLS8471Q::bRead(uint8_t __u8_register, uint8_t* __au8_OutValue,uint8_t __u8_length)

{

    uint8_t __au8_txBuffer[2];

    bool __b_result = false;

    uint8_t __u8_i;

  

    __au8_txBuffer[0] =  (__u8_register&0x7F) | (0x0<<7);

    __au8_txBuffer[1] = __u8_register&0x80;

  

    _t_cs = 0;

  

    _t_spi.write(  (__u8_register&0x7F) | (0x0<<7) ) ;

    _t_spi.write(__u8_register&0x80);

    for(__u8_i=0;__u8_i<__u8_length;__u8_i++)

    {

        __au8_OutValue[__u8_i] =  _t_spi.write(0x00) ;

    }

    _t_cs  =  1;

  __b_result = true;

    return __b_result;

}

I hope it helps you.

I will come back to you about the SPI/I²C mode auto-detection.

Anthony

0 Kudos

1,123 Views
davidsherman
Senior Contributor I

Thank you Anthony, as I said, I was able to read the WHO_AM_I register once I corrected the wiring mistake.  The SPI does not appear to be a problem, and apparently the weak pull-up on the MK10 at power up isn't keeping it from waking up in SPI mode.  My only question is how strong does the pull-up have to be before it wakes up in I2C mode.  More specifically, if I need to tie RST to an I/O line so the MK10 can wake up enough to configure the MISO pin so the pull-up is disabled before toggling the reset, it would be good to know.

0 Kudos

1,123 Views
anthonyduhamel
NXP Employee
NXP Employee

David, I just saw your reply. I'm happy you solved the problem.

Anthony

0 Kudos

1,123 Views
Zhimin
Contributor I

when I load code to sensor,restart power on . sensor needs 9s to stabilze ,while current is 50uA.

0 Kudos

1,123 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi David,

I will let Anthony Duhamel​ comment on the I2C/SPI auto-detection, I just want to share a screenshot which illustrates how to read the WHO_AM_I register (0x0D) in SPI mode.

SPI_Read.JPG 

Regards,

Tomas

1,123 Views
davidsherman
Senior Contributor I

Thank you, Tomas.  It turns out the problem was an error in the board layout, so the MISO/MOSI lines were backward to the part (oops!).  Now that I've got them wired properly, I see MISO start to rise, then it's pulled down to about halfway between VDD and VSS for 5mS.  It must be waking up in SPI after all, because I can read the WHO_AM_I register now.  I am still curious how much of a pull-up or pull-down it can tolerate before it determines that it's not floating.

0 Kudos