Problems playing a WAV-File from the µSD of the Teensy 3.6 / Understanding things

Status
Not open for further replies.

Atarien

New member
Hi,

I want to play a WAV-File using AudioPlaySdWav from the µSD-Slot on the Teensy 3.6. The very one soldered on the Teensy-PCB. Not the one from the audio shield. The output should be using the internal DAC. I already struggle with the SD-Card access. My console writes "Unable to access the SD card".

From what I have read on this forum this should be easy. I uncommented

// Use these with the Teensy Audio Shield
// #define SDCARD_CS_PIN 10
// #define SDCARD_MOSI_PIN 7
// #define SDCARD_SCK_PIN 14

and used

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

Yet I get "Unable to acces..." While researching, more questions arose:

. SPI needs MOSI, MISO, SCK and CS to work. Why do I only configure the CS-Pin, no MISO and there are confusing comments "Not actually used"?
. I configure the code to use the "Pins" 11 and 13. When I look at the schematic of the Teensy 3.6, these pins go to C8/PTC6 and D8/PTC5. These pins have nothing to do with the pins of the µSD-Card-Reader on the Teensy PCB, which are on PTE[5..0].

Please help. Thank you.
 
First to answer your question:

Why do I only configure the CS-Pin, no MISO and there are confusing comments "Not actually used"?
.

When you use BUILTIN_SDCARD for the CS pin, it puts the SD library into a special mode where it doesn't use SPI at all. Instead it uses the special SDIO pins.

Arudino's SD library was designed to be very simple. Unlike the more complex SdFat library, it only has the ability to give a single number for the CS pin. When we first made Teensy 3.5 & 3.6, a decision was made to support the non-SPI usage with this special constant for the CS pin number, rather than add a more complex usage (like SdFat has).
 
Why it's not able to access your card, I do not know. I've recently discovered some very old cards don't work at all with the SDIO socket. Why, I do not know (yet). But very old cards are rare in Micro SD - back then they were mostly full size SD.

You might try running the examples from File > Examples > SD. Especially run listfiles and CardInfo. Of course, edit the chip select pin to BUILTIN_SDCARD, as the comments say. Maybe running those examples will give more info?
 
Hi Paul,

thank you for your answer. So I understood that the "codeword" BUILTIN_SDCARD tells the underlying library, that SPI should not be used. So the lines
#define SDCARD_MOSI_PIN 11 // not actually used
#define SDCARD_SCK_PIN 13 // not actually used
could be ommited? Instead the library uses the SDIO-Pins on PTE[5..0].

My µSD is actually very old. It's a 256MB card. I try another one and experiment with the SD Examples.
 
Yup, that was quick: It works, Audio is playing. Left: The old, not recognized card. Right: The new, working card.

The old card worked with the SPI-µSD-Slot of the Audio Shield. So I didn't put the blame on her.

2021_10_11_sd_card.jpg
 
Yeah, I'm pretty sure there's a bug or limitation in the software for use of these very old pre-SDHC cards in the SDIO socket. I have a few here too which don't work. But they all work fine by SPI. Seems unlikely that bug will ever be found and fixed.


About this:

So the lines
#define SDCARD_MOSI_PIN 11 // not actually used
#define SDCARD_SCK_PIN 13 // not actually used
could be ommited?

If you try deleting those lines, you'll see the example doesn't compile. There are lots of ways to fix that, but they make the example more complicated. So we're left with a choice of extraneous config or conditional compile or other ways which make the code harder to read.
 
Status
Not open for further replies.
Back
Top