搜索
bottom↓
回复: 4

用过ILI9320驱动的进来看看

[复制链接]

出0入0汤圆

发表于 2009-7-28 16:01:33 | 显示全部楼层 |阅读模式
#include "ILI9320.h"

const uint color[]={0xF800,0x7E0,0x1F,0xffe0,0x0000,0xffff,0x07ff,0xf81f,0x07e0,0x0eff,
                     /*红色     橘黄    蓝色    黄色       黑色      白色    青色       紫色      绿色     天蓝*/
                       0x000F,0x03E0,0x03EF,0x7800};
void DelayNS(uint32 dly)
{
        uint32 i;
        for(; dly > 0; dly--)
                for(i=0; i<4000; i++);
}


void LCD_WR_REG(uint index)
{
        CRS();
        CCS();
        OutData_L(index);
        OutData_H(index>>8);
        CWR();
        SWR();
        SSCS();
        //SRS();
}

void LCD_WR_CMD(uint index,uint val)
{
        CRS();
        CCS();
        OutData_L(index);
        OutData_H(index>>8);
        CWR();
        SWR();
        //SSCS();
        SRS();
        //CCS();
        OutData_L(val);
        OutData_H(val>>8);
        CWR();
        SWR();
        SSCS();
        CRS();
}

void LCD_WR_Data(uint val)
{
        SRS();
        CCS();
        OutData_L(val);
        OutData_H(val>>8);
        CWR();
        SWR();
        SSCS();
}

void LCD_Init()
{
        PINSEL0 = PINSEL0&0x00000000;
        PINSEL1 = PINSEL1&0x00000000;
        PINSEL2 = PINSEL2&(~0x08);
       
        IO0DIR = IO0DIR|(1<<RST)|(1<<CS)|(1<<WR)|(1<<RS)|(1<<RD)|(0xff<<16);
        IO1DIR = IO1DIR|(0xff<<16);
}

void LCM_DispInit()
{
        LCD_Init();
       
        SRST();
        DelayNS(100);
        CRST();
        DelayNS(100);
        SRST();
        DelayNS(100);
       
        LCD_WR_CMD(0x00E5, 0x8000);          // Set the internal vcore voltage
        LCD_WR_CMD(0x0000, 0x0001);          // Start internal OSC.
        DelayNS(400);
        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
        DelayNS(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]
        DelayNS(50);                                         // Delay 50ms
        LCD_WR_CMD(0x0012, 0x013e);                 // VREG1OUT voltage
        DelayNS(50);                                         // Delay 50ms
        LCD_WR_CMD(0x0013, 0x1c00);                 // VDV[4:0] for VCOM amplitude
        LCD_WR_CMD(0x0029, 0x001e);                 // VCM[4:0] for VCOMH
        DelayNS(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(0xffff);
    }
   DelayNS(50);
}       



#include "ILI9320.h"

int main (void)
{       
        LCM_DispInit();
        while(1)
        {
                 lcd_bk();
                 DelayNS(100);
        }
    return 0;
}


我这样做,一直不能正常的现实,其实为只是测测屏,保证屏是好的。但是不知道我这么做有什么地方不对的吗?请指教下,谢谢了!

阿莫论坛20周年了!感谢大家的支持与爱护!!

知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)

出0入0汤圆

发表于 2009-7-28 16:06:38 | 显示全部楼层
先贴下你的接线图,排除硬件原因

出0入0汤圆

 楼主| 发表于 2009-7-28 16:14:12 | 显示全部楼层
/* 定义RES控制 */
#define   RST     28
#define   SRST()  IO0SET =  (1<<RST)
#define   CRST()  IO0CLR =  (1<<RST)

/* 定义RS控制 */
#define   RS      26
#define   SRS()   IO0SET = (1<<RS)
#define   CRS()   IO0CLR = (1<<RS)

/* 定义CS控制 */
#define   CS      25
#define   SSCS()  IO0SET =(1<<CS)
#define   CCS()   IO0CLR= (1<<CS)

/* 定义WR控制 */                  
#define   WR      27
#define   SWR()   IO0SET = (1<<WR)
#define   CWR()   IO0CLR = (1<<WR)

#define   RD      30
#define   SRD()   IO0SET = (1<<RD)
#define   CRD()   IO0CLR = (1<<RD)


/*定义数据口高8位*/
#define   BUS_NO   16
#define   OutData_H(dat)          IO1CLR = 0xff<<BUS_NO;IO1SET =(dat&0xff)<<BUS_NO
#define   OutData_L(dat)          IO0CLR = 0xff<<BUS_NO;IO0SET =(dat&0xff)<<BUS_NO

出0入0汤圆

发表于 2009-8-7 10:56:52 | 显示全部楼层
我在使用MSP430单片机来写,也尚未有显示,唉~头疼,不知道是不是时序对不对,~如果一个WR信号从下降到上升有1us的时间,还可以驱动吗?

出0入0汤圆

发表于 2012-12-17 22:35:10 | 显示全部楼层
学习了不错         
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-7-24 05:16

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表