2023-09-08 01:55 AM
STM32L4R9AII6 generates 16 SPI clock pulses when I have selected data size 8 in STM32CubeMX.
When I measure the SPI clock when I write a single byte to the SPI1 DR register it outputs 16 clocks.
When I debug I can look at the SPI1 registers. The CR2 DS bits = 7. According to the datasheet this is 8 bits. But when I measure there is 16 clocks when I write a single byte to the DR register.
If I change the DS bit to 3 it will output 8 bits.
What is going on?
Solved! Go to Solution.
2023-09-08 02:07 AM - edited 2023-09-08 02:16 AM
I solved it. This ST32 has a packed mode in the DR register. So one must be careful to write to it as an uint8_t pointer to send 8 bits.
Like this:
*((__IO uint8_t *)&hspi1.Instance->DR) = data[i];
2023-09-08 02:07 AM - edited 2023-09-08 02:16 AM
I solved it. This ST32 has a packed mode in the DR register. So one must be careful to write to it as an uint8_t pointer to send 8 bits.
Like this:
*((__IO uint8_t *)&hspi1.Instance->DR) = data[i];