Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Lpc2103 spi0

Status
Not open for further replies.

AtomSoft

Well-Known Member
**broken link removed**

I need some help getting SPI0 to work with SD card. I tried so many cards so i
assume its the software.

This is my INIT SPI0 code and Transmit Code. See anything wrong?
Code:
//code to init the SPI0:
void INIT_SPI(BYTE speed)
{
    PINSEL0 |= 0x1500;

    if(speed==0)
    {
        S0SPCCR = 126;    // 396Khz (50Mhz / 126 = 396Khz) (50mhz/396Khz = 126)
    }
    if(speed==1)
    {
         S0SPCCR = 8;    // 6.25Mhz (50Mhz / 8 = 6.25Mhz) (50mhz/6.25Mhz = 8)
    }
    if(speed==2)
    {
        S0SPCCR = 0;
        S0SPCR = 0; 
        return;
    }
    S0SPCR = 0x820;   // 8 bit Master mode 00
}

//Code to send/get data:
BYTE xmit_spi(BYTE data)
{
    unsigned char temp;
    S0SPDR = data;
    while(!(S0SPSR & SPIF)){}
    temp = S0SPSR;
    temp = S0SPDR;
    debug_printf("Sent 0x%X, Received: 0x%X\n\r",data,temp);
    return temp; 
}
 
Stupid me i had the wires reversed heh:

My Debug window:
Code:
!!!Timer1 Init. Complete.

80+ Dummy Clocks Done

Idle State Complete!

SD Ver 2

Mount Completed!
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top