Help with SDfat please

Gang,
What am I missing here? I am sure the SD part of this code used to work, now I get an error message when I compile

#include <SPI.h>
#include <SdFat.h>


SdFat sd;


SdFile file;


// set 30 to whatever your chip select pin is
uint8_t chipSelect = 9;
//
byte x;
byte D10 = 10;
byte D9 = 9;
byte onesSeconds;
byte tensSeconds;
byte onesMinutes;
byte tensMinutes;
byte onesHours;
byte tensHours;
byte reg0;
byte reg1;
byte reg2;


byte D7 = 7;
void setup() {
  for (x = 2; x < 32; x = x + 1) {
    pinMode (x, OUTPUT);
  }
  digitalWrite (D10, HIGH);
  digitalWrite (D9, HIGH);
  SPI.begin();
  SPI.setDataMode(SPI_MODE0); // needed for SD card


  digitalWrite (D7, HIGH);
  delay(1000);
  digitalWrite (D7, LOW);
  delay (1000);
  // lines to comment out after the time is running.
  //digitalWrite (D10, LOW);
  //SPI.transfer(0x8E); // enable oscillator
  //SPI.transfer(0x00);
  //digitalWrite (D10, HIGH);
  //digitalWrite (D10, LOW);
  //SPI.transfer(0x8F); // enable oscillator
  //SPI.transfer(0x00);
  //digitalWrite (D10, HIGH);
  Serial.begin(115200);
  
    if (!sd.init(SPI_FULL_SPEED, chipSelect)) sd.initErrorHalt();


  if (!file.open("HELLO.TXT", O_WRITE | O_CREAT | O_TRUNC)) {
    sd.errorHalt("open");
  }


  file.println("Hello World!");


  file.close();
  
  Serial.println("Done!");
  
    SPI.setDataMode(SPI_MODE1); // needed for DS3234
  
}
void loop() {


  digitalWrite (D10, LOW);
  SPI.transfer(0x00); // seconds address
  reg0 = SPI.transfer(0x00); // seconds
  digitalWrite (D10, HIGH);
  onesSeconds = reg0 & 0x0f;
  tensSeconds = (reg0 & 0xf0)>>4;


  digitalWrite (D10, LOW);
  SPI.transfer(0x01); // minutes address
  reg1 = SPI.transfer(0x00); // 
  digitalWrite (D10, HIGH);
  onesMinutes = reg1 & 0x0f;
  tensMinutes = (reg1 & 0xf0)>>4;


  digitalWrite (D10, LOW);
  SPI.transfer(0x02); // hours address
  reg2 = SPI.transfer(0x00); // seconds - error here, should have been reg2 for hours
  digitalWrite (D10, HIGH);
  onesHours = reg2 & 0x0f;
  tensHours = (reg2 & 0xf0)>>4;


  Serial.print(tensHours);
  Serial.print (onesHours);
  Serial.print (":");
  Serial.print (tensMinutes);
  Serial.print (onesMinutes);
  Serial.print (":");
  Serial.print (tensSeconds);
  Serial.println (onesSeconds);
  delay (995);
}
C:\Arduino 1.0.6\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega1284p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 -IC:\Arduino 1.0.6\hardware\mighty-1284p\cores\mighty -IC:\Arduino 1.0.6\hardware\mighty-1284p\variants\bobuino -IC:\Arduino 1.0.6\libraries\SPI -IC:\Arduino 1.0.6\libraries\SdFat C:\Users\CROSSR~1.CRO\AppData\Local\Temp\build8181114714175854120.tmp\RTC_USD_SPI_Test.cpp -o C:\Users\CROSSR~1.CRO\AppData\Local\Temp\build8181114714175854120.tmp\RTC_USD_SPI_Test.cpp.o 
RTC_USD_SPI_Test.ino: In function 'void setup()':
RTC_USD_SPI_Test:49: error: 'class SdFat' has no member named 'init'

I think it should be:

sd.begin(chipSelect, SPI_FULL_SPEED)

Pete

