esp-idf/examples/system/ulp/lp_core/gpio
Marius Vikhammer 1fa59c442b fix(ulp): fixed lp-core not booting during sleep
LP core was unable to boot when system was in deepsleep.
This was due to lp uart init in LP rom using XTAL as clk source,
which is normally powered down during sleep.

This would cause lp uart to get stuck while printing ROM output,
and the app would never boot.

Also fixed wrong wakeup cause used by HP core for ULP wake up
2024-04-18 11:36:30 +08:00
..
main
CMakeLists.txt
README.md fix(ulp): fixed lp-core not booting during sleep 2024-04-18 11:36:30 +08:00
sdkconfig.defaults

README.md

Supported Targets ESP32-C6 ESP32-P4

LP Core simple example with GPIO Polling:

This example demonstrates how to program the ULP coprocessor to poll a gpio and wakeup the main CPU when it changes its state;

ULP program written in C can be found across ulp/main.c. The build system compiles and links this program, converts it into binary format, and embeds it into the .rodata section of the ESP-IDF application.

At runtime, the application running inside the main CPU loads ULP program into the RTC_SLOW_MEM memory region using ulp_lp_core_load_binary function. The main code then configures the ULP wakeup period and starts the coprocessor by using ulp_lp_core_run. Once the ULP program is started, it runs periodically, with the period set by the main program. The main program enables ULP wakeup source and puts the chip into deep sleep mode.

When the ULP program finds an state changing in the pin, it saves the current state and sends a wakeup signal to the main CPU.

Upon wakeup, the main program prints the current level of the measured gpio and go back to the deep sleep.

In this example the input signal is connected to GPIO0. Note that this pin was chosen because most development boards have a button connected to it, so the pulses to be counted can be generated by pressing the button. For real world applications this is not a good choice of a pin, because GPIO0 also acts as a bootstrapping pin. To change the pin number, check the chip pin list document and adjust WAKEUP_PIN macros in main.c and lp_core_gpio_example_main.c.

Example output

Not a ULP wakeup, initializing it!
Entering in deep sleep

...

ULP woke up the main CPU!
ULP read changes in GPIO_0 current is: High
Entering in deep sleep