最新AVR驱动TFT(内含颜色设置).doc

上传人:1595****071 文档编号:33832352 上传时间:2022-08-12 格式:DOC 页数:10 大小:212KB
返回 下载 相关 举报
最新AVR驱动TFT(内含颜色设置).doc_第1页
第1页 / 共10页
最新AVR驱动TFT(内含颜色设置).doc_第2页
第2页 / 共10页
点击查看更多>>
资源描述

《最新AVR驱动TFT(内含颜色设置).doc》由会员分享,可在线阅读,更多相关《最新AVR驱动TFT(内含颜色设置).doc(10页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、精品资料AVR驱动TFT(内含颜色设置).AVR128驱动2.4寸TFT(主控芯片ILI9325) 2010-08-29 03:46:53 阅读139 评论0 字号:大中小订阅 1、原理图:AVR128与TFT最小系统原理图。2、程序/*/*lcd.c*/#include lcd.hint main(void)InitIO();/*IO口初始化*/ILI9325_Initial();/*LCD初始化*/ClearScreen(0xFFFF);/*清屏*/LCD_SetPos(0,0,239,319);while(1)Pant(0xf800,0,240,0,40); /红色Pant(0X07E0

2、,0,240,40,80); /绿色Pant(0x001f,0,240,80,120); /蓝色Pant(0xf800,0,240,120,160); /红色Pant(0X07E0,0,240,160,200); /绿色Pant(0x001f,0,240,200,240); /蓝色Pant(0xf800,0,240,240,280); /红色Pant(0X07E0,0,240,280,320); /绿色delayms(1000);delayms(1000);ClearScreen(0xFFFF);Pant(0xf800,0,240,0,320); /红色delayms(1000);delaym

3、s(1000);ClearScreen(0xFFFF);Pant(0X07E0,0,240,0,320); /绿色delayms(1000);delayms(1000);ClearScreen(0xFFFF);Pant(0x001f,0,240,0,320); /蓝色delayms(1000);delayms(1000);ClearScreen(0xFFFF); return 1;/*/*lcd.h*/*包含文件*/#include #include#include/*类型定义*/typedef unsigned char uint8;typedef unsigned int uint16;t

4、ypedef unsigned long uint32;#define WINDOW_XADDR_START0x0050 / Horizontal Start Address Set#define WINDOW_XADDR_END0x0051 / Horizontal End Address Set#define WINDOW_YADDR_START0x0052 / Vertical Start Address Set#define WINDOW_YADDR_END0x0053 / Vertical End Address Set#define GRAM_XADDR 0x0020 / GRAM

5、 Horizontal Address Set#define GRAM_YADDR 0x0021 / GRAM Vertical Address Set#define GRAMWR 0x0022 / memory write#define _nop_() asm(NOP)#define LCD_RS_DDR DDRG /数据/命令切换#define LCD_RS_PORT PORTG#define LCD_RS_BIT 2#define LCD_CS_DDR DDRG/片选#define LCD_CS_PORT PORTG#define LCD_CS_BIT3#define LCD_WR_DD

6、RDDRG/写控制#define LCD_WR_PORT PORTG#define LCD_WR_BIT0#define LCD_RD_DDRDDRG/读控制#define LCD_RD_PORTPORTG#define LCD_RD_BIT1#define LCD_RST_DDR DDRG/复位 #define LCD_RST_PORT PORTG#define LCD_RST_BIT 4#define LCD_CS_H LCD_CS_PORT |= 1LCD_CS_BIT#define LCD_CS_L LCD_CS_PORT &= (1LCD_CS_BIT) /SCE#define LC

7、D_RS_H LCD_RS_PORT |= 1LCD_RS_BIT#define LCD_RS_L LCD_RS_PORT &= (1LCD_RS_BIT) /A0#define LCD_RST_H LCD_RST_PORT |= 1LCD_RST_BIT#define LCD_RST_L LCD_RST_PORT &= (1LCD_RST_BIT) /RST#define LCD_WR_H LCD_WR_PORT |= 1LCD_WR_BIT#define LCD_WR_L LCD_WR_PORT &= (1LCD_WR_BIT)#define LCD_RD_H LCD_RD_PORT |=

8、 1LCD_RD_BIT#define LCD_RD_L LCD_RD_PORT &= (1LCD_RD_BIT)#define ComCtrl PORTG#define ComCtrlDDR DDRG#define DataH PORTC#define DataL PORTA#define DataDDRH DDRC#define DataDDRL DDRA /*作 者:jundg函数名:void InitIO(void)函数功能:IO口初始化函数参数:无返回值:无*/void InitIO(void)ComCtrlDDR=0x1f;DataDDRH=0xff;DataDDRL=0xff;D

