AnsweredAssumed Answered

ADXL372 data incorrect

Question asked by luutay on Oct 30, 2017
Latest reply on Apr 5, 2018 by NeerajSingla

Hello everybody,

I have a problem.

I'm using a PIC to work with ADXL372 Accelerometer , using SPI protocol.

Now i can read correct value in register 0x00~0x03 but I not move adxl372, the value in register XDATA_L, YDATA_L, ZDATA_L is alway change.

SPI frequency:4 MhzSPI_MODE_0.

I configurated for adxl372:

-THRESH_ACT_X_L(0X24): set 0xA3 // set therhold 0.5g

-THRESH_ACT_X_L(0X26) :set 0xA1  // set therhold 0.5g

-THRESH_ACT_X_L(0X28): set 0xA1  // set therhold 0.5g

-POWER_CTL( 0x3F): set 0x17// measure mode My configuration is correct ?

I need to configure anything else?

 

This is result when i use 1 byte Read to read value:

devid_ad (0X00) AD

devid_mst (0X01) 1D

devid_product (0X02) FA

revid (0X03) 02

status (0X04) 41

status2(0X05)  20

REGISTER 0X24 a3

REGISTER 0X26 a1

REGISTER 0X28 a1

power control (0X3F) 17

X_high=00 X_low=a0 Y_high=ff Y_low=f0  Z_high=00  Z_low=b0

X_high=01 X_low=00 Y_high=00 Y_low=f0  Z_high=01  Z_low=00

X_high=01 X_low=00 Y_high=ff Y_low=10  Z_high=01  Z_low=60

X_high=01 X_low=40 Y_high=ff Y_low=00  Z_high=02  Z_low=00

X_high=00 X_low=30 Y_high=ff Y_low=10  Z_high=00  Z_low=f0

X_high=01 X_low=a0 Y_high=ff Y_low=f0  Z_high=01  Z_low=00

X_high=01 X_low=00 Y_high=00 Y_low=f0  Z_high=01  Z_low=70

X_high=00 X_low=80 Y_high=ff Y_low=d0  Z_high=01  Z_low=70

X_high=00 X_low=30 Y_high=ff Y_low=00  Z_high=01  Z_low=80

X_high=00 X_low=80 Y_high=ff Y_low=00  Z_high=00  Z_low=80

X_high=01 X_low=00 Y_high=ff Y_low=f0  Z_high=01  Z_low=c0

X_high=00 X_low=a0 Y_high=fe Y_low=f0  Z_high=00  Z_low=00

X_high=00 X_low=30 Y_high=ff Y_low=f0  Z_high=01  Z_low=80

X_high=00 X_low=80 Y_high=ff Y_low=00  Z_high=00  Z_low=f0

X_high=00 X_low=30 Y_high=ff Y_low=e0  Z_high=01  Z_low=d0

 

This is result when i use Mulitbyte  Read to read value:

devid_ad (0X00) AD

devid_mst (0X01) 1D

devid_product (0X02) FA

revid (0X03) 02

status (0X04) 41

status2(0X05)  20

REGISTER 0X24 a3

REGISTER 0X26 a1

REGISTER 0X28 a1

power control (0X3F) 17

X_high=01 X_low=40 Y_high=ff Y_low=f0  Z_high=00  Z_low=b0

X_high=00 X_low=f0 Y_high=ff Y_low=f0  Z_high=01  Z_low=00

X_high=02 X_low=00 Y_high=ff Y_low=f0  Z_high=00  Z_low=f0

X_high=00 X_low=90 Y_high=ff Y_low=80  Z_high=01  Z_low=00

X_high=00 X_low=30 Y_high=ff Y_low=f0  Z_high=01  Z_low=00

X_high=01 X_low=80 Y_high=ff Y_low=80  Z_high=01  Z_low=a0

X_high=00 X_low=f0 Y_high=fe Y_low=f0  Z_high=01  Z_low=70

