完整的程序测试,始终没有显示
#include <reg51.h>
#include <INTRINS.H>
//Data Type Re-defination
#define uchar unsigned char
#define uint unsigned int
#define uchar_code unsigned char code
//MCU Interface Defination
sbit CS1=P3^5;
sbit CS2=P3^6;
sbit RS=P3^0;
sbit RW=P3^1;
sbit E=P3^4;
sbit RST=P3^7;
//Defination Border Dots Matrix
uchar_code border_inf[8] = {
0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x80 };
uchar_code bmp_area[1024]=
{
0xFF,0x81,0xBD,0xA5,0xA5,0xBD,0xA1,0xBF,0xA0,0xA0,0xFF,0x01,0xFD,0xA5,0xA5,0xBD,
0x81,0xFF,0x00,0x00,0xFF,0x01,0x81,0x41,0x21,0xF1,0x01,0x01,0x01,0x01,0x41,0x21,
0x11,0x11,0x11,0x31,0xC1,0x01,0x01,0xC1,0x21,0x11,0x11,0x11,0x21,0xC1,0x01,0x01,
0x11,0x21,0xC1,0x01,0x01,0x01,0xC1,0x21,0x11,0x01,0x01,0xC1,0x21,0x11,0x11,0x11,
0x21,0x41,0x01,0x01,0x01,0x01,0x81,0x41,0x21,0xF1,0x01,0x01,0x01,0x01,0x09,0x89,
0xC9,0xA9,0x99,0x89,0x89,0x45,0x35,0x05,0x05,0x05,0x01,0x01,0x09,0x09,0x09,0xE9,
0x59,0x49,0x49,0xE9,0x49,0x01,0xE1,0x01,0x01,0xFD,0x01,0xFF,0x00,0x00,0xFF,0x81,
0xBD,0xA5,0xA5,0xFD,0x01,0xFF,0xA0,0xA0,0xBF,0xA1,0xBD,0xA5,0xA5,0xBD,0x81,0xFF,
0xFC,0x04,0xF4,0x94,0x94,0xFF,0x00,0xFF,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x04,
0x04,0x04,0x04,0x04,0x07,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x80,0xC0,
0xA0,0x90,0x88,0x86,0x81,0x00,0x00,0x38,0x45,0x82,0x82,0x82,0x45,0x38,0x00,0x80,
0x40,0x20,0x18,0x05,0x02,0x05,0x18,0x20,0x40,0x80,0x00,0x3F,0x42,0x81,0x81,0x81,
0x42,0x3C,0x00,0x18,0x14,0x12,0x11,0x10,0x10,0xFF,0x10,0x00,0x00,0x00,0x84,0x4C,
0x26,0x16,0x05,0x05,0xFC,0x04,0x15,0x26,0x4C,0x88,0x00,0x00,0x04,0x02,0x81,0x42,
0x24,0x18,0x06,0x01,0x00,0x00,0x1F,0x80,0x00,0xFF,0x00,0x07,0x04,0x04,0x04,0x04,
0x04,0x04,0x04,0x04,0x04,0xFC,0x04,0x04,0xFF,0x00,0xFF,0x94,0x94,0xF4,0x04,0xFC,
0x03,0x02,0x02,0x02,0x02,0x02,0x02,0x03,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0xF8,0x08,0x08,0x88,0x78,0xA8,0x28,0xA8,0x68,0x28,0x08,0x08,0xF8,0x00,0x00,
0x00,0x08,0x08,0xF8,0x08,0x08,0xF8,0x08,0x08,0x00,0x40,0x20,0x90,0x1C,0x08,0x00,
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0xFC,0x90,0x90,0x90,0xD0,0x90,0x00,0x00,0x00,
0xF8,0x08,0x48,0xA8,0x18,0x20,0x20,0xE0,0x3C,0xA0,0x20,0x20,0x20,0x21,0x00,0x00,
0x40,0x84,0x19,0x82,0x61,0x10,0x90,0x70,0x10,0x95,0xF8,0x90,0x91,0x91,0x10,0x00,
0x00,0x00,0x00,0x00,0xF8,0xA8,0xA8,0xA8,0xA9,0xA8,0xA8,0xF8,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x03,0x02,0x02,0x02,0x02,0x02,0x02,0x03,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0xFF,0x09,0x09,0x04,0x04,0x22,0xC9,0x52,0x02,0x04,0x0C,0x04,0xFF,0x00,0x00,
0x01,0x01,0xC1,0x3F,0x01,0x01,0xFF,0x01,0x11,0x09,0x84,0x42,0x23,0x39,0x10,0x00,
0x00,0x00,0xC0,0x1F,0x48,0x88,0x08,0x28,0x48,0x88,0x08,0x3F,0x40,0x80,0x00,0x00,
0xFF,0x00,0x08,0x10,0x0F,0x12,0x13,0x12,0x12,0xFF,0x12,0x12,0x12,0x12,0x10,0x00,
0x10,0x11,0xFC,0x03,0x04,0x02,0xFF,0x04,0x86,0x49,0x32,0x6C,0x86,0x01,0x00,0x00,
0x00,0xFC,0x94,0x94,0x95,0x94,0xFC,0x00,0x00,0xFC,0x94,0x95,0x94,0x94,0xFC,0x00,
0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0x01,0xF9,0xA9,0xA9,0xA9,0xA9,0xA9,0xA9,0xA9,0xF9,0x01,0x03,0x00,0x00,
0x02,0x81,0x80,0x88,0x88,0x88,0x89,0x88,0x8A,0x89,0x88,0x88,0x88,0x80,0x80,0x00,
0x40,0x41,0xFC,0x40,0x40,0x11,0xD0,0x50,0x7C,0x51,0x50,0x7C,0xD0,0x11,0x00,0x00,
0x43,0x40,0xFC,0x40,0x40,0x00,0x20,0x20,0xFC,0x23,0x20,0x20,0xE0,0x00,0x00,0x00,
0x20,0xC4,0x1B,0x80,0x00,0xF8,0x0B,0xC9,0x08,0xF8,0x00,0xE0,0x01,0x03,0xFD,0x00,
0x00,0x09,0x70,0x20,0x00,0x40,0x41,0x40,0x40,0x41,0xFC,0x40,0x48,0x70,0x41,0x00,
0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xC0,0x40,0x40,0x40,0x40,0x40,0x40,0xC0,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,
0x80,0x84,0x88,0xB0,0x80,0xFF,0x80,0x80,0x80,0xFF,0xA0,0x90,0x8C,0x80,0x80,0x00,
0x40,0x20,0x10,0x0C,0x00,0x00,0x00,0xFF,0x00,0x00,0x04,0x08,0x30,0x60,0x00,0x00,
0x0C,0x03,0xFF,0x01,0x02,0x10,0x17,0x15,0xD5,0x3D,0x55,0x95,0x97,0x10,0x10,0x00,
0x20,0x60,0x3F,0x10,0x14,0x04,0xC4,0x34,0x0F,0x14,0x24,0x44,0xC7,0x84,0x84,0x00,
0x10,0xF0,0x0E,0x01,0x00,0x1F,0xC0,0x3F,0x40,0x9F,0x00,0x1F,0x00,0x00,0xFF,0x00,
0x01,0x01,0xFF,0x80,0x40,0x82,0x82,0x7E,0x42,0x42,0x07,0x18,0x60,0x80,0xE0,0x00,
0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0xC0,0x40,0x40,0x40,0x40,0x40,0x40,0xC0,
0x3F,0x20,0x2F,0x29,0x29,0xFF,0x00,0xFF,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0xE0,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0xC0,0x00,0x80,0x00,
0x00,0x80,0x00,0xC0,0x00,0x81,0x02,0x01,0x80,0x00,0xC0,0x00,0x80,0x00,0x00,0x80,
0x00,0xC0,0x03,0x80,0x00,0x02,0x82,0x01,0xC0,0x00,0x80,0x00,0x01,0x83,0x01,0xC0,
0x00,0x80,0x00,0x00,0x82,0x01,0xC0,0x00,0x80,0x00,0x00,0x80,0x00,0xC1,0x00,0x80,
0x00,0x03,0x80,0x00,0xC2,0x01,0x80,0x00,0x00,0x81,0x00,0xC0,0x01,0x82,0x01,0x00,
0x80,0x00,0xC1,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x20,0x20,0x21,0x20,
0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0xFF,0x00,0xFF,0x29,0x29,0x2F,0x20,0x3F,
0xFF,0x81,0xBD,0xA5,0xA5,0xBD,0x85,0xFD,0x05,0x05,0xFF,0x80,0xBF,0xA5,0xA5,0xBD,
0x81,0xFF,0x00,0x00,0xFF,0x80,0x80,0x80,0x80,0x80,0x84,0x83,0x8F,0x83,0x84,0x80,
0x80,0x84,0x83,0x8F,0x83,0x84,0x80,0x80,0x84,0x83,0x8F,0x83,0x84,0x80,0x80,0x84,
0x83,0x8F,0x83,0x84,0x80,0x80,0x84,0x83,0x8F,0x83,0x84,0x80,0x80,0x84,0x83,0x8F,
0x83,0x84,0x80,0x80,0x84,0x83,0x8F,0x83,0x84,0x80,0x80,0x84,0x83,0x8F,0x83,0x84,
0x80,0x80,0x84,0x83,0x8F,0x83,0x84,0x80,0x80,0x84,0x83,0x8F,0x83,0x84,0x80,0x80,
0x84,0x83,0x8F,0x83,0x84,0x80,0x80,0x80,0x80,0x80,0x80,0xFF,0x00,0x00,0xFF,0x81,
0xBD,0xA5,0xA5,0xBF,0x80,0xFF,0x05,0x05,0xFD,0x85,0xBD,0xA5,0xA5,0xBD,0x81,0xFF
};
/*Check Busy Flag
void check_busy(void)
{
RS=0;
RW=1;
P1=0Xff;
while (1)
{
E=1;
if (P1<0x80) break;
E=0;
}
E=0;
}
End Function check_busy*/
//Delay Times(s Level)
#pragma disable
void delays(uint n)
{
uint s;
while (n-- >0)
for (s=0;s<400;s++)
{}
}
//Write Instruction Code
#pragma disable
void wr_cmd(uchar cmd)
{
E=0;
_nop_();
_nop_();
RS=0;
_nop_();
_nop_();
RW=0;
_nop_();
_nop_();
P1=cmd;
_nop_();
_nop_();
E=1;
_nop_();
_nop_();
E=0;
_nop_();
_nop_();
}
//Write Display RAM Data
#pragma disable
void wr_dat(uchar dat)
{
E=0;
_nop_();
_nop_();
RS=1;
_nop_();
_nop_();
RW=0;
_nop_();
_nop_();
P1=dat;
_nop_();
_nop_();
E=1;
_nop_();
_nop_();
E=0;
_nop_();
_nop_();
}
//S6B0108 Initial
#pragma disable
void initial()
{
CS1=1;CS2=1;
wr_cmd(0x3f); //Display On
wr_cmd(0xb8);//Set Page Address(X Address)
wr_cmd(0x40);//Set Address(Y Address)
wr_cmd(0xc0);//Set Display Start Line(Z Address)
}
void wr_dots(uchar dat1,uchar dat2)
{
uint page_cnt,col_cnt;
uchar pg_address;
pg_address = 0xb8;
for (page_cnt=0;page_cnt<8;page_cnt++)
{
wr_cmd(pg_address); //Set Page Address(X Address)
wr_cmd(0x40);//Set Address(Y Address)
for (col_cnt=0;col_cnt<32;col_cnt++)
{
wr_dat(dat1);
wr_dat(dat2);
}
pg_address ++;
}
}
#pragma disable
void wr_border(void)
{
uint page_cnt,col_cnt;
uchar pg_address;
pg_address = 0xb8;
for (page_cnt=0;page_cnt<8;page_cnt++)
{
wr_cmd(pg_address); //Set Page Address(X Address)
wr_cmd(0X40);//Set Address(Y Address)
wr_dat(0xff);
for (col_cnt=1;col_cnt<63;col_cnt++)
{
wr_dat(border_inf[page_cnt]);
}
wr_dat(0xff);
pg_address ++;
}
}
#pragma disable
void disp_dat(uchar dat1,uchar dat2)
{
CS1=1;CS2=0;
wr_dots(dat1,dat2);
CS1=0;CS2=1;
wr_dots(dat1,dat2);
}
#pragma disable
void disp_border(void)
{
CS1=1;CS2=0;
wr_border();
CS1=0;CS2=1;
wr_border();
}
#pragma disable
void disp_bmp(uchar_code *bmparea)
{
uint i=0,j=0;
uchar temp;
CS1=1;CS2=0;
temp=0xb8;
wr_cmd(0xc0);
for(j=0;j<8;j++)
{
wr_cmd(temp);
wr_cmd(0x40);
for(i=0;i<64;i++)
{ wr_dat(bmparea[i+j*128]);}
temp++;
}
CS1=0;CS2=1;
temp=0xb8;
wr_cmd(0xc0);
for(j=0;j<8;j++)
{
wr_cmd(temp);
wr_cmd(0x40);
for(i=0;i<64;i++)
{ wr_dat(bmparea[i+j*128+64]);}
temp++;
}
}
void main()
{
RST=0;
delays(10);
RST=1;
delays(5);
//S6B0108 initial
initial();
while (1)
{
disp_dat(0xff,0xff); //All Dots Display
delays(100);
disp_dat(0x00,0x00); //Clear Screen
delays(100);
disp_dat(0xaa,0xaa); //Seperate rows I
delays(100);
disp_dat(0x55,0x55); //Seperate rows II
delays(100);
disp_dat(0xff,0x00); //Seperate Columns I
delays(100);
disp_dat(0x00,0xff); //Seperate Columns II
delays(100);
disp_dat(0xaa,0x55); //Seperate Dots I
delays(100);
disp_dat(0x55,0xaa); //Separate Dots II
delays(100);
disp_border();//Display The Border
delays(100);
disp_bmp(bmp_area);
delays(100);
}
} |