打印

ILI9325怎么都显示不出来,哪个高手帮忙看看呀!

[复制链接]
3616|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
fredinand|  楼主 | 2010-12-24 11:25 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 fredinand 于 2010-12-24 11:28 编辑

我用的是ILI9325,八位数据模式,开发板为EMSTM32V100,RS,CS,WR,RD分别接到PE0,PE1,PE2,PE3,八位数据口接到PD0-7;下面是C代码和H文件
#include "lcd_ILI9325.h"
extern void Delay(vu32 nTime);
void LCD_Init()
{
LCD_config();
//************* Start Initial Sequence **********//
LCD_WR_COM_DATA(0x0001, 0x0100); // set SS and SM bit
LCD_WR_COM_DATA(0x0002, 0x0700); // set 1 line inversion
LCD_WR_COM_DATA(0x0003, 0x1030); // set GRAM write direction and BGR=1.
LCD_WR_COM_DATA(0x0004, 0x0000); // Resize register
LCD_WR_COM_DATA(0x0008, 0x0202); // set the back porch and front porch
LCD_WR_COM_DATA(0x0009, 0x0000); // set non-display area refresh cycle ISC[3:0]
LCD_WR_COM_DATA(0x000A, 0x0000); // FMARK function
LCD_WR_COM_DATA(0x000C, 0x0000); // RGB interface setting
LCD_WR_COM_DATA(0x000D, 0x0000); // Frame marker Position
LCD_WR_COM_DATA(0x000F, 0x0000); // RGB interface polarity
//*************Power On sequence ****************//
LCD_WR_COM_DATA(0x0010, 0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB
LCD_WR_COM_DATA(0x0011, 0x0007); // DC1[2:0], DC0[2:0], VC[2:0]
LCD_WR_COM_DATA(0x0012, 0x0000); // VREG1OUT voltage
LCD_WR_COM_DATA(0x0013, 0x0000); // VDV[4:0] for VCOM amplitude
LCD_WR_COM_DATA(0x0007, 0x0001);
Delay(60000); // Dis-charge capacitor power voltage
LCD_WR_COM_DATA(0x0010, 0x1690); // SAP, BT[3:0], AP, DSTB, SLP, STB
LCD_WR_COM_DATA(0x0011, 0x0227); // R11h=0x0221 at VCI=3.3V, DC1[2:0], DC0[2:0], VC[2:0]
Delay(50000); // Delay 50ms
LCD_WR_COM_DATA(0x0012, 0x001A); // External reference voltage= Vci;
Delay(50000); // Delay 50ms
LCD_WR_COM_DATA(0x0013, 0x1400); // R13=1200 when R12=009D;VDV[4:0] for VCOM amplitude
LCD_WR_COM_DATA(0x0029, 0x0024); // R29=000C when R12=009D;VCM[5:0] for VCOMH
LCD_WR_COM_DATA(0x002B, 0x000C); // Frame Rate
Delay(50000); // Delay 50ms
LCD_WR_COM_DATA(0x0020, 0x0000); // GRAM horizontal Address
LCD_WR_COM_DATA(0x0021, 0x0000); // GRAM Vertical Address
// ----------- Adjust the Gamma Curve ----------//
LCD_WR_COM_DATA(0x0030, 0x0007);
LCD_WR_COM_DATA(0x0031, 0x0604);
LCD_WR_COM_DATA(0x0032, 0x0007);
LCD_WR_COM_DATA(0x0035, 0x0504);
LCD_WR_COM_DATA(0x0036, 0x0808);
LCD_WR_COM_DATA(0x0037, 0x0007);
LCD_WR_COM_DATA(0x0038, 0x0301);
LCD_WR_COM_DATA(0x0039, 0x0007);
LCD_WR_COM_DATA(0x003C, 0x0302);
LCD_WR_COM_DATA(0x003D, 0x0808);
//------------------ Set GRAM area ---------------//
LCD_WR_COM_DATA(0x0050, 0x0000); // Horizontal GRAM Start Address
LCD_WR_COM_DATA(0x0051, 0x00EF); // Horizontal GRAM End Address
LCD_WR_COM_DATA(0x0052, 0x0000); // Vertical GRAM Start Address
LCD_WR_COM_DATA(0x0053, 0x013F); // Vertical GRAM Start Address
LCD_WR_COM_DATA(0x0060, 0xA700); // Gate Scan Line
LCD_WR_COM_DATA(0x0061, 0x0001); // NDL,VLE, REV
LCD_WR_COM_DATA(0x006A, 0x0000); // set scrolling line
//-------------- Partial Display Control ---------//
LCD_WR_COM_DATA(0x0080, 0x0000);
LCD_WR_COM_DATA(0x0081, 0x0000);
LCD_WR_COM_DATA(0x0082, 0x0000);
LCD_WR_COM_DATA(0x0083, 0x0000);
LCD_WR_COM_DATA(0x0084, 0x0000);
LCD_WR_COM_DATA(0x0085, 0x0000);
//-------------- Panel Control -------------------//
LCD_WR_COM_DATA(0x0090, 0x0010);
LCD_WR_COM_DATA(0x0092, 0x0600);
LCD_WR_COM_DATA(0x0007, 0x0133); // 262K color and display ON
}
//向端口输送数据
void data_trans(u8 data)
{
GPIO_Write(GPIOD, (u16)data);
}
//写数据
void lcd_wr_u16_data(u16 data)
{
RS_high;
CS_low;

data_trans(data>>8);
WR_low;
WR_high;
data_trans(data);
WR_low;
WR_high;
CS_high;
}
//写命令
void lcd_wr_u16_command(u16 command)
{
RS_low;
CS_low;

data_trans(command>>8);
WR_low;
WR_high;
data_trans(command);
WR_low;
WR_high;
CS_high;
}
//写寄存器
void LCD_WR_COM_DATA(u16 Command,u16 data)
{
lcd_wr_u16_command(Command);
lcd_wr_u16_data(data);
}
void LCD_SET_LOCATION(u16 i,u16 j)
{
  LCD_WR_COM_DATA(0x0020,0);//设置X坐标位置
  LCD_WR_COM_DATA(0x0021,0);//设置Y坐标位置
  lcd_wr_u16_command(0x0022);//指向RAM寄存器,准备写数据到RAM
}
void LCD_WR_DATA_BYTE(u8 DataH,u8 DataL)
{
    RS_high;
CS_low;

  data_trans(DataH);      
  
WR_low;
WR_high;
data_trans(DataL);
     
WR_low;
WR_high;
CS_high;
}
void test_lcd_mon(void)
{
unsigned char i,j,k;
LCD_SET_LOCATION(0,0);     //设置X,Y坐标
  for(i=0;i<8;i++)        //显示单色数据到LCD
  for(j=0;j<40;j++)
   for(k=0;k<240;k++)
    LCD_WR_DATA_BYTE(color[i*2],color[i*2+1]);
}
void LCD_config(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;
//dataio
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOD, &GPIO_InitStructure);
//ctrlio
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOE, &GPIO_InitStructure);
  //启动时钟
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE|RCC_APB2Periph_GPIOD, ENABLE);
}


