EmbeddedRelated.com
Forums

SPI problem on LPC2103

Started by Tom September 25, 2007
I'm using SPI to send 10 bits of data to a digital potentiometer.
The SPI is set up as the master. I'm pretty sure everything is set
up properly.
I've checked the clock output with an oscilloscope and noticed that
I get the proper number of pulses. When I check the MOSI pin, there
are pulses there but its not the data I'm applying to the SPDR. It's
always high pulses. Another strange thing is that the voltage level
of the pulses is about 100 mV. The clock signal is at 3.3 V, so I
don't understand why the data is like this.
Heres a snippet of my code:
void spi_init(
SPI_SPCR = 0x0A24; // 10 bits per transfer, master mode,
msb first, no ints
SPI_SPDR = 0x0000; // initialized to 0
SPI_SPCCR = 0x08;
}

void main(void)
{
while(1)
{

GPIO_IOCLR = P20; // used as a chip select

SPI_SPDR = 0xCC;

while(!(SPI_SPSR & SPIF)) { // wait for transfer to
complete
}
GPIO_IOSET = P20;

for (mydelay = 0;mydelay; 500000;mydelay++);

}
}

An Engineer's Guide to the LPC2100 Series