lpcware

SPI output, waiting for SPI-idle fails? (LPC1549)

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by DennisFrie on Sun May 11 18:06:03 MST 2014
I've been setting up SPI for LPC1549, but have have a problem when waiting for SPI-idle.

SPI is running in master-mode, 8 bit length, ignoring RX, 2 SPI-clocks in all delay-blocks.

I'm sending multiple bytes in the same frame, which works just fine when done like here:


while( (LPC_SPI0 -> STAT & (1<<1)) == 0); // Wait until new data can be accepted in buffer

LPC_SPI0 -> TXDATCTL =
0xFF | // Data
((8-1)<<24) | // Set length
(0 << 20) | // Set EOT false
(1 << 22) | // Ignore RX
(0 << 16);

while( (LPC_SPI0 -> STAT & (1<<1)) == 0); // Wait until new data can be accepted in buffer

LPC_SPI0 -> TXDATCTL =
0xFF | 1 | // Data
((8-1)<<24) | // Set length
(1 << 20) | // Set EOT true
(1 << 22) | // Ignore RX
(0 << 16);



Problem is, for the last byte I have to change some pin-settings, but using the SPI-idle byte from the SPI status register doesn't seem to work. Using this code, it never gets past the while-loop checking the status-register.

while( (LPC_SPI0 -> STAT & (1<<1)) == 0); // Wait for new data to be accepted

LPC_SPI0 -> TXDATCTL =
0xFF | 1 | // Data
((8-1)<<24) | // Set length
(0 << 20) | // Set EOT
(1 << 22) | // Ignore RX
(0 << 16);

       // This one is never false?
while(~LPC_SPI0->STAT & SPI_STAT_MSTIDLE);; // Wait for all data to be transmitted

LPC_SPI0 -> TXDATCTL =
0xFF | 1 | // Data
((8-1)<<24) | // Set length
(1 << 20) | // Set EOT
(1 << 22) | // Ignore RX
(0 << 16);


I'm sure this is just a stupid mistake. It seems so simple, but I just can't see the problem.

Outcomes