This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

STM32F407 - Flag RXNE of SPI is clear when i read. Sometimes is stack in waiting the flag.

Hi, i using SPI for communicating Transmiting and Receiving with STM32F407. My routine for transmit:

void spi_transmit(uint8_t DataX)
{
//Envio
while(!(SPI_TFT->SR & SPI_SR_TXE));
SPI_TFT->DR = DataX;

while(!(SPI_TFT->SR & SPI_SR_RXNE));
SPI_TFT->DR;

//
while(SPI_TFT->SR & SPI_SR_BSY);

return;
}

My problem is that in normal function, arbitrary the program counter is stack in the waiting of flag SPI_SR_RXNE=1. If i debug step by step, when i read SPI_SR_RXNE, it clears and never continue. Why is that? i cant understand.