I am trying to loopback the SPI bus on my STM32F0 (with a discovery board, MISO pin connected to MOSI pin).
I am following the tutorial Discovering the STM32 Microcontroller, (edition January 18, 2014), Exercise 6.1 : SPILoopback.
The STM32 is configured as the master.
To send a byte to MOSI pin, the author wrote :
SPI_I2S_SendData (SPIx, *tbuf++);
where :
- SPIx is the SPI bus I want to send data
- tbuf is the uint8 (in other words an unsigned char ...) I want to send on the bus
To receive this byte from MISO pin, he wrote :
while (SPI_I2S_GetFlagStatus (SPIx, SPI_I2S_FLAG_RXNE) == RESET);
if (rbuf)
{
*rbuf++ = SPI_I2S_ReceiveData(SPIx);
...
...
The flag SPI_I2S_FLAG_RXNE should be SET since I send a data to MOSI pin, and since MOSI pin is connected to MISO pin.
My problem is :
I never go out from the while loop (the SPI_I2S_FLAG_RXNE is never SET, even if I look through the debugger.
(I see CLK and MOSI being alive on my logic analyser, so I'm sure my byte goes out from an electrical point of view.)
It is like the STM32 never received the byte, even if MISO pin is connected on MOSI pin ...
Why ?