Reply by Sunil Jha May 9, 20052005-05-09
Thanks Clyde for your valuable feedback. It would be further great
help to me if you can please let me know.. After Initializing in SPI
Mode through CMD0 what would be the response value and what would be
the command sequence for reading CID register or performing any
Read/Write operation? Also is it required to pull-up MOSI and
MISO lines?

regards,
Sunil Jha

--- In lpc2000@lpc2..., Clyde Stubbs <clyde@h...> wrote:
> On Sun, May 08, 2005 at 10:50:38AM -0000, Sunil Jha wrote:
> > What should be the polarity and phase for SD memory card?
>
> The clock line idle state is high, data is latched on the second
> (rising) edge.
>
> Note that when the card is first accessed, the data output is open
> drain and requires a pullup - you must use a slow clock speed - the
> spec says 400kHz but I have found that even that is too fast for
some
> cards - I use 200kHz. After initialization the output is push-pull
and
> it will run at full speed (25MHz).
>
> Clyde
>
> --
> Clyde Stubbs | HI-TECH Software
> Email: clyde@h... | Phone Fax
> WWW: http://www.htsoft.com/ | USA: (408) 490 2885 (408) 490
2885
> PGP: finger clyde@h... | AUS: +61 7 3552 7777 +61 7 3552 7778
> -------------------------------
--------
> HI-TECH C: compiling the real world.


An Engineer's Guide to the LPC2100 Series

Reply by Clyde Stubbs May 9, 20052005-05-09
On Sun, May 08, 2005 at 10:50:38AM -0000, Sunil Jha wrote:
> What should be the polarity and phase for SD memory card?

The clock line idle state is high, data is latched on the second
(rising) edge.

Note that when the card is first accessed, the data output is open
drain and requires a pullup - you must use a slow clock speed - the
spec says 400kHz but I have found that even that is too fast for some
cards - I use 200kHz. After initialization the output is push-pull and
it will run at full speed (25MHz).

Clyde

--
Clyde Stubbs | HI-TECH Software
Email: clyde@clyd... | Phone Fax
WWW: http://www.htsoft.com/ | USA: (408) 490 2885 (408) 490 2885
PGP: finger clyde@clyd... | AUS: +61 7 3552 7777 +61 7 3552 7778
---
HI-TECH C: compiling the real world.



Reply by Gus May 9, 20052005-05-09
We never tried miniSD but I am assuming it is the same as SD!! and
for that I gave you the SPI settings that we have been using for 2
years! By the way, I am not the one who wrote the driver for SD so I
don't know much about it.
The SD manual is available at http://sandisk.com/oem/manuals.asp

If you need consulting, contact our company dirrectly and we will be
happy to help.

Gus

