7 years, 11 months ago.

FRDM-K64F with FRDM-FXS-MULT2-B

Hello,

I'm trying to read the values of the gyroscope (FXAS21002C) on the mult2-b. I'm able to read out the values of all the other sensors, but for some reason the gyroscope (the one I actually need) isn't returning anything else besides X:16.80 Y:0.00 Z:0.00. The code I'm using is as follow:

  1. include "mbed.h"
  2. include "FXOS8700Q.h"
  3. include "FXAS21000.h"

FXAS21000 gyro(D14, D15); FXOS8700Q_acc combo_acc(D14, D15, FXOS8700CQ_SLAVE_ADDR1); FXOS8700Q_mag combo_mag(D14, D15, FXOS8700CQ_SLAVE_ADDR3);

Serial pc(USBTX, USBRX);

int main() { float gyro_data[3]; MotionSensorDataUnits adata; MotionSensorDataUnits mdata;

printf("\r\nStarting\r\n\r\n"); combo_acc.enable(); combo_mag.enable(); printf("FXOS8700 Combo = %X\r\n", combo_acc.whoAmI()); printf("FXAS21000 Gyro = %X\r\n", gyro.getWhoAmI());

wait(3);

while(1) { combo_acc.getAxis(adata); printf("FXOS8700 Acc: X:%6.3f Y:%6.3f Z:%6.3f\r\n", adata.x, adata.y, adata.z); combo_mag.getAxis(mdata); printf("FXOS8700 Mag: X:%6.2f Y:%6.2f Z:%6.2f\r\n", mdata.x, mdata.y, mdata.z);

gyro.ReadXYZ(gyro_data); printf("FXAS21000 Gyro: X:%6.2f Y:%6.2f Z:%6.2f\r\n", gyro_data[0], gyro_data[1], gyro_data[2]);

printf("\r\n");

wait(1); } }

The header file I'm using says FXAS21000, but I changed the register data to:

  1. define FXAS21000_SLAVE_ADDR 0x40
  1. define FXAS21000_STATUS 0x00
  2. define FXAS21000_WHOAMI 0x0C
  3. define FXAS21000_XYZ_DATA_CFG 0x0E
  4. define FXAS21000_CTRL_REG0 0x0D
  5. define FXAS21000_CTRL_REG1 0x13
  6. define FXAS21000_WHOAMI_VAL 0xD7

I have no clue why it isn't working. Who can help me out?

There was indeed something wrong with the communication protocol. It's fixed now. Thanks!

posted by Lois Koers 23 May 2016

2 Answers

7 years, 11 months ago.

I don't know which version of the mbed library you are using, but the latest version (120) has broken a few things in the K64F. I2C being one of them:

https://developer.mbed.org/questions/69021/Questions-about-initialization-failures-/

https://developer.mbed.org/users/infinnovation/code/pwm_regression/

Try switching back to mbed version 119

7 years, 11 months ago.

Hi,
According to the data sheet of FXAS21000
http://cache.nxp.com/files/sensors/doc/data_sheet/FXAS21000.pdf?fsrch=1&sr=5&pageNum=1

The slave address is either 0x20 or 0x21
So how about trying
FXAS21000 gyro(D14, D15, 0x20 <<1 );
or
FXAS21000 gyro(D14, D15, 0x21 <<1);
instead of
FXAS21000 gyro(D14, D15);

moto