Page 1 of 1

Problem with STM32F103C8 and SPI OLED with U8g2 lib

Posted: Sat Mar 06, 2021 7:53 am
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

Re: Problem with STM32F103C8 and SPI OLED with U8g2 lib

Posted: Sat Mar 06, 2021 8:00 am
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

Re: Problem with STM32F103C8 and SPI OLED with U8g2 lib

Posted: Sat Mar 06, 2021 8:02 am
by mlundin
How is the display connected to the SM32, what pins ?
What core are you using, what board and variant selection ?

Re: Problem with STM32F103C8 and SPI OLED with U8g2 lib

Posted: Wed Jan 19, 2022 8:10 am
by alisadri5890
i have same problem
any idea?