wanwzy 发表于 2010-5-18 13:37:29

液晶显示问题!急!!!!!!!!!!大家帮忙看看啊!不胜感谢!

大家有用过HS162-4液晶的吗?我写了个驱动控制程序,但是始终显示有问题。本来想显示“FEIYONG:”但是最终显示的是“:F E I Y O N G "中间空格的地方会出现一个认不到的图案,大家帮忙找找原因啊!谢谢了!原程序如下:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity lcd1 is
Port (sysclk:in std_logic;-----20兆赫兹晶振
      reset:in std_logic;
      lcdda : out std_logic;--寄存器选择信号
      lcdrw : out std_logic;--液晶读写信号
      lcden : out std_logic;--液晶时钟信号
      date : out std_logic_vector(7 downto 0));--液晶数据信号
end lcd1;

architecture Behavioral of lcd1 is
type state is (set_qp,set_gn,set_xskg,set_xsaddr,set_cgram,write_date,ting);--7种状态分别为清屏,功能设置,显示开关,设置CGRAM,独处数据,
                                                                               停止。
signal current_state:state;
type ram2 is array(0 to 7) of std_logic_vector(7 downto 0);
constant cgram:ram2:=(("01000110"),("01000101"),("01001001"),("01011001"),
("01001111"),("01001110"),("01000111"),("00111010"));--字符数据存储器分别存储了“FEIYONG:”                           
signal cnt:std_logic_vector(24 downto 0);
signal clk1:std_logic;--状态机时钟信号,同时也是液晶时钟信号,其周期应该满足液晶数据的建立时间

begin
process(sysclk)-----2/3赫兹分频
begin
if sysclk'event and sysclk='1' then
   if cnt=14999999 then clk1<=not clk1;cnt<=(others=>'0');
   else cnt<=cnt+1;
   end if;
end if;
end process;

lcden <=clk1 ; --液晶时钟信号
lcdrw <= '0' ;--写数据

control:process(clk1,reset,current_state)--液晶驱动控制器
variable cnt1: std_logic_vector(2 downto 0);
begin
if reset='0'then
    current_state<=set_qp;
    cnt1:="111";
    lcdda<='0';
elsif rising_edge(clk1)then
      if cnt1="111" then
      date<="00001111";--0fH
      current_state <=ting;
      lcdda <= '0';
      else current_state <=set_cgram;
      end if;
        case current_state is
          when set_qp=>                                         
               date<="00000001";--01H
               current_state<=set_gn;
             when set_gn=>
               date<="00111000";--38H
               current_state<=set_xskg;
             when set_xskg=>
               date<="00001111";--0fH
               current_state<=set_xsaddr;
          when set_xsaddr=>                   --从第一行的起始地址开始显示
               date<="10000000";--80H
               current_state<=set_cgram;          
          when set_cgram=>                      --向CGRAM中写入
               lcdda<='1';
               date<=cgram(conv_integer(cnt1));
               cnt1:=cnt1+1;
               current_state<=write_date;                                                         
   when write_date=>                       
               lcdda<='1';
               date<="00000000"; --写入字符
          when others => null;
end case;
end if;
end process;
end Behavioral;

HS162-4液晶显示使用说明ourdev_555015.doc(文件大小:159K) (原文件名:HS162-4液晶显示使用说明.doc)

我最终想实现液晶能有2部分显示,第一行显示“FEIYONG:变化的数据”;第二行显示数字时钟;(“FEIYONG:”这段字符是静态显示的,其他的都是动态变化的)。大家能帮下忙实现下嘛?帮忙改改代码!或者帮忙写段代码(本人初学,请稍加注释)!加我QQ:403246557.或发到我的QQ邮箱里都行。不胜感谢!
页: [1]
查看完整版本: 液晶显示问题!急!!!!!!!!!!大家帮忙看看啊!不胜感谢!