Skip to main content
Visitor II
October 16, 2020
Solved

LIS2DE12 I2C write timeout

  • October 16, 2020
  • 1 reply
  • 1286 views

My application is very low power, and I need to save power wherever possible.

To this end, I do the following:

LIS2DE12_WriteReg(LIS2DE12_MEMS_I2C_ADDRESS, 0x20, 0x08);

Which basically puts the accelerometer in power down mode. The LIS2DE12_WriteReg basically uses HAL_I2C_Mem_Write.

I seem to constantly get a HAL_TIMEOUT returned whenever I try to put the accelerometer in power down mode. I even set the timeout to a high value, and its still the same problem.

Inside LIS2DE12_WriteReg , this is what happens:

HAL_StatusTypeDef i2c_write_status;
 
i2c_write_status = HAL_I2C_Mem_Write(&hi2c1, deviceAddress, WriteAddr, I2C_MEMADD_SIZE_8BIT, (uint8_t*)&Data, 1, 10000);
 
DEBUG_LOG_ACC("I2C Bus Status(A): %d", HAL_I2C_GetError(&hi2c1));
DEBUG_LOG_ACC("I2C Write Status(A): %d", i2c_write_status);

i2c_write status always returns HAL_TIMEOUT.

Thanks for your time.

Tim

    This topic has been closed for replies.
    Best answer by Eleon BORLINI

    Hi @timothy0508​ ,

    not sure you have to write the LPen bit in CTRL_REG1 (20h) register: this bit enables the Low Power mode, and not the Power down mode, which is enabled by the ODR <3:0> = 0000 bin. Can you try to write 00h in the register and check if you still get the HAL_TIMEOUT error?

    -Eleon

    1 reply

    ST Employee
    October 16, 2020

    Hi @timothy0508​ ,

    not sure you have to write the LPen bit in CTRL_REG1 (20h) register: this bit enables the Low Power mode, and not the Power down mode, which is enabled by the ODR <3:0> = 0000 bin. Can you try to write 00h in the register and check if you still get the HAL_TIMEOUT error?

    -Eleon

    ST Employee
    October 22, 2020

    Hi Tim,

    did you make some progression on your issue?

    -Eleon

    Visitor II
    November 1, 2020

    Hi Eleon

    Thanks for checking in. Yes. It turned out there was a hardware pin that controlled the accelerometer. At some specific point in the program, the accelerometer had been accidentally turned off - which explained the timeout error.

    Tim