关于TFT初始化问题(初始化部分程序不理解) HX8347
我把源代码贴出来我也找到了46 47 ……等等寄存器 下图是他的作用我不知道程序初始化给他赋 A4 5300等什么意思 用过的人说说啊#include <reg52.h>
sbit LCD_RS = P3^5; //数据/命令切换
sbit LCD_REST = P1^2; //复位
sbit LCD_WR = P3^6; //写控制
sbit LCD_RD =P3^7; //读控制
sbit LCD_CS=P1^0;
void delayms(int count)// /* X1ms */
{
int i,j;
for(i=0;i<count;i++)
for(j=0;j<100;j++);
}
void main_Write_COM( intDH) //命令
{
LCD_RS=0;
LCD_CS =0;
P2=DH>>8;
P0=DH;
LCD_WR=0;
LCD_WR=1;
LCD_CS =1;
}
void main_Write_DATA(int DH) //数据
{
LCD_RS=1;
LCD_CS =0;
P2=DH>>8;
P0=DH;
LCD_WR=0;
LCD_WR=1;
LCD_CS =1;
}
void main_W_com_data( int com1,dat1) //命令数据一起
{
main_Write_COM(com1);
main_Write_DATA(dat1);
}
void address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2)
{
main_W_com_data(0x0002,x1>>8); // Column address start2
main_W_com_data(0x0003,x1); // Column address start1
main_W_com_data(0x0004,x2>>8); // Column address end2
main_W_com_data(0x0005,x2); // Column address end1
main_W_com_data(0x0006,y1>>8); // Row address start2
main_W_com_data(0x0007,y1); // Row address start1
main_W_com_data(0x0008,y2>>8); // Row address end2
main_W_com_data(0x0009,y2); // Row address end1
main_Write_COM(0x0022);
}
void main_init(void)
{
LCD_REST=1;
delayms(5);
LCD_REST=0;
delayms(10);
LCD_REST=1;
delayms(20);
//VENDOR
main_W_com_data(0x0046,0x00A4);
main_W_com_data(0x0047,0x0053);
main_W_com_data(0x0048,0x0000);
main_W_com_data(0x0049,0x0044);
main_W_com_data(0x004a,0x0004);
main_W_com_data(0x004b,0x0067);
main_W_com_data(0x004c,0x0033);
main_W_com_data(0x004d,0x0077);
main_W_com_data(0x004e,0x0012);
main_W_com_data(0x004f,0x004C);
main_W_com_data(0x0050,0x0046);
main_W_com_data(0x0051,0x0044);
//240x320 window setting
main_W_com_data(0x0002,0x0000); // Column address start2
main_W_com_data(0x0003,0x0000); // Column address start1
main_W_com_data(0x0004,0x0000); // Column address end2
main_W_com_data(0x0005,0x00ef); // Column address end1
main_W_com_data(0x0006,0x0000); // Row address start2
main_W_com_data(0x0007,0x0000); // Row address start1
main_W_com_data(0x0008,0x0001); // Row address end2
main_W_com_data(0x0009,0x003f); // Row address end1
// Display Setting
main_W_com_data(0x0001,0x0006); // IDMON=0, INVON=1, NORON=1, PTLON=0
main_W_com_data(0x0016,0x00C8); // MY=0, MX=0, MV=0, ML=1, BGR=0, TEON=0 0048
main_W_com_data(0x0023,0x0095); // N_DC=1001 0101
main_W_com_data(0x0024,0x0095); // PI_DC=1001 0101
main_W_com_data(0x0025,0x00FF); // I_DC=1111 1111
main_W_com_data(0x0027,0x0002); // N_BP=0000 0010
main_W_com_data(0x0028,0x0002); // N_FP=0000 0010
main_W_com_data(0x0029,0x0002); // PI_BP=0000 0010
main_W_com_data(0x002a,0x0002); // PI_FP=0000 0010
main_W_com_data(0x002C,0x0002); // I_BP=0000 0010
main_W_com_data(0x002d,0x0002); // I_FP=0000 0010
main_W_com_data(0x003a,0x0001); // N_RTN=0000, N_NW=001 0001
main_W_com_data(0x003b,0x0000); // P_RTN=0000, P_NW=001
main_W_com_data(0x003c,0x00f0); // I_RTN=1111, I_NW=000
main_W_com_data(0x003d,0x0000); // DIV=00
delayms(1);
main_W_com_data(0x0035,0x0038); // EQS=38h
main_W_com_data(0x0036,0x0078); // EQP=78h
main_W_com_data(0x003E,0x0038); // SON=38h
main_W_com_data(0x0040,0x000F); // GDON=0Fh
main_W_com_data(0x0041,0x00F0); // GDOFF
// Power Supply Setting
main_W_com_data(0x0019,0x0049); // CADJ=0100, CUADJ=100, OSD_EN=1 ,60Hz
main_W_com_data(0x0093,0x000F); // RADJ=1111, 100%
delayms(1);
main_W_com_data(0x0020,0x0040); // BT=0100
main_W_com_data(0x001D,0x0007); // VC1=111 0007
main_W_com_data(0x001E,0x0000); // VC3=000
main_W_com_data(0x001F,0x0004); // VRH=0011
//VCOM SETTING
main_W_com_data(0x0044,0x004D); // VCM=101 00004D
main_W_com_data(0x0045,0x000E); // VDV=1 0001 0011
delayms(1);
main_W_com_data(0x001C,0x0004); // AP=100
delayms(2);
main_W_com_data(0x001B,0x0018); // GASENB=0, PON=0, DK=1, XDK=0, VLCD_TRI=0, STB=0
delayms(1);
main_W_com_data(0x001B,0x0010); // GASENB=0, PON=1, DK=0, XDK=0, VLCD_TRI=0, STB=0
delayms(1);
main_W_com_data(0x0043,0x0080); //set VCOMG=1
delayms(2);
// Display ON Setting
main_W_com_data(0x0090,0x007F); // SAP=0111 1111
main_W_com_data(0x0026,0x0004); //GON=0, DTE=0, D=01
delayms(1);
main_W_com_data(0x0026,0x0024); //GON=1, DTE=0, D=01
main_W_com_data(0x0026,0x002C); //GON=1, DTE=0, D=11
delayms(1);
main_W_com_data(0x0026,0x003C); //GON=1, DTE=1, D=11
// INTERNAL REGISTER SETTING
main_W_com_data(0x0057,0x0002); // TEST_Mode=1: into TEST mode
main_W_com_data(0x0095,0x0001); // SET DISPLAY CLOCK AND PUMPING CLOCK TO SYNCHRONIZE
main_W_com_data(0x0057,0x0000); // TEST_Mode=0: exit TEST mode
//main_W_com_data(0x0021,0x0000);
main_Write_COM(0x0022);
}
void Pant(unsigned int color)
{
int i,j;
address_set(0,0,239,319);
for(i=0;i<320;i++)
{
for (j=0;j<240;j++)
{
main_Write_DATA(color);
}
}
}
main()
{
main_init(); //tft初始化
while(1)
{
Pant(0xf800); //红色
delayms(1000);
Pant(0X07E0); //绿色
delayms(1000);
Pant(0x001f); //蓝色
delayms(1000);
}
}
http://cache.amobbs.com/bbs_upload782111/files_34/ourdev_596443PSZFVA.JPG
初始部分 (原文件名:23.JPG) 回复【楼主位】joychainleo
-----------------------------------------------------------------------
這應該是屬於Gamma設置 楼主是3.2寸的屏吧,你这好像是卖家提供的程序,你调好没有? 你好
GAMMA Control 1~12 Register (R46~51h)..................................................................................111
这个是GAMMA设置的寄存器
这些值是根据gamma曲线调出来的 我也买了这个屏,
http://item.taobao.com/item.htm?id=5624820961
建议大家千万另买,不适合学习!卖家给的datasheet上面根本没有对程序中的命令的说明!
而且HX8347的datasheet我在网上找了几种,有什么HX8347-G(T)和什么HX8347-G(N)的,上面说的指令都和程序中的对不上号!
建议买驱动IC是ILI9320的屏
页:
[1]