SD Card recognition problem

PaulKirk

Member
Hi, I have a Teensy 3.6 and audio shield. I’m using Arduino IDE 2.3.4 to do some initial tests.

I watched the Teensy Audio Library Tutorial video on the Teensy site, which I found very useful.

I uploaded the example sketch Part_1_02_Hardware_Test.ino from File>Examples>Audio>Tutorial, and I get the expected beep in my headphones connected to the audio shield, which validates the audio hardware.

So I moved on to the SdCardTest.ino sketch and loaded that. The serial monitor reports the following:

SD Card Test
------------
SD card is not connected or unusable :-(

The SD card I'm using is a 32GB micro SD, which I formatted on a windows PC as FAT32

I checked around on the Teensy site and more generally, but didn’t find a useful next step.

Any help much appreciated, I haven’t worked with SD cards previously.
 
Question: Was the SD card inserted into the Audio board or onto the T_4.1 socket?

That code was from T_3.2 era so it is looking for the SDcard on SPI of the Audio shield. If the card is placed into the T_4.1 socket the code would need a change to get: SDCARD_CS_PIN BUILTIN_SDCARD
 
Hi, I have a Teensy 3.6 and audio shield. I’m using Arduino IDE 2.3.4 to do some initial tests.

I watched the Teensy Audio Library Tutorial video on the Teensy site, which I found very useful.

I uploaded the example sketch Part_1_02_Hardware_Test.ino from File>Examples>Audio>Tutorial, and I get the expected beep in my headphones connected to the audio shield, which validates the audio hardware.

So I moved on to the SdCardTest.ino sketch and loaded that. The serial monitor reports the following:

SD Card Test
------------
SD card is not connected or unusable :-(

The SD card I'm using is a 32GB micro SD, which I formatted on a windows PC as FAT32

I checked around on the Teensy site and more generally, but didn’t find a useful next step.

Any help much appreciated, I haven’t worked with SD cards previously.
@PaulKirk is using a T3.6 NOT 4.1
 
I resoldered some pins (7, 10, 12 & 14 ) as they're mentioned in the Teensy doc here for the audio Rev C with Teensy 3.6
Unfortunately it hasn't resolved the problem.

I also tried the Teensy on board SD socket by commenting out
Code:
// 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

and uncommenting
Code:
// 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

but the result is the same.

When uploading, in the compiler output, I noticed at the very first line an error. Extract from compiler o/p below. Is this significant?

loading library from c:\Users\Paul\Documents\Arduino\libraries\llHeader: invalid library: no header files found
FQBN: teensy:avr:teensy36
Using board 'teensy36' from platform in folder: C:\Users\Paul\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.59.0
Using core 'teensy3' from platform in folder: C:\Users\Paul\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.59.0

Any help much appreciated :)
 
Could you try with the following code.
Code:
/*
  SD card test

 This example shows how use the utility libraries on which the'
 SD library is based in order to get info about your SD card.
 Very useful for testing a card when you're not sure whether its working or not.

 created  28 Mar 2011
 by Limor Fried
 modified 9 Apr 2012
 by Tom Igoe
modified 2 Jan 2025 by Bob Bridges
 */
 // include the SD library:
#include <SD.h>
#include <SPI.h>

// set up variables using the SD utility library functions:
Sd2Card card;
SdVolume volume;
SdFile root;

// change this to match your SD shield or module;
// Teensy audio board TYPE C - Teensy 3.x: pin 10
// Teensy audio board TYPE D - Teensy 4.x: pin 11
// Teensy 3.5 & 3.6 & 4.1 on-board: BUILTIN_SDCARD
const int chipSelect = BUILTIN_SDCARD;

void setup()
{
    //UNCOMMENT THESE TWO LINES FOR TEENSY AUDIO BOARD:
    //SPI.setMOSI(7);  // Audio shield has MOSI on pin 7
    //SPI.setSCK(14);  // Audio shield has SCK on pin 14

   // Open serial communications and wait for port to open:
    Serial.begin(9600);
    while (!Serial && millis() < 3000) {
        ; // wait for serial port to connect.
    }
    Serial.print("Testing SD Card on ");
    switch (chipSelect) {
    case 10:
        SPI.setMOSI(7);  // Audio shield has MOSI on pin 7
        SPI.setSCK(14);  // Audio shield has SCK on pin 14
        Serial.print("Audio Card Type C (Teensy T3.x)");
        break;
    case 11:
        SPI.setMOSI(10);  // Audio shield has MOSI on pin 10
        SPI.setSCK(13);  // Audio shield has SCK on pin 13
        Serial.println("Audio Card Type Dx (Teensy T4.x)");
        break;
    case BUILTIN_SDCARD:
        Serial.println("Built in SD Socket");
        break;
    default:
        Serial.println("Not Teensy Audio Board SD Card Nor Teensy 3.5,3.6 or 4.1");
    }

    Serial.print("\nInitializing SD card...");


    // we'll use the initialization code from the utility libraries
    // since we're just testing if the card is working!
    if (!card.init(SPI_HALF_SPEED, chipSelect)) {
        Serial.println("initialization failed. Things to check:");
        Serial.println("* is a card inserted?");
        Serial.println("* is your wiring correct?");
        Serial.println("* did you change the chipSelect pin to match your shield or module?");
        return;
    }
    else {
        Serial.println("Wiring is correct and a card is present.");
    }

    // print the type of card
    Serial.print("\nCard type: ");
    switch (card.type()) {
    case SD_CARD_TYPE_SD1:
        Serial.println("SD1");
        break;
    case SD_CARD_TYPE_SD2:
        Serial.println("SD2");
        break;
    case SD_CARD_TYPE_SDHC:
        Serial.println("SDHC");
        break;
    default:
        Serial.println("Unknown");
    }

    // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
    if (!volume.init(card)) {
        Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
        return;
    }


    // print the type and size of the first FAT-type volume
    uint32_t volumesize;
    Serial.print("\nVolume type is FAT");
    Serial.println(volume.fatType(), DEC);
    Serial.println();

    volumesize = volume.blocksPerCluster();    // clusters are collections of blocks
    volumesize *= volume.clusterCount();       // we'll have a lot of clusters
    if (volumesize < 8388608ul) {
        Serial.print("Volume size (bytes): ");
        Serial.println(volumesize * 512);        // SD card blocks are always 512 bytes
    }
    Serial.print("Volume size (Kbytes): ");
    volumesize /= 2;
    Serial.println(volumesize);
    Serial.print("Volume size (Mbytes): ");
    volumesize /= 1024;
    Serial.println(volumesize);


    //Serial.println("\nFiles found on the card (name, date and size in bytes): ");
    //root.openRoot(volume);

    // list all files in the card with date and size
    //root.ls(LS_R | LS_DATE | LS_SIZE);
}


void loop(void) {

}
 
OK, I have solved the problem, I found this forum link here

It mentions that a solution was to use the SD formatter, link here

I used the SD formatter to format my SDHC and it is now recognised.

So the key takeaway for me is :

USING THE WINDOWS 10 OS FORMATTER TO FORMAT AN SD CARD FOR USE IN Teensy 3.6 or the Audio Shield DOES NOT WORK.

Thanks to all who looked at my post and tried to help, much appreciated :)

On this Teensy doc page, it mentions SD cards and I think it would be helpful to include some info on how they should be formatted :)

Edit: sorry forgot the o/p from serial monitor:
SD Card Test
------------
SD card is connected :)
Card type is SDHC
File system space is 31902.40 Mbytes.
SD library is able to access the filesystem
 
next part of query. The file SDTEST1.WAV from pjrc site loads and plays successfully.

I have another file named PIANO.WAV on the SD card, which is a 1 minute long WAV file. It was created using a sound recording device. If I attempt to play it in Windows 10 media player it plays as expected.

When I change the filename in the Teensy code from SDTEST1.WAV to PIANO.WAV , the file does not play.

Any thoughts on this please?
 
OK, thanks, got it working, the bit depth and sample rate were incorrect. I've recorded a new piece at 16 bits and 44.1kHZ and all works fine,
thanks for help :)
 
Back
Top