1

8255 を使用して、80188 で LCD をプログラミングしています。テキストを表示する基本的なコードを書いていますが、機能しません。次のように:

STI
PORTA   EQU     0080H
PORTB   EQU     0081H
PORTC   EQU     0082H
CWR     EQU     0083H

;set 8255 output
MOV AL, 89H       
MOV DX, CWR
OUT DX, AL        ;send the control word

NEXT:

call far ptr lcd
JMP NEXT

lcd proc far

PUSH    DX
PUSH    CX
PUSH    BX
PUSH    AX

設定:

; 移動AX、DATA_SEG; 移動AX、AX; 移動ES、AX

;The following sends all the necessary commands to the LCD
MOV AL, 38H ;initialize LCD for 2 lines & 5*7 matrix
CALL COMNDWRT ;write the command to LCD 
CALL DELAY ;wait before issuing the next command
CALL DELAY 
;this command needs lots of delay
CALL DELAY
MOV AL, 0EH ;send command for LCD on, cursor on 0000 1110b 
CALL COMNDWRT
CALL DELAY
MOV AL, 01   ;clear LCD
CALL COMNDWRT
CALL DELAY
MOV AL, 06   ;command for shifting cursor right
CALL COMNDWRT
CALL DELAY

COMNDWRT PROC ;this procedure writes commands to LCD
    PUSH DX ;save DX
    MOV DX, PORTB  ; connected to LCD
    OUT DX, AL   ;send the code to Port B
    MOV DX, PORTC
    MOV AL, 00000100B ;RS=0,R/W=0,E=1 for H-To-L pulse
    OUT DX, AL ; send setup to PORT C
    NOP
    NOP
    MOV AL, 00000000B ;RS=0,R/W=0,E=0 for H-To-L pulse
    OUT DX, AL
    POP DX
    RET
COMNDWRT ENDP

MOV AL, 1 ;display ‘1’ letter
CALL DATWRIT ;issue it to LCD
CALL DELAY ;wait before issuing the next character
MOV AL, 2 ;display ‘2’ letter
CALL DATWRIT ;issue it to LCD
CALL DELAY ;wait before issuing the next character
MOV AL, 5 ;display ‘5’ letter
CALL DATWRIT ;issue it to LCD
CALL DELAY ;wait
;data write to LCD without checking the busy flag
;AL = char sent to LCD

DATWRIT PROC
    PUSH DX  ;save DX
    MOV DX, PORTB  ;DX=port B address
    OUT DX, AL ;issue the char to LCD
    MOV AL, 00000101B ;RS=1,R/W=0, E=1 for H-to-L pulse
    MOV DX, PORTC ;port C address
    OUT DX, AL  ;make enable high
    MOV AL, 00000001B ;RS=1,R/W=0 and E=0 for H-to-L pulse
    OUT DX, AL
    POP DX
    RET
DATWRIT ENDP

DELAY PROC
    MOV CX, 1325  ;1325*15.085 usec = 20 msec
    PUSH AX
    W1: IN AL, 61H
    AND AL, 00010000B
    CMP AL, AH
    JE W1
    MOV AH, AL
    LOOP W1
    POP AX
    RET
DELAY ENDP

;JMP SETUP
POP AX
POP BX
POP CX
POP DX
ret 

液晶エンド

CODE_SEG ENDS END

私が何か欠けているかどうか誰にもわかりますか?

4

2 に答える 2

1

mov al, 00000100B ;これでリセットされますPC2

mov al, 00000000B ;これもリセットされますが、ここではPC0

あなたは最初の1セットEを言った後、それをリセットしました。したがって、E が PC0 に接続されていて、上昇してからゼロに戻したい、つまり負のエッジを意味する場合、コードは次のようになります。

mov al, 00000001B
mov al, 00000000B

これは負のエッジです。また、簡潔な内容を知らないことも覚えておいてください。このワイヤーの値なので、正のエッジ、次に負のエッジを待たずに、負のエッジのみです。

于 2014-01-21T06:08:48.300 に答える