我是编程液晶与80188,使用8255。我正在写一个基本的代码来显示一些文本,但它不工作。如下所示:
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设置:
;mov AX,DATA_SEG;mov AX,AX;mov 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 lcd endp
CODE_SEG结束结束
有没有人知道我是不是漏掉了什么?
发布于 2014-01-21 14:08:48
mov al, 00000100B ;这将重置PC2
对于mov al, 00000000B ;,这也将重置,但这里是PC0
你说第一个设置E,然后重置它。假设E与PC0相连,你想要上升,然后返回到零,这意味着一个负沿,然后你的代码是:
mov al, 00000001B
mov al, 00000000B这是一个负面的边缘,也要记住你不了解brev。这个线的值,所以不要等待正边缘然后是负边缘,它只是负边缘。
发布于 2015-08-27 12:52:48
我假设这是一个以8位模式连接的"HD44780“字符液晶屏。
我看到了看起来像是汇编语法错误的东西。为此:
MOV AL,%1;显示“%1”字母
您可能需要:
MOV AL,“%1”;显示“%1”字母
或者,如果您的编译器不理解单引号,可能会这样:
MOV AL,31h;显示“%1”字母
将1放入AL将选择CGRAM中的一个字符,这可能不是您想要的。
另一件经常出现在LCD上的事情是引脚3,"Vo“。这通常需要设置在1v左右,如果你将它连接到5v,字符将不可见。
对于初始化,HD44780和它更现代的“兼容”替代品有点棘手。
在这个线程( https://forum.crystalfontz.com/showthread.php/77 )中,有我久经考验的8位初始化代码:
//===========================================
void LCD_Initialize(void)
{
//This sequence is from the initialization on page 45 of the
//HD44780U Data Sheet.
DelayMs(20);
//Blind_Write_LCD_Control writes without checking the busy bit first.
Blind_Write_LCD_Control(0x30);
//Yes, the data sheet says write it twice.
DelayMs(5);
Blind_Write_LCD_Control(0x30);
//Yes, the data sheet says write it three times.
DelayUs(125);
Blind_Write_LCD_Control(0x30);
//Yes, the data sheet says write it four times, but at least this
//one counts.
//038h is Function set:
//8bit,
//2 line
//F = (5x8)
DelayUs(125);
Blind_Write_LCD_Control(0x38);
//"Display off"
Write_LCD_Control(0x08);
//"Display clear"
Write_LCD_Control(0x01);
//This delay is needed for the Sitronix ST7066 controller. No
//reasonable explanation, I found it empirically. Not needed for
//Samsung or Hitachi controllers.
DelayMs(2);
//Write_LCD_Control waits for the busy bit to go low, then writes
//the to the control register.
//006h is Entry mode set, increment, no shift
Write_LCD_Control(0x06);
//Display on, cursor on, blinking
Write_LCD_Control(0x0F);
//Clear the display again. This seems to fix a power-up problem
//where the display shows "{{{{{" in a couple of places.
Write_LCD_Control(0x01);
}
//===========================================https://stackoverflow.com/questions/19676504
复制相似问题