Skip to main content
a b
Associate
Jan 22, 2018 3:44 PM UTC
Solved

STM32F303ZE Why is my SPI3 module transmitting 16-bits

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.
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
Jan 22, 2018 5:22 PM UTC
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..

4 replies

Tesla DeLorean
Guru
Jan 22, 2018 4:21 PM UTC
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
Jan 22, 2018 5:22 PM UTC
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
Jan 22, 2018 5:29 PM UTC
Posted on January 22, 2018 at 17:29

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

JW