Question
STM32F407: SPI rx only mode - incorrect reading of the last bit in word.
Posted on October 14, 2015 at 21:12

Hi All,
I'm facing a strange problem with my STM32F407(Discovery board). While reading from SPI Data Register, sometimes the last bit is incorrect, which means result from my observation with logic analyzer is 0 while in SPI->DR there is 1 and vice versa. I don't think it's hardware issue as the problem is observed only for last bit in words. Values are read from ADC: LTC1408, but I think it doesn't matter now. SPI configuration:SPI_InitStructure_LTC.SPI_Mode = SPI_Mode_Master;
SPI_InitStructure_LTC.SPI_CPHA = SPI_CPHA_2Edge;
SPI_InitStructure_LTC.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStructure_LTC.SPI_CRCPolynomial = 1;
SPI_InitStructure_LTC.SPI_DataSize = SPI_DataSize_16b;
SPI_InitStructure_LTC.SPI_Direction = SPI_Direction_2Lines_RxOnly; // unidirectional MISO only pin
SPI_InitStructure_LTC.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure_LTC.SPI_NSS = SPI_NSS_Soft;
SPI_Init(LTC1408_SPI,&SPI_InitStructure_LTC); SPI is triggered with SysTick interrupt which enables SPI(clock) and toggles conv pin(needed for ADC).
SPI is serviced with interrupt handler, which part responsible for reading data is:
static uint16_t spi_ltc_results;
spi_ltc_results = SPI_I2S_ReceiveData(SPI1); Interrupt is not preempted during these operations.
Sample output from the logic analyzer(sample SPI->DR for the first word is 1100 1010 0011 100
0
:(
