this code can wake up soc every 5 seconds, but if I uncomment “ I_ADC (R1, 0, 6), ”, it can‘t wake up anymore,
Does anyone know the reason for this? Thank you in advance.
Code: Select all
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Init");
ulp_adc_wake_up(100,100);
}
void loop() {
// put your main code here, to run repeatedly:
}
#include "esp32/ulp.h"
#include "soc/rtc_cntl_reg.h"
#include "driver/rtc_io.h"
#include "driver/adc.h"
void ulp_adc_wake_up(unsigned int low_adc_treshold, unsigned int high_adc_treshold)
{
adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_DB_12);
adc1_config_width(ADC_WIDTH_BIT_10);
adc1_ulp_enable();
//rtc_gpio_init(GPIO_NUM_34);
const ulp_insn_t program[] = {
I_MOVI (R0, 1000),
M_LABEL (2),
I_DELAY (40000),
I_SUBI (R0, R0, 1),
M_BGE (2, 1),
// I_ADC (R1, 0, 6),
I_WAKE(),
I_HALT()
};
size_t size = sizeof(program)/sizeof(ulp_insn_t);
ulp_process_macros_and_load(0, program, &size);
ulp_run(0);
esp_sleep_enable_ulp_wakeup();
Serial.println("Sleep Now");
esp_deep_sleep_start();
}