cancel
Showing results for 
Search instead for 
Did you mean: 

SPI TXE or RXNE never goes to 1

Ebun.1
Senior

hello

I am using an STM32F7 series microcomputer.

with SPI peripherals

If writeable, write to the data register,

After that, if it is readable, it is reading from the data register.

The image in the code is like below,

Writeable, readable loops infinitely until it becomes possible.

These are checking his TXE, RXNE in the status register.

while (!writeable());

write();

while (!readable());

read();

After running for a while, I end up in an infinite loop on one of these.

Please tell me the reason why TXE is not 1.

What is the reason why RXNE does not become 1?

Thank you.

4 REPLIES 4
S.Ma
Principal

I assume (lack of details to provide detailed answer) that we have need here for SPI Master in 4 wire (NSS, MOSI, MISO, SCK).

In this case, Transmit AND Receive are happening at the same time.

The SPI Clocks depends on what you transmit.

The SPI finish the data exchange when RXNE is set.

You only need TXE to know when you can write in the DR register. It does not tell you that SPI is done transmitting.

Focus on RNXE and think "ReceiveTransmit" instead of "Transmit then Receive".

SPI is different than UART.

gbm
Lead III

Probably you configured the SPI incorrectly. Or maybe you set SPI to 8-bit frames but you read and write data in not as 8-bit - a common mistake with STM32 SPI. No code shown == no help possible.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice

yes. I am using STM32 as SPI master.

It is a 4-wire system of NSS, MOSI, MISO, and CLK.

Try a little more thought.

Thank you for your response.

yes. I am using STM32 as SPI master.

It is a 4-wire system of NSS, MOSI, MISO, and CLK.

Try a little more thought.

Thank you for your response.