Skip to main content
Visitor II
October 6, 2023
Question

Number of SPI clock cycles changes when below 1Mhz

  • October 6, 2023
  • 1 reply
  • 1135 views

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?

    This topic has been closed for replies.

    1 reply

    Super User
    October 8, 2023

    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.