|
楼主求帮忙。。。。我发一段代码,也是430的,就是跑不起来/**************控制端定义**************/
/*********选用P4口送DH,P3口送DL********/
/******P9.0控制CS端,P9.1控制RS端******/
/******P9.2控制RW端,P9.3控制RD端******/
/*************P9.4控制RES端************/
#define TFT_CS_1 P9OUT|=BIT0 //片选端
#define TFT_CS_0 P9OUT&=~BIT0
#define TFT_RS_1 P9OUT|=BIT2 //数据命令选择端
#define TFT_RS_0 P9OUT&=~BIT2
#define TFT_WR_1 P9OUT|=BIT1 //写
#define TFT_WR_0 P9OUT&=~BIT1
#define TFT_RD_1 P9OUT|=BIT3 //读
#define TFT_RD_0 P9OUT&=~BIT3
#define TFT_RES_1 P9OUT|=BIT4 //复位
#define TFT_RES_0 P9OUT&=~BIT4
/**************************************/
void LCD_WR_DATA(uint Data)
{
uchar DH,DL;
DH=Data>>8;
DL=Data;
TFT_CS_0;
//delayms(1);
TFT_RS_1;
//delayms(1);
P4OUT=DH;
P3OUT=DL;
TFT_WR_0;
//delayms(1);
TFT_WR_1;
//delayms(1);
TFT_CS_1;
//delayms(1);
}
/***************************************/
/***********LCD写寄存器*****************/
void LCD_WR_REG(uint Index)
{
uchar DH,DL;
DH=Index>>8;
DL=Index;
TFT_CS_0;
//delayms(1);
TFT_RS_0;
//delayms(1);
P4OUT=DH;
P3OUT=DL;
TFT_WR_0;
//delayms(1);
TFT_WR_1;
//delayms(1);
TFT_CS_1;
//delayms(1);
}
/**************************************/
/********在指定寄存器写数据************/
void LCD_WriteReg(uint Index,uint Data)
{
LCD_WR_REG(Index);
LCD_WR_DATA(Data);
}
/**************************************/
/**********初始化驱动芯片**************/
void ILI9481_Initial()
{
LCD_WR_REG(0x11);
delayms(20);
LCD_WR_REG(0xD0);
LCD_WR_DATA(0x07);
LCD_WR_DATA(0x42);
LCD_WR_DATA(0x18);
LCD_WR_REG(0xD1);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x07);
LCD_WR_DATA(0x10);
LCD_WR_REG(0xD2);
LCD_WR_DATA(0x01);
LCD_WR_DATA(0x02);
LCD_WR_REG(0xC0);
LCD_WR_DATA(0x10);
LCD_WR_DATA(0x3B);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x02);
LCD_WR_DATA(0x11);
LCD_WR_REG(0xC5);
LCD_WR_DATA(0x03);
LCD_WR_REG(0xC8);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x32);
LCD_WR_DATA(0x36);
LCD_WR_DATA(0x45);
LCD_WR_DATA(0x06);
LCD_WR_DATA(0x16);
LCD_WR_DATA(0x37);
LCD_WR_DATA(0x75);
LCD_WR_DATA(0x77);
LCD_WR_DATA(0x54);
LCD_WR_DATA(0x0C);
LCD_WR_DATA(0x00);
LCD_WR_REG(0x36);
LCD_WR_DATA(0x0A);
LCD_WR_REG(0x3A);
LCD_WR_DATA(0x55);
LCD_WR_REG(0x2A);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x01);
LCD_WR_DATA(0x3F);
LCD_WR_REG(0x2B);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x01);
LCD_WR_DATA(0xE0);
delayms(120);
LCD_WR_REG(0x29);
LCD_WR_REG(0x2c);
}
/***************************************/
/*************初始化函数****************/
void init_TFT()
{
TFT_CS_1;
delayms(50);
TFT_RES_0;
delayms(150);
TFT_RES_1;
delayms(50);
ILI9481_Initial();
}
void main()
{
init_430();
init_TFT();
P8DIR=0xff;
while(1)
{
ClearScreen(BLACK);
P8OUT=0xff;
delayms(1000);
P8OUT=0x00;
delayms(1000);
}
}
P8.1接了一个led,实测led正常闪烁但是液晶只有背光亮,求解决办法
|
|