Skip to content

[微机实验/TD-PITE] D/A 转换实验+选做实验

Published: at 16:25

ToC

实验内容

编程画出波形,通过 D/A 转换器转换为模拟信号,通过软件示波器观察波形。

实验接线

代码

;; DAC0832 IOY0
;; BASE OFFSET: 0600H
A0832 EQU 0600H
SSEG SEGMENT STACK
DW 0,0,0,0
SSEG ENDS
CODE SEGMENT
ASSUME CS:CODE, SS:SSEG
START:
MOV DX, A0832
;; --------- SAW START ---------
MOV CX, 0AH
SAW:
MOV AL, 00H
JC1:
OUT DX, AL
CALL DELAY_SHORT
CMP AL, 0FFH
JE JC2
INC AL
JMP JC1
JC2:
LOOP SAW
;; ---------- SAW END ----------
;; --------- RECT START ---------
MOV CX, 02H
RECT:
MOV AL, 00H
OUT DX, AL
CALL DELAY_LONG
MOV AL, 0FFH
OUT DX, AL
CALL DELAY_LONG
LOOP RECT
;; ---------- RECT END ----------
;; --------- TRI START ---------
MOV CX, 02H
TRI:
MOV AL, 00H
TR1:
OUT DX, AL
CALL DELAY_SHORT
CMP AL, 0FFH
JE TR2
INC AL
JMP TR1
TR2:
OUT DX, AL
CALL DELAY_SHORT
CMP AL, 00H
JE TR3
DEC AL
JMP TR2
TR3:
LOOP TRI
;; ---------- TRI END ----------
;; --------- STAIR START ---------
MOV CX, 02H
STA:
MOV AX, 00H
STA1:
OUT DX, AL
CMP AX, 0FFH
JGE STA_FIN
CALL DELAY_LONG
ADD AL, 11H ;; 0FH STAIRS
;; 11H GAP
JMP STA1
STA_FIN:
LOOP STA
;; ---------- STAIR END ----------
MOV AX, 4C00H
INT 21H
DELAY_SHORT:
PUSH AX
PUSH CX
MOV CX, 01FFH
LOOP $
POP CX
POP AX
RET
DELAY_LONG:
PUSH AX
PUSH CX
MOV CX, 0FFFFH
LOOP $
POP CX
POP AX
RET
CODE ENDS
END START

波形

锯齿波、矩形波、三角波
锯齿波、矩形波、三角波

阶梯波
阶梯波

选做实验:中断控制波形

描述

使用单脉冲开关 KK1 在四种波形间进行切换。

分析

KK1MIR6 相连,在中断处理程序中判断需要绘制的波形,主循环中绘制实际的波形。

需要封装一下之前用到的波形绘制部分代码。

代码

;; DAC0832 IOY0
;; BASE OFFSET: 0600H
A0832 EQU 0600H
SSEG SEGMENT STACK
DW 0,0,0,0
SSEG ENDS
CODE SEGMENT
ASSUME CS:CODE, SS:SSEG
START:
;; MIR6
MOV AX, OFFSET MIR6
MOV SI, 38H
MOV [SI], AX
MOV AX, CS
MOV SI, 3AH
MOV [SI], AX
;; --------------------------------------------------
;; INIT 8259
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
;; --------------------------------------------------
MOV DX, A0832
MOV BX, 0
MAIN:
MOV CX, 1
CMP BX, 0
JE M_SAW
CMP BX, 1
JE M_RECT
CMP BX, 2
JE M_TRI
CALL STA
JMP MAIN
M_SAW:
CALL SAW
JMP MAIN
M_RECT:
CALL RECT
JMP MAIN
M_TRI:
CALL TRI
JMP MAIN
MIR6:
INC BX
CMP BX, 4
JNE BACK
MOV BX, 0
BACK:
IRET
MOV DX, A0832
SAW:
MOV AL, 00H
JC1:
OUT DX, AL
CALL DELAY_SHORT
CMP AL, 0FFH
JE JC2
INC AL
JMP JC1
JC2:
LOOP SAW
RET
RECT:
MOV AL, 00H
OUT DX, AL
CALL DELAY_LONG
MOV AL, 0FFH
OUT DX, AL
CALL DELAY_LONG
LOOP RECT
RET
TRI:
MOV AL, 00H
TR1:
OUT DX, AL
CALL DELAY_SHORT
CMP AL, 0FFH
JE TR2
INC AL
JMP TR1
TR2:
OUT DX, AL
CALL DELAY_SHORT
CMP AL, 00H
JE TR3
DEC AL
JMP TR2
TR3:
LOOP TRI
RET
STA:
MOV AX, 00H
STA1:
OUT DX, AL
CMP AX, 0FFH
JGE STA_FIN
CALL DELAY_LONG
ADD AL, 11H ;; 0FH STAIRS
;; 11H GAP
JMP STA1
STA_FIN:
LOOP STA
RET
DELAY_SHORT:
PUSH AX
PUSH CX
MOV CX, 01FFH
LOOP $
POP CX
POP AX
RET
DELAY_LONG:
PUSH AX
PUSH CX
MOV CX, 0FFFFH
LOOP $
POP CX
POP AX
RET
CODE ENDS
END START

Previous Post
[微机实验/TD-PITE] A/D 转换实验+选做实验
Next Post
『彼女、お借りします』一期完结点评