Академический Документы
Профессиональный Документы
Культура Документы
Overview:
The Spartan® 3A starter kit board comes with a 2-line by 16-character liquid
crystal display (LCD) [1], which offers a practical way to display
information. The FPGA can use both 8-bit and 4-bit data interface to control
the LCD. Both ASCII and custom characters can be used for displaying
information.
In this tutorial, we discuss a way to display the word “HOLA” on the LCD
using the eight bit data interface.
For complete details on how the LCD display configuration and commands,
please refer to the Spartan® 3A User Guide.
Design Overflow:
Background:
All the clock cycles are measured relative to the 50 MHz on board clock
(LOC E12).
The character codes to be displayed on the screen are stored in the Display
Data Ram (DD-RAM). There are special addresses to store these characters:
0x00 to 0x0F (upper line) and 0x40 to 0x4F (lower line).
LCD_RS LCD_RW DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
0 0 1 A6 A5 A4 A3 A2 A1 A0
‘A’ in A6-A0 stands for address-bit. A6-A0 can be either ‘0’ or ‘1’ and refer
to one of the valid DD RAM addresses.
LCD_RS LCD_RW DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
1 0 D7 D6 D5 D4 D3 D2 D1 D0
‘D’ in D7-D0 stands for the data-bit to be written to the DD RAM address.
This could correspond to one of the LCD character sets in the CG ROM.
Since we are using the 8-bit interface, we can combine both the upper and
lower nibbles. For example, the command ‘Write Data to DD RAM’ for the
character ‘I’ can be sent as:
Value: 0x00
Execution Time: 15 ms = 750000 cycles
2. Function Set: This is used to set the number of display lines, the
character font and the data length (in bits)
* Please note that some of the value used can be changed by setting the
DB0 and DB1. Please refer to the user manual for details.
3. Set Display On: Turn the display on, cursor off and cursor position
off.
4. Clear Display:
5. Entry Mode Set: This is a powerful command! It can be used to set the
direction in which the cursor moves and to specify whether to shift the
display or not.
1. Char_h:
Value: 0x48
Execution Time: 4.2 ms = 210000 cycles
2. Char_o:
Value: 0x4F
Execution Time: 4.2 ms = 210000 cycles
3. Char_l:
Value: 0x4C
Execution Time: 4.2 ms = 210000 cycles
4. Char_a:
Value: 0x41
Execution Time: 4.2 ms = 210000 cycles
Waiting
LCD_E=0 T > 15 ms Function_set
LCD_RS=0
Initialize1
T < 20 ns 20 ns<T<8.4 ms T=8.4 ms LCD_Data=0x3C
LCD_RW=0
Function_set
LCD_Data=0x3C
T > 8.4 ms
Initialize3 Function_set
T < 20 ns 20 ns<T<8.4 ms T=8.4 ms
LCD_Data=0x3C
LCD_E=1 LCD_E=0 LCD_E=1
LCD_RS=0 LCD_RS=0 LCD_RS=0
LCD_RW=0 LCD_RW=0 LCD_RW=0
T > 8.4 ms
Initialize4 Function_set
T < 20 ns 20 ns<T<4.2 ms T=4.2 ms LCD_Data=0x3C
Set_display LCD_Data=0x0C
T < 20 ns 20 ns<T<4.2 ms T=4.2 ms
T > 4.2 ms
Clear_display LCD_Data=0x01
T < 20 ns 20 ns<T<4.2 ms T=4.2 ms
T > 4.2 ms
Entry_set LCD_Data=0x06
T < 20 ns 20 ns<T<4.2 ms T=4.2 ms
T > 4.2 ms
Char_h LCD_Data=0x48
T < 20 ns 20 ns<T<4.2 ms T=4.2 ms
LCD_Data=0x4F
Char_o
T < 20 ns 20 ns<T<4.2 ms T=4.2 ms
T > 4.2 ms
LCD_Data=0x4C
Char_l
T < 20 ns 20 ns<T<4.2 ms T=4.2 ms
T > 4.2 ms
LCD_Data=0x41
Char_a
T<4.2 ms T=4.2 ms
LCD_E=0 LCD_E=1
LCD_RS=0 LCD_RS=1
LCD_RW=0 LCD_RW=0
T > 4.2 ms
LCD_Data=0x00
Done
T<4.2 ms
LCD_E=0
LCD_RS=1
LCD_RW=0
We use Stateflow® in Simulink® to model the states and the state
transitions. The attached zip file contains the model ‘lcd_hola_sim.mdl’
which is the most direct implementation of the above flow diagram. When
the model is run, the corresponding values of the LCD_E, LCD_RW,
LCD_RS and LCD_DATA can be visualized in the scope block.
The values of T1, T2, T3 and T4, which correspond to 15 ms, 20 ns, 4.2 ms
and 8.4 ms, have been scaled down to reduce simulation time.
Before the code can be used for synthesis in Xilinx® ISE, some additional
changes need to be made to the generated VHDL file that corresponds to the
binary convertor embedded MATLAB function block ‘uint2bin’. This is
because this block produces a temporary variable of type ‘real’, which must
be changed to ‘integer’.
to:
VARIABLE argin_t_0 : integer;
to:
argin_t_0 := to_integer(argin_t) - to_integer(c(n - 1));
argin_t := to_unsigned(argin_t_0, 8);
This section is for those not familiar with Xilinx® ISE. Following are the
most straightforward way to synthesize, build and deploy the project to the
FPGA board (Please refer to the ISE in depth tutorial for complete details
[2]):
Right Click:
LCD display should print “HOLA”. Please ensure that the “Clock enable”
switch is “HIGH” as specified in the constraint file (constraints.ucf).
References: