资源描述:
《avr128驱动2.4寸tft(主控芯片ili9325)》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、AVR128驱动2.4寸TFT(主控芯片ILI9325)单片机2010-08-2903:46:53阅读255评论0 字号:大中小 订阅 1、原理图:AVR128与TFT最小系统原理图。 2、程序/************************************/*lcd.c************************************/#include"lcd.h"intmain(void){ InitIO();/*IO口初始化*/ ILI9325_Initial();/*LCD
2、初始化*/ ClearScreen(0xFFFF);/*清屏*/ //LCD_SetPos(0,0,239,319); while(1) { Pant(0xf800,0,240,0,40); //红色 Pant(0X07E0,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,
3、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); delayms(1000); ClearScreen(0xFFFF); Pant(0X07E0,0,240,0,320);//绿色 delayms(1000);
4、delayms(1000); ClearScreen(0xFFFF); Pant(0x001f,0,240,0,320);//蓝色 delayms(1000); delayms(1000); ClearScreen(0xFFFF); } return1;} /************************************/*lcd.h************************************//*********************包含文件**************
5、***********/#include#include#include/*********************类型定义*************************/typedefunsignedcharuint8;typedefunsignedint uint16;typedefunsignedlonguint32;#defineWINDOW_XADDR_START 0x0050//HorizontalStar
6、tAddressSet#defineWINDOW_XADDR_END 0x0051//HorizontalEndAddressSet#defineWINDOW_YADDR_START 0x0052//VerticalStartAddressSet#defineWINDOW_YADDR_END 0x0053//VerticalEndAddressSet#defineGRAM_XADDR 0x0020//GRAMHorizontalAddressSet#defineGRAM_YADDR 0
7、x0021//GRAMVerticalAddressSet#defineGRAMWR 0x0022//memorywrite#define_nop_()asm("NOP")#defineLCD_RS_DDR DDRG //数据/命令切换#defineLCD_RS_PORTPORTG#defineLCD_RS_BIT 2#defineLCD_CS_DDR DDRG //片选#defineLCD_CS_PORTPORTG#defineLCD_CS_BIT 3#defineLCD_WR_DDR
8、DDRG //写控制#defineLCD_WR_PORTPORTG#defineLCD_WR_BIT 0#defineLCD_RD_DDR DDRG //读控制#defineLCD_RD_PORT PORTG#defineLCD_RD_BIT 1#defineLCD_RST_DDRDDRG //复位#defineLCD_RST_PORTPORTG#defineLCD_RST_BIT4#defineLCD_CS_H LCD_CS_PORT
9、= 1<