Teensy 4.0 + Rev D2 Audio Shield: Not connecting to Micro SD

Hello, this is my first time coding & working with Teensy and I'm having a bit of trouble getting an SD card reading when connecting the T4.0 to the Audio Shield [Rev D2]. I'm working on this project in Arduino IDE 2.1.0 w/ Teensy 4 board and library running on a Mac.

I've tried the WAV File Player example a number of times and kept receiving "Unable to access the SD card" in the serial monitor. Now attempting to get a reading with the SD Card Test example and keep hitting "SD card is not connected or unusable :-(" I'm using a Sandisk Ultra 32GB Micro SD that has been formatted to FAT 32 and has all SDTEST WAV files uploaded to it. I'm currently using pins though will be soldering in some stackable headers tomorrow in case there's a connection issue though the led indicators [red & orange] on the T4 are both lit up when the processor and shield are connected. The SD card seems to work fine on all other devices, including another playback module. Could this be an issue of power from my computer to the processor [I'm using a usb hub at present]?

Any help would be greatly appreciated.

Here's the code I'm currently trying (have matched pins on both chips as specified in the code & connect 3V and Ground between the two)

Code:
// SD Card Test
//
// Check if the SD card on the Audio Shield is working,
// and perform some simple speed measurements to gauge
// its ability to play 1, 2, 3 and 4 WAV files at a time.
//
// Requires the audio shield:
//   http://www.pjrc.com/store/teensy3_audio.html
//
// Data files to put on your SD card can be downloaded here:
//   http://www.pjrc.com/teensy/td_libs_AudioDataFiles.html
//
// This example code is in the public domain.

#include <SD.h>
#include <SPI.h>

// Use these with the Teensy Audio Shield
#define SDCARD_CS_PIN    10
#define SDCARD_MOSI_PIN  11   
#define SDCARD_MISO_PIN  12
#define SDCARD_SCK_PIN   13  

// Use these with the Teensy 3.5 & 3.6 & 4.1 SD card
//#define SDCARD_CS_PIN    BUILTIN_SDCARD
//#define SDCARD_MOSI_PIN  11  // not actually used
//#define SDCARD_SCK_PIN   13  // not actually used

// Use these for the SD+Wiz820 or other adaptors
//#define SDCARD_CS_PIN    4
//#define SDCARD_MOSI_PIN  11
//#define SDCARD_SCK_PIN   13

void setup() {
  Sd2Card card;
  SdVolume volume;
  File f1, f2, f3, f4;
  char buffer[512];
  boolean status;
  unsigned long usec, usecMax;
  elapsedMicros usecTotal, usecSingle;
  int i, type;
  float size;

  // wait for the Arduino Serial Monitor to open
  while (!Serial) ;
  delay(50);

  // Configure SPI
  SPI.setMOSI(SDCARD_MOSI_PIN);
  SPI.setSCK(SDCARD_SCK_PIN);

  Serial.begin(9600);
  Serial.println("SD Card Test");
  Serial.println("------------");

  // First, detect the card
  status = card.init(SPI_FULL_SPEED, SDCARD_CS_PIN);
  if (status) {
    Serial.println("SD card is connected :-)");
  } else {
    Serial.println("SD card is not connected or unusable :-(");
    return;
  }

  type = card.type();
  if (type == SD_CARD_TYPE_SD1 || type == SD_CARD_TYPE_SD2) {
    Serial.println("Card type is SD");
  } else if (type == SD_CARD_TYPE_SDHC) {
    Serial.println("Card type is SDHC");
  } else {
    Serial.println("Card is an unknown type (maybe SDXC?)");
  }

  // Then look at the file system and print its capacity
  status = volume.init(card);
  if (!status) {
    Serial.println("Unable to access the filesystem on this card. :-(");
    return;
  }

  size = volume.blocksPerCluster() * volume.clusterCount();
  size = size * (512.0 / 1e6); // convert blocks to millions of bytes
  Serial.print("File system space is ");
  Serial.print(size);
  Serial.println(" Mbytes.");

  // Now open the SD card normally
  status = SD.begin(SDCARD_CS_PIN);
  if (status) {
    Serial.println("SD library is able to access the filesystem");
  } else {
    Serial.println("SD library can not access the filesystem!");
    Serial.println("Please report this problem, with the make & model of your SD card.");
    Serial.println("  http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports");
  }


  // Open the 4 sample files.  Hopefully they're on the card
  f1 = SD.open("SDTEST1.WAV");
  f2 = SD.open("SDTEST2.WAV");
  f3 = SD.open("SDTEST3.WAV");
  f4 = SD.open("SDTEST4.WAV");

  // Speed test reading a single file
  if (f1) {
    Serial.println();
    Serial.println("Reading SDTEST1.WAV:");
    if (f1.size() >= 514048) {
      usecMax = 0;
      usecTotal = 0;
      for (i=0; i < 1000; i++) {
        usecSingle = 0;
        f1.read(buffer, 512);
        usec = usecSingle;
        if (usec > usecMax) usecMax = usec;
      }
      reportSpeed(1, 1000, usecTotal, usecMax);
    } else {
      Serial.println("SDTEST1.WAV is too small for speed testing");
    }
  } else {
    Serial.println("Unable to find SDTEST1.WAV on this card");
    return;
  }

  // Speed test reading two files
  if (f2) {
    Serial.println();
    Serial.println("Reading SDTEST1.WAV & SDTEST2.WAV:");
    if (f2.size() >= 514048) {
      f1.seek(0);
      usecMax = 0;
      usecTotal = 0;
      for (i=0; i < 1000; i++) {
        usecSingle = 0;
        f1.read(buffer, 512);
        f2.read(buffer, 512);
        usec = usecSingle;
        if (usec > usecMax) usecMax = usec;
      }
      reportSpeed(2, 1000, usecTotal, usecMax);

      Serial.println();
      Serial.println("Reading SDTEST1.WAV & SDTEST2.WAV staggered:");
      f1.seek(0);
      f2.seek(0);
      f1.read(buffer, 512);
      usecMax = 0;
      usecTotal = 0;
      for (i=0; i < 1000; i++) {
        usecSingle = 0;
        f1.read(buffer, 512);
        f2.read(buffer, 512);
        usec = usecSingle;
        if (usec > usecMax) usecMax = usec;
      }
      reportSpeed(2, 1000, usecTotal, usecMax);
    } else {
      Serial.println("SDTEST2.WAV is too small for speed testing");
    }
  } else {
    Serial.println("Unable to find SDTEST2.WAV on this card");
    return;
  }


  // Speed test reading three files
  if (f3) {
    Serial.println();
    Serial.println("Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV:");
    if (f3.size() >= 514048) {
      f1.seek(0);
      f2.seek(0);
      usecMax = 0;
      usecTotal = 0;
      for (i=0; i < 1000; i++) {
        usecSingle = 0;
        f1.read(buffer, 512);
        f2.read(buffer, 512);
        f3.read(buffer, 512);
        usec = usecSingle;
        if (usec > usecMax) usecMax = usec;
      }
      reportSpeed(3, 1000, usecTotal, usecMax);

      Serial.println();
      Serial.println("Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV staggered:");
      f1.seek(0);
      f2.seek(0);
      f3.seek(0);
      f1.read(buffer, 512);
      f1.read(buffer, 512);
      f2.read(buffer, 512);
      usecMax = 0;
      usecTotal = 0;
      for (i=0; i < 1000; i++) {
        usecSingle = 0;
        f1.read(buffer, 512);
        f2.read(buffer, 512);
        f3.read(buffer, 512);
        usec = usecSingle;
        if (usec > usecMax) usecMax = usec;
      }
      reportSpeed(3, 1000, usecTotal, usecMax);
    } else {
      Serial.println("SDTEST3.WAV is too small for speed testing");
    }
  } else {
    Serial.println("Unable to find SDTEST3.WAV on this card");
    return;
  }


  // Speed test reading four files
  if (f4) {
    Serial.println();
    Serial.println("Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV, SDTEST4.WAV:");
    if (f4.size() >= 514048) {
      f1.seek(0);
      f2.seek(0);
      f3.seek(0);
      usecMax = 0;
      usecTotal = 0;
      for (i=0; i < 1000; i++) {
        usecSingle = 0;
        f1.read(buffer, 512);
        f2.read(buffer, 512);
        f3.read(buffer, 512);
        f4.read(buffer, 512);
        usec = usecSingle;
        if (usec > usecMax) usecMax = usec;
      }
      reportSpeed(4, 1000, usecTotal, usecMax);

      Serial.println();
      Serial.println("Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV, SDTEST4.WAV staggered:");
      f1.seek(0);
      f2.seek(0);
      f3.seek(0);
      f4.seek(0);
      f1.read(buffer, 512);
      f1.read(buffer, 512);
      f1.read(buffer, 512);
      f2.read(buffer, 512);
      f2.read(buffer, 512);
      f3.read(buffer, 512);
      usecMax = 0;
      usecTotal = 0;
      for (i=0; i < 1000; i++) {
        usecSingle = 0;
        f1.read(buffer, 512);
        f2.read(buffer, 512);
        f3.read(buffer, 512);
        f4.read(buffer, 512);
        usec = usecSingle;
        if (usec > usecMax) usecMax = usec;
      }
      reportSpeed(4, 1000, usecTotal, usecMax);
    } else {
      Serial.println("SDTEST4.WAV is too small for speed testing");
    }
  } else {
    Serial.println("Unable to find SDTEST4.WAV on this card");
    return;
  }

}


unsigned long maximum(unsigned long a, unsigned long b,
  unsigned long c, unsigned long d)
{
  if (b > a) a = b;
  if (c > a) a = c;
  if (d > a) a = d;
  return a;
}


void reportSpeed(unsigned int numFiles, unsigned long blockCount, unsigned long usecTotal, unsigned long usecMax)
{
  float bytesPerSecond = (float)(blockCount * 512 * numFiles) / usecTotal;
  Serial.print("  Overall speed = ");
  Serial.print(bytesPerSecond);
  Serial.println(" Mbyte/sec");
  Serial.print("  Worst block time = ");
  Serial.print((float)usecMax / 1000.0);
  Serial.println(" ms");
  Serial.print("    ");
  Serial.print( (float)usecMax / 29.01333);
  Serial.println("% of audio frame time");
}


void loop(void) {
  // do nothing after the test
}
 
I am also experiencing a similar issue.
Using Teensy 4.0 with Audio Shield R2.

My wav files (SDTEST1.wav from pjrc site) play but with extremely poor quality while running the audio example code SdWavPlayer. The hardware test code returns "SD card is not connected or unusable." I have tried different SD cards to no avail. I'm using the initialization below for both SdWavPlayer and SdCardTest.

// Use these with the Teensy Audio Shield
#define SDCARD_CS_PIN 10
#define SDCARD_MOSI_PIN 7 // Teensy 4 ignores this, uses pin 11
#define SDCARD_SCK_PIN 14 // Teensy 4 ignores this, uses pin 13

I've also purchased a 4.1 but keep having the COM busy issue. Any assistance would be greatly appreciated.
 
In IDE 2.1.0 w/TD 1.58.1 here Plugged a T_4.0 with a 64GB ADATA 'A2' card in the REV D Audio Card [ Never got an R2 here ]

Using unedited p#1 code it ran first time:
Code:
SD Card Test
------------
SD card is connected :-)
Card type is SDHC
File system space is 63185.09 Mbytes.
SD library is able to access the filesystem

