cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F407: SPI rx only mode - incorrect reading of the last bit in word.

krzysztofrybak6
Associate II
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

:( 0690X00000605JIQAY.png
4 REPLIES 4
krzysztofrybak6
Associate II
Posted on October 15, 2015 at 08:39

Hi,

divider is 256, so speed is 84MHz/256.

Posted on October 15, 2015 at 09:09

No, I mean the pins drive/slew rate, i.e. GPIOx_OSPEEDR setting.

JW
krzysztofrybak6
Associate II
Posted on October 16, 2015 at 21:08

There was 2MHz, 25MHz results with correct values, thank You very much.