;;=======±¨¾¯ÏµÍ³=========== SDA EQU P3.6 SCL EQU P3.7 phonenum EQU 03H ;µç»°¸öÊý ORG 0000H LJMP main ORG 0013H JMP INTPT1 org 000bh ljmp time0 org 001bh ljmp time1 ORG 0020H main: CLR EA MOV TMOD,#11H SETB ET0 setb et1 MOV A,#00H MOV B,A MOV R0,#20H CLR_RAM: MOV @R0,A INC R0 CJNE R0,#80H,CLR_RAM mov sp,#60h MAIN1: MOV 3AH,#00H ;µç»°±íÖ¸Õë MOV 37H,#00h MOV IP,#02H clr IT1 mov tl0,#0b0h mov th0,#3ch mov tl1,#0b0h mov th1,#3ch mov P0,#0ffh mov P1,#0ffh MOV P2,#0FFH ;p2.6 »»ÎªµÍµçƽÇý¶¯ MOV P3,#0FEH SETB EA setb tr1 ;=========²âÊÔ°´¼ü================ JNB P3.1,L2 MOV 30H,#16H LCALL delay10ms JNB P3.1,L2 MOV 30H,#16H LCALL delay10ms JNB P3.1,L2 LJMP pre_set ;½øÈëÔ¤Öà L2: JB P3.2,Next0 ;ÖжÏ0 Èç¹ûÓïÒôһֱΪµÍ ¾Í¹Ò»ú MOV 30H,#16H LCALL delay10ms JB P3.2,Next0 MOV 30H,#16H LCALL delay10ms JB P3.2,Next0 lcall handfree;·ÇµÍµãÆÀ²¦ºÅÒò ;------------------------------------------- Next0: JNB P3.4,NEXT1 MOV 30H,#10 LCALL delay10ms JNB P3.4,NEXT1 MOV 30H,#10 LCALL delay10ms JNB P3.4,NEXT1 setb 00h ;Ϊ¿ª¹ØÖжÏ1µÄ±êÖ¾ NEXT1: JNB P3.5,NEXT2 MOV 30H,#16H LCALL delay10ms JNB P3.5,NEXT2 MOV 30H,#16H LCALL delay10ms JNB P3.5,NEXT2 clr 00h ;------------------------------------------- NEXT2: JNB 00H,NEXTMAIN SETB EX1 ljmp NEXTMAIN1 NEXTMAIN: CLR EX1 NEXTMAIN1: NOP NOP LJMP MAIN1 ;=====================Ô¤ÖÃÆ=========================================================================== pre_set: lcall beep setb tr0 CLR EX1 pre_set1:jb 03h,pout ;60Ãëʱ¼ûµ½ JNB P3.1,L3 MOV 30H,#16H LCALL delay10ms JNB P3.1,L3 MOV 30H,#16H LCALL delay10ms JNB P3.1,L3 pout: ljmp pre_out L3: mov a,#0ffh lcall findkey cjne a,#00h,key ljmp pre_set1 ;==================¼Òô======================= key: mov 71h,#00h mov 70h,#00h cjne a,#93h,L91 ;²»ÊÇ*£¬ÅжÏÊDz»ÊÇ#ºÅ clr P2.5 lcall beep lcall beep L93: lcall findkey jb 03h,pout cjne a,#00h,L931 ljmp L93 L931: mov 71h,#00h mov 70h,#00h cjne a,#93h,L93 ;ÊÇ* ºÅ¼üÂ𣿠setb P2.5 ;ֹͣ¼Òô mov 30h,#30 lcall delay10ms clr P2.4 rescan: lcall findkey cjne a,#00h,stopplay ljmp rescan stopplay: setb P2.4 mov 30h,#30 lcall delay10ms ljmp pre_set1 L91: cjne a,#91h,pre_set1 ;ÊÇ# ºÅ¼üÂ𣿠;======½øÈë´æ´¢×´Ì¬========== ================== L63_1: lcall beeplong nop nop rep000: lcall findkey jb 03h,pout cjne a,#00h,L911 ljmp rep000 L911: mov 71h,#00h mov 70h,#00h cjne a,#91h,L63 ljmp pre_set L63: mov 31h,a ;±£´æÓÚ31HÖеÄÊǵڼ¸µç»°ºÅ ¼´Ò³ÃæºÅ ;============ÅжÏ1~9 #=============================== clr c subb a,#84h jnc rep000 mov a,31h CLR C subb a,#61h jnc L91_1 ljmp rep000 L91_1: lcall beep ;ÔÚ1~9Ö®¼ä L91_11: lcall findkey jb 03h,pre_out cjne a,#00h,L91_2 ljmp L91_11 L91_2: mov 71h,#00h mov 70h,#00h cjne a,#91h,rep000 ;ÊÇ"#"¼üÂð ;===============½øÈë´æ´¢ºÅÂë״̬7==5==5========================== lcall beep lcall beep mov a,31h clr c subb a,#61h mov dptr,#Tab123 movc a,@a+dptr dec a mov b,#16d mul ab mov r6,a ;r6Öдæ·ÅÒ³ÃæÊ×µØÖ· L92: lcall findkey jb 03h,pre_out cjne a,#00h,L61 ljmp L92 L61: mov 71h,#00h mov 70h,#00h mov 32h,a ;ÔÚ61h ºÍ93hÖ®¼äÂð clr c subb a,#93h jnc beep_err mov a,32h clr c subb a,#61h jnc store_1 lcall beep_err ljmp L92 ; store_1: mov a,32h ;¿ªÊ¼´æ´¢µç»°ºÅÂë lcall wtic16 mov a,#98h lcall rdic16 clr c subb a,32h jz usebeep ljmp store_1 usebeep: lcall beep lcall beep lcall beep inc r6 ;²¦ÏÂÒ»¸öºÅ mov r0,32h cjne r0,#91h,L92 ;²»ÊÇ#ºÅ ljmp rep000 ;======================================================== pre_out: setb 00h setb ex1 lcall beeplong lcall beeplong ljmp main1 ;===========´æ´¢Íê±Ï============================================= beep_err: mov r4,#5 beep1: clr p2.7 mov 30h,#4 lcall delay10ms setb p2.7 mov 30h,#5 lcall delay10ms djnz r4,beep1 ret beep: clr P2.7 mov 30h,#10 lcall delay10ms setb P2.7 mov 30h,#20 lcall delay10ms ret beeplong: clr P2.7 mov 30h,#50 lcall delay10ms setb P2.7 ret ;================================= time0: push 00h push acc push psw CLR C MOV A,71H ADD A,#01H MOV 71H,A MOV A,70H ADDC A,#00H MOV 70H,A MOV R0,71H CJNE R0,#58H,OVER000 MOV R0,70H CJNE R0,#02H,OVER000 SETB 03h mov 70h,#00h mov 71h,#00h mov th0,#3ch mov tl0,#0b0h clr tr0 ljmp tout OVER000: mov th0,#3ch mov tl0,#0b0h clr 03h setb tr0 tout: pop psw pop acc pop 00h ;±£´ær0 reti time1: mov tl1,#0b0h mov th1,#3ch setb tr1 clr P2.3 nop nop nop nop nop setb P2.3 reti ;======================================================= INTPT1: clr et0 MOV P1,#03H lcall keydelay mov 30h,#14h lcall delay10ms MOV 40H,#00H mov 39h,#64h agains: mov 30h,#01h lcall delay10ms jb P3.2,nexti inc 40h nexti: djnz 39h,agains mov a,40h subb a,#90d jnc next nop nop ljmp localwarning ;·ÇµÍµãÆÀ²¦ºÅÒò NOP next: ;========================================================= mov a,37h mov b,#16d mul ab mov 3Ah,a againi000: MOV r6,3AH INC 3AH lcall RDIC16 mov P1,A lcall keydelay cjne A,#91h,againi000 ;ÊÇ#ºÅ¼üÂð ;=========ÓïÒô¼à²â=============================================================================================== mov 38h,#00h mov 39h,#064h mov 35h,#00h int00: mov 34h,#00h againi0:mov 30h,#0ah lcall delay10ms jnb P3.2,adcount inc 35h ljmp out adcount:inc 34h mov 35h,#00h djnz 39h,againi0 ljmp handfree1 ;------------------------------ out: mov a,34h subb a,#0eh jnc oncemore mov a,34h subb a,#5d jnc ackvoice mov a,34h subb a,#4d jnc oncemore mov a,34h subb a,#2d jc onceagain inc 38h mov a,38h CLR C subb a,#02h ;03h jz gohandfree ;¼ì²âµ½Ã¦Òô onceagain: mov a,35h clr c subb a,#45 jnc gohandfree oncemore: JNB P3.5,rept0 MOV 30H,#16H LCALL delay10ms JNB P3.5,rept0 MOV 30H,#16H LCALL delay10ms JNB P3.5,rept0 lcall handfree ljmp int1out rept0: ljmp int00 gohandfree: ljmp handfree1 ;=============================================================================================================== ackvoice: lcall beep MOV 40H,#00H mov 41h,#00H mov 39h,#0a0h againss: mov 30h,#0ah lcall delay10ms jnb P3.2,nextii inc 40h ;¼ì²â¸ßµçƽ mov 41h,#00h mov a,40h clr c subb a,#45d jnc playmusic ljmp oncemore1 nextii: ;¼ì²âµÍµçƽ mov 40h,#00h inc 41h mov a,41h clr c subb a,#3d ;3d 2d jc oncemore1 mov 30h,#15d ;100d 250d ; 15d lcall delay10ms jb P3.2,handfree1 ;¼ì²âµ½Ã¦Òô mov 41h,#00h oncemore1: JNB P3.5,rept1 MOV 30H,#16H LCALL delay10ms JNB P3.5,rept1 MOV 30H,#16H LCALL delay10ms JNB P3.5,rept1 lcall handfree ljmp int1out rept1: djnz 39h,againss ljmp handfree1 playmusic: nop clr P2.4 mov r2,#00h mov r0,#64h busyloop1: mov r1,#0ah busyloop: mov 30h,#1d lcall delay10ms jb P3.2,oncemore3 inc r2 mov a,r2 clr c subb a,#20d ;30d jc oncemore2 mov 30h,#25d ;06d lcall delay10ms jb P3.2,handfree1 oncemore3: mov r2,#00h oncemore2: JNB P3.5,rept2 MOV 30H,#16H LCALL delay10ms JNB P3.5,rept2 MOV 30H,#16H LCALL delay10ms JNB P3.5,rept2 lcall handfree ljmp int1out rept2: djnz r1,busyloop djnz r0,busyloop1 setb P2.4 handfree1: lcall handfree inc 37h ;37hÖдæ·Åµç»°¸öÊý mov a,37h cjne a,#phonenum,int1next ljmp int1out int1next: ljmp INTPT1 localwarning: setb P3.0 mov 39h,#60d localw1: mov r4,#0ah localw: mov 30h,#0ah lcall delay10ms JNB P3.5,repeat0 MOV 30H,#16H LCALL delay10ms JNB P3.5,repeat0 MOV 30H,#16H LCALL delay10ms JNB P3.5,repeat0 ljmp int1out repeat0: djnz r4,localw djnz 39h,localw1 clr P3.0 int1out: SETB EX1 setb et0 RETI handfree: lcall beeplong mov P1,#03h lcall keydelay setb P2.4 mov 30h,#45h lcall delay10ms ret ;========================= delay10ms: MOV R3,#30H delay2: mov R7,#32H delay1: DJNZ R7,delay1 DJNZ R3,delay2 DJNZ 30H,delay10ms RET keydelay: mov 30h,#0aH lcall delay10ms mov P1,#0ffh mov 30h,#0bH lcall delay10ms ret ;================================= WTIC16: mov R5,A LCALL START JC X49 MOV A,#0A0H LCALL WTBYTE JC X48 MOV A,R6 LCALL WTBYTE JC X48 MOV A,R5 ;»Ö¸´AÖÐÊý¾Ý LCALL WTBYTE JC X48 CLR C X48: LCALL STOP X49: RET RDIC16: LCALL START JC X47 MOV A,#0A0H LCALL WTBYTE JC X46 MOV A,R6 LCALL WTBYTE JC X46 LCALL START JC X47 MOV A,#0A1H LCALL WTBYTE JC X46 LCALL RDBYTE LCALL NACK CLR C X46: LCALL STOP X47: RET ;====================================================================== START: SETB SDA SETB SCL JNB SDA,X40 JNB SCL,X40 NOP CLR SDA NOP NOP NOP NOP NOP CLR SCL CLR CY LJMP X41 X40: SETB CY X41: RET STOP: CLR SDA NOP NOP SETB SCL NOP NOP NOP NOP NOP SETB SDA RET ;½«AдÈëE2PROM WTBYTE: MOV B,#08H X42: RLC A MOV SDA,C NOP SETB SCL NOP NOP NOP NOP CLR SCL DJNZ B,X42 SETB SDA NOP NOP SETB SCL NOP NOP NOP NOP MOV C,SDA CLR SCL RET RDBYTE: SETB SDA MOV R0,#08H X43: NOP NOP NOP SETB SCL NOP NOP MOV C,SDA RLC A CLR SCL DJNZ R0,X43 RET ACK: CLR SDA NOP NOP SETB SCL NOP NOP NOP NOP CLR SCL RET NACK: SETB SDA NOP NOP SETB SCL NOP NOP NOP NOP CLR SCL RET ;============================================== findkey: mov P0,#0ffh clr P2.0 clr P2.1 clr P2.2 mov P1,#0ffh nop nop mov a,P0 cjne a,#0ffh,check clr a ljmp scankey_out check: mov 30h,#1 lcall delay10ms mov a,P0 cjne a,#0ffh,scankey clr a ljmp scankey_out scankey: mov p0,#00h setb p2.0 setb p2.1 setb p2.2 nop nop mov a,P0 jb p2.0,scankey_0 mov dptr,#tab_0 ljmp scankey_end scankey_0: jb p2.1,scankey_1 mov dptr,#tab_1 ljmp scankey_end scankey_1: jb p2.2,scankey_out mov dptr,#tab_2 scankey_end: mov p0,#0ffh clr p2.0 clr p2.1 clr p2.2 nop nop mov a,p0 cpl a movc a,@a+dptr mov dptr,#Tabmain movc a,@a+dptr scankey_out: nop nop ret tab_0: db 00h,01h,04h,00h,07h,00h,00h,00h,0ah,00h,00h,00h,00h,00h,00h,00h db 0dh,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h db 10h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h db 00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h db 13h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h db 00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h db 00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h db 00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h db 16h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h tab_1: db 00h,02h,05h,00h,08h,00h,00h,00h,0bh,00h,00h,00h,00h,00h,00h,00h db 0eh,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h db 11h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h db 00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h db 14h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h db 00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h db 00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h db 00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h db 17h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h tab_2: db 00h,03h,06h,00h,09h,00h,00h,00h,0ch,00h,00h,00h,00h,00h,00h,00h db 0fh,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h db 12h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h db 00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h db 15h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h db 00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h db 00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h db 00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h db 18h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h Tabmain: db 000h,0a3h,0a2h,0a1h db 093h,092h,091h,083h db 082h,081h,073h,072h db 071h,063h,062h,061h db 053h,052h,051h,043h db 042h,000h,003h,002h db 001h Tab123: db 03,02,01,00,00,00,00,00,00,00,00,00,00,00,00,00 db 06,05,04,00,00,00,00,00,00,00,00,00,00,00,00,00 db 09,08,07,00,00,00,00,00,00,00,00,00,00,00,00,00 END