|
1 |
| -| Supported Targets | ESP32-C6 | |
2 |
| -| ----------------- | -------- | |
| 1 | +| Supported Targets | ESP32-C5 | ESP32-C6 | ESP32-P4 | |
| 2 | +| ----------------- | -------- | -------- | -------- | |
| 3 | +# ULP-LP-Core simple example with GPIO Interrupt: |
3 | 4 |
|
4 |
| -This example demonstrates how to program the ULP Core coprocessor to count pulses on an IO while the main CPUs are either running some other code or are in deep sleep. See the README.md file in the upper level 'examples' directory for more information about examples. |
| 5 | +This example demonstrates how to program the LP-Core coprocessor to wake up from a RTC IO interrupt, instead of waking periodically from the ULP timer. |
5 | 6 |
|
6 |
| -At runtime, the main code running on the ESP (found in lp_core_pulse_counter_example_main.c) loads ULP program into the `RTC_SLOW_MEM` memory region using `ulp_lp_core_load_binary` function. Main code configures the ULP program by setting up values of some variables and then starts it using `ulp_lp_core_run`. Once the ULP program is started, it monitors the IO pin for pulses. |
| 7 | +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. |
7 | 8 |
|
8 |
| -When the ULP program finds an edge in the input signal, it performs debouncing and increments the variable maintaining the total edge count. Once the edge count reaches certain value, ULP triggers wake up from deep sleep. Note that the ULP program keeps running and monitoring the input signal even when the SoC is woken up. |
| 9 | +At runtime, the main code running on the ESP (found in lp_core_gpio_wake_up_example_main.c) loads ULP program into the `RTC_SLOW_MEM` memory region using `ulp_lp_core_load_binary` function. The main code then configures the ULP GPIO wakeup source and starts the coprocessor by using `ulp_lp_core_run` followed by putting the chip into deep sleep mode. |
9 | 10 |
|
10 |
| -### Hardware Required |
| 11 | +When the wakeup source pin is pulled low the LP-Core coprocessor is woken up, sends a wakeup signal to the main CPU and goes back to sleep again. |
11 | 12 |
|
12 |
| -To run this example, you should have a development board based on any of the chips listed in the supported targets table at the top and a host machine with a serial input connection. |
| 13 | +In this example the input signal is connected to GPIO2. To change the pin number, check the Chip Pin List document and adjust `WAKEUP_PIN` variable in main.c. |
13 | 14 |
|
14 |
| -#### Pin Assignment: |
15 | 15 |
|
16 |
| -**Note:** The following pin assignments are used by default. |
| 16 | +## Example output |
17 | 17 |
|
18 |
| - |
19 |
| -| | Uart Tx | Pulse Count Input | |
20 |
| -| ----------------------- | ------- | ----------------- | |
21 |
| -| ESP32-C6 | GPIO5 | GPIO6 | |
22 |
| -| Host machine | Rx | N/A | |
23 |
| - |
24 |
| - |
25 |
| -## Example Output |
26 |
| - |
27 |
| -The log output from the serial monitor connected to the main core should indicate that the LP core and the LP UART peripheral have been successfully initialized. The main CPU would then enter deep sleep mode. |
28 |
| - |
29 |
| -```bash |
30 |
| -Using pin 6 as pulse counter input |
31 |
| -ULP will wake up processor after every 10 pulses |
32 |
| -Not a ULP wakeup, initializing it! |
33 |
| -Entering in deep sleep |
34 |
| -... |
35 |
| -rst:0x5 (SLEEP_WAKEUP),boot:0xc (SPI_FAST_FLASH_BOOT) |
36 |
| -... |
37 |
| -ULP woke up the main CPU! |
38 |
| -Pulse count: 11 |
39 |
| -Entering in deep sleep |
40 | 18 | ```
|
| 19 | +Not a LP-Core wakeup, initializing it! |
| 20 | +Entering deep sleep |
41 | 21 |
|
42 |
| -The log output from the serial monitor connected to the LP core should display output as below - |
| 22 | +... |
43 | 23 |
|
44 |
| -```bash |
45 |
| -LP Core pulse counter started |
46 |
| -Pulse count: 10, wake-up main CPU |
| 24 | +LP-Core woke up the main CPU! |
| 25 | +Entering deep sleep |
47 | 26 | ```
|
48 |
| - |
49 |
| -## Troubleshooting |
50 |
| - |
51 |
| -(For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you as soon as possible.) |
0 commit comments