I am using waveshare 7 inch esp32-s3 touch-screen
I have my project running. The screen and SD card both work, but when I try to do anything with the SD card, the display flickers.
I am working with PlatformIO if it’s important.
What MCU/Processor/Board and compiler are you using?
ESP32-S3
What LVGL version are you using?
8.3
What do you want to achieve?
No flicker
What have you tried so far?
I tried implementing a file system driver and also just accessing the SD card as usual (in Arduino)
Also, I tried running the SD card code in a task on core 0/1.
I had the same issue and found that SD chip select is not assigned to a regular pin but is driven through an I/O expander.
Because SD.begin() wants a chip select pin number (or it will use pin10 as default), my solution was to provide another pin, choosing one that do not interfere with LCD.
So, using SD.begin(6) did the trick for me. (pin 6 is “sensor AD” which I do not use)
Don’t be tented to use unconnected pins 35, 36 and 37, because they’re used internally for PSRAM.
No, I did not rewired any pin, just left the board as is.
Because the library wants a CS to be defined I provided to it a pin that is not used by my project nor by other peripheral on the board. In this manner, the library will move the pin 6 thinking it is CS but instead doin nothing actually.
The real CS is connected to the I/O expander, so I had to assert it manually in the setup phase, forcing it to LOW level.
#define SD_CLK 12
#define SD_MISO 13
#define SD_MOSI 11
#define SD_CS 4 // pin 4 of expander chip, it is not a pin of ESP32!!!
#define SD_FAKE_CS 6 // fake ESP32 pin to pass to the library
ESP_IOExpander *expander = nullptr;
void setup() {
// [...] here goes the code to init I2C bus and expander
// init SPI
SPI.setHwCs(false);
SPI.begin(SD_CLK, SD_MISO, SD_MOSI, -1);
// assert CS
expander->digitalWrite(SD_CS, LOW);
// init SDCard
SD.begin(SD_FAKE_CS, SPI);
// [...] other stuff
}