Extra configuration must be provided in the SD.begin () line. The Sdfat beta library has two options:
Code:
SD.begin (SdioConfig (FIFO_SDIO));
and
Code:
SD.begin (SdioConfig (DMA_SDIO));
Depending on the processing speed of instructions. With FIFO_SDIO better results are obtained. Try this:
Code:
#include <stdio.h>
#include <stdlib.h>
#include "TeensyThreads.h"
#include <EEPROM.h>
//#include <i2c_t3.h> New i2c lib: Used instead of Wire.h see Documents for doc
#include <Wire.h>
#include <ILI9341_t3.h>
#include <Streaming.h>
#include <Metro.h>
#include <SPI.h> // WARNING : TEENSY DEFAULT LED (PIN 13) IS OVER-RIDDEN BY SCK FOR SPI
#include <TimeLib.h>
#include <XPT2046_Touchscreen.h>
#include "DHT.h"
#include <FreqMeasureMulti.h>
#include "SdFat.h"
#define SD_FAT_TYPE 1
#if SD_FAT_TYPE == 1
SdFat SD;
// File file;
File filex, fhandle1, fhandle2, fhandle3, anaFile, hexFile, afile, bfile ;
File root;
#elif SD_FAT_TYPE == 2
SdExFat SD;
ExFile filex, fhandle1, fhandle2, fhandle3, anaFile, hexFile, afile, bfile ;
ExFile root;
#elif SD_FAT_TYPE == 3
SdFs SD;
FsFile filex, fhandle1, fhandle2, fhandle3, anaFile, hexFile, afile, bfile ;
FsFile root;
#endif // SD_FAT_TYPE
// ILI9341_t3 tft
const uint8_t CS_PIN = 8, TFT_CS = 10, TFT_DC = 9, TIRQ_PIN = 2;
ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC); // 'n' version causing errors
XPT2046_Touchscreen ts(CS_PIN); // TFT GRAPHICS OBJECTS TOUCHSCREEN
TS_Point p, pmap;
// CALLBACK ROUTINES
time_t newtime, tempSystime;
void dateTime(uint16_t* date, uint16_t* time) { // Following used by -> SdFile::dateTimeCallback(dateTime);
*date = FAT_DATE(year(), month(), day()); // set date time callback function
*time = FAT_TIME(hour(), minute(), second());
}
time_t getTeensy3Time() {
return Teensy3Clock.get();
}
void setup() {
tft.begin();
ts.begin(); // touchscreen begin
tft.fillScreen(ILI9341_BLACK); tft.setRotation(3);
if (!SD.begin(SdioConfig(FIFO_SDIO))) {
//if (!SD.begin(SdioConfig(DMA_SDIO))) {
//if (!SD.begin()) {
tft.fillScreen(ILI9341_RED); tft.setRotation(3);
Serial.println("SD initialization failed!");
tft.setCursor(5, 205);
tft.setTextSize(2);
tft.print("SD failed to initialize");
delay(3000);
} else {
SdFile::dateTimeCallback(dateTime); // set date time callback function
tft.fillScreen(ILI9341_GREEN); tft.setRotation(3);
Serial.println("SD Init success ..file timestamp callback installed ");
tft.setCursor(5, 205);
tft.setTextSize(2);
tft.print("SD Init success");
}
}
void loop() {
}
With SD.begin()

With SD.begin(SdioConfig(FIFO_SDIO)) or SD.begin(SdioConfig(DMA_SDIO))