资源描述:
《单片机实验之DA转换实验.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、一、实验目的1、掌握单片机与DAC0832的接口设计方法。2、掌握Proteus软件与Keil软件的使用方法。二、设计要求1、用Proteus软件画出电路原理图,在单片机的外部扩展片外三总线,并通过片外三总线与0832接口。2、在单片机的外部扩展一个4个按键的键盘。3、按下K0,产生连续方波信号。4、按下K1,产生连续锯齿波信号。5、按下K2,产生连续三角波信号。6、按下K3,产生连续正弦波信号。7、通过外接示波器观察波形。三、电路原理图六、实验总结通过本次实验电路的设计,掌握了基本的DA转换电路单缓冲的设计;参考电压的选择;0832的片选;集成运放芯片的选择
2、及接线;尤其是运放的反馈电阻,从而能够产生正常的波形。七、思考题1、编程实现产生连续梯形波信号。答:程序见程序清单。四、实验程序流程框图和程序清单ORG0000H/***********起始程序***********/START:LJMPMAINORG0100H/***********监控程序***********/MAIN:MOVSP,#60HLOOP:LCALLKEYSSLJMPLOOPKEYSS:LCALLKEYJB20H.0,KEYAAJB20H.1,KEYBBJB20H.2,KEYCCJB20H.3,KEYDDJB20H.4,KEYEERET/***
3、********键功能程序*********/KEYAA:MOVR2,#00H;锯齿波LOOP1:MOVDPTR,#0000HMOVA,R2MOVX@DPTR,ADECR2LCALLKEYSSLJMPLOOP1KEYBB:MOVDPTR,#0000H;矩形波LOOP2:MOVR3,#0FFHMOVA,R3MOVX@DPTR,ALCALLDELAYLCALLKEYSSMOVR3,#00HMOVA,R3MOVX@DPTR,ALCALLDELAYLCALLKEYSSLJMPLOOP2KEYCC:MOVR2,#00H;三角波MOVDPTR,#0000HLOOP3:MO
4、VA,R2MOVX@DPTR,AINCR2LCALLKEYSSCJNER2,#0FFH,LOOP3LOOP4:MOVA,R2MOVX@DPTR,ADECR2LCALLKEYSSCJNER2,#00H,LOOP4LJMPLOOP3KEYDD:MOVR2,#00H;正弦波LOOP5:MOVDPTR,#SINMOVA,R2MOVCA,@A+DPTRMOVDPTR,#0000HMOVX@DPTR,AINCR2LCALLKEYSSLJMPLOOP5KEYEE:MOVR2,#00H;梯形波MOVDPTR,#0000HLOOP6:MOVA,R2MOVX@DPTR,AINCR
5、2LCALLKEYSSCJNER2,#0FFH,LOOP6LCALLDELAY20msLOOP7:MOVA,R2MOVX@DPTR,ADECR2LCALLKEYSSCJNER2,#00H,LOOP7LCALLDELAY20msLJMPLOOP6/*******常数表格***********/SIN:DB07FH,082H,085H,088H,08BH,08FH,092H,095H,098H,09BH,09EH,0A1H,0A4H,0A7H,0AAH,0ADHDB0B0H,0B3H,0B6H,0B8H,0BBH,0BEH,0C1H,0C3H,0C6H,0C8H,
6、0CBH,0CDH,0D0H,0D2H,0D5H,0D7HDB0D9H,0DBH,0DDH,0E0H,0E2H,0E4H,0E5H,0E7H,0E9H,0EBH,0ECH,0EEH,0EFH,0F1H,0F2H,0F4HDB0F5H,0F6H,0F7H,0F8H,0F9H,0FAH,0FBH,0FBH,0FCH,0FDH,0FDH,0FEH,0FEH,0FEH,0FEH,0FEHDB0FEH,0FEH,0FEH,0FEH,0FEH,0FEH,0FDH,0FDH,0FCH,0FBH,0FBH,0FAH,0F9H,0F8H,0F7H,0F6HDB0F5H,0F4H
7、,0F2H,0F1H,0EFH,0EEH,0ECH,0EBH,0E9H,0E7H,0E5H,0E4H,0E2H,0E0H,0DDH,0DBHDB0D9H,0D7H,0D5H,0D2H,0D0H,0CDH,0CBH,0C8H,0C6H,0C3H,0C1H,0BEH,0BBH,0B8H,0B6H,0B3HDB0B0H,0ADH,0AAH,0A7H,0A4H,0A1H,09EH,09BH,098H,095H,092H,08FH,08BH,088H,085H,082HDB07FH,07CH,079H,076H,073H,06FH,06CH,069H,066H,063H
8、,060H,05DH,05AH,057