H文件
#include "stm32f10x_lib.h"
/*----------------------------  LCD color  ---------------------------------*/
#define white          0xFFFF
#define black          0x0000
#define grey           0xF7DE//灰白
#define blue           0x001F
#define blue2          0x051F
#define red            0xF800
#define magenta        0xF81F//红紫
#define green          0x07E0
#define cyan           0x7FFF//青
#define yellow         0xFFE0
#define line0          0
#define line1          1*16
#define line2          2*16
#define line3          3*16
#define line4          4*16
#define line5          5*16
#define line6          6*16
#define line7          7*16
#define line8          8*16
#define line9          9*16
#define line10         10*16
#define line11         11*16
#define line12         12*16
#define line13         13*16
#define line14         14*16
#define line15         15*16
#define line16         16*16
#define line17         17*16
#define line18         18*16
#define line19         19*16
#define RS_high  GPIO_SetBits(GPIOE, GPIO_Pin_0)
#define RS_low  GPIO_ResetBits(GPIOE, GPIO_Pin_0)
#define CS_high  GPIO_SetBits(GPIOE, GPIO_Pin_1)
#define CS_low  GPIO_ResetBits(GPIOE, GPIO_Pin_1)
#define WR_high  GPIO_SetBits(GPIOE, GPIO_Pin_2)
#define WR_low  GPIO_ResetBits(GPIOE, GPIO_Pin_2)
#define RD_high  GPIO_SetBits(GPIOE, GPIO_Pin_3)
#define RD_low  GPIO_ResetBits(GPIOE, GPIO_Pin_3)
/*LCD function*/
void LCD_Init(void);
void test_lcd_mon(void);//彩条测试
void LCD_SET_LOCATION(u16 i,u16 j);
void LCD_WR_COM_DATA(u16 Command,u16 data);
void LCD_config(void);
void data_trans(u8 data);
void LCD_WR_DATA_BYTE(u8 DataH,u8 DataL);
void lcd_wr_u16_data(u16 data);
void lcd_wr_u16_command(u16 data);
u16 color[]={0xf8,0x00,0x07,0xe0,0x00,0x1f,0xff,0xe0,0x00,0x00,0xff,0xff,0x07,0xff,0xf8,0x1f};

调试截图
沙发
fredinand|  楼主 | 2010-12-26 09:42 | 只看该作者
怎么没有高手帮忙呢?苦等

使用特权

评论回复
板凳
jima| | 2010-12-28 18:15 | 只看该作者
你这是用哪个仪器抓的波形啊!

使用特权

评论回复
地板
IJK| | 2010-12-29 09:47 | 只看该作者
看了一下,LZ是用GPIO来模拟的。
贴出我的可以用的代码,供参考:

void LCD_Init(void)
{
  // Configure the LCD Control pins --------------------------------------------
  LCD_CtrlLinesConfig();

  // Configure the Parallel interface ------------------------------------------
  LCD_PrllConfig();

  delay_ms(50); // Delay 50 ms

  LCD_ID = LCD_ReadReg(0x00);
  if(LCD_ID == 0x9325)
  {
    LCD_Type = NEW_LCD_9325;
    // Start Initial Sequence
    LCD_WriteReg(R0,   0x0001); // Start internal OSC.
    LCD_WriteReg(R1,   0x0100); // set SS and SM bit
    LCD_WriteReg(R2,   0x0700); // set 1 line inversion
    LCD_WriteReg(R3,   0x1018); // set GRAM write direction and BGR=1.
    LCD_WriteReg(R4,   0x0000); // Resize register
  
    LCD_WriteReg(R8,  0x0202); // set the back porch and front porch
    LCD_WriteReg(R9,  0x0000); // set non-display area refresh cycle ISC[3:0]
    LCD_WriteReg(R10, 0x0000); // FMARK function
    LCD_WriteReg(R12, 0x0000); // RGB interface setting
    LCD_WriteReg(R13, 0x0000); // Frame marker Position
    LCD_WriteReg(R15, 0x0000); // RGB interface polarity

    // Power On sequence -------------------------------------------------------
    LCD_WriteReg(R16, 0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB
    LCD_WriteReg(R17, 0x0000); // DC1[2:0], DC0[2:0], VC[2:0]
    LCD_WriteReg(R18, 0x0000); // VREG1OUT voltage
    LCD_WriteReg(R19, 0x0000); // VDV[4:0] for VCOM amplitude
    delay_ms(200);             // Dis-charge capacitor power voltage (200ms)
    LCD_WriteReg(R16, 0x17B0); // SAP, BT[3:0], AP, DSTB, SLP, STB
    LCD_WriteReg(R17, 0x0137); // DC1[2:0], DC0[2:0], VC[2:0]
    delay_ms(50);              // Delay 50 ms
    LCD_WriteReg(R18, 0x0139); // VREG1OUT voltage
    delay_ms(50);              // Delay 50 ms
    LCD_WriteReg(R19, 0x1d00); // VDV[4:0] for VCOM amplitude
    LCD_WriteReg(R41, 0x0013); // VCM[4:0] for VCOMH
    delay_ms(50);              // Delay 50 ms
    LCD_WriteReg(R32, 0x0000); // GRAM horizontal Address
    LCD_WriteReg(R33, 0x0000); // GRAM Vertical Address

    // Adjust the Gamma Curve (ILI9325)-----------------------------------------
    LCD_WriteReg(R48, 0x0007);
    LCD_WriteReg(R49, 0x0302);
    LCD_WriteReg(R50, 0x0105);
    LCD_WriteReg(R53, 0x0206);
    LCD_WriteReg(R54, 0x0808);
    LCD_WriteReg(R55, 0x0206);
    LCD_WriteReg(R56, 0x0504);
    LCD_WriteReg(R57, 0x0007);
    LCD_WriteReg(R60, 0x0105);
    LCD_WriteReg(R61, 0x0808);

    // Set GRAM area -----------------------------------------------------------
    LCD_WriteReg(R80, 0x0000); // Horizontal GRAM Start Address
    LCD_WriteReg(R81, 0x00EF); // Horizontal GRAM End Address
    LCD_WriteReg(R82, 0x0000); // Vertical GRAM Start Address
    LCD_WriteReg(R83, 0x013F); // Vertical GRAM End Address

    LCD_WriteReg(R96,  0xA700); // Gate Scan Line(GS=1, scan direction is G320~G1)
    LCD_WriteReg(R97,  0x0001); // NDL,VLE, REV
    LCD_WriteReg(R106, 0x0000); // set scrolling line

    // Partial Display Control -------------------------------------------------
    LCD_WriteReg(R128, 0x0000);
    LCD_WriteReg(R129, 0x0000);
    LCD_WriteReg(R130, 0x0000);
    LCD_WriteReg(R131, 0x0000);
    LCD_WriteReg(R132, 0x0000);
    LCD_WriteReg(R133, 0x0000);

    // Panel Control -----------------------------------------------------------
    LCD_WriteReg(R144, 0x0010);
    LCD_WriteReg(R146, 0x0000);
    LCD_WriteReg(R147, 0x0003);
    LCD_WriteReg(R149, 0x0110);
    LCD_WriteReg(R151, 0x0000);
    LCD_WriteReg(R152, 0x0000);

    // set GRAM write direction and BGR=1
    // I/D=00 (Horizontal : increment, Vertical : decrement)
    // AM=1 (address is updated in vertical writing direction)
    LCD_WriteReg(R3, 0x1018);

    LCD_WriteReg(R7, 0x0133); // 262K color and display ON
    return;
  }
  // Start Initial Sequence (ILI9320)-------------------------------------------
  LCD_WriteReg(R229, 0x8000); // Set the internal vcore voltage
  LCD_WriteReg(R0,   0x0001); // Start internal OSC.
  LCD_WriteReg(R1,   0x0100); // set SS and SM bit
  LCD_WriteReg(R2,   0x0700); // set 1 line inversion
  LCD_WriteReg(R3,   0x1030); // set GRAM write direction and BGR=1.
  LCD_WriteReg(R4,   0x0000); // Resize register

  LCD_WriteReg(R8,  0x0202); // set the back porch and front porch
  LCD_WriteReg(R9,  0x0000); // set non-display area refresh cycle ISC[3:0]
  LCD_WriteReg(R10, 0x0000); // FMARK function
  LCD_WriteReg(R12, 0x0000); // RGB interface setting
  LCD_WriteReg(R13, 0x0000); // Frame marker Position
  LCD_WriteReg(R15, 0x0000); // RGB interface polarity

  // Power On sequence ---------------------------------------------------------
  LCD_WriteReg(R16, 0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB
  LCD_WriteReg(R17, 0x0000); // DC1[2:0], DC0[2:0], VC[2:0]
  LCD_WriteReg(R18, 0x0000); // VREG1OUT voltage
  LCD_WriteReg(R19, 0x0000); // VDV[4:0] for VCOM amplitude
  delay_ms(200);             // Dis-charge capacitor power voltage (200ms)
  LCD_WriteReg(R16, 0x17B0); // SAP, BT[3:0], AP, DSTB, SLP, STB
  LCD_WriteReg(R17, 0x0137); // DC1[2:0], DC0[2:0], VC[2:0]
  delay_ms(50);              // Delay 50 ms
  LCD_WriteReg(R18, 0x0139); // VREG1OUT voltage
  delay_ms(50);              // Delay 50 ms
  LCD_WriteReg(R19, 0x1d00); // VDV[4:0] for VCOM amplitude
  LCD_WriteReg(R41, 0x0013); // VCM[4:0] for VCOMH
  delay_ms(50);              // Delay 50 ms
  LCD_WriteReg(R32, 0x0000); // GRAM horizontal Address
  LCD_WriteReg(R33, 0x0000); // GRAM Vertical Address

  // Adjust the Gamma Curve
  LCD_WriteReg(R48, 0x0000);
  LCD_WriteReg(R49, 0x0007);
  LCD_WriteReg(R50, 0x0103);
  LCD_WriteReg(R53, 0x0407);
  LCD_WriteReg(R54, 0x090F);
  LCD_WriteReg(R55, 0x0404);
  LCD_WriteReg(R56, 0x0400);
  LCD_WriteReg(R57, 0x0404);
  LCD_WriteReg(R60, 0x0000);
  LCD_WriteReg(R61, 0x0400);

  // Set GRAM area -------------------------------------------------------------
  LCD_WriteReg(R80, 0x0000); // Horizontal GRAM Start Address
  LCD_WriteReg(R81, 0x00EF); // Horizontal GRAM End Address
  LCD_WriteReg(R82, 0x0000); // Vertical GRAM Start Address
  LCD_WriteReg(R83, 0x013F); // Vertical GRAM End Address

  LCD_WriteReg(R96,  0x2700); // Gate Scan Line
  LCD_WriteReg(R97,  0x0001); // NDL,VLE, REV
  LCD_WriteReg(R106, 0x0000); // set scrolling line

  // Partial Display Control ---------------------------------------------------
  LCD_WriteReg(R128, 0x0000);
  LCD_WriteReg(R129, 0x0000);
  LCD_WriteReg(R130, 0x0000);
  LCD_WriteReg(R131, 0x0000);
  LCD_WriteReg(R132, 0x0000);
  LCD_WriteReg(R133, 0x0000);

  // Panel Control -------------------------------------------------------------
  LCD_WriteReg(R144, 0x0010);
  LCD_WriteReg(R146, 0x0000);
  LCD_WriteReg(R147, 0x0003);
  LCD_WriteReg(R149, 0x0110);
  LCD_WriteReg(R151, 0x0000);
  LCD_WriteReg(R152, 0x0000);

  // set GRAM write direction and BGR=1
  // I/D=01 (Horizontal : increment, Vertical : decrement)
  // AM=1 (address is updated in vertical writing direction)
  LCD_WriteReg(R3, 0x1018);

  LCD_WriteReg(R7, 0x0173); // 262K color and display ON
}

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

124

主题

151

帖子

1

粉丝