打印
[FPGA]

FPGA驱动HT1621的问题

[复制链接]
786|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
Cjy_JDxy|  楼主 | 2018-5-11 20:05 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
先上程序:
module ht1621
                                (
                        input        clk,
                        input        rst_n,
                        output reg         sdio,
                        output reg         sclk,
                        output reg         stb
                                );




reg [15:0] olddata;
reg [4:0] currentstate;
parameter s1 = 5'b0_0001;
parameter s2 = 5'b0_0010;//设置工作模式
parameter s3 = 5'b0_0011;
parameter s4 = 5'b0_0100;//固定地址写数据
parameter s5 = 5'b0_0101;//
parameter s6 = 5'b0_0110;//S6和S5状态设置扫描限值寄存器
parameter s7 = 4'b0_0111;//
parameter s8 = 5'b0_1000; //S7和S8状态 设置正常显示模式
parameter s10 =5'b0_1010;//
parameter s11 =5'b0_1011;//s10和是1状态 送入显示的数据
parameter Init=5'b1_1110;
parameter Init1=5'b1_1111;


reg [5:0]counter;


parameter         
                        seg1 = 16'h14ab,
                        seg2 = 16'h14bc,
                        seg3 = 16'h14cd,                                //1.
                        seg4 = 16'h14de,                                //2
                        seg5 = 16'h14ef,                                //3
                        seg6 = 16'h14ff;                                //4
                       
reg [2:0]cnt;

//产生时钟
always @(posedge clk)
begin
  if(!rst_n) begin
                counter<=6'd0;
                sclk <= 1'b1;
    end
  else begin
    if(counter==6'd32) begin
      sclk <= ~sclk;
      counter<=6'd0;
      end
    else counter<=counter+6'd1;
    end
end

reg [3:0] sclk_cnt;//同步时钟计数器,15
always @(posedge sclk or negedge rst_n)
begin
        if(!rst_n) sclk_cnt <= 1'b0;
        else
        case(currentstate)
                Init1,s2,s4,s6,s8,s11:
                        if(4'd15  == sclk_cnt)
                                        sclk_cnt <= 1'b0;
                        else         sclk_cnt <= sclk_cnt + 1'b1;
                default: sclk_cnt <= 1'b0;
        endcase
end

reg [15:0] data;
//主状态机
always @(posedge sclk or negedge rst_n)
begin
        if(!rst_n) begin currentstate <=Init; cnt = 3'b0; end
        else
        case(currentstate)
        Init:currentstate <=Init1;
        Init1:begin
                        if(4'd15 == sclk_cnt) //16个时钟周期将数据送出去
                                currentstate <= s7;
                        else
                                currentstate <= Init1;
                end
        s1: currentstate <= s2;  //s1和S2状态设置译码寄存器       
        s2:begin
                        if(4'd15 == sclk_cnt) //16个时钟周期将数据送出去
                                currentstate <= s3;
                        else
                                currentstate <= s2;
                end
        s3: currentstate <= s4;//S3和S4状态设置亮度寄存器
        s4: begin
                        if(4'd15 == sclk_cnt) //16个时钟周期将数据送出去
                                currentstate <= s5;
                        else
                                currentstate <= s4;       
                end       
        s5: currentstate <= s6;//        S6和S5状态设置扫描限值寄存器
        s6: begin
                        if(4'd15 == sclk_cnt) //16个时钟周期将数据送出去
                                currentstate <= s10;
                        else
                   currentstate <= s6;
                end
        s7: currentstate <= s8;//        S7和S8状态 设置正常显示模式
        s8: begin
                        if(4'd15 == sclk_cnt) //16个时钟周期将数据送出去
                                currentstate <= s1;
                        else
                   currentstate <= s8;
                end
       
        //初始化完成         
        s10: if(olddata != data)
                                currentstate <= s11;//        正常送数据显示
                  else
                                currentstate <= s10;
        s11: begin
                        if(4'd15 == sclk_cnt) //16个时钟周期将数据送出去
                                begin
                                        currentstate <= s10;
                                        cnt = cnt + 1'b1;
                                end       
                        else
                   currentstate <= s11;
                end         
        endcase
end
always @(posedge sclk or negedge rst_n)
begin
        if(!rst_n)begin  data <= 16'h0000; olddata <= 16'h0000; end
        else case(currentstate)
                Init:data <= 16'h0852;                //0b1000 0101 0010 1/3duty 4com
                s7: data <= 16'h0830;   //0b1000 0011 0000 内部时钟
                s1: data <= 16'h080A;        //0b1000 0000 1010 禁止看门狗
           s3: data <= 16'h0802;        //0b1000 0000 0010 打开系统振荡器
                s5: data <= 16'h0806;   //0b1000 0000 0110 打开LCD偏压
               
                s10: begin
                        case(cnt)
                        3'd0: data <= seg1;
                        3'd1: data <= seg2;
                        3'd2: data <= seg3;
                        3'd3: data <= seg4;
                        3'd4: data <= seg5;
                        3'd5: data <= seg6;
                       
                        endcase

                        olddata <= data;
                end//{4'b0000,dd,4'b000,dd};olddata <=16'h0c01;end//{4'b0000,4'd4,8'd6};olddata <= {4'b0000,4'd4,8'd6};;;end//16'h080e;  //待显示的数据
                Init1,s2,s4,s6,s8,s11: begin data <= data << 1;        olddata <= olddata; end//循环移位 将高位送出
                default: begin data <= 16'h0000; olddata <= olddata; end
        endcase
end
//----------数据串行---------
always @(posedge sclk or negedge rst_n)
begin
        if(!rst_n) sdio <= 1'b0;
        else case(currentstate)
                Init1,s2,s4,s6,s8,s11: sdio <= data[15];
                default: sdio <= 1'b0;
        endcase
end
//----------串行数据写有效LOAD----------
always @(posedge sclk or negedge rst_n)
begin
        if(!rst_n) stb <= 1'b1;
        else case(currentstate)
                Init1,s2,s4,s6,s8,s11: stb <= 1'b0;  //送数的时候处于低
                default: stb <= 1'b1; //非送数时候,拉高 锁存数据
        endcase
end


endmodule
可是下载到板子里,液晶一段也不亮。
请高手看看,哪里有问题。谢谢!

相关帖子

沙发
xushuo888| | 2018-8-2 17:55 | 只看该作者
之前用过可以替代的型号 VK1621B SSOP48 LQFP48 LQFP44 DIP28,完全兼容替代HT1621B 全部封装
我有IC 资料和驱动程序,我发给你。

VK1621B-LCD液晶显示驱动IC.pdf

1.41 MB

VK1622B LQFP48液晶驅動IC.pdf

600.82 KB

VK1622液晶驱动IC资料.pdf

623.5 KB

使用特权

评论回复
板凳
Cjy_JDxy|  楼主 | 2018-8-3 08:06 | 只看该作者
xushuo888 发表于 2018-8-2 17:55
之前用过可以替代的型号 VK1621B SSOP48 LQFP48 LQFP44 DIP28,完全兼容替代HT1621B 全部封装
我有IC 资料 ...

谢谢!你怎么发呢?
我QQ:413132614
邮箱:chenbingspll@163.com

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:绿水本无忧因风皱面,青山原不老为雪白头。

553

主题

3520

帖子

19

粉丝