标题:
ILI9325驱动程序
[打印本页]
作者:
aniaiye
时间:
2010-5-19 10:22
标题:
ILI9325驱动程序
最近刚刚开始搞这个芯片,用来驱动一块320*240的2.8"液晶屏,结果试了一天都没有结果。后来在网上下载了一些初始化寄存器的例子,参考以后还是不行,不知道哪个环节出了问题。插一句,本来屏幕边缘一小块区域是可以随着初始化刷屏改变颜色的,后来也不知改了什么地方,连这个效果也看不到了。
下面是我的初始化程序,用的是飞思卡尔EP100的单片机。
//初始化 ili9325 控制器
void ili9325_Init()
{
Dly_ms(10);
LCMCS=1;
LCMRS=1;
LCMWr=1;
LCMRd=1;
LCMLedOn=0;
Dly_ms(50);
ili9325_WriteRegister(0xe7,0x0010);
//************* Start Initial Sequence **********//
ili9325_WriteRegister(0x00,0x0001);
ili9325_WriteRegister(0x01,0x0100); // SS set high
ili9325_WriteRegister(0x02,0x0700); //power on sequence
ili9325_WriteRegister(0x03,0x1030); //65K
ili9325_WriteRegister(0x04,0x0000);
ili9325_WriteRegister(0x08,0x0206);
ili9325_WriteRegister(0x09,0x0000);
ili9325_WriteRegister(0x0a,0x0000);
ili9325_WriteRegister(0x0c,0x0001);
ili9325_WriteRegister(0x0d,0x0000);
ili9325_WriteRegister(0x0f,0x0000);
Dly_ms(2);
//*************Power On sequence ****************//
ili9325_WriteRegister(0x10,0x0000);
ili9325_WriteRegister(0x11,0x0007);
ili9325_WriteRegister(0x12,0x0000);
ili9325_WriteRegister(0x13,0x0000);
Dly_ms(2);
ili9325_WriteRegister(0x10,0x1590);
ili9325_WriteRegister(0x11,0x0227);
Dly_ms(2);
ili9325_WriteRegister(0x12,0x009c);
Dly_ms(2);
ili9325_WriteRegister(0x13,0x1900);
ili9325_WriteRegister(0x29,0x0023);
ili9325_WriteRegister(0x2b,0x000e);
Dly_ms(2);
ili9325_WriteRegister(0x20,0x0000);
ili9325_WriteRegister(0x21,0x0000);
Dly_ms(2);
// ----------- Adjust the Gamma Curve ----------//
ili9325_WriteRegister(0x30,0x0007);
ili9325_WriteRegister(0x31,0x0707);
ili9325_WriteRegister(0x32,0x0006);
ili9325_WriteRegister(0x35,0x0704);
ili9325_WriteRegister(0x36,0x1f04);
ili9325_WriteRegister(0x37,0x0004);
ili9325_WriteRegister(0x38,0x0000);
ili9325_WriteRegister(0x39,0x0706);
ili9325_WriteRegister(0x3c,0x0701);
ili9325_WriteRegister(0x3d,0x000f);
Dly_ms(2);
//------------------ Set GRAM area ---------------//
ili9325_WriteRegister(0x50,0x0000);
ili9325_WriteRegister(0x51,0x00ef);
ili9325_WriteRegister(0x52,0x0000);
ili9325_WriteRegister(0x53,0x013f);
ili9325_WriteRegister(0x60,0xa700);
ili9325_WriteRegister(0x61,0x0001);
ili9325_WriteRegister(0x6a,0x0000);
//-------------- Partial Display Control ---------//
ili9325_WriteRegister(0x80,0x0000);
ili9325_WriteRegister(0x81,0x0000);
ili9325_WriteRegister(0x82,0x0000);
ili9325_WriteRegister(0x83,0x0000);
ili9325_WriteRegister(0x84,0x0000);
ili9325_WriteRegister(0x85,0x0000);
ili9325_WriteRegister(0x90,0x0010);
ili9325_WriteRegister(0x92,0x0000);
ili9325_WriteRegister(0x93,0x0003);
ili9325_WriteRegister(0x95,0x0110);
ili9325_WriteRegister(0x97,0x0000);
ili9325_WriteRegister(0x98,0x0000);
ili9325_WriteRegister(0x07,0x0133);
Dly_ms(2);
LCMLedOn=1;
ili9325_Clear(0x001f);
}
void ili9325_Clear(word data)
{
dword i;
ili9325_WriteRegister(0x20,0);
ili9325_WriteRegister(0x21,0);
ili9325_WriteRegister(0x50,0x0000);//水平 GRAM起始位置
ili9325_WriteRegister(0x51,239);//水平GRAM终止位置
ili9325_WriteRegister(0x52,0x0000);//垂直GRAM起始位置
ili9325_WriteRegister(0x53,319);//垂直GRAM终止位置
for(i=0;i<76800;i++)
{
ili9325_WriteGRAM(data);
}
}
void Dly_ms(int ms)
{
int ii,jj;
if (ms<1) ms=1;
for(ii=0;ii<ms;ii++)
for(jj=0;jj<2670;jj++);
}
//写 ili9325 寄存器数据
void ili9325_WriteGRAM(word data)
{
LCMCS=0;
LCMRS=0;
LCMRd=1;
PORTB = 0x00;
LCMWr=0;
Dly_ms(1);
LCMWr=1;
PORTB = 0x22;
LCMWr=0;
Dly_ms(1);
LCMWr=1;
LCMRS=1;
PORTB = (byte)(data>>8);
LCMWr=0;
Dly_ms(1);
LCMWr=1;
PORTB = (byte)(data&0x00ff);
LCMWr=0;
Dly_ms(1);
LCMWr=1;
LCMCS=1;
}
//写指定地址寄存器数据
void ili9325_WriteRegister(byte index,word data)
{
LCMCS=0;
LCMRS=0;
LCMRd=1;
PORTB = 0x00;
LCMWr=0;
Dly_ms(1);
LCMWr=1;
PORTB = index;
LCMWr=0;
Dly_ms(1);
LCMWr=1;
LCMRS=1;
PORTB = (byte)(data>>8);
LCMWr=0;
Dly_ms(1);
LCMWr=1;
PORTB = (byte)(data&0x00ff);
LCMWr=0;
Dly_ms(1);
LCMWr=1;
LCMCS=1;
}
作者:
aniaiye
时间:
2010-5-19 10:24
补充一句, 用的是i80 system interface with 8bit bus width
作者:
落叶秋无声
时间:
2010-5-19 21:20
请问你这程序是自己编的吗?
作者:
finewind
时间:
2010-5-20 11:27
检查时序,看你的指令执行的时长是不是符合ILI9325芯片的读写时序
作者:
aniaiye
时间:
2010-5-20 17:02
是自己写的,本来屏幕边缘一小块区域是可以随着初始化刷屏改变颜色的,所以所时序应该没有问题啊。
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/)
Powered by Discuz! 7.0.0