cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F303ZE Why is my SPI3 module transmitting 16-bits

a b
Associate
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
1 ACCEPTED SOLUTION

Accepted Solutions
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
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

4 REPLIES 4
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
Up vote any posts that you find helpful, it shows what's working..
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
Up vote any posts that you find helpful, it shows what's working..
Posted on January 22, 2018 at 17:29

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

JW

Posted on January 22, 2018 at 17:32

Thanks Clive, works great now.