2015-10-11 04:55 PM
Hi,
I am trying a very simple thing: I would like to read a register of a sensor. So the first thing I did is to write the read-register (8 bit) to the sensor. After that the DR register has been filled with dummy data (the data which was on the MISO line while sending the read-register, 0x000000ff). Next thing is sending dummy data (8 bit) for getting the contents of the sensor. Now the DR register contains 0x00003fff. For me its not really clear how to read the DR register for clearing its data and to make it free for the next reception. When is the DR register (containing the data of the RX fifo) cleared? thanks a lot!2015-10-11 05:20 PM
What STM32 part are we talking about?
For each byte you want to receive you have to send a byte out, the SPI is symmetrical in that regard to generating clock pulses. Each time you read the SPIx->DR it clears the RXNE bit. You have to write SPIx->DR to send another dummy byte.2015-10-14 09:23 AM
Hi,
I am using the STM32F0. I wonder why the first reception (while sending the read register the STM is already reading the MISO line) will not be cleared after reading DR. While I was debugging I saw the DR register, it contains 0xff after the sending the read register. Some steps further it contains 0x0. After sending the next dummybyte for the reception of the register, the contains 0x3fff. 0x3f is the 8 bit read value of the register. Is it common that the DR register contains a 16 bit value after reading a 8 bit value?