完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
本帖最后由 cccdddfff 于 2012-6-19 15:38 编辑
ORG 0000H LJMP MAIN ORG 0003H LJMP BREAK0 MAIN: SETB IT0 ;设置中断 SETB EX0 MOV TMOD,#01H ;设置定时器0方式1 MOV TH0,#0D8H ;初D8F0定时10ms MOV TL0,#0F0H CLR A MOV R0,#0H MOV R1,#0H MOV R4,#0H MOV R5,#0H CALL KEY MOV R0,A MOV A,#0E0H ;输出显示十位 MOV P2,A MOV A,R0 MOV DPTR,#TAB MOVC A,@A+DPTR MOV P1,A CALL KEY MOV R1,A ;输入个位 SETB EA ;设置中断允许 WAIT: CALL SHOW ;等待开始 JMP WAIT BEGIN: SETB EA ;设置中断允许 JP0: CALL SHOW DEC R5 CJNE R5,#0FFH,JP0 DEC R4 MOV R5,#9H CJNE R4,#0FFH,JP0 DEC R1 MOV R4,#5H CJNE R1,#0FFH,JP0 DEC R0 MOV R1,#9H CJNE R0,#0FFH,JP0 JMP BEEP SHOW: MOV R3,#25H LOOP: MOV R2,#0D0H ;设置分输出个位 MOV P2,R2 MOV A,R1 ;取分个位数值 MOV DPTR,#TAB MOVC A,@A+DPTR MOV P1,A ;输出 CALL DY12 MOV R2,#0E0H ;设置输出分十位 MOV P2,R2 MOV A,R0 MOV DPTR,#TAB MOVC A,@A+DPTR MOV P1,A CALL DY12 MOV R2,#70H ;设置输出秒个位 MOV P2,R2 MOV A,R5 MOV DPTR,#TAB MOVC A,@A+DPTR MOV P1,A CALL DY12 MOV R2,#0B0H ;设置输出秒十位 MOV P2,R2 MOV A,R4 MOV DPTR,#TAB MOVC A,@A+DPTR MOV P1,A CALL DY12 DJNZ R3,LOOP RET BREAK0: SETB EA CALL KEY0 ;中断程序 SETB EA RET STOP: SETB C MOV P3.7,C SETB EA JMP WAIT BEEP: SETB EA CLR C MOV P3.7,C MOV R1,#2H MOV R0,#0H MOV R4,#0H MOV R5,#0H JP1: CALL SHOW SETB EA DEC R5 CJNE R5,#0FFH,JP1 DEC R4 MOV R5,#9H CJNE R4,#0FFH,JP1 DEC R1 MOV R4,#5H CJNE R1,#0FFH,JP1 DEC R0 MOV R1,#9H CJNE R0,#0FFH,JP1 JMP MAIN KEY0: CLR A SETB RS1 ACALL KEY2 ;处理特殊键 CJNE A,#0AH,KK CLR RS1 JMP BEGIN KK: CJNE A,#0BH,KEND CLR RS1 AJMP STOP KEY2: ACALL KS1 JNZ LK11 AJMP KEND LK11: ACALL DY12 ACALL KS1 JNZ LK2 AJMP KEY2 KEY: CLR A SETB RS1 ACALL KEY1 ;处理特殊键 CJNE A,#0AH,KKK CLR RS1 JMP BEGIN KKK: CJNE A,#0BH,KEND CLR RS1 AJMP STOP KEY1: ACALL KS1 ;键盘程序 JNZ LK1 AJMP KEY1 LK1: ACALL DY12 ACALL KS1 JNZ LK2 AJMP KEY1 LK2: MOV R2,#0FEH MOV R4,#00H LK4: MOV A,R2 MOV P2,A MOV A,P0 JB ACC.0,LONE MOV A,#00H AJMP LKP LONE: JB ACC.1,LTWO MOV A,#04H AJMP LKP LTWO: JB ACC.2,LTHR MOV A,#08H AJMP LKP LTHR: JB ACC.3,NEXT MOV A,#0CH LKP: ADD A,R4 PUSH ACC LK3: ACALL KS1 JNZ LK3 POP ACC KEND: CLR RS1 RET NEXT: INC R4 MOV A,R2 JNB ACC.7,KND RL A MOV R2,A AJMP LK4 KND: AJMP KEY1 KS1: MOV A,#0E0H MOV P2,A MOV A,P0 CPL A ANL A,#0FH RET DY12: MOV R7,#25 DY1: MOV R6,#200 DY2: DJNZ R6,DY2 DJNZ R7,DY1 RET DY10: MOV TH0,#0D8H ;重装初值D8F0定时10ms MOV TL0,#0F0H SETB TR0 ;启动定时器 DYWAIT: JBC TF0,DYEND JMP DYWAIT DYEND: CLR TR0 RET TAB: DB 3FH,06H,5BH,4FH,66H,6DH DB 7DH,07H,7FH,6FH JMPTAB: JMP BEGIN JMP STOP END LO EQU 30H SI EQU 31H TC EQU 32H ORG 0000H JMP BEGIN ORG 000BH JMP TOINT BEGIN: MOV SP, #60H MOV TMOD, #00H MOV IE, #82H WAIT : MOV C,P1.4 JC RUN JMP WAIT RUN : ACALL SOUNDON ACALL PLAYSONG ACALL SOUNDOFF JMP WAIT PLAY : MOV C,P1.4 JC PLAY0 ACALL SOUNDOFF JMP WAIT PLAY0: ACALL LOADVALUE L1 : MOV R5, #30 ACALL DELAY DJNZ R3, L1 ACALL SOUNDOFF MOV R5, #3 ACALL DELAY ACALL SOUNDON RET PLAYSONG: MOV TC, #0 X0: MOV DPTR, #SONG MOV A, TC MOVC A, @A+DPTR MOV R4, A CJNE A, #0FFH, X1 RET X1: MOV DPTR, #LEN MOV A, TC MOVC A, @A+DPTR MOV R3, A ACALL PLAY INC TC JMP X0 RET SOUNDON: SETB TR0 RET SOUNDOFF: CLR TR0 RET LOADVALUE: MOV DPTR, #SILIST MOV A,R4 MOVC A,@A+DPTR MOV SI,A MOV DPTR, #LOLIST MOV A, R4 MOVC A, @A+DPTR MOV LO, A RET TOINT : MOV TL0, LO MOV TH0, SI CPL P3.4 REti DELAY : MOV R6, #35 D1 : MOV R7, #70 DJNZ R7, $ DJNZ R6, D1 DJNZ R5, DELAY RET SILIST: DB 196,202,208,211,216,220,224 DB 226,229,232,233,236,238,240 DB 241,242,244,244,246,247,248 LOLIST: DB 4,28,21,7,5,16,12 DB 4,13,10,20,3,8,6 SONG: DB 12,15,13,12,12,10,12,13,15,12,12,13,12,10,9,9,10,12,10,9,10,8 DB 12,15,13,15,12,10,12,9,10,12,10,12,13,15,12,13,12,10,12,8,10,9 DB 10,9,8,9,10,13,12,10,12,13,12,15,13,12,10,12,9,12,9,10,9,8,0F FH LEN: DB 2,1,1,2,2,1,1,1,1,2,2,2,1,1,2,2,2,1,1,1,1,3 DB 2,2,1,1,2,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,2 DB 1,1,1,1,2,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,2,0FFH END 音乐定时器 图在附件 http://pan.baidu.com/netdisk/singlepublic?fid=411529_615487490 或者网盘下载
|
|
相关推荐
1个回答
|
|
汇编语言 让人蛋疼
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
串口发送中断中对发送I/O口定义为GPIO输出,出现发送数据不完整,缺少2个字节,求解答
1168 浏览 3 评论
728 浏览 0 评论
【xG24 Matter开发套件试用体验】10-Bluetooth示例1
836 浏览 0 评论
919 浏览 0 评论
【xG24 Matter开发套件试用体验】power specification电源规格参数配置
747 浏览 0 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
10859 浏览 31 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-8-26 01:22 , Processed in 0.488446 second(s), Total 78, Slave 55 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191