实验六-音乐门铃设计

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

电子科技大学中山学院学生实验报告院别:电子信息学院课程名称:微处理器实验班级:12电信A姓名:学号:实验名称:六、音乐门铃设计实验时间:2014年11月3日成绩:教师签名:批改时间:一、实验原理与目的通过本实验,理解掌握信号频率产生和按键的应用,继续熟悉单片机应用。1、蜂鸣器器件在不同频率信号的驱动下,会产生不同的声调,通过程序将不同的声调组合起来,就能够产生音乐。和应用,熟悉按键分支程序的设计。2、利用定时器可以产生不同频率的信号,用于驱动蜂鸣器。。3、可以将曲调预先编辑好,给程序查表用。二、实验设备1、PC机一台(已安装KeilµVision、STC_ISP等软件);2、ZSC-1单片机实验箱一台。三、实验内容与分析1、编写程序,设计按键触发的分支程序。2、编写程序,使单片机的P1.0口控制一个蜂鸣器产生音乐。3、结合以上两部分程序,编程实现音乐门铃的程序设计。SONG1EQU3EHSONG2EQU3DHKX0EQUP3.2KX1EQUP3.4KX2EQUP3.5KX3EQUP3.7L101EQUP0.0L102EQUP0.1L103EQUP0.2L104EQUP0.3ORG0000HJMPMAINORG000BHJMPINTT0ORG0100HMAIN:MOVSP,#60HMOVTMOD,#01HMOVSONG1,#00HMOVSONG2,#00HLCALLDELAY2宏定义LCALLDELAY2CHKKX0:JBKX0,CHKKX1;KX0未按下,则检测KX1LCALLDELAY2;软件延时JBKX0,CHKKX1;KX0未按下,则检测KX1CPLL101;KX0按下,则求反L101MOVDPTR,#TABLE_1JNBKX0,$;等待KX0松开SJMPSTART;跳转到主程序开头CHKKX1:JBKX1,CHKKX2LCALLDELAY2JBKX1,CHKKX2CPLL102MOVDPTR,#TABLE_2JNBKX1,$SJMPSTARTCHKKX2:JBKX2,CHKKX3LCALLDELAY2JBKX2,CHKKX3CPLL103MOVDPTR,#TABLE_3JNBKX2,$SJMPSTARTCHKKX3:JBKX3,MAINLCALLDELAY2JBKX3,MAINCPLL104MOVDPTR,#TABLE_4JNBKX3,$SJMPSTARTSTART:MOVSONG1,DPLMOVSONG2,DPHSETBEX1SETBET0SETBEASTART0:MOV30H,#00HNEXT:MOVA,30HMOVDPL,SONG1MOVDPH,SONG2MOVCA,@A+DPTRMOVR2,AJZENDDANLA,#0FH;高4位清0MOVR5,AMOVA,R2检测按键0检测按键1检测按键2检测按键3SWAPAANLA,#0FH;高4位清0JNZSINGCLRTR0JMPD1SING:DECAMOV22H,ARLAMOVDPTR,#TABLE1MOVCA,@A+DPTRMOVTH0,AMOV21H,AMOVA,22HRLAINCAMOVCA,@A+DPTRMOVTL0,AMOV20H,ASETBTR0D1:CALLDELAYINC30HJMPNEXTENDD:CLRTR0JMPMAININTT0:PUSHPSWPUSHACCMOVTL0,20HMOVTH0,21HCPLP1.0POPACCPOPPSWRETIDELAY:MOVR7,#12DELAY0:MOVR4,#187DELAY1:MOVR3,#248DJNZR3,$DJNZR4,DELAY1DJNZR7,DELAY0DJNZR5,DELAYRETDELAY2:MOVR7,#04DELAY3:MOVR4,#187DELAY4:MOVR3,#248DJNZR3,$外部中断0延时子程序DJNZR4,DELAY4DJNZR7,DELAY3RETTABLE_1:DB02H,11H,21H,32H,32H,22H,32H,21H,11H,0A1H,91H,92H,0D1H,91HDB0A2H,91H,81H,94H,11H,0A1H,91H,0A1HDB11H,93H,94H,03H,81H,11H,0A1H,91H,81H,92H,0A1H,91H,94H,08HDB03H,81H,32H,21H,11H,22H,31H,21H,21H,83HDB01H,11H,91H,0A1H,11H,61H,51H,11H,34H,01H,31H,21H,31H,48HDB23H,31H,32H,42H,38H,03H,11H,21H,52H,31HDB33H,31H,31H,41H,51H,61H,23H,21H,21H,41H,31H,21H,13H,0D1HDB21H,11H,0A1H,11H,91H,92H,91H,11H,0A1H,91HDB0A1H,31H,31H,22H,0A1H,11H,14H,01H,11H,21H,31H,63H,31HDB42H,51H,31H,22H,11H,21H,52H,31H,33H,31H,31H,41HDB51H,61H,23H,21H,21H,41H,31H,21H,13H,0D1H,0D1H,21H,11HDB0A1H,11H,91H,92H,91H,11H,0A1H,91HDB0A2H,41H,31H,22H,31H,21H,12H,12H,11H,11H,21H,31HDB63H,51H,32H,11H,21H,26H,11H,0A1H,18HDB00HTABLE_2:DB82H,01H,81H,94H,84H,0B4H,0A4H,04HDB82H,01H,81H,94H,84H,0C4H,0B4H,04HDB82H,01H,81H,0F4H,0D4H,0B4H,0A4H,94HDB0E2H,01H,0E1H,0D4H,0B4H,0C4H,0B4H,04HDB82H,01H,81H,94H,84H,0B4H,0A4H,04HDB82H,01H,81H,94H,84H,0C4H,0B4H,04HDB82H,01H,81H,0F4H,0D4H,0B4H,0A4H,94HDB0E2H,01H,0E1H,0D4H,0B4H,0C4H,0B4H,04HDB00HTABLE_3:DB66H,52H,36H,22H,12H,12H,22H,32H,98H,84H,82H,92H,14H,12H,22HDB32H,52H,22H,42H,38H,66H,52H,36H,22H,12H,22H,22H,32H,98HDB24H,22H,32H,54H,52H,32H,92H,12H,92H,82H,98H,66H,52H,36H,22HDB12H,12H,22H,32H,98H,84H,82H,92H,14H,12H,22H,32H,52H,22H,42H,38HDB66H,52H,36H,22H,12H,22H,22H,32H,98H,24H,22H,32H,54H,52H,32HDB22H,12H,92H,82H,98H,14H,24H,34H,44H,64H,0B4H,64H,32H,52HDB62H,0B2H,62H,52H,38H,24H,22H,32H,54H,52H,62H,52H,32H,32H,22H,38HDB64H,0B4H,64H,32H,52H,62H,0B2H,62H,52H,38H,22H,22H,22H,32H,52H,52HDB52H,62H,7FH,74H,04H,58H,6FHDB00HTABLE_4:DB02H,82H,16H,32H,54H,02H,52H,0A6H,32H,54H,02H,52HDB64H,74H,0B6H,64H,52H,5CH,32H,22H,16H,12H,14H,32H,22HDB16H,12H,14H,22H,32H,26H,12H,94H,22H,32H,2CHDB32H,52H,36H,22H,14H,54H,0ACH,92H,0A2HDB96H,0A2H,96H,82H,3CH,54H,36H,22H,14H,54HDB0ACH,92H,0A2H,16H,12H,14H,22H,32H,2CH,02H,82HDB16H,32H,56H,12H,0A6H,32H,56H,52H,66H,72H,0B6H,62H音乐1音乐4音乐3音乐2DB62H,52H,58H,32H,22H,16H,12H,14H,32H,22HDB16H,12H,14H,22H,32H,26H,92H,0A4H,12H,22H,1CHDB00TABLE1:DW64260,64400,64524,64580,64684,64777,64820,64898DW64968,65030,65058,65110,65157,65178,65217END验证:1.按键可切换音乐。2.可暂停继续。四、实验结论1.掌握了蜂鸣器件的驱动和应用,熟悉按键文件分程序设计。2.通过本实验,理解和掌握了信号频率产生的应用。响多久

1 / 5
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功