ESP32-C3: Using GPIO19 with internal pull-down

dnicoara
Posts: 1
Joined: Sun Apr 10, 2022 12:07 am

ESP32-C3: Using GPIO19 with internal pull-down

Postby dnicoara » Sun Apr 10, 2022 1:39 am

Hi there!

I'm trying to use GPIO19 as a general purpose pin. The manual mentions that USB_SERIAL_JTAG_DP_PULLUP bit controls the pull-up resistor. Though it is not clear if an application needs to perform this update explicitly or not.

For reference I'm explicitly trying to configure the GPIO pin as a pull-down:

Code: Select all

gpio_config_t io_conf = {};
io_conf.intr_type = GPIO_INTR_ANYEDGE;
io_conf.pin_bit_mask = 1 << 19;
io_conf.mode = GPIO_MODE_INPUT;
io_conf.pull_up_en = 0;
io_conf.pull_down_en = 1;
gpio_config(&io_conf);
Left floating after configuration gpio_get_level(19) always returns 1 and it acts as a pull-up.

There is another topic related to this at: viewtopic.php?t=22256 however that seems to imply that clearing USB_DEVICE_USB_PAD_ENABLE is sufficient. This did not work for me.

As a note, USB_SERIAL_JTAG_USB_PAD_ENABLE is cleared via gpio_config indirectly, so it's unclear if this is just an out-of-date reference.

I figured that this is still a configuration issue on my side since the correct bit isn't being reset so I added:

Code: Select all

CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_DP_PULLUP);
after gpio_config() and it now works as expected.

I've resolved the issue in my code, but would like to understand if this is indeed something that needs to be explicitly done by the application or if gpio_config() should update the USB_SERIAL_JTAG_DP_PULLUP bit depending on the gpio_config_t configuration?

Thank you!
Daniel

ESP_Sprite
Posts: 9759
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-C3: Using GPIO19 with internal pull-down

Postby ESP_Sprite » Sun Apr 10, 2022 8:20 am

Hm, I'm not sure... I'd expect clearing USB_DEVICE_USB_PAD_ENABLE should also disable the pullups, but that doesn't seem to match what you're saying. I'll ask around internally, if this is actually a thing we'll change the gpio driver to match.

espmich
Posts: 4
Joined: Tue Jan 16, 2024 8:32 pm

Re: ESP32-C3: Using GPIO19 with internal pull-down

Postby espmich » Tue Jan 16, 2024 9:31 pm

Like the poster, I'm trying to use GPIO19 (and GPIO18 as well) for something other than USB connectivity. Instead, I have a tactical SPST switch (push button) connected to GPIO19 which connects the pin to GND when depressed. So I'm setting the internal pullup on 18 and 19 just like I do for any other pin with a SPST that connects GND when pressed.

Is there anything special that I need to do, when using a ESP32-C3 with ESP-IDF 5.1.2, in order to (re)use pins 18 and 19 without the USB-JTAG driver claiming them and putting a carrier signal on them or whatever is happening to cause the MCU to not detect (an interrupt) that 18 or 19 become grounded?

Who is online

Users browsing this forum: No registered users and 105 guests