AnsweredAssumed Answered

ADXL362 giving false readings after brownout?

Question asked by robertjenkins on Mar 27, 2018
Latest reply on Mar 27, 2018 by jwang

I have a problem with the ADXL362 giving false readings which seems to occur after the power supply voltage drops below a certain level. Even when the voltage is restored to a correct level, these false readings persist. The only way is to disconnect power altogether, and in my embedded application this is not possible since the battery is hard wired.

 

More details:

 

When the program starts, the functions begin() and beginMeasure() are called. These are as follows:

 

void begin() {

pinMode(slaveSelectPin, OUTPUT);

SPI.begin();

SPIwriteOneRegister(0x2C, 0x03); //ODR at 100

SPI.setDataMode(SPI_MODE0); //CPHA = CPOL = 0 MODE = 0

 

// soft reset

SPIwriteOneRegister(0x1F, 0x52); // Write to SOFT RESET, "R"

delay(100);

}

 

 

void beginMeasure() {

byte temp = SPIreadOneRegister(0x2D); // read Reg 2D before modifying for measure mode

// turn on measurement mode

byte tempwrite = temp | 0x02; // turn on measurement bit in Reg 2D

SPIwriteOneRegister(0x2D, tempwrite); // Write to POWER_CTL_REG, Measurement Mode

delay(10);

}

 

 

Then X Y and Z readings are taken as follows:

 

int XDATA = SPIreadTwoRegisters(0x0E);

int YDATA = SPIreadTwoRegisters(0x10);

int ZDATA = SPIreadTwoRegisters(0x12);

 

 

When the program is working normally and correctly, XDATA, YDATA and ZDATA are generally within the range -800 to 800

However, when the malfunction occurs, all three variables are stuck at 32677 ie (2^15)-1

 

 

It appears that the device is not being reset properly, despite begin() being called. In case it is of any use, here are the SPI read and write functions

 

 

 

void SPIwriteOneRegister(byte regAddress, byte regValue){

 

digitalWrite(slaveSelectPin, LOW);

SPI.transfer(0x0A); // write instruction

SPI.transfer(regAddress);

SPI.transfer(regValue);

digitalWrite(slaveSelectPin, HIGH);

}

 

 

int SPIreadTwoRegisters(byte regAddress){

int twoRegValue = 0;

digitalWrite(slaveSelectPin, LOW);

SPI.transfer(0x0B); // read instruction

SPI.transfer(regAddress);

twoRegValue = SPI.transfer(0x00);

twoRegValue = twoRegValue + (SPI.transfer(0x00) << 8);

digitalWrite(slaveSelectPin, HIGH);

return twoRegValue;

}

 

void SPIwriteTwoRegisters(byte regAddress, int twoRegValue){

byte twoRegValueH = twoRegValue >> 8;

byte twoRegValueL = twoRegValue;

digitalWrite(slaveSelectPin, LOW);

SPI.transfer(0x0A); // write instruction

SPI.transfer(regAddress);

SPI.transfer(twoRegValueL);

SPI.transfer(twoRegValueH);

digitalWrite(slaveSelectPin, HIGH);

}

 

 

I really need help to sort this out and am really stuck!

Outcomes