Hi.
I am using a 1284p processor (with Mainiacbugs 1284 bootloader), connected to the BMP085 pressure sensor and an SD card (2Gb/4Gb). This combination worked fine, but I left off for a couple of months, and now the board does not work, it fails the SD card. I have tried earlier versions of the project, with the same failure. I have tried different SD cards (uSD x 2 and one SD card, all formatted by the SDformatter programme, and all read OK on my computer and work on a 'Pro mini' board.
I tried the sample code from the SD library, and also the attached code posted on the forum.
The following code gives 'initialization failed!' message
/* SD card read/write example. Derived from the official example by Bill Greiman */
#include <SD.h>
// Change to SD chip select.
const int8_t sdChipSelect = 4;
// Chip select for any other SPI device or -1 if no other SPI device.
const int8_t otherChipSelect = 10;
File myFile;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
// Disable any other SPI device.
if (otherChipSelect >= 0) {
pinMode(otherChipSelect, OUTPUT);
digitalWrite(otherChipSelect, HIGH);
}
Serial.print("Initializing SD card...");
if (!SD.begin(sdChipSelect)) {
Serial.println("initialization failed!");
while(1);
}
Serial.println("initialization done.");
// open the file.
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
}
I have tried using const int8_t sdChipSelect = SS; instead of const int8_t sdChipSelect = 4; to no avail (printing SS prints '4' so I know SS is also '4'
I also noticed that the requisite 'PIin 10' connection is Rx1 on the Mighty 1284 pinouts - I think tjis may be where the problem lies?
Connections are
1284 pin 5 (D4) to uSD 2 (CS)
1284 pin 6 (MOSI) to uSD 3 (DI)
1284 pin 7 (MISO) to uSD 7 (DO)
1284 pin 8 (SCK) to uSD 5
Thanks for any help offered, I am stumped by this one.
Regards
Tony