#include<reg52.h> #define uint unsigned int #define uchar unsigned char uchar n,m; uchar code tu32[]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24, 0xC8,0x00,0x74,0x54,0x7C,0x54,0x7C,0x54,0x74,0x04,0x00,0x88,0x88,0xE8,0xA8,0xA8, 0xAC,0xA8,0xA8,0xE8,0x88,0x88,0x00,0x10,0xF0,0x1C,0xF0,0x10,0x10,0x10,0xFC,0x10, 0x10,0x10,0x00,0x10,0xF0,0x1C,0xF0,0x00,0xF8,0xA8,0xAC,0xA8,0xF8,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x40,0x40,0x80,0x80, 0x40,0x40,0x40,0x40,0xC0,0x40,0x40,0x40,0x40,0x40,0x80,0x80,0x00,0x80,0x80,0x80, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, 0x1F,0x00,0x14,0x0D,0x05,0x15,0x1D,0x05,0x0D,0x14,0x00,0x11,0x10,0x08,0x06,0x02, 0x02,0x02,0x1E,0x10,0x10,0x1D,0x00,0x13,0x0A,0x04,0x0B,0x00,0x1F,0x11,0x11,0x11, 0x11,0x1F,0x00,0x10,0x0B,0x04,0x0B,0x00,0x1F,0x10,0x0B,0x04,0x0A,0x11,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x80,0x60,0x10,0x8C,0x82,0x41,0xA0,0x60,0x18,0x80,0x44,0x22, 0x22,0x44,0x80,0x01,0x84,0x42,0x22,0x24,0x40,0x8C,0x30,0x42,0x81,0x80,0x00,0x00, 0x00,0x07,0x78,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10, 0x91,0x55,0xF5,0x5D,0x57,0x55,0x55,0xD5,0x11,0x10,0x00,0x11,0x16,0xF0,0x04,0x14, 0x64,0x04,0x04,0xFF,0x04,0x04,0x00,0x20,0x22,0x2A,0xB2,0x62,0xFF,0x62,0xB2,0x2A, 0x22,0x20,0x00,0x00,0x1C,0x7E,0x7E,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x01,0x01,0xF1,0x0C,0x02,0x01,0xE0,0x10,0x08,0x09,0x12,0x94, 0x97,0x2B,0x29,0x28,0x21,0x12,0x14,0x17,0x23,0xC1,0xE0,0x10,0x00,0x00,0x01,0x03, 0x0D,0xF2,0x02,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 0x00,0x00,0x07,0x05,0x05,0x05,0x05,0x07,0x00,0x80,0x80,0x84,0x02,0x01,0x02,0x84, 0x84,0x85,0x85,0x05,0x84,0x84,0x80,0x02,0x02,0x01,0x80,0x80,0x87,0x80,0x00,0x01, 0x02,0x02,0x00,0x00,0x00,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x84,0xC8,0xD0,0x55,0x2A,0x34,0x24,0x49, 0x49,0x90,0x90,0x93,0x93,0x48,0x48,0x64,0x53,0x40,0x20,0x21,0x50,0xD0,0xC8,0x8C, 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x21,0x4C,0x82,0x00,0x01,0x03,0x01,0x00, 0x80,0xC0,0x7F,0x21,0x4C,0x82,0x00,0x01,0x03,0x01,0x00,0x80,0xC0,0x61,0x3F,0x1E, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x38,0x3C,0x3E,0x37,0x23,0x00,0x07,0x08,0x17,0x2D,0x0D,0x07, 0x03,0x01,0x03,0x03,0x01,0x03,0x07,0x0D,0x0D,0x07,0x20,0x10,0x08,0x07,0x00,0x23, 0x37,0x3E,0x3C,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x06,0x03, 0x01,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x06,0x03,0x01,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }; sbit rs = P2^0; sbit rw = P2^1; sbit en = P2^2; sbit psb = P2^3; sbit rst = P2^4; /***************延时函数***********************/ void delay(uint ms) { uint a,b; for (a=ms;a>0;a--) for(b=110;b>0;b--); } /****************写指令************************/ void com(uchar com) { rs=0; //rs拉低为写入指令 rw=0; //选择写操作 P0=com; //往P0口送数据 delay(5); //稍微延时保证数据都送过去 en=1; //使能端拉高写入数据 delay(5); en=0; //锁存数据 } /****************写数据************************/ void dat(uchar dat) { rs=1; //rs拉低为写入数据 rw=0; //选择写操作 P0=dat; //往P0口送数据 delay(5); //稍微延时保证数据都送过去 en=1; //使能端拉高写入数据 delay(5); en=0; //锁存数据 } /***************初始化init函数*****************/ void init() { psb=1; //设置数据为并行口方式 com(0x30); //初始启动 delay(5); com(0x0e); //显示开关,打开光标和反白 delay(5); com(0x01); //清除指令 delay(5); } /***************显示函数******************** void display() { uint i; com(0x80); for(i=0;i<622;i++) { dat(tu32[i]); delay(2); } } /***************清除GCRAM里的内容,防止花屏*****/ void clear_gcrom() { uchar i,j,k; m=n=0x80; com(0x34); for(i=0;i<2;i++) { for(j=0;j<32;j++) { com(m+j); com(n); for(k=0;k<16;k++) { dat(0x00); } } n=0x88; } com(0x36); com(0x30); } /***************显示图片**********************/ void displaytu(uchar *p) { uchar i,j,k; m=n=0x80; com(0x34); for(i=0;i<2;i++) { for(j=0;j<32;j++) { com(m+j); com(n); for(k=0;k<16;k++) { dat(*p++); } } n=0x88; } com(0x36); com(0x30); } /*****************主函数**********************/ void main() { init(); displaytu(tu32); while(1); }