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@yahoogroups.com, "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@yahoogroups.com, "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?Message
Re: SD card problem!
2005-05-08 by Gus
Attachments
- No local attachments were found for this message.