Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to share the same SPI bus with TFT_eSPI on ESP32 #477

Open
JerryZRF opened this issue Mar 24, 2024 · 4 comments
Open

Unable to share the same SPI bus with TFT_eSPI on ESP32 #477

JerryZRF opened this issue Mar 24, 2024 · 4 comments

Comments

@JerryZRF
Copy link

JerryZRF commented Mar 24, 2024

Hi, I am using a LCD screen which shares its SPI bus with a SD reader on ESP32.

// User_Setup.h in TFT_eSPI
#define ST7796_DRIVER

#define SPI_FREQUENCY  40000000

#define TFT_MISO  25
#define TFT_MOSI  27
#define TFT_SCLK  26
#define TFT_CS    13  // Chip select control pin
#define TFT_DC    14  // Data Command control pin
#define TFT_RST   12  // Reset pin (could connect to RST pin)
//SdFatConfig.h in SdFat
#define SDFAT_FILE_TYPE 3
#define ENABLE_DEDICATED_SPI 0
#define SPI_DRIVER_SELECT 2
// My code
const uint8_t SD_CS = 33;
SoftSpiDriver<TFT_MISO, TFT_MOSI, TFT_SCLK> softSpi;
#define SD_CONFIG SdSpiConfig(SD_CS, SHARED_SPI, SD_SCK_MHZ(40), &softSpi)

When I try to init the SdFat and then the TFT_eSPI, the SdFat doesn't work.

sd.begin(SD_CONFIG); // It succeeds.

tft.begin();
tft.setRotation(1);
tft.fillScreen(TFT_BLUE);

uint32_t size = sd.card()->sectorCount();  // It returns 0.

And when I try to init the TFT_eSPI and then the SdFat, the TFT_eSPI doesn't work.

tft.begin();
tft.setRotation(1);
tft.fillScreen(TFT_BLUE);

sd.begin(SD_CONFIG) // It succeeds.

uint32_t size = sd.card()->sectorCount();  // It returns the right value.
tft.println("Succeed");  // Nothing happends
Serial.println("Succeed");  // It succeeds.
@greiman
Copy link
Owner

greiman commented Mar 24, 2024

Are you pulling chip select high on the second device to to be initialized so it won't interfere with initializing of the first device?

@sud-sharma
Copy link

I am also facing the same issue. Did you find a solution ?

@Andy2No
Copy link

Andy2No commented Aug 9, 2024

Not all SD breakouts are the same. The ones that use a logic level shifter to work with 5V Arduinos tend not to work well with 3.3V MCUs. SD SPI is 3.3V so the sort of breakout you need should just have some resistors and capacitors on it, no voltage regulator or level shifter.

@archearth
Copy link

archearth commented Sep 6, 2024

I am in the same situation. I was able to get the SD to mount and list the files inside but only in the setup() function. After that, it does not list the files if the function is called inside loop() and also, when I tried to load a function that displays an image on the TFT screen it does not work. I am trying to use SdFs and the TFT_eSPI library and read/display images from the SD card. If anyone has found a solution or has one, it will be much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants