Using SDXC/exFAT with Teensy 4.0 (SPI)

Sunday, December 13, 2020

Teensy 4.0

t f B! P L

The SDIO connection between the Teensy 4.0 board and microSD was introduced in a previous article. Here, I also report on SPI connection for comparison.

SPI Interface

Since the Teensy 4.0 supports an SDIO interface for SD cards, there is little reason to use SPI connection. However, SPI connection is of course also available. When connecting via SPI2, the SDIO interface pin layout on the back of the Teensy 4.0 can be used as is. Here, I show the case of using SPI0, which can be connected on a breadboard.

SD Card Connection via SPI
Teensy4.0
Pin No.
Teensy4.0
Pin Name
microSD
SPI Shield
microSD
Pin No. / Pin Name
GNDGNDGNDGND
3.3V3.3V3.3V3.3V
10CSCS2 / DAT3
11MOSIMOSI3 / CMD
12MISOMISO7 / DAT0
13SCLKSCLK5 / CLK
 
microSD connection via SPI on breadboard

Test Environment

As with the SDIO case, the SdFat beta version is used for testing with SDXC cards formatted with the exFAT file system. The modifications required for SPI connection are as follows:

Around line 329 of SdFat/src/SdFatConfig.h:
#define HAS_SDIO_CLASS 1
#endif  // defined(__MK64FX512__) || defined(__MK66FX1M0__)
#if defined(__IMXRT1062__)
// #define HAS_SDIO_CLASS 1   // Comment out
#define HAS_SDIO_CLASS 0  // Define as 0
#endif  // defined(__IMXRT1062__)

SdInfo Project

The SdInfo project can be used without modification. The SPI clock frequency is set to 16 MHz in this project.

bench Project

The bench project has the SPI clock frequency set to 50 MHz, but in this breadboard environment, some cards could not operate properly at that speed, so it was reduced to 45 MHz for testing. Around lines 10 and 28 of SdFat/examples/bench/bench.ino:
// SD_FAT_TYPE = 0 for SdFat/File as defined in SdFatConfig.h,
// 1 for FAT16/FAT32, 2 for exFAT, 3 for FAT16/FAT32 and exFAT.
// #define SD_FAT_TYPE 0
#define SD_FAT_TYPE 3

~~~~~~~

// Try max SPI clock for an SD. Reduce SPI_CLOCK if errors occur.
// #define SPI_CLOCK SD_SCK_MHZ(50)
#define SPI_CLOCK SD_SCK_MHZ(45)

Results

As with the SDIO connection, the following three cards were tested:
  • SanDisk microSDXC Ultra A1 64GB (UHS-I Speed Class 1)
  • SanDisk microSDXC Ultra A1 512GB (UHS-I Speed Class 1)
  • SanDisk microSDXC Extreme A2 1TB (UHS-I Speed Class 3)
Overall, the access speed was approximately 1/5 of the SDIO connection.

SdInfo Project

The SdInfo project results are shown for the 64GB card only:
SdFat version: 2.0.3-beta.1
... (same as original)

bench Project

The bench project results are shown below:
================================
(Sandisk SDXC microsd Ultra 64GB)
... (same as original)

About Me

My photo
Electronics, programming & audio

Featured Post

Synchronizing Radio-Controlled Clocks with Raspberry Pi Pico W (JJY Standard Radio Wave Emulator)

As a Raspberry Pi Pico W application, I built a JJY emulator for radio-controlled clocks (for time synchronization) with minimal peripheral...

QooQ