独闷闷网

标题: 新手求教 [打印本页]

作者: zhong506567527    时间: 2014-12-12 11:20
标题: 新手求教
哪位大神帮忙看下这个TFT彩屏的程序,看看是哪里出了问题,上电只显示整屏的雪花点。程序如下
#include <reg52.h>
#define TFT_DATAPORT P0
typedef unsigned char uchar;
typedef unsigned int uint;
//sfr16 DPTR=0x82;
sbit A0 = P3^2;  //数据/命令切换
sbit RES = P3^3;        //复位
sbit WRB = P2^5;   //写控制
sbit RDB =P2^6;   //读控制
sbit CS_MAIN=P2^7;

void delayms(int count)  //10ms
{
        int i,j;
        for(i=0;i<count;i++)
                for(j=0;j<100;j++);
}
/****************************************************************************/
void main_Write_COM(uint cmd)
{
WRB = 1;      //初始化WR
CS_MAIN = 0;     //打开片选
RDB = 1;           //选择写
A0 = 0;     //选择命令
TFT_DATAPORT = (cmd >> 8) & 0x00FF; //放置命令数据
    WRB = 0;     //写入时序
WRB = 1;
    TFT_DATAPORT = cmd & 0x00FF;        //放置命令数据
    WRB = 0;     //写入时序
WRB = 1;
CS_MAIN = 1;     //关闭片选
}
/****************************************************************************/
   
void main_Write_DATA(uint dat)
{
WRB = 1;      //初始化WR
CS_MAIN = 0;     //打开片选
RDB = 1;           //选择写
A0 = 1;     //选择发送数据
TFT_DATAPORT = (dat >> 8) & 0x00FF;  //放置命令数据
    WRB = 0;     //写入时序
WRB = 1;
    TFT_DATAPORT = dat & 0x00FF;         //放置命令数据
    WRB = 0;     //写入时序
WRB = 1;
CS_MAIN = 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(0x0200,x1);//设置X坐标位置
    main_W_com_data(0x0201,y1);//设置Y坐标位置
    main_W_com_data(0x0210,x1);   //开始X
   main_W_com_data(0x0212,y1);   //开始Y
    main_W_com_data(0x0211,x2);  //结束X
   main_W_com_data(0x0213,y2);  //结束Y
    main_Write_COM(0x0202);
}
void main_init(void)
{
RES=1;
delayms(5);
RES=0;
delayms(10);
RES=1;
delayms(20);
//************* Start Initial Sequence **********//
main_Write_COM(0x0000);
main_Write_COM(0x0000);
delayms(10);
main_Write_COM(0x0000);
main_Write_COM(0x0000);
main_Write_COM(0x0000);
main_Write_COM(0x0000);
delayms(10);
main_Write_COM(0x0400); main_Write_DATA(0x6200);
main_Write_COM(0x0008); main_Write_DATA(0x0808);

main_Write_COM(0x0300); main_Write_DATA(0x0109);
main_Write_COM(0x0301); main_Write_DATA(0x7E0A);
main_Write_COM(0x0302); main_Write_DATA(0x0704);
main_Write_COM(0x0303); main_Write_DATA(0x0911);

main_Write_COM(0x0304); main_Write_DATA(0x2100);

main_Write_COM(0x0305); main_Write_DATA(0x1109);
main_Write_COM(0x0306); main_Write_DATA(0x7407);
main_Write_COM(0x0307); main_Write_DATA(0x0A0E);
main_Write_COM(0x0308); main_Write_DATA(0x0901);

main_Write_COM(0x0309); main_Write_DATA(0x0021);

main_Write_COM(0x0010); main_Write_DATA(0x0016);
main_Write_COM(0x0011); main_Write_DATA(0x0202);
main_Write_COM(0x0012); main_Write_DATA(0x0300);
main_Write_COM(0x0013); main_Write_DATA(0x0007);
delayms(10);

main_Write_COM(0x0100); main_Write_DATA(0x0330);
main_Write_COM(0x0101); main_Write_DATA(0x0247);
main_Write_COM(0x0103); main_Write_DATA(0x1000);
main_Write_COM(0x0280); main_Write_DATA(0xBC00);
main_Write_COM(0x0102); main_Write_DATA(0xD1B0);
delayms(100);

main_Write_COM(0x0001); main_Write_DATA(0x0100);
main_Write_COM(0x0002); main_Write_DATA(0x0100);
main_Write_COM(0x0003); main_Write_DATA(0x1030);
main_Write_COM(0x0009); main_Write_DATA(0x0001);
main_Write_COM(0x000C); main_Write_DATA(0x0000);
main_Write_COM(0x0090); main_Write_DATA(0x8000);
main_Write_COM(0x000F); main_Write_DATA(0x0000);
main_Write_COM(0x0210); main_Write_DATA(0x0000);
main_Write_COM(0x0211); main_Write_DATA(0x00EF);
main_Write_COM(0x0212); main_Write_DATA(0x0000);
main_Write_COM(0x0213); main_Write_DATA(0x018F);
main_Write_COM(0x0500); main_Write_DATA(0x0000);
main_Write_COM(0x0501); main_Write_DATA(0x0000);
main_Write_COM(0x0502); main_Write_DATA(0x005F);
main_Write_COM(0x0401); main_Write_DATA(0x0001);
main_Write_COM(0x0404); main_Write_DATA(0x0000);
delayms(50);

main_Write_COM(0x0007); main_Write_DATA(0x0100);
delayms(100);

main_Write_COM(0x0200); main_Write_DATA(0x0000);
main_Write_COM(0x0201); main_Write_DATA(0x0000);
delayms(10);
main_Write_COM(0x0202);
}
void disp_color(uint color)
{
int i,j;
address_set(0,0,240,400);
    for(i=0;i<400;i++)
  {
   for (j=0;j<240;j++)
     {
         main_Write_DATA(color);
     }
   }
}
main()
{
   
main_init();   //tft初始化
while(1)
{
    disp_color(0xf800); //红
disp_color(0X07E0); //绿
disp_color(0x001f); //蓝  
//disp_color(0xffe0); //黄
disp_color(0x0000); //黑
disp_color(0xffff); //白
// disp_color(0x07ff); //青
// disp_color(0xd343); //暗红
    }

}








作者: zhong506567527    时间: 2014-12-12 11:36
资料忘加上了

驱动芯片资料.pdf

3.34 MB, 下载次数: 534

芯片资料

彩屏电路.pdf

45.79 KB, 下载次数: 1454

电路

彩屏.pdf

839.86 KB, 下载次数: 1463

彩屏资料


作者: waphaoyun    时间: 2014-12-13 19:20
这种驱动问题  大家不好帮忙啊,而且手里也未必有你手中的屏幕!
作者: zhong506567527    时间: 2014-12-15 12:00
waphaoyun 发表于 2014-12-13 19:20
这种驱动问题  大家不好帮忙啊,而且手里也未必有你手中的屏幕!

恩!谢谢!
作者: jianhong_wu    时间: 2014-12-15 17:35
是的。这种驱动问题大家不好帮忙啊,而且手里也未必有你手中的屏幕!




欢迎光临 独闷闷网 (http://dumenmen.com/) Powered by Discuz! X3.2