AnsweredAssumed Answered

STM32f0 SPI trouble

Question asked by zhou.peng on Feb 24, 2013
I am using the stm32f0 discovery board and having trouble getting SPI to talk properly with an external SPI sensor. As a test case, I wrote a small program to send bytes from SPI1 to SPI2 and then compare these sent and received values to see if they are the same.

Here is the setup: SPI1 is the master and SPI2 is the slave. Here are the pins I used and how the pins are connected:

    </colgroup>                                                                                                                                                                                                                                                                            
Right before and after a byte was sent from SPI1 to SPI2, I dump out the status register of both SPI1 and SPI2. Here is the output:

SPI1 registers:
SPI_I2S_FLAG_TXE = 1
SPI_I2S_FLAG_RXNE = 1
SPI_I2S_FLAG_BSY = 0
SPI_I2S_FLAG_OVR = 0
SPI_I2S_FLAG_FRE = 0
I2S_FLAG_UDR = 0
I2S_FLAG_CHSIDE = 0
SPI_TransmissionFIFOStatus_Empty = false
SPI_TransmissionFIFOStatus_1QuarterFull = false
SPI_TransmissionFIFOStatus_HalfFull = false
SPI_TransmissionFIFOStatus_Full = false
SPI_ReceptionFIFOStatus_Empty = false
SPI_ReceptionFIFOStatus_1QuarterFull = false
SPI_ReceptionFIFOStatus_HalfFull = true
SPI_ReceptionFIFOStatus_Full = true

SPI2 registers:
SPI_I2S_FLAG_TXE = 1
SPI_I2S_FLAG_RXNE = 0
SPI_I2S_FLAG_BSY = 0
SPI_I2S_FLAG_OVR = 0
SPI_I2S_FLAG_FRE = 0
I2S_FLAG_UDR = 0
I2S_FLAG_CHSIDE = 0
SPI_TransmissionFIFOStatus_Empty = false
SPI_TransmissionFIFOStatus_1QuarterFull = false
SPI_TransmissionFIFOStatus_HalfFull = false
SPI_TransmissionFIFOStatus_Full = false
SPI_ReceptionFIFOStatus_Empty = false
SPI_ReceptionFIFOStatus_1QuarterFull = false
SPI_ReceptionFIFOStatus_HalfFull = false
SPI_ReceptionFIFOStatus_Full = false

I am expecting that both SPI1 and SPI2 would have its RXNE set. From the output, it is clear that SPI1 indeed has data in its RX FIFO, but not SPI2. Indeed, the code was stuck while waiting to see if it can from SPI2 for the sent data.

So, was there any communication between SPI1 and SPI2 or not? Does anyone know what I have done wrong? Any help is much appreciated.
 
SPI1SPI2
CSNPA4PB12
SCKPA5PB13
MOSIPA7PB15
MISOPA6PB14

Attachments

Outcomes