《单片机实验之DA转换实验(5页).doc》由会员分享,可在线阅读,更多相关《单片机实验之DA转换实验(5页).doc(5页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、-一、实验目的1、掌握单片机与DAC0832的接口设计方法。2、掌握Proteus软件与Keil软件的使用方法。二、设计要求 1、用Proteus软件画出电路原理图,在单片机的外部扩展片外三总线,并通过片外三总线与0832接口。 2、在单片机的外部扩展一个4个按键的键盘。 3、按下K0,产生连续方波信号。 4、按下K1,产生连续锯齿波信号。 5、按下K2,产生连续三角波信号。 6、按下K3,产生连续正弦波信号。 7、通过外接示波器观察波形。 三、 电路原理图六、 实验总结 通过本次实验电路的设计,掌握了基本的DA转换电路单缓冲的设计;参考电压的选择;0832的片选;集成运放芯片的选择及接线;尤
2、其是运放的反馈电阻,从而能够产生正常的波形。七、思考题 1、编程实现产生连续梯形波信号。 答:程序见程序清单。四、 实验程序流程框图和程序清单 ORG 0000H/*起始程序*/START: LJMP MAIN ORG 0100H/*监控程序*/MAIN: MOV SP, #60H LOOP: LCALL KEYSS LJMP LOOP KEYSS: LCALL KEY JB 20H.0 ,KEYAA JB 20H.1 ,KEYBB JB 20H.2 ,KEYCC JB 20H.3 ,KEYDD JB 20H.4 ,KEYEE RET/*键功能程序*/ KEYAA: MOV R2 ,#00H
3、;锯齿波 LOOP1: MOV DPTR ,#0000H MOV A ,R2 MOVX DPTR ,A DEC R2 LCALL KEYSS LJMP LOOP1 KEYBB: MOV DPTR ,#0000H ;矩形波 LOOP2: MOV R3 ,#0FFH MOV A ,R3 MOVX DPTR ,A LCALL DELAY LCALL KEYSS MOV R3 ,#00H MOV A ,R3 MOVX DPTR ,A LCALL DELAY LCALL KEYSS LJMP LOOP2 KEYCC: MOV R2 ,#00H ;三角波 MOV DPTR ,#0000HLOOP3: MO
4、V A ,R2 MOVX DPTR ,A INC R2 LCALL KEYSS CJNE R2 ,#0FFH ,LOOP3LOOP4: MOV A ,R2 MOVX DPTR ,A DEC R2 LCALL KEYSS CJNE R2 ,#00H ,LOOP4 LJMP LOOP3 KEYDD: MOV R2,#00H ;正弦波 LOOP5: MOV DPTR ,#SIN MOV A ,R2 MOVC A ,A+DPTR MOV DPTR ,#0000H MOVX DPTR ,A INC R2 LCALL KEYSS LJMP LOOP5KEYEE: MOV R2 ,#00H ;梯形波 MOV
5、 DPTR ,#0000HLOOP6: MOV A ,R2 MOVX DPTR ,A INC R2 LCALL KEYSS CJNE R2 ,#0FFH ,LOOP6 LCALL DELAY20msLOOP7: MOV A ,R2 MOVX DPTR ,A DEC R2 LCALL KEYSS CJNE R2 ,#00H ,LOOP7 LCALL DELAY20ms LJMP LOOP6/*常数表格*/ SIN: DB 07FH ,082H ,085H ,088H ,08BH ,08FH ,092H ,095H ,098H ,09BH ,09EH ,0A1H ,0A4H ,0A7H ,0AAH
6、 ,0ADHDB 0B0H ,0B3H ,0B6H ,0B8H ,0BBH ,0BEH ,0C1H ,0C3H ,0C6H ,0C8H ,0CBH ,0CDH ,0D0H ,0D2H ,0D5H ,0D7HDB 0D9H ,0DBH ,0DDH ,0E0H ,0E2H ,0E4H ,0E5H ,0E7H ,0E9H ,0EBH ,0ECH ,0EEH ,0EFH ,0F1H ,0F2H ,0F4HDB 0F5H ,0F6H ,0F7H ,0F8H ,0F9H ,0FAH ,0FBH ,0FBH ,0FCH ,0FDH ,0FDH ,0FEH ,0FEH ,0FEH ,0FEH ,0FEHDB
7、0FEH ,0FEH ,0FEH ,0FEH ,0FEH ,0FEH ,0FDH ,0FDH ,0FCH ,0FBH ,0FBH ,0FAH ,0F9H ,0F8H ,0F7H ,0F6HDB 0F5H ,0F4H ,0F2H ,0F1H ,0EFH ,0EEH ,0ECH ,0EBH ,0E9H ,0E7H ,0E5H ,0E4H ,0E2H ,0E0H ,0DDH ,0DBHDB 0D9H ,0D7H ,0D5H ,0D2H ,0D0H ,0CDH ,0CBH ,0C8H ,0C6H ,0C3H ,0C1H ,0BEH ,0BBH ,0B8H ,0B6H ,0B3HDB 0B0H ,0AD
8、H ,0AAH ,0A7H ,0A4H ,0A1H ,09EH ,09BH ,098H ,095H ,092H ,08FH ,08BH ,088H ,085H ,082HDB 07FH ,07CH ,079H ,076H ,073H ,06FH ,06CH ,069H ,066H ,063H ,060H ,05DH ,05AH ,057H ,054H ,051HDB 04EH ,04BH ,048H ,046H ,043H ,040H ,03DH ,03BH ,038H ,036H ,033H ,031H ,02EH ,02CH ,029H ,027HDB 025H ,023H ,021H ,
9、01EH ,01CH ,01AH ,019H ,017H ,015H ,013H ,012H ,010H ,00FH ,00DH ,00CH ,00AHDB 009H ,008H ,007H ,006H ,005H ,004H ,003H ,003H ,002H ,001H ,001H ,000H ,000H ,000H ,000H ,000HDB 000H ,000H ,000H ,000H ,000H ,000H ,001H ,001H ,002H ,003H ,003H ,004H ,005H ,006H ,007H ,008HDB 009H ,00AH ,00CH ,00DH ,00F
10、H ,010H ,012H ,013H ,015H ,017H ,019H ,01AH ,01CH ,01EH ,021H ,023HDB 025H ,027H ,029H ,02CH ,02EH ,031H ,033H ,036H ,038H ,03BH ,03DH ,040H ,043H ,046H ,048H ,04BHDB 04EH ,051H ,054H ,057H ,05AH ,05DH ,060H ,063H ,066H ,069H ,06CH ,06FH ,073H ,076H ,079H ,07CH/*键扫子程序*/ KEY:LCALL KEYCHULI JZ EXITLCA
11、LL DELAYLCALL KEYCHULI JZ EXIT MOV B ,20H KEYSF:LCALL KEYCHULI JZ KEY1 LJMP KEYSF KEY1:MOV 20H ,B EXIT: RETKEYCHULI:PUSH PSW CLR RS1 SETB RS0 MOV P1 ,#0FFH MOV A ,P1 CPL A MOV 20H ,A CLR RS1 CLR RS0 POP PSW RET /*延时子程序*/DELAY: MOV R7,#01H ;延时1msDL1: MOV R6,#8EHDL0: MOV R5,#02H DJNZ R5,$ DJNZ R6,DL0 DJNZ R7,DL1 RETDELAY20ms: MOV R6,#0D7H ;20msDL2: MOV R5,#2DH DJNZ R5,$ DJNZ R6,DL2 NOP NOP RET END 五、 实验结果(波形图)-第 5 页-