搜索
bottom↓
回复: 3

请教ILI9328水平和垂直方向设定问题

[复制链接]

出0入0汤圆

发表于 2012-10-11 17:16:38 | 显示全部楼层 |阅读模式
本帖最后由 自学STM32 于 2012-10-11 17:48 编辑

[attachimg]57969[/attachimg    最近几天买了片2.8寸的ILI9328的屏, 初始化0X0003寄存器AM[D3]=0的话 我用全屏填充成白色,是从0到239 显示的.这算是垂直方向还是水平方向,把0X0003寄存器AM[D3]=的话刷新是 0-319 应该是水平方向吧,我感觉和ILI9328手册上方向是反的
初始化代码
void ILI9328_CPT28_Initial(void)
{
        unsigned short id;
// VCI=2.8V
//************* Reset LCD Driver ****************//
Tft_RST_PIN = 1;
delay(100); // Delay 1ms
Tft_RST_PIN = 0;
delay(1000); // Delay 10ms // This delay time is necessary
Tft_RST_PIN = 1;
delay(1000); // Delay 50 ms
          Tft_BLK_PIN=1;  //屏灯打开PBout(1)
                delay(200);
                id=Tft_ReadID();
                delay(200);
         if (id==0x9325|| id==0x9328)
    {
//************* Start Initial Sequence **********//
TftWrite(0x0001, 0x0000); // set SM and SS bit  SM=0  SS=1                        
TftWrite(0x0002, 0x0700); // set 1 line inversion D10=1  B/C =1 EOR=1
TftWrite(0x0003, 0x1038); // set GRAM write direction and BGR=1.  TRI[D15]=0 DFM[14]=0 BGR[12]=1 ORG[D7]=0 I/D1[D5]:I/D0[D4]=11 AM[D3]=0
TftWrite(0x0004, 0x0000); // Resize register 调整大小控制寄存器
TftWrite(0x0008, 0x0207); // set the back porch and front porch FP3[D11]:FP2[D10]:FP1[D9]:FP0[D8]=0010 BP3[D3]:BP2[D2]:BP1[D1]:BP0[D0]=0111
TftWrite(0x0009, 0x0000); // set non-display area refresh cycle ISC[3:0]
TftWrite(0x000A, 0x0000); // FMARK function
TftWrite(0x000C, 0x0000); // RGB interface setting
TftWrite(0x000D, 0x0000); // Frame marker Position
TftWrite(0x000F, 0x0000); // RGB interface polarity
//*************Power On sequence 电源开启顺序****************//
TftWrite(0x0010, 0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB
TftWrite(0x0011, 0x0007); // DC1[2:0], DC0[2:0], VC[2:0]
TftWrite(0x0012, 0x0000); // VREG1OUT voltage
TftWrite(0x0013, 0x0000); // VDV[4:0] for VCOM amplitude
TftWrite(0x0007, 0x0001);
delay(500); // Dis-charge capacitor power voltage 显示充电电容电源电压
TftWrite(0x0010, 0x1290); // 0X1290=1001010010000 SAP[D12]=1, BT2[D10]:BT1[D9]:BT0[D8], AP, DSTB, SLP, STB
TftWrite(0x0011, 0x0227); // 0X0227=0000001000100111  DC1[2:0], DC0[2:0], VC[2:0]
delay(500); // Delay 50ms
TftWrite(0x0012, 0x001A); // 001a Internal reference voltage= Vci;
delay(500); // Delay 50ms
TftWrite(0x0013, 0x1800); // 1800 Set VDV[4:0] for VCOM amplitude
TftWrite(0x0029, 0x0028); //0028 Set VCM[5:0] for VCOMH
TftWrite(0x002B, 0x000C); // Set Frame Rate
delay(500); // Delay 50ms
TftWrite(0x0020, 0x0000); // GRAM horizontal Address
TftWrite(0x0021, 0x0000); // GRAM Vertical Address
// ----------- Adjust the Gamma Curve ----------//
TftWrite(0x0030, 0x0000);
TftWrite(0x0031, 0x0305);
TftWrite(0x0032, 0x0003);
TftWrite(0x0035, 0x0304);
TftWrite(0x0036, 0x000F);
TftWrite(0x0037, 0x0407);
TftWrite(0x0038, 0x0204);
TftWrite(0x0039, 0x0707);
TftWrite(0x003C, 0x0403);
TftWrite(0x003D, 0x1604);
//------------------ Set GRAM area ---------------//
TftWrite(0x0050, 0x0000); // Horizontal GRAM Start Address 水平GRAM起始地址
TftWrite(0x0051, 0x00EF); // Horizontal GRAM End Address   水平程序结束地址
TftWrite(0x0052, 0x0000); // Vertical GRAM Start Address   垂直GRAM起始地址
TftWrite(0x0053, 0x013F); // Vertical GRAM Start Address
TftWrite(0x0060, 0xA700); // Gate Scan Line
TftWrite(0x0061, 0x0001); // NDL,VLE, REV
TftWrite(0x006A, 0x0000); // set scrolling line
//-------------- Partial Display Control 局部显示控制---------//
TftWrite(0x0080, 0x0000);
TftWrite(0x0081, 0x0000);
TftWrite(0x0082, 0x0000);
TftWrite(0x0083, 0x0000);
TftWrite(0x0084, 0x0000);
TftWrite(0x0085, 0x0000);
//-------------- Panel Control 面板控制-------------------//
TftWrite(0x0090, 0x0010);
TftWrite(0x0092, 0x0600);
TftWrite(0x0007, 0x0137); // 262K color and display ON
  }
        TftClear(0XFFFF);  //将屏幕填充成指定的颜色
}

/***************************************************************************
名    称:void TftClear(unsigned short int Color)
功    能:将屏幕填充成指定的颜色
入口参数:填充颜色值
出口参数:无
说    明:
调用方法:TftClear(RED);
***************************************************************************/
void TftClear(unsigned short int Color)
{
          unsigned int index = 0;

        TftWrite(0x0050,0x0000);
        TftWrite(0x0051,0x00ef);
        TftWrite(0x0052,0x0000);
        TftWrite(0x0053,0x013f);
        TftWrite(0x0020,0x0000);
        TftWrite(0x0021,0x0000);  
        TftWrite16(0x0022);   

          for(index = 0; index < 76800; index++)
        {
                Tft_WR_DATA16(Color);
                delay(50); //加延时可以看到刷新方向
        }

}

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

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

你熬了10碗粥,别人一桶水倒进去,淘走90碗,剩下10碗给你,你看似没亏,其实你那10碗已经没有之前的裹腹了,人家的一桶水换90碗,继续卖。说白了,通货膨胀就是,你的钱是挣来的,他的钱是印来的,掺和在一起,你的钱就贬值了。

出0入0汤圆

发表于 2012-10-11 21:37:08 来自手机 | 显示全部楼层
帮顶,一开始我也遇到这个,总觉得不好理解,现在弄懂了,本来是竖屏要横着用,就要坐标变换,R3h,R20h,R21h,R50h,51h,52h,53h,都有关系。横屏后排线在右,x是原来的y,y是原来的239-x。

出0入0汤圆

 楼主| 发表于 2012-10-12 00:26:11 | 显示全部楼层
本帖最后由 自学STM32 于 2012-10-12 00:38 编辑

谢谢!!!
我的理解是  R50  R51  是8位的 所以只能放 X数据 0X00EF=239  R52  R53 是9位的所以可以放Y  = 0X013F=319

R03H我把 I/D1:I/D0 全为1  AM本来=0 是横屏  AM=1 是竖屏,我现在是相反的

R20H   R21H  是内存 X,Y坐标的指针 ,我现在横屏是把X与Y的数据交换.
   现在可以画水平直线 垂直直线 任意坐标画指定长度的水平直线,我主要是为了学习RT-Thread系统的
  struct rt_device_graphic_ops lcd_ili_ops =
{
    rt_hw_lcd_set_pixel,
    rt_hw_lcd_get_pixel,
    rt_hw_lcd_draw_hline,
    rt_hw_lcd_draw_vline,
    rt_hw_lcd_draw_blit_line
};

struct rt_device _lcd_device;
static rt_err_t lcd_init(rt_device_t dev)
{
    return RT_EOK;
}

static rt_err_t lcd_open(rt_device_t dev, rt_uint16_t oflag)
{
    return RT_EOK;
}

static rt_err_t lcd_close(rt_device_t dev)
{
    return RT_EOK;
}

static rt_err_t lcd_control(rt_device_t dev, rt_uint8_t cmd, void *args)
{
    switch (cmd)
    {
    case RTGRAPHIC_CTRL_GET_INFO:
    {
        struct rt_device_graphic_info *info;

        info = (struct rt_device_graphic_info*) args;
        RT_ASSERT(info != RT_NULL);

        info->bits_per_pixel = 16;
        info->pixel_format = RTGRAPHIC_PIXEL_FORMAT_RGB565P;
        info->framebuffer = RT_NULL;
        info->width = 320;
        info->height = 240;
    }
    break;

    case RTGRAPHIC_CTRL_RECT_UPDATE:
        /* nothong to be done */
        break;

    default:
        break;
    }

    return RT_EOK;
}

void rt_hw_lcd_init(void)
{
   /* register lcd device */
    _lcd_device.type  = RT_Device_Class_Graphic;
    _lcd_device.init  = lcd_init;
    _lcd_device.open  = lcd_open;
    _lcd_device.close = lcd_close;
    _lcd_device.control = lcd_control;
    _lcd_device.read  = RT_NULL;
    _lcd_device.write = RT_NULL;

    _lcd_device.user_data = &lcd_ili_ops;
    ILI9328_CPT28_Initial();

    /* register graphic device driver */
    rt_device_register(&_lcd_device, "lcd",
                       RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE);
}

ILI9328.C现在裸奔正常了,也可以读取指定坐标的内存数据,把ILI9328.C加到RT-Thread工程里正常


我刚刚学习RT-Thread,有点头大.
有个问题一直困惑着
int rt_application_init()
{
        rt_thread_t init_thread;


        init_thread = rt_thread_create("init",
                                                                rt_init_thread_entry, RT_NULL,
                                                                2048, 8, 20);


        if (init_thread != RT_NULL)
        {
                rt_thread_startup(init_thread);
        }

        return 0;
}
这个建立的 init 线程运行一次后 会被idle删除,我跟踪调试搞不清楚是什么原理,我知道这个初始化线程运行一次就可以了,就是想搞清楚原理
还有个就是不动怎么能运行简单的 RTGUI 我现在已经建立RTGUI线程
void rtgui_system_server_init(void)
{
        /* init image */
        rtgui_system_image_init();
        /* init font */
        rtgui_font_system_init();

        /* init rtgui server */
        rtgui_topwin_init();
        rtgui_server_init();

        /* init theme */
        rtgui_system_theme_init();
}
不知道是不是正确
下步不知道怎么建立显示的画面,我用的是 STM32F103RBT6    ILI9328  8BIT驱动
准备以后加GPS模块 GSM模块,我估计128KB FLASH和20KB  RAM全不够

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

出0入0汤圆

发表于 2015-11-9 12:53:14 | 显示全部楼层
自学STM32 发表于 2012-10-12 00:26
谢谢!!!
我的理解是  R50  R51  是8位的 所以只能放 X数据 0X00EF=239  R52  R53 是9位的所以可以放Y  = 0X ...

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

本版积分规则

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

GMT+8, 2024-10-3 02:39

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

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