2015-10-14 12:12 PM
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
:(2015-10-14 02:31 PM
What speed are the output pins set to?
https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2FStrange%20reading%20over%20SPI&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=1482015-10-14 11:39 PM
Hi,
divider is 256, so speed is 84MHz/256.2015-10-15 12:09 AM
No, I mean the pins drive/slew rate, i.e. GPIOx_OSPEEDR setting.
JW2015-10-16 12:08 PM