Problem with STM32F103C8 and SPI OLED with U8g2 lib

Post here first, or if you can't find a relevant section!
Post Reply
saeed144
Posts: 36
Joined: Mon Sep 21, 2020 10:11 am

Problem with STM32F103C8 and SPI OLED with U8g2 lib

Post by saeed144 »

Hi
I have problem with stm32.
Nothing show on OLED

Code: Select all

#include <Arduino.h>
#include <U8g2lib.h>

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif

/*
U8g2lib Example Overview:
Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption
Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards.
U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only.

/
U8G2_SSD1306_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, / cs=/ PB8, / dc=/ PB7, / reset=*/ PB6);

void setup(void) {
u8g2.begin();
}

void loop(void) {
u8g2.clearBuffer(); // clear the internal memory
u8g2.setFont(u8g2_font_ncenB08_tr); // choose a suitable font
u8g2.drawStr(0,10,"Hello World!"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
}
this code worke well with arduino uno, I think problem is the pins.

p.s. I checked that code with u8g2.firstpae() and do while , still same problem
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Problem with STM32F103C8 and SPI OLED with U8g2 lib

Post by ag123 »

you did not mention the (stm32duino) core you are using, and
did you define U8X8_HAVE_HW_SPI or U8X8_HAVE_HW_I2C ?
otherwise the macros are simply not defined

normally such are the pins for SPI1 on stm32f103

Code: Select all

#define TFT_CLK		PA5
#define TFT_MISO	PA6
#define TFT_MOSI	PA7
and your calls to initialize the other lcd control pins looks strange in the syntax, they seemed to be commented off
Last edited by ag123 on Sat Mar 06, 2021 8:10 am, edited 2 times in total.
mlundin
Posts: 94
Joined: Wed Nov 04, 2020 1:20 pm
Answers: 6
Location: Sweden

Re: Problem with STM32F103C8 and SPI OLED with U8g2 lib

Post by mlundin »

How is the display connected to the SM32, what pins ?
What core are you using, what board and variant selection ?
alisadri5890
Posts: 1
Joined: Wed Jan 19, 2022 8:03 am

Re: Problem with STM32F103C8 and SPI OLED with U8g2 lib

Post by alisadri5890 »

i have same problem
any idea?
Post Reply

Return to “General discussion”