• No results found

VHDL code for LCD Display

N/A
N/A
Protected

Academic year: 2021

Share "VHDL code for LCD Display"

Copied!
7
0
0

Loading.... (view fulltext now)

Full text

(1)

AIM

Apparatus Required

Code implementation

To display our name on the LCD screen of

.

Software

Xilinx ISE Project Navigator (M.63c) 12.2

Xilinx ISE iMPACT (M.63c) 12.2

Xilinx ISim Simulator (M.63c) 12.2

Hardware

MTE Universal VTU trainer MXS3FK-VTU protoboard.

Universal VTU trainer protoboard

--libraries to be used are specified here

library

use .ALL

use .ALL

use .ALL

entity is

Port out downto

out out in ; out in end architecture of is type is IEEE IEEE STD_LOGIC_1164 IEEE STD_LOGIC_ARITH IEEE STD_LOGIC_UNSIGNED ( LCD_DB: std_logic_vector std_logic std_logic std_logic std_logic std_logic ; . ; . ; . ; lcd (7 0); RS: ; RW: ; CLK: OE: ; rst: ); lcd; Behavioral lcd mstate ( stFunctionSet, stDisplayCtrlSet, stDisplayClear, stPowerOn_Delay, stFunctionSet_Delay, stDisplayCtrlSet_Delay, --DB( 7 through 0) --WE --ADR(0) --GCLK2

--ADR1:out std_logic; --ADR(1)

--ADR2:out std_logic; --ADR(2)

--CS:out std_logic; --CSC

--OE --BTN

--rdone: out std_logic); --WriteDone output to work with DI05 test

--- Component Declarations

--- Local Type Declarations

--- Symbolic names for all possible states of the state machines.

--LCD control state machine

--Initialization states

--Delay states

(2)

type is signal downto signal signal downto signal std_logic signal signal signal signal signal signal

type is array integer range of downto constant stDisplayClear_Delay, stInitDne, stActWr, stCharDelay ); wstate ( stRW, stEnable, stIdle ); clkCount: (5 0); activateW: := '0'; count: (16 0):= "00000000000000000"; delayOK: := '0'; OneUSClk: ; stCur:mstate:= stPowerOn_Delay; stNext:mstate; stCurW:wstate:= stIdle; stNextW:wstate; writeDone: := '0'; LCD_CMDS_T ( <>) (9 0); LCD_CMDS : LCD_CMDS_T := ( 0 => "00"&X"3C", 1 => "00"&X"0C", 2 => "00"&X"01", 3 => "00"&X"02", 4 => "10"&X"50", 5 => "10"&X"72", 6 => "10"&X"61", 7 => "10"&X"76", 8 => "10"&X"65", 9 => "10"&X"65",

--Display charachters and perform standard operations

--Write delay for operations

--stWait --Idle state

--Write control state machine

--set up RS and RW --set up E

--Write data on DB(0)-DB(7)

--- Signal Declarations and Constants

---These constants are used to initialize the LCD pannel. --FunctionSet:

--Bit 0 and 1 are arbitrary

--Bit 2: Displays font type(0=5x8, 1=5x11) --Bit 3: Numbers of display lines (0=1, 1=2) --Bit 4: Data length (0=4 bit, 1=8 bit)

--Bit 5-7 are set --DisplayCtrlSet:

--Bit 0: Blinking cursor control (0=off, 1=on) --Bit 1: Cursor (0=off, 1=on)

--Bit 2: Display (0=off, 1=on) --Bit 3-7 are set

--DisplayClear:

--Bit 1-7 are set

--15 bit count variable for timing delays

--High when count has reached the --right delay time

--Signal is treated as a 1 MHz clock --LCD control state machine --Write control state machine

--Command set finish

--Function Set --Display ON, Cursor OFF, Blink OFF --Clear Display --return home --P --r --a --v --e --e std_logic_vector

std_logic --Activate Write sequence std_logic_vector

std_logic

std_logic

(3)

10 => "10"&X"6E", 11 => "10"&X"48", 12 => "10"&X"56", 13 => "10"&X"61", 14 => "10"&X"69", 15 => "10"&X"73", 16 => "10"&X"68", 17 => "10"&X"6E", 18 => "10"&X"61", 19 => "10"&X"76", 20 => "10"&X"20", 21 => "10"&X"20", 22 => "10"&X"20", 23 => "00"&X"18"); lcd_cmd_ptr : 0 LCD_CMDS'HIGH + 1 := 0; (CLK, oneUSClk) (CLK = '1' CLK'event) clkCount <= clkCount + 1; ; ; oneUSClk <= clkCount(5); (oneUSClk, delayOK) (oneUSClk = '1' oneUSClk'event) delayOK = '1' count <= "00000000000000000"; count <= count + 1; ; ; ; writeDone <= '1' (lcd_cmd_ptr = LCD_CMDS'HIGH) '0'; (lcd_cmd_ptr, oneUSClk) (oneUSClk = '1' oneUSClk'event) ((stNext = stInitDne stNext =

stDisplayCtrlSet stNext = stDisplayClear) writeDone = '0') lcd_cmd_ptr <= lcd_cmd_ptr + 1;

