True 3 wire SPI on the ESP32 (detaching MISO from the pin matrix)

I screwed up.

On my latest board using an ESP32 I connected an LED to pin 19, but it would never light up.

I wasn’t using the pin for anything else, and sources online didn’t seem to indicate any problem with using it as a GPIO output. I was however using the VSPI port to connect to an ePaper display, but it was only physically connected in 3 wire mode.

When the display was initialised, I could no longer control the LED.

Fortunately I had read about a handy feature of the ESP32 known as the GPIO matrix. It allows the physical pins of the chip to be mapped (and importantly unmapped) from an internal signal.

Poking around inside esp32-hal-spi.c the signal name of “VSPIQ_OUT_IDX ” can be found.

A little further on an example of detatching a signal can be found here.

pinMatrixInDetach(signal, false, false);

Meaning all we need to run to detatch the MISO of VSPI is:

pinMatrixInDetach(VSPIQ_OUT_IDX, false, false);

And it works!

Leave a Reply

Your email address will not be published. Required fields are marked *