专家
公告
财富商城
电子网
旗下网站
首页
问题库
专栏
标签库
话题
专家
NEW
门户
发布
提问题
发文章
51单片机
2.4TFT彩屏51驱动程序
2020-01-27 11:24
发布
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
站内问答
/
51单片机
9919
22
22
规格书及驱动实例.rar
友情提示:
此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
22条回答
kanpingya
2020-01-27 14:18
#include <reg51.h>
/*
代码测试环境:JME-2核心板+1T指令周期的STC单片机(51内核STC12LE5A60S2)+33M晶振 单片机工作电压3.3V
程序默认IO连接方式:
控制线:RS-P3^5; WR-P3^6; RD-P3^7; CS-P1^0; REST-P1^2;
数据线: DB0-DB7依次连接P0^0-P0^7; DB8-DB15依次连接P2^0-P2^7;(8位模式下DB0-DB7可以不连接)
触摸功能连接方式:(不使用触摸可不连接)
D_CLK-P1^7; D_CS-P1^4; D_DIN-P3^0; D_OUT-P3^1; D_PENIRQ-P3^4;
*/
#define Bus_16 //16位数据模式,如果使用8位模式,请注释此语句,如果使用16位模式,请打开此句
#define LCD_DataPortH P2 //高8位数据口,8位模式下只使用高8位
#define LCD_DataPortL P0 //低8位数据口 ,8位模式下低8位可以不接线,请确认P0口已经上拉10K电阻,不宜太小,最小4.7K,推荐10K.
sbit LCD_RS = P3^5; //数据/命令切换
sbit LCD_WR = P3^6; //写控制
sbit LCD_RD =P3^7; //读控制
sbit LCD_CS=P1^0; //片选
sbit LCD_REST = P1^2; //复位
void delayms(int count) // /* X1ms */
{
int i,j;
for(i=0;i<count;i++)
for(j=0;j<1000;j++);
}
#ifdef Bus_16 //条件编译-16位数据模式
void LCD_Writ_Bus(char VH,char VL) //并行数据写入函数
{
LCD_DataPortH=VH;
LCD_DataPortL=VL;
LCD_WR=0;
LCD_WR=1;
}
#else //条件编译-8位数据模式
void LCD_Writ_Bus(char VH,char VL) //并行数据写入函数
{
LCD_DataPortH=VH;
LCD_WR=0;
LCD_WR=1;
LCD_DataPortH=VL;
LCD_WR=0;
LCD_WR=1;
}
#endif
void Lcd_Write_Com(char VH,char VL) //发送命令-8位参数
{
LCD_RS=0;
LCD_Writ_Bus(VH,VL);
}
void Lcd_Write_Data(char VH,char VL) //发送数据-8位参数
{
LCD_RS=1;
LCD_Writ_Bus(VH,VL);
}
void Lcd_Write_Com_Data(int com,int val) //发送数据命令
{
Lcd_Write_Com(com>>8,com);
Lcd_Write_Data(val>>8,val);
}
void Address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2)
{
Lcd_Write_Com(0x00,0x20);Lcd_Write_Data(x1>>8,x1); //设置X坐标位置
Lcd_Write_Com(0x00,0x21);Lcd_Write_Data(y1>>8,y1); //设置Y坐标位置
Lcd_Write_Com(0x00,0x50);Lcd_Write_Data(x1>>8,x1); //开始X
Lcd_Write_Com(0x00,0x52);Lcd_Write_Data(y1>>8,y1); //开始Y
Lcd_Write_Com(0x00,0x51);Lcd_Write_Data(x2>>8,x2); //结束X
Lcd_Write_Com(0x00,0x53);Lcd_Write_Data(y2>>8,y2); //结束Y
Lcd_Write_Com(0x00,0x22);
}
void Lcd_Init(void)
{
LCD_REST=1;
delayms(5);
LCD_REST=0;
delayms(5);
LCD_REST=1;
LCD_CS=1;
LCD_RD=1;
LCD_WR=1;
delayms(5);
LCD_CS =0; //打开片选使能
//************* Start Initial Sequence **********//
Lcd_Write_Com_Data(0x0001, 0x0100); // set SS and SM bit
Lcd_Write_Com_Data(0x0002, 0x0200); // set 1 line inversion
Lcd_Write_Com_Data(0x0003, 0x1030); // set GRAM write direction and BGR=1.
Lcd_Write_Com_Data(0x0004, 0x0000); // Resize register
Lcd_Write_Com_Data(0x0008, 0x0207); // set the back porch and front porch
Lcd_Write_Com_Data(0x0009, 0x0000); // set non-display area refresh cycle ISC[3:0]
Lcd_Write_Com_Data(0x000A, 0x0000); // FMARK function
Lcd_Write_Com_Data(0x000C, 0x0000); // RGB interface setting
Lcd_Write_Com_Data(0x000D, 0x0000); // Frame marker Position
Lcd_Write_Com_Data(0x000F, 0x0000); // RGB interface polarity
//*************Power On sequence ****************//
Lcd_Write_Com_Data(0x0010, 0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB
Lcd_Write_Com_Data(0x0011, 0x0007); // DC1[2:0], DC0[2:0], VC[2:0]
Lcd_Write_Com_Data(0x0012, 0x0000); // VREG1OUT voltage
Lcd_Write_Com_Data(0x0013, 0x0000); // VDV[4:0] for VCOM amplitude
Lcd_Write_Com_Data(0x0007, 0x0001);
delayms(200); // Dis-charge capacitor power voltage
Lcd_Write_Com_Data(0x0010, 0x1690); // SAP, BT[3:0], AP, DSTB, SLP, STB
Lcd_Write_Com_Data(0x0011, 0x0227); // Set DC1[2:0], DC0[2:0], VC[2:0]
delayms(50); // Delay 50ms
Lcd_Write_Com_Data(0x0012, 0x000D); // 0012
delayms(50); // Delay 50ms
Lcd_Write_Com_Data(0x0013, 0x1200); // VDV[4:0] for VCOM amplitude
Lcd_Write_Com_Data(0x0029, 0x000A); // 04 VCM[5:0] for VCOMH
Lcd_Write_Com_Data(0x002B, 0x000D); // Set Frame Rate
delayms(50); // Delay 50ms
Lcd_Write_Com_Data(0x0020, 0x0000); // GRAM horizontal Address
Lcd_Write_Com_Data(0x0021, 0x0000); // GRAM Vertical Address
// ----------- Adjust the Gamma Curve ----------//
Lcd_Write_Com_Data(0x0030, 0x0000);
Lcd_Write_Com_Data(0x0031, 0x0404);
Lcd_Write_Com_Data(0x0032, 0x0003);
Lcd_Write_Com_Data(0x0035, 0x0405);
Lcd_Write_Com_Data(0x0036, 0x0808);
Lcd_Write_Com_Data(0x0037, 0x0407);
Lcd_Write_Com_Data(0x0038, 0x0303);
Lcd_Write_Com_Data(0x0039, 0x0707);
Lcd_Write_Com_Data(0x003C, 0x0504);
Lcd_Write_Com_Data(0x003D, 0x0808);
//------------------ Set GRAM area ---------------//
Lcd_Write_Com_Data(0x0050, 0x0000); // Horizontal GRAM Start Address
Lcd_Write_Com_Data(0x0051, 0x00EF); // Horizontal GRAM End Address
Lcd_Write_Com_Data(0x0052, 0x0000); // Vertical GRAM Start Address
Lcd_Write_Com_Data(0x0053, 0x013F); // Vertical GRAM Start Address
Lcd_Write_Com_Data(0x0060, 0xA700); // Gate Scan Line
Lcd_Write_Com_Data(0x0061, 0x0001); // NDL,VLE, REV
Lcd_Write_Com_Data(0x006A, 0x0000); // set scrolling line
//-------------- Partial Display Control ---------//
Lcd_Write_Com_Data(0x0080, 0x0000);
Lcd_Write_Com_Data(0x0081, 0x0000);
Lcd_Write_Com_Data(0x0082, 0x0000);
Lcd_Write_Com_Data(0x0083, 0x0000);
Lcd_Write_Com_Data(0x0084, 0x0000);
Lcd_Write_Com_Data(0x0085, 0x0000);
//-------------- Panel Control -------------------//
Lcd_Write_Com_Data(0x0090, 0x0010);
Lcd_Write_Com_Data(0x0092, 0x0000);
Lcd_Write_Com_Data(0x0007, 0x0133); // 262K color and display ON
LCD_CS =1; //关闭片选使能
}
void Pant(char VH,char VL)
{
int i,j;
LCD_CS =0; //打开片选使能
Address_set(0,0,240,320);
for(i=0;i<320;i++)
{
for (j=0;j<240;j++)
{
Lcd_Write_Data(VH,VL);
}
}
LCD_CS =1; //关闭片选使能
}
main()
{
Lcd_Init(); //TFT初始化
Pant(0xff,0xff); //TFT清屏
while(1)
{
Pant(0xf8,0x00); //红 {MOD}
delayms(2000);
Pant(0X07,0xE0); //绿 {MOD}
delayms(2000);
Pant(0x00,0x1f); //蓝 {MOD}
delayms(2000);
}
}
目录:
触摸测试程序
LCD图片取模软件Image2Lcd
C51图片显示测试程序
C51刷屏测试程序
需要单片屏的可以联系我 30元/片 QQ277152571
(原文件名:20111122114937.jpg)
点击此处下载
ourdev_697865IS91H5.rar(文件大小:2.99M)
(原文件名:规格书及驱动实例.rar)
加载中...
查看其它22个回答
一周热门
更多
>
相关问题
【东软载波ESF0654 PDS开发板活动】开箱
1 个回答
东软载波ESF0654 PDS开发板外部中断
1 个回答
东软载波ESF0654 PDS开发板高级控制定时器AD16C4T
1 个回答
用串口调试助手为什么只能在hex模式接收发送而在文本模式不行
9 个回答
触摸芯片SC02B/SC04B在地砖灯的设计方案
1 个回答
相关文章
51单片机与蓝牙模块连接
0个评论
51单片机的硬件结构
0个评论
基于51单片机的无线遥控器制作
0个评论
51单片机 AD转换
0个评论
51单片机数码管递增显示
0个评论
如何实现对单片机寄存器的访问
0个评论
基于51单片机的指纹密码锁
0个评论
×
关闭
采纳回答
向帮助了您的知道网友说句感谢的话吧!
非常感谢!
确 认
×
关闭
编辑标签
最多设置5个标签!
51单片机
保存
关闭
×
关闭
举报内容
检举类型
检举内容
检举用户
检举原因
广告推广
恶意灌水
回答内容与提问无关
抄袭答案
其他
检举说明(必填)
提交
关闭
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
×
付费偷看金额在0.1-10元之间
确定
×
关闭
您已邀请
0
人回答
查看邀请
擅长该话题的人
回答过该话题的人
我关注的人
/*
代码测试环境:JME-2核心板+1T指令周期的STC单片机(51内核STC12LE5A60S2)+33M晶振 单片机工作电压3.3V
程序默认IO连接方式:
控制线:RS-P3^5; WR-P3^6; RD-P3^7; CS-P1^0; REST-P1^2;
数据线: DB0-DB7依次连接P0^0-P0^7; DB8-DB15依次连接P2^0-P2^7;(8位模式下DB0-DB7可以不连接)
触摸功能连接方式:(不使用触摸可不连接)
D_CLK-P1^7; D_CS-P1^4; D_DIN-P3^0; D_OUT-P3^1; D_PENIRQ-P3^4;
*/
#define Bus_16 //16位数据模式,如果使用8位模式,请注释此语句,如果使用16位模式,请打开此句
#define LCD_DataPortH P2 //高8位数据口,8位模式下只使用高8位
#define LCD_DataPortL P0 //低8位数据口 ,8位模式下低8位可以不接线,请确认P0口已经上拉10K电阻,不宜太小,最小4.7K,推荐10K.
sbit LCD_RS = P3^5; //数据/命令切换
sbit LCD_WR = P3^6; //写控制
sbit LCD_RD =P3^7; //读控制
sbit LCD_CS=P1^0; //片选
sbit LCD_REST = P1^2; //复位
void delayms(int count) // /* X1ms */
{
int i,j;
for(i=0;i<count;i++)
for(j=0;j<1000;j++);
}
#ifdef Bus_16 //条件编译-16位数据模式
void LCD_Writ_Bus(char VH,char VL) //并行数据写入函数
{
LCD_DataPortH=VH;
LCD_DataPortL=VL;
LCD_WR=0;
LCD_WR=1;
}
#else //条件编译-8位数据模式
void LCD_Writ_Bus(char VH,char VL) //并行数据写入函数
{
LCD_DataPortH=VH;
LCD_WR=0;
LCD_WR=1;
LCD_DataPortH=VL;
LCD_WR=0;
LCD_WR=1;
}
#endif
void Lcd_Write_Com(char VH,char VL) //发送命令-8位参数
{
LCD_RS=0;
LCD_Writ_Bus(VH,VL);
}
void Lcd_Write_Data(char VH,char VL) //发送数据-8位参数
{
LCD_RS=1;
LCD_Writ_Bus(VH,VL);
}
void Lcd_Write_Com_Data(int com,int val) //发送数据命令
{
Lcd_Write_Com(com>>8,com);
Lcd_Write_Data(val>>8,val);
}
void Address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2)
{
Lcd_Write_Com(0x00,0x20);Lcd_Write_Data(x1>>8,x1); //设置X坐标位置
Lcd_Write_Com(0x00,0x21);Lcd_Write_Data(y1>>8,y1); //设置Y坐标位置
Lcd_Write_Com(0x00,0x50);Lcd_Write_Data(x1>>8,x1); //开始X
Lcd_Write_Com(0x00,0x52);Lcd_Write_Data(y1>>8,y1); //开始Y
Lcd_Write_Com(0x00,0x51);Lcd_Write_Data(x2>>8,x2); //结束X
Lcd_Write_Com(0x00,0x53);Lcd_Write_Data(y2>>8,y2); //结束Y
Lcd_Write_Com(0x00,0x22);
}
void Lcd_Init(void)
{
LCD_REST=1;
delayms(5);
LCD_REST=0;
delayms(5);
LCD_REST=1;
LCD_CS=1;
LCD_RD=1;
LCD_WR=1;
delayms(5);
LCD_CS =0; //打开片选使能
//************* Start Initial Sequence **********//
Lcd_Write_Com_Data(0x0001, 0x0100); // set SS and SM bit
Lcd_Write_Com_Data(0x0002, 0x0200); // set 1 line inversion
Lcd_Write_Com_Data(0x0003, 0x1030); // set GRAM write direction and BGR=1.
Lcd_Write_Com_Data(0x0004, 0x0000); // Resize register
Lcd_Write_Com_Data(0x0008, 0x0207); // set the back porch and front porch
Lcd_Write_Com_Data(0x0009, 0x0000); // set non-display area refresh cycle ISC[3:0]
Lcd_Write_Com_Data(0x000A, 0x0000); // FMARK function
Lcd_Write_Com_Data(0x000C, 0x0000); // RGB interface setting
Lcd_Write_Com_Data(0x000D, 0x0000); // Frame marker Position
Lcd_Write_Com_Data(0x000F, 0x0000); // RGB interface polarity
//*************Power On sequence ****************//
Lcd_Write_Com_Data(0x0010, 0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB
Lcd_Write_Com_Data(0x0011, 0x0007); // DC1[2:0], DC0[2:0], VC[2:0]
Lcd_Write_Com_Data(0x0012, 0x0000); // VREG1OUT voltage
Lcd_Write_Com_Data(0x0013, 0x0000); // VDV[4:0] for VCOM amplitude
Lcd_Write_Com_Data(0x0007, 0x0001);
delayms(200); // Dis-charge capacitor power voltage
Lcd_Write_Com_Data(0x0010, 0x1690); // SAP, BT[3:0], AP, DSTB, SLP, STB
Lcd_Write_Com_Data(0x0011, 0x0227); // Set DC1[2:0], DC0[2:0], VC[2:0]
delayms(50); // Delay 50ms
Lcd_Write_Com_Data(0x0012, 0x000D); // 0012
delayms(50); // Delay 50ms
Lcd_Write_Com_Data(0x0013, 0x1200); // VDV[4:0] for VCOM amplitude
Lcd_Write_Com_Data(0x0029, 0x000A); // 04 VCM[5:0] for VCOMH
Lcd_Write_Com_Data(0x002B, 0x000D); // Set Frame Rate
delayms(50); // Delay 50ms
Lcd_Write_Com_Data(0x0020, 0x0000); // GRAM horizontal Address
Lcd_Write_Com_Data(0x0021, 0x0000); // GRAM Vertical Address
// ----------- Adjust the Gamma Curve ----------//
Lcd_Write_Com_Data(0x0030, 0x0000);
Lcd_Write_Com_Data(0x0031, 0x0404);
Lcd_Write_Com_Data(0x0032, 0x0003);
Lcd_Write_Com_Data(0x0035, 0x0405);
Lcd_Write_Com_Data(0x0036, 0x0808);
Lcd_Write_Com_Data(0x0037, 0x0407);
Lcd_Write_Com_Data(0x0038, 0x0303);
Lcd_Write_Com_Data(0x0039, 0x0707);
Lcd_Write_Com_Data(0x003C, 0x0504);
Lcd_Write_Com_Data(0x003D, 0x0808);
//------------------ Set GRAM area ---------------//
Lcd_Write_Com_Data(0x0050, 0x0000); // Horizontal GRAM Start Address
Lcd_Write_Com_Data(0x0051, 0x00EF); // Horizontal GRAM End Address
Lcd_Write_Com_Data(0x0052, 0x0000); // Vertical GRAM Start Address
Lcd_Write_Com_Data(0x0053, 0x013F); // Vertical GRAM Start Address
Lcd_Write_Com_Data(0x0060, 0xA700); // Gate Scan Line
Lcd_Write_Com_Data(0x0061, 0x0001); // NDL,VLE, REV
Lcd_Write_Com_Data(0x006A, 0x0000); // set scrolling line
//-------------- Partial Display Control ---------//
Lcd_Write_Com_Data(0x0080, 0x0000);
Lcd_Write_Com_Data(0x0081, 0x0000);
Lcd_Write_Com_Data(0x0082, 0x0000);
Lcd_Write_Com_Data(0x0083, 0x0000);
Lcd_Write_Com_Data(0x0084, 0x0000);
Lcd_Write_Com_Data(0x0085, 0x0000);
//-------------- Panel Control -------------------//
Lcd_Write_Com_Data(0x0090, 0x0010);
Lcd_Write_Com_Data(0x0092, 0x0000);
Lcd_Write_Com_Data(0x0007, 0x0133); // 262K color and display ON
LCD_CS =1; //关闭片选使能
}
void Pant(char VH,char VL)
{
int i,j;
LCD_CS =0; //打开片选使能
Address_set(0,0,240,320);
for(i=0;i<320;i++)
{
for (j=0;j<240;j++)
{
Lcd_Write_Data(VH,VL);
}
}
LCD_CS =1; //关闭片选使能
}
main()
{
Lcd_Init(); //TFT初始化
Pant(0xff,0xff); //TFT清屏
while(1)
{
Pant(0xf8,0x00); //红 {MOD}
delayms(2000);
Pant(0X07,0xE0); //绿 {MOD}
delayms(2000);
Pant(0x00,0x1f); //蓝 {MOD}
delayms(2000);
}
}
目录:
触摸测试程序
LCD图片取模软件Image2Lcd
C51图片显示测试程序
C51刷屏测试程序
需要单片屏的可以联系我 30元/片 QQ277152571
(原文件名:20111122114937.jpg)
点击此处下载 ourdev_697865IS91H5.rar(文件大小:2.99M) (原文件名:规格书及驱动实例.rar)
一周热门 更多>