ESP32-C3 SPI Pins as GPIO

Mateo4865
Posts: 4
Joined: Mon Mar 04, 2024 3:49 pm

ESP32-C3 SPI Pins as GPIO

Postby Mateo4865 » Mon Mar 04, 2024 7:25 pm

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?

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

Re: ESP32-C3 SPI Pins as GPIO

Postby ESP_Sprite » Tue Mar 05, 2024 12:44 am

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.

Mateo4865
Posts: 4
Joined: Mon Mar 04, 2024 3:49 pm

Re: ESP32-C3 SPI Pins as GPIO

Postby Mateo4865 » Tue Mar 05, 2024 12:21 pm

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?

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

Re: ESP32-C3 SPI Pins as GPIO

Postby ESP_Sprite » Wed Mar 06, 2024 1:47 am

There is not; the internal flash still is connected to those pins.

Mateo4865
Posts: 4
Joined: Mon Mar 04, 2024 3:49 pm

Re: ESP32-C3 SPI Pins as GPIO

Postby Mateo4865 » 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.

Mateo4865
Posts: 4
Joined: Mon Mar 04, 2024 3:49 pm

Re: ESP32-C3 SPI Pins as GPIO

Postby Mateo4865 » 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.

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

Re: ESP32-C3 SPI Pins as GPIO

Postby ESP_Sprite » Thu Mar 07, 2024 2:31 am

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.

Who is online

Users browsing this forum: No registered users and 71 guests