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

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

0