Dynamic light sleep strange behaviour

daniSi
Posts: 47
Joined: Thu Dec 23, 2021 9:43 am

Dynamic light sleep strange behaviour

Postby daniSi » Fri Dec 23, 2022 9:29 am

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

axellin
Posts: 200
Joined: Mon Sep 17, 2018 9:09 am

Re: Dynamic light sleep strange behaviour

Postby axellin » Fri Dec 23, 2022 9:50 am

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.

daniSi
Posts: 47
Joined: Thu Dec 23, 2021 9:43 am

Re: Dynamic light sleep strange behaviour

Postby daniSi » Fri Dec 23, 2022 10:36 am

Thank you for the quick reply, an issue was opened https://github.com/espressif/esp-idf/issues/10434.

Who is online

Users browsing this forum: benrank, Bing [Bot], MicroController and 120 guests