AnsweredAssumed Answered

Reading from SPI (Bidirectional one line)

Question asked by koc.talha on Jun 2, 2012
Latest reply on Jun 2, 2012 by Clive One
Hi all,

I'm trying to use the SPI interface of a TFT controller that uses only one line for write and read. I have the following problem:

1)First I set the SPI direction as Tx and write one byte data to the line, the clock is automatically generated.
2)Next, I use SPI_BiDirectionalLineConfig(SPI_Direction_Rx) to change direction.
3)But how am I going to read data from the same line, because the clock is not generated? Should I write something dummy to generate the clock? But the line is Rx now, and wouldn't it be meaningless to write in this mode? I really got stuck here.

Here is my setting for SPI:

  /* SPI configuration -------------------------------------------------------*/
  SPI_I2S_DeInit(SPI2);
  SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Tx;
  SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
  SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;
  SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;
  SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
  SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4;
  SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
 /* SPI_InitStructure.SPI_CRCPolynomial = 7;*/
  SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
  SPI_Init(SPI2, &SPI_InitStructure);

SPIOneline.PNG

Outcomes