Teensy 3.5 SD Card error

Status
Not open for further replies.

tony74

New member
Hello Everybody,

First message on this forum. I really need help for this problem, I have been looking and trying everything possible to solve it.

I work with macOS Mojave 10.14.5 and Teensyduino application from pjrc.
I have a Teensy 3.5 board and a Transcend 16Go SDHC Class 10 Card formatted in ExFAT (also tried in FAT32).

I do not succeed to write and save txt data on the card from the SPI bus of the teensy.
I tried all the examples programs and some from the forum: SdInfo, wipe, Formatter, SdFormatter, ReadWrite.
Always the same error:SD errorCode: 0X20,0X0
I have been looking for this error message inside the code of the librairies but nothing showed up, maybe not the right place.
It also show on some programs the message Initialization failed, verify card
I also try the modified SdInfo from "drmatin 10-03-2016, 05:54 AM" at https://forum.pjrc.com/threads/37652-microSD-slot-on-teensy-3-6 and it showed this message in the monitor:

Code:
SdFat version: 10102

type any character to start

init time: 7 ms

Card type: SDHC

Manufacturer ID: 0X74
OEM ID: J`
Product: USDU1
Version: 2.0
Serial number: 0XE7A31943
Manufacturing date: 10/2012

cardSize: 15962.47 MB (MB = 1,000,000 bytes)
flashEraseSize: 128 blocks
eraseSingleBlock: true
OCR: 0XC0FF8000

SD Partition Table
part,boot,type,start,length
1,0X0,0XEE,1,31176703
2,0X0,0X0,0,0
3,0X0,0X0,0,0
4,0X0,0X0,0,0
error: 
File System initialization failed.


type any character to start


Thank you for your help,
Regards,
Tony
 
There's some apparent conflict in the description you provide. You say
I do not succeed to write and save txt data on the card from the SPI bus of the teensy.

If you are using the micro-SD slot on the T3.5, it is not intended to be used as an SPI bus device. It should be initialized and used as a 4-bit SDIO port. I think you need to provide us with some source code to straighten out this issue. I've used the SDIO port of the T3.6 many times and it works well if properly set up.
 
With the program readWrite from the SdFat library, initialization fail.
As I am very new to the teensy world and Arduino in general, I don't really understand how is it possible to write data on this card. What is the difference between the SPI or SDIO ? How does it work ? I have a T3.5.
Thank you,
Regards
Here is the code of the ReadWrite program:

Code:
/*
  SD card read/write

 This example shows how to read and write data to and from an SD card file
 The circuit:
 * SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13

 created   Nov 2010
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe

 This example code is in the public domain.

 */

#include <SPI.h>
#include <SD.h>
#include "SdFat.h"
SdFat SD;

#define SD_CS_PIN SS
File myFile;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.print("Initializing SD card...");

  if (!SD.begin(SD_CS_PIN)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  myFile = SD.open("test.txt", FILE_WRITE);

  // if the file opened okay, write to it:
  if (myFile) {
    Serial.print("Writing to test.txt...");
    myFile.println("testing 1, 2, 3.");
    // close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }

  // re-open the file for reading:
  myFile = SD.open("test.txt");
  if (myFile) {
    Serial.println("test.txt:");

    // read from the file until there's nothing else in it:
    while (myFile.available()) {
      Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}

void loop() {
  // nothing happens after setup
}
 
Hello, it is working !!
It was a problem from the SD card format from the macintosh formatting in MS-DOS FAT32. I bought a brand new 16Go card without formatting and it is working perfectly !
I think the card was corrupted or something wrong with it.

Thank you for your help,
Regards,
Tony
 
Status
Not open for further replies.
Back
Top