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

Thread: SD card present switch on Teensy 4.1

  1. #1
    Junior Member
    Join Date
    Sep 2020
    Posts
    2

    SD card present switch on Teensy 4.1

    I have a Teensy 4.1 I am using on a project. I am having trouble detecting the removal of a SD card while the program is running. I notice the Hirose SD card socket has a card detect switch and I have verified it works with an ohmmeter. One side is connected to ground (left side) but the right side does not seem to go to any of the pins exposed on the Teensy board. Does the card detect pin connect to any port on the processor or do I need to solder it to an unused port pin on the Teensy board?

    Thanks in advance for your help.

    Barry

  2. #2
    Junior Member
    Join Date
    Jul 2020
    Location
    Texas
    Posts
    4
    I have this in setup to detect SD not sure if this is feasible in main to detect removal.
    // Read Values from SD Card
    if (!card.init(SPI_HALF_SPEED, chipSelect))
    {
    Serial.println("SD Card initialization failed. Things to check:");
    Serial.println("* is a card inserted?");
    SDFail = 1;
    //Serial.println(SDFail);
    }
    else
    {
    Serial.println("SD card is present.");
    SD.begin(chipSelect);
    Serial.println("Read SD card file...");
    // Do something here if SD present
    }

  3. #3
    Junior Member
    Join Date
    Sep 2020
    Posts
    2
    Thanks for the reply. I had already done the initialization test, and it worked the first time on power up, but not when the card was removed.

    I have a version working now by attempting to open a file I know is on the SD card and if it fails, the card is gone. I need to do more testing on how long this process takes since it is in a time critical loop. A switch test would be much better since it is fast and definitive.

  4. #4
    Junior Member
    Join Date
    Jul 2020
    Location
    Texas
    Posts
    4
    I agree, trying to open a file is overhead!

  5. #5
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,891
    AFAIK,
    the card present switch is not connected to Teensy.

Posting Permissions

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