I'm using STM32F205's SPI1 in master mode. And the RXNE flag is never set during transactions. Here's a part of SPI initialization:
SPI1->CR1 = SPI_CR1_MSTR | SPI_CR1_SSI | SPI_CR1_SSM | SPI_CR1_SPE;
SPI1->CR2 = 0;
Then I'm trying to perform transmition/receiving of a single byte:
while(!(SPI1->SR & SPI_FLAG_TXE)) {} // wait for compeltion of the previous Tx
SPI1->DR = 0xAB; // transmit some byte
while(!(SPI1->SR & SPI_FLAG_RXNE)) {} // wait for byte to be received
uint8_t result = SPI1->DR;
This code stucks at the waiting for RXNE flag. I tried to wait for busy flag BSY = 0
instead of RXNE = 1
and SPI began to work. It seems RXNE is never set.
SPI_FLAG_TXE
and why don't you useSPI_SR_TXE
from the standard header? – Freddie Chopin#define SPI_FLAG_TXE SPI_SR_TXE
– Max