Teensy 4.1 SD card interface

Fluxanode

Well-known member
Does the teensy 4.1 SD card slot use the external pins 10,11,12,13? Or are they available for use independently by another device(s)?
 
No, it uses SDIO, which is a lot faster.
On the Schematic on the Teensy 4.1 product page:

1725475510170.png

Which from my Excel document:
1725475570143.png

Which the center area shows actual Teensy IO pins for it.
 
Thanks Kurt, so i can wire up another SPI device to the external pins and not worry about interfering with the SD? How does the Teensy know to use which set of pins? Is it defined in the SD lib?
 
Depends? Which library are you using?
If you are using the SD library,
Pass in BUILTIN_SDCARD
#define BUILTIN_SDCARD 254

As shown in some of the examples, like the listfiles, which has:
Code:
#include <SD.h>


// change this to match your SD shield or module;
// Teensy 2.0: pin 0
// Teensy++ 2.0: pin 20
// Wiz820+SD board: pin 4
// Teensy audio board: pin 10
// Teensy 3.5 & 3.6 & 4.1 on-board: BUILTIN_SDCARD
const int chipSelect = 10;

Now if you are using SDFat, directly or through the SD wrapper, the SDFat_Usage exampl shows some different ways:
Code:
// Instead of the usual SD.begin(pin), you can access the underlying
  // SdFat library for much more control over how the SD card is
  // accessed.  Uncomment one of these, or craft your own if you wish
  // to use SdFat's many special features.

  // Faster SPI frequency.  16 MHz is default for longer / messy wiring.
  ok = SD.sdfs.begin(SdSpiConfig(chipSelect, SHARED_SPI, SD_SCK_MHZ(24)));

  // Very slow SPI frequency.  May be useful for hardware with slow buffers.
  //ok = SD.sdfs.begin(SdSpiConfig(chipSelect, SHARED_SPI, SD_SCK_MHZ(4)));

  // SdFat offers DEDICATED_SPI optimation when no other SPI chips are
  // connected.  More CPU time is used and results may vary depending on
  // interrupts, but for many cases speed is much faster.
  //ok = SD.sdfs.begin(SdSpiConfig(chipSelect, DEDICATED_SPI, SD_SCK_MHZ(16)));

  // Different SPI port (Teensy 4.1 SPI1 is MOSI1:pin26, MISO1:pin1, SCK1:pin27)
  // SPI1 photo: https://forum.pjrc.com/threads/69254?p=297875&viewfull=1#post297875
  // SPI2 photo: https://forum.pjrc.com/threads/60954?p=303782&viewfull=1#post303782
  //ok = SD.sdfs.begin(SdSpiConfig(chipSelect, SHARED_SPI, SD_SCK_MHZ(16), &SPI1));

  // Access the built in SD card on Teensy 3.5, 3.6, 4.1 using FIFO
  //ok = SD.sdfs.begin(SdioConfig(FIFO_SDIO));

  // Access the built in SD card on Teensy 3.5, 3.6, 4.1 using DMA (maybe faster)
  //ok = SD.sdfs.begin(SdioConfig(DMA_SDIO));
 
Correction, I have used SD on the teensy 3.2 and am moving to the 4.1. Isn't SDFat now integrated into SD? Which do you suggest?
 
Basically my problem is I made a PCB and used 10,11,12,and 13 for my AD converter, CS is 10. Now I'm concerned that is going to conflict with the SD as I want to write the AD info to the SD.
 
Correction, I have used SD on the teensy 3.2 and am moving to the 4.1. Isn't SDFat now integrated into SD? Which do you suggest?
The Teensy versions of SD library is a thin wrapper over the top of the SDFat library. If you are comfortable with SD library, I would simply
use it.
Basically my problem is I made a PCB and used 10,11,12,and 13 for my AD converter, CS is 10. Now I'm concerned that is going to conflict with the SD as I want to write the AD info to the SD.
Again on Teensy 3.5, 3.6, 4.x, if you use BUILTIN_SDCARD as the chip select passed in to begin... It will NOT use SPI, so pins 10-13 are perfectly valid to use for other SPI things.
 
Back
Top