Dual SPI on same pins - ESP32-S3

I have a custom board with an ESP32-S3 Wroom. Furthermore I have a display and a pressure sensor connected to a SPI bus. When routing the board I made a mistake and mixed up MISO and MOSI on the display.
So I had the idea to use a second SPI bus with MISO and MOSI swapped. With this I could solve my hardware problem by software.
But I think I can't use a second SPI bus which has the same pins as the first one.
Example SCK = 11, MISO = 12, MOSI = 13 :

BaroSPI = new SPIClass(HSPI);
BaroSPI ->begin(11, 12, 13, CS_Baro);

DisplaySPI = new SPIClass(FSPI);
DisplaySPI->begin(11, 13, 12, CS_Display);

Did I just write my code wrong or is it not possible to use two separate SPI buses with the same pins (just swapped)?
The SPI that was created last works without problems but the one that was created first does not work.

Welcome to the forum

It may be possible to do what you want but how will the sketch know the function of the pins if potentially they each have two purposes ?

For my information, what are the first 3 parameters of the begin() function ?

Thanks for the response.
void SPIClass::begin(int8_t sck = (int8_t)(-1), int8_t miso = (int8_t)(-1), int8_t mosi = (int8_t)(-1), int8_t ss = (int8_t)(-1))

SPI.beginn(Clock, MISO, MOSI, ChipSelect);

Then

BaroSPI ->begin(11, 12, 13, CS_Baro);

DisplaySPI->begin(11, 13, 12, CS_Display);

is never going to work because pins 12 and 13 both have 2 conflicting definitions


So it does not work if I use two separate SPI buses.
Is there any other way to re-map the SPI pins without having to close and re-open the SPI bus?

My advice would be to bodge the board by cutting tracks and fixing the connections using wire links. Once you know that it works then consider fixing the track routing and having new boards made

Why not use the other ESP32 SPI bus?

https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/spi_master.html

Either way the board needs to be changed

I have already tried this as you can see in the first example code. The problem is that I think it is not possible that two separate SPI buses are mapped to the same pin.
If this is possible could you explain me how to achieve this?

Since there doesn't seem to be a software solution to my hardware error, I guess I will have no choice but to cut the trackes on the board and solder new connections.

I'm going to say it's not possible but did you ask ESPRESSIF, the people who made the ESP32, if its possible?

No, I have not yet. What is the best way to do that? On Github?

Could be worth asking in the Espressif forums ?

Did you try to go to https://esp32.com/?

If you could swap MISO and MOSI signals on pressure sensor such way, so the both sensor and display will have the same swapped pins - than you can use SOFT_SPI on that pins.

I know that if I swap Miso and Mosi on the pressure sensor or display, I can use a single SPI interface to drive both. But I wanted to ask if it is possible to solve this problem without destroying the PCB traces and soldering new cables. Because if there is a software solution it would probably be much easier than soldering these pins.
But it seems to me that this software solution is not possible without changing the hardware and therefore I will probably cut the tracks of the board and solder new ones.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.