How to connect SD card reader to teensy 4.0 through pads?

gxhary

Member
I am trying to read/write to a sd card connected to the teensy using the bottom pads i have no idea how to code that, I cannot find anything online about this, I have the pcb soldered and i pretty sure it works fine i just cannot program it to work. I believe the wiring is correct since a more capable person did it not me lol
 
Can you show us photos this hardware and how you've connected it? Or at least give a link to the hardware? You know what it is, but please try to imagine how anyone reading this is supposed to answer. We can't even know if this is a USB device or something like this module which uses SPI.
 
Can you show us photos this hardware and how you've connected it? Or at least give a link to the hardware? You know what it is, but please try to imagine how anyone reading this is supposed to answer. We can't even know if this is a USB device or something like this module which uses SP
I dont have the pcb on me right now but it uses a flat wire connector and connects them like this schematic, i checked the wiring and it is soldered correctly,
the part i am using is this one

 

Attachments

  • IMG_3412.jpeg
    IMG_3412.jpeg
    186.4 KB · Views: 14
Ah, now I can see you're trying to connect a plain SD socket to all 8 SD pins. That definitely does work on the Teensy 4.0 breakout board. It even uses the same socket. Maybe that board's info can help?

On the software side, any of the SD library examples should work if you simply edit the chip select to BUILTIN_SDCARD.

If it's still not working, best I can tell you is this really does work when you make that simple edit to the examples and wire all 8 pins correctly. If it's still not working, maybe 1 or more wires aren't connected properly? If you want help double checking your connections, you'll need to show photos. The more clearly we can see your wiring, the better your odds that someone might notice the problem. But without seeing anything, best I can do is confirm this really does work on the breakout board. The same code also works on Teensy 4.1 where the SD socket is wired directly to those 8 pins.
 
Ah, now I can see you're trying to connect a plain SD socket to all 8 SD pins. That definitely does work on the Teensy 4.0 breakout board. It even uses the same socket. Maybe that board's info can help?

On the software side, any of the SD library examples should work if you simply edit the chip select to BUILTIN_SDCARD.

If it's still not working, best I can tell you is this really does work when you make that simple edit to the examples and wire all 8 pins correctly. If it's still not working, maybe 1 or more wires aren't connected properly? If you want help double checking your connections, you'll need to show photos. The more clearly we can see your wiring, the better your odds that someone might notice the problem. But without seeing anything, best I can do is confirm this really does work on the breakout board. The same code also works on Teensy 4.1 where the SD socket is wired directly to those 8 pins.
i did change to sd card to BUILTIN_SDCARD, i will check with the person who soldered to pcb to see if the wiring is correct, i really hope this works, should have an update by tomorrow
 
Before the T4.1, I did a few of them. Sometimes without it always working.

One thing I typically do in a case like this is to use a program to check the continuity of each of the pins.
Often times I use a program I have posted several times that @defragster and myself hacked on several years ago.
At times I think a simplified cleaned up version would be good example to add to the teensy installs

C++:
#include <Arduino.h>
 void setup() {
  Serial.begin(115200);
  while (!Serial && millis() < 4000 );
  Serial.println("Compile Time:: " __FILE__ " " __DATE__ " " __TIME__);
  Serial.printf("Num Digital Pins: %d\n", NUM_DIGITAL_PINS);
  testForShorts();
 
}
uint32_t cnt = 0;
void loop() {
  cnt++;
    allPinTest( cnt );
}
uint32_t pinLast[NUM_DIGITAL_PINS];
void allPinTest( uint32_t cnt ) {
  uint32_t ii, SET;
  Serial.print("PULLDOWN Start Vals:\n  ");
  SET = 0;
  Serial.print("PULLDOWN :: TEST to 3.3V\n  ");
  for ( ii = 0; ii < NUM_DIGITAL_PINS; ii++) {
    pinMode( ii, INPUT_PULLDOWN );
    delayMicroseconds( 5 );
    pinLast[ii] = digitalReadFast( ii );
    if (pinLast[ii]) {
      Serial.print("\nd#=");
      Serial.print( ii );
      Serial.print( " val=" );
    }
    Serial.print( pinLast[ii] );
    Serial.print(',');
  }
  Serial.println();
  Serial.println();
  while ( 1 ) {
    uint32_t jj, dd = 0, cc = 0, ee=4;
    cc = 0;
    for ( ii = 0; ii < NUM_DIGITAL_PINS; ii++) {
      jj = digitalReadFast( ii );
      if ( jj != pinLast[ii] ) {
        dd = 1;
        cc++;
        pinLast[ii] = jj;
        Serial.print("d#=");
        Serial.print( ii );
        if ( pinLast[ii] ) Serial.print( "\t" );
        Serial.print( " val=" );
        Serial.print( pinLast[ii] );
        Serial.print(',');
      }
      if ( cc > 1 && ee ) {
        Serial.println(">>> MULTI CHANGE !!");
        ee--;
      }
      if ( Serial.available() ) {
        while ( Serial.available() ) Serial.read();
        if ( 0 == SET ) {
          SET = 1;
          Serial.print("PULLUP :: TEST TO GND\n  ");
        }
        else {
          SET = 0;
          Serial.print("PULLDOWN :: TEST to 3.3V\n  ");
        }
        for ( ii = 0; ii < NUM_DIGITAL_PINS; ii++) {
          if ( 0 == SET )
            pinMode( ii, INPUT_PULLDOWN );
          else
            pinMode( ii, INPUT_PULLUP );
          delayMicroseconds( 20 );
          pinLast[ii] = digitalReadFast( ii );
          if (SET != pinLast[ii]) {
            Serial.print("d#=");
            Serial.print( ii );
            Serial.print( " val=" );
            Serial.println( pinLast[ii] );
          }
        }
      }
    }
    if ( dd ) {
      dd = 0;
      Serial.println();
      delay( 50 );
    }
  }
}
void testForShorts() {
  uint32_t ii;
  Serial.print("Quick Test for Shorts to adjacent pin");
  Serial.println("First pull pins down and see if the next one follows");
  for ( ii = 0; ii < NUM_DIGITAL_PINS-1; ii++) {
    pinMode( ii+1, INPUT_PULLDOWN );
    pinMode( ii, OUTPUT);
    digitalWrite(ii, HIGH);
    delayMicroseconds( 5 );
    if (digitalRead(ii+1)) {
      Serial.printf("%d:%d ", ii, ii+1);
    }
  }
  Serial.println("\n Now try Pull up and see if setting low follow");
  for ( ii = 0; ii < NUM_DIGITAL_PINS-1; ii++) {
    pinMode( ii+1, INPUT_PULLUP );
    pinMode( ii, OUTPUT);
    digitalWrite(ii, LOW);
    delayMicroseconds( 5 );
    if (!digitalRead(ii+1)) {
      Serial.printf("%d:%d ", ii, ii+1);
    }
  }
  Serial.println(); 
}

