Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
11 years ago

LCD Procedure code

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?

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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.