资源描述:
《毕业设计电子时钟程序》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、#include#defineucharunsignedchar#defineuintunsignedint#defineLCD_PORTP0sbitRS=P1^0;sbitRW=P1^1;sbitEN=P1^2;sbitKEY1=P1^3;sbitKEY2=P1^4;sbitKEY3=P1^5;sbitKEY4=P1^6;sbitLED1=P2^0;sbitLED2=P2^1;sbitBEEP=P2^2;sbitHW=P3^3;sbitDS=P3^4;voidDelay(ui
2、ntt);voidDelay_Ms(uintt);voidWriteData(ucharDAT);voidWriteCommand(ucharCOM);voidLcdPost(ucharX,ucharY);voidDisplayChar(ucharX,ucharY,ucharDAT);voidDisplayString(ucharX,ucharY,uchar*p);voidInitLcd1602();voidreset();bitread_bit();voidwrite_all(uchardate
3、);unsignedcharread_all();voidtempchange();unsignedintget_temp();voidWelcome_Page();voidClean_Screen();voidDisplay_Temper(uinttemper);voidDisplay(ucharx,uchary,uintnum);voidDisplay_Date();voidDisplay_Week();voidDisplay_Ring();voidDisplay_Lcd();voidChec
4、k_Ring();voidCheck_Temperature();voidKey_Scan();voidKey_Service();voidBeep();voidAlarm_Led(ucharnum);voidAlarm_Ringing();voidTimer0_Init();voidHW_Init();voidSystem_Init();unsignedchardate;unsignedcharyear,month,day,week,hour,min,sec,ring;unsignedcharr
5、ing_hour,ring_min,ring_sec;unsignedinttemperature;unsignedcharflag=0,ring_flag=0;unsignedcharhw_data[4]={0};bittemper_alarm=0;bithw_flag=0;bitset_date=0;bitset_ring=0;bitadd_flag=0;bitsub_flag=0;bitring_open=0;bitisRingTime=0;bitkey_on=0;bithw_on=0;vo
6、idmain(){System_Init();//系统初始化while(1){if((set_ring==0)&&(set_date==0)){Display_Lcd();}Check_Ring();Check_Temperature();Key_Scan();}}voidDelay(uintt)//延时微秒函数{while(t--);}voidDelay_Ms(uintt)//延时毫秒函数{unsignedintx,y;for(x=t;x>0;x--)for(y=110;y>0;y--);}vo
7、idWriteData(ucharDAT)//写数据到LCD{RS=1;RW=0;LCD_PORT=DAT;EN=1;Delay_Ms(5);EN=0;}voidWriteCommand(ucharCOM)//写指令到LCD{RS=0;RW=0;LCD_PORT=COM;EN=1;Delay_Ms(5);EN=0;}voidLcdPost(ucharX,ucharY)//设置显示坐标函数{ucharaddr;if(X==0){addr=0x80+Y;}elseif(X==1){addr=0x80+
8、0x40+Y;}WriteCommand(addr);}voidDisplayChar(ucharX,ucharY,ucharDAT)//显示一个字符{LcdPost(X,Y);WriteData(DAT);}voidDisplayString(ucharX,ucharY,uchar*p)//显示一个字符串{LcdPost(X,Y);while(*p!=' '){WriteData(*p);p++;}}voidInitLcd1602(){WriteCommand(0x38);//