esp-idf/examples/system/ulp/ulp_riscv/gpio_interrupt
Marius Vikhammer 9d41418bd2 fix(ulp): improve ULP examples for users using usb-jtag-serial
When using USB-serial-jtag for monitoring idf-monitor will lose connection
during deep sleep (because the peripheral powers down) and will need
some time to reconnect when we wake-up. In the ULP examples this would result in
the chip waking up->printing-> going back to sleep, before idf-monitor is even able
to connect, and users would erroneously assume the chip never woke up.

Add a 1 sec delay at the start of the examples to improve the user experience when
using jtag-serial.
2024-01-15 13:01:59 +08:00
..
main fix(ulp): improve ULP examples for users using usb-jtag-serial 2024-01-15 13:01:59 +08:00
CMakeLists.txt ulp/lp-core: added gpio API for lp core as well as an example showcasing it. 2023-05-29 11:13:47 +08:00
README.md ulp/lp-core: added gpio API for lp core as well as an example showcasing it. 2023-05-29 11:13:47 +08:00
sdkconfig.defaults ulp/lp-core: added gpio API for lp core as well as an example showcasing it. 2023-05-29 11:13:47 +08:00

Supported Targets ESP32-S2 ESP32-S3

ULP-RISC-V simple example with GPIO Interrupt:

This example demonstrates how to program the ULP-RISC-V coprocessor to wake up from a RTC IO interrupt, instead of waking periodically from the ULP timer.

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_riscv_load_binary function. The main code then configures the ULP GPIO wakeup source and starts the coprocessor by using ulp_riscv_config_and_run followed by putting the chip into deep sleep mode.

When the wakeup source pin is pulled low the ULP-RISC-V coprocessor is woken up, sends a wakeup signal to the main CPU and goes back to sleep again.

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 variable in main.c.

Example output

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

...

ULP-RISC-V woke up the main CPU!
Entering in deep sleep