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

Thread: Teensy 4.1 Cannot access Internal SD card

  1. #1
    Junior Member
    Join Date
    May 2020
    Location
    North Carolina
    Posts
    7

    Teensy 4.1 Cannot access Internal SD card

    I am an experienced Arduino user making the switch to Teensy and finding it painful. I recently got the full featured 4.1 with built in SD card, but can find no way to access it.

    Arduino's SD library won't work
    SdFat won't work
    Examples sketches from forums using older boards won't work

    My card is a brand new SanDisk 32 gig, formatted Fat32. My PC reads/writes it perfectly.

    Don't bother asking for my source code, it's all garbage anyway.

    What I need is a GREATLY SIMPLIFIED set of tested examples of how to:

    1. #include the SD library, where in the sketch, and which library actually works in 4.1

    2. Syntax for begin, including CS pin is any - is the CS pin now selected by the 4.1 board for SD?

    3. Syntax for exists and !exists

    4. Syntax for file establishment, file open and file close.

    Something on the order of the way books are written on Arduino would be wonderful.

    I have done all this successfully on Arduino MEGA and built substantial projects using SD, memories, etc., but
    cannot get to first base with Teensy.

    Please keep it simple.
    Last edited by steamrocks; 05-25-2020 at 06:40 PM. Reason: grammar

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,100
    Use SD.begin(BUILTIN_SDCARD) to cause the SD library to access the SD socket on Teensy 4.1.

    The comments in all the SD library examples mention this only for Teensy 3.5 and 3.6. I've committed an update to also mention Teensy 4.1 in those comments.

    https://github.com/PaulStoffregen/SD...9f246b20be1282

  3. #3
    Junior Member
    Join Date
    May 2020
    Location
    North Carolina
    Posts
    7
    Adding to the list of things that DONT work, I talked to Paul and he said you have to put in a statement "chipSelect=BUILTIN_SDCARD
    in code for the 4.1, after which the usual SD libraries from Arduino should work. Below is my code for a simple test, only testing if the SD is functioning:

    #include <SD.h>
    #include <SPI.h>
    int chipSelect = BUILTIN_SDCARD;
    void setup() {

    if (!SD.begin()) Serial.println ("NO LUCK");
    else Serial.println ("SD WORKS!");
    }
    void loop() {
    // put your main code here, to run repeatedly:
    }

    The statement "NO LUCK" is repeated every time.

    Any and all help is appreciated.

  4. #4
    Junior Member
    Join Date
    May 2020
    Location
    North Carolina
    Posts
    7
    MANY THANX, PAUL! One line of written code is worth 1000 verbal descriptions! You can see from my code above that I misinterpreted the verbal info!
    I can get SD to open now, and now I'll mess with read/write tests.

    FYI this is for a fully programmable percussion sequencer or "Drum Machine" used for performance. It currently exists in Arduino format, with
    520 available rhythm patterns, capable of playing about 8 instruments at any given instant, a total palate of about 100. It is programmed via MIDI
    from Cakewalk, and outputs MIDI to the sound source of your choice. It has breaks, fills, intros, endings, drum cadenzas, and lots of other fun stuff.
    I currently have the first one built in the console of my theater organ, the Teensy version will be a portable.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,100
    If you're familiar with serial MIDI on Arduino Mega, one minor detail that commonly comes up is the need for different resistors with 3.3V signals. Details here:

    https://www.pjrc.com/teensy/td_libs_MIDI.html

    You might also be interested to know Teensy can do USB MIDI, both device and host modes. For USB device MIDI, this page has info:

    https://www.pjrc.com/teensy/td_midi.html

    For USB host MIDI, see the examples in the USBHost_t36 library. Usually host mode is used for connecting musical instruments that send MIDI, so perhaps not so useful for a sequencer that primarily transmits MIDI.

Posting Permissions

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