| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 745 人关注过本帖
标题:新手学习单片机遇到的程序问题
只看楼主 加入收藏
qlq001
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-11-11
收藏
 问题点数:0 回复次数:0 
新手学习单片机遇到的程序问题
ORG 0000H
JMP START
ORG 000BH
JMP TIM0
ORG 001BH
JMP TIM1
START: MOV TMOD,#11H
MOV IE,#8AH
CLR TR0
CLR TR1
SETB PT0
CLR PT1
MOV P2,#0FFH
MOV A,P2
MOV P2,#0FFH
NOP
ANL A,#00H ;从第一首歌曲开始播放
MOV 40H,A
JB P3.0,$ ;P3.0为起始信号 片选信号
START0: MOV 30H,#00H
SAOMIAO: MOV A,40H
JNB P3.1,YY1 ;由按键控制直接跳转到音乐1
JNB P3.2,YY2 ;由按键控制直接跳转到音乐2
JNB P3.3,YY3 ;由按键控制直接跳转到音乐3
JNB P3.4,YY4 ;由按键控制直接跳转到音乐4
JNB P3.5,YY5 ; 由按键控制直接跳转到音乐5
MOV DPTR,#TABLE1 ;从音乐1开始演奏
JMP CON
YY1: ;MOV A,P3
;CJNE A,#0FDH,YY2
MOV DPTR,#TABLE1 ;演奏音乐1
JMP CON
YY2: ; MOV A,P3
;CJNE A,#0FBH,YY3
MOV DPTR,#TABLE2 ;演奏音乐2
JMP CON
YY3 : ;MOV A,P3
;CJNE A,#0F7H,YY4
MOV DPTR,#TABLE3 ;演奏音乐3
JMP CON
YY4: ;MOV A,P3;
CJNE A,#0EFH,YY5
MOV DPTR,#TABLE4 ;演奏音乐4
JMP CON
YY5: ;MOV A,P3;
CJNE A,#0DFH,BBF
MOV DPTR,#TABLE5 ;演奏音乐5
JUM CON
CON: SETB P2.0
MOV A,30H ;歌曲数据查表
MOVC A,@A+DPTR
MOV R2,A
JZ JIES
ANL A,#0FH ;算节拍
MOV R5,A
MOV A,R2
SWAP A
ANL A,#0FH ; 算出音调值
JNZ SING
CLR TR0
JMP D1
SING: MOV 50H,A
MOV A,40H
CJNE A,#00H,MODE1
MOV DPTR,#TABLE0 ;TABLE1
JMP CONT
MODE1: MOV DPTR,#TABLE00
CONT: MOV A,50H ;定T0,T1时器装值
DEC A
MOV 22H,A
RL A
MOVC A,@A+DPTR
MOV TH0,A
MOV TH1,A
MOV 21H,A
MOV A,22H
RL A
INC A
MOVC A,@A+DPTR
MOV TL0,A
MOV TL1,A
MOV 20H,A
SETB TR0 ;启动定时器T0
SETB TR1 ;启动定时器T1
D1: CALL YC ;调用延迟程序
INC 30H ;指向下一个歌曲数据
JMP SAOMIAO
JIES: CLR TR0
JMP START0
TIM0: PUSH ACC ;定时器T0中断程序
PUSH PSW
MOV TL0,20H
MOV TH0,21H
CPL P2.0
CLR TR0
JSYC: SETB PT0
CLR PT1
POP PSW
POP ACC
RETI
TIM1: PUSH ACC ;定时器T0中断程序
PUSH PSW
MOV TL1,20H
MOV TH1,21H
JMP LSD ;跳转到流水灯程序
JSLSD: SETB PT0
CLR PT1
POP PSW
POP ACC
RETI
LSD: NOP
NOP
MOV A,#0FFH ;送数据初值
MOV P1,A
MOV A,#00FEH ;数据送P1口点亮发光二极管
ACALL YC1 ;延时
MOV 24H,#07H ;设置左移7次
LOOP: RL A ;左移一位
MOV P1,A ;数据送P1口点亮发光二极管
ACALL YC1 ;延时
JSYC1: DJNZ 24H,LOOP ;24H单元是否为0,不为0转LOOP继续执行
AJMP JSLSD ;返回主程循环执
YC1: MOV 27H,#01H ;流水灯延迟程序
DL1: MOV 26H,#8EH
DL0: MOV 25H,#02H
DJNZ 25H,$
DJNZ 26H,DL0
DJNZ 27H,DL1基于单片机的音乐流水灯设计
AJMP JSYC11
YC: MOV R7,#02 ;音乐延迟程序
D2: MOV R4,#125
D3: MOV R3,#248
DJNZ R3,$
DJNZ R4,D3
DJNZ R7,D2
DJNZ R5,YC
AJMP JSYC
TABLE0:
DW 64260,64400,64524,64580
DW 64684,64777,64820,64898
DW 64968,65030,65058,65110
DW 65157,65178,65217
TABLE00:
DW 64260,64400,64524,64580
DW 64684,64777,64820,64898
DW 64968,65030,65058,65110
DW 65157,65178,65217
TABLE1: ;生日快乐
DB 82H,01H,81H,94H,84H
DB 0B4H,0A4H,04H
DB 82H,01H,81H,94H,84H
DB 0C4H,0B4H,04H
DB 82H,01H,81H,0F4H,0D4H
DB 0B4H,0A4H,94H
DB 0E2H,01H,0E1H,0D4H,0B4H
DB 0C4H,0B4H,04H
DB 82H,01H,81H,94H,84H
DB 0B4H,0A4H,04H
DB 82H,01H,81H,94H,84H
DB 0C4H,0B4H,04H
DB 82H,01H,81H,0F4H,0D4H
DB 0B4H,0A4H,94H
DB 0E2H,01H,0E1H,0D4H,0B4H
DB 0C4H,0B4H,04H
TABLE2: ;康定情歌
DB 34H,52H,63H,62H,52H,64H,32H,28H
DB 33H,32H,52H,63H,62H,52H,63H,32H,37H
DB 34H,52H,63H,62H,52H,63H,32H,28H
DB 53H,52H,32H,22H,32H,22H,12H,24H,98H
DB 93H,22H,28H,53H,32H,38H,22H,12H,98H, 53H,52H,32H,22H,32H,22H,12H,23H,98H
DB 93H,22H,28H,53H,32H,38H,23H,12H,98H, 53H,52H,32H,22H,32H,22H,12H,22H,65H 37
基于单片机的音乐流水灯设计
TABLE3: ;精忠报国
DB 66H,52H,36H,22H,12H,12H,22H,32H,98H,84H,82H,92H,14H,12H,22H
DB 32H,52H,22H,42H,38H,66H,52H,36H,22H,12H,22H,22H,32H,98H
DB 24H,22H,32H,54H,52H,32H,92H,12H,92H,82H,98H,66H,52H,36H,22H
DB 12H,12H,22H,32H,98H,84H,82H,92H,14H,12H,22H,32H,52H,22H,42H,38H
DB 66H,52H,36H,22H,12H,22H,22H,32H,98H,24H,22H,32H,54H,52H,32H
DB 22H,12H,92H,82H,98H,14H,24H,34H,44H,64H,0B4H,64H,32H,52H
DB 62H,0B2H,62H,52H,38H,24H,22H,32H,54H,52H,62H,52H,32H,32H,22H,38H
DB 64H,0B4H,64H,32H,52H,62H,0B2H,62H,52H,38H,22H,22H,22H,32H,52H,52H
DB 52H,62H,7FH,74H,04H,58H,6FH
TABLE4: ;同一首歌
DB 88h,14h,24h,36H,42H,34H,14H,28H,14H,94H
DB 1fH,88H,14H,24H,34H,32H,42H,54H,14H
DB 46H,32H,54H,22H,32H,32H,22H,2CH,38H,54H,74H
DB 76H,62H,68H,54H,52H,62H,74H,62H,52H,3fH
DB 46H,42H,54H,64H,54H,42H,32H,28H,0a4H,0a2H
DB 92H,84H,94H,1fH,0b8H,68H,46H,52H,68H
DB 74H,72H,72H,74H,62H,52H,3fH,0b8H,68H
DB 46H,52H,68H,64H,62H,62H,64H,42H,32H,2fH
DB 58H,14H,24H,36H,42H,34H,12H,12H,26H,22H,24H,22H,12H
DB 94H,9cH,0a8H,0a6H,92H,84H,64H,54H,22H,22H,46H,42H,44H,32H,22H,5fH
TABLE5: ;大海
DB 82H,92H,12H,14H,12H,14H,92H,82H,12H,14H,22H,14H,92H,12H,22H,24H
DB 22H,24H,12H,92H,22H,24H,32H,24H,32H,52H,62H,54H,52H,64H,52H,32H
DB 22H,32H,22H,12H,94H,82H,92H,12H,14H,12H,14H,94H,1cH
DB 82H,92H,12H,14H,12H,14H,92H,82H,12H,14H,22H,14H,92H,12H,22H,24H
DB 22H,24H,12H,92H,22H,24H,32H,24H,32H,52H,62H,54H,52H,64H,52H,32H
DB 22H,32H,22H,12H,94H,82H,92H,12H,14H,12H,14H,22H,12H,1cH,32H,52H
DB 62H,64H,62H,64H,0b2H,62H,52H,54H,62H,54H,32H,22H
DB 12H,14H,12H,14H,24H,3cH,32H,22H,12H,14H,12H,14H,0b2H,62H,52H,54H,62H,54H,32H,52H
DB 66H,0b2H,0b4H,62H,52H,5cH,32H,52H,62H,64H,62H,64H,0b2H,62H,52H,54H
DB 62H,54H,32H,22H,12H,14H,12H,14H,54H,3cH,32H,22H,12H,14H,12H,14H,22H,32H
DB 52H,54H,32H,54H,32H,52H,6fH,04H,02H,92H,32H,24H,12H,1fH
DB 00
END

编译老是提示语法啥的错误,不知如何修改 求高手传授

搜索更多相关主题的帖子: 歌曲 音乐 按键 
2011-11-11 18:52
快速回复:新手学习单片机遇到的程序问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016656 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved