资源描述:
《数字频率发生器的设计》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、目录一、设计要求:2二、硬件实验设计方案21.硬件组成22.电路图23.简单工作原理2三、软件设计31.流程图:32.程序组成结构33.参考程序代码4四、系统设计的调试方法12五、设计分析总结14六、参考文献1515设计要求:1.设计一个数字频率发生器,要求产生方波信号。2.能够显示发送信号频率,该信号显示为XXXX四位(或010~999HZ).3.频率范围可调:10~999HZ或10~1000HZ.一、硬件实验设计方案1.硬件组成MCS-51单片机、键盘、LED显示器、鼠标、辅助机箱2.电路图3.简单工作原理主要利用所学的定时器的
2、原理控制方波信号的输出,使其产生需要的频率,并在显示器上将其显示出来。15软件设计1.流程图:2.程序组成结构151.参考程序代码代码如下:ORG4000HSJMPMAINORG400BHLJMPDSQ50MSDISPLAYEQU0170HMAIN:CLRP1.7MOVSP,#6FHMOVTH0,#0F2HMOVTL0,#0FBHMOVTMOD,#01HMOVIP,#02HMOVIE,#82HSETBTR0MOV7EH,#14HMOV7DH,#14HMOV78H,#14HMOV77H,#14HLCALLDISPLAYMOV62H,#
3、00HMOV63H,#0AH15KS:MOVA,60HANLA,#0FHMOV7BH,AMOVA,60HANLA,#0F0HSWAPAMOV7CH,AMOVA,61HANLA,#0FHMOV79H,AMOVA,61HANLA,#0F0HSWAPAMOV7AH,AJP:JBP1.0,JP1LCALLYSJBP1.0,JP1MOVA,63HADDA,#1MOV63H,AMOVA,62HADDCA,#015MOV62H,AJP1:LCALLDISPLAYMOVR2,62HMOVR3,63HLCALLBTODMOV60H,R5MOV61H,
4、R6MOVR5,#15HMOVR4,#16HMOVR3,#05HMOVR2,#00HMOVR6,#62HMOVR7,#63HLCALLNDIVICLRCMOVA,#00HSUBBA,R5MOV65H,AMOVA,#00HSUBBA,R4MOV64H,ALJMPKS15DSQ50MS:MOVTL0,65HMOVTH0,64HCPLP1.7PTFOR:RETIYS:MOVR7,#89HYS1:MOVR6,#0F8HYS2:NOPDJNZR6,YS2DJNZR7,YS1RETBCDZHB:MOVR3,#0MOVA,@R0MOVR4,AID
5、TKL:MOVA,R4MOVB,#10MULABMOVR4,AMOVA,#10XCHA,BXCHA,R3MUL,ABADDA,R315XCHA,R4INCR0ADDA,@R0XCHA,R4ADDCA,#0MOVR3,ADJNZR2,IDTLRETBTOD:CLRAMOVR4,AMOVR5,AMOVR6,AMOVR7,#16BTOD1:CLRCMOVA,R3RLCAMOVR3,AMOVA,R2RLCAMOVR2,AMOVA,R6ADDCA,R615DAAMOVR6,AMOVA,R5ADDCA,R5DAAMOVR5,AMOVA,R4AD
6、DCA,R4DAAMOVR4,ADJNZR7,BTOT1RETNDIV1:MOVA,R3CLRCSUBBA,R7MOVA,R2SUBBA,R6JNCNDIV5MOVR0,#16NDIV2:CLRCMOVA,R5RLCA15MOVR5,AMOVA,R4RLCAMOVR4,AMOVA,R3RLCAMOVR3,AXCHA,R2RLCAXCHA,R2MOVF0,CCLRCSUBBA,R7MOVR1,AMOVA,R2SUBBA,R6JBF0,NDIV3JCNDIV4NDIV3:MOVR2,AMOVA,R1MOVR3,AINCR515NDIC4
7、:DJNZR0,NDIV2CLRF0RETNSIV5:SETBF0RET15系统设计的调试方法调试过程:1、主程序:首先让显示器显示为0010(HZ)用定时器软件t定时=50ms,则t=2t定时=1000mms=0.1s则其频率为f=10HZ调试修改:t定时=5ms,则t=2t定时=10ms=0.01s则其频率为f=100HZt定时=0.5ms,则t=2t定时=1ms=0.001s则其频率为f=1000HZ定时器的时间常数为X(16位)为别为:THO(高8位),TLO(低8位)2、选择定时器0,方式1:t定时=(216-X)12/f
8、osc,fosc=8MHZ=8×106设定频率值求f求T求t定时则t定时=T/2=1/2f代入上式t定时=(216-X)12/fosc,得1/2f=(216-X)12/fosc则X=216-fosc/2f×12=216-8×106/2