SD Card Problem with Wave Shield

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
inphaseprod
 
Posts: 1
Joined: Sat Nov 15, 2014 8:28 pm

SD Card Problem with Wave Shield

Post by inphaseprod »

My friend is helping me try to get my Wave Shield working and we’re stuck on a function.
I’m trying to determine what might be the trouble. Formatting issue? Ideas? We’re stuck!
The printout follows:

Code: Select all

uint8_t SdReader::init(uint8_t slow) {
  uint8_t ocr[4];
  uint8_t r;
  
  Serial.println(71);  
  
  pinMode(SS, OUTPUT);
  digitalWrite(SS, HIGH);
  pinMode(MOSI, OUTPUT);
  pinMode(MISO_PIN, INPUT);
  pinMode(SCK, OUTPUT);
  Serial.println(72);  
  
#if SPI_INIT_SLOW
  // Enable SPI, Master, clock rate f_osc/128
  SPCR = (1 << SPE) | (1 << MSTR) | (1 << SPR1) | (1 << SPR0);
#else  // SPI_INIT_SLOW
  // Enable SPI, Master, clock rate f_osc/64
  SPCR = (1 << SPE) | (1 << MSTR) | (1 << SPR1);
#endif  // SPI_INIT_SLOW
  
  // must supply min of 74 clock cycles with CS high.
  for (uint8_t i = 0; i < 10; i++) spiSend(0XFF);
  Serial.println(73);  
  
  // next two lines prevent re-init hang by cards that were in partial read
  spiSSLow();
  for (uint16_t i = 0; i <= 512; i++) spiRec();
  Serial.println(74);  
  
  // command to go idle in SPI mode
  for (uint8_t retry = 0; ; retry++) {
    Serial.println(741);  
    if ((r = cardCommand(CMD0, 0)) ==  R1_IDLE_STATE) break;
    if (retry == 10) {
      error(SD_CARD_ERROR_CMD0, r);
      return false;
    }
  }
  Serial.println(75);  
Here’s what it prints back:
690
1
71
72
73
74
741
741
690
51
71
72
73
74
741
741
741
741
741
741
741
741
741
741
741
10
Last edited by adafruit_support_mike on Sun Nov 16, 2014 2:45 am, edited 1 time in total.
Reason: added CODE tags to preserve formatting

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: SD Card Problem with Wave Shield

Post by adafruit_support_mike »

It looks like the code is doing what it should.

What problem are you having? In general, you shouldn't need to dive into the SD library to make a Wave Shield work.

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

Return to “Arduino Shields from Adafruit”