AnsweredAssumed Answered

Why DATAxx-registers are not updated in ADXL345?

Question asked by alex_jet on Jan 21, 2016
Latest reply on Feb 29, 2016 by alex_jet

I am ADXL345 is connected to ATmega 2560 with SPI (mode 3).I write data to the registers and read the recorded data from all registers. However, in the mode 2g (for example) 10-bit value data (DATAX0<<8 | DATAX1) 511 is always equal in all axes!

What am I doing wrong? The datasheet bad written about initialization ADXL345, but in the simplest case, you must do the following:

//Initialization of ADXL345

ADXL345_SPIWrite_Byte(DATA_FORMAT, 0);           //SPI 4-wire

ADXL345_SPIWrite_Byte(POWER_CTL, 0);               //ADXL345 is off

ADXL345_SPIWrite_Byte(POWER_CTL, 8);               //ADXL345 is measure

ADXL345_SPIWrite_Byte(DATA_FORMAT, 0);          //ADXL345 resolution 2g


//Read DATAxx-register of ADXL345

for(y=0; y < 6; y++) ADXL345_Data_Array[y] = ADXL345_SPIRead_Byte(DATAX0 + y);

AxisX += ((signed int)ADXL345_Data_Array[1] << 8) | ADXL345_Data_Array[0];

AxisY += ((signed int)ADXL345_Data_Array[3] << 8) | ADXL345_Data_Array[2];

AxisZ += ((signed int)ADXL345_Data_Array[5] << 8) | ADXL345_Data_Array[4];

 

After read DATAxx-register AxisX = AxisY = AxisZ = 511!!! (for resolution 2g). If you change the resolution, changes only the order of magnitude, but they are all equal and do not depend on the position of the accelerometer !!!


What am I doing wrong???

Outcomes