Reading SDTEST1.WAV:
  Overall speed = 1.36 Mbyte/sec
  Worst block time = 0.46 ms
    15.68% of audio frame time

Reading SDTEST1.WAV & SDTEST2.WAV:
  Overall speed = 1.05 Mbyte/sec
  Worst block time = 1.02 ms
    35.29% of audio frame time

Reading SDTEST1.WAV & SDTEST2.WAV staggered:
  Overall speed = 1.05 Mbyte/sec
  Worst block time = 1.02 ms
    35.26% of audio frame time

Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV:
  Overall speed = 1.05 Mbyte/sec
  Worst block time = 1.52 ms
    52.49% of audio frame time

Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV staggered:
  Overall speed = 1.05 Mbyte/sec
  Worst block time = 1.52 ms
    52.49% of audio frame time

Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV, SDTEST4.WAV:
  Overall speed = 1.05 Mbyte/sec
  Worst block time = 2.03 ms
    69.83% of audio frame time

Reading SDTEST1.WAV, SDTEST2.WAV, SDTEST3.WAV, SDTEST4.WAV staggered:
  Overall speed = 1.05 Mbyte/sec
  Worst block time = 2.02 ms
    69.73% of audio frame time
 
I have a Teensy 4.0 with Audio shield Rev D2 hooked up with soldered on headers. I've tried everything but the SD Card just doesn't detect. Keeps showing "Unable to access the SD card".

Going by this comment, I've checked with a multimeter the connection of the G pin between 5v and 3.3v and the GND pin and they are connected. CS is set to 10. I've also tried 7 through 14.

What am I doing wrong?? Would really appreciate the help.
 
What am I doing wrong??

Please show us what you've really done, rather than merely telling us. All the words you've said seem to be correct, so we simply have no info to be able to see what you might be doing wrong. Photos and screenshots are needed to actually see.
 
Back
Top