Hello community members.
I have recently started working with SD card using Microchip ARM based uC SAM4. So far I have managed to initialize the HSMCI interface of SAM4 and SD card is also initialized and has responded with the card capacity and the RCA (Relative Card Address). What I need to do now is read and write on the SD card. For this purpose I have extracted some functions implemented in the Atmel Studio examples. What I am confused about is how is the addressing done for the SD card, I realize that the card responds with a RCA but afterwards how is the addressing tracked to read and write data over the SD card and if we want to read data previously written how do we know where to read it from. I understand these are very basic questions but as I mentioned I am very new to this and need assistance.
Thanks in advance.
Regards,
Owais.
Hi Owals,
Can you point to the exact link here on the sample code used ?
Usually the card address will be obtained during initialization. For read/write the list of commands are used as defined in the official SD card specification document. Cmd52/Cmd53 with adress, read/write operation and data to be read/write will be specified in it.
Techguyz
Yes it may be a single allocating boot adresse probleme. Did you use an existing distribution, or did you try to compile yourself the code ? I have got this kind of probleme on the OMAP5432 when i tried myself to compile my own SD boot sequence.
Or unfortunately it may be a dysfunctioning component on the board ?
Hello Techguys,
Thank for your response. Actually I started with an example project in Atmel Studio for SAM4S-EK2 board for unit test of SD/MMC/SDIO card. So the example first identifies the type of card inserted and then initializes it accordingly. I have extracted the initialization code from this example and now I can create my own project and initialize the card and it returns the correct card size as well as RCA (Relative Card Address). What I need to do now is get the SD card related functions or in this case more specifically the HSMCI (High Speed Mutimedia Card Interface) functions to read and write blocks and integrate them into FreeRTOS+FAT SL. Since the example provided by FreeRTOS+FAT SL is for RAM, i have to adjust the functions and insert functions related to SD card. the example I used is documented in the following link:
http://asf.atmel.com/docs/3.19.0/common.components.memory.sd_mmc.unit_tests.sam4s_ek2/html/index.html
I am already following a thread related this matter on another blog dedicated for FreeRTOS. it would be helpful if someone here could also help me in this regard or if someone has already done this kind of thing before please do share your experience.
Owais
Hello ackmiro,
Thank for your response. As mentioned in the above response to techguys, I used an example project from Atmel Studio and extracted the SD card initialization sequence from there. i can now initialize the SD card and it returns the card capacity as well as RCA(Relative Card Address). Rest I have mentioned above please see.
Great, If you have the correct Relative Card Address it's easiest. What methode did you use to configure your SD Card Boot ? In the U-Boot sequence cross compiled, you could enter the RCA manually, if i remember clearly.
I am not sure if I understand you correctly, but I have used the initialization sequence as given in the attachment. Now i am trying to understand how to insert this in FreeRTOS+FAT SL. If you have any experience please do share.
Hi Owais,
I mean the return address is like 0x????????U or somethink like that ? No ?what is the correct RCA ? You have to recompile your code after modify the correct RCA in the correct .h file for exemple : sam4s16e.hI mean it's may only a mistake in a define's entry perhaps ?
Hello,
I mean the address is correct that is why the card is initializing and responding with CSD(Card Specific Data) from which I can collect the correct card size. Thsi is not a problem the initialization is carried out without any error. What is troubling me is the read and write block functions. Here I have attached both of these functions please have a look and suggest.
regards,
I also have a problem of the same kind. My problem is that i have viewed the example for SAM4-EK2 in Atmel Studio for SD card and cant make read function work for me. I think i have problem with giving function its needed parameters correctly.
I am sending you source code of this function, I'm hoping You could shed the light on what am I missing and how should I call this function correctly.
Best regards.