--- In lpc2000@lpc2..., "Sunil Jha" <jha0574@y...> wrote:
> Hi Gus,
> Actually setting S0SPCCR = 8 makes SPI clock rate = 1.875 MHz
> (Xtal MHz, PLL MSEL=5 PSEL=2, VPBDIV=2). Can you let me know
> which speed will be fine with mini SD memory card? At present I am
> working with 0.5 MHz.
>
> S0SPCR=0x30 makes CPOL=1 which is not working in my case. With
this
> I am getting Response of CMD0 as 0x00. With CPOL=0, setting
> S0SPCR=0x20, the response byte of CMD0=0x01. Which indicates card
in
> Idle State and is expected.
>
> One more help.. After Initializing in SPI Mode through CMD0 what
> would be the command sequence for reading CID register or
performing
> any Read/Write operation? Also is it required to pull-up MOSI and
> MISO lines?
>
> In one Forum at Microchip, I saw it is recommended to pad oxFF
> before and after CMD0 command. Now CMDO is 0xFF 0x40 0x00 0x00
0x00
> 0x00 0x95 0xFF. I tried it and it is giving response 0x01.
>
> Please help me in understanding these problems and rectifying them.
>
> regards,
> Sunil > --- In lpc2000@lpc2..., "Gus" <gus_is_working@y...> wrote:
> > change these in your code
> >
> > S0SPCCR=8;
> > S0SPCR=0x30;
> >
> > Make sure the hardware CS pin of SPI is connected to VCC
> >
> > look at the schematics on our website
> >
> > www.ghielectronics.com
> >
> > Gus
> >
> > --- In lpc2000@lpc2..., "Sunil Jha" <jha0574@y...> wrote:
> > > Hi Atanas,
> > > I am trying to initialize my Mini SD memory card in SPI
mode
> > > using LPC2129, but after lots of effort not able to do so. The
> SPI
> > > bus is working with another SPI IC, i have tested it before
> > > connecting to memory. I have incorporated corrections - Pull
> SSEL
> > to
> > > high and use another GPIO as SSEL.Every time i am getting
> response
> > > 0xFF from memory. Below is my code:
> > > ---------------------------
--
> --
> > --
> > > void init_SPI0 (void)
> > > {
> > > PINSEL0 |= 0x00005500;
> > > //Enable SPI0 pins
> > > IODIR0 |= 0x00000001;
> > > //Enable Chipselect pin as output
> > >
> > > S0SPCCR = 0x0000001E;
> > > //Set bit timing PCLK/30
> > > S0SPCR = 0x000000A0;
> > > //Configure as SPI Master interrupts enabled
> > >
> > > IOSET0 |= CS; //Pull Chipselect high
> > >
> > > }
> > >
> > > void init_memory(void)
> > > {
> > > unsigned char txstatus, byteread;
> > >
> > > IOCLR0 |= CS; //Pull Chipselect low
> > >
> > > S0SPDR = 0x40;
> > > while (!(S0SPSR & 0x80))
> > > putchar('+');
> > > txstatus = S0SPSR;
> > > S0SPDR;
> > > sprintf(str,"Transmit Status 0x40 %x\n",txstatus);
> > > putstr(str);
> > >
> > > S0SPDR = 0x00;
> > > while (!(S0SPSR & 0x80))
> > > putchar('+');
> > > txstatus = S0SPSR;
> > > S0SPDR;
> > > sprintf(str,"Transmit Status 0x00 %x\n",txstatus);
> > > putstr(str);
> > >
> > > S0SPDR = 0x00;
> > > while (!(S0SPSR & 0x80))
> > > putchar('+');
> > > txstatus = S0SPSR;
> > > S0SPDR;
> > > sprintf(str,"Transmit Status 0x00 %x\n",txstatus);
> > > putstr(str);
> > >
> > > S0SPDR = 0x00;
> > > while (!(S0SPSR & 0x80))
> > > putchar('+');
> > > txstatus = S0SPSR;
> > > S0SPDR;
> > > sprintf(str,"Transmit Status 0x00 %x\n",txstatus);
> > > putstr(str);
> > >
> > > S0SPDR = 0x00;
> > > while (!(S0SPSR & 0x80))
> > > putchar('+');
> > > txstatus = S0SPSR;
> > > S0SPDR;
> > > sprintf(str,"Transmit Status 0x00 %x\n",txstatus);
> > > putstr(str);
> > >
> > > S0SPDR = 0x95;
> > > while (!(S0SPSR & 0x80))
> > > putchar('+');
> > > txstatus = S0SPSR;
> > > S0SPDR;
> > > sprintf(str,"Transmit Status 0x95 %x\n",txstatus);
> > > putstr(str);
> > >
> > > S0SPDR = 0xFF;
> > > while (!(S0SPSR & 0x80))
> > > putchar('.');;
> > > txstatus = S0SPSR;
> > > byteread = S0SPDR;
> > > sprintf(str,"Byte Read %x\n",byteread);
> > > putstr(str);
> > > }
> > > ---------------------------
--
> > >
> > > If you have acheived this can you please help me in getting my
> > card
> > > initialized for SPI mode?
> > >
> > > regards,
> > > Sunil
> > >
> > > --- In lpc2000@lpc2..., "Atanas Tulbenski"
<top4e@y...>
> > > wrote:
> > > >
> > > > I'm using SD card with LPC2124. At first I used software
SPI
> > and
> > > > everything was fine. When I start using hardware SPI got
> > problem.
> > > The
> > > > SD card initializes, I can read serial numbers, but I cant
> read
> > > data
> > > > using CMD17. The card returns error code 0x04 "ilegal
> command".
> > > Any
> > > > sugestions?


