简体   繁体   中英

ESP32: Reading ADC in Active Mode blocks ADC reading in Deep Sleep mode ULP code

I am currently working on a GPS project and am using voltage detection to put my system to sleep and a wake it up.

When voltage on ADC channel 6 (pin 34) is 0 the system goes to deep sleep and and in deep sleep I use a ULP code to measure voltage and wake up system if a threshold is met. My problem now is, when I run adc1_get_raw(ADC1_CHANNEL_6) in the Active Mode, ADC read in the ULP program in deep sleep is not responding still I delete the code in the Active Mode one. Can anyone me out what's wrong here. Thanks in advance.

Active Mode Code:

bool ignitionSate() {
  int val = 0;
  val = adc1_get_raw(ADC1_CHANNEL_6);
    
  if (val > 0) {
    return true;
  } else {
        return false;
  }
}

Deep Sleep ADC Config Code:

/* Configure ADC channel */
/* Note: when changing channel here, also change 'adc_channel' constant in adc.S */
adc1_config_channel_atten(ADC1_CHANNEL_6, ADC_ATTEN_DB_11);
adc1_config_width(ADC_WIDTH_BIT_12);
adc1_ulp_enable();

I encountered this issue in a project I am working on.

You need to call adc1_ulp_enable() after calling adc1_get_raw() in the active mode so that the ULP ADC instruction does not hang.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM