Teensy 4.0 SD Corruption

Status
Not open for further replies.

jimmie

Well-known member
I am using the PJRC's SD board with a Teensy 4 and running Teensduino 1.47. I am also using Teensy's SD library. The hardware consists of a Teensy4, Wiznet WIZ850io and SD card.

I am experiencing a lot of file corruption problems. Sometimes, the board does not find the SD card. Other times, the card is located and a successful write occurs but then the next write fails. When this happens, the card is also often corrupted.

I am using an 8 GB SD card formatted using SDFormatter.

The code I am using is below:

Code:
 //------------------------------------------------------------

#include <SD.h>
#include <SPI.h>
File myFile;
const int chipSelect = 4;   // Wiz820+SD board: pin 4


...
...
...
  //http://www.pjrc.com/store/wiz820_sd_adaptor.html#init

  pinMode(9, OUTPUT);
  digitalWrite(9, LOW);    // begin reset the WIZ820io
  pinMode(10, OUTPUT);
  digitalWrite(10, HIGH);  // de-select WIZ820io
  pinMode(4, OUTPUT);
  digitalWrite(4, HIGH);   // de-select the SD Card
  digitalWrite(9, HIGH);   // end reset pulse

Serial.print("Initializing SD card...");
  if (!SD.begin(chipSelect)) {
    Serial.println("initialization failed!");
    //return;
  }
  Serial.println("initialization done.");
  write2SD();
  readSD();
  //------------------------------------------------------------

Is there an issue with using SD cards with the Teensy 4.0? I would appreciate the community's input.
 
Last edited:
Status
Not open for further replies.
Back
Top