Go Down

Topic: Micro SD card adapter interface with arduino due (Read 1 time) previous topic - next topic

himsikha

Hi,
i am trying to interface micro  SD CARD ADAPTER with arduino due ;tried the below things:

**Used ICSP header:
      MOSI-> ICSP4
     MISO->ICSP1
     SCK->ICSP3
     SS-> 4/10

** Also tried with SPI header :

clk->2
MISO-> 1
MOSI-> 5
SS->4


** Also  I looked at the Arduino DUE schematic and  tried connecting :
                                 MOSI-> 26
                                   MISO-> 25
                                  CLK->27
After trying the above things,i am not able to read the SDCard.
Please guide me regarding this.


himsikha

Hi,

I added the SdFatBeta20121203.ziP to the arduino ide1.5.6 but when was compliling the SDFATinfo then
compilation was terminated.
/root/Arduino/libraries/SdFat-master/src/SysCall.h:33:17: fatal error: SPI.h: No such file or directory
 #include <SPI.h>

I then added the #include <SPI.h> but encountered with errors.

i am still not able to interface SDcard adapter with the arduino due board.
Pls guide me.


weird_dave

What errors are you getting?
Also, it isn't obvious how you're connecting the hardware, or even what the hardware is. I would be using the SPI header, but I don't know what those numbers you've listed are for.

GolamMostafa

#4
Apr 04, 2018, 10:38 pm Last Edit: Apr 04, 2018, 10:39 pm by GolamMostafa
Quote
** Also tried with SPI header :

clk->2
MISO-> 1
MOSI-> 5
SS->4
The above connections have worked for my SD card. I uploaded the following program for simple write/read operation, and they worked well!
Code: [Select]
//SIMPLE WRITE AND READ

#include<SPI.h>   //sd cARD USES spi bUS
#include<SD.h>    //contains library functions

#define CSPIN 4   //slecting DPin-4 does not require to set direction
File myFile;      //file pointer variavle declaration

void setup()
{
  Serial.begin(9600);
  SD.begin(CSPIN);        //SD Card is initialized
  SD.remove("Test1.txt"); //remove any existing file with this name
  myFile = SD.open("Test1.txt", FILE_WRITE);  //file created and opened for writing

  if(myFile)        //file has really been opened
  {
    myFile.println(4000);
    myFile.println(200);
    myFile.println(3000);
    myFile.close();

  }
   myFile = SD.open("Test1.txt", FILE_READ);  //file created and opened for writing

  if(myFile)        //file has really been opened
  {
    while(myFile.available())
    {
      Serial.print((char)myFile.read());
    }
    myFile.close();
  }
}

void loop()
{
  
}

weird_dave

OK, how did you get that working? I couldn't match the pin numbers with either the Due SPI, SD card, Micro SD card, or one of the many adaptors available (obviously I couldn't tell if the named pins were for the Due or the SD end!)

GolamMostafa

#6
Apr 05, 2018, 11:55 am Last Edit: Apr 05, 2018, 12:23 pm by GolamMostafa
The following is the connection diagram between DUE and SD Card.







weird_dave

I see what's happened now:
https://www.arduino.cc/en/uploads/Main/arduino-Due-schematic.pdf
You happen to be on the correct pins, but the numbering is incorrect (your pin 1 is correct but your pin 4 is actually pin 6). Where did these Due SPI pin numbers originate?

Go Up