cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F2xx SPI slave receive data problem

ho
Associate II
Posted on September 12, 2014 at 04:32

I have a STM32F2xx connected to FTDI UM232H using SPI communication, STM will configured as Slave and FTDI as Master, I will be using NVID

I have configured my SPI as below:

  1. 2 line duplex
  2. 1 Mhz clock
  3. MSB
  4. 8bit
  5. Phase = Low
  6. Polarity = Positive
  7. Hardware: 4 lines connection, CS, SCLK, MOSI, MISO
I have no problem sending data from STM to FTDI, I could read the data correctly.

But, the problem starts when I start to send data from FTDI to STM32, I could not read the data properly, I always get 0x00 when I called SPI_I2S_ReceiveData(SPI2);

I could see the signal from FTDI is correctly generated and I could get the interupt in my STM, but I cant get the data, always 0...

and when I configured the SPI as SPI_Direction_1Line_Rx, now I am getting 0xFF instead of 0...

Any idea what is wrong???

My SPI configuration:

SPI_InitTypeDef SPI_InitStructure;

SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;

SPI_InitStructure.SPI_Mode = SPI_Mode_Slave;

SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;

SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;

SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;

SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;

SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;

SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;

SPI_InitStructure.SPI_CRCPolynomial = 7;

SPI_Init(SPI2, &SPI_InitStructure);

1 REPLY 1
Posted on October 09, 2014 at 10:57

Hi ho.tim,

Just one question to more understand the issue you are experiencing:

when using the SPI Slave full duplex mode could you confirm that you check on RXNE before reading the data using SPI_I2S_ReceiveData(SPI2);  ??

Regards,

Heisenberg.