Keil Logo Arm Logo

Discussion Forum

Problem in using SPI 1 of LPC2210

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
Edgar Policarpio
Posted
28-Mar-2007 10:40 GMT
Toolset
ARM
New! Problem in using SPI 1 of LPC2210

Hi all,

For some reason, SPI 1 of my LPC2210 would not work. The source code below worked for SPI 0 of LPC2138 (after changing the names of the registers, of course).


void main(void)
{
        SPI_Init();
        while (1)
        {
                 SPI_Write(0x55);
                   SPI_Write(0xAA);
        }
}

Initialization routine is as follows:


void SPI1_Init(void)
{
        IODIR0 |= 0x00100000;  // P0.7 is Output used as Slave Select
        PINSEL1 |= 0x000000a8; // SPI0 signals selected: SCK1, MISO1, MOSI1
        IOSET0 |= 0x00000080;  // Slave select is initialized to "1"
        S1SPCR |= 0x00000028;  // Master, CPOL=0, CPHA=1, rest is default
        S1SPCCR = 24;              // Divisor of CPU clock to get SCK
}

The write routine is as follows:


void SPI_Write(unsigned char value)
{
        IOCLR0 |= 0x00100000;
        S1SPDR = value;
        while ((S0SPSR & 0xF8) != 0x80); // Wait for data transfer to finish
        IOSET0 |= 0x00100000;
}


What am I doing wrong?

Thanks in advance,

Edgar

Read-Only
Author
Edgar Policarpio
Posted
28-Mar-2007 11:21 GMT
Toolset
ARM
New! RE: Problem in using SPI 1 of LPC2210

Ooops! I copied incorrectly in the third instruction of SPI_Init! It should read

IOSET0 |= 0x00100000; (not 0x00000080)

Edgar

Read-Only
Author
Edgar Policarpio
Posted
29-Mar-2007 01:16 GMT
Toolset
ARM
New! RE: Problem in using SPI 1 of LPC2210

Also to make sure that the connections are sound, I configured SPI 1 as GPIOs then toggled each one. Scoping them proved that they indeed toggle.

Edgar

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Keil logo

Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.