P.S. One of the examples I have, uses this:

  if (!sd.begin(chipSelect, SD_SCK_MHZ(50))) {

Pete

Thanks, that's better.
Compiles & runs now. Getting SDFat error messages, time to look at actual signals I guess.

Which error messages?
Have you built your own uSD card interface? (Which would require looking at actual signals)

Pete

Type any character to start
Free RAM: 15198
Can't access SD card. Do not reformat.
No card, wrong chip select pin, or SPI problem?
SD errorCode: 0X1,0X0

Running this code now. Interface has '1284P with cd74HC4050 to buffer 5V CS/, SCK, MOSI down to 3.3V, and a '125 to bring MISO back to 5V. The RTC code was working without the uSD code.
The card was formatted using SD Formatter.

#include <SPI.h>
#include <SdFat.h>
#include <SdFatUtil.h>

// file system
SdFat sd;

// test file
SdFile file;

// SD chip select pin
//const uint8_t chipSelect = SS_PIN;
// set 30 to whatever your chip select pin is
uint8_t chipSelect = 9;
//
byte x;
byte D10 = 10;
byte D9 = 9;
byte onesSeconds;
byte tensSeconds;
byte onesMinutes;
byte tensMinutes;
byte onesHours;
byte tensHours;
byte reg0;
byte reg1;
byte reg2;

byte D7 = 7;

#define FILE_SIZE_MB 5
#define FILE_SIZE (1000000UL*FILE_SIZE_MB)
#define BUF_SIZE 100

uint8_t buf[BUF_SIZE];

// Serial output stream
ArduinoOutStream cout(Serial);
//------------------------------------------------------------------------------
// store error strings in flash to save RAM
#define error(s) sd.errorHalt_P(PSTR(s))
//------------------------------------------------------------------------------
void setup() {
  for (x = 2; x < 32; x = x + 1) {
    pinMode (x, OUTPUT);
  }
  digitalWrite (D10, HIGH);
  digitalWrite (D9, HIGH);
  SPI.begin();
  SPI.setDataMode(SPI_MODE1); // needed for SD card

  digitalWrite (D7, HIGH);
  delay(1000);
  digitalWrite (D7, LOW);
  delay (1000);
  // lines to comment out after the time is running.
  //digitalWrite (D10, LOW);
  //SPI.transfer(0x8E); // enable oscillator
  //SPI.transfer(0x00);
  //digitalWrite (D10, HIGH);
  //digitalWrite (D10, LOW);
  //SPI.transfer(0x8F); // enable oscillator
  //SPI.transfer(0x00);
  //digitalWrite (D10, HIGH);
  Serial.begin(115200);
  
  // pstr stores strings in flash to save RAM
  cout << pstr("Type any character to start\n");
  while (!Serial.available());

  cout << pstr("Free RAM: ") << FreeRam() << endl;

  // initialize the SD card at SPI_FULL_SPEED for best performance.
  // try SPI_HALF_SPEED if bus errors occur.
  if (!sd.begin(SPI_HALF_SPEED, chipSelect)) sd.initErrorHalt();

  cout << pstr("Type is FAT") << int(sd.vol()->fatType()) << endl;

  // open or create file - truncate existing file.
  if (!file.open("BENCH.DAT", O_CREAT | O_TRUNC | O_RDWR)) {
    error("open failed");
  }

  // fill buf with known data
  for (uint16_t i = 0; i < (BUF_SIZE-2); i++) {
    buf[i] = 'A' + (i % 26);
  }
  buf[BUF_SIZE-2] = '\r';
  buf[BUF_SIZE-1] = '\n';

  cout << pstr("File size ") << FILE_SIZE_MB << pstr("MB\n");

  cout << pstr("Starting write test.  Please wait up to a minute\n");

  // do write test
  uint32_t n = FILE_SIZE/sizeof(buf);
  uint32_t t = millis();
  for (uint32_t i = 0; i < n; i++) {
    if (file.write(buf, sizeof(buf)) != sizeof(buf)) {
      error("write failed");
    }
  }
  file.sync();
  t = millis() - t;
  double s = file.fileSize();
  cout << pstr("Write ") << s/t << pstr(" KB/sec\n\n");
  cout << pstr("Starting read test.  Please wait up to a minute\n");

  // do read test
  file.rewind();
  t = millis();
  for (uint32_t i = 0; i < n; i++) {
    if (file.read(buf, sizeof(buf)) != sizeof(buf)) {
      error("read failed");
    }
  }
  t = millis() - t;
  cout << pstr("Read ") << s/t << pstr(" KB/sec\n");
  cout << pstr("Done\n");
    SPI.setDataMode(SPI_MODE1); // needed for DS3234  
}
void loop() {

  digitalWrite (D10, LOW);
  SPI.transfer(0x00); // seconds address
  reg0 = SPI.transfer(0x00); // seconds
  digitalWrite (D10, HIGH);
  onesSeconds = reg0 & 0x0f;
  tensSeconds = (reg0 & 0xf0)>>4;

  digitalWrite (D10, LOW);
  SPI.transfer(0x01); // minutes address
  reg1 = SPI.transfer(0x00); // 
  digitalWrite (D10, HIGH);
  onesMinutes = reg1 & 0x0f;
  tensMinutes = (reg1 & 0xf0)>>4;

  digitalWrite (D10, LOW);
  SPI.transfer(0x02); // hours address
  reg2 = SPI.transfer(0x00); // seconds 
  digitalWrite (D10, HIGH);
  onesHours = reg2 & 0x0f;
  tensHours = (reg2 & 0xf0)>>4;

  Serial.print(tensHours);
  Serial.print (onesHours);
  Serial.print (":");
  Serial.print (tensMinutes);
  Serial.print (onesMinutes);
  Serial.print (":");
  Serial.print (tensSeconds);
  Serial.println (onesSeconds);
  delay (995);
}

The only info I have found about the 0x1 error is this:

A message like this from SdInfo with erorCode 0X1 indicates the SD card
is not seen by SdFat. This is often caused by a wiring error and reformatting
the card will not solve the problem.

Pete

Thanks. Time for some o'scoping, see what's going on.