ESP32 ULP can't wake up SOC from deep sleep
Posted: Wed Jan 20, 2021 3:16 pm
Hey there,
I don't know why, but I can't wake up the SOC (pico D4) from deep sleep by the ULP Coprocessor. The ULP code is running correctly, incrementing a variable that I can successfully read out when waking the SOC by the timer. Code is simple:
And the ULP code:
The ULP code is running, but somehow totally ignores the "wake".
Anybody has an idea?
Thanks in advance.
I don't know why, but I can't wake up the SOC (pico D4) from deep sleep by the ULP Coprocessor. The ULP code is running correctly, incrementing a variable that I can successfully read out when waking the SOC by the timer. Code is simple:
Code: Select all
static void init_ulp_program(void) {
ulp_x = 0;
ESP_ERROR_CHECK( ulp_load_binary(0, ulp_main_bin_start, (ulp_main_bin_end - ulp_main_bin_start) / sizeof(uint32_t)) ); // load binary into rtc
ESP_ERROR_CHECK( ulp_set_wakeup_period(0, 2000*1000) ); // run every 2 seconds
ESP_ERROR_CHECK( ulp_run((&ulp_entry - RTC_SLOW_MEM) / sizeof(uint32_t)));
}
extern "C" void app_main() {
while(1) {
if(firstStart) {
firstStart = false;
init_ulp_program();
}
printf("X = %d\n", ulp_x & UINT16_MAX);
ESP_ERROR_CHECK( esp_sleep_enable_ulp_wakeup() );
esp_deep_sleep_start();
}
}
Code: Select all
#include "soc/rtc_cntl_reg.h"
#include "soc/soc_ulp.h"
#include "soc/rtc_io_reg.h"
.bss
.global x
x: .long 0
.text
.global entry
entry:
move r1, x // Get adress of x
ld r0, r1, 0 // Read x in r0
add r0, r0, 1 // Increment x
st r0, r1, 0 // Save the x in memory
wake
halt
Anybody has an idea?
Thanks in advance.