|
Post by AlexandreM on Aug 23, 2017 12:58:21 GMT
Hi !
I'm using a TC275 and I can't save my values on a dataloger, he work properly with a uno, mega and also with a Max32 but with the TC275 he didn't work ...
The LED indicator of backup is all the time ON ... then I think the SD card port are saturated and I don't know why ( probably the wiring).
Anyone have a solution ?
Thanks !
|
|
|
Post by unseenart on Dec 15, 2023 8:05:39 GMT
After some testing to use Spi channel 1 on p12 (MISO), p11(MOSI) and p13 (SCK) which also uses p10 as the slave select:
For me this code works, anyone facing this problem can try:
/* SD card read/write
#include <SD.h> #include <SPI.h> #define Serial SerialASC File myFile;
void setup() { // Open serial communications and wait for port to open: SPI.begin(BOARD_SPI_SS0_S1); Serial.begin(9600); pinMode(BOARD_SPI_SS0_S1,OUTPUT); while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only }
Serial.print("Initializing SD card...");
if (!SD.begin(BOARD_SPI_SS0_S1)) { Serial.println("initialization failed!"); while (1); } Serial.println("initialization done."); SDwrite(); SDread();
}
void loop() { // nothing happens after setup }
void SDread(){ // re-open the file for reading: myFile = SD.open("test.txt",FILE_READ); if (myFile) { Serial.println("datalog.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 SDwrite(){ // 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");
// 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("Writing to test.txt sucessfully"); } else { // if the file didn't open, print an error: Serial.println("error opening test.txt"); } }
|
|