Skip to main content
mcufan
Associate II
July 19, 2019
Solved

stm32f411 spi4 low clock speed

  • July 19, 2019
  • 15 replies
  • 4288 views

Hello!

I have problem with spi4 clock speed. I want to drive a lcd tft display but spi clock is max 500Khz, baudrate prescaler set to SPI_BAUDRATEPRESCALER_2. Is very weird. Initial setup was made with CubeMX to 48Mbit/s. APB2 clock is set to 96Mhz. I tried with dma, and without hal but the speed remains the same

What is the cause of this very low spi clock output speed?

This topic has been closed for replies.
Best answer by waclawek.jan

As you can see, although PLL is switched on in CR, PLLCFGR is at its default value; nonetheless your system clock is set to HSI in CFGR, and both APB dividers are set to 16 (maximum).

In other words, you don't run the SystemClock_Config() function as you've presented us above. Find out, how do you actually set the clocks.

JW

15 replies

S.Ma
Principal
July 20, 2019

You can even make spi by gpio at such speed to test the display functionality, then tune with spi hw peripherals

waclawek.jan
waclawek.janBest answer
Super User
July 20, 2019

As you can see, although PLL is switched on in CR, PLLCFGR is at its default value; nonetheless your system clock is set to HSI in CFGR, and both APB dividers are set to 16 (maximum).

In other words, you don't run the SystemClock_Config() function as you've presented us above. Find out, how do you actually set the clocks.

JW

Tesla DeLorean
Guru
July 20, 2019

Something nominal in SystemInit() would be my guess

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
mcufan
mcufanAuthor
Associate II
July 20, 2019

Yes, you are right! I will try to setup the clock somehow.

Thank you!

mcufan
mcufanAuthor
Associate II
July 20, 2019

Yess! done:) thank you for all. Clive, i set up in the SystemInit() the RCC_CFGR and RCC_PLLCFGR without calling the SystemClock_Config() and now spi is fast as hell:D

mcufan
mcufanAuthor
Associate II
July 20, 2019

The only mistake was that when i created the code with CubeMX in the RCC setup the HSE selected value was BYPASS Clock Source and not Chrystal/Ceramic Resonator