Teensy 4.1 SD Card SPI Port

cgeber24

Active member
I have successfully accessed an SD card using the BUILTIN_SDCARD connector on the Teensy 4.1

I now wish to also access a 2nd SD card connected to a Teensy 4.1's SPI Port; thus I need to supply the CS pin to the SD.begin(pin) function call.

Can any digital pin be used for this function? When I make this call, how would I know and/or specify which of the two Teensy 4.1 SPI ports will be utilized?

The Pinout diagram for the Teensy 4.1 seems to have some green SPI pins labelled "CS" and "CS1" but it is not clear what that means...perhaps CS Pin 10 implies SPI0 and CS1 Pin 38 implies SPI1?

Thanks,
Chuck Geber
 
I have successfully accessed an SD card using the BUILTIN_SDCARD connector on the Teensy 4.1

I now wish to also access a 2nd SD card connected to a Teensy 4.1's SPI Port; thus I need to supply the CS pin to the SD.begin(pin) function call.

Can any digital pin be used for this function? When I make this call, how would I know and/or specify which of the two Teensy 4.1 SPI ports will be utilized?

The Pinout diagram for the Teensy 4.1 seems to have some green SPI pins labelled "CS" and "CS1" but it is not clear what that means...perhaps CS Pin 10 implies SPI0 and CS1 Pin 38 implies SPI1?

Thanks,
Chuck Geber
For most SPI devices, you can use any digital pin for the CS and/or DC pins.

In the Teensy 3.1/3.2/3.5/3.6 processors, there are several special CS/DC pins that some of the display drivers use to provide micro-optimizations to speed up the display. These micro-optimizations needed both the CS and DS pins to be selected.

When the Teensy 4.0 came out, there was only one special pin available (pin 10 for SPI0 and pin 0 for SPI1). The micro-optimizations for the display drivers were not done, and any digital pin could be used for CS and DC.

I don't believe that when the Teensy 4.1 came out with additional special pins, that the display drivers were modified to add the micro-optimizations back.
 
Thanks Michael!

This leaves me with just one question: which Teensy 4.1 SPI port will be used by the SD library when a CS pin is supplied instead of BUILTIN_SDCARD?
 
Poking around with a Logic Analyzer, I have found that the SD library uses the first SPI port on the Teensy 4.1 CPU; there does not appear to be a way to select the 2nd SPI port.
 
In Arduino IDE (with Teensy selected), click File > Examples > SD > SdFat_Usage for an example of how to select the other SPI ports. See the comments in that example for explanation.
 
Back
Top