I'm having an issue with the RTC being reset after waking up from a deepsleep. I have narrowed it down to the way the ESP32-C3 is being woken up on one of the GPIO pins.
I currently have a nchannel mosfet at GPIO input (see attached image) and have the following code in startup to print out the reason for wakeup:
Code: Select all
esp_reset_reason_t esp_reason = esp_reset_reason();
printf("ESP reset reason: %i\n", esp_reason);
RESET_REASON rtc_reason = rtc_get_reset_reason(0);
printf("RTC reset reason: %i\n", rtc_reason);
esp_sleep_source_t wakeup_respon = esp_sleep_get_wakeup_cause();
printf("Wakeup reason: %i\n", wakeup_respon);
ESP reset reason: 8
RTC reset reason: 5
Wakeup reason: 7
but sometimes i get the following:
ESP reset reason: 1
RTC reset reason: 1
Wakeup reason: 0
and when i get this the RTC time has been reset.
Another thing i tried was to replace the nchannel mosfet with a switch (to experiment) and found that in over 10,000 wakeups, it always woke up correctly.
I then tried using a sine wave as the wakeup signal and found that it would ALWAYS fail wakeup (RTC would be reset).
This led me to believe that the rise/fall time of the wkaeup pulse has an effect on this error. Anything with a rise/fall time of less than 100uS 'seems' to be ok but anything greater causes issues in the wakeup.
I appreciate your time and hope you can help resolve this as the nchannel mosfet is the setup i require.
Note:
Currently using the ESP32-C3-MINI on IDF V4.4.2