cancel
Showing results for 
Search instead for 
Did you mean: 

SPI communication between two STM32F3 problem

love-peace2001
Associate II
Posted on November 21, 2013 at 12:42

The original post was too long to process during our migration. Please click on the attachment to read the original post.
4 REPLIES 4
Posted on November 21, 2013 at 15:43

The master might want to make sure RXNE is cleared prior to sending the junk bytes

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
love-peace2001
Associate II
Posted on November 21, 2013 at 17:10

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.

Posted on November 21, 2013 at 17:52

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); 
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
love-peace2001
Associate II
Posted on November 21, 2013 at 18:34

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 ?