Page 1 of 1

ESP32-C3 SPI Pins as GPIO

Posted: Mon Mar 04, 2024 7:25 pm
by Mateo4865
I have a project with the ESP32-C3 chip, and I need to use the SPI pins (SPICS0, SPICLK, SPIQ, SPID) as GPIOs since I don't have any more available pins. I understand that these are internally connected to the flash. For this reason, if I try to set them through the iomux to function as GPIOs, the MCU resets continuously. It's not working.
Is there an effective way to configure and use them as GPIOs without encountering this issue?

Re: ESP32-C3 SPI Pins as GPIO

Posted: Tue Mar 05, 2024 12:44 am
by ESP_Sprite
No. The ESP32-C3 caches need to be able to fetch data from flash for the system to work, so there's no way to use these pins as GPIOs and have a working system.

Re: ESP32-C3 SPI Pins as GPIO

Posted: Tue Mar 05, 2024 12:21 pm
by Mateo4865
I'am using ESP32-C3FH4. It has in-packge flash. So I don't use an external flash.
Even without external flash there is no way to use them?

Re: ESP32-C3 SPI Pins as GPIO

Posted: Wed Mar 06, 2024 1:47 am
by ESP_Sprite
There is not; the internal flash still is connected to those pins.

Re: ESP32-C3 SPI Pins as GPIO

Posted: Wed Mar 06, 2024 12:56 pm
by Mateo4865
Well, thanks for the support.
I have one more doubt. If using these pins is imposibble. Why does the datasheet mention that using SPI pins as GPIO is not recommended instead of explicitly stating that you can't?
Thanks again.

Re: ESP32-C3 SPI Pins as GPIO

Posted: Wed Mar 06, 2024 2:19 pm
by Mateo4865
SPIHD (GPIO12) and SPIWP (GPIO13) Pins are available to use as GPIO?
In the Pin Layout section (2.1) of the datasheet, Pins 19 and 20 (SPIHD and SPIWP) of the ESP32C3-FH4 are labeled as NC (Not Connected). However, in the table in section 2.3, they are designated as default GPIOs. I tested using them as outputs, and it worked for me, but according to the datasheet, this shouldn't be possible. Hence, my uncertainty.

Re: ESP32-C3 SPI Pins as GPIO

Posted: Thu Mar 07, 2024 2:31 am
by ESP_Sprite
Mateo4865 wrote:
Wed Mar 06, 2024 12:56 pm
Well, thanks for the support.
I have one more doubt. If using these pins is imposibble. Why does the datasheet mention that using SPI pins as GPIO is not recommended instead of explicitly stating that you can't?
Thanks again.
Because technically, it's possible to add another SPI device in parallel with the flash, and you'd use those pins then. In practice, this has a ton of downsides, and after attempting to support it for the ESP32 in ESP-IDF, we decided to abandon software support for it for later chips.
Mateo4865 wrote:
Wed Mar 06, 2024 2:19 pm
SPIHD (GPIO12) and SPIWP (GPIO13) Pins are available to use as GPIO?
In the Pin Layout section (2.1) of the datasheet, Pins 19 and 20 (SPIHD and SPIWP) of the ESP32C3-FH4 are labeled as NC (Not Connected). However, in the table in section 2.3, they are designated as default GPIOs. I tested using them as outputs, and it worked for me, but according to the datasheet, this shouldn't be possible. Hence, my uncertainty.
You can use those pins if a. you don't run the flash in QIO/QOUT mode, and b. the flash happens to be configured in such a way that it doesn't care what the values on those pins are.