Page 1 of 1

Dynamic light sleep strange behaviour

Posted: Fri Dec 23, 2022 9:29 am
by daniSi
Hi,

I have a code which takes always different time to execute. After this execution the MCU has to go to light sleep, but always wake up at same time (with accuracy of few 100ms). I calculate the code execution time correctly but when setting the sleep wake up value its only the first time correct, and later wrong. I have setup a small test program where the strange behaviour can be simulated:
  1. gpio_set_level(DEVICE_DEBUG_PIN, 1);
  2. vTaskDelay(pdMS_TO_TICKS(5000));
  3. uint64_t testTim = 5 * 1000000;
  4. printf("START SLEEP TIME: %lld\n", testTim);
  5. gpio_set_level(DEVICE_DEBUG_PIN, 0);
  6. vTaskDelay(pdMS_TO_TICKS(5)); /* Small delay just to make shure pin goes low before sleep */
  7. esp_timer_start_periodic
  8. while(1){
  9.     esp_sleep_enable_timer_wakeup(testTim);
  10.     esp_light_sleep_start();
  11.  
  12.     gpio_set_direction(DEVICE_DEBUG_PIN, GPIO_MODE_OUTPUT);
  13.     gpio_set_level(DEVICE_DEBUG_PIN, 1);
  14.     vTaskDelay(pdMS_TO_TICKS(2000));
  15.     testTim += 5000000;
  16.     gpio_set_level(DEVICE_DEBUG_PIN, 0);
  17.     vTaskDelay(pdMS_TO_TICKS(5)); /* Small delay just to make shure pin goes low before sleep */
  18. }
Here are the results measured with a logic analyser. First is the start sequence with 5s, later the sleep time (pin state low) should start with 5s and increase every iteration for 5s.
Image
Image

Is it not possible to change the timer wake up dynamical or do I have some bug in the code?

Thank you

Re: Dynamic light sleep strange behaviour

Posted: Fri Dec 23, 2022 9:50 am
by axellin
Can you create an issue on https://github.com/espressif/esp-idf/issues ?
Also please provide your esd-idf version (git describe --tags output), SoC/Module , and sdkconfig.

Re: Dynamic light sleep strange behaviour

Posted: Fri Dec 23, 2022 10:36 am
by daniSi
Thank you for the quick reply, an issue was opened https://github.com/espressif/esp-idf/issues/10434.