Reply by Sunil Jha May 8, 20052005-05-08
Hi Gus,
Actually setting S0SPCCR = 8 makes SPI clock rate = 1.875 MHz
(Xtal MHz, PLL MSEL=5 PSEL=2, VPBDIV=2). Can you let me know
which speed will be fine with mini SD memory card? At present I am
working with 0.5 MHz.

S0SPCR=0x30 makes CPOL=1 which is not working in my case. With this
I am getting Response of CMD0 as 0x00. With CPOL=0, setting
S0SPCR=0x20, the response byte of CMD0=0x01. Which indicates card in
Idle State and is expected.

One more help.. After Initializing in SPI Mode through CMD0 what
would be the command sequence for reading CID register or performing
any Read/Write operation? Also is it required to pull-up MOSI and
MISO lines?

In one Forum at Microchip, I saw it is recommended to pad oxFF
before and after CMD0 command. Now CMDO is 0xFF 0x40 0x00 0x00 0x00
0x00 0x95 0xFF. I tried it and it is giving response 0x01.

Please help me in understanding these problems and rectifying them.

regards,
Sunil --- In lpc2000@lpc2..., "Gus" <gus_is_working@y...> wrote:
> change these in your code
>
> S0SPCCR=8;
> S0SPCR=0x30;
>
> Make sure the hardware CS pin of SPI is connected to VCC
>
> look at the schematics on our website
>
> www.ghielectronics.com
>
> Gus
>
> --- In lpc2000@lpc2..., "Sunil Jha" <jha0574@y...> wrote:
> > Hi Atanas,
> > I am trying to initialize my Mini SD memory card in SPI mode
> > using LPC2129, but after lots of effort not able to do so. The
SPI
> > bus is working with another SPI IC, i have tested it before
> > connecting to memory. I have incorporated corrections - Pull
SSEL
> to
> > high and use another GPIO as SSEL.Every time i am getting
response
> > 0xFF from memory. Below is my code:
> > -----------------------------
--
> --
> > void init_SPI0 (void)
> > {
> > PINSEL0 |= 0x00005500;
> > //Enable SPI0 pins
> > IODIR0 |= 0x00000001;
> > //Enable Chipselect pin as output
> >
> > S0SPCCR = 0x0000001E;
> > //Set bit timing PCLK/30
> > S0SPCR = 0x000000A0;
> > //Configure as SPI Master interrupts enabled
> >
> > IOSET0 |= CS; //Pull Chipselect high
> >
> > }
> >
> > void init_memory(void)
> > {
> > unsigned char txstatus, byteread;
> >
> > IOCLR0 |= CS; //Pull Chipselect low
> >
> > S0SPDR = 0x40;
> > while (!(S0SPSR & 0x80))
> > putchar('+');
> > txstatus = S0SPSR;
> > S0SPDR;
> > sprintf(str,"Transmit Status 0x40 %x\n",txstatus);
> > putstr(str);
> >
> > S0SPDR = 0x00;
> > while (!(S0SPSR & 0x80))
> > putchar('+');
> > txstatus = S0SPSR;
> > S0SPDR;
> > sprintf(str,"Transmit Status 0x00 %x\n",txstatus);
> > putstr(str);
> >
> > S0SPDR = 0x00;
> > while (!(S0SPSR & 0x80))
> > putchar('+');
> > txstatus = S0SPSR;
> > S0SPDR;
> > sprintf(str,"Transmit Status 0x00 %x\n",txstatus);
> > putstr(str);
> >
> > S0SPDR = 0x00;
> > while (!(S0SPSR & 0x80))
> > putchar('+');
> > txstatus = S0SPSR;
> > S0SPDR;
> > sprintf(str,"Transmit Status 0x00 %x\n",txstatus);
> > putstr(str);
> >
> > S0SPDR = 0x00;
> > while (!(S0SPSR & 0x80))
> > putchar('+');
> > txstatus = S0SPSR;
> > S0SPDR;
> > sprintf(str,"Transmit Status 0x00 %x\n",txstatus);
> > putstr(str);
> >
> > S0SPDR = 0x95;
> > while (!(S0SPSR & 0x80))
> > putchar('+');
> > txstatus = S0SPSR;
> > S0SPDR;
> > sprintf(str,"Transmit Status 0x95 %x\n",txstatus);
> > putstr(str);
> >
> > S0SPDR = 0xFF;
> > while (!(S0SPSR & 0x80))
> > putchar('.');;
> > txstatus = S0SPSR;
> > byteread = S0SPDR;
> > sprintf(str,"Byte Read %x\n",byteread);
> > putstr(str);
> > }
> > -----------------------------
> >
> > If you have acheived this can you please help me in getting my
> card
> > initialized for SPI mode?
> >
> > regards,
> > Sunil
> >
> > --- In lpc2000@lpc2..., "Atanas Tulbenski" <top4e@y...>
> > wrote:
> > >
> > > I'm using SD card with LPC2124. At first I used software SPI
> and
> > > everything was fine. When I start using hardware SPI got
> problem.
> > The
> > > SD card initializes, I can read serial numbers, but I cant
read
> > data
> > > using CMD17. The card returns error code 0x04 "ilegal
command".
> > Any
> > > sugestions?


