EmbDev.net

Forum: ARM programming with GCC/GNU tools MCI Protocol (LPC23xx)


von John (Guest)


Rate this post
useful
not useful
I'm new to arm programming, with books and examples found on the 
Internet I goota some of the microcontroler functions to work like: use 
of fic, irq, uart0, rtc, gp/io, lcd mod, a/d.
I'm really lost now, i'm trying to communicate with the SD CARD to 
initially write a block and record a variable for example. And in a 
futher use a Fat32 filesystem.

I'm using Yagarto compiler.

I found some examples of mmc with fat chan library but don't work with 
my board, or i dont know how to initializate the card.

Anyone can pass me more detalled informations about the use of SD CARD 
using the MCI protocol?

Where can I start studing to complete this Task?

Any information will help a lot.

von Martin T. (mthomas) (Moderator)


Rate this post
useful
not useful
John wrote:
> I'm new to arm programming, with books and examples found on the
> Internet I goota some of the microcontroler functions to work like: use
> of fic, irq, uart0, rtc, gp/io, lcd mod, a/d.
> I'm really lost now, i'm trying to communicate with the SD CARD to
> initially write a block and record a variable for example. And in a
> futher use a Fat32 filesystem.
>
> I'm using Yagarto compiler.
>
> I found some examples of mmc with fat chan library but don't work with
> my board, or i dont know how to initializate the card.

ChaN has an example with LPC23xx/24xx MCI support in is "sample-package" 
available from elm-chan (do not confuse this with my project from 
www.siwawi..., I just mixed code from various sources and wrote some 
glue-functions. ChaN created his own code from scratch and this one 
should be prefered).

If it does not work with your board double-check the connections. Maybe 
there is FET to enable/disable the card's VCC. Try to build a prototype 
exactly like ChaN's schematic or at least try to find the differences. 
There is also example-code for the low-level-functions available from 
the NXP-site and from keil.com (mind the license). The efsl (beta RC 
xzy) also includes some MCI code.

> Anyone can pass me more detalled informations about the use of SD CARD
> using the MCI protocol?
If the LPC's manual is not enough, search the technical library on 
arm.com. There is a document which describes the MCI-cell. Also a full 
SD and/or SDHC specification might be useful.

von John (Guest)


Rate this post
useful
not useful
I do what you have suggested, starts to study the elm-chan project 
example.
I got the circuit that he uses in a image that goes with the example 
code.
Analising the only difference that i found in the circuit of my board is 
that the MCI POWER pin in his board is changed to P0.10 as a GPIO pin. 
In my board this pin is connect to MCI_POWER pin (P0.21).

The only reference that I found to pin P0.10 in the code is in mci.c:
#define SOCKPORT  FIO0PIN1  /* Socket contact port */
#define SOCKINS    0x04    /* Card detect switch (bit2) */
#define  SOCKWP    0    /* Write protect switch (none) */

What I understand is that the interruption change the stat analising 
this pin to know if there is a card connected to the socket.
In my board, the same pin, is connected to P0.21, that should be:
#define SOCKPORT  FIO0PIN2
#define SOCKINS    0x20
#define  SOCKWP    0

but with this change still don't work, i got an error verifing if there 
is a Card conected to the socket, returns 3 (STA_NOINIT|STA_NODISK).
The same value is returned if the card is or isn't on the board.

Sure there is not the correctly form to verify if there is a Card 
connected to the board. How can I verify if there is a card connected to 
a board to pass this state check?

I also tried to force the Stat variable to be 0 (all OK) to pass this 
step of verification. The verification pass, identify the card as SDC 
ver1 or SDC ver2 correctly (I tryed both), but in this part of mci.c 
goto di_fail (error):
mci.c / inside  disk_initialize function:
do {  /* Wait while card is busy state (use ACMD41 or CMD1) */
  /* This loop will take a time. Insert wai_tsk(1) here for multitask 
envilonment. */
  if (!Timer[0]) goto di_fail;
} while (!send_cmd(cmd, 0x00FF8000, 1, resp) || !(resp[0] & 
0x80000000));

The response received goto a error.

Can anyone help-me to solve this or indicating where can I be missing?

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.