stCur = stPowerOn_Delay stNext = stPowerOn_Delay lcd_cmd_ptr <= 0; lcd_cmd_ptr <= lcd_cmd_ptr; --n --space --V --a --i --s --h --n --a --v --space --space --space --Shifts left

-- This process counts to 50, and then resets. It is used to divide -- the clock signal time.

-- This makes oneUSClock peak once every 1 microsecond

-- This process incriments the count variable unless delayOK = 1.

--This goes high when all commands have been run

--rdone <= '1' when stCur = stWait else '0';

--Increments the pointer so the statemachine goes through the -- commands

signal integer range to

begin process begin if and then end if end process process begin if and then if then else end if end if end process when else process begin if and then if or or and then elsif or then else

(4)

end if end if end process when and or and or and or and or and else '0' process begin if and then if then else end if end if end process process begin case is when if then else end if downto when downto ; ; ;

delayOK <= '1' ((stCur = stPowerOn_Delay count = "00100111001010010")

(stCur = stFunctionSet_Delay count = "00000000000110010")

(stCur = stDisplayCtrlSet_Delay count = "00000000000110010")

(stCur = stDisplayClear_Delay count = "00000011001000000")

(stCur = stCharDelay count = "11111111111111111"))

;

-- This process runs the LCD status state machine (oneUSClk, rst) oneUSClk = '1' oneUSClk'Event rst = '1' stCur <= stPowerOn_Delay; stCur <= stNext; ; ; ;

(stCur, delayOK, writeDone, lcd_cmd_ptr)

stCur stPowerOn_Delay => delayOK = '1' stNext <= stFunctionSet; stNext <= stPowerOn_Delay; ; RS <= LCD_CMDS(lcd_cmd_ptr)(9); RW <= LCD_CMDS(lcd_cmd_ptr)(8); LCD_DB <= LCD_CMDS(lcd_cmd_ptr)(7 0); activateW <= '0'; stFunctionSet => RS <= LCD_CMDS(lcd_cmd_ptr)(9); RW <= LCD_CMDS(lcd_cmd_ptr)(8); LCD_DB <= LCD_CMDS(lcd_cmd_ptr)(7 0); activateW <= '1';

-- Determines when count has gotten to the right number, -- depending on the state.

--20050 --50 --50 --1600

--Max Delay for character writes and shifts --(stCur = stCharDelay and count =

"00000000000100101"))--37 This is proper delay between writes to ram.

-- This process generates the sequence of outputs needed to -- initialize and write to the LCD screen

-- Delays the state machine for 20ms which is needed for proper startup.

-- This issuse the function set to the LCD as follows -- 8 bit data length, 2 lines, font is 5x8.

(5)

stNext <= stFunctionS stFunctionSet_Delay => RS <= LCD_CMDS(lcd_cmd_ptr)(9); RW <= LCD_CMDS(lcd_cmd_ptr)(8); LCD_DB <= LCD_CMDS(lcd_cmd_ptr)(7 0); activateW <= '0'; delayOK = '1' stNext <= stDisplayCtrlSet; stNext <= stFunctionSet_Delay; ; stDisplayCtrlSet => RS <= LCD_CMDS(lcd_cmd_ptr)(9); RW <= LCD_CMDS(lcd_cmd_ptr)(8); LCD_DB <= LCD_CMDS(lcd_cmd_ptr)(7 0); activateW <= '1'; stNext <= stDisplayCtrlSet_Delay; stDisplayCtrlSet_Delay => RS <= LCD_CMDS(lcd_cmd_ptr)(9); RW <= LCD_CMDS(lcd_cmd_ptr)(8); LCD_DB <= LCD_CMDS(lcd_cmd_ptr)(7 0); activateW <= '0'; delayOK = '1' stNext <= stDisplayClear; stNext <= stDisplayCtrlSet_Delay; ; stDisplayClear => RS <= LCD_CMDS(lcd_cmd_ptr)(9); RW <= LCD_CMDS(lcd_cmd_ptr)(8); LCD_DB <= LCD_CMDS(lcd_cmd_ptr)(7 0); activateW <= '1'; stNext <= stDisplayClear_Delay; stDisplayClear_Delay => RS <= LCD_CMDS(lcd_cmd_ptr)(9); RW <= LCD_CMDS(lcd_cmd_ptr)(8); LCD_DB <= LCD_CMDS(lcd_cmd_ptr)(7 0); activateW <= '0'; delayOK = '1' stNext <= stInitDne; stNext <= stDisplayClear_Delay; ; et_Delay; when downto if then else end if when downto when downto if then else end if when downto when downto if then else end if

