1、(完整word)实验六 音乐门铃设计电子科技大学中山学院学生实验报告院别:电子信息学院 课程名称:微处理器实验 班级:12电信A 姓名: 学号: 实验名称:六、音乐门铃设计 实验时间:2014 年11月3日成绩: 教师签名: 批改时间:一、 实验原理与目的 通过本实验,理解掌握信号频率产生和按键的应用,继续熟悉单片机应用。1、 蜂鸣器器件在不同频率信号的驱动下,会产生不同的声调,通过程序将不同的声调组 合起来, 就能够产生音乐。和应用,熟悉按键分支程序的设计。2、利用定时器可以产生不同频率的信号,用于驱动蜂鸣器。.3、可以将曲调预先编辑好,给程序查表用。二、实验设备1、PC机一台(已安装Kei
2、l Vision、STC_ISP等软件);2、ZSC-1单片机实验箱一台。三、实验内容与分析 1、编写程序,设计按键触发的分支程序.2、编写程序,使单片机的P1.0口控制一个蜂鸣器产生音乐。3、结合以上两部分程序,编程实现音乐门铃的程序设计。 SONG1 EQU 3EHSONG2 EQU 3DH KX0 EQU P3。2宏定义 KX1 EQUP3。4 KX2 EQUP3。5 KX3 EQUP3。7 L101EQUP0。0 L102EQUP0.1 L103EQUP0.2 L104EQUP0。3ORG 0000H JMP MAIN ORG000BH JMP INTT0 ORG0100HMAIN:
3、MOV SP,#60H MOV TMOD,01H MOVSONG1,#00HMOVSONG2,#00HLCALLDELAY2 LCALLDELAY2CHKKX0: JBKX0,CHKKX1 ;KX0未按下,则检测KX1 检测按键0 LCALLDELAY2 ;软件延时 JBKX0,CHKKX1 ;KX0未按下,则检测KX1 CPLL101 ;KX0按下,则求反L101MOVDPTR,#TABLE_1 JNB KX0,$ ;等待KX0松开 SJMP START ;跳转到主程序开头CHKKX1: JBKX1,CHKKX2 LCALLDELAY2检测按键1 JBKX1,CHKKX2 CPLL102MO
4、VDPTR,#TABLE_2 JNBKX1,$ SJMPSTART CHKKX2: JBKX2,CHKKX3 LCALLDELAY2检测按键2 JBKX2,CHKKX3 CPLL103MOVDPTR,#TABLE_3 JNBKX2, SJMPSTART CHKKX3: JBKX3,MAIN LCALLDELAY2检测按键3 JBKX3,MAIN CPLL104MOVDPTR,#TABLE_4 JNBKX3,$ SJMPSTART START:MOVSONG1,DPLMOVSONG2,DPHSETBEX1 SETBET0 SETBEA START0: MOV30H,00HNEXT:MOVA,30
5、HMOVDPL,SONG1MOVDPH,SONG2 MOVCA,A+DPTR MOVR2,A JZENDD ANLA,#0FH ;高4位清0 MOVR5,A MOVA,R2 SWAPA ANLA,0FH;高4位清0 JNZSING CLRTR0 JMPD1SING: DECA MOV22H,A RLA MOVDPTR,#TABLE1 MOVCA,A+DPTR MOVTH0,A MOV21H,A MOVA,22H RLA INCA MOVCA,A+DPTR MOVTL0,A MOV20H,A SETBTR0D1: CALLDELAY INC30H JMPNEXTENDD: CLRTR0 JMPM
6、AININTT0: PUSHPSW PUSHACC外部中断0 MOVTL0,20H MOVTH0,21H CPLP1。0 POPACC POPPSW RETI DELAY: MOVR7,#12DELAY0: MOVR4,187DELAY1:MOVR3,248延时子程序 DJNZR3, DJNZR4,DELAY1 DJNZR7,DELAY0 DJNZR5,DELAY RETDELAY2: MOVR7,04DELAY3: MOVR4,187DELAY4: MOVR3,#248 DJNZR3, DJNZR4,DELAY4 DJNZR7,DELAY3 RETTABLE_1:DB 02H,11H,21H
7、,32H,32H,22H,32H,21H,11H,0A1H,91H,92H,0D1H,91HDB 0A2H,91H,81H,94H,11H,0A1H,91H,0A1HDB 11H,93H,94H,03H,81H,11H,0A1H,91H,81H,92H,0A1H,91H,94H,08HDB 03H,81H,32H,21H,11H,22H,31H,21H,21H,83HDB 01H,11H,91H,0A1H,11H,61H,51H,11H,34H,01H,31H,21H,31H,48HDB 23H,31H,32H,42H,38H,03H,11H,21H,52H,31H音乐1DB 33H,31H,
8、31H,41H,51H,61H,23H,21H,21H,41H,31H,21H,13H,0D1HDB 21H,11H,0A1H,11H,91H,92H,91H,11H,0A1H,91HDB 0A1H,31H,31H,22H,0A1H,11H,14H,01H,11H,21H,31H,63H,31HDB 42H,51H,31H,22H,11H,21H,52H,31H,33H,31H,31H,41HDB 51H,61H,23H,21H,21H,41H,31H,21H,13H,0D1H,0D1H,21H,11HDB 0A1H,11H,91H,92H,91H,11H,0A1H,91HDB 0A2H,41
9、H,31H,22H,31H,21H,12H,12H,11H,11H,21H,31HDB 63H,51H,32H,11H,21H,26H,11H,0A1H,18HDB 00HTABLE_2:DB 82H,01H,81H,94H,84H,0B4H,0A4H,04H DB 82H,01H,81H,94H,84H,0C4H,0B4H,04H DB 82H,01H,81H,0F4H,0D4H,0B4H,0A4H,94H音乐2 DB 0E2H,01H,0E1H,0D4H,0B4H,0C4H,0B4H,04H DB 82H,01H,81H,94H,84H,0B4H,0A4H,04H DB 82H,01H,8
10、1H,94H,84H,0C4H,0B4H,04H DB 82H,01H,81H,0F4H,0D4H,0B4H,0A4H,94H DB 0E2H,01H,0E1H,0D4H,0B4H,0C4H,0B4H,04HDB 00HTABLE_3: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,2
11、2H 音乐3DB 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
12、,52H,38H,22H,22H,22H,32H,52H,52H DB 52H,62H,7FH,74H,04H,58H,6FH DB 00HTABLE_4:DB 02H,82H,16H,32H,54H,02H,52H,0A6H,32H,54H,02H,52HDB 64H,74H,0B6H,64H,52H,5CH,32H,22H,16H,12H,14H,32H,22H音乐4DB 16H,12H,14H,22H,32H,26H,12H,94H,22H,32H,2CH DB 32H,52H,36H,22H,14H,54H,0ACH,92H,0A2H DB 96H,0A2H,96H,82H,3CH,5
13、4H,36H,22H,14H,54H DB 0ACH,92H,0A2H,16H,12H,14H,22H,32H,2CH,02H,82H DB 16H,32H,56H,12H,0A6H,32H,56H,52H,66H,72H,0B6H,62H DB 62H,52H,58H,32H,22H,16H,12H,14H,32H,22HDB 16H,12H,14H,22H,32H,26H,92H,0A4H,12H,22H,1CH DB 00响多久TABLE1: DW 64260,64400,64524,64580,64684,64777,64820,64898 DW 64968,65030,65058,65110,65157,65178,65217END验证:1. 按键可切换音乐。2. 可暂停继续。四、 实验结论1. 掌握了蜂鸣器件的驱动和应用,熟悉按键文件分程序设计。2. 通过本实验,理解和掌握了信号频率产生的应用.