Coder Social home page Coder Social logo

cardSize Failed about sdfat HOT 8 CLOSED

schlaegerz avatar schlaegerz commented on July 22, 2024
cardSize Failed

from sdfat.

Comments (8)

pmdmartins123 avatar pmdmartins123 commented on July 22, 2024

On the sdfat library folder there is .h file that have the error codes description. When i locate the file i will post here again. If someone finds it out please post here.

from sdfat.

greiman avatar greiman commented on July 22, 2024

SdInfo can't access the register with card size. This is the first access to the card so you may have a wiring problem.

What board are you using? What type SD module and card? How is it connected?

from sdfat.

pmdmartins123 avatar pmdmartins123 commented on July 22, 2024

Hi,

So I am using an micro sd card reader bought from this store:
https://www.dfrobot.com/product-875.html
the sd card is HC 1 from Scan Disk.
The default wiring is:
13->SCK
12->MISO
11->MOSI
4->Chip Silect
But i have another stuff connected to this ports. So what I had to do was I changed the wiring to another ports and the code that i uploaded to the arduino was this:

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

/SD Card Congiguration***/
#if ENABLE_SOFTWARE_SPI_CLASS
const uint8_t SOFT_MISO_PIN = 7;
const uint8_t SOFT_MOSI_PIN = 6;
const uint8_t SOFT_SCK_PIN = 5;
const uint8_t SD_CHIP_SELECT_PIN = 4;
#else // ENABLE_SOFTWARE_SPI_CLASS
#error ENABLE_SOFTWARE_SPI_CLASS must be set non-zero in SdFat/SdFatConfig.h
#endif //ENABLE_SOFTWARE_SPI_CLASS

// SdFat software SPI template
SdFatSoftSpi<SOFT_MISO_PIN, SOFT_MOSI_PIN, SOFT_SCK_PIN> sd; // this ables to attribute aonther ports different of the default ports.

// Test file.
SdFile file;
SdFile hour;
File readFile;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
SPI.begin();
}

void loop(){
....
}

I hope this helps

from sdfat.

pmdmartins123 avatar pmdmartins123 commented on July 22, 2024

If you want to connect to the default wiring all you have to do is:

#include <SPI.h>
//#include <SD.h>
#include "SdFat.h"
SdFat SD; //default wiring

#define SD_CS_PIN SS
File myFile;

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

Serial.print("Initializing SD card...");

if (!SD.begin(SD_CS_PIN)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");

// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
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
}

this code is ReadWrite.ino example.

from sdfat.

greiman avatar greiman commented on July 22, 2024

pmdmartins123,

I can't help since I don't have your SD module. The module uses resistor voltage dividers instead of IC level shifters. This type SD module often causes problems.

from sdfat.

pmdmartins123 avatar pmdmartins123 commented on July 22, 2024

ok thanks

from sdfat.

schlaegerz avatar schlaegerz commented on July 22, 2024

I actually know mine is wired correctly because it was working with the built-in SD card libraries.

It turns out that it was a clock speed problem. When I changed it down to 1/2 clock speed everything seems to work just fine.

from sdfat.

greiman avatar greiman commented on July 22, 2024

built-in SD library use 4 MHz by default. You can use higher clock speed with this undocumented call.

boolean begin(uint32_t clock, uint8_t csPin);

from sdfat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.