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

SPI, SSP on LPC2148 MCB2140 Keil Bug?

Hi All,

Has anyone set up the SPI or SSP on the LPC2148?

I cant get SPI0 to work at all, i.e. no SCK when I scope the dev board (I have pull ups on SCK, MOSI0, MOI0 & SSEL0).

void SPI_Init (void)
{
PINSEL0 = 0x00005500; // SPI Pins
IODIR0 = 0x00000400; // Chipselect
S0SPCCR = 0x000000FF; // bit timing
S0SPCR = 0x000000A0; // Master, Ints enabled

VICVectCntl0 = 0x0000002A;
VICVectAddr0 = (unsigned);
VICIntEnable = 0x00000400;
}

So I thought I'll try the SSP instead.
Set that up with, no interrupts: -

void SPI1_Init (void)
{
PINSEL1 = 0x000002A8; // SPI1 pins
SSPCR0 = 0x00000007;
SSPCR1 = 0x00000002;
SSPCPSR = 0x00000002; // 30 MHz SCK
SSPCPSR = 0x00007530;
}

And the SPI1 SCK is there when I scope the hardware. Great!
But no.... try reading data from the SPI and it's not there. So I start single stepping and find the data is there but doesn't get passed properly (Keil Bug?).

My read command is 0x9F, which should return 0x20.

So my function is:

void read_Device_Type(void)
{
IOCLR0 = 0x00000400; // Pull Chip Sel low
while (SSPSR & BSY); // wait for SPI Idle
SSPDR = 0x009F; // Write command (1)
while (!(SSPSR & TNF)); // Wait transmit
SSPDR = 0x0000; // Dummy write (2)
while (!(SSPSR & TNF)); // Wait transmit
input = SSPDR; // Data from device (3)
IOSET0 = 0x00000400; // Chip select high
}

Now, looking at the memory location of SSPDR I find that after (1) SSPDR = 0xFF, then after (2) SSPDR = 0x20 (what I expect) but when I read SSPDR at (3) it returns 0x00.

If I replace (2) with (3) I return 0x00


The disasembler reveals an STRH R1, [R0] instruction which shows the correct return value but this is lost in the next LDR instruction.

Hope that gives you enough to understand, I spent all day on this....

Thanks,

Malcom

0