{
unsigned char i; //定义变量 while(ms--) {
for(i = 0; i< 250; i++) {
_nop_(); //空指令函数,延时 _nop_(); _nop_(); _nop_(); } } }
/********************************************************** 函数功能:测试LCD忙碌状态 入口参数: 出口参数:result
***********************************************************/ bit lcd_bz() { bit result; rs = 0; rw = 1; ep = 1; _nop_();
45
_nop_(); _nop_(); _nop_();
result = (bit)(P0 & 0x80); ep = 0; return result; }
/********************************************************** 函数功能:写指令数据到LCD子程序 入口参数:cmd 出口参数:
**********************************************************/ void lcd_wcmd(unsigned char cmd)
{while(lcd_bz()); //判断LCD是否忙碌 rs = 0; rw = 0; ep = 0; _nop_(); _nop_(); P0 = cmd; _nop_(); _nop_(); _nop_(); _nop_();
46
ep = 1; _nop_(); _nop_(); _nop_(); _nop_(); ep = 0; }
/********************************************************** 函数功能:设定显示位置子程序 入口参数:pos 出口参数:
***********************************************************/ void lcd_pos(unsigned char pos) {
lcd_wcmd(pos | 0x80); }
/********************************************************** 函数功能:写入显示数据到LCD子程序 入口参数:dat 出口参数:
***********************************************************/ void lcd_wdat(unsigned char dat)
{ while(lcd_bz()); //判断LCD是否忙碌 rs = 1;
47
rw = 0; ep = 0; P0 = dat; _nop_(); _nop_(); _nop_(); _nop_(); ep = 1; _nop_(); _nop_(); _nop_(); _nop_(); ep = 0; }
/************************************************************ 函数功能:LCD初始化子程序 入口参数: 出口参数:
*************************************************************/ void lcd_init() {
lcd_wcmd(0x38); //显示模式设置 delay(1);
lcd_wcmd(0x0c); //开显示 delay(1);
48
lcd_wcmd(0x06); //显示光标移动设置 delay(1);
lcd_wcmd(0x01); //清屏 delay(1); }
/*******************显示函数***********/
void display(unsigned char miao,unsigned char feng,unsigned char shi,unsigned char h,unsigned char l,unsigned char y,unsigned char mo,unsigned char d) {
unsigned char i,miao1,miao2,feng1,feng2,shi1,shi2; miao1=miao/10;
miao2=miao; feng1=feng/10; feng2=feng; shi1=shi/10;
shi2=shi;
//求百位
//求十位
dis2[6]=(h*10)00/100+0x30;
dis2[7]=(h*10)0/10+0x30; //求个位
dis2[9]=(h*10)+0x30; //求小数位
dis2[12]=(l*10)00/100+0x30;
//求十位
dis2[13]=(l*10)0/10+0x30; //求个位
dis2[15]=(l*10)+0x30; //求小数位
dis1[1]=(y)+0x30; //求ge位
49