SD card storage using the HSMCI interface

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!

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

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 KB)

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

p

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.

Hello folks,

I was wondering if there has been any progress in this topic. I am also trying to work with SD card in SD mode on a SAM4S, So far I have successfully initialized bot the HSMCI and SD cards in SD mode now what I need is to test the read and write operation of the card in order to make sure everything is working properly. I am working on Atmel Studio and I tend not to use any of the ASF stuff so I am trying to make a completely custom project from scratch and then including the necessary files like HSMCI.c & HSMCI.h as well as sd_mmc_protocol.h file as a starting point. Please let me know if anyone has successfully done this before or is doing it now. Any help and suggestion would be appreciated.

Regards,
Owais.

Hey there, wondering if anyone has been able to get this "HSMCI_test.zip" code to compile with 1.6.8?

I get this error using: Arduino: 1.6.8 (Windows 7), Board: "Arduino Due (Native USB Port)"

too few arguments to function 'FRESULT f_open(FIL*, const TCHAR*, BYTE, int, int, int, int, int, int)'

Hello rocketjosh,

DominicG's sample sketch/library (HSMCI_test) runs OK but only in the IDE 1.5.6-r2 (at least for me).
Remember that this is an old code but it permits read/write an SD card very fast. I have run it with good results on a 32GB Kingston class 4 SDHC.

Do you really need hs reading your SD card? I wouldn’t recommend you messing with this library. It is very raw. Why don't use an SDCard on SPI? There is already a lot of support available for this solution in the Arduino library and this forum. Regards.

-p

'Very fast' ? faster than SdFat with custom DMA code?

What sort of speed are we talking?

Regards,

Graham

ghlawrence2000:
'Very fast' ? faster than SdFat with custom DMA code?

What sort of speed are we talking?

Regards,

Graham

Hello Graham,

Performance for high speed MCI (SD clock 48MHz):
Write 18.75MBytes/sec.
Read 19.5MBytes/sec.
I used Atmel's basic HSMCI SD/MMC example. I don't remember if the example transferred data with DMA (probably).

The above was about one year ago (from my taken scribbled notes) while testing Due with my TFT(HX8347A based).

http://forum.arduino.cc/index.php?topic=229976.10

Regards,

-p

Palliser,

Thank you for the reply! I'll try that older IDE to see how it works - I wonder what has changed with the newer IDEs to make it not work?

To answer your question - I am working with a custom board that uses the SAM3X with the SD socket connected to the HSMCI port. I'd love to take advantage of the higher speed capabilities and free up the SPI port for other stuff.

Also, I ran across this repo while doing some GIThub snooping. I am going to try this out as well. Maybe it will help someone else:

Thanks again for the replies!

rocketjosh

Did anyne get working HSMCI code to share?

I'm newbie here with DUE trying to make work MMC or SD in high speed.

@dbfonseca, if you dont want to by third party board lie the taijuino DUE, as Palliser mention, you could use DMA SPI.

I'e nerer tried it but the is one library for example:

/SdSpiSAM3X.cpp

Nitrof