完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
麻烦大家帮我看看程序。1602的,晶振是50MHZ的。弄了很久,一直没能显示出来字符。。刚开始接触verilog HDL。希望大家帮帮忙,这个问题困扰很久很久了
|
|
相关推荐
2个回答
|
|
额。我设置的应该是不要积分的==,不知道为什么显示下载需要积分了
|
|
|
|
程序在下面。
/*--------------------------- 1602 LCD display ----------------------------*/ module LCD_1602 ( rst,clk,rs,rw,en,dataport ); input rst; input clk; output rs; output rw; output en; output [7:0] dataport; reg f_1MHZ; reg f_10K; reg state; reg state1; reg rs; reg rw; reg[4:0] count1; reg[7:0] count; reg[7:0] dataport; reg[3:0] counter; //reg[7:0] chara[3:0]; wire en; /////////////////////////////////////////////// parameter init = 1'b0, write_data = 1'b1; assign en = f_10K; /*--------------------------- 1MHZ frequency divided ----------------------------*/ always@(posedge clk ) begin if(count == 24) begin count <= 4'b0; f_1MHZ <= ~f_1MHZ; end else begin count <= count + 1'b1; f_1MHZ <= f_1MHZ; end end /*--------------------------- 10KHZ frequency divided ----------------------------*/ always@(posedge f_1MHZ ) begin if(count == 50) begin count1 <= 5'b0; f_10K <= ~f_10K; end else begin count1 <= count1 + 1'b1; f_10K <= f_10K; end end /*--------------------------- character obtain always @(posedge clk ) begin case(counter) 4'd0 : chara[counter] = "0" ; 4'd1 : chara[counter] = "1" ; 4'd2 : chara[counter] = "2" ; 4'd3 : chara[counter] = "3" ; // 4'd4 : chara[flag] = "4" ; // 4'd5 : chara[flag] = "5" ; // 4'd6 : chara[flag] = "6" ; // 4'd7 : chara[flag] = "7" ; // 4'd8 : chara[flag] = "8" ; // 4'd9 : chara[flag] = "9" ; endcase end ----------------------------*/ /*-------------------------- rst -------------------------*/ always@(posedge clk or negedge rst ) // rst begin if(!rst) state1 <= init; //如果复位case语句从init开始执行 else state1 <= state; //否则看state的状态 end /*--------------------------- LCD initialize ----------------------------*/ //initial begin always@(posedge f_10K ) // write command begin case(state1) init: begin rs <= 1'b0; //写命令 rw <= 1'b0; counter <= counter + 1'b1; case(counter) 1:dataport <= 8'h38; //display mode 2:dataport <= 8'h08; // close cursor 3:dataport <= 8'h01; //clear screen 4:dataport <= 8'h06; //cursor move set 5:dataport <= 8'h0c; //open display and cursor set 6: begin dataport <= 8'h80; //cursor location state <= write_data; counter <= 3'b000; //计数清零 end default : counter <= 3'b000; endcase end write_data: begin rs <= 1'b1; //写数据 rw <= 1'b0; counter <= counter + 1'b1; case(counter) 1:dataport <= "F"; 2:dataport <= "P"; 3:dataport <= "G"; 4:dataport <= "A"; 5:dataport <= ":"; 6:dataport <= " "; // 7:dataport = chara[0]; // 8:dataport = chara[1]; // 9:dataport = chara[2]; // 10:dataport = chara[3]; 7: begin rs <= 1'b0; dataport <= 8'h80; counter <= 3'b000; state <= init; //重新刷写字符 end default : counter <= 3'b000; endcase // if(counter == 10) // begin // counter = 0; // state = write_data_2; // end end default: state <= init; endcase end endmodule |
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
1446 浏览 1 评论
助力AIoT应用:在米尔FPGA开发板上实现Tiny YOLO V4
1061 浏览 0 评论
2525 浏览 1 评论
2217 浏览 0 评论
矩阵4x4个按键,如何把识别结果按编号01-16(十进制)显示在两个七段数码管上?
2486 浏览 0 评论
1939 浏览 53 评论
6023 浏览 113 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-26 02:18 , Processed in 0.509896 second(s), Total 76, Slave 57 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号