SD card

Hai all,

I’m a beginner for ARM.we are planning to write a data on SD card.could u please tell me the procedure and documents for that.I’m using MCB2140.

Thanks

Naz

naz:
Hai all,

I’m a beginner for ARM.we are planning to write a data on SD card.could u please tell me the procedure and documents for that.I’m using MCB2140.

[http://www.keil.com/arm/rl-arm/rl-flash.asp](http://www.keil.com/arm/rl-arm/rl-flash.asp)

check this:

http://www.nxp.com/acrobat_download/app … 0406_3.pdf

Thank you for reply.

http://www.keil.com/download/list/rl-arm.htm

in this link some demo software is there for SD card ,shall i use it on MCB2140.

i’m getting confused about sd card,any one can please tell which is the correct way to do my work.currently i did spi initialization only.

#define clk 0x00000800;//p0.11 timer capture

void spi_sd_init(void);

int main()

{

spi_sd_init();

}

void spi_sd_init()

{

IODIR0=clk;/*direction-11th pin out on PINSEL0 */

IOSET0=clk;/output set-11th pin out on PINSEL0/

PINSEL1=0x000000A8;/enable SCK,MISO,MOSI/

SSPCR0=0x0007;/8bit data transfer/

SSPCR1=0x02;/ssp enable/

SSPCPSR=0x02;/clock pre scale =here we enable 2/

PINSEL1|=clk;/SSEL enable/

}

next what i have to do.Actually my objective is i have read data from SD card and write data to SD card.we are using MCB2140(LPC2148) board and Transcen 1gb SD card.

Thanks

Naz

I suggest doing your work forward. It never seems to work well when doing it in reverse.

naz:
currently i did spi initialization only.

next what i have to do.

Next you have to read the document that raedbenz referred you to:

http://www.nxp.com/acrobat_download/app … 0406_3.pdf

cfb,

i tried that code,but nothing happened,means i downloaded the hex file to LPC2148,then sd card doesn’t detected.

You will find everything here http://www.siwawi.arubi.uni-kl.de/avr_p … index.html :smiley:

Angelo

Thanks for the kindful reply.i want to initialise the SD card.means first i want to see either my sd card is present or not.

#include<LPC214x.h>

#include<stdio.h>

#define cmd_size 5

#define clk 0x00000800;//p0.11 timer capture

#define IN_IDLE_STATE (1<<0) /waking from idle stage/

void spi_sd_init(void);

unsigned char sd_init(void);

unsigned char spi_tx_ready(unsigned char);

void spi_send(void);

void spi_send1(void);

unsigned char sd_response(unsigned char);

unsigned char sd_init_cmd={0x40,0x00,0x00,0x00,0x00,0x95};//reset commands

unsigned char sd_out_idle= {0x45, 0x00,0x00,0x00,0x00, 0xFF}; //bring out from idel state

long int i;

int main()

{

spi_sd_init();

sd_init();

}

void spi_sd_init()

{

IODIR0=clk;/*direction-11th pin out on PINSEL0 */

IOSET0=clk;/output set-11th pin out on PINSEL0/

PINSEL1=0x000000A8;/enable SCK,MISO,MOSI/

SSPCR0=0x0007;/8bit data transfer/

SSPCR1=0x02;/ssp enable/

SSPCPSR=0x02;/clock pre scale =here we enable 2/

PINSEL1|=clk;/SSEL enable/

}

unsigned char sd_init(void)

{

int i;

long int count =0xFF;

IOSET0=clk;//unselect slave

for(i=0;i<10;i++)

spi_tx_ready(0xFF);/check tx reg/

IOCLR0=clk; //select slave

spi_send();/send sd_init commmands/

if( sd_response(IN_IDLE_STATE))

{

IOSET0=clk;

return (1);

}

IOSET0=clk;//unselect slave

spi_tx_ready(0xFF); //send dummy clock

IOCLR0=clk; //select slave

i=255;//for repeating process

do

{

spi_send1();//send commands for bring out from idle stage

}while((spi_tx_ready(0x00)) && --count);

if(!count)

{

IOSET0=clk;

return 2;

}

spi_tx_ready(0xFF); //send dummy clock

IOCLR0=clk; //select slave

return 1;

}

/check tx reg/

unsigned char spi_tx_ready(unsigned char ch)

{

unsigned char ch1;

while((SSPSR & 0x02)!=1); /wait until TNF full/

SSPDR=ch;

while((SSPSR & 0x10)!=0); /wait until busy bit o/

ch1=SSPDR;

return ch1;

}

void spi_send(void)

{

int i;

for(i=0;i<cmd_size;i++)

spi_tx_ready(sd_init_cmd_); /send the sd commands/_
}
void spi_send1(void)
{
int j;

  • for(j=0;j<cmd_size;j++)*
  • spi_tx_ready(sd_out_idle[j]);*
    }
    unsigned char sd_response(unsigned char ch)
    {
    long int count =0xFF;
    while((spi_tx_ready(0xFF)!=ch) && --count);/254 !=1 && 254-this loop will execute upto 255 time/
    return (1);
    }

hai all,

i think my code is correct,but it doesn’t work.i think we have to add starup and retarget file…is it?

naz:
hai all,

i think my code is correct,but it doesn’t work.i think we have to add starup and retarget file…is it?

This is a funny statement. It doesn’t work, so you KNOW it isn’t correct. :shock:

hello all,

i’m using keil evaulation version.is it enough to develop Sd card application,or i have to buy licenesed versiong software.

naz:
i’m using keil evaulation version.is it enough to develop Sd card application,or i have to buy licenesed versiong software.

The limitations of the evaluation version are described here:

http://www.keil.com/demo/limits.asp

If your application is not doing much besides accessing the SD card, you are only planning to use it for a few months and it’s not a commercial product it might be sufficient for your use.