This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Simulating SPI on keil using ARM9

hi all I am working on the project related to friendly arm 2440 having a S3C2440A board
I wanted to simulate the SPI peripheral but system viewer neither the peripheral tab in menu shows any such entry..
Can anyone suggest any solution

Thanks for the help..

Parents Reply Children
  • #include <S3C2440.H>
    #include<stdio.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

    //************************************************************** sd_card_init(); 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};

    GPEDAT=GPEDAT||0x1000;

    //mosi=1;

    GPGDAT=GPGDAT||0x0004;

    //cs=1;

    spi_delay();

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

    GPGDAT=GPGDAT||0xFFFB;

    //cs=0;

    for(x=0;x<6;x++)

    SPTDAT0=cmd0[x];

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

    while((SPRDAT0==0x01)||(SPSTAT0&0x01==0))

    { for(x=0;x<6;x++)

    SPTDAT0=cmd55[x];

    for(x=0;x<6;x++)

    SPTDAT0=cmd41[x]; }
    }

    void spi_delay()
    {

    unsigned char i,j; //wait for 74 clk cycles or more

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

    for(j=0;j<255;j++);
    }

    this is my code which I am trying to simulate on keil but since SPI
    peripheral is not available there for this board it is of no use
    As sir has said.I have even tested this using oscilloscope but
    could not even find the clock...so anything else has o be done please tell
    me I am in great need of your comments and help.
    I am eagerly waiting for the answers...

    Thank you
    Roger

  • You'll want to review your clock and pin configurations. Perhaps you can seek some better examples.

    This is NOT how to do a bitwise OR GPEDAT=GPEDAT||0x1000;

    You'd want to use a single |

  • Thanks for pointing out sir

    It will be very helpful if you could post the examples here
    especially of S3C2440A board where they have used the SPI interface for Sd card.
    Also if you could help me on the aspect that if somehow I store the data in sd card and if I wanted to open it as a text file on the desktop how it might be possible if the card is FAT compatible.

  • the card is FAT compatible

    that is a big problem. try not to get a card that is ext2 or ntfs. they are more expensive and are not compatible in lots of things. like cameras and videos and fridges and things like that.

  • thanks sir

    But if there are any solutions then they will be appreciated.

    Thank you

    Roger

  • Hello all

    Well I have waited a lot almost a week for answers but I suppose all the geeky heads have gone
    to take a rest..If someone has awaken..
    Please help me..

    Thanks

    Roger