cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4R9AII6 generates 16 SPI clock pulses when I have selected data size 8 in STM32CubeMX.

MSipo
Senior II

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?

1 ACCEPTED SOLUTION

Accepted Solutions
MSipo
Senior II

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];

 

View solution in original post

1 REPLY 1
MSipo
Senior II

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];