Reply by Gus May 8, 20052005-05-08
change these in your code

S0SPCCR=8;
S0SPCR=0x30;

Make sure the hardware CS pin of SPI is connected to VCC

look at the schematics on our website

www.ghielectronics.com

Gus

--- In lpc2000@lpc2..., "Sunil Jha" <jha0574@y...> wrote:
> Hi Atanas,
> I am trying to initialize my Mini SD memory card in SPI mode
> using LPC2129, but after lots of effort not able to do so. The SPI
> bus is working with another SPI IC, i have tested it before
> connecting to memory. I have incorporated corrections - Pull SSEL
to
> high and use another GPIO as SSEL.Every time i am getting response
> 0xFF from memory. Below is my code:
> -------------------------------
--
> void init_SPI0 (void)
> {
> PINSEL0 |= 0x00005500;
> //Enable SPI0 pins
> IODIR0 |= 0x00000001;
> //Enable Chipselect pin as output
>
> S0SPCCR = 0x0000001E;
> //Set bit timing PCLK/30
> S0SPCR = 0x000000A0;
> //Configure as SPI Master interrupts enabled
>
> IOSET0 |= CS; //Pull Chipselect high
>
> }
>
> void init_memory(void)
> {
> unsigned char txstatus, byteread;
>
> IOCLR0 |= CS; //Pull Chipselect low
>
> S0SPDR = 0x40;
> while (!(S0SPSR & 0x80))
> putchar('+');
> txstatus = S0SPSR;
> S0SPDR;
> sprintf(str,"Transmit Status 0x40 %x\n",txstatus);
> putstr(str);
>
> S0SPDR = 0x00;
> while (!(S0SPSR & 0x80))
> putchar('+');
> txstatus = S0SPSR;
> S0SPDR;
> sprintf(str,"Transmit Status 0x00 %x\n",txstatus);
> putstr(str);
>
> S0SPDR = 0x00;
> while (!(S0SPSR & 0x80))
> putchar('+');
> txstatus = S0SPSR;
> S0SPDR;
> sprintf(str,"Transmit Status 0x00 %x\n",txstatus);
> putstr(str);
>
> S0SPDR = 0x00;
> while (!(S0SPSR & 0x80))
> putchar('+');
> txstatus = S0SPSR;
> S0SPDR;
> sprintf(str,"Transmit Status 0x00 %x\n",txstatus);
> putstr(str);
>
> S0SPDR = 0x00;
> while (!(S0SPSR & 0x80))
> putchar('+');
> txstatus = S0SPSR;
> S0SPDR;
> sprintf(str,"Transmit Status 0x00 %x\n",txstatus);
> putstr(str);
>
> S0SPDR = 0x95;
> while (!(S0SPSR & 0x80))
> putchar('+');
> txstatus = S0SPSR;
> S0SPDR;
> sprintf(str,"Transmit Status 0x95 %x\n",txstatus);
> putstr(str);
>
> S0SPDR = 0xFF;
> while (!(S0SPSR & 0x80))
> putchar('.');;
> txstatus = S0SPSR;
> byteread = S0SPDR;
> sprintf(str,"Byte Read %x\n",byteread);
> putstr(str);
> }
> -----------------------------
>
> If you have acheived this can you please help me in getting my
card
> initialized for SPI mode?
>
> regards,
> Sunil
>
> --- In lpc2000@lpc2..., "Atanas Tulbenski" <top4e@y...>
> wrote:
> >
> > I'm using SD card with LPC2124. At first I used software SPI
and
> > everything was fine. When I start using hardware SPI got
problem.
> The
> > SD card initializes, I can read serial numbers, but I cant read
> data
> > using CMD17. The card returns error code 0x04 "ilegal command".
> Any
> > sugestions?


