AnsweredAssumed Answered

SPI Sends Dummy bytes

Question asked by sd.pranathi on Mar 5, 2013
Latest reply on Mar 5, 2013 by Clive One
Hello All,
I am using STM32F207VC. I have problem while sending data to slaves.
I send a packet of data for example 0x01,0x02,0x03,0x04,0x05,0x06.
While sending these packets SPI sends 0x00 in between anyof these data and my actual data is skipped.So My Slave doesnt understand what I am sending and its not responding.
Could any one pls let me know what could be the problem. I am stuck with this since last 2 days.

Here is my code

uint8_t SPIWrite(uint8_t *pBufferPtr, uint8_t ucSPIPacketLength)
{

 uint8_t ucCount;
    uint8_t ucDummyRead;
   
 /*Assert the CS Pin to Low for SPI Slave*/
    CS_LOW(GPIOB,GPIO_Pin_12);       
    Delayus(100);
 
 
   for (ucCount=0; ucCount < ucSPIPacketLength; ucCount++)
   {
  while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) != SET);
  

  SPI_I2S_SendData(SPI2,*pBufferPtr );
  if(SPI2->DR != *pBufferPtr)
  {
   SPI_I2S_SendData(SPI2,*pBufferPtr );
  }
ucDummyRead =SPI_I2S_ReceiveData(SPI2);
  /*wait for transmission to complete */            
  while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) != SET);
  Delayus(100);
  /*read the response from the spi rx buffer to dummy variable*/
  ucDummyRead =SPI_I2S_ReceiveData(SPI2);
 while(SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_RXNE) == RESET) ;     pBufferPtr++;     
   
    }
      CS_HIGH(GPIOB,GPIO_Pin_12);

    return SUCCESS;
   
}

Outcomes