X_high=00 X_low=80 Y_high=00 Y_low=00  Z_high=00  Z_low=f0

X_high=01 X_low=00 Y_high=ff Y_low=f0  Z_high=01  Z_low=c0

X_high=01 X_low=80 Y_high=ff Y_low=00  Z_high=01  Z_low=00

X_high=01 X_low=40 Y_high=ff Y_low=10  Z_high=01  Z_low=00

X_high=00 X_low=f0 Y_high=ff Y_low=f0  Z_high=02  Z_low=20

X_high=02 X_low=00 Y_high=ff Y_low=f0  Z_high=01  Z_low=00

X_high=00 X_low=00 Y_high=00 Y_low=00  Z_high=01  Z_low=00

X_high=00 X_low=80 Y_high=00 Y_low=00  Z_high=01  Z_low=00

X_high=00 X_low=30 Y_high=ff Y_low=10  Z_high=00  Z_low=80

X_high=01 X_low=70 Y_high=ff Y_low=f0  Z_high=02  Z_low=80

X_high=01 X_low=c0 Y_high=ff Y_low=f0  Z_high=01  Z_low=00

X_high=01 X_low=80 Y_high=ff Y_low=f0  Z_high=00  Z_low=f0

X_high=00 X_low=f0 Y_high=fe Y_low=f0  Z_high=00  Z_low=30

X_high=00 X_low=80 Y_high=fe Y_low=b0  Z_high=00  Z_low=50

X_high=00 X_low=00 Y_high=fe Y_low=f0  Z_high=00  Z_low=f0

X_high=00 X_low=f0 Y_high=ff Y_low=f0  Z_high=01  Z_low=e0

 

- this is function read and write for adxl372:

/******************************************************************************

**           write 1 byte to adxl372               

*******************************************************************************/

void SPI_ADXL372_WRITE (BYTE adress, BYTE data) {

   unsigned char TempAddress;

   TempAddress = adress;

   TempAddress = TempAddress << 1;

   output_low(SS);      //CS4 = LOW

   delay_ms(1);            //CS to SCLK set up time   

   spi_write(TempAddress);      //write adress

   spi_write(data);

   delay_ms(1);

   output_high(SS);      //CS4 = High

   delay_ms(1);             //Wait Time

}

 

/******************************************************************************

**           read 1 byte from adxl372               

*******************************************************************************/

unsigned char SPI_ADXL372_READ(BYTE adress) {

   unsigned char result;

   unsigned char TempAddress;

   TempAddress = adress;

   TempAddress   = TempAddress << 1;

   TempAddress += 1;

   output_low(SS);     //CS4 = LOW

   delay_ms(1);           //CS to SCLK set up tim 

   spi_write(TempAddress);  //adress in read mode

   result = spi_read(0);       //Read 8bit data (Send Dummy data 0x00)

   delay_ms(1);            //CS to SCLK set up time

   output_high(SS);     //CS4 = High

   delay_ms(1);             //Wait Time

   return result;

}

 

/******************************************************************************

**           read muti byte to adxl372                

*******************************************************************************/

void SPI_ADXL372_M_READ(BYTE adress, BYTE RXCONT) {

   unsigned char   RXBYTE;

   unsigned char TempAddress;

  

   TempAddress = adress;

   TempAddress = TempAddress << 1;

   TempAddress += 1;

   output_low(SS);      //CS4 = LOW

   delay_ms(1);             //CS to SCLK set up time 

   spi_write(TempAddress);

  

   for(RXBYTE=0; RXBYTE<RXCONT; RXBYTE++)

   {   

      r_data[RXBYTE] = spi_read(0);   //Read 8bit data (Send Dummy data 0x00)

   }

   delay_ms(1);                  //CS to SCLK set up time

   output_high(SS);           //CS4 = High

   delay_ms(1);                  //Wait Time

}

Please help me to fix this problem.

Regards,

Outcomes