#include<c8051f120.h>
#include<intrins.h>
#include<math.h>
#include<declare.h>
typedef unsigned char uchar;
typedef unsigned int uint;
/******************************函数声明*************************
void lcd_senddata(unsigned char da);
void lcd_sendcmd(unsigned char da);
void lcd_int(void);
void Set_Page_Address(unsigned char dat);
void Set_Colume_Address(unsigned char dat);
void lcd_clr(void);
void lcd_disword(unsigned char x,unsigned char y,unsigned char* wp);
void lcd_disletter(unsigned char x,unsigned char y,unsigned char* lp);
void lcd_drawpot(unsigned char x, unsigned char y);
void lcd_Picture(unsigned char *pic);
/*******************************end********************************/
uchar old_SFRPAGE;
uchar y[80];
void delay1us()
{
unsigned char i=15;
while(i)
{
_nop_();_nop_();_nop_();
--i;
}
}
void delay10us()
{
unsigned char i=149;
while(i)
{
_nop_();_nop_();_nop_();
--i;
}
}
void delay100us()
{
uint i=680;
while(i)
{
_nop_();_nop_();_nop_();
i--;
}
}
void delay1ms()
{
uchar i=10;
while(i)
{
delay100us();i--;
}
}
void sys_int()
{
WDTCN=0XDE; //禁止看门狗
WDTCN = 0xAD;
old_SFRPAGE = SFRPAGE;
SFRPGCN=1; //SFR页选择
SFRPAGE=0XF;
SFRPAGE=old_SFRPAGE;
}
void oscx_int()
{
old_SFRPAGE = SFRPAGE;
SFRPAGE=0XF;
OSCXCN=0X67; //外部晶振,11.0592M
delay1ms(); //wait 1ms以上
while(OSCXCN&0X80!=0X80) //判断外部晶振正常工作
_nop_();
CLKSEL = 0x01; //切换到外部晶振
OSCICN = 0x00; //关闭内部晶振
SFRPAGE=old_SFRPAGE;
}
void pll_int()
{
old_SFRPAGE = SFRPAGE;
SFRPAGE=0XF;
PLL0CN=0X04; //PLL参考外部
SFRPAGE=0;
FLSCL=0X30; //
SFRPAGE=0XF;
PLL0CN|=0X01; //PLL上电
PLL0DIV=1; //1分频
PLL0FLT=0X07;
PLL0MUL=8; //8倍频
delay10us(); //延时5us以上
PLL0CN|=0x02; //PLL使能
while(PLL0CN&0X10!=0X10) //判断PLL频率已锁定
_nop_();
CLKSEL=0X02; //切换系统时钟为PLL
SFRPAGE = old_SFRPAGE;
}
void port_int()
{
old_SFRPAGE = SFRPAGE;
SFRPAGE=0x0F;
P3|=0X02;
XBR2=0X40; //允许交叉开关,全局弱上拉
SFRPAGE = old_SFRPAGE;
}
unsigned char code zhong[]={0x00,0x00,0xFC,0x08,0x08,0x08,0x08,0xFF,0x08,0x08,0x08,0x08,0xFC,0x08,0x00,0x00,
0x00,0x00,0x07,0x02,0x02,0x02,0x02,0xFF,0x02,0x02,0x02,0x02,0x07,0x00,0x00,0x00} ;//中 ,纵向取模,字节倒序
unsigned char code guo[]={0x00,0xFE,0x02,0x0A,0x8A,0x8A,0x8A,0xFA,0x8A,0x8A,0x8A,0x0A,0x02,0xFE,0x00,0x00,
0x00,0xFF,0x40,0x48,0x48,0x48,0x48,0x4F,0x48,0x49,0x4E,0x48,0x40,0xFF,0x00,0x00} ;//国
unsigned char code shi[]={0x02,0x02,0x02,0x02,0x82,0xF2,0x4E,0x42,0x42,0x42,0x42,0x42,0xC2,0x02,0x02,0x00,
0x10,0x08,0x04,0x02,0x01,0x7F,0x20,0x20,0x20,0x20,0x20,0x20,0x7F,0x00,0x00,0x00} ;//石
unsigned char code you[]={0x10,0x61,0x06,0xF0,0x00,0xF0,0x10,0x10,0x10,0xFF,0x10,0x10,0x10,0xF0,0x00,0x00,
0x04,0x04,0xFF,0x00,0x00,0xFF,0x42,0x42,0x42,0x7F,0x42,0x42,0x42,0xFF,0x00,0x00} ;//油
unsigned char code da[]={0x20,0x20,0x20,0x20,0x20,0x20,0xA0,0x7F,0xA0,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
0x00,0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x01,0x06,0x08,0x30,0x60,0xC0,0x40,0x00} ;//大
unsigned char code xue[]={0x40,0x30,0x10,0x12,0x5C,0x54,0x50,0x51,0x5E,0xD4,0x50,0x18,0x57,0x32,0x10,0x00,
0x00,0x02,0x02,0x02,0x02,0x02,0x42,0x82,0x7F,0x02,0x02,0x02,0x02,0x02,0x02,0x00} ;//学
uchar code m[]={0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F};//m
uchar code h[]={0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20};//h
uchar code c[]={0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00};//c
uchar code shu[]={0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00};
/**************************************************汉字编码**************************************************/
/**************************************************picture******************************************/
uchar code pic[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,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,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,
0x80,0x00,0x40,0x00,0x80,0x40,0x00,0x40,0x00,0x80,0x00,0x00,0x80,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,
0x00,0x00,0x04,0x02,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x04,0x00,0x04,0x04,0x00,
0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x6F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x00,0x00,
0x08,0x00,0x08,0x08,0x00,0x00,0x08,0x04,0x08,0x08,0x00,0x08,0x00,0x08,0x00,0x08,
0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x00,0x01,0x00,0x02,0x02,
0x02,0xDD,0x00,0x02,0x02,0x02,0x00,0x02,0x00,0x02,0x02,0x60,0x2D,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,0x04,0x00,0x00,0x04,0x00,
0x04,0x00,0x04,0x00,0x02,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x02,0x00,0x02,
0x00,0x04,0x00,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x14,0x00,0x08,0x08,0x08,0x00,0x00,
0x10,0x15,0x10,0x00,0x10,0x10,0x10,0x10,0x08,0x10,0x15,0x00,0x10,0x00,0x10,0x10,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x