-- Gives the proper delay of 37us between the function set and -- the display control set.

-- Issuse the display control set as follows -- Display ON, Cursor OFF, Blinking Cursor OFF.

-- Gives the proper delay of 37us between the display control set -- and the Display Clear command.

-- Issues the display clear command.

-- Gives the proper delay of 1.52ms between the clear command -- and the state where you are clear to do normal operations.

-- State for normal operations for displaying characters, changing -- the Cursor position etc.

(6)

when downto when downto when downto if then else end if end case end process; process begin if and then if then else end if end if end process process begin case is when stInitDne => RS <= LCD_CMDS(lcd_cmd_ptr)(9); RW <= LCD_CMDS(lcd_cmd_ptr)(8); LCD_DB <= LCD_CMDS(lcd_cmd_ptr)(7 0); activateW <= '0'; stNext <= stActWr; stActWr => RS <= LCD_CMDS(lcd_cmd_ptr)(9); RW <= LCD_CMDS(lcd_cmd_ptr)(8); LCD_DB <= LCD_CMDS(lcd_cmd_ptr)(7 0); activateW <= '1'; stNext <= stCharDelay; stCharDelay => RS <= LCD_CMDS(lcd_cmd_ptr)(9); RW <= LCD_CMDS(lcd_cmd_ptr)(8); LCD_DB <= LCD_CMDS(lcd_cmd_ptr)(7 0); activateW <= '0'; delayOK = '1' stNext <= stInitDne; stNext <= stCharDelay; ; ; (oneUSClk, rst) oneUSClk = '1' oneUSClk'Event rst = '1' stCurW <= stIdle; stCurW <= stNextW; ; ; ; (stCurW, activateW) stCurW stRw => OE <= '0'; stNextW <= stEnable;

-- Provides a max delay between instructions.

-- This process runs the write state machine

-- This genearates the sequence of outputs needed to write to the -- LCD screen

-- This sends the address across the bus telling the DIO5 that we are -- writing to the LCD, in this configuration the adr_lcd(2) controls -- the enable pin on the LCD

--CS <= '0'; --ADR2 <= '1'; --ADR1 <= '0';

-- This adds another clock onto the wait to make sure data is stable -- on the bus before enable goes low. The lcd has an active falling -- edge and will write on the fall of enable

(7)

when when if then else end if end case end process end stEnable => OE <= '0'; stNextW <= stIdle; stIdle => OE <= '1'; activateW = '1' stNextW <= stRw; stNextW <= stIdle; ; ; ; Behavioral;

The user constraints given are as follows: lcd_db(0) = p46; lcd_db(1) = p43; lcd_db(2) = p44; lcd_db(3) = p40; lcd_db(4) = p42; lcd_db(5) = p37; lcd_db(6) = p39; lcd_db(7) = p35; rs = p48; rw = p50; oe = p45; clk = p76; rst = p190; --CS <= '0'; --ADR2 <= '0'; --ADR1 <= '0';

-- Waiting for the write command from the instuction state machine --ADR2 <= '0'; --ADR1 <= '0'; --CS <= '1'; net loc net loc net loc net loc net loc net loc net loc net loc net loc net loc net loc net loc net loc

References

Related documents

With funding from our three key partners (City of Rossland, MRDT, and the Red Resort Association) we are able to leverage additional funding from other stakeholders and

on other personal characteristics, we experimented with additional interaction terms. The effect of perceived gender discrimination does not seem to vary with a woman’s age,

In this paper, by using Mawhins continuation theorem of coincidence degree theory and some analytical approaches, we establish the existence of four positive almost periodic

00450088 “West Side Story” nod “Leonard Bernstein” are registered tradensarks of Amberson Holdings U,C, Music From West Side Story -

A small study of psoriasis patients with recent- onset joint symptoms has shown presence of gray-scale (GS) and power Doppler (PD) US activity in clinically inactive joints (15),

Detekce pohybu, parametry obrazu, zpracování obrazu, zpracování videa, metoda odečtení pozadí, frame differencing method, binární obraz, monochromatický

Zeer recent onderzoek, gepubliceerd in juli 1999, heeft aangetoond dat het risico van de 3e-generatiepil vooral hoog is bij jonge Starters: het risico voor veneuze trombose zou in

We expected an efficient method for preparing Polyimide-Silica Nanocomposite films by blending ultralow concentrations of Tetraethoxysilane with PI for