Skip to main content
a b
Associate
January 22, 2018
Solved

STM32F303ZE Why is my SPI3 module transmitting 16-bits

  • January 22, 2018
  • 4 replies
  • 945 views
Posted on January 22, 2018 at 16:44

I have my SPI3 module configured as a master.  I want it to transmit 8-bit words.  Here is my setup as read from the chip while its executing.  No matter what I do each time I write to SPI3->DR it transmits 16-bits what can I do?  Please don't give any answers involving the HAL libraries as I am not able to use it.

0690X00000609PjQAI.png

Thanks

#stm32f-spi
This topic has been closed for replies.
Best answer by Tesla DeLorean
Posted on January 22, 2018 at 17:22

*((volatile uint8_t *)&SPI1->DR) = 0xAA; // volatile will be safer from the compiler folding the write

4 replies

Tesla DeLorean
Guru
January 22, 2018
Posted on January 22, 2018 at 17:21

Write to the register with an appropriate cast so the bus transaction has the right width.

*((uint8_t *)&SPI1->DR) = 0xAA;

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
January 22, 2018
Posted on January 22, 2018 at 17:22

*((volatile uint8_t *)&SPI1->DR) = 0xAA; // volatile will be safer from the compiler folding the write

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
waclawek.jan
Super User
January 22, 2018
Posted on January 22, 2018 at 17:29

And the explanation is under Data packing subchapter in the SPI chapter of RM.

JW