lpcware

SPI - slave mode

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by tyassin on Tue Nov 12 07:16:35 MST 2013
Hello,

I have a communication between two MCUs: LPC1114 and LPC11A12. The slave device seems to be receiving the same data that is supposed to be sent! I have attached the code below:

void SSP_Send_Receive( uint8_t* buf, uint8_t length )
{
  uint8_t i;

  for ( i = 0; i < length; i++ )
  {
  LPC_SSP1->DR = *buf++;
//  while(!(LPC_SSP1->SR & SSPSR_BSY));
//  while ( (LPC_SSP1->SR & (SSPSR_BSY|SSPSR_RNE)) != SSPSR_RNE );
//  while(!(LPC_SSP1->SR & SSPSR_RFF));
  while ( !(LPC_SSP1->SR & SSPSR_RNE) );
  /* Wait until the Busy bit is cleared */

  Spi_receive_buffer = LPC_SSP1->DR;
  }
}


I supply the function with an array consisting of 0xDD, 0xEE, and 0xFF. After I have called the function I use the UART to see whet is in "Spi_receive_buffer".
Then it writes out 0xDD, 0xEE and 0xFF and I know something else is sent from the Master. Anybody have an idea what might be the problem? As you can see I have tried with different status register bits but nothing have helped.

Thank you.

Outcomes