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
  • #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

Reply
  • #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

Children