2012-06-01 08:01 PM
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); stm32f4-spi2012-06-02 07:48 AM
The use of throwaway writes on SPI buses is quite common, the fact the signal goes nowhere, or the device ignores it makes no difference, the purpose is to generate a clock.