1. 程式人生 > >8251序列介面應用實驗:輸出部分方波

8251序列介面應用實驗:輸出部分方波

實驗現象:
在示波器上觀察到類似方波的波形(形如101010100)
實驗程式碼:

 1	Con_8253    EQU     0B003H
    2	T2_8253     EQU     0B002H
    3	CTL_ADDR   EQU     0F001H
    4	DATA_ADDR  EQU     0F000H
    5	_STACK SEGMENT STACK
    6	DW 100 DUP(?)
    7	_STACK ENDS
    8	CODE SEGMENT
    9	ASSUME CS:CODE
    10	START:  CALL   INIT_8253
    11	         CALL   INIT_8251
    12	A1:      CALL   SEND
    13	         MOV   CX,0FFFH
    14	A2:      MOV   AX,01E0H
    15	A3:      DEC   AX
    16	         JNZ    A3
    17	         LOOP  A2
    18	         JMP    A1
    19	INIT_8253 PROC NEAR
    20	         MOV   DX,Con_8253
    21	         MOV   AL,96H
    22	         OUT   DX,AL
    23	         MOV   DX,T2_8253
    24	         MOV   AL,26H
    25	         OUT   DX,AL
    26	         RET
    27	INIT_8253 ENDP
    28	INIT_8251 PROC NEAR
    29	         CALL   Reset_8251
    30	         MOV   DX,CTL_ADDR
    31	         MOV   AL,7EH
    32	         OUT   DX,AL
    33	         CALL  DLTIME
    34	         MOV   AL,31H
    35	         OUT   DX,AL
    36	         CALL  DLTIME
    37	         RET
    38	INIT_8251 ENDP
    39	Reset_8251 PROC NEAR
    40	         MOV   DX, CTL_ADDR
    41	         MOV   AL,0
    42	         OUT   DX,AL
    43	         CALL  DLTIME 
    44	         OUT   DX,AL
    45	         CALL  DLTIME
    46	         OUT   DX,AL
    47	         CALL  DLTIME
    48	         MOV   AL,40H
    49	         OUT   DX,AL
    50	         CALL   DLTIME
    51	         RET
    52	Reset_8251 ENDP
    53	DLTIME PROC NEAR
    54	         MOV   CX,10
    55	         LOOP $
    56	         RET
    57	DLTIME ENDP
    58	SEND:   MOV   AL,55H
    59	         MOV   DX,DATA_ADDR
    60	         OUT   DX,AL
    61	         RET
    62	CODE ENDS
    63	END START