Page 1 of 1

How to get digital input from ADC pins?

Posted: Mon Nov 09, 2020 8:25 pm
by sittingduck
I would like to use my pins, which are able to do ADC1, as general GPIO pins to read digital values. This is somehow not possible using this config:

Code: Select all

    gpio_config_t io_conf;

    // configure interrupt pins
    // set as input mode
    io_conf.mode = GPIO_MODE_INPUT;
    // interrupt
    io_conf.intr_type = GPIO_INTR_DISABLE;
    // bit mask of the pins
    io_conf.pin_bit_mask = (BIT(39) | BIT(36) | BIT(34));
    // dis pull-down mode
    io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
    // disable pull-up mode
    io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
    esp_err_t ret_gpio = gpio_config(&io_conf);
Do I need to deactivate ADC somehow? What is the reason, why I cannot read their digital values with:

Code: Select all

gpio_get_level(36);
//...

Re: How to get digital input from ADC pins?

Posted: Mon Nov 09, 2020 8:37 pm
by chegewara

Code: Select all

io_conf.pin_bit_mask = (BIT(39ULL) | BIT(36ULL) | BIT(34ULL));
or something like that:

Code: Select all

  gpioConfig.pin_bit_mask = ((1ULL<<GPIO_NUM_19) | (1ULL<<GPIO_NUM_18) | (1ULL<<GPIO_NUM_17) | (1ULL<<GPIO_NUM_16));

Re: How to get digital input from ADC pins?

Posted: Mon Nov 09, 2020 8:59 pm
by sittingduck
What a fail... That's it! Thank you very much. It works...