SD card initialization failure using Mega 2560 / gps ultra d

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jtabatch
 
Posts: 25
Joined: Thu Sep 29, 2016 3:31 pm

SD card initialization failure using Mega 2560 / gps ultra d

Post by jtabatch »

Setup is Mega 2560 with GPS ultra data logger shield. Shield switch is set to "Direct" and GPS is working. Using Cardinfo example as a test bench with chipSelect = 10. SD card is good. Get "SD Card initialization failure" on serial output. Also followed recommended download of SD library per online setup instructions. Sort of at the end of my rope here . Below is a snipit of Cardinfo code.

#include <SPI.h>
#include <SD.h>

// set up variables using the SD utility library functions:
Sd2Card card;
SdVolume volume;
SdFile root;

// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
const int chipSelect = 10;

void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}


Serial.print("\nInitializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin
// (10 on most Arduino boards, 53 on the Mega) must be left as an output
// or the SD library functions will not work.
pinMode(SS, OUTPUT);


// we'll use the initialization code from the utility libraries
// since we're just testing if the card is working!
while (!card.init(SPI_HALF_SPEED, chipSelect)) {
Serial.println("initialization failed. Things to check:");
Serial.println("* is a card is inserted?");
Serial.println("* Is your wiring correct?");
Serial.println("* did you change the chipSelect pin to match your shield or module?");
}

User avatar
adafruit_support_bill
 
Posts: 88144
Joined: Sat Feb 07, 2009 10:11 am

Re: SD card initialization failure using Mega 2560 / gps ult

Post by adafruit_support_bill »

Please post photos showing all your soldering to the board.

User avatar
jtabatch
 
Posts: 25
Joined: Thu Sep 29, 2016 3:31 pm

Re: SD card initialization failure using Mega 2560 / gps ult

Post by jtabatch »

photos enclosed. Thanks
Attachments
gps_mega_2560.pdf
solder connections
(307.95 KiB) Downloaded 74 times

User avatar
adafruit_support_bill
 
Posts: 88144
Joined: Sat Feb 07, 2009 10:11 am

Re: SD card initialization failure using Mega 2560 / gps ult

Post by adafruit_support_bill »

The soldering looks good. For the Mega, you need to use Soft SPI.
See the compatibility guide here: https://learn.adafruit.com/adafruit-shi ... s-642938-6

User avatar
jtabatch
 
Posts: 25
Joined: Thu Sep 29, 2016 3:31 pm

Re: SD card initialization failure using Mega 2560 / gps ult

Post by jtabatch »

hi - thanks for the reply. I followed your instructions and set the dip switch to soft and jumped pins 7/8 to D18 and 19. Checked Sd2PinMap and Sd2card.h and for the ATmega2560 the lines had already been adjusted . I am running shield_sdlog and the card is still not initializing. I am using a 32 G card that had been formatted . Shield/card works on Uno but Uno does not have enough memory for what I want to do.

Justin

User avatar
adafruit_support_bill
 
Posts: 88144
Joined: Sat Feb 07, 2009 10:11 am

Re: SD card initialization failure using Mega 2560 / gps ult

Post by adafruit_support_bill »

Code: Select all

#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
// Mega

// Two Wire (aka I2C) ports
uint8_t const SDA_PIN = 20;
uint8_t const SCL_PIN = 21;

// SPI port
uint8_t const SS_PIN = 53;
uint8_t const MOSI_PIN = 51;
uint8_t const MISO_PIN = 50;
uint8_t const SCK_PIN = 52;
sdPinMap defines the hardware SPI pins for the Mega. If you look, you will see that those pins are on the Mega extended headers and have no connection to the shield.

Please follow the instructions in the link above to use software SPI with the Mega.

User avatar
jtabatch
 
Posts: 25
Joined: Thu Sep 29, 2016 3:31 pm

Re: SD card initialization failure using Mega 2560 / gps ult

Post by jtabatch »

Ok - still not working

#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
// Mega

// Two Wire (aka I2C) ports
uint8_t const SDA_PIN = 20;
uint8_t const SCL_PIN = 21;

// SPI port

uint8_t const SS_PIN = 10;
uint8_t const MOSI_PIN = 11;
uint8_t const MISO_PIN = 12;
uint8_t const SCK_PIN = 13;

/*
uint8_t const SS_PIN = 53;
uint8_t const MOSI_PIN = 51;
uint8_t const MISO_PIN = 50;
uint8_t const SCK_PIN = 52;
*/

User avatar
adafruit_support_bill
 
Posts: 88144
Joined: Sat Feb 07, 2009 10:11 am

Re: SD card initialization failure using Mega 2560 / gps ult

Post by adafruit_support_bill »

The preferred method is not to edit sdPinMap, but to specify the pins in your call to the 'begin()' function:

as in:

Code: Select all

  begin(10,11,12,13);

User avatar
jtabatch
 
Posts: 25
Joined: Thu Sep 29, 2016 3:31 pm

Re: SD card initialization failure using Mega 2560 / gps ult

Post by jtabatch »

Lol - wish you had told me that in the beginning . At least it's initializing so over came first hurdle .

Thanks for the help.

Justin

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”