How to clear the SPI RX FIFO (register mode)
Hi all,
I have an issue. I need to see the Slaves free space, for that, I am reading the slave's Empty space, and based on the results I send the data points which needed. but I am having a big issue. it always has a one execution cycle delay.
For example, if read empty spaces as 100, then code is sending 80 data plots which is regarded to the previous read. I am quite confused.
GPIOA->BSRR = GPIO_BSRR_BR4; //CS low
SPI1->DR = 0xF012; // Send read value command
while(!(SPI1->SR & SPI_SR_TXE)) {} // wait for TX end
RX_FIFO= SPI1->DR; // read the empty values in RX fifo
GPIOA->BSRR = GPIO_BSRR_BS4; // Cs high
*
*
*
GPIOA->BSRR = GPIO_BSRR_BR4; //CS low
// then send the data required according to RX_FIFO (for loop is used to send data)
GPIOA->BSRR = GPIO_BSRR_BS4; // Cs highThis happens in every 50KHz interrupt, I tried to keep an interval in between sending and receiving, but still the same problem if anyone go this issue. please help me. I think this might be due to masters Rx is not clearing up. Does anybody know how to clear the Masters Rx in register mode? I can't use HAL because it consumes a lot of time.
Thanks