STM32F103C8T6 with u8g2 library problem

Post here all questions related to LibMaple core if you can't find a relevant section!
Post Reply
Posts: 2
Joined: Sun Nov 06, 2022 12:10 am

STM32F103C8T6 with u8g2 library problem

Post by gabrielwong1991 »

Hi I have an SSD1322 LCD panel that has a 4-pin SPI connection.

The panel works fine with Arduino UNO under Hardware and Software SPI mode. In the FPS test that comes with U8G2 example library, it scores 13 fps which is normal.

Note I am using this board manager
However, i have recently got a genuine C8T6 and plugged it with the following standard configuration:

Code: Select all

It displays okay in Software SPI mode but the FPS is incredibly slow - only 1.4 fps. I am surprised that the STM32 which has a higher CPU clock speed than Arduino UNO.

Code: Select all

U8G2_SSD1322_NHD_256X64_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ PA5, /* data=*/ PA7, /* cs=*/ PA4, /* dc=*/ PB0, /* reset=*/ PB1);
So I investigate further to understand whether it is due to page buffer vs full buffer. Turns out FPS is the same.

Then I try it with hardware SPI mode but turns out it just won't show anything and U8G2 constructor does not allow assigning the clock, data pin.

Code: Select all

U8G2_SSD1325_NHD_128X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ PA4, /* dc=*/ PB0, /* reset=*/ PB1);
So here are two questions. Is there anywhere I could define the clock and data pin with hardware mode?
What is the reason for such a slow speed with STM32? Could that be the SPI link speed that I shall need to define?

A related problem here in this forum but it seems like it never gets solved...

Thanks you all for your help!
Posts: 44
Joined: Thu Dec 19, 2019 3:27 pm
Answers: 1

Re: STM32F103C8T6 with u8g2 library problem

Post by hobbya »

Not sure if the core you used was up to date. You can install the up to date version below:

Roger's original core: or
A fork of Roger's and is more frequently maintained:

When picking options in the u8g2 library always choose "HW SPI". For example:
U8X8_SSD1306_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ PA4, /* dc=*/ PB0, /* reset=*/ PB1);
U8G2_SSD1306_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ PA4, /* dc=*/ PB0, /* reset=*/ PB1);

If you choose "SW SPI" the clock rate will drop to a very low value. For native hardware SPI you do not need to specify MOSI and SCLK.
Post Reply

Return to “General discussion”