8284|4

73

帖子

0

TA的资源

纯净的硅(中级)

楼主
 

ILI9320的驱动TFT [复制链接]




在淘宝上买了一块这样的TFT,用ARM2148去驱动,不知道为什么屏幕显示背景色的时候只能显示一半,就卡死了,什么都出不来了。

程序代码见下:
#include "config.h"

#define uint unsigned int
#define uchar unsigned char
#define  cs    (1<<25)
#define  rs    (1<<26)
#define  wr    (1<<27)
#define  rst   (1<<28)

void delay_ms(uint32 uidly)
{
uint32 i;
for(;uidly>0;uidly--)
  for(i=40000;i>0;i--);
}

void LCD_WR_REG(uint index)
{
IO0CLR = rs;
IO0CLR = cs;
IO0CLR = 0xff<<16;
IO0SET = (index&0xff)<<16;
IO1CLR = 0xff<<16;
IO1SET = ((index>>8)&0xff)<<16;
IO0CLR = wr;
IO0SET = wr;
IO0SET = cs;
IO0SET = rs;
}

void LCD_WR_Data(uint val)
{
IO0SET = rs;
IO0CLR = cs;
IO0CLR = 0xff<<16;
IO0SET = (val&0xff)<<16;
IO1CLR = 0xff<<16;
IO1SET = ((val>>8)&0xff)<<16;
IO0CLR = wr;
IO0SET = wr;
IO0SET = cs;
}
void LCD_WR_CMD(uint index,uint val)
{
IO0CLR = rs;
IO0CLR = cs;
IO0CLR = 0xff<<16;
IO0SET = (index&0xff)<<16;
IO1CLR = 0xff<<16;
IO1SET = ((index>>8)&0xff)<<16;
IO0CLR = wr;
IO0SET = wr;
IO0SET = cs;
IO0SET = rs;
IO0CLR = cs;
IO0CLR = 0xff<<16;
IO0SET = (val&0xff)<<16;
IO1CLR = 0xff<<16;
IO1SET = ((val>>8)&0xff)<<16;
IO0CLR = wr;
IO0SET = wr;
IO0SET = cs;
IO0CLR = rs;
}

