Home » Source Code » Verilog LCD1602 » LCD1602.v

LCD1602.v ( File view )

  • By 1601015340 2016-04-01
  • View(s):0
  • Download(s):0
  • Point(s): 1
			module LCD1602(CLK_50M,RST_,lcd_en,lcd_rw,lcd_rs,lcd_data,lcd_on,lcd_bg);
input CLK_50M,RST_;
output lcd_en,lcd_rw,lcd_rs,lcd_on,lcd_bg;
output reg [7:0] lcd_data;
reg lcd_rw,lcd_rs,clk4hz,lcd_on;
reg [10:0] state;
reg [6:0] count;
reg [5:0] disp_count;reg [23:0] cnt;reg [255:0] data_in_buf;
parameter CLEAR =8'b0000_0001;
parameter SETCGRAM=8'B0000_0010;
parameter SETFUNCTION=8'B0000_0100;
parameter SWITCHMODE=8'B0000_1000;
parameter RETURNCURSOR=8'B0001_0000;
parameter SETMODE=8'B0010_0000;
parameter SHIFT=8'B0100_0000;
parameter WRITERAM=8'B1000_0000;
parameter CUR_INC = 1;
parameter CUR_NOSHIFT =0;
parameter OPEN_DISPLAY = 1;
parameter OPEN_CUR = 0;
parameter BLANK_CUR =0;
parameter DATAWIDTH8 =1;
parameter DATAWIDTH4 =0;
parameter TWOLINE =1;
parameter ONELINE =0;
parameter FONT5X10 =1;
parameter FONT5X7 =0;
parameter DATA_IN =" displays! ";
assign lcd_bg=1;
always @(posedge CLK_50M)
 begin 
 if(cnt==23'h505F4E10)
 begin cnt<=0;clk4hz<=~clk4hz;end
 else cnt<=cnt+1;
 end
assign lcd_en=clk4hz;
always @(posedge clk4hz,negedge RST_)
 if(!RST_)
  begin state<=CLEAR;
  lcd_on<=0;disp_count<=6'b0;
  end
  else begin 
  lcd_on<=1;
  case(state)
  CLEAR:begin lcd_rs<=0;
              lcd_rw<=0;
				  lcd_data<=8'b0000_0001;
				  data_in_buf<=DATA_IN;
				  state<=SETCGRAM;
				  end
  SETCGRAM:begin 
              lcd_rs<=0;
				  lcd_rw<=0;
				  lcd_data<=8'b1000_0000;
				  state<=SETFUNCTION;
				  end
  SETFUNCTION:begin 
              lcd_rs<=0;
				  lcd_rw<=0;
				  lcd_data[7:5]<=3'b001;
				  lcd_data[4]<=DATAWIDTH8;
               lcd_data[3]<=TWOLINE;
					lcd_data[2]<=FONT5X10;
					lcd_data[1:0]<=2'b00;
					state<=SWITCHMODE;
					end
  SWITCHMODE:begin 
              lcd_rs<=0;
				  lcd_rw<=0;
				  lcd_data[7:3]<=5'b00001;
				  lcd_data[2]<=OPEN_DISPLAY;
				  lcd_data[1]<=OPEN_CUR;
				  lcd_data[0]<=BLANK_CUR;
				  state<=SETMODE;
				  end
  SETMODE:begin 
              lcd_rs<=0;
				  lcd_rw<=0;
				  lcd_data[7:2]<
...
...
(Please download the complete source code to view)
			
...
Expand> <Close

Want complete source code? Download it here

Point(s): 1

Download
0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
01.97 kB
LCD1602.v3.00 kB2016-04-01|15:39
...
Sponsored links

LCD1602.v (1.16 kB)

Need 1 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D