新闻中心

EEPW首页>嵌入式系统>设计应用> stm32开发板开发笔记(5)-2.4寸26万色TFT触摸屏模块

stm32开发板开发笔记(5)-2.4寸26万色TFT触摸屏模块

作者: 时间:2016-11-13 来源:网络 收藏
因为产品要用到显示屏和触摸,就买了一个2.4寸的彩色触摸屏模块。
原理图:
显示屏的驱动芯片是ILI9325
ILI9325 is a 262,144-color one-chip SoC driver for a-TFT liquid crystal display with resolution of 240RGBx320
dots, comprising a 720-channel source driver, a 320-channel gate driver, 172,800 bytes RAM for graphic data
of 240RGBx320 dots, and power supply circuit.
大概的意思就是ILI9325是一颗 26万色片上soc的TFT液晶屏驱动芯片,支持的分辨率为240RGB*320,172800个字节的显存。
下面来说说说这几个数字 的含义。
26万色是色阶,具体就是,RGB每种颜色用6个位表示,这样就是64x64x64=262,144,当前主流的手机屏幕应该都是 1600万色,就是256*256*256=16777216。
再来说这个172800 :320*240*2.25=172,800 个字节 320 240 很容易理解,2.25在这里是18个bit,也就是说,如果以26万色的色阶填充,填满整个屏幕,需要这么多个字节的数据,算了一下大概是168.75KB。
在看手机屏幕,当前的主流的分辨率是1080P,旗舰手机是2K屏幕,就以普通的1080P 屏幕为例,1920*1080*96=199065600个字节
算了一下,大约是189.84375MB,2K屏幕就已经是300多MB了,手机的处理器性能确实强大。
comprising a 720-channel source driver, a 320-channel gate driver
720-channel 和320-channel gate在芯片上是实实在在存在的,720表示240的点的RGB,320就是门驱动。
上图为芯片管脚图
上图为管脚尺寸图
门输出顺序,这个和取模没有关系的 通过控制Driver Output Control (R01h) 的SM 和GS,可以控制驱动门开启的数序,
这里可能有点显示的效果的控制。
和显示编程最相关的是8.2.5. Entry Mode (R03h) 这个寄存器,其影响取模的方式,显示的位置。
从上面的描述就是水平方向上的递增递减来看,如果原点没有改动,上图中红色点标出的地方就是原点,
我将这里标记为物理原点。
对比实物图
ILI9325 has a 16-bit index register (IR), an 18-bit write-data register (WDR), an d an 18-bit read-data register
(RDR). The IR is the register to store index information from control registers and the internal GRAM. The
WDR is the register to temporarily store data to be written to control registers and the internal GRAM. The
RDR is the register to temporarily store data read from the GRAM.
Data from the MPU to be written to theinternal GRAM are first written to the WDR and then automatically written to the internal GRAM in internaloperation. Data are read via the RDR from the internal GRAM.
Therefore, invalid data are read out to the data
bus when the ILI9325 read the first data from the internal GRAM. Valid data are read out after the ILI9325
performs the second read operation.
ILI9325 有一个16位的索引寄存器(缩写 IR),一个18位的写数据寄存器(缩写为WDR),和一个18位的读数据寄存器(缩写为RDR) 。IR用来存储来自控制寄存器和内部GRAM的索引信息,WDR是用来暂存写入到GRAM中的数据的。RDR是用来暂存来自GRAM的数据的。
来自MPU的写GRAM数据第一步写入到WDR,然后通过内部的自动操作,写入到GRAM中。读操作和写操作的道理一样。
因此,第一步读到 总线上的数据是无效的,第二步读到的数据才是有效数据。
Address Counter (AC)
The address counter (AC) gives an address to the internal GRAM. When the index of the register for setting a
RAM address in the AC is written to the IR, the address information is sent from the IR to the AC. As writing
data to the internal GRAM, the address in the AC is automatically updated plus or minus 1. The window
address function enables writing data only in the rectangular area arbitrarily set by users on the GRAM.
地址计数器用来给内部的GRAM传递地址信息,当要设置AC的信息,先是将这个RAM地址写入IR中,然后传递给AC。
写一个数据到GRAM,AC 自动加1或者减1。 窗口地址功能使得任意写入到GRAM 中数据在窗口显示。
昨天一直弄错的一个问题,我想采用上面的配置 AM=0, ID=11 在水平方向上扫描,水平地址增长,垂直地址增长,
然后取模软件这边的设置如下图:
配合屏幕的方向,我在扫描的时候做了以上的设置,我将扫描的起点和屏幕的原点重合,
这样在增长方向上都是增加,事实证明这种扫描方式是可以的。
问题出来和软件的配合上
x=((uint16_t)(pic[2]<<8)+pic[3])-1; //从图像数组里取出图像的长度
y=((uint16_t)(pic[4]<<8)+pic[5])-1; //从图像数组里取出图像的高度
这种方式取出来的x=320
y=240
LCD_WR_CMD(EntryMode,0x1030); //图像显示方向为左下起 行递增 列递减
LCD_WR_CMD(HorizontalAddressStart, StartX); //水平显示区起始地址 0-239
LCD_WR_CMD(HorizontalAddressEndPosition, StartX+x); //水平显示区结束地址 0-239
LCD_WR_CMD(VerticalAddressStart, StartY); //垂直显示区起始地址 0-319
LCD_WR_CMD(VerticalAddressEndPosition, StartY+y); //垂直显示区结束地址 0-319
LCD_WR_CMD(HorizontalGramAddressSet, StartX); //水平显示区地址
LCD_WR_CMD(VerticalGramAddressSet, StartY); //垂直显示区地址
这样在水平方向就会越界,导致?屏。
这种扫描方式x应该是240 y是320
正常的竖屏扫描方式
配合屏幕,竖屏显示

SS和GS两个位通过控制S1-S720的和G1-G320的方向来确定原点的位置
SS是Source Shift
GS是Gate Shift

1、坐标原点位置由SS和GS确定。对应01H和60H命令.

本文引用地址: //m.amcfsurvey.com/article/201611/316353.htm

2、AM和I/D[1:0]即03H命令,控制其扫描方式,这将决定你图片取模方式。正常的取模图片才会正常显示。




评论


技术专区

关闭