lpcware

LPC1768 SSP Problem

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by Usare on Sun Apr 28 11:27:54 MST 2013
Hello everyone,

I am trying to implement an SSP interface. I have got it working, well kind of.
It seems to be a one shot thing :confused:

More explanation:
If i try to read a register, i get the expected response. If i reboot and try to read another register, i get the expected response again.

But if i try to read two different registers, one after the other, without rebooting; the second read provides the value of the first read as the response. its as if the rx buffer is not being emptied.

The read code is from an NXP sample to read SD/MMC cards, and is as follows:

SEND:

uint8_t SPI_SendByte (uint8_t data)
{

    /* Put the data on the FIFO */
    LPC_SSP1->DR = data;

    /* Wait for sending to complete */
    while (LPC_SSP1->SR & SSP_SR_BSY);

    uint8_t tmp = LPC_SSP1->DR;

    /* Return the received value */
    return tmp;


}


Receive:

uint8_t SPI_RecvByte (void)
{

    /* Send 0xFF to provide clock for MISO to receive one byte */
    return SPI_SendByte (0xFF);
}


Any ideas whats going wrong here?

Outcomes