完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
#include
#define Bus_16 //16位数据模式,如果使用8位模式,请注释此语句,如果使用16位模式,请打开此句 #define LCD_DataPortH P3 //高8位数据口,8位模式下只使用高8位 #define LCD_DataPortL P1 //低8位数据口 ,8位模式下低8位可以不接线,请确认P0口已经上拉10K电阻,不宜太小,最小4.7K,推荐10K. ***it LCD_RS = P2^6; //数据/命令切换 ***it LCD_WR = P2^5; //写控制 ***it LCD_RD =P2^4; //读控制 ***it LCD_CS=P2^3; //片选 ***it LCD_REST = P2^2; //复位 void delayms(int count) // /* X1ms */ { int i,j; for(i=0;i } #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); Lcd_Write_Com_Data(0x0002,0x0700); Lcd_Write_Com_Data(0x0003,0x1030); Lcd_Write_Com_Data(0x0004,0x0000); Lcd_Write_Com_Data(0x0008,0x0207); Lcd_Write_Com_Data(0x0009,0x0000); Lcd_Write_Com_Data(0x000A,0x0000); Lcd_Write_Com_Data(0x000C,0x0000); Lcd_Write_Com_Data(0x000D,0x0000); Lcd_Write_Com_Data(0x000F,0x0000); //power on sequence VGHVGL Lcd_Write_Com_Data(0x0010,0x0000); Lcd_Write_Com_Data(0x0011,0x0007); Lcd_Write_Com_Data(0x0012,0x0000); Lcd_Write_Com_Data(0x0013,0x0000); //vgh Lcd_Write_Com_Data(0x0010,0x1290); Lcd_Write_Com_Data(0x0011,0x0227); //delayms(100); //vregiout Lcd_Write_Com_Data(0x0012,0x001d); //0x001b //delayms(100); //vom amplitude Lcd_Write_Com_Data(0x0013,0x1500); //delayms(100); //vom H Lcd_Write_Com_Data(0x0029,0x0018); Lcd_Write_Com_Data(0x002B,0x000D); //gamma Lcd_Write_Com_Data(0x0030,0x0004); Lcd_Write_Com_Data(0x0031,0x0307); Lcd_Write_Com_Data(0x0032,0x0002);// 0006 Lcd_Write_Com_Data(0x0035,0x0206); Lcd_Write_Com_Data(0x0036,0x0408); Lcd_Write_Com_Data(0x0037,0x0507); Lcd_Write_Com_Data(0x0038,0x0204);//0200 Lcd_Write_Com_Data(0x0039,0x0707); Lcd_Write_Com_Data(0x003C,0x0405);// 0504 Lcd_Write_Com_Data(0x003D,0x0F02); //ram Lcd_Write_Com_Data(0x0050,0x0000); Lcd_Write_Com_Data(0x0051,0x00EF); Lcd_Write_Com_Data(0x0052,0x0000); Lcd_Write_Com_Data(0x0053,0x013F); Lcd_Write_Com_Data(0x0060,0xA700); Lcd_Write_Com_Data(0x0061,0x0001); Lcd_Write_Com_Data(0x006A,0x0000); // 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); // Lcd_Write_Com_Data(0x0090,0x0010); Lcd_Write_Com_Data(0x0092,0x0600); Lcd_Write_Com_Data(0x0093,0x0003); Lcd_Write_Com_Data(0x0095,0x0110); Lcd_Write_Com_Data(0x0097,0x0000); Lcd_Write_Com_Data(0x0098,0x0000); Lcd_Write_Com_Data(0x0007,0x0133); Lcd_Write_Com(0x00,0x22); LCD_CS =1; //关闭片选使能 } void Pant(char VH,char VL) { int i,j; LCD_CS =0; //打开片选使能 Address_set(0,0,239,319); 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); //红色 delayms(2000); Pant(0X07,0xE0); //绿色 delayms(2000); Pant(0x00,0x1f); //蓝色 delayms(2000); } } |
|
相关推荐
5个回答
|
|
这种事情只能帮顶
|
|
|
|
你试试把IO口都设置为准双向
|
|
|
|
I/O口有没有与程序对应,要根据原理图,还有高低数据位是否对应原理图上的寄存器(一般是P2高,P0低)
|
|
|
|
|
|
先做个简单的,先受控,再说别的事
|
|
|
|
只有小组成员才能发言,加入小组>>
3278 浏览 9 评论
2955 浏览 16 评论
3455 浏览 1 评论
8987 浏览 16 评论
4050 浏览 18 评论
1102浏览 3评论
570浏览 2评论
const uint16_t Tab[10]={0}; const uint16_t *p; p = Tab;//报错是怎么回事?
568浏览 2评论
用NUC131单片机UART3作为打印口,但printf没有输出东西是什么原因?
2301浏览 2评论
NUC980DK61YC启动随机性出现Err-DDR是为什么?
1857浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 05:51 , Processed in 1.274612 second(s), Total 92, Slave 71 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号