defenseman
New member
I cannot get my LCD to initialize. to rule out bad timing, I made the wait ~1sec after each initialize setting, hence the 26-bit count. here is my code:
EDIT: this code sucks...dont use it. see my updated code below.
EDIT: this code sucks...dont use it. see my updated code below.
Code:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity lcd_init is
port(
reset : in std_logic;
clock : in std_logic;
enable : in std_logic;
done_ack : in std_logic;
done : out std_logic;
RW : out std_logic;
rs : out std_logic;
lcd_e : out std_logic;
leds : out std_logic_vector (7 downto 0);
Qout : out std_logic_vector(7 downto 0));
--lcd_power: out std_logic_vector(2 downto 0));
end lcd_init;
architecture initial of lcd_init is
type state_type is (waiting, i0, i1, i2, i3, i4, i5, i6, donestate);
signal state, next_state : state_type;
signal count, count_temp : std_logic_vector(25 downto 0);
signal Qout_temp : std_logic_vector(7 downto 0);
begin
running : process(state,enable,done_ack,count) is
begin
case state is
when waiting =>
leds <= Qout_temp;
done <= '0';
lcd_e <= '1';
RW <= '0';
rs <= '0';
Qout_temp <= "00000000";
if (enable = '1' and count = "10111110101111000010000000") then
next_state <= i0;
else
next_state <= waiting;
end if;
when i0 =>
leds <= Qout_temp;
Qout_temp <= "00110000";
done <= '0';
lcd_e <= '1';
RW <= '0';
rs <= '0';
if count = "10111110101111000010000000" then
next_state <= i1;
else
next_state <= i0;
end if;
when i1 =>
leds <= Qout_temp;
Qout_temp <= "00110000";
done <= '0';
lcd_e <= '1';
RW <= '0';
rs <= '0';
if count = "10111110101111000010000000" then
next_state <= i2;
else
next_state <= i1;
end if;
when i2 =>
leds <= Qout_temp;
Qout_temp <= "00110000";
done <= '0';
lcd_e <= '1';
RW <= '0';
rs <= '0';
if count = "10111110101111000010000000" then
next_state <= i3;
else
next_state <= i2;
end if;
when i3 =>
leds <= Qout_temp;
Qout_temp <= "00111100";
done <= '0';
lcd_e <= '1';
RW <= '0';
rs <= '0';
if count = "10111110101111000010000000" then
next_state <= i4;
else
next_state <= i3;
end if;
when i4 =>
leds <= Qout_temp;
Qout_temp <= "00001000";
done <= '0';
lcd_e <= '1';
RW <= '0';
rs <= '0';
if count = "10111110101111000010000000" then
next_state <= i5;
else
next_state <= i4;
end if;
when i5 =>
leds <= Qout_temp;
Qout_temp <= "00000001";
done <= '0';
lcd_e <= '1';
RW <= '0';
rs <= '0';
if count = "10111110101111000010000000" then
next_state <= i6;
else
next_state <= i5;
end if;
when i6 =>
leds <= Qout_temp;
Qout_temp <= "00000111";
done <= '0';
lcd_e <= '1';
RW <= '0';
rs <= '0';
if count = "10111110101111000010000000" then
next_state <= donestate;
else
next_state <= i6;
end if;
when donestate =>
leds <= Qout_temp;
done <= '1';
lcd_e <= '1';
RW <= '0';
rs <= '1';
Qout_temp <= "01111111";
if done_ack = '1' then
next_state <= waiting;
else
next_state <= donestate;
end if;
end case;
end process running;
timing : process(clock,reset) is
begin
if rising_edge(clock) then
Qout <= Qout_temp;
count <= count_temp;
if reset = '1' then
state <= waiting;
count_temp <= "00000000000000000000000000";
else
state <= next_state;
count_temp <= count_temp + '1';
end if;
end if;
end process timing;
end initial;
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
Last edited: