ST7511初始化代码
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
/********************************************************;
;* IC : ST7511 *;
;* MCU type : W78E52B(20K RAM) *;
;* Data : 2012.08.17 8080 mode *;
;* Bily *;
;********************************************************/
#include
#include
#define uint unsigned int
#define uchar unsigned char
#include"bmp.txt"
//========================================================
sbit RES=P3^4;
sbit CS1=P3^3;
sbit A0=P3^0;
sbit RW=P3^1;
sbit E=P3^2;
sbit DB0=P1^0;
sbit DB1=P1^1;
sbit DB2=P1^2;
sbit DB3=P1^3;
sbit DB4=P1^4;
sbit DB6=P1^6;
sbit DB5=P1^5;
sbit DB7=P1^7;
sbit key1=P3^5;
/*********************************************************/
sbit SCK = P2^0;
sbit SO= P2^1;
sbit SI = P2^2;
sbit CS = P2^3;
//sbit key2=P3^6;
//sbit key3=P3^7;
//========================================================
void init();
void clealddram();
void font1();
void font2();
void font3();
void font4();
void font5();
void showpic(char *k);
void kscan();
void write_com(int para);
void write_data(int para);
void write_data1(int para);
void delay(int t);
int yy=10;
void spi_init(void);
void delayms(int t);
//========================================================
/*
void init()
{
RES=1;
delay(20);
RES=0;
delay(5);
RES=1;
delay(120);
write_com(0xae); //-- SWreset
write_data(0xa5);
write_com(0x61); //-- all PWR on
write_data(0x0f);
write_data(0x04);
write_data(0x02);
write_data(0xa5);
write_com(0x62); //-- VCOM/VGH/VGL default setting
write_data(0x00);
write_data(0x3b);
write_data(0x1b);
write_data(0xa5);
write_com(0x63); //-- VCOM/VGH/VGL default setting
write_data(0x05);
write_data(0x0f);
write_data(0xa5);
write_data(0xa5);
write_com(0x24); //MV MY MX
write_data(0x01);
write_data(0xa5);
write_data(0xa5);
write_data(0xa5);
write_com(0x22); // Gray Select(Mono Mode)
write_data(0x02); //
write_data(0xa5); //
write_data(0xa5); //
write_data(0xa5); //
write_com(0x91); // Gamset
write_data(0x00); //
write_data(0x2b-yy); //
write_data(0x2d-yy); //
write_data(0x2e-yy); //
write_com(0x92); // Gamset
write_data(0x31-yy); //
write_data(0x32-yy); //
write_data(0x33-yy); //
write_data(0x34-yy); //
write_com(0x93); // Gamset
write_data(0x35-yy); //
write_data(0x36-yy); //
write_data(0x37-yy); //
write_data(0x38-yy); //
write_com(0x94); // Gamset
write_data(0x3a-yy); //
write_data(0x3b-yy); //
write_data(0x3c-yy); //
write_data(0x3f); //
write_com(0x99); // Gamset
write_data(0x00); //
write_data(0x2b-yy); //
write_data(0x2d-yy); //
write_data(0x30-yy); //
write_com(0x9a); // Gamset
write_data(0x31-yy);
//
write_data(0x32-yy); //
write_data(0x33-yy); //
write_data(0x34-yy); //
write_com(0x9b); // Gamset
write_data(0x35-yy); //
write_data(0x36-yy); //
write_data(0x37-yy); //
write_data(0x38-yy); //
write_com(0x9c); // Gamset
write_data(0x3a-yy); //
write_data(0x3f-yy); //
write_data(0x45-yy); //
write_data(0x3f); //
write_com(0x12); //-- SLP out
write_data(0xa5);
// clealddram();
write_com(0x15); //-- display on
write_data(0xa5);
} */
void init()
{
RES=1;
delay(20);
RES=0;
delay(5);
RES=1;
delay(120);
write_com(0xae); //-- SWreset
write_data(0xa5);
write_com(0x12); //-- sleep out
write_data(0xa5);
write_com(0x61); //-- all PWR on
write_data(0x8f);
write_data(0x04);
write_data(0xa5);
write_data(0xa5);
write_com(0x62); //-- VCOM/VGH/VGL default setting
write_data(0x00);
write_data(0x0b);
write_data(0x0b);
write_data(0xa5);
write_com(0x33); //-- VCOM/VGH/VGL default setting
write_data(0x07);
write_data(0x2c);
write_data(0x09);
write_data(0x2a);
write_com(0x63); //-- VCOM/VGH/VGL default setting
write_data(0x17);
write_data(0x17);
write_data(0xa5);
write_data(0xa5);
////////////////////////////////////////
write_com(0x91); // Gamset
write_data(0x00); //
write_data(0x2b-yy); //
write_data(0x2d-yy); //
write_data(0x2e-yy); //
write_com(0x92); // Gamset
write_data(0x31-yy); //
write_data(0x32-yy); //
write_data(0x33-yy); //
write_data(0x34-yy); //
write_com(0x93); // Gamset
write_data(0x35-yy); //
write_data(0x36-yy); //
write_data(0x37-yy); //
write_data(0x38-yy); //
write_com(0x94); // Gamset
write_data(0x3a-yy); //
write_data(0x3b-yy); //
write_data(0x3c-yy); //
write_data(0x3f); //
write_com(0x99); // Gamset
write_data(0x00); //
write_data(0x2b-yy); //
write_data(0x2d-yy); //
write_data(0x30-yy); //
write_com(0x9a); // Gamset
write_data(0x31-yy); //
write_data(0x32-yy); //
write_data(0x33-yy); //
write_data(0x34-yy); //
write_com(0x9b); // Gamset
write_data(0x35-yy); //
write_data(0x36-yy); //
write_data(0x37-yy); //
write_data(0x38-yy); //
write_com(0x9c); // Gamset
write_data(0x3a-yy); //
write_data(0x3f-yy); //
write_data(0x45-yy); //
write_data(0x3f); //
write_com(0x24); //MV MY MX
write_data(0x01);
write_data(0xa5);
write_data(0xa5);
write_data(0xa5);
write_com(0x22); // Gray SelectMono Mode
write_data(0x02); //
write_data(0xa5); //
write_data(0xa5); //
write_data(0xa5); //
//-------------------------------------------------------------------------------------
write_com(0x1b); //-- Display Invert in
write_data(0xa5);
//-------------------------------------------------------------------------------------
write_com(0x15); //-- display on
write_data(0xa5);
}
/*
void spi_init(void)
{
SCK = 1;
SI = 1;
CS = 1;
SO = 0;
}
void spiSendByte (unsigned char dat)
{
unsigned char i;
for(i=0;i<8;i++)
{
SCK=0;
if(dat&0x80)
SI=1;
else
SI=0;
SCK=1;
dat<<1;
}
}
unsigned char spiReadByte(void)
{
unsigned char i,dat=0;
for (i=0;i<8;i++)
{
SCK=0;
dat<<1;
if(SO)
dat++;
SCK=1;
}
return dat;
}
unsigned int SPI_Flash_ReadID(void)
{
unsigned int Temp = 0;
CS=0;
spiSendByte(0x90);
spiSendByte(0x00);
spiSendByte(0x00);
spiSendByte(0x00);
Temp|=spiReadByte()<<8;
Temp|=spiReadByte();
CS=1;
return Temp;
}
void SPI_Flash_Read(unsigned long int ReadAddr,unsigned int NumByte)
{
unsigned int i;
CS=0;
spiSendByte(W25X_ReadData);
spiSendByte((unsigned char)((ReadAddr)>>16));
spiSendByte((unsigned char)(ReadAddr)>>8);
}
*/
//========================================================
void clealddram()
{
int i,j;
write_com(0x25); // Page Address Set
write_data(0x00); // Set page START address
write_data(0x27); // Set page END address(Mono Mode)
write_data(0x00); // Set frame address
write_data(0x5a);
write_com(0x26); // Column Address Set
write_data(0x00); // Set column START address
write_data(0x00); // Set column START address
write_data(0x02); // Set column END address
write_data(0x7F); // Set column END address
write_com(0x2c);
write_data(0xa5);
write_com(0x21); //
write_data(0x00); //
write_data(0x27); //
write_data(0x00); //
write_data(0x5
a); //
for(i=0;i<40;i++)
{
for(j=0;j<640;j++)
{
write_data(0x00);
}
}
}
/*
//========================================================
void font1()
{
int i,j;
write_com(0x25); // Page Address Set
write_data(0x00); // Set page START address
write_data(0x27); // Set page END address(Mono Mode)
write_data(0x00); // Set frame address
write_data(0x5a);
write_com(0x26); // Column Address Set
write_data(0x00); // Set column START address
write_data(0x00); // Set column START address
write_data(0x02); // Set column END address
write_data(0x7F); // Set column END address
write_com(0x2c);
write_data(0xa5);
for(i=0;i<40;i++)
{
for(j=0;j<640;j++)
{
write_data(0xff);
}
}
}
//=========================================================
void font2()
{
int i,j;
write_com(0x25); // Page Address Set
write_data(0x00); // Set page START address
write_data(0x27); // Set page END address(Mono Mode)
write_data(0x00); // Set frame address
write_data(0x5a);
write_com(0x26); // Column Address Set
write_data(0x00); // Set column START address
write_data(0x00); // Set column START address
write_data(0x02); // Set column END address
write_data(0x7F); // Set column END address
write_com(0x2c);
write_data(0xa5);
for(i=0;i<40;i++)
{
for(j=0;j<640;j++)
{
write_data(0x55);
}
}
}
//========================================================
void font3()
{
int i,j;
write_com(0x25); // Page Address Set
write_data(0x00); // Set page START address
write_data(0x27); // Set page END address(Mono Mode)
write_data(0x00); // Set frame address
write_data(0x5a);
write_com(0x26); // Column Address Set
write_data(0x00); // Set column START address
write_data(0x00); // Set column START address
write_data(0x02); // Set column END address
write_data(0x7F); // Set column END address
write_com(0x2c);
write_data(0xa5);
for(i=0;i<40;i++)
{
for(j=0;j<320;j++)
{
write_data(0x00);
write_data(0xff);
}
}
}
//========================================================
void font4()
{
int i,j;
write_com(0x25); // Page Address Set
write_data(0x00); // Set page START address
write_data(0x27); // Set page END address(Mono Mode)
write_data(0x00); // Set frame address
write_data(0x5a);
write_com(0x26); // Column Address Set
write_data(0x00); // Set column START address
write_data(0x00); // Set column START address
write_data(0x02); // Set column END address
write_data(0x7F); // Set column END address
write_com(0x2c);
write_data(0xa5);
for(i=0;i<40;i++)
{
for(j=0;j<320;j++)
{
write_data(0x55);
write_data(0xaa);
}
}
}*/
//========================================================
void font5()
{
int i,j;
write_com(0x22); // Gray Select(Mono Mode)
write_data(0x02); //
write_data(0xa5); //
write_data(0xa5); //
write_data(0xa5); //
write_com(0x25); // Page Address Set
write_data(0); // Set page START address
write_data(159); // Set page END address(Mono Mode)
write_data(0x00); // Set frame address
write_data(0x5a);
write_com(0x26); // Column Address Set
write_data(0x00); // Set column START address
write_data(0x00); // Set column START address
write_data(0x02); // Set column END address
write_data(0x7F); // Set column END address
write_com(0x2c);
write_data(0xa5);
for(i=0;i<10;i++)
{
for(j=0;j<640;j++)
{
write_data(0x00);
}
}
for(i=0;i<10;i++)
{
for(j=0;j<640;j++)
{
write_data(0x11);
}
}
for(i=0;i<10;i++)
{
for(j=0;j<640;j++)
{
write_data(0x22);
}
}
for(i=0;i<10;i++)
{
for(j=0;j<640;j++)
{
write_data(0x33);
}
}
for(i=0;i<10;i++)
{
for(j=0;j<640;j++)
{
write_data(0x44);
}
}
for(i=0;i<10;i++)
{
for(j=0;j<640;j++)
{
write_data(0x55);
}
}
for(i=0;i<10;i++)
{
for(j=0;j<640;j++)
{
write_data(0x66);
}
}
for(i=0;i<10;i++)
{
for(j=0;j<640;j++)
{
write_data(0x77);
}
}
for(i=0;i<10;i++)
{
for(j=0;j<640;j++)
{
write_data(0x88);
}
}
for(i=0;i<10;i++)
{
for(j=0;j<640;j++)
{
write_data(0x99);
}
}
for(i=0;i<10;i++)
{
for(j=0;j<640;j++)
{
write_data(0xaa);
}
}
for(i=0;i<10;i++)
{
for(j=0;j<640;j++)
{
write_data(0xbb);
}
}
for(i=0;i<10;i++)
{
for(j=0;j<640;j++)
{
write_data(0xcc);
}
}
for(i=0;i<10;i++)
{
for(j=0;j<640;j++)
{
write_data(0xdd);
}
}
for(i=0;i<10;i++)
{
for(j=0;j<640;j++)
{
write_data(0xee);
}
}
for(i=0;i<10;i++)
{
for(j=0;j<640;j++)
{
write_data(0xff);
}
}
}
//========================================================
void showpic(char *k)
{
int i,j;
write_com(0x25); // Page Address Set
write_data(0x00); // Set page START address
write_data(0x27); // Set page END address(Mono Mode)
write_data(0x00); // Set frame address
write_data(0x5a);
write_com(0x26); // Column Address Set
write_data(0x00); // Set column START address
write_data(0x00); // Set column START address
write_data(0x02); // Set column END address
write_data(0x7F); // Set column END address
write_com(0x2c);
write_data(0xa5);
for(i=0;i<40;i++)
{
for(j=0;j<640;j++)
{
write_data(*k++);
}
}
}
void ShowExpandpic(unsigned char *k)
{
unsigned long int i=0,n=0;
unsigned int num;
unsigned char tmp;
write_com(0x25); // Page Address Set
write_data(0x00); // Set page START address
// write_data(0x27); // Set page END address(Mono Mode)
write_data(0X1D);
write_data(0x00); // Set frame address
write_data(0x5a);
write_com(0x26); // Column Address Set
/* write_data(0x00); // Set column START address
write_data(0x00); // Set column START address
write_data(0x02); // Set column END address
write_data(0x7F); // Set column END address */
write_data(0x00); // Set column START address
write_data(0XA0); // Set column START address
write_data(0x01); // Set column END address
write_data(0xDF); // Set column END address
write_com(0x2c);
write_data(0xa5);
while(i<9600)
{
if (*k==0x00||*k==0xff) //expand code
{
tmp =*k++;
if (*k!=0x00) num=*k++;
else {k++; num=*k++; num|=(*k++<<8);}
while (num--)
{
write_data(tmp);
i++;
}
}
else
{
write_data(*k++);
i++;
}
}
}
/*
void delay_10x_nop_(int t)
{ unsigned char i;
for(i=t;i>0;i--)
{ _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();_nop_(); _nop_(); }
}
*/
//========================================================
void write_com(int para)
{
CS1=0;
A0=0;
E=1;
P1=para;
RW=0;
_nop_();
_nop_();
RW=1;
CS1=1;
}
//========================================================
void write_data(int para)
{
CS1=0;
A0=1;
E=1;
P1=para;
RW=0;
_nop_();
_nop_();;
RW=1;
CS1=1;
}
//========================================================
void write_data1(int para)
{
int rr,i;
CS1=0;
A0=1;
E=1;
for(i=0;i<8;i++)
{
rr<<=1;
if(para&0x01)
rr|=0x01;
para>>=1;
}
P1=para;
RW=0;
delay(200);
RW=1;
CS1=1;
}
//========================================================
void kscan()
{
delay(10);
while(key1==0)
{
delay(10);
}
}
void delayms(int t)
{
int i,j;
for(i=0;i
}
//========================================================
void delay(int t)
{
register int i,j,k;
for(i=0;i
for(k=0;k<8;k++);
}
//========================================================
main()
{
init();
delay(300);
while(1)
{
// font5();
// delay(10000);
//kscan();
write_com(0x22); // Gray Select(Mono Mode)
write_data(0x00); //
write_data(0xa5); //
write_data(0xa5); //
write_data(0xa5); //
ShowExpandpic(bmp2);
delay(15000);
//kscan();
ShowExpandpic(bmp3);
delay(15000);
//kscan();
ShowExpandpic(bmp1);
delay(15000);
//kscan();
ShowExpandpic(bmp6);
delay(15000);
//kscan();
// ShowExpandpic(bmp5);
// delay(15000);
//kscan();
}
}
//=================================================================