2013-11-21 03:42 AM
2013-11-21 06:43 AM
The master might want to make sure RXNE is cleared prior to sending the junk bytes
2013-11-21 08:10 AM
Thank you clive for your response. I'm not sure understanding your remark.
Do you mean , i have to change the order like this? while (RxIdx <BufferSize) { /* In this step, the Master recieves data from the Slave*/ /* Wait for SPI1 data reception */ while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET); /* Read SPI1 received data */ SPI1_Buffer_Rx[RxIdx] = SPI_ReceiveData8(SPI1); RxIdx++; /* send a byte */ while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET); //SPI_SendData8(SPI1,SPI1_Buffer_Tx[TxIdx++]); // Send Dummy SPI data to get back data from DR Register SPI_SendData8(SPI1,0x01); } If yes, it doesn't work, it gets stuck in RXNE.2013-11-21 08:52 AM
while(RxIdx <BufferSize)
{
/* send a byte */
while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET); // Spin Till TX Empty, should be after RX
if (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) != RESET) // Clear any hanging RX
SPI_ReceiveData8(SPI1);
// Send Dummy SPI data to get back data from DR Register
SPI_SendData8(SPI1,0x01);
/* In this step, the Master recieves data from the Slave*/
/* Wait for SPI1 data reception */
while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);
/* Read SPI1 received data */
SPI1_Buffer_Rx[RxIdx] = SPI_ReceiveData8(SPI1);
RxIdx++;
/* Turn on LED5 */
STM_EVAL_LEDOn(LED5);
}
2013-11-21 09:34 AM
I tried you solution but unfortunately, i have only zero.
May be i need to make some delay to wait the slave clock to start transfer because i think that during two cycles, the clock still inactive this why i have 2 zero in the beginning. I don't how and where ?