cancel
Showing results for 
Search instead for 
Did you mean: 

STM32f0 SPI trouble

zhoupn138
Associate
Posted on February 24, 2013 at 02:04

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>

SPI1 SPI2

CSN PA4 PB12

SCK PA5 PB13

MOSI PA7 PB15

MISO PA6 PB14

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.  

#stm32f0-spi
0 REPLIES 0