2023-12-15 02:26 AM
Hi Experts,
I am using lis2dw12 accelerometer connected to esp32s3 and recently have got a situation which is blocking for esp32s3 to read status registers of accelerometer when LIR =1 (latched mode). I put accelerometer on stationary mode and routing the intruppt to INT1 which resets my esp32. Interrupt is working fine but when I want to read tap_source or wakeup_source or in general ALL_INT_SRC ( not pulling them. only one time) to detect the reset reason on my esp32 side, It will be hanged sometimes until esp32 watchdog happens and from that point the status register are readable since i2c is reinitiated I guess. Whould you mind please help me to underestand why acccelerometer get frozen?
Here is my configurations:
and after reboot which takes only 10ms I try to read:
2023-12-15 06:47 AM
Hi @farshad ,
Welcome to ST Community!
When you reset your esp32, is the lis2dw12 always powered on?
2023-12-15 06:58 AM
Yes it has seperated 3.3 voltage source which is always on. I may need to send him to stationary or double tap mode after esp32 reboot( if the wake up reason was INT1 trigger from accelerometer)
2023-12-15 07:00 AM
Yes it has seperated 3.3 voltage source which is always on. I may need to send him to stationary or double tap mode after esp32 reboot( if the wake up reason was INT1 trigger from accelerometer)
2023-12-15 07:15 AM
Perfect. Are you sure that the i2c is ready to read the sensor, when the micro reboots? you need to understand what is the difference between the first read that does not return anything and the one after the watchdog triggers... you could try to read the whoami register to see if there are problems with that register or the whole sensor.
2023-12-15 07:23 AM - edited 2023-12-15 07:36 AM
I have already tried reading whoamI and seems it get stuck reading from accelerometer while I am sure I2c is reinitiated after each reboot and ready to be used since there is and rtc module also reading from i2c and is functional( they dont have any interference).
It is worth mentioning it randomly happen and for example if you lift the senor and keep it face up for a while it likely stopps before reading form I2C process(like accelerometer is hanged somewhere, Write process is also not working). I even tried a loop to read status register after reboot to see if the value of flags change but they are somehow froozen sometimes. Is not it related to happening two WU_IA in a row before reading the wake_up source register or all_int_src register?
2023-12-18 12:44 AM
Which interrupt routine are you using for ESP32S3?
The interrupt routine must be as short as possible in order to avoid the watchdog to start. All the readings after the interrupt should be done in a separate routine.
2023-12-18 01:01 AM
Interrupts routine is so short and fast. INT1 pin is connected to PWR_ON pin of ESP32S3 and As I said before reboot time take a couples of 10ms until we start to read from I2C. I insiste to say when LIR=0 every read from I2C , at the same API call level, will work but when LIR=1 esp32 watchdog reset happens. Could you please check the differences between this two working mode? I guess LIS2DW12 needs to write event flags in NVS which can leads to not being responding during that process or.....
2023-12-21 07:41 AM
Hi @farshad ,
The difference between latched and pulsed should be only the duration of the interrupt signal level to stay high but we will do further analysis to try to replicate your issues.
However, can you provide us your project schematic (which ESP32 pin are you using to communicate with our sensor), and the line code in which you detect the interrupt event and the following few lines?
Moreover, it can be helpful for us to read the esp32 message about reboot and watchdog Timer. When does the reboot of 10ms happen? Thanks.
2024-01-03 07:33 AM
Hi Federica,
Sorry for my late response due to the holidays. I actually found the problem but I have no proper explanation for the reason of that. As I mentioned above I only try to put the accelerometer in the stationary after each esp32s3 power on. Accelerometer can wake up the esp32s3 since the INT pin is connected to esp_pwr_on pin( you can see in the schematic). The faulty scenario happens when I set accelerometer in stationary + latched mode enabled(LIR = 1).
Faulty scenario: while I bring the accelerometer out of latched mode (LIR=0) and wait for wakeup source register clean up through polling loop, If I shake the sensor during reconfiguration, it will finally come out of the polling loop and Accelerometer goes to latched mode again( here something happens) and I will not be able to read or write from/to accelerometer until shaking stops for next configuration.
*****after every power on of esp32 I have the following code immediately:
========================================> I have noticed that when execution reaches here, there should not be any movement for accelerometer( wakeup_source_reg = 00) and not any interrupt should not happen before configuration. I am sure about that since I have tried a lot to keep the accelerometer stationery before this line execution and it will never crashes================= >
+++++I is worth mentioning if accelerometer is steady within the above execution until esp32 goes to power down, any movement powers on the esp and if accelerometer gets steady before the above code execution it will never crashes
esp_en goes to esp32s3 pwr_en pin