银杏科技有限公司旗下技术文档发布平台 | |||
技术支持电话 | 0379-69926675-801 | ||
技术支持邮件 | Gingko@vip.163.com | ||
版本 | 日期 | 作者 | 修改内容 |
---|---|---|---|
V1.0 | 2019-12-25 | gingko | 初次建立 |
注意事项1: 注意FPC转接板和核心板之间引脚要对齐(如图31-1中①处所示,转接板和核心板边缘要对齐)。
注意事项2: FPC软线与FPC接口连接时,请确认软排线接口处蓝色绝缘皮朝上(如图31-1中②③所示)。
注意事项3: 下载程序前请确认FPC连接线无误,且iCore3核心板引脚与PIN.tcl文件中绑定引脚相互对应。
/*输入转换命令字符*/ reg [7:0]DIN_x; reg [7:0]DIN_y; reg DIN_r; always @(negedge spi_clk or negedge RST_n) if (!RST_n) begin DIN_x <= 8'b1101_0000; //转换X方向模拟量命令 DIN_y <= 8'b1001_0000; //转换Y方向模拟量命令 end
//--------------------DCLK------------------// reg [9:0]cnt_clk; reg spi_clk = 1'd0; reg spi_clk_r = 1'd0; always @(negedge TOUCH_CLK or negedge RST_n) if (!RST_n) cnt_clk <= 10'd0; else if (cnt_clk == 10'd299)//分频计数器 cnt_clk <= 10'd0; else cnt_clk <= cnt_clk + 1'd1; always @(negedge TOUCH_CLK or negedge RST_n) if (!RST_n) begin spi_clk <= 1'd0; spi_clk_r <= 1'd0; end else if (cnt_clk == 10'd0) begin spi_clk <= 1'd1; spi_clk_r <= 1'd1; end else if (cnt_clk == 10'd150) spi_clk <= 1'd0; else if(cnt_clk == 10'd130) spi_clk_r <= 1'd0; assign DCLK = spi_clk; //转换时钟100KHz
//--------------------spi_clk_counter------------------// reg [9:0]spi_clk_counter; always @(posedge spi_clk_r or negedge RST_n) if (!RST_n) spi_clk_counter <= 10'd0; else if (spi_clk_counter == 10'd999) spi_clk_counter <= 10'd0; else spi_clk_counter <= spi_clk_counter + 10'd1;
//--------------------DIN------------------// /*输入转换命令字符*/ reg [7:0]DIN_x; reg [7:0]DIN_y; reg DIN_r; always @(negedge spi_clk or negedge RST_n) if (!RST_n) begin DIN_x <= 8'b1101_0000; //转换X方向模拟量命令 DIN_y <= 8'b1001_0000; //转换Y方向模拟量命令 end else case (spi_clk_counter) 10'd0: DIN_r <= DIN_x[7]; 10'd1: DIN_r <= DIN_x[6]; 10'd2: DIN_r <= DIN_x[5]; 10'd3: DIN_r <= DIN_x[4]; 10'd4: DIN_r <= DIN_x[3]; 10'd5: DIN_r <= DIN_x[2]; 10'd6: DIN_r <= DIN_x[1]; 10'd7: DIN_r <= DIN_x[0]; 10'd24: DIN_r <= DIN_y[7]; 10'd25: DIN_r <= DIN_y[6]; 10'd26: DIN_r <= DIN_y[5]; 10'd27: DIN_r <= DIN_y[4]; 10'd28: DIN_r <= DIN_y[3]; 10'd29: DIN_r <= DIN_y[2]; 10'd30: DIN_r <= DIN_y[1]; 10'd31: DIN_r <= DIN_y[0]; default: DIN_r <= 1'd0; endcase assign DIN = DIN_r;
//--------------------DOUT------------------// /*实现AD转换*/ reg [11:0]DOUT_x; reg [11:0]DOUT_y; always @(negedge spi_clk or negedge RST_n) if (!RST_n) begin DOUT_x <= 12'd0; DOUT_y <= 12'd0; end else case (spi_clk_counter) 10'd10: DOUT_x[11] <= DOUT; 10'd11: DOUT_x[10] <= DOUT; 10'd12: DOUT_x[9] <= DOUT; 10'd13: DOUT_x[8] <= DOUT; 10'd14: DOUT_x[7] <= DOUT; 10'd15: DOUT_x[6] <= DOUT; 10'd16: DOUT_x[5] <= DOUT; 10'd17: DOUT_x[4] <= DOUT; 10'd18: DOUT_x[3] <= DOUT; 10'd19: DOUT_x[2] <= DOUT; 10'd20: DOUT_x[1] <= DOUT; 10'd21: DOUT_x[0] <= DOUT; 10'd34: DOUT_y[11] <= DOUT; 10'd35: DOUT_y[10] <= DOUT; 10'd36: DOUT_y[9] <= DOUT; 10'd37: DOUT_y[8] <= DOUT; 10'd38: DOUT_y[7] <= DOUT; 10'd39: DOUT_y[6] <= DOUT; 10'd40: DOUT_y[5] <= DOUT; 10'd41: DOUT_y[4] <= DOUT; 10'd42: DOUT_y[3] <= DOUT; 10'd43: DOUT_y[2] <= DOUT; 10'd44: DOUT_y[1] <= DOUT; 10'd45: DOUT_y[0] <= DOUT; endcase //--------------------POS------------------// /*输出转换值*/ reg [11:0]x_pos; reg [11:0]y_pos; reg mark;// reg [11:0]mark; always @(posedge TOUCH_CLK or negedge RST_n) if (!RST_n) begin x_pos <= 12'd0; y_pos <= 12'd0; mark <= 1'd0; end else if (spi_clk_counter == 10'd46) //转换完成,输出转换值,转换完成标志置1 begin x_pos <= DOUT_x; y_pos <= DOUT_y; mark <= 1'd1;//转换完成标志位,高有效 end else mark <= 1'd0;
//--------------------IMG_RGB-----------------------------------// reg [15:0] IMG_RGB_r; always@(posedge TFT_CLK or negedge RST_n) if (!RST_n) IMG_RGB_r<=16'd0; else if((X_POS>12'h000)&&(Y_POS<12'hfff))//判断是否有触摸值,如果有触摸,则切换显示色彩。 IMG_RGB_r<=16'b11111_000000_00000;//有触摸,显示红色 else IMG_RGB_r<=16'b00000_111111_00000;//无触摸,显示绿色 assign IMG_RGB = IMG_RGB_r;