2016-01-08 08:15 AM
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.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.2016-01-08 08:28 AM
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
2016-01-08 05:59 PM
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;Sentence:*((uint8_t *)&SPI1->DR) = 0XFF ;Do you have any idea?Thanks again.2016-01-08 06:08 PM
STR (Word) vs STRB (Byte)
2016-01-09 05:12 PM
Thank you Clivel. You are nice.