资源描述:
《实验十-D-A转换实验.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、实验十D/A转换实验一.实验要求利用DAC0832,编制程序产生锯齿波、三角波、正弦波。三种波轮流显示,用示波器观看。二.实验目的1.了解D/A转换的基本原理。2.了解D/A转换芯片0832的性能及编程方法。3.了解单片机系统中扩展D/A转换的基本方法。三.实验电路及连线四.实验说明D/A转换是把数字量转换成模拟量的变换,从本书D/A电路输出的是模拟电压信号。要实现实验要求,比较简单的方法是产生三个波形的表格,然后通过查表来实现波形显示。产生锯齿波和三角波的表格只需由数字量的增减来控制,同时要注意三角波要分
2、两段来产生。要产生正弦波,较简单的手段是造一张正弦数字量表。即查函数表得到的值转换成十六进制数填表。这样做虽然简单,但是费时费力,没有充分发挥单片机的能力。利用嵌入式定点、浮点运算子程序库可方便的完成正弦波的波形表生成工作。有关子程序库的详细使用方法请查阅《爱迪克仿真器51/98/96汇编运算子程序库使用手册》。注意汇编子程序的每个子程序名应为%开头的字符串,汇编程序在汇编时会自动将子程序链入。CALCL51/96禁止用户对此改写,否则会导致调用出错。D/A转换取值范围为一个周期,采样点越多,精度越高些。本
3、例采用的采样点为256点/周期。五.实验框图程序框图:-6-PDA.ASM主程序框图-6--6-STACKSSEGMENTSTACK;堆栈段DW128DUP(?);注意这里只有128个字节STACKSENDSDATASSEGMENT;数据段SHUJUDB67,70,73,76,80,83,86,88,91,94,97,100,102,105,107,109,111,113,115,117DB119,120,122,123,124,125,126,127,127,128,128,128,128,128,127
4、,127,126,125,124,123DB122,120,119,117,115,114,111,109,107,105,102,100,97,94,91,89,86,83,80,77DB73,70,67,64,61,58,55,52,49,46,43,40,37,34,31,29,26,23,21,19DB17,15,13,11,9,8,6,5,4,3,2,1,1,0,0,0,0,0,1,1DB2,3,4,5,6,7,9,11,12,14,16,19,21,23,26,28,31,34,36,39DB4
5、2,45,48,51,54,58,61,64DATASENDSCODESSEGMENT;代码段ASSUMECS:CODES,DS:DATASSTART:MOVAX,DATAS;初始化MOVDS,AXMOVAX,STACKSMOVSS,AXMOVAH,0MOVDX,0606HMOVAL,10000010BOUTDX,ALLP:MOVDX,0602HINAL,DXANDAL,03HCMPAL,0JZJUCMPAL,01HJZSANCMPAL,02HJZSINCEJMPLPJU:MOVDX,0600H;矩形波MO
6、VAL,0OUTDX,ALP1:CALLPINADDAL,BLOUTDX,AL-6-PUSHDXPUSHAXMOVDX,0602HINAL,DXANDAL,03HCMPAL,00HJNZLPPOPAXPOPDXJMPP1SAN:MOVDX,0600H;三角波MOVAL,0OUTDX,ALONE:CALLPINADDAL,BLOUTDX,ALPUSHAXPUSHDXMOVDX,0602HINAL,DXANDAL,03HCMPAL,01HJNZLPPOPDXPOPAXCMPAL,255JNZONETWO:CAL
7、LPINSUBAL,BLOUTDX,ALPUSHDXPUSHAXMOVDX,0602HINAL,DXANDAL,3CMPAL,1JNZLP-6-POPAXPOPDXCMPAL,0JNZTWOJMPONESINCE:MOVSI,0;正弦波MOVDX,0600HMOVBX,OFFSETSHUJUA31:MOVAL,[BX+SI]OUTDX,ALPUSHDXPUSHAXMOVDX,0602HINAL,DXANDAL,3CMPAL,2JNZLPPOPAXPOPDXCALLPINADDSI,BXCMPSI,128JN
8、ZA31JMPSINCEPINPROCNEARPUSHDXPUSHAXMOVDX,0602HINAL,DXMOVBL,ALANDBL,11111100BSHRBL,1SHRBL,1POPAXPOPDXRETPINENDPMOVAX,4C00H;退出程序INT21HCODESENDSENDSTART-6-