hello there.
i hav been going through the config options relating to disabling the USB/JTAG interface and cannot find anything in the docs on how to disable the driver.
I would like to use the GPIO 18 and 19 for io and am struggling getting that right
ESP32-C3 Enabling GPIO18 and GPIO19 for IO use
-
- Posts: 9739
- Joined: Thu Nov 26, 2015 4:08 am
Re: ESP32-C3 Enabling GPIO18 and GPIO19 for IO use
I think that in newer ESP-IDF versions, you can simply configure these pins as a GPIO in the same way you would normally do (using gpio_config(), or gpio_reset_pin followed by other configuration calls).
Re: ESP32-C3 Enabling GPIO18 and GPIO19 for IO use
It's now 2024 and I'm using ESP-IDF 5.1.2 (the most current stable) to try to do as suggested. Like the poster, I want to (re)use GPIO18 and GPIO19 of the ESP32-C3 as tactical switch button inputs. So I'm trying to disable the USB-JTAG driver on these pins.
Expectation
I should be able to press the tactical switch button on GPIO18 or GPIO19 which drives the pin low and the MCU interrupts, just like I'm doing with GPIO8 and GPIO9. My device has four buttons.
Problem
While GPIO8 and GPIO9 work properly, when I press the button on GPIO18 or GPIO19 then nothing happens and the MCU does not interrupt.
Is anybody else having trouble doing this, and is it because the necessary code is still not in ESP-IDF as of 5.1.2?
I'm using gpio_isr_handler_add() on both GPIO18 and GPIO19. Is that a problem?
There are some CLEAR_PERI_REG_MASK() and REG_SET_BIT() macros that I'm not using, because I'm unsure which parameters to pass. I hope these kinds of macros are not needed, what do you think?
Code: Select all
// For good measure set GPIO 18 and 19 twice, one time here
gpio_reset_pin(GPIO_NUM_18);
gpio_reset_pin(GPIO_NUM_19);
gpio_set_pull_mode(GPIO_NUM_18, GPIO_PULLDOWN_DISABLE);
gpio_set_pull_mode(GPIO_NUM_18, GPIO_PULLUP_ENABLE);
gpio_set_pull_mode(GPIO_NUM_19, GPIO_PULLDOWN_DISABLE);
gpio_set_pull_mode(GPIO_NUM_19, GPIO_PULLUP_ENABLE);
gpio_set_direction(GPIO_NUM_18, GPIO_MODE_INPUT);
gpio_set_direction(GPIO_NUM_19, GPIO_MODE_INPUT);
// For good measure set GPIO 18 and 19 twice, a second time here
gpio_config_t cfg;
esp_err_t result;
memset(&cfg, 0x0, sizeof(cfg));
cfg.pin_bit_mask |= (1LL << gpio);
cfg.mode = GPIO_MODE_INPUT;
cfg.pull_up_en = GPIO_PULLUP_ENABLE;
cfg.pull_down_en = GPIO_PULLDOWN_DISABLE;
cfg.intr_type = GPIO_INTR_ANYEDGE;
result = gpio_config(&cfg);
I should be able to press the tactical switch button on GPIO18 or GPIO19 which drives the pin low and the MCU interrupts, just like I'm doing with GPIO8 and GPIO9. My device has four buttons.
Problem
While GPIO8 and GPIO9 work properly, when I press the button on GPIO18 or GPIO19 then nothing happens and the MCU does not interrupt.
Is anybody else having trouble doing this, and is it because the necessary code is still not in ESP-IDF as of 5.1.2?
I'm using gpio_isr_handler_add() on both GPIO18 and GPIO19. Is that a problem?
There are some CLEAR_PERI_REG_MASK() and REG_SET_BIT() macros that I'm not using, because I'm unsure which parameters to pass. I hope these kinds of macros are not needed, what do you think?
Who is online
Users browsing this forum: Baidu [Spider], homedad and 104 guests