Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

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

  1. #1
    Junior Member
    Join Date
    Oct 2021
    Posts
    3

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

    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.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,082
    First to answer your question:

    Quote Originally Posted by Atarien View Post
    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).

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,082
    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?

  4. #4
    Junior Member
    Join Date
    Oct 2021
    Posts
    3
    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.

  5. #5
    Junior Member
    Join Date
    Oct 2021
    Posts
    3
    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.

    Click image for larger version. 

Name:	2021_10_11_sd_card.jpg 
Views:	13 
Size:	58.7 KB 
ID:	26151

  6. #6
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    9,333
    Oops... your really should use newer cards.
    Buy a new one, > = 64 GB.
    Ama*** sells them for 5€

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,082
    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:

    Quote Originally Posted by Atarien View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •