|
本帖最后由 taizhou1234 于 2013-11-29 15:08 编辑
testbench 文件
复位部分时序仿真
写命令和写数据时序仿真
全部初始化仿真波形
共享 ILI9325 液晶 VERILOG 初始化配置程序
module tft_control(
LCD_CS,
LCD_WR,
LCD_RS,
LCD_REST,
LCD_RD,
LCD_DataPort,
LCD_BK,
Sys_Clk,
Sys_Reset_N,
Control_Commend,
Control_Data,
Control_WR_RD_Direct,
Control_Data_IN_Valid,
Operate_State,
LCD_SRAM_DATA
);
output LCD_CS;
output LCD_WR;
output LCD_RS;
output LCD_REST;
output LCD_RD;
output [15:0] LCD_DataPort;
output LCD_BK;
input Sys_Clk;
input Sys_Reset_N; //低电平复位有效
/*
Control_Commend [3:0] = 0000; 无效命令
Control_Commend [3:0] = 0001; 复位TFT显示器
Control_Commend [3:0] = 0010; 发送命令模式 LCD_Write_COM(alt_u16 data)
Control_Commend [3:0] = 0011; 发送数据模式 LCD_Write_DATA(alt_u16 data)
Control_Commend [3:0] = 0100; 设置显示区域功能 Address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2)
Control_Commend [3:0] = 0101; 测试模式,控制显示器输出彩色条纹
Control_Commend [3:0] = 0110; 设置光标位置 LCD_SetCursor(unsigned char Xpos, unsigned char Ypos)
Control_Commend [3:0] = 0111; 读取TFT显示器中SRAM区域数据
Control_Commend [3:0] = 1000; TFT 背光打开
Control_Commend [3:0] = 1001; TFT 背光关闭
*/
input [3:0] Control_Commend;
input [15:0] Control_Data;
input Control_WR_RD_Direct;
input Control_Data_IN_Valid;
output Operate_State;
output [15:0] LCD_SRAM_DATA;
reg [15:0] LCD_Data_Temp;
wire [15:0] LCD_SRAM_DATA;
assign LCD_DataPort = LCD_Data_Temp;
// 检测控制命令有效的上升沿
reg Control_Data_IN_Valid_TMEP1;
reg Control_Data_IN_Valid_TMEP2;
wire New_Commend;
always@(posedge Sys_Clk)
begin
Control_Data_IN_Valid_TMEP1 <= Control_Data_IN_Valid;
Control_Data_IN_Valid_TMEP2 <= Control_Data_IN_Valid_TMEP1;
end
assign New_Commend = (~Control_Data_IN_Valid_TMEP2)&Control_Data_IN_Valid_TMEP1;
// 锁存控制命令
reg [3:0] Control_Commend_Reg1;
always@(posedge Sys_Clk)
Control_Commend_Reg1 <= Control_Commend;
//解析控制命令: 复位、写命令、写数据
reg [3:0] JieXi_STATE;
reg [1:0] Control_State;
reg RESET_START;
reg WRITE_DATA_START;
reg WRITE_COMMEND_START;
reg [3:0] Control_Commend_Reg;
reg Operate_State;
reg OPEN_BK;
reg RESET_END;
reg WRITE_COMMEND_END;
reg WRITE_DATA_END;
always@(negedge Sys_Clk or negedge Sys_Reset_N)
if(!Sys_Reset_N)
begin
Operate_State <= 1'b0;//为1时,正在操作,为0时,空闲
JieXi_STATE <= 0;
Control_State <= 0;
RESET_START <= 1'b0;
WRITE_DATA_START<= 1'b0;
WRITE_COMMEND_START <= 1'b0;
end
else
begin
case(JieXi_STATE)
0:
if(Control_Data_IN_Valid) //(New_Commend) //检测到新命令,进入到操作状态机中
begin
JieXi_STATE <= 1;
Control_Commend_Reg <= Control_Commend; //Control_Commend_Reg1;
Operate_State <= 1'b1; //为1时,正在操作,为0时,空闲
end
else
begin
Operate_State <= 1'b0; //为1时,正在操作,为0时,空闲
JieXi_STATE <= 0;
Control_State <= 0;
RESET_START <= 1'b0;
WRITE_DATA_START<= 1'b0;
WRITE_COMMEND_START <= 1'b0;
end
///////////////////进入复位操作///////////
1:
if(Control_Commend_Reg == 4'b0001) //复位TFT命令
begin
JieXi_STATE <= 2;
//Operate_State <= 1'b1; //为1时,正在操作,为0时,空闲
Control_State <= 0; //进入复位控制状态
RESET_START <= 1'b1;
end
else
JieXi_STATE <= 4; //跳转到下一个执行命令
2: begin
RESET_START <= 1'b1; //启动TFT复位控制状态机
JieXi_STATE <= 3;
end
3:
if(RESET_END) //判断复位是否结束
begin
//Operate_State <= 1'b0;
JieXi_STATE <= 4; //跳转到下一个执行命令
end
else
begin
RESET_START <= 1'b0;
JieXi_STATE <= 3; //等待复位结束
end
/////////////////////复位操作结束//////////////////
//////////////////控制TFT 写命令开始///////////////
4:
if(Control_Commend_Reg == 4'b0010) //发送命令模式 LCD_Write_COM(alt_u16 data)
begin
JieXi_STATE <= 5;
//Operate_State <= 1'b1; //为1时,正在操作,为0时,空闲
end
else
JieXi_STATE <= 7; //跳转到下一个执行命令
5: begin
Control_State <= 1; //进入控制TFT 写命令状态
WRITE_COMMEND_START <= 1'b1; //启动写命令状态机
JieXi_STATE <= 6;
end
6:
if(WRITE_COMMEND_END) //判断写命令是否结束
begin
//Operate_State <= 1'b0;
JieXi_STATE <= 7; //跳转到下一个执行命令
end
else
begin
WRITE_COMMEND_START <= 1'b0;
JieXi_STATE <= 6; //等待写命令结束
end
//////////////////控制TFT 写命令结束///////////////
7: //////////////////控制TFT 写数据开始///////////////
if(Control_Commend_Reg == 4'b0011) //发送数据模式 LCD_DATA(alt_u16 data)
begin
JieXi_STATE <= 8;
//Operate_State <= 1'b1; //为1时,正在操作,为0时,空闲
end
else
JieXi_STATE <= 10; //跳转到下一个执行命令
8: begin
Control_State <= 2; //进入控制TFT 写数据状态
WRITE_DATA_START<= 1'b1; //启动写命令状态机
JieXi_STATE <= 9;
end
9:
if(WRITE_DATA_END) //判断写数据是否结束
begin
//Operate_State <= 1'b0;
JieXi_STATE <= 10; //跳转到下一个执行命令
end
else
begin
WRITE_DATA_START<= 1'b0;
JieXi_STATE <= 9; //等待写数据结束
end
//////////////////控制TFT 写数据结束///////////////
10:if(Control_Commend_Reg == 4'b1000) //背光打开
begin
OPEN_BK <= 1'b1;
JieXi_STATE <= 11;
end
else
JieXi_STATE <= 11;
11:if(Control_Commend_Reg == 4'b1001) //背光关闭
begin
OPEN_BK <= 1'b0;
JieXi_STATE <= 0;
Operate_State <= 1'b0;
end
else
begin
JieXi_STATE <= 0;
Operate_State <= 1'b0;
end
default: JieXi_STATE <= 0;
endcase
end
///// 延时控制/////
reg [15:0] Delay_Count_TEMP1;
reg [15:0] Delay_Count_TEMP2;
//执行控制
reg [3:0] RESET_STATE;
reg [15:0] Delay_Count;
reg [2:0] WRITE_COMMEND_STATE;
reg [2:0] WRITE_DATA_STATE;
reg LCD_CS;
reg LCD_RD;
reg LCD_WR;
reg LCD_RS;
reg LCD_REST;
reg LCD_BK;
always@(posedge Sys_Clk or negedge Sys_Reset_N)
if(!Sys_Reset_N)
begin
RESET_STATE <= 0;
RESET_END <= 1'b1;
WRITE_COMMEND_END <= 1'b1;
WRITE_COMMEND_STATE <= 0;
WRITE_DATA_END <= 1'b1;
WRITE_DATA_STATE <= 0;
LCD_CS <= 1'b1;
LCD_RD <= 1'b1;
LCD_WR <= 1'b1;
LCD_RS <= 1'b1;
LCD_REST <= 1'b1;
end
else
case(Control_State)
0 : //控制TFT复位状态
case(RESET_STATE)
0 :
if(RESET_START) //其它模块控制
begin
RESET_STATE <= 1;
LCD_CS <= 1'b0;
LCD_RD <= 1'b1;
LCD_WR <= 1'b1;
LCD_RS <= 1'b1;
LCD_REST <= 1'b0;
RESET_END <= 1'b0;
end
else
begin
RESET_STATE <= 0;
//LCD_CS <= 1'b1;
LCD_REST <= 1'b1;
RESET_END <= 1'b1;
end
1: if(Delay_Count_TEMP1 < 16'h03f)
Delay_Count_TEMP1 <= Delay_Count_TEMP1 + 1'b1;
else
begin
Delay_Count_TEMP1 <= 0;
RESET_STATE <= 2;
end
2:
begin
LCD_REST <= 1'b1;
RESET_STATE <= 3;
end
3: if(Delay_Count_TEMP2 < 16'h03f)
Delay_Count_TEMP2 <= Delay_Count_TEMP2 + 1'b1;
else
begin
Delay_Count_TEMP2 <= 0;
RESET_STATE <= 0;
RESET_END <= 1'b1;
//LCD_CS <= 1'b1;
end
default:
begin
RESET_STATE <= 0;
LCD_REST <= 1'b1;
RESET_END <= 1'b1;
end
endcase
1://控制TFT 写命令
case(WRITE_COMMEND_STATE)
0:
if(WRITE_COMMEND_START)
begin
WRITE_COMMEND_STATE <= 1;
WRITE_COMMEND_END <= 1'b0;
end
else
begin
WRITE_COMMEND_STATE <= 0;
WRITE_COMMEND_END <= 1'b1;
end
1: begin
LCD_CS <= 1'b0;
LCD_RS <= 1'b0;
LCD_RD <= 1'b1;
LCD_REST <= 1'b1;
LCD_Data_Temp <= Control_Data; //将命令字发送给TFT
WRITE_COMMEND_STATE <= 2;
end
2: begin
LCD_WR <= 1'b0;
//LCD_CS <= 1'b0;
WRITE_COMMEND_STATE <= 3;
end
3: begin
LCD_WR <= 1'b1;
//LCD_CS <= 1'b1;
WRITE_COMMEND_STATE <= 4;
end
4: begin
WRITE_COMMEND_END <= 1'b1;
WRITE_COMMEND_STATE <= 0;
end
default: begin
LCD_WR <= 1'b1;
//LCD_CS <= 1'b1;
WRITE_COMMEND_STATE <= 0;
WRITE_COMMEND_END <= 1'b1;
end
endcase
2:
case(WRITE_DATA_STATE)
0:
if(WRITE_DATA_START)
begin
WRITE_DATA_STATE <= 1;
WRITE_DATA_END <= 1'b0;
end
else
begin
WRITE_DATA_STATE <= 0;
WRITE_DATA_END <= 1'b1;
end
1: begin
//LCD_CS <= 1'b1;
LCD_RS <= 1'b1;
LCD_RD <= 1'b1;
LCD_REST <= 1'b1;
LCD_Data_Temp <= Control_Data; //将命令字发送给TFT
WRITE_DATA_STATE <= 2;
end
2: begin
LCD_WR <= 1'b0;
//LCD_CS <= 1'b0;
WRITE_DATA_STATE <= 3;
end
3: begin
LCD_WR <= 1'b1;
//LCD_CS <= 1'b1;
WRITE_DATA_STATE <= 4;
end
4: begin
WRITE_DATA_END <= 1'b1;
WRITE_DATA_STATE <= 0;
LCD_CS <= 1'b1;
end
default:
begin
LCD_WR <= 1'b1;
WRITE_DATA_STATE <= 0;
WRITE_DATA_END <= 1'b1;
end
endcase
3: //背光打开或关闭
if(OPEN_BK) //背光打开
begin
//LCD_CS <= 1'b0;
LCD_BK <= 1'b1;
LCD_REST <= 1'b1;
end
else //背光关闭
begin
//LCD_CS <= 1'b0;
LCD_BK <= 1'b0;
LCD_REST <= 1'b1;
end
default:;
endcase
endmodule
////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
/*
Control_Commend [3:0] = 0000; 无效命令
Control_Commend [3:0] = 0001; 复位TFT显示器
Control_Commend [3:0] = 0010; 发送命令模式 LCD_Write_COM(alt_u16 data)
Control_Commend [3:0] = 0011; 发送数据模式 LCD_Write_DATA(alt_u16 data)
Control_Commend [3:0] = 0100; 设置显示区域功能 Address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2)
Control_Commend [3:0] = 0101; 测试模式,控制显示器输出彩色条纹
Control_Commend [3:0] = 0110; 设置光标位置 LCD_SetCursor(unsigned char Xpos, unsigned char Ypos)
Control_Commend [3:0] = 0111; 读取TFT显示器中SRAM区域数据
Control_Commend [3:0] = 1000; TFT 背光打开
Control_Commend [3:0] = 1001; TFT 背光关闭
*/
/*
TFT 应用层程序
*/
module tft_top(
LCD_CS,
LCD_WR,
LCD_RS,
LCD_REST,
LCD_RD,
LCD_DataPort,
INIT_OV7670_SWITCH,
TFT_INIT_FINISH,
Clk_100MHZ,
Sys_Reset_N,
START_INIT_TFT,
TFT_CTRL_CLK,
LCD_BK,
TFT_WR_RD
);
output LCD_CS;
output LCD_WR;
output LCD_RS;
output LCD_REST;
output LCD_RD;
output [15:0] LCD_DataPort;
output [1:0] INIT_OV7670_SWITCH;
input Clk_100MHZ;
input Sys_Reset_N;
output TFT_INIT_FINISH; //高电平输出表示初始化结束,低电平时表示正在初始化
input START_INIT_TFT; //高电平时TFT初始化,低电平时,不进行初始化
output TFT_CTRL_CLK;
output LCD_BK;
output TFT_WR_RD;
//如果要控制模块进行初始化,可以先判断 TFT_INIT_FINISH 是否为高电平,如果为高电平,
//设置 START_INIT_TFT 为高电平,则模块进入初始化状态。设置高电平后需要拉回低电平
// START_INIT_TFT 为高电平宽度以 TFT_CTRL_CLK 时钟为准
// 定义颜色
parameter BLACK = 16'h0000; /* 黑色: 0, 0, 0 */
parameter BLUE = 16'h001F; /* 蓝色: 0, 0, 255 */
parameter GREEN = 16'h07E0; /* 绿色: 0, 255, 0 */
parameter CYAN = 16'h07FF; /* 青色: 0, 255, 255 */
parameter RED = 16'hF800; /* 红色: 255, 0, 0 */
parameter MAGENTA = 16'hF81F; /* 品红: 255, 0, 255 */
parameter YELLOW = 16'hFFE0; /* 黄色: 255, 255, 0 */
parameter WHITE = 16'hFFFF; /* 白色: 255, 255, 255 */
parameter NAVY = 16'h000F; /* 深蓝色: 0, 0, 128 */
parameter DGREEN = 16'h03E0; /* 深绿色: 0, 128, 0 */
parameter DCYAN = 16'h03EF; /* 深青色: 0, 128, 128 */
parameter MAROON = 16'h7800; /* 深红色:128, 0, 0 */
parameter PURPLE = 16'h780F; /* 紫色: 128, 0, 128 */
parameter OLIVE = 16'h7BE0; /* 橄榄绿:128, 128, 0 */
parameter LGRAY = 16'hC618; /* 灰白色:192, 192, 192 */
parameter DGRAY = 16'h7BEF; /* 深灰色:128, 128, 128 */
parameter LBLUE = 16'h3BD0; /* 浅蓝色: */
parameter LRED = 16'hF44F; /* 浅红色: */
parameter LGREEN = 16'h8F12; /* 浅绿色: */
// Clock Setting
parameter CLK_Freq = 50000000;//100000000; // 100 MHz
parameter TFT_Freq = 500000; // 10000 = 100us KHz
parameter MAXIN_INDEX = 56;
///////////////////// TFT Control Clock ////////////////////////
reg TFT_CTRL_CLK;
reg [15:0] TFT_CLK_DIV;
// 产生TFT控制时钟信号
always@(posedge Clk_100MHZ or negedge Sys_Reset_N)
if(!Sys_Reset_N)
begin
TFT_CTRL_CLK <= 0;
TFT_CLK_DIV <= 0;
end
else
begin
if( TFT_CLK_DIV < (CLK_Freq/TFT_Freq) )
TFT_CLK_DIV <= TFT_CLK_DIV + 1'b1;
else
begin
TFT_CLK_DIV <= 0;
TFT_CTRL_CLK <= ~TFT_CTRL_CLK;
end
end
//调用底层TFT 控制程序
tft_control u0(
.LCD_CS(LCD_CS),
.LCD_WR(LCD_WR),
.LCD_RS(LCD_RS),
.LCD_REST(LCD_REST),
.LCD_RD(LCD_RD),
.LCD_DataPort(LCD_DataPort),
.LCD_BK(LCD_BK),
.Sys_Clk(TFT_CTRL_CLK),
.Sys_Reset_N(Sys_Reset_N),
.Control_Commend(Control_Commend),
.Control_Data(Control_Data),
.Control_WR_RD_Direct(Control_WR_RD_Direct),
.Control_Data_IN_Valid(Control_Data_IN_Valid),
.Operate_State(Operate_State),
.LCD_SRAM_DATA(LCD_SRAM_DATA)
);
//彩条颜色设置
wire [15:0] TFT_DATA_CAI_TIAO;
wire Operate_State;
wire [15:0] LCD_SRAM_DATA;
reg TFT_INIT_FINISH;
reg [3:0] Control_Commend;
reg Control_WR_RD_Direct;
reg Control_Data_IN_Valid;
reg [15:0] Control_Data;
reg [4:0] YingYong_State;
reg [5:0] TFT_LUT_INDEX;
reg [31:0] TFT_LUT_DATA_REG32;
reg [8:0] Hang_Total;
reg [8:0] Lie_Total;
reg [1:0] INIT_OV7670_SWITCH;
reg [15:0] JiCunQi_Delay;
reg [31:0] TFT_LUT_DATA;
//assign TFT_DATA_CAI_TIAO = (Hang_Total<80)? BLUE :((Hang_Total>=80)&&(Hang_Total<160))? RED :(Hang_Total>=160)?DGREEN:PURPLE;
assign TFT_DATA_CAI_TIAO[15:0] = (Hang_Total[8:0]<100)? 16'h001F :16'hF44F;
assign TFT_WR_RD = Control_WR_RD_Direct;
///////////////////////////////////////////////////////////
// TFT 应用层操作
always@(posedge TFT_CTRL_CLK or negedge Sys_Reset_N)
if(!Sys_Reset_N)
begin
YingYong_State <= 0;
TFT_LUT_INDEX <= 0;
TFT_INIT_FINISH <= 1'b0;
Control_Data_IN_Valid <= 1'b0;
Control_WR_RD_Direct <= 1'b1;
Control_Commend <= 4'b0000;
INIT_OV7670_SWITCH <= 2'b01; // 初始配置到TFT 初始化控制部分
JiCunQi_Delay <= 0;
end
else
case(YingYong_State)
0: begin
Control_WR_RD_Direct <= 1'b1; //为写状态
Control_Commend <= 4'b0001; //复位命令
Control_Data_IN_Valid <= 1'b1; //使能命令有效
Control_Data <= 16'h0000;
YingYong_State <= 1;
TFT_INIT_FINISH <= 1'b0;
INIT_OV7670_SWITCH <= 2'b01; //初始配置到TFT 初始化控制部分
TFT_LUT_INDEX <=0;
end
1: begin
Control_Data_IN_Valid <= 1'b0; //使能命令无效
YingYong_State <= 2;
end
2:
YingYong_State <= 3;
3:
if(!Operate_State) //为1时,正在操作,为0时,空闲
YingYong_State <= 4; //复位操作结束
else
YingYong_State <= 3; //等待复位操作结束
//复位结束,开始初始化液晶屏
4: if(TFT_LUT_INDEX[5:0] < 6'd56)
begin
TFT_LUT_DATA_REG32 <= TFT_LUT_DATA; //读取索引表中数据
YingYong_State <= 5;
end
else
YingYong_State <= 11; //表示初始化完成,进入到下一步操作
5: begin
Control_Commend <= 4'b0010; //进入写命令模式
Control_Data[15:0] <= TFT_LUT_DATA_REG32[31:16]; //读取命令值
Control_Data_IN_Valid <= 1'b1; //使能信号
YingYong_State <= 6;
end
6: begin
YingYong_State <= 7;
Control_Data_IN_Valid <= 1'b0;
end
7:
if(!Operate_State)
YingYong_State <= 8;
else
YingYong_State <= 7;
8: begin
Control_Commend <= 4'b0011; //进入写数据模式
Control_Data[15:0] <= TFT_LUT_DATA_REG32[15:0]; //读取命令值
Control_Data_IN_Valid <= 1'b1;
YingYong_State <= 9;
end
9: begin
YingYong_State <= 10;
Control_Data_IN_Valid <= 1'b0;
end
10:
if(!Operate_State)
YingYong_State <= 21; //跳转到21状态,判断是否当前寄存器操作后需要延时
else
YingYong_State <= 10;
//////////初始化完成///////////
// 设置显示位置/// LCD_Write_COM(0x0022);
11: if(!Operate_State)
begin
Control_Commend <= 4'b0010; //进入写命令模式
Control_Data[15:0] <= 16'h0022; //读取命令值
YingYong_State <= 12;
Control_Data_IN_Valid <= 1'b1;
end
else
YingYong_State <= 11;
12: begin
YingYong_State <= 13;
Control_Data_IN_Valid <= 1'b0; //使能信号
end
13:
if(!Operate_State)
YingYong_State <= 14;
else
YingYong_State <= 13;
/////////////////////////////////////////////////
/// 显示彩条颜色
14:if(Lie_Total < 319)
YingYong_State <= 15;
else
YingYong_State <= 19; //彩条显示结束
15:if(Hang_Total < 239)
YingYong_State <= 16;
else
begin
YingYong_State <= 14;
Lie_Total <= Lie_Total + 1'b1;
end
16: begin
Control_Commend <= 4'b0011; //进入写数据模式
Control_Data[15:0] <= TFT_DATA_CAI_TIAO[15:0]; //显示彩条数据
Control_Data_IN_Valid <= 1'b1;
YingYong_State <= 17;
end
17: begin
YingYong_State <= 18;
Control_Data_IN_Valid <= 1'b0;
end
18: begin
if(!Operate_State)
begin
YingYong_State <= 15;
Hang_Total <= Hang_Total + 1'b1;
end
else
YingYong_State <= 18;
end
19: begin
YingYong_State <= 20;
TFT_INIT_FINISH <= 1'b1;
INIT_OV7670_SWITCH <= 2'b10; // 切换到OV7670显示 2'b10
end
20:
if(START_INIT_TFT)
YingYong_State <= 0;
else
YingYong_State <= 20;
//////////////////////////////////////////////////////////////
//延时状态, 在初始化的某些寄存器配置好后需要进行延时
21:
if((TFT_LUT_INDEX == 6'd1)|(TFT_LUT_INDEX == 6'd15)|(TFT_LUT_INDEX == 6'd16)|(TFT_LUT_INDEX == 6'd17)|(TFT_LUT_INDEX == 6'd50)|(TFT_LUT_INDEX == 6'd13)|(TFT_LUT_INDEX == 6'd56))
begin
TFT_LUT_INDEX <= TFT_LUT_INDEX + 1'b1;
YingYong_State <= 22; //需要延时,进入延时状态
end
else
begin
TFT_LUT_INDEX <= TFT_LUT_INDEX + 1'b1;
YingYong_State <= 4; //不需要延时,则跳转到下一个寄存器写状态
end
22:
if(JiCunQi_Delay < 16'h0FF) //延时200ms
JiCunQi_Delay <= JiCunQi_Delay + 1'b1;
else
begin
JiCunQi_Delay <= 0;
YingYong_State <= 4;
end
default:YingYong_State <= 0;
endcase
always@(*)
begin
case(TFT_LUT_INDEX)
//************* Start Initial Sequence **********//
0: TFT_LUT_DATA <= {16'h00E5,16'h8000}; //oscillation control
1: TFT_LUT_DATA <= {16'h0000,16'hffff}; //oscillation control
//delayms(200);
2: TFT_LUT_DATA <= {16'h0001,16'h0100}; //oscillation control
3: TFT_LUT_DATA <= {16'h0002,16'hffff}; // 1: TFT_LUT_DATA <= {16'h0002,16'h0700};
4: TFT_LUT_DATA <= {16'h0003,16'h1018}; // entry mode 0x1028
5: TFT_LUT_DATA <= {16'h0004,16'h0000}; //resize control
6: TFT_LUT_DATA <= {16'h0008,16'h0202}; // display control// set fp,bp
7: TFT_LUT_DATA <= {16'h0009,16'h0000}; // display control
8: TFT_LUT_DATA <= {16'h000a,16'h0000}; //display control 4
9: TFT_LUT_DATA <= {16'h000c,16'h0001}; //rgb display interface control//RGB interface 16bit 静态的图片,动态的需要设置为dm和rm
10: TFT_LUT_DATA <= {16'h000d,16'h0000}; //frame marker position
11: TFT_LUT_DATA <= {16'h000F,16'h0000}; // rgb display interface control
//power on
12: TFT_LUT_DATA <= {16'h0010,16'h17b0}; //power control 1
13: TFT_LUT_DATA <= {16'h0011,16'h0137}; //power control 2
14: TFT_LUT_DATA <= {16'h0012,16'h0139}; //power control 3
//set pon vcmr=1,pson=0;set vrh3-0
15: TFT_LUT_DATA <= {16'h0013,16'h1B00}; //power control 4
//set vdv3-0
//delayms(200};
//////////////////////
// 1: TFT_LUT_DATA <= {16'h0010,16'h0000}; //power control 1
//set bt
// 1: TFT_LUT_DATA <= {16'h0011,16'h0007}; //power control 2
//set vrc2-0
//delayms(50};
// 1: TFT_LUT_DATA <= {16'h0012,16'h0000}; //power control 3
//set pon vcmr=1,pson=0;set vrh3-0
//delayms(50};
16: TFT_LUT_DATA <= {16'h0013,16'h0000}; //power control 4
//set vdv3-0
//delayms(200};
17: TFT_LUT_DATA <= {16'h0029,16'h0011}; //power control 7:
//delayms(50};
//end power on
18: TFT_LUT_DATA <= {16'h0020,16'h0000}; // GRAM address set
// horizontal address set
19: TFT_LUT_DATA <= {16'h0021,16'h0000};
//set gamma value
20: TFT_LUT_DATA <= {16'h0030,16'h0504}; // Gamma control (1)
21: TFT_LUT_DATA <= {16'h0031,16'h0703}; // Gamma control (2)
22: TFT_LUT_DATA <= {16'h0032,16'h0702}; // Gamma control (3)
23: TFT_LUT_DATA <= {16'h0035,16'h0101}; // Gamma control (6)
24: TFT_LUT_DATA <= {16'h0036,16'h0a1F}; // Gamma control (7)
25: TFT_LUT_DATA <= {16'h0037,16'h0504}; // Gamma control (8)
26: TFT_LUT_DATA <= {16'h0038,16'h0003}; // Gamma control (9)
27: TFT_LUT_DATA <= {16'h0039,16'h0706}; // Gamma control (10)
28: TFT_LUT_DATA <= {16'h003C,16'h0707}; // Gamma control (11)
29: TFT_LUT_DATA <= {16'h003D,16'h091f}; // Gamma control (12)
//SET GRAM AREA
30: TFT_LUT_DATA <= {16'h0050,16'h0000}; //horizontal address start position
31: TFT_LUT_DATA <= {16'h0051,16'h00EF}; //horizontal address end position
32: TFT_LUT_DATA <= {16'h0052,16'h0000}; //vertical address start position
33: TFT_LUT_DATA <= {16'h0053,16'h013F}; //vertical address end position
34: TFT_LUT_DATA <= {16'h0060,16'h2700}; //driver output control
35: TFT_LUT_DATA <= {16'h0061,16'h0001}; //base image display control
36: TFT_LUT_DATA <= {16'h006A,16'h0000}; //vertical scroll control
//Partial displsy control
37: TFT_LUT_DATA <= {16'h0076,16'h00d0};
38: TFT_LUT_DATA <= {16'h0080,16'h0000}; //partial image 1 display position
39: TFT_LUT_DATA <= {16'h0081,16'h0000};
40: TFT_LUT_DATA <= {16'h0082,16'h0000};
41: TFT_LUT_DATA <= {16'h0083,16'h0000};
42: TFT_LUT_DATA <= {16'h0084,16'h0000};
43: TFT_LUT_DATA <= {16'h0085,16'h0000};
//panel interface control
44: TFT_LUT_DATA <= {16'h0090,16'h0010};
45: TFT_LUT_DATA <= {16'h0092,16'h0600};
46: TFT_LUT_DATA <= {16'h0093,16'h0003};
47: TFT_LUT_DATA <= {16'h0095,16'h0110};
48: TFT_LUT_DATA <= {16'h0097,16'h0000};
49: TFT_LUT_DATA <= {16'h0098,16'h0000};
//display on
50: TFT_LUT_DATA <= {16'h0007,16'h0173};//1: TFT_LUT_DATA <= {16'h0007,16'h0173};
// delayms(20};
// delayms(50};
// IOWR_ALTERA_AVALON_PIO_DATA(LCD_CS_BASE,1}; //关闭片选使能
/////设置显示窗口
/*
LCD_Write_COM(0x0020);LCD_Write_DATA(0); //设置X坐标位置
LCD_Write_COM(0x0021);LCD_Write_DATA(0); //设置Y坐标位置
LCD_Write_COM(0x0050);LCD_Write_DATA(0); //开始X
LCD_Write_COM(0x0052);LCD_Write_DATA(0); //开始Y
LCD_Write_COM(0x0051);LCD_Write_DATA(239); //结束X
LCD_Write_COM(0x0053);LCD_Write_DATA(319); //结束Y
*/
51: TFT_LUT_DATA <= {16'h0020,16'h0000};
52: TFT_LUT_DATA <= {16'h0021,16'h0000};
53: TFT_LUT_DATA <= {16'h0050,16'h0000};
54: TFT_LUT_DATA <= {16'h0052,16'h0000};
55: TFT_LUT_DATA <= {16'h0051,16'h00EF};
56: TFT_LUT_DATA <= {16'h0053,16'h013F};
default: TFT_LUT_DATA <= {16'h0000,16'hffff}; //oscillation control
endcase
end
endmodule
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|