Using Mighty 1284P with SD card issues.

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

Do you use a solderless breadboard? If so try to refresh all the contacts (put out/in the wires/pins few times)..

Pito

No, it is made on Vero. I have checked all the wiring and joints, and checked the SD card on a Pro mini, and its fine using the above programme (with CS set to 9).

I have used a different 1284P as well, no dice. Also, I wired a uSD socket in parallel with the original SD socket, still no dice.

The Pro mini requires Pin 10 as the hardware SS pin fo rthe SD library to function.
I tried substituting 'SS' into the CS and 'pin 10' constants. They print as '4' (correct) but no joy from the SD card.

I modified the programme to have CS and 'pin 10' as variables, and cycled through them (CS 0 to 15, then increase pin 10 value) then the card reports errors until I get to CS = 4 (correct) and 'pin 10' is 1. This is repeatable. If I fix CS and pin 10 to these values, the initialisation fails.

Really stuck now.

Thanks for the advice, anyway.

Tony

Fixed the issue (I think). There was no 1284P defined in the library, just the standard Arduino processors.

I added the 1284P definition to libraries/SD/utility/Sd2PinMap.h to read

#elif defined(AVR_ATmega644P) || defined(AVR_ATmega644) ||(AVR_ATmega1284P)
// Sanguino

Hope this helps anyone.

Regards

Tony