我的相关程序如下:
1. 2410lib.c 中相关部分:
//===========================[ PORTS ]===================================================*
void Port_Init(void)
{
.....
//=== PORT C GROUP
//Ports : GPC15 GPC14 GPC13 GPC12 GPC11 GPC10 GPC9 GPC8 GPC7 GPC6 GPC5 GPC4 GPC3 GPC2 GPC1 GPC0
//Signal : VD7 VD6 VD5 VD4 VD3 VD2 VD1 VD0 LCDVF2 LCDVF1 LCDVF0 VM VFRAME VLINE VCLK LEND
//Binary : 10 10 , 01 01 , 01 01 , 01 01 , 10 10 , 10 10 , 10 10 , 10 10
rGPCCON = 0xa555aaaa;
rGPCUP = 0x00ff; // The pull up function is disabled GPC[7:0]
//=== PORT D GROUP
//=== The pin8-pin11 are set as BackLight,Reset,WRite,ReaD
//Ports : GPD15 GPD14 GPD13 GPD12 GPD11 GPD10 GPD9 GPD8 GPD7 GPD6 GPD5 GPD4 GPD3 GPD2 GPD1 GPD0
//Signal : VD23 VD22 VD21 VD20 VD19 VD18 VD17 VD16 VD15 VD14 VD13 VD12 VD11 VD10 VD9 VD8
//Binary : 10 10 , 10 10 , 10 10 , 10 10 , 10 10 , 10 10 , 10 10 ,10 10
rGPDCON = 0xaaaaaaaa;
rGPDUP = 0x0000; // The pull up function is enabled GPD[15:0]
....
}
2. 头文件相关部分:
#define LCD_BACKLIGHT_H rGPCDAT |= (1<<8) //GPC8 is BackLight,WR,RD are not defined.
#define LCD_CS_H rGPCDAT |= (1<<9) //GPC9 is CS
#define LCD_CS_L rGPCDAT &= ~(1<<9)
#define LCD_WR_H rGPCDAT |= (1<<10) //GPC10 is WR
#define LCD_WR_L rGPCDAT &= ~(1<<10)
#define LCD_RD_H rGPCDAT |= (1<<11) //GPC11 is RD
#define LCD_RD_L rGPCDAT &= ~(1<<11)
#define LCD_RS_H rGPCDAT |= (1<<12) //GPC12 is RS
#define LCD_RS_L rGPCDAT &= ~(1<<12)
#define LCD_RESET_H rGPCDAT |= (1<<13) //GPC13 is reset signal to ili9320
#define LCD_RESET_L rGPCDAT &= ~(1<<13)
#define NOP __asm{ nop;}
#define LCD_PORT rGPDDAT //将GPDDAT端口0x56000034作为LCD端口。
......
3. c程序中相关部分:
void LCD_SetReg(U16 addr,U16 dat) //change the INT8U/16U as U16,
{
LCD_CS_L;
NOP;
LCD_RS_L;
LCD_WR_L;
NOP;
NOP;
LCD_WR_H;
LCD_PORT =addr; //这里的指令执行后,相应地址0x56000034内容没有任何变化。
LCD_Delay(15);
LCD_RS_H;
LCD_WR_L;
LCD_WR_H;
LCD_PORT =dat; //故障现象同上
LCD_WR_L;
NOP;
NOP;
LCD_WR_H;
LCD_CS_H;
}
.....
static void Lcd_Init(void)
{
LCD_BACKLIGHT_H; //执行后点亮了背光
LCD_Delay(15);
LCD_RESET_H; //执行后GPCDAT的对应位被置高。
LCD_Delay(1);
LCD_RESET_L; //执行后GPCDAT的对应位被置低。
LCD_Delay(15);
LCD_RESET_H; //执行后GPCDAT的对应位被置高。
LCD_Delay(150);
LCD_SetReg(0xE5,0x8000);
LCD_SetReg(0x00,0x0001);
LCD_SetReg(0x2B,0x0010);
LCD_SetReg(0x01,0x0100);//driver output control,
LCD_SetReg(0x02,0x0700);//LCD driving control
LCD_SetReg(0x03,0x1230);
LCD_SetReg(0x04,0x0000);
LCD_SetReg(0x08,0x0202);//display control 2lines. BP=2lines,FP=2lines BackPorch,FrontPorch
LCD_SetReg(0x09,0x0000);
LCD_SetReg(0x0A,0x0000);
LCD_SetReg(0x0C,0x0000);
LCD_SetReg(0x0D,0x0000);
LCD_SetReg(0x0F,0x0000);
LCD_SetReg(0x50,0x0000);
LCD_SetReg(0x51,0x00EF);
LCD_SetReg(0x52,0x0000);
LCD_SetReg(0x53,0x013F);
LCD_SetReg(0x60,0x2700);
LCD_SetReg(0x61,0x0001);
LCD_SetReg(0x6A,0x0000);
LCD_SetReg(0x80,0x0000);
LCD_SetReg(0x81,0x0000);
LCD_SetReg(0x82,0x0000);
LCD_SetReg(0x83,0x0000);
LCD_SetReg(0x84,0x0000);
LCD_SetReg(0x85,0x0000);
LCD_SetReg(0x90,0x0010);
LCD_SetReg(0x92,0x0000);
LCD_SetReg(0x93,0x0003);
LCD_SetReg(0x95,0x0110);
LCD_SetReg(0x97,0x0000);
LCD_SetReg(0x98,0x0000);
LCD_SetReg(0x10,0x0000);//power control 1
LCD_SetReg(0x11,0x0000);//power control 2
LCD_SetReg(0x12,0x0000);//...
LCD_SetReg(0x13,0x0000);//power control 4
LCD_Delay(2000); //>200ms
LCD_SetReg(0x10,0x17B0);
LCD_SetReg(0x11,0x0004);
LCD_Delay(550); //>50ms
LCD_SetReg(0x12,0x013E);
LCD_Delay(550); //>50ms
LCD_SetReg(0x13,0x1F00);
LCD_SetReg(0x29,0x000F);
LCD_Delay(550); //>50ms
LCD_SetReg(0x20,0x0000);
LCD_SetReg(0x21,0x0000);
LCD_SetReg(0x30,0x0204);
LCD_SetReg(0x31,0x0001);
LCD_SetReg(0x32,0x0000);
LCD_SetReg(0x35,0x0206);
LCD_SetReg(0x36,0x0600);
LCD_SetReg(0x37,0x0500);
LCD_SetReg(0x38,0x0505);
LCD_SetReg(0x39,0x0407);
LCD_SetReg(0x3C,0x0500);
LCD_SetReg(0x3D,0x0503);
LCD_SetReg(0x07,0x0173);//display control 1
} |