Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)

LCD Procedure code

Altera_Forum
Honored Contributor II
1,170 Views

I need a procedure to write a word in the lcd that I can call any time, so i thought of something like this: 

 

procedure write1 is 

variable cont1: integer range 0 to 18; 

begin 

for cont1 in 0 to 18 loop 

case cont1 is 

when 0 =>lcd_rs<='0'; 

lcd_data<=x"C0"; 

when 1 =>lcd_e<='1'; 

when 2 =>lcd_e<='0'; 

when 3 =>lcd_rs<='1'; 

when 4 =>lcd_data<=x"4C"; --L 

when 5 =>lcd_e<='1'; 

when 6 =>lcd_e<='0'; 

when 7 =>lcd_data <=x"49"; --I 

when 8 =>lcd_e<='1'; 

when 9 =>lcd_e<='0'; 

when 10 =>lcd_data <=x"4B"; --K 

when 11 =>lcd_e<='1'; 

when 12 =>lcd_e<='0'; 

when 13 =>lcd_data <=x"45"; --E 

when 14 =>lcd_e<='1'; 

when 15 =>lcd_e<='0'; 

when 16 =>lcd_rs<='0'; 

lcd_data<=x"80"; 

when 17 =>lcd_e<='1'; 

when 18 =>lcd_e<='0'; 

lcd_rs<='1'; 

end case; 

end loop; 

end write1; 

 

I want to use it like this in a fsm: 

 

if(w1='1' and w2= '0' and w3 = '0') then 

write1; 

elsif(w1='0' and w2 = '1' and w3 = '0') then 

write2; 

elsif(w1='0' and w2 = '0' and w3 = '1') then 

write3; 

elsif(w1 = '0' and w2 = '0' and w3 = '0') then 

clearline2; 

end if; 

 

 

 

But it seems i got all wrong, can someone explain what i should do?
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
435 Views

You're using vhdl like c. A sequential circuit with no clock. Mmmm.... 

What I do: I'll write a simple module that control the timing of the lcd_enable signal. You fire it with a start input and this acknowledges with an end_tick signal when it finishes. Then I'll instantiate this module inside a state machine that sends the comands and ascii to lcd.
0 Kudos
Reply