espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.7k stars 7.3k forks source link

esp32c6 lp core in halt high power consumption (IDFGH-13765) #14626

Open Szybet opened 1 month ago

Szybet commented 1 month ago

Answers checklist.

General issue report

In the ulp program (so lp core, the naming is confusing) I call

    ulp_lp_core_lp_timer_set_wakeup_time(20 * 1000000);
    ulp_lp_core_halt();

I know those are called after the main function exits, but I wanted to be sure, the results are the same in both

So, to the issue, in regular call to esp_deep_sleep_start(); the device consumes 350 uA, When I run the lp core it runs then exits with the code above, then the device consumes 400 uA but doesn't wakes up, which is normal, I didn't call ESP_ERROR_CHECK(esp_sleep_enable_ulp_wakeup());. When I call it and then go to sleep, the lp core does wake up how it's supposed to but the power consumption is 900 uA while the lp core is not running. It's really a lot, I think something is wrong because at that point going to full deep sleep and waking up the hp core would give similar results in the long run.

The issue described here: https://esp32.com/viewtopic.php?t=34643 sounds similar to my problem but I checked, I call the correct functions

my esp idf version is 5.3 As already mentioned that's on the esp32c6, I measure the currents with NRF-PPK2

Any ideas? Thanks

ESP-Marius commented 1 month ago

Hi,

Can you try running the GPIO example (just delete the GPIO related code from it) and see what you get?

I just did on v5.3.1 and i got reasonable results when measuring with my devkit (10 uA when ULP sleeping, peak 2 mA when ULP woken up)

Szybet commented 1 month ago

Yes, I have done some testing and on the devkit via the measuring pins I get 10 uA and 2 mA when running. Maybe the cause are rtc pins being initialized? How do I control what they do (Low, high) while the lp core is not running? Do they remember the previous state when the lp core halts?

Szybet commented 1 month ago

Yes, configuring the rtc gpio causes this, rtc_gpio_isolate fixes it but dissalows the lp core to use the gpio... Any idea how to fix it?

ESP-Marius commented 1 month ago

Are these input or output pins? what do you want them to do while the ULP is sleeping?

janav1 commented 1 month ago

I am also observing the same problem. By putting the HP core to sleep and using the LP core to monitor two inputs for the interrupt on change I try to achieve low consumption, but the measured current is around 1 mA. I only use 2 pins as inputs with pull up enabled - from the buttons. Module is ESP32-C6-WROOM-1 with ESP-IDF 5.3.1 release version.

Szybet commented 1 month ago

fixed my issue by setting an output pin high. It's weird that not calling the ulp wakeup function fixes it (which caused the confussion and the reason for posting this issue), or that setting the pin to open drain output didnt fix it

The issue could be closed, but janav1 has a similar issue so I will not close it for now

janav1 commented 2 weeks ago

My issue still persists. I am not able to achieve low power and simultaneously wait for an interrupt with the LP core. In this case, I measure a current of 1.3 mA. My project is attached. When the LP core does not do anything and just sleeps, the power consumption is about 370 uA - tested on custom board and on ESP32-C6-DevKitC-1 V1.2. There is some issue with some pins - like GPIO2 (LP_GPIO_2), which ignores my settings and is always HIGH regarding value in gpio_set_level(). GPIO dump is:

================IO DUMP Start================
IO[0] -
  Pullup: 0, Pulldown: 0, DriveCap: 2
  InputEn: 0, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[1] -
  Pullup: 0, Pulldown: 0, DriveCap: 2
  InputEn: 0, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[2] -
  Pullup: 0, Pulldown: 0, DriveCap: 2
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[3] -
  Pullup: 0, Pulldown: 0, DriveCap: 2
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[4] -
  Pullup: 0, Pulldown: 0, DriveCap: 2
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[5] -
  Pullup: 0, Pulldown: 0, DriveCap: 2
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[6] -
  Pullup: 0, Pulldown: 0, DriveCap: 2
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[7] -
  Pullup: 0, Pulldown: 0, DriveCap: 2
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[8] -
  Pullup: 0, Pulldown: 0, DriveCap: 2
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[9] -
  Pullup: 1, Pulldown: 0, DriveCap: 2
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[10] -
  Pullup: 0, Pulldown: 0, DriveCap: 2
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[11] -
  Pullup: 0, Pulldown: 0, DriveCap: 2
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[12] -
  Pullup: 0, Pulldown: 0, DriveCap: 3
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[13] -
  Pullup: 1, Pulldown: 0, DriveCap: 3
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[14] -
  Pullup: 0, Pulldown: 0, DriveCap: 2
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[15] -
  Pullup: 0, Pulldown: 0, DriveCap: 2
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[16] -
  Pullup: 1, Pulldown: 0, DriveCap: 2
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[17] -
  Pullup: 1, Pulldown: 0, DriveCap: 2
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[18] -
  Pullup: 0, Pulldown: 0, DriveCap: 2
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[19] -
  Pullup: 0, Pulldown: 0, DriveCap: 2
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[20] -
  Pullup: 0, Pulldown: 0, DriveCap: 2
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[21] -
  Pullup: 0, Pulldown: 0, DriveCap: 2
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[22] -
  Pullup: 0, Pulldown: 0, DriveCap: 2
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[23] -
  Pullup: 0, Pulldown: 0, DriveCap: 2
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[24] **RESERVED** -
  Pullup: 1, Pulldown: 0, DriveCap: 1
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[25] **RESERVED** -
  Pullup: 1, Pulldown: 0, DriveCap: 1
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[26] **RESERVED** -
  Pullup: 1, Pulldown: 0, DriveCap: 1
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 1 (GPIO)
  GPIO Matrix SigIn ID: (simple GPIO input)
  SleepSelEn: 1

IO[27] -
  Pullup: 0, Pulldown: 0, DriveCap: 2
  InputEn: 0, OutputEn: 0, OpenDrain: 0
  FuncSel: 1 (GPIO)
  SleepSelEn: 1

IO[28] **RESERVED** -
  Pullup: 1, Pulldown: 0, DriveCap: 1
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 1 (GPIO)
  GPIO Matrix SigIn ID: (simple GPIO input)
  SleepSelEn: 1

IO[29] **RESERVED** -
  Pullup: 1, Pulldown: 0, DriveCap: 1
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

IO[30] **RESERVED** -
  Pullup: 1, Pulldown: 0, DriveCap: 1
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 0 (IOMUX)
  SleepSelEn: 1

=================IO DUMP End==================

My project is attached. I am using GPIO7 as input with pullup for interrupt and GPIO2 and 3 for output LED indication. Any help is appreciated. ULPWakeUp.zip

ESP-Marius commented 1 week ago

@janav1 sorry for the slow reply. You are initializing LP UART, which will config and take a few of the IO pins.

If you want to go fully into deep sleep while waiting for a IO interrupt I suggest you check out the lp_core/gpio_wakeup and see if that can help you get something working.