STM32 & KS0108 LCD Integration: Proteus Simulation

by Marwen Maghrebi

Things used in this project

Software apps and online services:

1- STMicroelectronics STM32CubeMX

2- STMicroelectronics STM32CubeIDE

3- Proteus 8

Empowering STM32 Projects with KS0108 Graphical LCD Integration 

This project aims to leverage the STM32 microcontroller’s GPIO capabilities to interface with a Graphical LCD based on the KS0108 controller. By utilizing GPIO pins for data transmission and control, we seek to create a robust and versatile display solution for various STM32-based applications. The goal is to enable seamless communication between the microcontroller and the LCD, facilitating the display of graphics and text with high resolution and clarity.

Overview of KS0108 Graphical LCDs:

Graphical LCDs utilizing the KS0108 controller are prevalent in the realm of display technology. These LCDs boast internal memory of 512 bytes, facilitating resolutions of up to 64×64 pixels. Larger displays often employ multiple controllers, with each one handling a fraction of the screen’s area. For instance, a 128×64 LCD typically incorporates two controllers, while a 128×128 display would employ four.

Each controller operates independently and is activated using two control lines: CS1 and CS2 (chip select), functioning as a 2-bit address selector for up to four ICs. Notably, these controllers lack an internal font generator, necessitating the storage of glyph pixel data by the driving device, such as a microcontroller’s Flash memory or an external memory module.

Pin Description and Functionality:

  • VSS: Ground reference (0V)
  • VDD: Supply voltage for the LCD (5V)
  • V0: Contrast adjustment
  • D/I: Selects between Data (1) or Instruction (0)
  • R/W: Selects between reading (1) or writing (0) the controller
  • E: Initiates data transfer upon pulse application
  • DB0..7: Data bus (8-bit bus)
  • CS1..2: Controller selection lines
  • RES: Reset signal; resets all controllers when set to 0
  • Vee: Negative voltage OUTPUT
  • K and A: Backlight, typically LEDs

Sending Commands and Data to the LCD:

Sending commands or data to the LCD involves several steps, including activating the desired controller, setting the D/I line according to the type of data being sent, placing the data on the data bus, and applying a pulse to the E line. The display is divided into 8 horizontal pages and 64 vertical lines/columns.

To start this project, we will first configure the GPIO pins of the STM32 microcontroller to establish communication with the KS0108-based graphical LCD. This involves setting up the necessary GPIO pins for data transmission, control signals, and any additional functionalities required by the LCD.

STM32CubeMX Configuration:

  • Open CubeMX & Create New Project Choose The Target MCU STM32F103C6 & Double-Click Its Name
  • Go To The Clock Configuration & Set The System Clock To 16MHz

Configuration for the GPIO Mode:

  • Configure The GPIO Pin [PA0 .. PA7] as Output Pin (D0 ,D1 , D2 , D3 , D4 , D5 , D6 , D7)
  • Configure The GPIO Pin [PB8.. PB13] as Output Pin (DI ,RW , EN , CS1 , CS2 , RS )

STM32CubeIDE Configuration :

  • Write The Application Layer Code
  • KS0108.h & KS0108.c
  • IO_Macros.h
  • Fonts11x13.h 
  • Fonts27x28.h 
  • main.c

Proteus Configuration :

  • Open Proteus & Create New Project and click next

  • Click on Pick Device
  • Search for STM32F103C6 & LGM12641BS1R
  • Click on Terminal Mode then choose (DEFAULT & POWER & GROUND)
  • finally make the circuit below and start the simulation

That’s all!

If you have any questions or suggestions don’t hesitate to leave a comment below.

You Might Also Like

Leave a Comment


Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?
-
00:00
00:00
Update Required Flash plugin
-
00:00
00:00