SPI0 Send

Hi

Can anyone see the problem with the following:

uint32_t SPI_Send(uint32_t byte)

{

/* Transmits data to the SPI bus and waits until the end of SPI data transmission. */

SPI_SPDR = byte; // Data is sent

while (!(SPI_SPSR & 0x08)); // Wait till end of transmission

SPI_SPSR &= ~0x80; // Clear the ARM SPI interrupt flag

return SPI_SPDR; // Receive data on SPI Read

}

When I debug it just sits on that ‘while’ loop.

hello

if your code is blocked on the loop it is that the register of state is never equal 0x80, therefore your SPI does not work!!

I have a code SPI on LPC2129 which works fine well if you wants it!

look at your Doc. well if there is not particular configuration for the SSEL PIN

for the lpc2129 it is necessary to put this PIN to 3.3v for the master mode

Hi

Wow thanks…now it makes sense! My SSEL pin isn’t connected to 3.3V…and I will leave it just to keep my options open…

You are right…i just had a look at my SPI_Init code and I think there is something wrong with it…maybe i havent initialised the SPI properly…there is no SCK pulse…

PINSEL0 = 0x001500

what should the other registers be kept to make sure it’s in master mode?

Do you have any code for SPI0 initialiation? I am using an LPC2148 chip…