I'm porting some code which includes SD card datalogging over to a Teensy 3.1, which has successfully run with Arduino versions Uno R3 and Pro Mini. I've hit some sort of barrier, possibly centered on the versions of the SD library I have available, even though all that I've read so far makes it seem like it should have been relatively easy.
The error messages are:
C:\...\arduino-1.0.5\libraries\SD\utility\Sd2Card.cpp:418:9: error: prototype for 'uint8_t Sd2Card::init(uint8_t, uint8_t)' does not match any in class 'Sd2Card'
In file included from C:\...\arduino-1.0.5\libraries\SD\utility\Sd2Card.cpp:21:0:
C:\...\arduino-1.0.5\libraries\SD\utility\Sd2Card.h:187:11: error: candidates are: uint8_t Sd2Card::init(uint8_t, uint8_t, int8_t, int8_t, int8_t)
C:\..\arduino-1.0.5\libraries\SD\utility\Sd2Card.h:184:11: error: uint8_t Sd2Card::init(uint8_t)
C:\...\arduino-1.0.5\libraries\SD\utility\Sd2Card.h:176:11: error: uint8_t Sd2Card::init()
The errors above are what I get when I use an SD library with files that have date stamps of 12/15/2013.
I have other SD libraries available (only one is present at a time in the libraries folder and I always exit then re-enter Arduino when I switch libraries). Each of them results in wildly different collections of errors, and in much greater quantity; the date stamps of them are 11/5/2013 (SDadafruit), another at 5/17/2013, and I also have SdFat which has a huge number of files with a wide range of dates (12/15/2013 for SdFat.h). Most of the files contain references to SparkFun authorship in the comments.
I have 2 questions so far:
a. Which SD library should I be using? A link to an download source would be great.
b. Can anyone spot a problem with these lines of code (which work beautifully with Arduinos):
What I have in the global code space:
#include <SPI.h>
#include <SD.h>
File logfile;
char filename[13];
const int slaveSelectPin = 10;
What I have in setup():
pinMode (slaveSelectPin, OUTPUT);
// see if the card is present and can be initialized:
if (!SD.begin(slaveSelectPin)) {
Serial.println("Is an SD card in place?");
}
// Construct a unique file name
strcpy(filename, "TGPS__00.CSV");
for (uint8_t i = 0; i < 100; i++) {
filename[6] = '0' + i/10;
filename[7] = '0' + i%10;
if (! SD.exists(filename)) { // create if does not exist, do not open existing, write, sync after write
break;
}
}
// Get ready to log
logfile = SD.open(filename, FILE_WRITE);
if( ! logfile ) {
Serial.println("No Go "); //Serial.println(filename);
while(1); // might as well stop if we can't open the file for logging
}
Supporting hardware information:
Teensy 3.1 (powered from 5V)
AdaFruit SD card breakout board (5V power, includes 5V, 3.3V level shifters for the data lines)
CS connected to Teensy pin 10
DO connected to Teensy pin 11
DI connected to Teensy pin 12
CLK connected to Teensy pin 13
The error messages are:
C:\...\arduino-1.0.5\libraries\SD\utility\Sd2Card.cpp:418:9: error: prototype for 'uint8_t Sd2Card::init(uint8_t, uint8_t)' does not match any in class 'Sd2Card'
In file included from C:\...\arduino-1.0.5\libraries\SD\utility\Sd2Card.cpp:21:0:
C:\...\arduino-1.0.5\libraries\SD\utility\Sd2Card.h:187:11: error: candidates are: uint8_t Sd2Card::init(uint8_t, uint8_t, int8_t, int8_t, int8_t)
C:\..\arduino-1.0.5\libraries\SD\utility\Sd2Card.h:184:11: error: uint8_t Sd2Card::init(uint8_t)
C:\...\arduino-1.0.5\libraries\SD\utility\Sd2Card.h:176:11: error: uint8_t Sd2Card::init()
The errors above are what I get when I use an SD library with files that have date stamps of 12/15/2013.
I have other SD libraries available (only one is present at a time in the libraries folder and I always exit then re-enter Arduino when I switch libraries). Each of them results in wildly different collections of errors, and in much greater quantity; the date stamps of them are 11/5/2013 (SDadafruit), another at 5/17/2013, and I also have SdFat which has a huge number of files with a wide range of dates (12/15/2013 for SdFat.h). Most of the files contain references to SparkFun authorship in the comments.
I have 2 questions so far:
a. Which SD library should I be using? A link to an download source would be great.
b. Can anyone spot a problem with these lines of code (which work beautifully with Arduinos):
What I have in the global code space:
#include <SPI.h>
#include <SD.h>
File logfile;
char filename[13];
const int slaveSelectPin = 10;
What I have in setup():
pinMode (slaveSelectPin, OUTPUT);
// see if the card is present and can be initialized:
if (!SD.begin(slaveSelectPin)) {
Serial.println("Is an SD card in place?");
}
// Construct a unique file name
strcpy(filename, "TGPS__00.CSV");
for (uint8_t i = 0; i < 100; i++) {
filename[6] = '0' + i/10;
filename[7] = '0' + i%10;
if (! SD.exists(filename)) { // create if does not exist, do not open existing, write, sync after write
break;
}
}
// Get ready to log
logfile = SD.open(filename, FILE_WRITE);
if( ! logfile ) {
Serial.println("No Go "); //Serial.println(filename);
while(1); // might as well stop if we can't open the file for logging
}
Supporting hardware information:
Teensy 3.1 (powered from 5V)
AdaFruit SD card breakout board (5V power, includes 5V, 3.3V level shifters for the data lines)
CS connected to Teensy pin 10
DO connected to Teensy pin 11
DI connected to Teensy pin 12
CLK connected to Teensy pin 13