【正文】
case 9: if(tab_1302[state][3]30) tab_1302[state][3]=1。 case 8: if(tab_1302[state][3]31) tab_1302[state][3]=1。 case 7: if(tab_1302[state][3]31) tab_1302[state][3]=1。 case 6: if(tab_1302[state][3]30) tab_1302[state][3]=1。 case 5: if(tab_1302[state][3]30) tab_1302[state][3]=1。 case 4: if(tab_1302[state][3]30) tab_1302[state][3]=1。 case 3: if(tab_1302[state][3]31) tab_1302[state][3]=1。 case 2: if(tab_1302[state][3]29) tab_1302[state][3]=1。 switch(tab_1302[state][4]) { case 1: if(tab_1302[state][3]31) tab_1302[state][3]=1。 break。 case 3:tab_1302[state][2]++。 if(tab_1302[state][1]=60) tab_1302[state][1]=0。 break。 if(k2==0) //當(dāng)k2==0時(shí),用于增加現(xiàn)在的時(shí)間和鬧鈴的時(shí)間 { switch(key1) { case 1:tab_1302[state][0]++。 } while(k1==0)。 if(k1==0) { key1++。 } } //當(dāng)k4被釋放后,離開函數(shù) while(k4==0)。i6。 if(state1) //一共要調(diào)2個(gè) { state=0。 //當(dāng)k4被按下時(shí) if(k4==0) { DelayMS(20)。 //日 LCD_ShowCharacter(1,15,tab_state[state])。)。 //月LCD_ShowCharacter(1,12,39。)。 //年 LCD_ShowCharacter(1,9,39。 } LCD_ShowNumber(1,5,20)。 //秒 if(tab_1302[state][2]12) { LCD_ShowString(0,14,tab_am)。)。 //分 LCD_ShowCharacter(0,10,39。)。 //小時(shí) LCD_ShowCharacter(0,7,39。 LCD_ShowString(1,0,tab_d)。 uchar tab_state[]=SA。 uchar tab_set[]=SET。 uchar tab_am[]=AM。 uchar tab_t[]=Time:。 uchar state=0。 uchar key1=1。 sbit k5=P3^3。 sbit k3=P3^7。 init bank mechanism to code bank 0 LJMP ?C_START END主程序代碼include include include //DS1302驅(qū)動(dòng)程序 include //LCD1302驅(qū)動(dòng)程序 define _OK_ 0xf0define _END_ 0xff sbit k1=P3^5。 EXTRN CODE (?B_SWITCH0)。 Standard SFR Symbols ACC DATA 0E0HB DATA 0F0HSP DATA 81HDPL DATA 82HDPH DATA 83H NAME ?C_STARTUP?C_C51STARTUP SEGMENT CODE?STACK SEGMENT IDATA RSEG ?STACK DS 1 EXTRN CODE (?C_START) PUBLIC ?C_STARTUP CSEG AT 0?C_STARTUP: LJMP STARTUP1 RSEG ?C_C51STARTUPSTARTUP1:IF IDATALEN 0 MOV R0,IDATALEN 1 CLR AIDATALOOP: MOV R0,A DJNZ R0,IDATALOOPENDIFIF XDATALEN 0 MOV DPTR,XDATASTART MOV R7,LOW (XDATALEN) IF (LOW (XDATALEN)) 0 MOV R6,(HIGH (XDATALEN)) +1 ELSE MOV R6,HIGH (XDATALEN) ENDIF CLR AXDATALOOP: MOVX DPTR,A INC DPTR DJNZ R7,XDATALOOP DJNZ R6,XDATALOOPENDIFIF PPAGEENABLE 0 MOV PPAGE_SFR,PPAGEENDIFIF PDATALEN 0 MOV R0,LOW (PDATASTART) MOV R7,LOW (PDATALEN) CLR APDATALOOP: MOVX R0,A INC R0 DJNZ R7,PDATALOOPENDIFIF IBPSTACK 0EXTRN DATA (?C_IBP) MOV ?C_IBP,LOW IBPSTACKTOPENDIFIF XBPSTACK 0EXTRN DATA (?C_XBP) MOV ?C_XBP,HIGH XBPSTACKTOP MOV ?C_XBP+1,LOW XBPSTACKTOPENDIFIF PBPSTACK 0EXTRN DATA (?C_PBP) MOV ?C_PBP,LOW PBPSTACKTOPENDIF MOV SP,?STACK1。 SFR that supplies uppermost address byte。 define PPAGE number.。 set to 1 if pdata object are used.。 in the linker invocation.。 The following EQU statements define the xdata page used for pdata。 Page Definition for Using the Compact Model with 64 KByte xdata RAM。 set top of stack to highest location+1.。 Stack Space for reentrant functions in the COMPACT model. PBPSTACK EQU 0 。 set top of stack to highest location+1.。 Stack Space for reentrant functions in the LARGE model. XBPSTACK EQU 0 。 set top of stack to highest location+1.。 Stack Space for reentrant functions in the SMALL model.IBPSTACK EQU 0 。 functions and initialized it:。 runtime routines must be set to zero.。 Notes: The IDATA space overlaps physically the DATA and BIT areas of the。 the length of PDATA memory in bytes.。PDATASTART EQU 0H 。 the absolute startaddress of XDATA memoryXDATALEN EQU 0H 。 the length of IDATA memory in bytes.。 。 at processor reset can be defined:。 To link the modified file to your application use the following。 A51 。 To translate this file use A51 with the following invocation:。 : This code is executed after processor reset.。 Copyright (c) 19882002 Keil Elektronik GmbH and Keil Software, Inc.。sbit CP_RL2 = T2CON^0。sbit TR2 = T2CON^2。sbit TCLK = T2CON^4。sbit EXF2 = T2CON^6。 // 8052 onlysbit T2 = P1^0。sbit RI = SCON^0。sbit RB8 = SCON^2。sbit REN = SCON^4。sbit