We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
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.