STM32F407: SPI rx only mode - incorrect reading of the last bit in word.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-10-14 12:12 PM
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
:(
This discussion is locked. Please start a new topic to ask your question.
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-10-14 2:31 PM
Posted on October 14, 2015 at 23:31
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=148Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-10-14 11:39 PM
Posted on October 15, 2015 at 08:39
Hi,
divider is 256, so speed is 84MHz/256.Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-10-15 12:09 AM
Posted on October 15, 2015 at 09:09
No, I mean the pins drive/slew rate, i.e. GPIOx_OSPEEDR setting.
JWOptions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-10-16 12:08 PM
Posted on October 16, 2015 at 21:08There was 2MHz, 25MHz results with correct values, thank You very much.
