|
本帖最后由 自学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碗,继续卖。说白了,通货膨胀就是,你的钱是挣来的,他的钱是印来的,掺和在一起,你的钱就贬值了。
|