SD card present switch on Teensy 4.1

Status
Not open for further replies.

Barry123

New member
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
 
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
}
 
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.
 
Status
Not open for further replies.
Back
Top