2020-11-02 02:30 AM
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:
Solved! Go to Solution.
2020-11-02 03:30 AM
2020-11-02 03:30 AM