Watchdog triggered after light sleep wake up

dacitt
Posts: 4
Joined: Thu Dec 20, 2018 4:53 pm

Watchdog triggered after light sleep wake up

Postby dacitt » Tue Jan 08, 2019 5:01 pm

Hi all,

in my esp32 freertos project I put the chip in light sleep, during witch ULP is active and check if a ADC value is over certain treshold.
Wake up works well, but if sleep last more than 2-3 minutes nothing happens and watchdog is triggered on esp_timer (no problem if sleep is less than 2 minutes).

Actually I have set in my project 2 task called by esp_timer callback, following instruction of espressif guide and they works well but after wake up from relative long light sleep they don't work anymore until watchdog action.

Log:
Task watchdog got triggered. The following tasks did not reset the watchdog in time:
- IDLE (CPU 0)
Tasks currently running:
CPU 0: esp_timer

Any suggestions? Are esp_timers incompatible with ULP adc/light sleep?

Thanks!

ESP_igrr
Posts: 1413
Joined: Tue Dec 01, 2015 8:37 am

Re: Watchdog triggered after light sleep wake up

Postby ESP_igrr » Tue Jan 08, 2019 5:33 pm

Hi dacitt, you might have run into a bug of some sort. Can you share your project (e.g. via a PM) so that we can reproduce the issue on our end?

dacitt
Posts: 4
Joined: Thu Dec 20, 2018 4:53 pm

Re: Watchdog triggered after light sleep wake up

Postby dacitt » Wed Jan 09, 2019 7:17 am

I will provide complete code soon.
Just a question to be sure: is it normal that esp_timer callback tasks are running also during light_sleep mode?
If i put a esp_logi inside the function task I can see log during sleep.

For example, one task is initialized in this way:

Code: Select all

 esp_timer_create_args_t x_args =
  {
    .callback = ACInputTask,        //!< Function to call when timer expires
    .arg = NULL,                      //!< Argument to pass to the callback
    .dispatch_method = ESP_TIMER_TASK,   //!< Call the callback from task or from ISR
    .name = "ACInputTim",
  };
  esp_timer_create(&x_args, &x_ACInput_Timer_Hdl);
  
  esp_timer_start_periodic(x_ACInput_Timer_Hdl, 250);
They work well in normal condition (no sleep).

Thanks

ESP_igrr
Posts: 1413
Joined: Tue Dec 01, 2015 8:37 am

Re: Watchdog triggered after light sleep wake up

Postby ESP_igrr » Wed Jan 09, 2019 12:21 pm

If i put a esp_logi inside the function task I can see log during sleep.
No, this most definitely should not be happening. If you see the logs being printed, this means that the chip is not in light sleep. All peripherals are clock gated in light sleep, so no UART output can be produced in this state.

I think the issue might be that if the timer period is 250 microseconds, but you insert a log message into the handler, so the handler will take more than 250 microseconds to run. Therefore it will be constantly executing (next timeout will trigger while the callback is still running). This will prevent lower priority task (such as the one where app_main is running) from running and entering light sleep. Try replacing log output with something which takes less than 250 microseconds (e.g. toggling a GPIO) or increase the timer period when doing this test, to give lower priority tasks a chance to run.

dacitt
Posts: 4
Joined: Thu Dec 20, 2018 4:53 pm

Re: Watchdog triggered after light sleep wake up

Postby dacitt » Wed Jan 09, 2019 1:40 pm

Yes you are right, this task is continuously executed and main app is never called -> no call to light sleep.
Are esp timer freezed during light sleep? This short period of timer could be responsible of the trigger of watchdog after sleep?

Thanks

ESP_igrr
Posts: 1413
Joined: Tue Dec 01, 2015 8:37 am

Re: Watchdog triggered after light sleep wake up

Postby ESP_igrr » Wed Jan 09, 2019 2:02 pm

Timer callbacks are not executed during light sleep (no code is executed, because CPUs are clock gated). After wakeup, pending timers (which would have triggered during sleep) will run. However periodic timers will run at most once, and then will keep running with their expected period.

Return to “General Discussion”

Who is online

Users browsing this forum: Bing [Bot] and 21 guests