Page 1 of 1

Cannot reconfigure certain pins for GPIO usage

Posted: Wed Mar 29, 2023 3:00 pm
by mrdakwar
I have been using both the ESP32-C3 Devkit and a custom board using the ESP32-C3FN4 (which has the SPI pins attached)

I am attempting to use pins 19-24 (GPIO 12-17) as simply GPIO. Whenever I run my code to reconfigure the pins as GPIO, I get a looped boot with the serial output shown below. What baffles me is that I ran this same code but on pins 25-26 (GPIO 18,19 the USB pins) and it works without issue.

All the code is as simple as shown below. What is to be noted is that GPIO is not the default function for GPIO 12-17 (and others). Which means I need to change the function, but this is not clearly communicated how to do so. Even when I run Espressif's code, it throws the same error. For example, the Blink example they provide crashes when you set the pin to 12-17, so they are not checking to configure it in their own code.

Arduino Code

Code: Select all

#define GPIO_GATE 14
void setup() {
  // No need to initialize the RGB LED
}
void loop() {
  pinMode(GPIO_GATE,OUTPUT);
  digitalWrite(GPIO_GATE,HIGH);
  delay(3000);
  digitalWrite(GPIO_GATE,LOW);
  delay(3000);
}
Serial Output

Code: Select all

ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x8 (TG1WDT_SYS_RST),boot:0xd (SPI_FAST_FLASH_BOOT)
Saved PC:0x40380080
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5810,len:0x438
load:0x403cc710,len:0x918
load:0x403ce710,len:0x24e4
entry 0x403cc710

Re: Cannot reconfigure certain pins for GPIO usage

Posted: Thu Mar 30, 2023 6:51 am
by ESP_Sprite
Those pins are where the flash from where your program is executed, is connected. Using them for anything else is not supported (datasheet: "These pins are not recommended for other uses."), and trying to reconfigure them leads to crashes, as you found out.

Re: Cannot reconfigure certain pins for GPIO usage

Posted: Thu Mar 30, 2023 4:39 pm
by mrdakwar
I see, an oversight I made. Since I am using it in DIO mode with internal flash, it does free up GPIO 12 & 13, but the other 4 I cannot use.