The SD Card Slot for the LCD-15143 fails to be detected

I am using the SparkFun Thing Plus ESP32 U.FL and connected GPIO21 to the SDCS pin of the LCD-15143 display with SD card slot. When I test with the LCD display by itself to draw, it works fine. As soon as I try to access the SD card slot with my 32GB microsd card inserted (which is already formatted as FAT32 with a single partition using the entire space). When using the following code, the output in the serial monitor is:

Testing the LCD15143

No SD card attached

listing root directory

#include "SD.h"
#include "HyperDisplay_KWH018ST01_4WSPI.h" // Click here to get the library: http://librarymanager/All#SparkFun_HyperDisplay_KWH018ST01

#define PWM_PIN 36            // Pin definitions
#define LCDCS_PIN 17
#define SDCS_PIN 21
#define DC_PIN 16
#define SPI_SPEED 32000000        // Requests host uC to use the fastest possible SPI speed up to 4 MHz

KWH018ST01_4WSPI displayModule;           // The KWH018ST01_4WSPI class is used for this breakout, and we will call our object displayModule
File root;

ILI9163C_color_18_t defaultColor; // Global objects are used for default colors so that they are always in-scope
ILI9163C_color_18_t colorLoops[8]; //colors to loop through
uint8_t colorIndex = 0;

void setup() {
  Serial.begin(115200);
  Serial.println("Testing the LCD15143");
  
  SD.begin(SDCS_PIN, SPI, 1000, "/sd", 5, false);
    uint8_t cardType = SD.cardType();

    if(cardType == CARD_NONE){
        Serial.println("No SD card attached");
    }
  
  root = SD.open("/");
  Serial.println("listing root directory");
  File file = root.openNextFile();
    while(file){
        if(file.isDirectory()){
            Serial.print("  DIR : ");
            Serial.println(file.name());
        } else {
            Serial.print("  FILE: ");
            Serial.print(file.name());
            Serial.print("  SIZE: ");
            Serial.println(file.size());
        }
        file = root.openNextFile();
    }
    
  displayModule.begin(DC_PIN, LCDCS_PIN, PWM_PIN, SPI, SPI_SPEED);
  displayModule.clearDisplay();

  colorLoops[0] = displayModule.rgbTo18b(  0,  0,  0 );
  colorLoops[1] = displayModule.rgbTo18b(255,  0,  0 );
  colorLoops[2] = displayModule.rgbTo18b(255,255,  0 );
  colorLoops[3] = displayModule.rgbTo18b(  0,255,  0 );
  colorLoops[4] = displayModule.rgbTo18b(  0,255,255 );
  colorLoops[5] = displayModule.rgbTo18b(  0,  0,255 );
  colorLoops[6] = displayModule.rgbTo18b(255,  0,255 );
  colorLoops[7] = displayModule.rgbTo18b(255,255,255 );
}

void loop() {
  ILI9163C_color_18_t color = colorLoops[colorIndex];
  for(uint8_t indi = 0; indi < displayModule.xExt/2; indi+=1)
  {
    displayModule.rectangle(displayModule.xExt/2-1-indi, displayModule.yExt/2-1-indi, displayModule.xExt/2+1+indi, displayModule.yExt/2+1+indi, false, (color_t)&color);
    delay(50);
  }
  if(colorIndex == 8) {
    colorIndex = 0;
  }
  else {
    colorIndex++;
  }
}

Banging my head over this… I can see the SDCS pin voltages changing when I use the logic analyzer from Waveforms when using the Digilent Analog Discovery 2. I took out the return statements earlier so I could see what happens if it progresses further along.

Have you tried moving the SD card from one slot to the other? (if using on screen’s slot, swap to Thing Plus slot, or vice-versa?)

I’m guessing either the wrong sd library is being called for the slot, or a mismatch in the library for which pins are actually being used :-/