Hi,
I've been using the Thingy:91 to communicate with some sensors. One of this sensors is causing us some trouble: sometimes the I2C communication with him seems to fail and produces the following behaviour:
-Program blocks, waiting for the response of the unresponsive sensor.
-Watchdog triggers but fails to reset the device (callback function executes).
In order to solve the first problem, ideally it would be that the sensor never fails, but for robustness purposes it would be nice to be able to force a stop condition (or something that would free the i2c communication) on the bus after a certain amount of time. Searching in the devzone I have found information on non-blocking TWI but some of these posts are 2 years old and I am not sure if the code they talk about is the way to go with the Thingy:91. Additionally I am not aware of a timeout possibility when using i2c.h. Could you explain me when to use i2c/twi/twim functions and when not? Is there any function I could use in order to implement a timeout?
Moreover, I have a problem with the Wathcdog. When the watchdog triggers due to the i2c blockage, it executes the callback function (where I make the LEDs on the Thingy:91 blink white) but afterwards it fails to reset the device. Motivated by this error, I tried other behaviours when the wathcdog triggers, which are defined on its setup. I found out that when I use the flags "WDT_FLAG_RESET_CPU_CORE
" and "WDT_FLAG_RESET_NONE
" there is an error and the device enters a rebooting loop. Would this be a normal behaviour, meaning that the only flag I can use is "WDT_FLAG_RESET_SOC
"?
Thank you very much for your help.
Aleix.