Chapter 4. API Guides
Once the program is loaded into RTC memory, the application can start it, passing the address of the entry point to
the ulp_run function:
ESP_ERROR_CHECK( ulp_run(&ulp_entry
esp_err_t
ulp_run(uint32_t entry_point)
Run the program loaded into RTC memory.
Return ESP_OK on success
Parameters
• entry_point: entry point, expressed in 32-bit words
Declaration of the entry point symbol comes from the generated header file mentioned above,
${ULP_APP_NAME}.h. In the assembly source of the ULP application, this symbol must be marked as
.global:
.global
entry
entry:
/*
code starts here
4.28.7 ESP32-S2 ULP program flow
ESP32-S2 ULP coprocessor is started by a timer. The timer is started once ulp_run is called. The timer counts
a number of RTC_SLOW_CLK ticks (by default, produced by an internal 90 kHz RC oscillator). The number of
ticks is set using RTC_CNTL_ULP_CP_TIMER_1_REG register.
The application can set ULP timer period values by ulp_set_wakeup_period function.
esp_err_t
ulp_set_wakeup_period(size_t period_index, uint32_t period_us)
Set one of ULP wakeup period values.
ULP coprocessor starts running the program when the wakeup timer counts up to a given value (called period).
There are 5 period values which can be programmed into SENS_ULP_CP_SLEEP_CYCx_REG registers, x =
0..4 for ESP32, and one period value which can be programmed into RTC_CNTL_ULP_CP_TIMER_1_REG
register for ESP32-S2.
SENS_ULP_CP_SLEEP_CYC0_REG, i.e. period number 0. ULP program code can use SLEEP instruction
to select which of the SENS_ULP_CP_SLEEP_CYCx_REG should be used for subsequent wakeups.
However, please note that SLEEP instruction issued (from ULP program) while the system is in deep sleep
mode does not have effect, and sleep cycle count 0 is used.
For ESP32-s2 the SLEEP instruction not exist. Instead a WAKE instruction will be used.
Note The ULP FSM requires two clock cycles to wakeup before being able to run the program. Then additional
16 cycles are reserved after wakeup waiting until the 8M clock is stable. The FSM also requires two more
clock cycles to go to sleep after the program execution is halted. The minimum wakeup period that may
be set up for the ULP is equal to the total number of cycles spent on the above internal tasks. For a default
configuration of the ULP running at 150kHz it makes about 133us.
Return
• ESP_OK on success
• ESP_ERR_INVALID_ARG if period_index is out of range
Parameters
• period_index: wakeup period setting number (0 - 4)
• period_us: wakeup period, us
Once the timer counts the number of ticks set in the selected RTC_CNTL_ULP_CP_TIMER_1_REG register, ULP
coprocessor powers up and starts running the program from the entry point set in the call to ulp_run.
The program runs until it encounters a halt instruction or an illegal instruction. Once the program halts, ULP
coprocessor powers down, and the timer is started again.
Espressif Systems
-
RTC_SLOW_MEM) );
*/
By default, for ESP32, wakeup timer will use the period set into
1499
Submit Document Feedback
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?