• 黑金开发板板上实现的液晶刷屏程序(1)


    1、首先介绍一下手中的资源配置

    (声明:本人只是黑金开发板的用户,并非黑金技术支持

      FPGA芯片型号:Cyclone IV,EP4CE15

      液晶参数:SSD1289,320*240,RGB(565)

      开发板from:黑金淘宝官网

      TFT液晶from:黑金淘宝官网

    2、向上一张贴图:

      

    3、贴上自己的源码:

      1)显示部分代码:

      1 module TFT(
      2     //system
      3     CLK,
      4     RSTn,
      5     //tft signal
      6     LCD_CS,
      7     LCD_RS,
      8     LCD_RD,
      9     LCD_WR,
     10     LCD_RST,
     11     LCD_DATA
     12 );
     13     
     14     input             CLK;
     15     input             RSTn;
     16     //TIF signal wire
     17     output            LCD_CS;
     18     output            LCD_RS;
     19     output             LCD_RD;
     20     output             LCD_WR;
     21     output            LCD_RST;
     22     output [15:0]    LCD_DATA;
     23     
     24     reg                LCD_CS;
     25     reg                LCD_RS;
     26     reg                LCD_WR;
     27     reg        [15:0]    LCD_DATA;
     28     
     29     assign LCD_RD     = 1'b1;
     30     assign LCD_RST     = 1'b1;
     31         
     32     reg [3:0]        state_lcd_write;
     33     reg [7:0]        addr_command;
     34     reg    [16:0]        LCD_DATA_TEMP;
     35     reg [31:0]        count_dot;
     36     reg [15:0]        count_delay;
     37     always @(posedge CLK or negedge RSTn)
     38     if(!RSTn)
     39         begin
     40             state_lcd_write <= 4'd0;
     41             LCD_CS <= 1'b1;
     42             LCD_WR <= 1'b1;
     43             LCD_RS <= 1'b0;
     44             LCD_DATA <= 16'd0;
     45             addr_command <= 8'd0;
     46             LCD_DATA_TEMP <= 17'd0;
     47             count_dot <= 16'd0;
     48             count_delay <= 16'd0;
     49         end
     50     else
     51         begin
     52         case(state_lcd_write)
     53             4'd0:
     54                 if(count_delay == 16'd2499)//init delay
     55                     begin
     56                         state_lcd_write <= 4'd1;
     57                         count_delay <= 16'd0;
     58                     end
     59                 else
     60                     begin
     61                     state_lcd_write <= 4'd0;
     62                     count_delay <= count_delay + 1'b1;
     63                     end
     64             4'd1:
     65                 if(count_delay == 16'd999)//dot delay
     66                     begin
     67                         state_lcd_write <= 4'd2;
     68                         LCD_CS        <= 1'b1;
     69                         LCD_WR        <= 1'b1;
     70                         LCD_DATA_TEMP<=display_command(addr_command);
     71                         count_delay <= 16'd0;
     72                     end
     73                 else
     74                     begin
     75                     state_lcd_write <= 4'd1;
     76                     count_delay <= count_delay + 1'b1;
     77                     end
     78             4'd2:
     79                 if(LCD_DATA_TEMP[16])//data
     80                     begin
     81                         state_lcd_write <= state_lcd_write + 1'b1;
     82                         LCD_CS    <= 1'b0;
     83                         LCD_RS    <= 1'b0;
     84                         LCD_WR    <= 1'b0;
     85                         LCD_DATA<= LCD_DATA_TEMP[15:0];
     86                     end
     87                 else    //command
     88                     begin
     89                         state_lcd_write <= state_lcd_write + 1'b1;
     90                         LCD_CS    <= 1'b0;
     91                         LCD_RS    <= 1'b1;
     92                         LCD_WR    <= 1'b0;
     93                         LCD_DATA<= LCD_DATA_TEMP[15:0];
     94                     end
     95             4'd3:
     96                 state_lcd_write <= state_lcd_write + 1'b1;
     97             4'd4:
     98                 begin
     99                     state_lcd_write <= state_lcd_write + 1'b1;
    100                     LCD_CS    <= 1'b1;
    101                 end
    102             4'd5:
    103                 begin 
    104                     state_lcd_write <= state_lcd_write + 1'b1;
    105                     LCD_WR    <= 1'b1;
    106                 end
    107             4'd6:if(addr_command == 8'd83)            //red
    108                     begin
    109                         count_dot <= count_dot + 1'b1;
    110                         state_lcd_write <= 4'd1;
    111                         if(count_dot == 32'd76800 )
    112                             begin 
    113                                 addr_command <= 8'd84;
    114                                 count_dot <= 32'd1;
    115                             end
    116                         else state_lcd_write <= 4'd1;
    117                     end
    118                 else if(addr_command == 8'd84)        //white
    119                     begin
    120                         count_dot <= count_dot + 1'b1;
    121                         state_lcd_write <= 4'd1;
    122                         if(count_dot ==32'd76800 )
    123                             begin 
    124                                 addr_command <= 8'd83;
    125                                 count_dot <= 32'd0;
    126                             end
    127                         else state_lcd_write <= 4'd1;
    128                     end
    129                 else 
    130                     begin
    131                         addr_command <= addr_command + 1'b1;
    132                         state_lcd_write <= 4'd0;
    133                     end
    134             4'd7:state_lcd_write <= 4'd7;
    135                         
    136                     
    137         endcase
    138         end
    139     
    140     function [16:0] display_command;
    141     input [7:0]addr;
    142         begin
    143             case (addr)
    144                 8'd0:display_command = {1'b1,16'h0000};
    145                 8'd1:display_command = {1'b0,16'h0001};
    146                 
    147                 8'd2:display_command = {1'b1,16'h0003};
    148                 8'd3:display_command = {1'b0,16'h6664};
    149                 
    150                 8'd4:display_command = {1'b1,16'h000C};
    151                 8'd5:display_command = {1'b0,16'h0000};
    152                                       
    153                 8'd6:display_command = {1'b1,16'h000D};
    154                 8'd7:display_command = {1'b0,16'h080C};
    155                 
    156                 8'd8:display_command = {1'b1,16'h000E};
    157                 8'd9:display_command = {1'b0,16'h2B00};
    158                                      
    159                 8'd10:display_command = {1'b1,16'h001E};
    160                 8'd11:display_command = {1'b0,16'h00B0};
    161                 
    162                 8'd12:display_command = {1'b1,16'h0001};                 
    163                 8'd13:display_command = {1'b0,16'h2B3F};
    164                 
    165                 8'd14:display_command = {1'b1,16'h0002};
    166                 8'd15:display_command = {1'b0,16'h0600};
    167                 
    168                 8'd16:display_command = {1'b1,16'h0010};
    169                 8'd17:display_command = {1'b0,16'h0000};
    170                 
    171                 8'd18:display_command = {1'b1,16'h0011};//set display control mode
    172                 8'd19:display_command = {1'b0,16'h6070};
    173                 
    174                 8'd20:display_command = {1'b1,16'h0005};
    175                 8'd21:display_command = {1'b0,16'h0000};
    176                 
    177                 8'd22:display_command = {1'b1,16'h0006};           
    178                 8'd23:display_command = {1'b0,16'h0000};
    179                 
    180                 8'd24:display_command = {1'b1,16'h0016};
    181                 8'd25:display_command = {1'b0,16'hEF1C};
    182                 
    183                 8'd26:display_command = {1'b1,16'h0017};
    184                 8'd27:display_command = {1'b0,16'h0003};
    185                 8'd28:display_command = {1'b1,16'h0007};
    186                 8'd29:display_command = {1'b0,16'h0233};
    187                 8'd30:display_command = {1'b1,16'h000B};
    188                 8'd31:display_command = {1'b0,16'h0000};
    189                 8'd32:display_command = {1'b1,16'h000F};
    190                 8'd33:display_command = {1'b0,16'h0000};
    191                 8'd34:display_command = {1'b1,16'h0041};
    192                 8'd35:display_command = {1'b0,16'h0000};
    193                 8'd36:display_command = {1'b1,16'h0042};
    194                 8'd37:display_command = {1'b0,16'h0000};
    195                                       
    196                 8'd38:display_command = {1'b1,16'h0048};
    197                 8'd39:display_command = {1'b0,16'h0000};
    198                                   
    199                 8'd40:display_command = {1'b1,16'h0049};
    200                 8'd41:display_command = {1'b0,16'h013F};
    201                                   
    202                 8'd42:display_command = {1'b1,16'h004A};
    203                 8'd43:display_command = {1'b0,16'h0000};
    204                 
    205                 8'd44:display_command = {1'b1,16'h004B};
    206                 8'd45:display_command = {1'b0,16'h0000};
    207                 
    208                 8'd46:display_command = {1'b1,16'h0044};//horizontal ram address
    209                 8'd47:display_command = {1'b0,16'hEF00};
    210                 
    211                 8'd48:display_command = {1'b1,16'h0045};//v
    212                 8'd49:display_command = {1'b0,16'h0000};
    213                 
    214                 8'd50:display_command = {1'b1,16'h0046};
    215                 8'd51:display_command = {1'b0,16'h013f};
    216                 
    217                 8'd52:display_command = {1'b1,16'h0030};
    218                 8'd53:display_command = {1'b0,16'h0707};
    219                 
    220                 8'd54:display_command = {1'b1,16'h0031};
    221                 8'd55:display_command = {1'b0,16'h0204};
    222                 
    223                 8'd56:display_command = {1'b1,16'h0032};
    224                 8'd57:display_command = {1'b0,16'h0204};
    225                 
    226                 8'd58:display_command = {1'b1,16'h0033};
    227                 8'd59:display_command = {1'b0,16'h0502};
    228                 
    229                 8'd60:display_command = {1'b1,16'h0034};
    230                 8'd61:display_command = {1'b0,16'h0507};
    231                 
    232                 8'd62:display_command = {1'b1,16'h0035};
    233                 8'd63:display_command = {1'b0,16'h0204};
    234                 
    235                 8'd64:display_command = {1'b1,16'h0036};
    236                 8'd65:display_command = {1'b0,16'h0204};
    237                 
    238                 8'd66:display_command = {1'b1,16'h0037};
    239                 8'd67:display_command = {1'b0,16'h0502};  
    240                 
    241                 8'd68:display_command = {1'b1,16'h003A};
    242                 8'd69:display_command = {1'b0,16'h0302};
    243                 
    244                 8'd70:display_command = {1'b1,16'h003B};
    245                 8'd71:display_command = {1'b0,16'h0302};
    246                 
    247                 8'd72:display_command = {1'b1,16'h0023};
    248                 8'd73:display_command = {1'b0,16'h0000}; 
    249                 
    250                 8'd74:display_command = {1'b1,16'h0024};
    251                 8'd75:display_command = {1'b0,16'h0000}; 
    252                 
    253                 8'd76:display_command = {1'b1,16'h0025};
    254                 8'd77:display_command = {1'b0,16'h8000};
    255                 
    256                 8'd78:display_command = {1'b1,16'h004E};//光标位置X
    257                 8'd79:display_command = {1'b0,16'h00ef};
    258                 
    259                 8'd80:display_command = {1'b1,16'h004F};//光标位置Y
    260                 8'd81:display_command = {1'b0,16'h013f};
    261                 
    262                 8'd82:display_command = {1'b1,16'h0022};//开始RAM显示
    263                 8'd83:display_command = {1'b0,16'hf800};
    264                 8'd84:display_command = {1'b0,16'hffff};
    265             
    266                 default:display_command = {1'b0,16'h0000};
    267             endcase
    268         end
    269     endfunction
    270     
    271     
    272 endmodule 

      2)引脚配置TCL文件:

     1 set_location_assignment PIN_K15 -to LCD_CS
     2 set_location_assignment PIN_J16 -to LCD_RS
     3 set_location_assignment PIN_L16 -to LCD_RST
     4 set_location_assignment PIN_L14 -to LCD_RD
     5 set_location_assignment PIN_K16 -to LCD_WR
     6 
     7 set_location_assignment PIN_T14 -to LCD_DATA[15]
     8 set_location_assignment PIN_R13 -to LCD_DATA[14]
     9 set_location_assignment PIN_T15 -to LCD_DATA[13]
    10 set_location_assignment PIN_R14 -to LCD_DATA[12]
    11 set_location_assignment PIN_P14 -to LCD_DATA[11]
    12 set_location_assignment PIN_L9    -to LCD_DATA[10]
    13 set_location_assignment PIN_N14 -to LCD_DATA[9]
    14 set_location_assignment PIN_N12 -to LCD_DATA[8]
    15 set_location_assignment PIN_L13 -to LCD_DATA[7]
    16 set_location_assignment PIN_M11 -to LCD_DATA[6]
    17 set_location_assignment PIN_R16 -to    LCD_DATA[5]
    18 set_location_assignment PIN_K12 -to    LCD_DATA[4]
    19 set_location_assignment PIN_P16 -to    LCD_DATA[3]
    20 set_location_assignment PIN_P15 -to    LCD_DATA[2]
    21 set_location_assignment PIN_N16 -to    LCD_DATA[1]
    22 set_location_assignment PIN_N15 -to    LCD_DATA[0]
    23 #
    24 
    25 set_location_assignment PIN_A9 -to CLK
    26 set_location_assignment PIN_M1 -to RSTn

    谢谢指正!如需要交流,请留言!

  • 相关阅读:
    Java核心技术(初阶)知识点复习——[2]面向对象思想
    Java核心技术(初阶)知识点复习——[1]Java的类结构和main函数
    printStream与printWriter
    java反射的初步探索
    JDKJREJVM的关系
    树链剖分模板
    树状数组模板2
    树状数组模板1
    树状数组+欧拉降幂
    线段树模板二
  • 原文地址:https://www.cnblogs.com/zhezhe1988/p/3504572.html
Copyright © 2020-2023  润新知