This project demonstrates how to interface a 128Γ64 SSD1306 OLED display with an STM32F103C6 microcontroller using the SPI protocol. The SSD1306 is a popular choice for compact and low-power displays, providing flexibility to render text, graphics, and animations.
Compared to character LCDs, OLED displays are:
- Compact β perfect for portable and wearable applications (e.g., smartwatches)
- Aesthetic β clear text and smooth graphics
- Cost-effective β more affordable than graphic LCDs while offering better features
This project covers hardware setup, SPI configuration, and basic graphics rendering. Simulation is performed in Proteus 8.
STM32CubeMX Setup- MCU Selection: STM32F103C6 (8 MHz system clock)
- SPI1 Configuration
- Mode: Transmit Only Master
- Prescaler: 8 (SPI baud rate β 4 Mbps)
- Data Size: 8 bits
- GPIO Configuration
- PA3 β DC (Data/Command select) β Output Push-Pull
- PA4 β CS (Chip Select) β Output Push-Pull
- PA5 β SCK (SPI Clock) β Alternate Function Push-Pull
- PA7 β MOSI (SPI Data) β Alternate Function Push-Pull
- Generate project and open in STM32CubeIDE
Key Files
- oled.c / oled.h
- SSD1306_Init() β Initialize display
- SSD1306_WriteString() β Display text
- SSD1306_DrawLine() β Render simple graphics
- fonts.c / fonts.h
- Store font data (e.g., 8Γ6, 12Γ6 pixel fonts)
- main.c
- Call SSD1306_Init() after HAL initialization
- Example:
SSD1306_Clear();
SSD1306_WriteString("Hello, OLED!", Font_11x18, White);
SSD1306_UpdateScreen();Required Components
- STM32F103C6
- SSD1306 OLED (SPI)
- Power (VCC, GND)
Connections
- PA5 β SCK
- PA7 β MOSI
- PA4 β CS
- PA3 β DC
- VCC, GND β Power supply
Steps
- Load the compiled .hex file into STM32
- Run simulation in Proteus
- Observe βHello, OLED!β message and graphics on the SSD1306 display
If you have any questions or suggestions don't hesitate to leave a comment below





Comments