Upload
gagandeep-singh-dhingra
View
217
Download
0
Embed Size (px)
Citation preview
8/12/2019 LCD_notes
1/13
Special topic #1: LCD Module on DE2 Board
In this section, an application example of FSM for LCD display will be presented. In order to
use the LCD module on DE board, appropriate data communication between F!"# and LCD
module is re$uired. %ne can desi&n an FSM to achie'e this communication. First, F!"# lo&ic
&enerates di&ital cloc( si&nals )hours, minutes, and seconds*+ then an FSM desi&ned in F!"#
deli'ers the di&ital cloc( si&nals to LCD module, accordin& to interface re$uirements, such as
data format and timin& constraints.
1. LCD module on DE2 board
%n the #ltera DE F!"# de'elopment board, there is a Li$uid Crystal Display )LCD*
module that can be used to display text by sendin& appropriate commands from F!"# chip to the
LCD module. here is a built-in controller D//012 in the LCD module to dri'e the display. he
interface between F!"# chip and the LCD module is shown in Fi&.3.
Fi&.3 he interface between F!"# chip and LCD module
LCD4%5 )hi&h-acti'e* turns on the power of LCD module.
LCD46L%5 controls the LCD bac( li&ht.
LCD4D## 72809 is an 1-bit data bus for their data communication.
LCD4:; defines the direction of data bus )LCD4:;3?+ LCD4D## is a command )display clear, cursor shift and address information
etc.* if LCD4:S is >2?.
FPGA
LCDd
isplay
(controllerHD44780
included)
LCD_ON
LCD_BLON
LCD_RW
LCD_RS
LCD_EN
LCD_DATA[0:7]
8/12/2019 LCD_notes
2/13
he F!"# pin assi&nment of the interface is shown in able.3.3.
able 3.3 LCD related pin assi&nments on DE
2. Function description of LCD module
1) Registers, DDRAM, and CR!M in LCD module
he controller D//012, built in LCD module, plays an important role in the LCD display
tas(. he controller communicates with F!"#, and controls the LCD display. he bloc( dia&ram
of D//012 is shown in Fi&..
he D//012 has two 1-bit re&isters )I:, and D:* to store information sent from F!"#.
he operation and selection of two re&isters are defined by able 3.. he I: )instruction
re&ister* stores instruction codes, such as display clear, cursor shift, and address information for
display data :#M )DD:#M* and character &enerator :#M )C":#M*. he I: can only be
written from F!"#. he D: )data re&ister* temporarily stores data to be written into DD:#M or
8/12/2019 LCD_notes
3/13
C":#M and temporarily stores data read from DD:#M or C":#M. ere we only consider the
situation that data are written into DD:#M or C":#M. So, in our followin& discussion,
LCD4:; is always set to >2? for writin& only, unless otherwise stated. 6y LCD4:S, the data
LCD4D## 72809 is interpreted either as instruction codes )when LCD4:S
8/12/2019 LCD_notes
4/13
able 1. :e&ister Selection
Fi&.@ the relationship between DD:#M addresses and positions on LCD
he address counter )#C* recei'es an initial address throu&h I: based on a
command=instruction code, and assi&ns and updates addresses to both DD:#M and C":#M.
he DD:#M is used to store the display data represented in 1-bit character codes and sent from
F!"#. Each address of DD:#M corresponds to a position on the LCD. he relationship between
DD:#M addresses and positions on LCD is shown in Fi&. @ )-by-3A character display*.
8/12/2019 LCD_notes
5/13
C"aracter enerator R!M #CR!M)$ he C":%M &enerate Bx1 dot or Bx32 dot
character patterns from 1-bit character codes. See able 3.@. For example, in order to display on
the first line position B, 1h@ should be written into the address )#C* 1h2/ of DD:#M.
able 3.@ C":%M pattern )Bx1 dots*
8/12/2019 LCD_notes
6/13
2) %nstruction table
able 3./ includes all a'ailable instructions to control LCD. he M!=F!"# will send a
se$uence of instructions to LCD with appropriate timin& constraints. he instructions are di'ided
into two types8 3* command+ * data transfer. he command instructions ):S
8/12/2019 LCD_notes
7/13
&) 'iming re(uirements
he M!=F!"# should meet the followin& timin& re$uirements when it communicates with
LCD. For write operation#:=;
8/12/2019 LCD_notes
8/13
& %nitialiing of LCD
F!"# chip needs to send a series of initialiation commands to initialie the LCD. hese
commands include function set, display off, display clear, and entry mode set. he datasheet
pro'ides a typical initialiation process shown in Fi&.B.
Fi&. B Initialiation steps
8/12/2019 LCD_notes
9/13
*. F+Acore LCDDispla-$ LCD panel c"aracter displa-
C!M+!E' LCD4Display
+!R')ex4Display4Data8 % /'DL!%C0EC'!R
))5um4ex4Di&its/*-3 D!'! 2*+
reset, cloc(4/1M8 % /'DL!%C+LCD4:S, LCD4E8 !' /'DL!%C+
LCD4:;8 %!' /'DL!%C+
D##46S8 %!' /'DL!%C0EC'!R)0 D!'! 2**+ED C!M+!E'3
he LCD4Display core is used to display static #SCII characters and chan&in& hex 'alues
from hardware on the DEs 3A by line LCD display panel. he cores GDL code can be
confi&ured internally by the user to display different #SCII strin&s and hex data fields.
Instructions can be found in comments in the cores GDL code. # "eneric,Num_Hex_Digits, is
used to set the sie of the ex4Display4Data input )i.e., Each hex di&it displayed re$uires a /-bit
si&nal*. he LCD controller datasheet contains information on &raphics characters and LCD
commands. # state machine is used to send data and commands to the LCD controller and to
&enerate the re$uired handsha(e si&nals.
ex4Display4Data contains the /-bit hexadecimal hardware si&nal 'alues to con'ert to
#SCII hex di&its and send to the LED display. he "eneric, 5um4ex4Di&its, adHusts the sie of
the input hex data.
LI6:#: IEEE+SE IEEE.SD4L%"IC433A/.all+
SE IEEE.SD4L%"IC4#:I.all+
SE IEEE.SD4L%"IC45SI"5ED.all+
-- S;1 )"L%6#L :ESE* resets LCD
8/12/2019 LCD_notes
10/13
E5I LCD4Display IS
-- Enter number of li'e ex hardware data 'alues to display
-- )do not count #SCII character constants*
"E5E:IC)5um4ex4Di&its8 Inte&er8< *+
--
!%:)reset, cl(4/1Mh 8 I5 SD4L%"IC+ex4Display4Data 8 I5 SD4L%"IC4GEC%:))5um4ex4Di&its/*-3 D%;5% 2*+
LCD4:S, LCD4E 8 % SD4L%"IC+
LCD4:; 8 % SD4L%"IC+
D##46S 8 I5% SD4L%"IC4GEC%:)0 D%;5% 2**+
E5D E5I LCD4Display+
#:CIEC:E a %F LCD4Display IS
!E character4strin& IS #::# ) 2 % @3 * %F SD4L%"IC4GEC%:) 0 D%;5% 2 *+
!E S#E4!E IS )%LD, F5C4SE, DIS!L#4%5, M%DE4SE, !rint4Strin&,
LI5E, :E:54%ME, D:%!4LCD4E, :ESE3, :ESE,
:ESE@, DIS!L#4%FF, DIS!L#4CLE#:*+
SI"5#L state, next4command8 S#E4!E+SI"5#L LCD4display4strin& 8 character4strin&+
-- Enter new #SCII hex data abo'e for LCD DisplaySI"5#L D##46S4G#LE, 5ext4Char8 SD4L%"IC4GEC%:)0 D%;5% 2*+
SI"5#L CLJ4C%54/22K8 SD4L%"IC4GEC%:)3 D%;5% 2*+
SI"5#L C#:4C%58 SD4L%"IC4GEC%:)/ D%;5% 2*+
SI"5#L CLJ4/22K4Enable,LCD4:;4I5 8 SD4L%"IC+
SI"5#L Line34chars, Line4chars8 SD4L%"IC4GEC%:)30 D%;5% 2*+
6E"I5
LCD4display4strin& < )-- #SCII hex 'alues for LCD Display
-- Enter Li'e ex Data Galues from hardware here
-- LCD DIS!L#S E F%LL%;I5"8------------------------------
--N Count
8/12/2019 LCD_notes
11/13
CLJ4/22K4Enable < R2R+
ELSE
IF CLJ4C%54/22K OP2E#A2P E5
CLJ4C%54/22K < CLJ4C%54/22K 3+
CLJ4/22K4Enable < R2R+ELSE
CLJ4C%54/22K < OP22222P+CLJ4/22K4Enable < R3R+
E5D IF+
E5D IF+
E5D !:%CESS+
!:%CESS )CLJ4/1MK, reset*
6E"I5IF reset < R2R E5
state < :ESE3+
D##46S4G#LE < OP@1P+
next4command < :ESE+
LCD4E < R3R+
LCD4:S < R2R+
LCD4:;4I5 < R3R+
ELSIF CLJ4/1MKREGE5 #5D CLJ4/1MK < R3R E5
-- State Machine to send commands and data to LCD DIS!L# IF CLJ4/22K4Enable < R3R E5
C#SE state IS
-- Set Function to 1-bit transfer and line display with Bx1 Font sie
-- see itachi D//012 family data sheet for LCD command and timin& details
;E5 :ESE3
8/12/2019 LCD_notes
12/13
next4command < DIS!L#4%FF+
-- urn off Display and urn off cursor
;E5 DIS!L#4%FF
8/12/2019 LCD_notes
13/13
ELSE
C#:4C%5 < P22222P+
E5D IF+
-- Uump to second lineV
IF C#:4C%5 < 3B E5 next4command < line+-- :eturn to first lineV
ELSIF )C#:4C%5 < @3* %: )5ext4Char < OPFEP*E5
next4command < return4home+
ELSE next4command < !rint4Strin&+ E5D IF+
-- Set write address to line character 3
;E5 LI5E