2020-10-16 01:05 AM
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
Solved! Go to Solution.
2020-10-16 07:56 AM
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
2020-10-16 07:56 AM
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
2020-10-22 04:41 AM
Hi Tim,
did you make some progression on your issue?
-Eleon
2020-10-31 05:01 PM
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
2020-11-01 11:13 PM
Thank you for the feedback Tim!
-Eleon