Reply by Sunil Jha May 8, 20052005-05-08
Hi Gus,
What should be the polarity and phase for SD memory card?

thanks,
Sunil --- In lpc2000@lpc2..., "Gus" <gus_is_working@y...> wrote:
>
> check your polarity and idle state of SCLK. Why don't you scope it
> and compare sotware sPI to hardware SPI?
>
> We have it working, no problems.
> http://www.ghielectronics.com/ALFAT-SD.htm
>
> Gus
>
> --- In lpc2000@lpc2..., "Atanas Tulbenski" <top4e@y...>
> wrote:
> >
> > I'm using SD card with LPC2124. At first I used software SPI
and
> > everything was fine. When I start using hardware SPI got
problem.
> The
> > SD card initializes, I can read serial numbers, but I cant read
> data
> > using CMD17. The card returns error code 0x04 "ilegal command".
> Any
> > sugestions?


Reply by Sunil Jha May 8, 20052005-05-08
Hi Atanas,
I am trying to initialize my Mini SD memory card in SPI mode
using LPC2129, but after lots of effort not able to do so. The SPI
bus is working with another SPI IC, i have tested it before
connecting to memory. I have incorporated corrections - Pull SSEL to
high and use another GPIO as SSEL.Every time i am getting response
0xFF from memory. Below is my code:
---------------------------------
void init_SPI0 (void)
{
PINSEL0 |= 0x00005500;
//Enable SPI0 pins
IODIR0 |= 0x00000001;
//Enable Chipselect pin as output

S0SPCCR = 0x0000001E;
//Set bit timing PCLK/30
S0SPCR = 0x000000A0;
//Configure as SPI Master interrupts enabled

IOSET0 |= CS; //Pull Chipselect high

}

void init_memory(void)
{
unsigned char txstatus, byteread;

IOCLR0 |= CS; //Pull Chipselect low

S0SPDR = 0x40;
while (!(S0SPSR & 0x80))
putchar('+');
txstatus = S0SPSR;
S0SPDR;
sprintf(str,"Transmit Status 0x40 %x\n",txstatus);
putstr(str);

S0SPDR = 0x00;
while (!(S0SPSR & 0x80))
putchar('+');
txstatus = S0SPSR;
S0SPDR;
sprintf(str,"Transmit Status 0x00 %x\n",txstatus);
putstr(str);

S0SPDR = 0x00;
while (!(S0SPSR & 0x80))
putchar('+');
txstatus = S0SPSR;
S0SPDR;
sprintf(str,"Transmit Status 0x00 %x\n",txstatus);
putstr(str);

S0SPDR = 0x00;
while (!(S0SPSR & 0x80))
putchar('+');
txstatus = S0SPSR;
S0SPDR;
sprintf(str,"Transmit Status 0x00 %x\n",txstatus);
putstr(str);

S0SPDR = 0x00;
while (!(S0SPSR & 0x80))
putchar('+');
txstatus = S0SPSR;
S0SPDR;
sprintf(str,"Transmit Status 0x00 %x\n",txstatus);
putstr(str);

S0SPDR = 0x95;
while (!(S0SPSR & 0x80))
putchar('+');
txstatus = S0SPSR;
S0SPDR;
sprintf(str,"Transmit Status 0x95 %x\n",txstatus);
putstr(str);

S0SPDR = 0xFF;
while (!(S0SPSR & 0x80))
putchar('.');;
txstatus = S0SPSR;
byteread = S0SPDR;
sprintf(str,"Byte Read %x\n",byteread);
putstr(str);
}
-----------------------------

