Page 1 of 1

A problem about wake up SOC with ULP (with C marco I_WAKE)

Posted: Tue Jul 16, 2024 6:19 am
by vitus.li
Hello Every, I am recently work on an Arduino project on ESP32, this is my code,
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();
   
}


Re: A problem about wake up SOC with ULP (with C marco I_WAKE)

Posted: Tue Jul 16, 2024 3:30 pm
by aliarifat794
Sorry, I did not use ULP, so I cannot help much. However, here is a thread about ulp.h.
https://forum.arduino.cc/t/esp32-ulp-an ... ro/1195753

Re: A problem about wake up SOC with ULP (with C marco I_WAKE)

Posted: Tue Jul 16, 2024 4:09 pm
by vitus.li
Hello aliarifat794, yes,I am also aware of your link. In fact, I can use ULP to read ADC and output it to the serial monitor, but when I enable I_ ADC, I_WAKE does not work. I have seen many successful examples online, and I have tried but none have been successful. By the way, The ESP32 Library I am using is 2.0.17