AnsweredAssumed Answered

STM32F2xx SPI slave receive data problem

Question asked by ice111 on Sep 12, 2014
Latest reply on Oct 9, 2014 by Montassar BEN ROMDHANE
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.    
  3. 1 Mhz clock
  4.    
  5. MSB
  6.    
  7. 8bit
  8.    
  9. Phase = Low
  10.    
  11. Polarity = Positive
  12.    
  13. 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);

Outcomes