AnsweredAssumed Answered

Reading worng first byte from serial flash

Question asked by farkash on May 18, 2015
Latest reply on May 18, 2015 by farkash
Hi everyone,

I'm working on custom board connecting STM32L152 to MX25L8006E (serial flash) using SPI driver.
The SS is handle by me (software).

I'm writing 24 bytes to some address and when i read from same address the first byte is always 0xFF.

It is not issue with serial flash because on the scope i can see that MISO signal is currect.

Waht can be the issue ????
below you can find my Read/Write functions :

//Send
void SendDataSpiControl(BYTE a_data)
{
 
  //< Wait until the transmit buffer is empty
  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET)
  {
  }
 
  //!< Send the byte
 //~~~~~~~~~~~~~~~~~~~~~~~~~
  SPI_I2S_SendData(SPI1, a_data);
 
  //!< Wait to receive a byte
 //~~~~~~~~~~~~~~~~~~~~~~~~~
  while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET){}
 
 
 
  //!< Return the byte read from the SPI bus
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  //return SPI_I2S_ReceiveData(ETH_SPI);
 
}
 
//Receive
uint8_t ReciveDataSpiControl(void)
{
  uint8_t Data = 0;
 
   //!< Wait until the transmit buffer is empty
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET){}
 
 
  //!< Send the byte
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  SPI_I2S_SendData(SPI1, SD_DUMMY_BYTE);
 
   
  //!< Wait until a data is received
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET){}
 
 
  //!< Get the received data
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  g_opSpiControl->m_receiveByte = SPI_I2S_ReceiveData(SPI1);

 
 
  // !< Return the shifted data
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  return g_opSpiControl->m_receiveByte;
}


Thanks in advance,
Moran

Outcomes