Download LCD Display Controller-Digital Systems Design-Lecture 07 Slides-Electrical and Computer Engineering and more Slides Digital Systems Design in PDF only on Docsity!
Digital Systems Design
DE2 LCD Display Controller
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-
Using the LCD Module
• The LCD module can be used to display text by
sending appropriate commands to the display
controller
• Will require an FSM in VHDL for
– Initialization
– Sending commands to the controller
– Reading/writing data, etc.
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-
• Can optionally download new font information
– A default font set is built-in to the controller
– We will only use the default font set in this example
LCD Module Functioning
• The LCD display Module is built in a LSI controller with two
8-bit registers
- A write-only instruction register (IR) and a data register (DR)A write only instruction register (IR) and a data register (DR)
• The IR stores instruction codes, such as display clear and
cursor shift, and address information for display data RAM
(DDRAM) and character generator RAM (CGRAM)
• The DR temporarily stores data to be written or read from
DDRAM or CGRAM
Wh dd i f ti i itt i t th IR th d t i
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-
• When address information is written into the IR, then data is
stored into the DR from DDRAM or CGRAM
Pin Assignments for the LCD Module
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-
Display Data RAM (DDRAM)
• This DDRAM is used to store the display data represented in
8-bit character codes. Its extended capacity is 808 bits or 80
characterscharacters
• The relationship between the 7-bit DDRAM address and
positions on the liquid crystal display is given below
Display position DDRAM address
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
2-line by 16-character display
LCD Write Timing Diagram
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-
LCD Write Timing Parameters
Item Symbol Min Typical Max Units Enable cycle time t (^) cycE 500 -- -- ns Enable pulse width (high level) PW (^) EH 230 -- -- ns Enable rise/fall time t (^) Er, t (^) Ef -- -- 20 ns Address setup time (RS, RW to E) t (^) AS 40 -- -- ns Address hold time t (^) AH 10 -- -- ns Data setup time t (^) DSW 80 -- -- ns Data hold time t (^) H 10 -- -- ns
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-
LCD Read Timing Diagram
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-
LCD Initialization Flowchart (Part 1)
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-
LCD Initialization Flowchart (Part 2)
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-
Selected LCD Commands
Instruction
Instruction Code Description RS RW DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB Write “00H” to DDRAM Clear Display 0 0 0 0 0 0 0 0 0 1 and set DDRAM address to “00H” from AC
Return Home 0 0 0 0 0 0 0 0 1 --
Set DDRAM address to “00H” from AC and return cursor to its original position if shifted. The contents of DDRAM are not changed. Assign cursor moving
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-
Entry Mode Set 0 0 0 0 0 0 0 1 I/D^ SH
Assign cursor moving direction and enable the shift of entire display
-- = don’t care
Selected LCD Commands (continued)
Instruction
Instruction Code Description RS RW DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB
DiDisplay l Set display (D), cursor ON/OFF Control
0 0 0 0 0 0 1 D C B
p y ( ), (C ), and blinking of cursor (B) on/off control bit.
Function Set 0 0 0 0 1 DL N F -- --
Set interface data length (DL:8-bit/4-bit), numbers of display line (N:2-line/1-line) and, display font type (F:5x 11 dots/5x8 dots)
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-
) Set DDRAM Address 0 0 1
AC 6
AC 5
AC 4
AC 3
AC 2
AC 1
AC 0
Set DDRAM address in address counter.
Write Data to RAM
1 0 D7 D6 D5 D4 D3 D2 D1 D
Write data into internal RAM (DDRAM/CGRAM).
LCD Controller Example
• We will define an array of STD_LOGIC_VECTORs for
holding data to be displayed on the LCD
• An FSM will be used for LCD initialization (see initializationAn FSM will be used for LCD initialization (see initialization
flowchart) then controlling data written to the LCD
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-
LCD Controller Example
- LCD_display_string contains static text for display as well as two 4-bit
fields to support displaying two HEX digits (0-F)
- The leading “0000” field will be used in the FSM to indicate dynamicg y
data. This data will be converted to ASCII for display
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-
LCD Controller Example
• The DATA_BUS value will be driven from the
DATA_BUS_VALUE signal when an LCD write operation is
performed Otherwise DATA BUS will be tri-stated as far asperformed. Otherwise DATA_BUS will be tri-stated as far as
the FSM in the FPGA is concerned. This example FSM does
not support LCD read operations.
• Next_Char represents the next character to output to the
LCD display from the string
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-
LCD Controller Example
- The 50MHz clock is used to generate a 400Hz signal
(CLK_400HZ_Enable). This is not actually a 400HZ clock, but is a signal
that will be active high once every 1.25ms.
- The 400Hz signal will be active high for only one 50Mhz clock period and
will be used to control transitions between states in the FSM.
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-
LCD Controller Example
- RESET2 and RESET3 states implement the next two states in the LCD
initialization flowchart.
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-
LCD Controller Example
- These states implement the
FUNC_SET, DISPLAY_OFF,
and DISPLAY_CLEAR steps
of the LCD initialization from
the flowchart
- These states all write to the
IR (RS=0)
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-
holds commands (from the
command list) to be written to
the LCD
LCD Controller Example
- The remaining initialization states turn the display on and set the mode to
autoincrement the address counter so that when a character is written to
the LCD, AC is incremented and the cursor is moved to the next location
of the LCD.
- We will have to account for the address change for the second display line.
- There will be a specific state to accommodate that address change.
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-
LCD Controller Example
- The Print_String state prints one ASCII character to the display
- If the value in Next_Char is a static ASCII character from the character array, then it is written to the LCD data register (RS=1) directly.
- If the upper four bits of Next_Char are “0000”, then the lower four bits are concatenated with the proper value to produce an ASCII character for 0-9 (30- 39H) or A-F (41-46H) to be written to the display.
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-
LCD Controller Example
- The RETURN_HOME state is similar to the LINE2 state except that an address of 00H is written to the address counter (AC)
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-
LCD Controller Example
- The final section of the VHDL design implements the DROP_LCD_E and HOLD states needed to implement the falling edge of the LCD E signal as well has hold time for address and data to remain valid following the falling edge of E.
- N tNote since no assignments are made to LCD_RS and LCD_RW in the HOLD i i t d t LCD RS d LCD RW i th HOLD state, they retain their previous values (implied memory)
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-
LCD Controller State Diagram
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-
Sample LCD Simulation
Electrical & Computer EngineeringElectrical & Computer Engineering Dr. D. J. Jackson Lecture 7-