|
小弟最近在用CycloneII:ep2c5q208c8的FPGA驱动驱动群创4.3寸TFT液晶,(24位RGB)在满屏显示一种颜色的时候出现了一个奇怪的问题:当设定一个背景色如:24'0000ff时,理应显示红色,但在液晶上显示时,第一帧画面显示的是红色,第二帧显示的却是淡蓝色,然后又显示红色,又淡蓝色,如此往复 当将RGB值设为黑色时,液晶第一帧画面显示的是黑色,第二帧显示的是白,如此往复。我怀疑是RGB值被取反了,搞不懂为什么会出现这种情况,还望坛里大虾帮帮忙。现将程序贴出来:
module tft(clk_9m,disp_enable,hsync,vsync,de,disp_rgb);
input clk_9m;
//input clk;
//input rst_n;
output disp_enable;
output hsync;
output vsync;
output de;
output [23:0] disp_rgb;
reg [23:0] disp_rgb=24'hzzzzzz;
reg [9:0] hcount=10'd0;
reg [9:0] vcount=10'd0;
//reg [23:0] disp_rgb_r;
//wire clk_9m;
wire dat_act;
wire hcount_over;
wire vcount_over;
//reg hcount_over_r;
//reg vcount_over_r;
parameter Hsync_end=10'd40;
parameter Hdata_begin=10'd42;
parameter Hdata_end=10'd523;
parameter Hpixel_end=10'd524;
parameter Vsync_end=10'd0;
parameter Vdata_begin=10'd0;
parameter Vdata_end=10'd283;
parameter Vline_end=10'd285;
//clock cc(clk,rst_n,clk_9m);
//???
always @(posedge clk_9m )
begin
if(hcount_over)
hcount<=10'd0;
else
hcount<=hcount+10'd1;
end
assign hcount_over=(hcount==Hpixel_end);
//???
always @(posedge hcount_over )
begin
if(hcount_over)
begin
if(vcount_over)
vcount<=10'd0;
else
vcount<=vcount+10'd1;
end
end
//assign hcount_over=hcount_over_r;
//assign vcount_over=vcount_over_r;
//always @(posedge clk)
//begin
// hcount_over_r<=(hcount==Hpixel_end);
// vcount_over_r<=(vcount==Vline_end);
//end
assign vcount_over=(vcount==Vline_end);
assign dat_act=((hcount>=Hdata_begin)&&(hcount<Hdata_end))&&((vcount>=Vdata_begin)&&(vcount<Vdata_end));
assign hsync=(hcount>Hsync_end);
assign vsync=(vcount>Vsync_end);
assign de =(hcount>Hdata_begin)&&(hcount<Hdata_end);
assign disp_enable=1'b1;
//assign disp_rgb=dat_act? 24'hffffff:24'hff0000;
//assign disp_rgb=24'hff00ff;
always @(negedge clk_9m)
begin
if(de) begin
if(dat_act)
disp_rgb<=24'h00ff00;
else disp_rgb<=24'hffffff;
end
end
endmodule |
阿莫论坛20周年了!感谢大家的支持与爱护!!
知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)
|