实验五 D/A转换实验
1. 实验内容
基础部分
编写程序,产生周期的锯齿波、矩形波、三角波和阶梯波,经 D/A 转换,显示在软件模拟示波器上。
要求:每种波形的周期数、阶梯波的阶梯数可通过参数设置。
扩展部分
在软件模拟示波器上显示锯齿波、矩形波、三角波和阶梯波,并使用单脉冲开关KK1在四种波形间进行切换。
2. 实验原理
3. 连线
KK1 连接 MIR6
4. 实验代码
基础部分:
(见扩展部分)
扩展部分:
DAC0832 EQU 0600H
DATA SEGMENT
SIGN DB 00H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, 0000H
MOV DS, AX
LEA AX, MIR6
MOV SI, 38H
MOV [ES:SI], AX
MOV AX, CS
MOV SI, 3AH
MOV [ES:SI], AX
CLI
MOV AL, 11H
OUT 20H, AL
MOV AL, 08H
OUT 21H, AL
MOV AL, 04H
OUT 21H, AL
MOV AL, 07H
OUT 21H, AL
MOV AL, 2FH
OUT 21H, AL
STI
MAIN:
CMP SIGN, 0
JZ SAW
CMP SIGN, 1
JZ REC
CMP SIGN, 2
JZ TRI
CMP SIGN, 3
JZ STA_CON
JMP MAIN
SAW:
CMP SIGN, 0
JNE MAIN
MOV DX, DAC0832
MOV AL, 00H
SA1:
OUT DX, AL
CALL DELAY1
CMP AL, 0FFH
JE SA2
INC AL
JMP SA1
SA2:
JMP SAW
REC:
CMP SIGN,1
JNE MAIN
MOV DX, DAC0832
MOV AL, 00H
OUT DX, AL
CALL DELAY2
MOV AL, 0FFH
OUT DX, AL
CALL DELAY2
JMP REC
STA_CON:
JMP STA
STA_RET:
JMP MAIN
TRI:
T1:
CMP SIGN, 2
JNE MAIN
MOV DX, DAC0832
OUT DX, AL
CALL DELAY1
CMP AL, 0FFH
JE T2
INC AL
JMP T1
T2:
MOV DX, DAC0832
OUT DX, AL
CALL DELAY1
CMP AL, 00H
JE T3
DEC AL
JMP T2
T3:
JMP TRI
STA:
MOV AX, 0FEH
MOV BL, 05H
DIV BL
MOV BL, AL
MOV BH, 00H
ST1:
CMP SIGN,3
JNE STA_RET
MOV AX, 0000H
ST2:
MOV DX, DAC0832
OUT DX, AL
CMP AX, 00FFH
JAE ST3
CALL DELAY2
ADD AX, BX
JMP ST2
ST3:
JMP STA
MIR6:
INC SIGN
CMP SIGN, 4
JNZ QUIT
MOV SIGN, 0
QUIT:
IRET
DELAY1:
PUSH CX
MOV CX, 01FFH
D1: PUSH AX
POP AX
LOOP D1
POP CX
RET
DELAY2:
PUSH CX
MOV CX, 0FFFFH
D2: PUSH AX
POP AX
LOOP D2
POP CX
RET
CODE ENDS
END START