cancel
Showing results for 
Search instead for 
Did you mean: 

LIS2DE12 I2C write timeout

timothy0508
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions
Eleon BORLINI
ST Employee

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

View solution in original post

4 REPLIES 4
Eleon BORLINI
ST Employee

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

Hi Tim,

did you make some progression on your issue?

-Eleon

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

Thank you for the feedback Tim!

-Eleon