I was working under Teensyduino 1.53 and was writing a program for teensy 4.1 that stored data on an SD card. Since I met some bugs under TD 1.53, I had to update to TD 1.55. But after the updating, the program stopped detecting the SD card inserted into the built-in slot. In the process of my attempts to figure out what was going wrong, I got to the point that I tried to compile a sketch from the "SD" library examples (C: \ Program Files (x86) \ Arduino \ hardware \ teensy \ avr \ libraries \ SD \ examples \ listfiles). And it does not detect the SD card. I ran this example on two teensy 4.1 with two different SD cards and always got the same result:
OK. Then I roll back to the Teensyduino 1.53 version, and compile just the same sketch, and flashed it into the Teensy board. Both Teensy boards began to see the SD cards.
OK. Then I updated the TD to the 1.55 version, again the cards are not visible. I rolled back to 1.53 again - everything works again. Then I checked TD 1.54 - SD cards are also not visible by the program.
So, the question is: what could be the reason for this behavior and what should I do to get access to the SD card under Teensyduino 1.55?
Here is the full text of the sketch that I wrote to the board for each version of Teensyduino:
Code:
Port open
Initializing SD card ... initialization failed!
OK. Then I updated the TD to the 1.55 version, again the cards are not visible. I rolled back to 1.53 again - everything works again. Then I checked TD 1.54 - SD cards are also not visible by the program.
So, the question is: what could be the reason for this behavior and what should I do to get access to the SD card under Teensyduino 1.55?
Here is the full text of the sketch that I wrote to the board for each version of Teensyduino:
Code:
/*
SD card basic directory list example
....
This example code is in the public domain.
*/
#include <SD.h>
// change this to match your SD shield or module;
// Teensy 3.5 & 3.6 & 4.1 on-board: BUILTIN_SDCARD
const int chipSelect = BUILTIN_SDCARD;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect.
}
Serial.print("Initializing SD card...");
if (!SD.begin(chipSelect)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
File root = SD.open("/");
printDirectory(root, 0);
Serial.println("done!");
}
void loop()
{
// nothing happens after setup finishes.
}
void printDirectory(File dir, int numSpaces) {
while (true) {
File entry = dir.openNextFile();
if (!entry) {
//Serial.println("** no more files **");
break;
}
printSpaces(numSpaces);
Serial.print(entry.name());
if (entry.isDirectory()) {
Serial.println("/");
printDirectory(entry, numSpaces + 2);
}
else {
// files have sizes, directories do not
printSpaces(48 - numSpaces - strlen(entry.name()));
Serial.print(" ");
Serial.println(entry.size(), DEC);
}
entry.close();
}
}
void printSpaces(int num) {
for (int i = 0; i < num; i++) {
Serial.print(" ");
}
}