Interface and Programming of SPCE061A and LCD Module HS12864-1

1 Introduction

In embedded measurement and control systems centered around microcontrollers, the interface between the microcontroller and display devices is an essential link. This involves selecting the type of display device, determining whether to use serial or parallel interfaces, and establishing the display driver, among other issues. A typical display device is the LED digital tube, which has high brightness and is suitable for most applications. However, its disadvantages include complex interface circuitry and high power consumption. LCD display devices utilize the electro-optical effect of liquid crystals, offering advantages such as low power consumption and convenient interface control [1]. Moreover, the module’s interface signals and operation commands are widely compatible and can directly interface with microcontrollers. It also includes dedicated commands for various operations, and the power consumption of an LCD with the same display area is hundreds of times smaller than that of an LED display, making it particularly suitable for direct integration with CMOS circuits. LCD display devices have become one of the most important information processing means in the contemporary high-tech industry (information industry) and are widely used in various measurement and control instruments.

LCD display devices can be classified into segment type, character type, and dot matrix type. Among them, dot matrix LCDs can display characters, numbers, as well as various graphics, curves, and Chinese characters. They can also implement dynamic display functions such as window opening, inversion, and flashing. When displaying Chinese characters on a dot matrix LCD, it is necessary to first obtain the dot matrix data of the characters and then write it into the display memory of the dot matrix LCD for display. This article introduces the LCD display control design based on the Sunplus SPCE061A microcontroller.

2 Working Principle of HS12864-1 LCD Module

HS12864-1 is a graphic dot matrix LCD that mainly consists of row and column drivers and a 128×64 full dot matrix LCD. It can achieve graphic display and can also display 8×4 (16×16 dot matrix) Chinese characters. The HS12864-1 LCD integrates the HD61102 graphic LCD display module, where the driving and control system is composed of one HD61102 as a 64-line row driver. The HD61102 is equipped with a management circuit for the display memory and an interface circuit with the MCU, allowing direct connection to the MCU’s bus [5]. The structure of HS12864-1 is shown in Figure 1.

Interface and Programming of SPCE061A and LCD Module HS12864-1

Figure 1 Structure of HS12864-1

HS12864-1 has a simple yet powerful instruction set that can achieve functions such as character movement and flashing display. It has a total of 7 instructions, and the microcontroller can display specified content or display modes simply by sending data or instructions through D/I, R/W, DB0~DB7. Table 1 lists the instructions for HS12864-1.

Table 1 HS12864-1 Instruction List

Interface and Programming of SPCE061A and LCD Module HS12864-1

3 Hardware Interface Design of HS12864-1 and SPCE061A Microcontroller

SPCE061A is another 16-bit microcontroller launched by Sunplus Technology after the SPCE500A series. The CPU core uses Sunplus’s latest 16-bit u nsp microprocessor chip, which has a higher integration level compared to the MCS-51 8-bit MCU, making it more flexible and convenient to use, thus shortening the development cycle and reducing costs.

The RISC-based SPCE061A has higher execution efficiency and faster speeds than the 8-bit MCS 51 series. Its wide operating voltage range and low power consumption with anti-interference design make the 061A particularly suited for battery-powered applications. It features 2K bytes of SRAM and 32K FLASH, as well as 32 programmable general-purpose input/output ports, and includes functions such as WatchDog. It is increasingly used in instruments, industrial control, and communication products.

In terms of program design, the assembly instructions for the μ’nSP? microcontroller have been optimized for C language, making the assembly instruction format similar to C language in many aspects. Additionally, its development simulation environment IDE provides a C language development environment, allowing for easy mutual calls between C functions and assembly functions [2, 3]. The hardware interface circuit between HS12864-1 and SPCE061A microcontroller is shown in Figure 2.

Interface and Programming of SPCE061A and LCD Module HS12864-1

Figure 2 uses a parallel communication method, where the microcontroller’s IOA0-IOA7 ports are connected to the LCD module’s DB0-DB7 ports for data input and output; IOA0-IOB4 ports are connected to the LCD module’s CS1, CS2, D/I, R/W, and E as control ports for the microcontroller to the LCD.

4 Display Program Design

There are two methods to display full-screen characters or images on the LCD: one is to send the character pattern data to the display data RAM all at once; the other is to display individually at designated positions on the screen [4]. Both methods must be performed under the condition that the controller is idle, and before operation, it is necessary to read the busy flag to determine whether the controller is busy. Generally, the delay waiting method can replace this.

The main program of this system includes the main program and several subroutine blocks: LCD initialization, LCD screen selection, LCD display, and several control subroutines. The main program calls these subroutines to control the operation of the LCD display. The program flowchart is shown in Figure 3.

Interface and Programming of SPCE061A and LCD Module HS12864-1

Figure 3 Program Flowchart

Common programming languages for Sunplus microcontrollers include assembly language and C language. Assembly language generates machine code with high efficiency but lacks readability, whereas C language typically generates machine code with efficiency comparable to assembly language while far exceeding assembly language in readability and portability. Additionally, C language can embed assembly code to address high-performance coding needs. In terms of development cycles, using C language generally results in significantly shorter development times than assembly language. Considering the advantages of C language, it was chosen for the design.

Here is the command/data sending program for the right half of the screen, illustrating the configuration of IOA/IOB ports in the SPCE061A microcontroller program design. The program for controlling the LCD display part of the Sunplus microcontroller is as follows:

Interface and Programming of SPCE061A and LCD Module HS12864-1

This system debugging uses the Sunplus 61 board (i.e., SPCE061A EMU BOARD) and the u’nSP IDE integrated development environment. Hardware debugging is relatively simple; it only requires adjusting the contrast and backlight brightness of the LCD. On the software side, the Sunplus u’nSP IDE software is used to compile and debug the LCD program.

During debugging, the character pattern data comes from the character pattern generation software Zimo3, but the generated character pattern data cannot be used directly in this program, as the running results will show the upper and lower parts of the font inverted, necessitating a reversal of the order.

The debugging results met the program design requirements.

Interface and Programming of SPCE061A and LCD Module HS12864-1

Interface and Programming of SPCE061A and LCD Module HS12864-1

To facilitate better learning for everyone, Changxue Electronics Network has specially added a public account for microcontrollers and EDA, pushing relevant knowledge daily, hoping to assist your studies!

Interface and Programming of SPCE061A and LCD Module HS12864-1Interface and Programming of SPCE061A and LCD Module HS12864-1

Leave a Comment