ADXL355 and Arduino Boards

Hi All,

Currently I am trying to use arduino board with ADXL355 to communicate with SPI protocol.

When I connect the sensor to arduino-DUE board to get the g readings I get correct readings from the sensors

BUT, when I connect it to arduino-Uno or Nano (with and without 3.3V to 5V level shifters to adjust the voltage levels of SPI lines) using the same code unchanged I got only noise readings, it seems the the MSB byte of the sensor reading has sort of issue in this case.

So any one tried using the ADXL355 with arduino UNO/Nano family and get correct SPI readings? 

Below I am adding the part of Arduino SPI communication code that is working fine with Due but not with Nano:

"

const int XDATA3 = 0x08;
const int XDATA2 = 0x09;
const int XDATA1 = 0x0A;
const int YDATA3 = 0x0B;
const int YDATA2 = 0x0C;
const int YDATA1 = 0x0D;
const int ZDATA3 = 0x0E;
const int ZDATA2 = 0x0F;
const int ZDATA1 = 0x10;

SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0));
digitalWrite(CHIP_SELECT_PIN, LOW);
SPI.transfer((XDATA3 << 1) | READ_BYTE);
uint8_t xdataMSB = SPI.transfer((XDATA2 << 1) | READ_BYTE);
uint8_t xdataMID = SPI.transfer((XDATA1 << 1) | READ_BYTE);
uint8_t xdataLSB = SPI.transfer((YDATA3 << 1) | READ_BYTE);
uint8_t ydataMSB = SPI.transfer((YDATA2 << 1) | READ_BYTE);
uint8_t ydataMID = SPI.transfer((YDATA1 << 1) | READ_BYTE);
uint8_t ydataLSB = SPI.transfer((ZDATA3 << 1) | READ_BYTE);
uint8_t zdataMSB = SPI.transfer((ZDATA2 << 1) | READ_BYTE);
uint8_t zdataMID = SPI.transfer((ZDATA1 << 1) | READ_BYTE);
uint8_t zdataLSB = SPI.transfer(0x00);
digitalWrite(CHIP_SELECT_PIN, HIGH);
SPI.endTransaction();

uint32_t xdata = ((xdataLSB >> 4) | ( xdataMID << 4) | (xdataMSB << 12)) & 0b00000000000011111111111111111111;
double xdata_out;
if (xdata >= 0b00000000000010000000000000000000) {
xdata = (xdata | ~0b00000000000001111111111111111111);
xdata_out = (~xdata + 1);
xdata_out = -1 * xdata_out;
}
else {
xdata_out = xdata;
}

uint32_t ydata = ((ydataLSB >> 4) | ( ydataMID << 4) | (ydataMSB << 12)) & 0b00000000000011111111111111111111;
double ydata_out;
if (ydata >= 0b00000000000010000000000000000000) {
ydata = (ydata | ~0b00000000000001111111111111111111);
ydata_out = (~ydata + 1);
ydata_out = -1 * ydata_out;
}
else {
ydata_out = ydata;
}

uint32_t zdata = ((zdataLSB >> 4) | ( zdataMID << 4) | (zdataMSB << 12)) & 0b00000000000011111111111111111111;
double zdata_out;
if (zdata >= 0b00000000000010000000000000000000) {
zdata = (zdata | ~0b00000000000001111111111111111111);
zdata_out = (~zdata + 1);
zdata_out = -1 * zdata_out;
}
else {
zdata_out = zdata;
}

"