The idea is you can setup to jumper from either GND or a 3.3v pin to different pins and it will tell which pin or pins that changed state. Pressing enter key on keyboard will swap between trying to set all of the pins to INPUT_PULLUP or INPUT_PULLDOWN and with that which of the pins you should jumper from.

Withe the flex ribbon I had cases where my soldering was not good enough and maybe shorted two pins to each other. Also other times
where the ribbon did not make a good contact...

So if you take a jumper lets say from ground and touch each of the SD Cards data pins, it should how one pin changed state. If none do on a pin, then no continuity. if multiple you have a short... Note: two pins on the connector are GND and 3.3v if you jumper to one of those it will either do nothing or reset the board.

Good luck
 
TallDog / loglow did a T_4.0 breakout board https://www.tindie.com/products/loglow/teensy-40-breakout-revision-a/ and the SD wires were not right the first time IIRC. Here is a snippet from the product card that might help confirm ordering.
The 'SDCARD' pins are for the socket and there are some crossings from the T_4.0 base pads where a Ribbon cable was soldered and the USB_Host pins were pulled out. This is shown here: https://forum.pjrc.com/index.php?threads/teensy-4-0-breakout-kit.57122/post-211992
1716865074072.png
 
FWIW I've had success using blackketter/teensy4_header_breakout (forum post here) as a starting point for making my own PCB to get access to the SD_* pins via a surface mounted teensy 4.0:
pcb1.jpg

I was surprised by the quality of the castilated holes from JLCPCB, but the cost was a bit over the top. I ended up trying out regular through holes, and they worked out fine as well:
pcb2.jpg

For both cases I needed to manually touch up a few joints with some thin copper wire and solder, but the process has worked pretty well.
 
Hello Everyone, I got my hands on the pcb and i check the wiring, with a multimeter and it is all good
Front:
1717121745859.png

Back:
1717121779403.png

All I want to do is just read and write to a simple csv file, I dont care about the parsing for now i will do that later,
I tried the SD.h library with BUILTIN_SDCARD for the chip select and it didnt work, I am guessing the problem is me using the wrong library/protocol?
 
Last lines of Arduino IDE Verbose build output shows included 'libraries used' - the SDFAT lib must be from the Teensyduino install and not a local copy of any other 'published SDFAT'.

There are Teensy SD examples that should work for cardinfo and other simple example tasks when BUILTIN_SDCARD is set for the CS pin.
 
Any change the Flat Flex Cable is not fully inserted into the connector?

Here is a quick comparison of your image with the breakout board photo. Notice less of the blue part is visible.

sc.jpg


Looks like your cable may not be fully plugged into the socket.
 
cable is fully inserted, trust me i cannot push it any further, the blue part on my cable is just bigger. Also i think the teensy is dead, i dont know how that happened so im on pause till i get a new one :(
 
cable is fully inserted, trust me i cannot push it any further, the blue part on my cable is just bigger. Also i think the teensy is dead, i dont know how that happened so im on pause till i get a new one :(
Why do you think it is dead?
Can the PC see it?
If you plug it into pc and hold program button down for something like 10 seconds and release, does the recovery stuff reprogram it back to the ship state with LED blinking?

If not if you unplug it from the SD and anything else you can unplug does it do anything?
if you it works at all, did you try the HILOW test I mentioned earlier? If so do all of the data signals ring through and only one signal showing a connection per touching each pin? And in the right order... I think on one of my own prototypes, I reversed the pins...
 
Why do you think it is dead?
Can the PC see it?
If you plug it into pc and hold program button down for something like 10 seconds and release, does the recovery stuff reprogram it back to the ship state with LED blinking?

If not if you unplug it from the SD and anything else you can unplug does it do anything?
if you it works at all, did you try the HILOW test I mentioned earlier? If so do all of the data signals ring through and only one signal showing a connection per touching each pin? And in the right order... I think on one of my own prototypes, I reversed the pins...
i think it's dead because the pc cant see it,the led is not on. the HILOW test last thing i uploaded before the teensy died. i can feel the teensy heating though
 
Last edited:
Back
Top