If you have acheived this can you please help me in getting my card
initialized for SPI mode?

regards,
Sunil

--- In lpc2000@lpc2..., "Atanas Tulbenski" <top4e@y...>
wrote:
>
> I'm using SD card with LPC2124. At first I used software SPI and
> everything was fine. When I start using hardware SPI got problem.
The
> SD card initializes, I can read serial numbers, but I cant read
data
> using CMD17. The card returns error code 0x04 "ilegal command".
Any
> sugestions?


Reply by Dan Beadle April 3, 20052005-04-03
Mouser (www.mouser.com) has 17 items listed if you seach on mmc then drill
down to connectors.

A typical part is 688-SCDA1A0701. Cost is $2.16 for one.

-----Original Message-----
From: Michael Anburaj [mailto:embeddedeng@embe...]
Sent: Saturday, April 02, 2005 11:02 AM
To: lpc2000@lpc2...
Subject: Re: [lpc2000] Re: SD card problem! Where can I buy SDIO connectors in retail quantity (1
or 2) In-store California or online?

Thanks,
-Mike.

--- Gus <gus_is_working@gus_...> wrote:
>
> check your polarity and idle state of SCLK. Why
> don't you scope it
> and compare sotware sPI to hardware SPI?
>
> We have it working, no problems.
> http://www.ghielectronics.com/ALFAT-SD.htm
>
> Gus
>
> --- In lpc2000@lpc2..., "Atanas Tulbenski"
> <top4e@y...>
> wrote:
> >
> > I'm using SD card with LPC2124. At first I used
> software SPI and
> > everything was fine. When I start using hardware
> SPI got problem.
> The
> > SD card initializes, I can read serial numbers,
> but I cant read
> data
> > using CMD17. The card returns error code 0x04
> "ilegal command".
> Any
> > sugestions? >
>
__________________________________
Yahoo! Messenger
Show us what our next emoticon should look like. Join the fun.
http://www.advision.webevents.yahoo.com/emoticontest
Yahoo! Groups Links



Reply by donhamilton2002 April 2, 20052005-04-02

http://www.sparkfun.com/shop/index.php?shop=1&cart 4636&cat=1&itemid30&
http://www.sparkfun.com/shop/index.php?shop=1&cart 4636&cat=1&itemid31&


Reply by Michael Anburaj April 2, 20052005-04-02
Where can I buy SDIO connectors in retail quantity (1
or 2) In-store California or online?

Thanks,
-Mike.

--- Gus <gus_is_working@gus_...> wrote:
>
> check your polarity and idle state of SCLK. Why
> don't you scope it
> and compare sotware sPI to hardware SPI?
>
> We have it working, no problems.
> http://www.ghielectronics.com/ALFAT-SD.htm
>
> Gus
>
> --- In lpc2000@lpc2..., "Atanas Tulbenski"
> <top4e@y...>
> wrote:
> >
> > I'm using SD card with LPC2124. At first I used
> software SPI and
> > everything was fine. When I start using hardware
> SPI got problem.
> The
> > SD card initializes, I can read serial numbers,
> but I cant read
> data
> > using CMD17. The card returns error code 0x04
> "ilegal command".
> Any
> > sugestions? >
>
__________________________________
Yahoo! Messenger
Show us what our next emoticon should look like. Join the fun.
http://www.advision.webevents.yahoo.com/emoticontest