求助各位大神,我的开发板是EP2C8Q208C8,学的是verylog,店家给我的实验例程只有vhdl的,所以用了我同学的程序,但烧进去运行,能显示我要他显示的字符,但背光效果全无,引脚也没有接错啊。后来又到网上当了几段代码,也没有效果,倒是我自己的那份vhdl的既能显示字符又有背光。晚上又换了个lcd,(因为买来时开发板里面就已经内置了程序,所以一按电源键,lcd就会滚动WELCOME~~~~~的字符,有背光效果),这次接了个新的以后,按下电源键,新lcd能显示字符,但也没有背光效果,我还没有烧进去啊!又接了个新lcd,这次是直接连字符都几不可见。
不知道各位能不能看懂?新手求教啊。是硬件的事还是程序的事呢?
此帖出自
小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
input clk; //系统时钟输入50M
output [7:0] dat; //LCD的8位数据口
output rs,rw,en; //LCD的控制脚
reg e;
reg [7:0] dat;
reg rs;
reg [15:0] counter;
reg [5:0] current,next;
reg clkr;
reg [1:0] cnt;
//定义了LCD状态机需要的状态。
parameter set0=6'h0;
parameter set1=6'h1;
parameter set2=6'h2;
parameter set3=6'h3;
parameter set4=6'h4;
parameter dat0=6'h7;
parameter dat1=6'h8;
parameter dat2=6'h9;
parameter dat3=6'hA;
parameter dat4=6'hB;
parameter dat5=6'hC;
parameter dat6=6'hD;
parameter dat7=6'hE;
parameter dat8=6'hF;
parameter dat9=6'h10;
parameter dat10=6'h12;
parameter dat11=6'h13;
parameter dat12=6'h14;
parameter dat13=6'h15;
parameter dat14=6'h16;
parameter dat15=6'h17;
parameter dat16=6'h18;
parameter dat17=6'h19;
parameter dat18=6'h1A;
parameter dat19=6'h1B;
parameter dat20=6'h1C;
parameter dat21=6'h1D;
parameter dat22=6'h1E;
parameter dat23=6'h1F;
parameter dat24=6'h20;
parameter dat25=6'h21;
parameter dat26=6'h22;
parameter nul=6'hF1;
always @(posedge clk) //da de shi zhong pinlv
begin
counter=counter+1;
if(counter==16'h000f)
clkr=~clkr;
end
always @(posedge clkr)
begin
current=next;
case(current)
//LCD1602的资料上面介绍的地址第一行的起始地址是00H
//第二行的其实地址是40H,他这个是没有加上最高位那个1
//所以我们实际的编程是地址第一行的起始地址是00H+80H= 0x80
//实际的编程是地址第二行的起始地址是40H+80H= 0xC0
//这里要注意
// case 0:addr=0x80; break; //所以我们实际的编程是地址第一行的起始地址是00H+80H= 0x80
// case 1:addr=0xC0; break;//实际的编程是地址第二行的起始地址是40H+80H= 0xC0
set0: begin rs<=0; dat<=8'h38; next<=set1; end //*设置8位格式,2行,5*7*
set1: begin rs<=0; dat<=8'h0C; next<=set2; end //*整体显示,关光标,不闪烁*/
set2: begin rs<=0; dat<=8'h06; next<=set3; end //*设定输入方式,增量不移位*/
set3: begin
rs<=0; dat<=8'h01; next<=dat0; //*清除显示*/
end
dat0: begin rs<=1; dat<="D"; next<=dat1; end //显示第一行
dat1: begin rs<=1; dat<="E"; next<=dat2; end
dat2: begin rs<=1; dat<="V"; next<=dat3; end
dat3: begin rs<=1; dat<=":";next<=dat4; end
dat4: begin rs<=1; dat<="<"; next<=dat5; end
dat5: begin rs<=1; dat<="A"; next<=dat6; end
dat6: begin rs<=1; dat<="-"; next<=dat7; end
dat7: begin rs<=1; dat<="C";next<=dat8; end
dat8: begin rs<=1; dat<="5"; next<=dat9; end
dat9: begin rs<=1; dat<="F";next<= dat10 ; end
dat10: begin rs<=1; dat<="B"; next<=dat11; end
dat11: begin rs<=1; dat<=">"; next<=set4; end
set4: begin rs<=0; dat<=8'hC0; next<=dat12; end //显示第二行
dat12: begin rs<=1; dat<="W"; next<=dat13; end
dat13: begin rs<=1; dat<="W";next<=dat14; end
dat14: begin rs<=1; dat<="W"; next<=dat15; end
dat15: begin rs<=1; dat<="."; next<=dat16; end
dat16: begin rs<=1; dat<="2"; next<=dat17; end
dat17: begin rs<=1; dat<="1"; next<=dat18; end
dat18: begin rs<=1; dat<="E"; next<=dat19; end
dat19: begin rs<=1; dat<="D"; next<=dat20; end
dat20: begin rs<=1; dat<="A"; next<=dat21; end
dat21: begin rs<=1; dat<="."; next<=dat22; end
dat22: begin rs<=1; dat<="N"; next<=dat23 ; end
dat23: begin rs<=1; dat<="E"; next<=dat24; end
dat24: begin rs<=1; dat<="T"; next<=dat25; end
dat25: begin rs<=1; dat<=" "; next<=dat26; end
dat26: begin rs<=1; dat<=" "; next<=nul; end
nul: begin rs<=0; dat<=8'h00; // 把液晶的E 脚 拉高
if(cnt!=2'h2)
begin
e<=0;next<=set0;cnt<=cnt+1;
end
else
begin next<=nul; e<=1;
end
end
default: next=set0;
endcase
end
assign en=clkr|e;
assign rw=0;
endmodule
一周热门 更多>