AnsweredAssumed Answered

ADXL343 read return value misbehaviour

Question asked by chris987 on Oct 20, 2017
Latest reply on Nov 2, 2017 by jwang

Hello,

 

we are currently using your ADXL343 Accelerometer and already established the procedure of communicating with it via SPI (4-wire).

 

The communication function we are using is READ/WRITE (Send_Receive) with two buffers one for writing and one for reading.

 

Example:

Send_Receive(send buffer, length of buffer, received buffer, length of buffer);

 

Read Function:

 

send[0] = 0x0 | 0x80; 
send[1] = 0x00;

StartSPI(); //enable interrupts etc.

PORT4 = 0; //set Chip select low

Delay(1);

Send_Receive(send 1, received, 0); // first we send the register with the set write bit

memset(send, 0x0, 2);
memset(received, 0x0, 2);

send[0] = 0x80;

Send_Receive(send, 1, received, 1); // then we receive the value of the register we send

PORT4 = 1; //set Chip select Hight => End of Reading

Delay(3);

StopSPI();

 

Problem:

The first time we used this function the value returned is correct, however the misbehaviour happens after we execute the function a second time, then the returned value stays at "177 decimal" or "0xB1" hex.

 

We currently assume that this value is some sort of error ID which we cannot interpret.

 

So our question is, why does that happen and what does the value mean?

Outcomes