void Lcd_Init(void)
{
PINSEL0 = 0x00000000;
PINSEL1 = 0x00000000;
PINSEL2 = PINSEL2&(~0x08);

IO0DIR = cs|wr|rs|rst;
IO0SET = cs|wr|rs|rst;
}
void Lcd_Disp(void)
{
IO0CLR = rst;
delay_ms(100);
IO0SET = rst;
delay_ms(100);

LCD_WR_CMD(0x00E5, 0x8000);   // Set the internal vcore voltage
LCD_WR_CMD(0x0000, 0x0001);   // Start internal OSC.
delay_ms(40);
LCD_WR_CMD(0x0001, 0x0000);  // set SS and SM bit
LCD_WR_CMD(0x0002, 0x0700);  // set 1 line inversion
LCD_WR_CMD(0x0003, 0x1038);  // set GRAM write direction and BGR=1.
LCD_WR_CMD(0x0004, 0x0000);  // Resize register
LCD_WR_CMD(0x0008, 0x0202);  // set the back porch and front porch
LCD_WR_CMD(0x0009, 0x0000);  // set non-display area refresh cycle ISC[3:0]
LCD_WR_CMD(0x000A, 0x0000);  // FMARK function
LCD_WR_CMD(0x000C, 0x0000);   // RGB interface setting
LCD_WR_CMD(0x000D, 0x0000);  // Frame marker Position
LCD_WR_CMD(0x000F, 0x0000);   // RGB interface polarity
LCD_WR_CMD(0x002b, 0x0020);     //frame rate and color control(0x0000)
//*************Power On sequence ****************
LCD_WR_CMD(0x0010, 0x0000);   // SAP, BT[3:0], AP, DSTB, SLP, STB
LCD_WR_CMD(0x0011, 0x0004);   // DC1[2:0], DC0[2:0], VC[2:0]
LCD_WR_CMD(0x0012, 0x0000);   // VREG1OUT voltage
LCD_WR_CMD(0x0013, 0x0000);   // VDV[4:0] for VCOM amplitude
delay_ms(100);    // Dis-charge capacitor power voltage
LCD_WR_CMD(0x0010, 0x17B0);   // SAP, BT[3:0], AP, DSTB, SLP, STB
LCD_WR_CMD(0x0011, 0x0001);   // DC1[2:0], DC0[2:0], VC[2:0]
delay_ms(50);      // Delay 50ms
LCD_WR_CMD(0x0012, 0x013e);   // VREG1OUT voltage
delay_ms(50);      // Delay 50ms
LCD_WR_CMD(0x0013, 0x1c00);   // VDV[4:0] for VCOM amplitude
LCD_WR_CMD(0x0029, 0x001e);   // VCM[4:0] for VCOMH
delay_ms(50);
LCD_WR_CMD(0x0020, 0x0000);   // GRAM horizontal Address
LCD_WR_CMD(0x0021, 0x0000);   // GRAM Vertical Address
// ----------- Adjust the Gamma Curve ----------//
LCD_WR_CMD(0x0030, 0x0002);
LCD_WR_CMD(0x0031, 0x0606);
LCD_WR_CMD(0x0032, 0x0501);

LCD_WR_CMD(0x0035, 0x0206);
LCD_WR_CMD(0x0036, 0x0504);
LCD_WR_CMD(0x0037, 0x0707);
LCD_WR_CMD(0x0038, 0x0306);
LCD_WR_CMD(0x0039, 0x0007);
LCD_WR_CMD(0x003C, 0x0700);
LCD_WR_CMD(0x003D, 0x0700);
//------------------ Set GRAM area ---------------//
LCD_WR_CMD(0x0050, 0x0000);  // Horizontal GRAM Start Address
LCD_WR_CMD(0x0051, 0x00EF);  // Horizontal GRAM End Address
LCD_WR_CMD(0x0052, 0x0000);  // Vertical GRAM Start Address
LCD_WR_CMD(0x0053, 0x013F);  // Vertical GRAM Start Address

LCD_WR_CMD(0x0060, 0x2700);  // Gate Scan Line
LCD_WR_CMD(0x0061, 0x0001);  // NDL,VLE, REV
LCD_WR_CMD(0x006A, 0x0000);  // set scrolling line
//-------------- Partial Display Control ---------//
LCD_WR_CMD(0x0080, 0x0000);
LCD_WR_CMD(0x0081, 0x0000);
LCD_WR_CMD(0x0082, 0x0000);
LCD_WR_CMD(0x0083, 0x0000);
LCD_WR_CMD(0x0084, 0x0000);
LCD_WR_CMD(0x0085, 0x0000);
//-------------- Panel Control -------------------//
LCD_WR_CMD(0x0090, 0x0010);
LCD_WR_CMD(0x0092, 0x0000);
LCD_WR_CMD(0x0093, 0x0003);
LCD_WR_CMD(0x0095, 0x0110);
LCD_WR_CMD(0x0097, 0x0000);
LCD_WR_CMD(0x0098, 0x0000);

LCD_WR_CMD(0x0007, 0x0173);  // 262K color and display ON
LCD_WR_REG(0x0022);
}
void lcd_bk()
{
uint16 temp,n,num;
LCD_WR_CMD(0x0050, 0x0000);  // Horizontal GRAM Start Address
LCD_WR_CMD(0x0051, 0x00EF);  // Horizontal GRAM End Address
LCD_WR_CMD(0x0052, 0x0000);  // Vertical GRAM Start Address
LCD_WR_CMD(0x0053, 0x013F);  // Vertical GRAM Start Address
//temp=color[bk];
LCD_WR_CMD(0x20,0);        //0-239
LCD_WR_CMD(0x21,0);        //0-319
LCD_WR_REG(0x0022);
for(n=0;n<320;n++)
{
  for(num=0;num<240;num++)
     LCD_WR_Data(0xf800);
  }
delay_ms(50);

}
int main()
{
Lcd_Init();
Lcd_Disp();

while(1)
{
  lcd_bk();
}
}                                                                        

怀疑是时序和初始化问题,但是一直检查不出来,希望做过TFT的人帮忙看看,谢谢了。

[ 本帖最后由 平常心 于 2009-7-31 09:41 编辑 ]

ILI9320.pdf

1.22 MB, 下载次数: 330

此帖出自单片机论坛

最新回复

我有点奇怪的是,你用ARM开发怎么不单步调试,看问题在哪里呢?  详情 回复 发表于 2010-9-16 13:38
点赞 关注
 

回复
举报

12

帖子

0

TA的资源

一粒金砂(初级)

沙发
 
此帖出自单片机论坛
 
 

回复

827

帖子

0

TA的资源

一粒金砂(中级)

板凳
 
最近我也在调试ILI9320呢,还没搞定啊
此帖出自单片机论坛
 
 
 

回复

4996

帖子

19

TA的资源

裸片初长成(初级)

4
 
这个代码我有,在这个帖子,你可以下载看看:https://bbs.eeworld.com.cn/thread-108375-1-1.html
此帖出自单片机论坛
 
个人签名我的博客
 
 

回复

4996

帖子

19

TA的资源

裸片初长成(初级)

5
 

回复 楼主 平常心 的帖子

我有点奇怪的是,你用ARM开发怎么不单步调试,看问题在哪里呢?
此帖出自单片机论坛
 
个人签名我的博客
 
 

回复
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/9 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表