9、ataH=0xff;DataL=0xff;ComCtrl=0x1f;/*作 者:jundg函数名:void delayms(unsigned int count)函数功能:延时函数函数参数:时间值返回值:无*/void delayms(unsigned int count) int i,j; for(i=0;icount;i+) for(j=0;j8;n=y;Write_Cmd(0x00,x);Write_Data(m,n);/*作 者:jundg函数名:static void LCD_SetPos(unsigned int x0,unsigned int x1,unsigned int y0

10、,unsigned int y1)函数功能:设置显示区域函数参数:x0行起始点,x1行结束点,y0列起始点,y1列结束点返回值:无*/static void LCD_SetPos(unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1) Write_Cmd_Data(WINDOW_XADDR_START,x0); Write_Cmd_Data(WINDOW_XADDR_END,x1); Write_Cmd_Data(WINDOW_YADDR_START,y0); Write_Cmd_Data(WINDOW_YADDR_EN

11、D,y1); Write_Cmd_Data(GRAM_XADDR,x0); Write_Cmd_Data(GRAM_YADDR,y0); Write_Cmd (0x00,0x22);/LCD_WriteCMD(GRAMWR);/*作 者:jundg函数名:void Pant(int dcolor,unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1)函数功能:设置显示区域并显示颜色函数参数:dcolor颜色值,x0行起始点,x1行结束点,y0列起始点,y1列结束点返回值:无*/void Pant(int dcolor,u

12、nsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1)int i,j;LCD_SetPos(x0,x1,y0,y1); for(i=0;i320;i+) for (j=0;j8,dcolor); /*作 者:jundg函数名:void ClearScreen(unsigned int bColor)函数功能:清屏函数参数:bColor=0xffff清屏返回值:无*/void ClearScreen(unsigned int bColor)unsigned int i,j;LCD_SetPos(0,240,0,320);/3

13、20x240for (i=0;i322;i+) for (j=0;j8,bColor);/*作 者:jundg函数名:void ILI9325_Initial(void)函数功能:LCD初始化函数参数:无返回值:无*/void ILI9325_Initial(void) LCD_CS_H;delayms(5);LCD_RST_L;delayms(5);LCD_RST_H;delayms(5);delayms(50);Write_Cmd_Data(0x0001,0x0100); Write_Cmd_Data(0x0002,0x0700); Write_Cmd_Data(0x0003,0x1030

14、); Write_Cmd_Data(0x0004,0x0000); Write_Cmd_Data(0x0008,0x0207); Write_Cmd_Data(0x0009,0x0000);Write_Cmd_Data(0x000A,0x0000); Write_Cmd_Data(0x000C,0x0000); Write_Cmd_Data(0x000D,0x0000);Write_Cmd_Data(0x000F,0x0000);/power on sequence VGHVGLWrite_Cmd_Data(0x0010,0x0000); Write_Cmd_Data(0x0011,0x000

15、7); Write_Cmd_Data(0x0012,0x0000); Write_Cmd_Data(0x0013,0x0000); /vgh Write_Cmd_Data(0x0010,0x1290); Write_Cmd_Data(0x0011,0x0227);/delayms(100);/vregiout Write_Cmd_Data(0x0012,0x001d); /0x001b/delayms(100); /vom amplitudeWrite_Cmd_Data(0x0013,0x1500);/delayms(100); /vom HWrite_Cmd_Data(0x0029,0x00

16、18); Write_Cmd_Data(0x002B,0x000D); /gammaWrite_Cmd_Data(0x0030,0x0004);Write_Cmd_Data(0x0031,0x0307);Write_Cmd_Data(0x0032,0x0002);/ 0006Write_Cmd_Data(0x0035,0x0206);Write_Cmd_Data(0x0036,0x0408);Write_Cmd_Data(0x0037,0x0507); Write_Cmd_Data(0x0038,0x0204);/0200Write_Cmd_Data(0x0039,0x0707); Write

17、_Cmd_Data(0x003C,0x0405);/ 0504Write_Cmd_Data(0x003D,0x0F02); /ramWrite_Cmd_Data(0x0050,0x0000); Write_Cmd_Data(0x0051,0x00EF);Write_Cmd_Data(0x0052,0x0000); Write_Cmd_Data(0x0053,0x013F); Write_Cmd_Data(0x0060,0xA700); Write_Cmd_Data(0x0061,0x0001); Write_Cmd_Data(0x006A,0x0000); /Write_Cmd_Data(0x

18、0080,0x0000); Write_Cmd_Data(0x0081,0x0000); Write_Cmd_Data(0x0082,0x0000); Write_Cmd_Data(0x0083,0x0000); Write_Cmd_Data(0x0084,0x0000); Write_Cmd_Data(0x0085,0x0000); /Write_Cmd_Data(0x0090,0x0010); Write_Cmd_Data(0x0092,0x0600); Write_Cmd_Data(0x0093,0x0003); Write_Cmd_Data(0x0095,0x0110); Write_Cmd_Data(0x0097,0x0000); Write_Cmd_Data(0x0098,0x0000);Write_Cmd_Data(0x0007,0x0133);/Write_Cmd_Data(0x0022);/

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 小学资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