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.
Send_Receive(send buffer, length of buffer, received buffer, length of buffer);
send = 0x0 | 0x80;
send = 0x00;
StartSPI(); //enable interrupts etc.
PORT4 = 0; //set Chip select low
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 = 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
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?