cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F051r8t6 SPI initialization issue

fifi_22
Associate III

Hello.

I'm trying to use SPI interface in STM32F051r8t6 micro on my STM32F0 discovery board. I got it to send data, but I set data lenght to 8bit, it is sending double that (first 8 is my data, but second 8 bit is always 0x00). When I set it to 4-bit, it sends 8bits (first 4 is my data and second 4 is 0x0). What I'm missing? Is that something with CRC?

SPI1->CR1 &= ~((SPI_CR1_CPHA) | (SPI_CR1_CPOL) | (SPI_CR1_CRCEN));						//set phase and polarity to 0
	SPI1->CR1 |= (SPI_CR1_MSTR) | (SPI_CR1_BR_1) | (SPI_CR1_SSM ) | (SPI_CR1_SSI);			//set spi to master and clock to /8 and software slave to 1
 
	SPI1->CR2 = (SPI1->CR2 & (~SPI_CR2_DS)) | (SPI_CR2_DS_2) | (SPI_CR2_DS_1) | (SPI_CR2_DS_0); 	//spi 8-bit
	SPI1->CR1 |= (SPI_CR1_SPE);																//turn on spi
 
	SPI1->DR = 0xaa;

at 8 bit selected:0693W000005A1GZQA0.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
1 REPLY 1
fifi_22
Associate III