AnsweredAssumed Answered

LIS2DH: Minimum delay between commands during Self-test

Question asked by Gar.Cesco on Mar 28, 2017
Latest reply on Jan 11, 2018 by M Poppitz

Hi,

is it possible to know the minimum delay required to wait between register writing during the self-test?

 

I write down my code, to make myself more clear

 

while(1)
{
BYTE xH = 0;
BYTE yH = 0;
BYTE zH = 0;

//HPF disabling
writeRegAccel(BYTE_REG2, WRT_CTRL_REG2_WO_MS);
//Minimum delay to swotch from a mode to another
delayMs(7);
//I set the frequency at 5k376 Hz
writeRegAccel(LOW_PWR_MODE_5K376HZ_W_XYZ, WRT_CTRL_REG1_WO_MS);
delayMs(7);

//I read the 3 H axis
//First reading with garbage data
xxx1:
if(((readRegAccel(STATUS_REG)) & 0x08) == 0x08)
{
readRegAccel(OUT_X_H);
readRegAccel(OUT_Y_H);
readRegAccel(OUT_Z_H);
}else{
goto xxx1;
}

//Second reading of the "real" datas
xxx2:
if(((readRegAccel(STATUS_REG)) & 0x08) == 0x08)
{
xH = readRegAccel(OUT_X_H);
resultAbsX = abs(xH);
yH = readRegAccel(OUT_Y_H);
resultAbsY = abs(yH);
zH = readRegAccel(OUT_Z_H);
resultAbsZ = abs(zH);
}else{
goto xxx2;
}

//Self-test function
accel_Test();

//Display refresh
shwAccelTest(SHW_ACCEL_RFSH);
//Disabling the self-test mode
writeRegAccel(BYTE_REG4, WRT_CTRL_REG4_WO_MS);

//I clear the memory in case there are garbage readings
xxx3:
if(((readRegAccel(STATUS_REG)) & 0x08) == 0x08)
{
readRegAccel(OUT_X_H);
readRegAccel(OUT_Y_H);
readRegAccel(OUT_Z_H);
}else{
goto xxx3;
}

xxx4:
if(((readRegAccel(STATUS_REG)) & 0x08) == 0x08)
{
readRegAccel(OUT_X_H);
readRegAccel(OUT_Y_H);
readRegAccel(OUT_Z_H);
}else{
goto xxx4;
}

//HPF reactivation 
writeRegAccel(BYTE_REG2_HP, WRT_CTRL_REG2_WO_MS);
//I set the frequency to 50 Hz 
writeRegAccel(LOW_PWR_MODE_50HZ_W_XYZ, WRT_CTRL_REG1_WO_MS);
delayMs(20);
}

 

 

accel_Test FUNCTION

 

void accel_Test()
{
BYTE xH_Test = 0;
BYTE yH_Test = 0;
BYTE zH_Test = 0;
BYTE delta_X = 0;
BYTE delta_Y = 0;
BYTE delta_Z = 0;

//I activate the self-test
writeRegAccel(BYTE_REG4_SELF_TEST, WRT_CTRL_REG4_WO_MS);
//Minimum delay to activate the self-test
delayMs(7);

 


//First reading (garbage data)
xxx3:
if(((readRegAccel(STATUS_REG)) & 0x08) == 0x08)
{
readRegAccel(OUT_X_H);
readRegAccel(OUT_Y_H);
readRegAccel(OUT_Z_H);
}else{
goto xxx3;
}

//Second reading of the effective data
xxx4:
if(((readRegAccel(STATUS_REG)) & 0x08) == 0x08)
{
xH_Test = readRegAccel(OUT_X_H);
resultAbsTestX = abs(xH_Test);
yH_Test = readRegAccel(OUT_Y_H);
resultAbsTestY = abs(yH_Test);
zH_Test = readRegAccel(OUT_Z_H);
resultAbsTestZ = abs(zH_Test);
}else{
goto xxx4;
}

 

//I make a delta between the two reading
delta_X = resultAbsTestX - resultAbsX;
delta_Y = resultAbsTestY - resultAbsY;
delta_Z = resultAbsTestZ - resultAbsZ;
//Delta's absolute of the datas
delta_X = abs(delta_X);
delta_Y = abs(delta_Y);
delta_Z = abs(delta_Z);

//Results control
if(delta_X > KMIN_DELTA_TEST_ACC ||
delta_Y > KMIN_DELTA_TEST_ACC ||
delta_Z > KMIN_DELTA_TEST_ACC )
{
//Result OK
}else{
//Result error
}
}

 

 

If I don't put those delay of 7ms, the accelerometer will give me back wrong datas, like 0xff or datas from before the self-test was deactivated.

Thus, is there a minimum delay I need to set after I change my frequency or set other registers?

I translated my comments so that the reading will be simplier.

 

Thank you

Outcomes