SPI clock frequency (with ST7735 lib) on MBED os v5


Sorry if my request seems stupid but I may turn the problem in all directions, I can not find the solution.

I use the st7735 adafruit library with mbed v2 for a long time without problem. Unfortunately I will have to switch to v5 because it better controls threads and I will use the wav_player lib in parallel with my screen.

the problem that I meet is that mbed (in v5) seems to ignore my frequency request (blocked at 1 MHz). In v2, everything is fine, the images stored in flash as well as the possible text, are displayed very quickly. But in v5, I stay at 1 MHz. No way to speed up the display (without using the threads for the moment). the text is slow to display (1 to 2s for the whole screen against an instant display in v2).

Anyone have a solution to bring me?

thank you in advance


Have you try set different values for SPI clock? Something like

I try with K64F board and it worked.



I trying Mbed Studio Beta to port a sketch from Arduino to a Núcleo-F103RB board.

I’m using ST7735 display and I noticed ( compared to a 8mhz Arduino AVR) the SPI is performing slow.

I tried prior Mbed versions with no luck, currently 5.15.1

So I decided to try VSCode’s stm32 platform with mbed framework and it is performing fast. Same code. Same board.

Looks like the frequency is locked at 1Mhz!

I decided to investigate and the SPI::frequency on the SPI.cpp is not working because I hardcoded a 4Mhz spi frequency directly.

Even the 4Mhz is not enough the display can handle 16Mhz.

How is possible to change the frequency?

What do you mean by that? Can you share links to the resources?

Regarding the SPI frequency, you’ll find the answer here:


You can get as high as 36 MHz, but make sure you’re using the right SPI.

thank for multi replies,
my problem is not solve at this time, so I work with mbed2 for now.

I have tested with all frequency from 1mhz to 64mhz and my screen still lazy (juste with mbed v5, with v2 all is fine).

can you share your code? it’s hard to help without knowing much…


no problem. For information, my board is mbed lxp1768. I use the online compiler.


sorry, a publish the entire source code with the original lib ST7735. So I republish with a simple folder…

Looks like ST7735::commonInit(uint8_t *cmdList) defines SPI frequency. Are you setting frequency in there?


on line 250 of the ST7725.cpp. from 1Mhz to 64Mhz… no visual change. the spi seem to stay a 1Mhz (with mbed v5 only… mbed v2 work fine).

I thought the max SPI freq of lxp1768 was 48MHz. Try 10Mhz or something and see if it makes any difference.

also tested… not work

Are you using a scope or logic analyzer to verify the actual frequency?

Hi there,

You use same code with MbedOS5 on MbedOS2?

Maybe it is not relevant but it will be the second frequency setting accepted by SPI interface, when it is already set 1Mhz? I see you have a SD card and the TFT on the same SPI and both objects are initialized with different frequency.

BR, Jan

yes it’s the same main code.

only the lib for use the sdcard is different : in v5, the lib is include with the os and I can’t set the spi frequency, or Iif I can, I don’t set it and I let it with default value.

so in v5 , I only set the frequency one time in st7735 lib …

for information, with the v2 code, yes, I have setting the frequency two time (in st77365 lib and in SDFileSystem lib) … and it’s work any way…

You can get as high as 36 MHz, but make sure you’re using the right SPI.

Captura de ecrã 2020-04-09, às 15.27.02
All seems to be ok.

The main.cpp:

The libs are:

The board is:

  • Nucleo-F103RB

I tried set the frequency ex: lcdPort.frequency(12000000); directly in the lib, which is working because I can set a very low frequency and it works, but it seems to be capped to 1Mhz or so.

edit: I forgot to say I tried on vscode also the generic stm32F103c8t6 with Mbed /Vscode and the spi is faster too:


F103RB Mbed Mbed Studio -> slow
F103RB Mbed VSCode -> fast
F103C8 MBed VSCode ->fast

I think I’m using the default port, at least on the board we can read MOSI/MISO/SCLK etc…

Are you using a scope or logic analyzer to verify the actual frequency?

Ok, Now the things get weird…

:tv:Oscilloscope test:
:white_check_mark: SCLK is working at the correct frequency I set up! (I tested 1Mhz 4Mhz 12Mhz )

How this is possible SCLK is Ok but display is slow?!

This is what I get compiled on Mbed Studio
setFrequency(x)     |      SCLK 
1MHz                      562KHz
2MHz                      1.125MHz
4MHz                      2.25 MHz
8MHz                      4.49MHz
16MHz                     9MHz
32MHz                     18MHz

I think I found the problem, well partial problem. The delay between instructions is big on Mbed Studio.

You’re table is correct and the same as the one I provided in ST’s wiki.

The bug seems to be coming from Mbed Studio.

The global output of compilation could help us.