Pages: [1]   Go Down
Author Topic: SD card storage using the HSMCI interface  (Read 1466 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,
Has anyone ever had success testing the HSMCI (High Speed Memory Card) interface with the Arduino Due board?

I'm currently implementing a custom board based on the SAM3X8E processor used in the Due and I'm planning to use the HSMCI interface for SD card storage.  Right now I'm trying to do some software testing using an Arduino Due with an SD card connected to the HSCMI interface pins.  All the necessary signals except for MCDA0 are available on the headers.  MCDA0 is available by soldering to the TXLED.

So far I have attempted to get this working by using the Atmel Software Framework examples in Atmel Studio 6, and then using bossac.exe to flash the board.

The closest to success that I have achieved so far is to start with the "SD/MMC/SDIO Card FatFs Example - SAM3X-EK" project.  That project is intended for Atmel's SAM3X-EK demo board, so it uses the SAM3X8H processor instead of the SAM3X8E processor as used in the Due.  I was able to change the device to the SAM3X8E in the project settings, then modify the board definition file so that the Card Detect pin uses a pin available on the Due, and get the project to compile and load.

With this project compiled and loaded, I can see the MCCK (clock) pin creating a square wave, and I can see some brief pulses on the MCCDA (command) pin, but the initialization process still fails, unable to communicate with the SD card.

My alternate approach was to start with an example project created for the Due specifically, and then use the ASF wizard to add the necessary files to match the SD example project.  Although I can get that version to compile, load, and run, the clock pin never toggles nor does the command pin.  It seems like for some reason the PIO is not correctly configuring those pins for HSMCI usage in that case.


Anyway, that's enough background to understand what I have tried so far.  Has anyone else ever attempted to use the HSCMI interface with a Due board and had success?

Thanks so much in advance for any help or suggestions!


Dominic

PS - Before working with Atmel Studio and the ASF, I tried quite a lot to copy the relevant code into Arduino sketch files and compile within the IDE version 1.5.2, but I had absolutely no success getting it to compile as it could never seem to find the definitions and functions used in the ASF, even though I believe that most of those definition files should be part of the Arduino Due core library...

PPS - I am aware that there is a SPI interface SD library available for the Arduino Due.  That was my plan A, but unfortunately I'm also using some SPI ADC chips that require precise timing for a fast control loop and therefore I can't tolerate the delays from the block writes over a shared SPI bus.  If there are other alternatives (like software SPI to separate the SD vs. ADC busses, etc), I'm all ears!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

UPDATE:
Writing the post above made me think through the problem a bit more, so I decided to do a little bit more hardware debugging.

When I probed the command signal along with the clock signal, I could see the command sent by the processor as well as the response from the card.  However, after the card response, the command signal slowly drifted from 3.3V down towards ground, so I realized that I was missing a required pullup resistor on the MCCDA signal.  After adding a 10k pullup to 3.3V, the test writes to the SD card finally worked!!


However, I'm not out of the woods yet.  I have a fairly large sketch already running on the Due, and I need to integrate this HSMCI code with the sketch.  So, I'm still very interested in any suggestions about the best way to integrate Atmel ASF based code with the Arduino IDE code.  As I mentioned in my earlier post, when I started with an ASF example project specifically intended for the Due, the clock and command output pins were never active, even when the HSMCI->HSMCI_CMDR register write occurred.  It seems that something is wrong with the PIO settings when I try to integrate the SD card example project with the Arduino Due board configuration.

Thanks again!

Dominic
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,
This is by no means a proper Arduino library with examples, etc, but user Palliser requested a follow up with the code I used to get the HSMCI interface to an SD card working.

I have attached a zip file with the SdFatHsmci "library" that I used and a simple test program HSMCI_test.  This was created based on the HSMCI example projects from the Atmel Studio Atmel Software Framework and modifying as necessary to get the code to compile and run correctly in the Arduino IDE.  It was awhile ago when I did this work, but I believe that the primary code modifications had to do with eliminating some of the calls related to RTC (real time clock) functions that were not supported in my hardware setup.

I hope this is helpful to someone.

Thanks,

Dominic

* HSMCI_test.zip (140.4 KB - downloaded 18 times.)
Logged

Venezuela
Offline Offline
God Member
*****
Karma: 17
Posts: 522
Ground, ground, always ground
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Dominic and thank you for the files. I will be testing your sample and keep posting how it goes.

p
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I am new to memory card interfacing and would like to know some basics regarding MMC cards. FIrst of all I will be using the SPI interface to communicate with an eMMC card. I have found out through some research over the internet that only one data line DAT0 can be used to receive data from the eMMC by connecting it to SPI MISO and CMD can be used to send data to eMMC by connecting it to SPI MOSI. Is this information correct? If so, can someone please guide me to further details related to this matter.
Thanks in advance.

Regards,
Owais

P.S. I am using SAM4S16C which also has HSMCI but according to my requirement I need to use SPI.
Logged

Pages: [1]   Go Up
Jump to: