I have been working on this kit for the past month and have simulated some basic programs using Keil (non os using just C). I was assigned a project of making a data logger which stores the data in SDLC (synchronous data link protocol) format on SD card.

Thus my project has 2 very straight forward parts:

  1. Receive the data in sdlc format (TTL compatible).

  2. Store on SD Card.

I have searched the forums of both Keil as well as Mini 2440 but still clueless about the interfacing of an SD card interface using simple C. Everybody seems to be suggesting anything but C. I have read the manuals and other PDF regarding interfacing using both the SPI as well as SD bus mode and whatever I could make out of it was written in a code which is given below:

#include <S3C2440.H>
void sd_card_init(void);
void spi_delay(void);
int main()
    //pclk is 12MHZ
    GPECON=0x0a800000; //clk mosi miso 13 12 11
    GPGCON=0x00000030;//ss 2
    SPCON0=0x18;//set the clk & enable the master
    SPPRE0=0x0e;//set the clk at 400 khz
    SPPIN0=0x01;//derive the mosi level
    return 0;

void sd_card_init()
    unsigned char x;
    unsigned int cmd0[]={0x40 ,0x00 , 0x00, 0x00 ,0x00 ,0x95};
    unsigned int cmd55[]={0x77 ,0x00 , 0x00, 0x00 ,0x00 ,0x95};
    unsigned int cmd41[]={0x69 ,0x00 , 0x00, 0x00 ,0x00 ,0x95};






    //********************RESET COMMAND************************





    //**********************check if card is ready or not.******************


void spi_delay()
    unsigned char i,j; //wait for 74 clk cycles or more


This is my code which I am trying to simulate on Keil for SPI. I have even tested this using an oscilloscope but could not even find the clock, so if anything else has to be done please tell. I am in great need of your comments and help.

  • \$\begingroup\$ can I have some ans please \$\endgroup\$ – Srishti Jul 6 '13 at 6:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.