Sharing SPI bus

Hi,

Can someone assist me

I have three devices: XPT2046, ILI9341, and SD_Card.

XPT pin list ( TP_CLK, TP_CS, TP_DIN, TP_OUT, TP_IRQ)

ILI9341 pin list (CS, SCK, DC, MOSI, MISO, RESET, TF_BL)

SD-card pin list ( SD_CARD, MTDO, MTCK, MTDI)

What my quest is can i put all these three devices on same SPI bus ( to save gpio pins)

Meaning merge all three module SCK,MOSI,MISO pins into one aka. to have one SCK, one MOSI, one MISO.

Will it work? - Unfortunately I don’t have all these three items on me to test in on dev board.

In theory, yes. They can all share the SCK, MISO & MOSI pins of the Arduino, but they each need their own SS/CS pin.

In practice, some SD card modules have a fault in their design which means they cannot share the SPI bus with other devices.

It depends on the devices being good original ones or not. Clones especially now and then fails like reply #2 tells.

Thanks, then its best practice to split the sd card to be on the safe side

To do that you will need two SPI busses

Which Arduino board are you using ?

using an ESP32 and a HiLetGo 240X320 Resolution 2.8" SPI TFT LCD Display Touch Panel ILI9341 I found

  1. having the ILI9341 and SD on the VSPI bus did not work
  2. having TFT touch display using VSPI and SD card using HSPI worked OK

Well i’m planing to use esp32-s3 to make my own board. Im in process of sketching things out.

I added 10k pull ups on all CS lines.

I’ve found a tutorial for esp32-s3 board (https://www.youtube.com/watch?v=jiJGbWOSdMo&t=120s)

Does this look to you like its going to work.

I have already tried to make a custom esp32-s3 board. I’ve managed to get the board to ID, and upload a sketch, but it seems like its not running nor do i get any serial messages in serial monitor. And this was my schematic

Here i used Gpio 6-11 and gpio 1-5 maybe that was a mistake…

Not necessarily. You can use an SD module that doesn't have this problem, such as the Adafruit module. Or you can use a generic 3.3V SD module. The problem arises when the module is intended to work with a 5V CPU. It runs all lines through a level shifter, which never lets go of MISO. But if you don't have a level shifter, it should work fine. You can always just use a bare microSD holder in a 3.3V circuit.

Why didn't it work?

The warning I gave in post #2 is for exactly the reason @ShermanP explained. But if the SD card on your display PCB has no level shifter, there should have been no problem that I'm aware of.

We still don't know whether @amer_m plans to use bare chips or modules, so it's impossible to know if they will be affected by the problem or not. We know that @amer_m plans to use an ESP32, which is a 3.3V device, so a 3.3V SD card module (with no level shifter) should work fine.

no idea!
some time since I did this test
the notes I have against the tests when attempting different order of initializing the TFT and SD card are
1.SD card OK TFT does not work
2. SD works on first call to setupSD() but not after initializing TFT

gave up and moved SD card to HSPI and everything worked

using TFT_eSPI library with ESP32 core 3.x

However, looking at same tests using the same TFT on a ESP32-S3-DevKitC-1 and ESP32-C3-MINI-1 the TFT and SD card worked together OK on VSPI - using ESP32 core 2.0.14

guess it is a case of experimenting with the particular microcontroller/TFT configuration