Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Introduction
! LCD modules can be split into two groups: those that have built-in
controller and driver chips, and those that have only driver chips. LCD
displays that do not have controllers are typically used with powerful
hardware, such as a laptop computer, where a video controller is available to
generate the complex drive signals necessary to run the display. Most color
and large (greater than 320x240) monochrome displays are of this type.
! LCD displays have two RAMs, naming DDRAM and CGRAM. DDRAM
registers in which position which character in the ASCII chart would be
displayed. Each byte of DDRAM represents each unique position on the LCD
display. The LCD controller reads the information from the DDRAM and
displays it on the LCD screen. CGRAM allows user to define their custom
characters. For that purpose, address space for first 16 ASCII characters are
reserved for users. After CGRAM has been setup to display characters, user
can easily display their custom characters on the LCD screen.
For 4-bit interface data, only four bus lines (DB4 to DB7) are used for
transfer. Bus lines DB0 to DB3 are disabled. The data transfer between
the HD44780U and the Microprocessor is completed after the 4-bit data
has been transferred twice. As for the order of data transfer, the four
high order bits (for 8-bit operation, DB4 to DB7) are transferred before
the four low order bits (for 8-bit operation, DB0 to DB3).
The busy flag must be checked (one instruction) after the 4-bit data has
been transferred twice. Two more 4-bit operations then transfer the
busy flag and address counter data.
Fig2. 4-Bit Transfer Example (more detail see HD44780U Data sheet) .
For 8-bit interface data, all eight bus lines (DB0 to DB7) are used.
Reset Function
1.Initializing by Internal Reset Circuit
! An internal reset circuit automatically initializes the HD44780U when
the power is turned on. The following instructions are executed during the
initialization. The busy flag (BF) is kept in the busy state until the initialization
ends (BF = 1).(more detail see HD44780U Data Sheet). The busy state lasts
for 10 ms after VCC rises to 4.5 V.
Instructions
Outline
Only the instruction register (IR) and the data register (DR) of the HD44780U
can be controlled by the MPU. Before starting the internal operation of the
HD44780U, control information is temporarily stored into these registers to
allow interfacing with various MPUs, which operate at different speeds, or
various peripheral control devices. The internal operation of the HD44780U is
determined by signals sent from the MPU. These signals, which include
register selection signal (RS), read/write signal (R/W), and the data bus (DB0
to DB7), make up the HD44780U instructions (Table 2). There are four
categories of instructions that:
Note: Be sure the HD44780U is not in the busy state (BF = 0) before sending
an instruction from the MPU to the HD44780U. If an instruction is sent without
checking the busy flag, the time between the first instruction and next
instruction will take much longer than the instruction time itself. Refer to Table
2 for the list of each instruction execution time.
2.Initializing by Instruction
If the power supply conditions for correctly operating the internal reset circuit
are not met, initialization by instructions becomes necessary. Refer to Figures
3 and 4 for the procedures on 8-bit and 4-bit initializations, respectively.
Fig.6 Frequency used commands and instructions for LCD (fromTable 2).
- write command and data that depend on an instruction register (IR) and a
data register (DR). If RS=0 => IR(Command), else => DR(Data)
- ex. write command => RS=0, R/W=0, and EN = 0->1 then 1->0
From Table 2 see at the last column we can know the execution time of
instruction. The execution time depend on f(osc). The minimum f(osc) show in
figure 11 is 190MHz that mean the execution time of instruction more than
50 us. The Delay subroutine for LCD in a program we choose 100 us to wait
for the execution time of instruction.
MAIN Program
! 1.Declare
constant and
variables.
! 2.Initial
necessary value of
variables.
! 3.Initial Stack
and Direction port
! 4.Initial LCD 2
Line 16 columns 5x8
dot Matrix.
! 5.Polling for
send a string to the
LCD.
Procedure I.
! 1. Use ISIS schematic capture of Proteus program draw the circuit
follow figure 14.
! 2. Write assembly program LCD 4-bit data mode correspond with
circuit in figure14.
! 3. Integrate main program and all subroutine follow figure 7 - 13 to
build a complete LCD assembly program.
! 4. Design all delay subroutine and some necessary code for
complement this program.
! 5. Use Atmel Studio complie this program and run the program with
circuit in figure 14 by ISIS-Proteus simulation.
! 6. Use Arduino UNO Board and Electronic parts from Arduino lab
box set build a real circuit from a figure 14.
! 7. Use Atmel Studio complie this program and upload hex files to
Arduino UNO Board for run the LCD program. (Hint:use external tools in
Menu Tools with some command line to upload ,so you have to find the
way from internet.)
! 8. Show the result both the simulation and the real hardware with a
staff of LAB. Send a short report and all assembly source code with their
comment and flow-chart.
Fig. 15 Show Header and Main program C code for LCD 16x2 Line
Fig. 15 (cont.) Show Header and Main program C code for LCD 16x2 Line
Procedure II.
! 1.See C code in figure 15 that show header and main program for LCD
16x2 Line .Design body function of function prototype follow the
algorithm same previous assembly program in C language.
(Figure16:function prototype)
! 2.Test program with the same circuit in Procedure I.Show the result
with a staff of LAB . Send a short report and all C source code with their
comment and flow-chart.
Assignment
! 1.Write a C program for LCD show in 1st line Hello Thailand! and
2nd line . Show a result with a staff of LAB. Send a report and all
C source code with their comment and flow chart.