Why F030C8 SPI performes like this? ''Data packing“ problem
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2016-01-08 8:15 AM
Posted on January 08, 2016 at 17:15
Is the sentence ''SPI1->DR = 0XFF;'' a kind of ''16-bit access of SPIx_DR''?When I replaced 0XFF with a uint8_t variable the waveform didn't change at all.I also changed the optimization level to -O0, but it had no effect.''Data packing'' is too inconvenient to communicate with some devices,like nRF24L01. Can anyone tell me how to read/write SPIx_DR in a 8-bit way like it is in F1xx series? Thanks.
IDE environment: KEIL v5.14 + CubeMX v4.12 + CubeF0 v1.4
Chip type:F030C8T6Debugger:ST-LINK VIIWhen I use SPI in polling mode, i found a weird thing. I have never met this before when I were using F1xx series chips.The date size is set to 8-bit long and MSB first (SPIx_CR1=0x36C,SPIx_CR2=0x1700).Here is the main code.while(1){ SPI1->DR = 0XFF; while(SPI1->SR & SPI_SR_BSY); while(!(SPI1->SR & SPI_SR_RXNE)); temp = SPI1->DR;}This is the corresponding waveform.
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2016-01-08 8:28 AM
Posted on January 08, 2016 at 17:28
Is the sentence ''SPI1->DR = 0XFF;'' a kind of ''16-bit access of SPIx_DR''?
What's the structure define it as being? Because it will use that to determine it.Can anyone tell me how to read/write SPIx_DR in a 8-bit way like it is in F1xx series?*((uint8_t *)&SPI1->DR) = 0xFF; // simple casting
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2016-01-08 5:59 PM
Posted on January 09, 2016 at 02:59
Sentence:*((uint8_t *)&SPI1->DR) = 0XFF ;
Do you have any idea?Thanks again.
Hi clivel,
Thank you for your advise, it works!I also try to change the define of DR in the structure to uint8_t, it has the same effect. :DBut I am still confused why ?SPI1->DR = 0XFF;? and ''*((uint8_t *)&SPI1->DR) = 0XFF ;'' show up in the same assembly statement.Sentence:SPI1->DR = 0XFF;Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2016-01-08 6:08 PM
Posted on January 09, 2016 at 03:08
STR (Word) vs STRB (Byte)
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2016-01-09 5:12 PM
Posted on January 10, 2016 at 02:12
Thank you Clivel. You are nice.
