DAC0832
First, the use of software delay method to achieve sawtooth wave, square wave, triangular waves, trapezoidal wave.
1.1 Time delay method, 16 times Sawtooth Wave, highest point -5v
;0832 ua-oscilloscope observation delay method
; 0832cs280h~287h
; Ua=-uxef/256*n; ub=-uxef/256*n-5
Data SEGMENT
Data ENDS
STACK1 SEGMENT PARA STACK
dw 20H DUP (0)
STACK1 ENDS
CODE SEGMENT
assume cs:code, Ds:data, Ss:stack1
START:
MOV AX, DATA
mov DS, AX
mov AL, 00H
AGAIN:
MOV DX, 280H; Port number
out DX, AL
call DELAY
ADD AL, 10H; 16 times from 00h-10h-20h-30h-40h-50h-60h-70h-80h-90h-a0h-b0h-c0h-d0h-e0h-f0h, back to 00H
JMP AGAIN
MOV AH, 4CH; exit to DOS, end program run
INT 21H
DELAY PROC near
PUSH CX
MOV CX, 0FFFFH
L1:
LOOP L1
MOV CX, 0FFFFH
L2:
LOOP L2
POP CX
Ret
DELAY ENDP
CODE ENDS
END START
1.2 Time delay method, 32 times Sawtooth Wave, highest point -5v
0832 ua-oscilloscope Observation delay method
; 0832cs280h~287h
; Ua=-uxef/256*n; Ub=-uxef/256*n-5
; 0832cs280h~287h
DATA SEGMENT
DATA ENDS
CODE SEGMENT
Assume Cs:code, Ds:data
START:
MOV AX, DATA
MOV DS, AX
MOV AL, 00H
AGAIN:
MOV DX, 280H
Out DX, AL
Call DELAY
ADD AL, 08H; from 00000000-00001000-0001100 ... 111,110,001 Total 32 times, back to 00H
JMP AGAIN
MOV AH, 4CH
INT 21H
DELAY PROC near
PUSH CX
MOV CX, 0FFFFH
L1:
LOOP L1
MOV CX, 0FFFFH
L2:
LOOP L2
POP CX
Ret
DELAY ENDP
CODE ENDS
END START
2. Delay method, generate square wave, highest point -5v
0832 ua-oscilloscope Observation delay method
; 0832cs280h~287h
; Ua=-uxef/256*n; Ub=-uxef/256*n-5
DATA SEGMENT
DATA ENDS
STACK1 SEGMENT PARA STACK
DW 20H DUP (0)
STACK1 ENDS
CODE SEGMENT
Assume Cs:code, Ds:data, Ss:stack1
START:
MOV AX, DATA
MOV DS, AX
MOV AL, 5H
AGAIN:
MOV DX, 280H; Port number
Out DX, AL
Call DELAY
NEG AL; Take the opposite number.
JMP AGAIN
MOV AH, 4CH; Exit to DOS, which ends the program running
INT 21H
DELAY PROC near
PUSH CX
MOV CX, 0FFFFH
L1:
LOOP L1
MOV CX, 0FFFFH
L2:
LOOP L2
POP CX
Ret
DELAY ENDP
CODE ENDS
END START
3. Time delay method, 16 times to produce triangular wave, the highest point -2.5v
0832 ua-oscilloscope Observation delay method
; 0832cs280h~287h
; Ua=-uxef/256*n; Ub=-uxef/256*n-5
DATA SEGMENT
DATA ENDS
CODE SEGMENT
Assume Cs:code, Ds:data
START:
MOV AX, DATA
MOV DS, AX
MOV AL, 0H
Draw_ascend_line:; Draw the rising side
MOV DX, 280H
Out DX, AL
Call DELAY
CMP AL, 80H
JZ Draw_descend_line; Jump to the edge of the drawing drop
ADD AL, 08H
JMP Draw_ascend_line
Draw_descend_line:; Draw the falling edge
SUB AL, 08H
MOV DX, 280H
Out DX, AL
Call DELAY
CMP AL, 00H
JZ Draw_ascend_line; Jump to the rising edge of the painting
JMP Draw_descend_line
MOV ah,4ch; Exit to DOS, the end of program run
INT 21H
DELAY PROC near
PUSH CX
MOV CX, 200H
L1:
LOOP L1
POP CX
Ret
DELAY ENDP
CODE ENDS
END START
4. Time delay method, 16 times to produce trapezoidal wave, the highest point -2.5v
0832 ua-oscilloscope Observation delay method
; 0832cs280h~287h
; Ua=-uxef/256*n; Ub=-uxef/256*n-5
DATA SEGMENT
DATA ENDS
CODE SEGMENT
Assume Cs:code, Ds:data
START:
MOV AX, DATA
MOV DS, AX
MOV AL, 00H
Draw_ascend_line:; Draw the rising waist
MOV DX, 280H
Out DX, AL
Call DELAY
CMP AL, 80H
JZ Draw_horizon_line; Jump to the bottom of the ladder
ADD AL, 08H
JMP Draw_ascend_line
Draw_horizon_line: To draw a ladder to the bottom
MOV CX, 10H
AGAIN:
Out DX, AL
Call DELAY
LOOP AGAIN
Draw_descend_line:; Draw a falling waist
SUB AL, 08H
MOV DX, 280H
Out DX, AL
Call DELAY
CMP AL, 00H
JZ Draw_ascend_line; Jump to the waist of the Painted ascent
JMP Draw_descend_line
MOV AH, 4CH; exit to DOS, which is the end of the program
INT 21H
DELAY PROC near
PUSH CX
MOV CX, 200H
L1:
LOOP L1
POP CX
Ret
DELAY ENDP
CODE ENDS
END START
First, the use of hardware "8253+8255" delay method to achieve the sawtooth wave, square wave, triangular waves, trapezoidal wave.
1.1 16-time sawtooth wave, highest point -5v
; 0832 ua-oscilloscope observation
; 0832cs280h~287h
; Ua=-uxef/256*n; Ub=-uxef/256*n-5
; 8253-288H~28BH; Clk0-2mhz; Gate0-vcc;out0-pc7
; 8255-290h~293h;
; Ua=-uxef/256*n; Ub=-uxef/256*n-5
DATA SEGMENT
t0_8253 EQU 288H
kz_8253 EQU 28BH
pc_8255 EQU 292H
kz_8255 EQU 293H
DATA ENDS
STACK1 SEGMENT PARA STACK
DW 20H DUP (0)
STACK1 ENDS
CODE SEGMENT
Assume Cs:code, Ds:data, Ss:stack1
START:
MOV AX, DATA
MOV DS, AX
Call init_8253
Call init_8255
MOV AL, 00H
AGAIN:
MOV DX, 280H; Port number
Out DX, AL
Call DELAY
ADD AL, 10H
JMP AGAIN
MOV AH, 4CH; Exit to DOS, which ends the program running
INT 21H
DELAY PROC near
PUSH DX
PUSH AX
NEXT1:
MOV dx,pc_8255
in AL,DX
al,80h;1000 0000b-pc7
jnz NEXT1
next2:
MOV dx,pc_8255
in Al,dx
and al,80h
JZ NEXT2
POP AX
POP DX
Ret
DELAY ENDP
init_8253 PROC
PUSH DX
PUSH AX
MOV dx,kz_8253
MOV al,00100111b; Select channel 0-out0, write high byte, mode 3, with BCD code
Out Dx,al
MOV dx,t0_8253
MOV al,20h
Out Dx,al
; 8253 generate 1mS of continuous square wave */
POP AX
POP DX
Ret
init_8253 ENDP
; Initialize 8255
init_8255 PROC
PUSH DX
PUSH AX
MOV dx,kz_8255; 8255-way word control word control; 10011000
MOV al,98h
Out Dx,al
POP AX
POP DX
Ret
init_8255 ENDP
CODE ENDS
END START
2. Generate square wave, highest point -5v
; 0832 ua-oscilloscope observation
; 0832cs280h~287h
; Ua=-uxef/256*n; Ub=-uxef/256*n-5
; 8253-288H~28BH; Clk0-2mhz; Gate0-vcc;out0-pc7
; 8255-290h~293h;
; Ua=-uxef/256*n; Ub=-uxef/256*n-5
DATA SEGMENT
t0_8253 EQU 288H
kz_8253 EQU 28BH
pc_8255 EQU 292H
kz_8255 EQU 293H
DATA ENDS
STACK1 SEGMENT PARA STACK
DW 20H DUP (0)
STACK1 ENDS
CODE SEGMENT
Assume Cs:code, Ds:data, Ss:stack1
START:
MOV AX, DATA
MOV DS, AX
Call init_8253
Call init_8255
MOV AL, 5H
AGAIN:
MOV DX, 280H; Port number
Out DX, AL
Call DELAY
NEG AL
JMP AGAIN
MOV AH, 4CH; Exit to DOS, which ends the program running
INT 21H
DELAY PROC near
PUSH DX
PUSH AX
NEXT1:
MOV dx,pc_8255
in AL,DX
al,80h;1000 0000b-pc7
jnz NEXT1
next2:
MOV dx,pc_8255
in Al,dx
and al,80h
JZ NEXT2
POP AX
POP DX
Ret
DELAY ENDP
init_8253 PROC
PUSH DX
PUSH AX
MOV dx,kz_8253
MOV al,00100111b; Select channel 0-out0, write high byte, mode 3, with BCD code
Out Dx,al
MOV dx,t0_8253
MOV al,20h
Out Dx,al
; 8253 generate 1mS of continuous square wave */
POP AX
POP DX
Ret
init_8253 ENDP
; Initialize 8255
init_8255 PROC
PUSH DX
PUSH AX
MOV dx,kz_8255; 8255-way word control word control; 10011000
MOV al,98h
Out Dx,al
POP AX
POP DX
Ret
init_8255 ENDP
CODE ENDS
END START
3.16 times to produce triangular waves, highest point -5v
; 0832 ua-oscilloscope observation
; 0832cs280h~287h
; Ua=-uxef/256*n; Ub=-uxef/256*n-5
; 8253-288H~28BH; Clk0-2mhz; Gate0-vcc;out0-pc7
; 8255-290h~293h;
; Ua=-uxef/256*n; Ub=-uxef/256*n-5
DATA SEGMENT
t0_8253 EQU 288H
kz_8253 EQU 28BH
pc_8255 EQU 292H
kz_8255 EQU 293H
DATA ENDS
STACK1 SEGMENT PARA STACK
DW 20H DUP (0)
STACK1 ENDS
CODE SEGMENT
Assume Cs:code, Ds:data, Ss:stack1
START:
MOV AX, DATA
MOV DS, AX
Call init_8253
Call init_8255
MOV AL, 00H
Draw_ascend_line:; Draw the rising side
MOV DX, 280H
Out DX, AL
Call DELAY
CMP AL, 80H
JZ Draw_descend_line; Jump to the edge of the drawing drop
ADD AL, 08H
JMP Draw_ascend_line
Draw_descend_line:; Draw the falling edge
SUB AL, 08H
MOV DX, 280H
Out DX, AL
Call DELAY
CMP AL, 00H
JZ Draw_ascend_line; Jump to the rising edge of the painting
JMP Draw_descend_line
MOV AH, 4CH; Exit to DOS, which ends the program running
INT 21H
DELAY PROC near
PUSH DX
PUSH AX
NEXT1:
MOV dx,pc_8255
In AL,DX
and al,80h;1000 0000B-PC7
JNZ NEXT1
NEXT2:
MOV dx,pc_8255
In AL,DX
and al,80h
JZ NEXT2
POP AX
POP DX
Ret
DELAY ENDP
init_8253 PROC
PUSH DX
PUSH AX
MOV dx,kz_8253
MOV al,00100111b; Select channel 0-out0, write high byte, mode 3, with BCD code
Out Dx,al
MOV dx,t0_8253
MOV al,20h
Out Dx,al
; 8253 generate 1mS of continuous square wave */
POP AX
POP DX
Ret
init_8253 ENDP
; Initialize 8255
init_8255 PROC
PUSH DX
PUSH AX
MOV dx,kz_8255; 8255-way word control word control; 10011000
MOV al,98h
Out Dx,al
POP AX
POP DX
Ret
init_8255 ENDP
CODE ENDS
END START
4.16 times to produce trapezoidal wave, the highest point -5v
; 0832 ua-oscilloscope observation
; 0832cs280h~287h
; Ua=-uxef/256*n; Ub=-uxef/256*n-5
; 8253-288H~28BH; Clk0-2mhz; Gate0-vcc;out0-pc7
; 8255-290h~293h;
; Ua=-uxef/256*n; Ub=-uxef/256*n-5
DATA SEGMENT
t0_8253 EQU 288H
kz_8253 EQU 28BH
pc_8255 EQU 292H
kz_8255 EQU 293H
DATA ENDS
STACK1 SEGMENT PARA STACK
DW 20H DUP (0)
STACK1 ENDS
CODE SEGMENT
Assume Cs:code, Ds:data, Ss:stack1
START:
MOV AX, DATA
MOV DS, AX
Call init_8253
Call init_8255
MOV AL, 00H
Draw_ascend_line:; Draw the rising waist
MOV DX, 280H
Out DX, AL
Call DELAY
CMP AL, 80H
JZ Draw_horizon_line; Jump to the bottom of the ladder
ADD AL, 08H
JMP Draw_ascend_line
Draw_horizon_line: To draw a ladder to the bottom
MOV CX, 10H
AGAIN:
Out DX, AL
Call DELAY
LOOP AGAIN
Draw_descend_line:; Draw a falling waist
SUB AL, 08H
MOV DX, 280H
Out DX, AL
Call DELAY
CMP AL, 00H
JZ Draw_ascend_line; Jump to the waist of the Painted ascent
JMP Draw_descend_line
MOV AH, 4CH; Exit to DOS, which ends the program running
INT 21H
DELAY PROC near
PUSH DX
PUSH AX
NEXT1:
MOV dx,pc_8255
in AL,DX
al,80h;1000 0000b-pc7
jnz NEXT1
next2:
MOV dx,pc_8255
in Al,dx
and al,80h
JZ NEXT2
POP AX
POP DX
Ret
DELAY ENDP
init_8253 PROC
PUSH DX
PUSH AX
MOV dx,kz_8253
MOV al,00100111b; Select channel 0-out0, write high byte, mode 3, with BCD code
Out Dx,al
MOV dx,t0_8253
MOV al,20h
Out Dx,al
; 8253 generate 1mS of continuous square wave */
POP AX
POP DX
Ret
init_8253 ENDP
; Initialize 8255
init_8255 PROC
PUSH DX
PUSH AX
MOV dx,kz_8255; 8255-way word control word control; 10011000
MOV al,98h
Out Dx,al
POP AX
POP DX
Ret
init_8255 ENDP
CODE ENDS
END START
Modern computer Interface Experiment (IV) 0832 experiment