cancel
Showing results for 
Search instead for 
Did you mean: 

Number of SPI clock cycles changes when below 1Mhz

m1ng
Associate

Hi, I find that the number of SPI clock cycles change when I set the SPI clock speed below 1Mhz. 

When SPI Clock > 1 Mhz, the SPI clocks out 8 cycles 4 times, as expected. ( I am sending 4 bytes of data)Screenshot 2023-10-06 115402.pngWhen the SPI Clock < 1Mhz, the SPI clocks out 32 cycles despite transmitting only 4 bytes of data in the HAL function call.

Screenshot 2023-10-06 114848.png

What is the reason for the number of clock cycles to change despite only changing the SPI clock speed in the cubemx tool?

1 REPLY 1
TDK
Guru

Increase the sampling rate on your logic analyzer to accommodate the higher data rate. If your logic analyzer isn't fast enough, you'll need to decrease the SPI clock speed to an appropriate level.

As for why it's sending 32 clock instead of 8: most likely due to a bug in the code or a misinterpretation of what it should be doing. Show your code or follow SPI examples given in CubeMX repository.

If you feel a post has answered your question, please click "Accept as Solution".