LPC2132 驱动ILI9320 TFT 程序问题
[复制链接]
这是一个TFT显示一幅红色图片的程序,但是在板上运行时,显示完一幅完整的图片要得差不多一个小时,不知道是什么原因, 请各位大侠 挥指知之间 指点指点 ..................不胜感激.
#include<LPC214X.h> //#include"init.h" typedef unsigned char uint8; // defined for unsigned 8-bits integer variable 无符号8位整型变量 typedef signed char int8; // defined for signed 8-bits integer variable 有符号8位整型变量 typedef unsigned short uint16; // defined for unsigned 16-bits integer variable 无符号16位整型变量 typedef signed short int16; // defined for signed 16-bits integer variable 有符号16位整型变量 typedef unsigned int uint32; // defined for unsigned 32-bits integer variable 无符号32位整型变量 typedef signed int int32; // defined for signed 32-bits integer variable 有符号32位整型变量
//TFT管脚定义 #define TFT_CS (1 << 26) #define TFT_RS (1 << 27) #define TFT_WR (1 << 28) #define TFT_RD (1 << 29) #define TFT_RST (1 << 30) #define TFT_BLK 0x000F0000 #define TFT_DAT 0xFFFF0000 #define TFT_L (1 << 20) #define TFT_U (1 << 21) #define TFT_R (1 << 22) #define TFT_D (1 << 23)
//LED管脚定义 #define LED (1 << 3)
//************** 颜色定义 ***************************
#define RED 0xF8000000 // 红色 #define GREEN 0x03E00000 // 绿色 #define BLUE 0x001F0000 // 蓝色 #define WRITE 0xFFFF0000 // 白色 #define BLACK 0x00000000 // 黑色 #define ORANGE 0xF8600000 // 橙色 #define YELLOW 0xFFE00000 // 黄色 #define CYAN 0x07FF0000 // 青色 #define PROPLE 0xF81F0000 // 紫色 #define NOCOLOR 0x00010000 // 无色
//************** 定义屏宽 ***************************
#define WIDTH 240 // 屏宽 #define HEIGTH 320 // 屏高
//变量定义 uint8 To_1s = 0; uint8 i = 0;
//----------------------------- //function description void delay(uint8 n);
void lcd_initial(void); void lcd_display(void); void send_inst(uint32); void send_data(uint32 dat); void set_reg(uint32 address,uint32 dat); void initial01(void); void initial02(void); void initial03(void);
void Pllinit(void); void T0MR0init(void);
void IRQ_Timer0 (void) __irq{
if((IO0PIN&LED) == LED) { IO0CLR = LED; }else IO0SET = LED; T0IR = 0x01; /* 清除中断标志 */ VICVectAddr = 0x00; /* 通知VIC中断处理结束 */ } //************************************************************************************************************* // main function //************************************************************************************************************* int main() {
delay(10);
PINSEL0 = 0x00000000; PINSEL1 = 0x00000000; PINSEL2 = 0x00000000; IO0DIR = TFT_CS | TFT_RS | TFT_WR | TFT_RD | TFT_RST | TFT_BLK | LED; IO1DIR = TFT_DAT; //TFT数据管脚设置为输出
IO0CLR = TFT_BLK; //打开TFT背光始化
T0MR0init(); //定时器初始化 lcd_initial(); //----------------------------------- while(1) { lcd_display(); }
}
//T0MR0 定时器初始化子函数 void T0MR0init(void) { T0TC = 0; /* 定时器设置为0 */ T0PR = 0; /* 时钟不分频 */ T0MCR = 0x03; /* 设置T0MR0匹配后复位T0TC,并产生中断标志 */ //T0MR0 = 1875; /* 0.5秒钟定时 */ T0MR0 = 12000000; T0TCR = 0x01; /* 启动定时器 */ /* 设置定时器0中断IRQ */
VICIntSelect = 0x00; /* 所有中断通道设置为IRQ中断 */ VICVectCntl0 = 0x20 | 0x04; /* 设置定时器0中断通道分配最高优先级 */ VICVectAddr0 = (unsigned int)IRQ_Timer0; /* 设置中断服务程序地址 */ VICIntEnable = 1 << 0x04; }
//**************************************************** // delay //**************************************************** void delay(uint8 n) { uint8 i=0; uint16 j; for(i=0;i<n;i++) { for(j=0;j<6418;j++);//__RESET_WATCHDOG(); //复位看门狗 } } //************************************************************************************************************* //lcd initial function //input:no //output:no //************************************************************************************************************* void lcd_initial(void) { IO0CLR = TFT_RST; delay(10); //10ms IO0SET = TFT_RST; delay(10); //10ms initial01(); initial02(); initial03(); set_reg(0x070000,0x01730000); } //***************************************************** // initial01/02/03 //***************************************************** void initial01(void) { //set_reg(0XE50000,0x80000000); set_reg(0x000000,0x00010000); delay(50); //20ms>10ms //set_reg(0x2b0000,0x00100000); set_reg(0x010000,0x01000000); set_reg(0x020000,0x07000000); set_reg(0x030000,0x12300000); set_reg(0x040000,0x00000000); set_reg(0x080000,0x02020000); set_reg(0x090000,0x00000000); set_reg(0x0a0000,0x00000000); set_reg(0x0c0000,0x00000000); set_reg(0x0d0000,0x00000000); set_reg(0x0f0000,0x00000000); delay(50);
set_reg(0x500000,0x00000000); set_reg(0x510000,0x00ef0000); set_reg(0x520000,0x00000000); set_reg(0x530000,0x013f0000); set_reg(0x600000,0x27000000); set_reg(0x610000,0x00010000); set_reg(0x6a0000,0x00000000); set_reg(0x800000,0x00000000); set_reg(0x810000,0x00000000); set_reg(0x820000,0x00000000); set_reg(0x830000,0x00000000); set_reg(0x840000,0x00000000); set_reg(0x850000,0x00000000); set_reg(0x900000,0x00100000); set_reg(0x920000,0x00000000); set_reg(0x930000,0x00030000); set_reg(0x950000,0x01100000); set_reg(0x970000,0x00000000); set_reg(0x980000,0x00000000); } void initial02(void) { set_reg(0x100000,0x00000000); set_reg(0x110000,0x00000000); set_reg(0x120000,0x00000000); set_reg(0x130000,0x00000000); delay(200); //200ms set_reg(0x100000,0x17b00000); set_reg(0x110000,0x00000000); delay(50); //50ms set_reg(0x120000,0x013e0000); delay(50); //50ms set_reg(0x130000,0x1f000000); set_reg(0x290000,0x000f0000); delay(50); //50ms set_reg(0x200000,0x00000000); set_reg(0x210000,0x00000000); } void initial03(void) { set_reg(0x300000,0x00040000); set_reg(0x310000,0x00070000); set_reg(0x320000,0x01000000); set_reg(0x350000,0x00070000); set_reg(0x360000,0x04000000); set_reg(0x370000,0x07000000); set_reg(0x380000,0x00050000); set_reg(0x390000,0x07070000); set_reg(0x3c0000,0x00000000); set_reg(0x3d0000,0x04000000); }
//***************************************************** //set reg //input:address and data //output: no //***************************************************** void set_reg(uint32 address,uint32 dat) { send_inst(address); send_data(dat); }
//***************************************************** //send data //input:data //output:no //***************************************************** void send_data(uint32 dat) { IO0CLR = TFT_CS; IO0SET = TFT_RS; IO0SET = TFT_RD; IO1CLR = TFT_DAT; IO1SET = dat; IO0CLR = TFT_WR; IO0SET = TFT_WR; }
//***************************************************** //sene inst //input:inst //output:no //***************************************************** void send_inst(uint32 inst) { IO0CLR = TFT_CS; IO0CLR = TFT_RS; IO0SET = TFT_RD; IO1CLR = TFT_DAT; IO1SET = inst; IO0CLR = TFT_WR; IO0SET = TFT_WR; } //***************************************************** //lcd output function //input:station //output:no //***************************************************** void lcd_display(void) { uint16 hang; uint8 lie; //------------------ send_inst(0x00220000); IO0CLR = TFT_CS; IO0SET = TFT_RS; IO0SET = TFT_RD; IO1CLR = TFT_DAT; IO1SET = RED; for(hang=1;hang<=320;hang++) for(lie=1;lie<=240;lie++) { IO0CLR = TFT_WR; IO0SET = TFT_WR; } }
[ 本帖最后由 Randy302 于 2010-11-6 10:55 编辑 ]
|