I want to initialise a 2x16 LCD module, connected to an 8088 SBC but my code didn't work!!
; 2x16 LCD module connected to the 8088 SBC via 8255 PIO:
; - D4-D7 are connected to portC C4-C7
; - RS is connected to PORTC C0
; - E is connected to portB B0
; 8255 : PORTA= 00 PORTB=01 PORTC=02 PORT COMMAND=03
;=========================================
rom_size = 2000h ; 8K byte EPROM
rom_start = 100000h - rom_size
rom_empty = 0FFh
;=========================================
use16
;-----------------------------------------
start:
; init 8255
mov al, 80h ; MODE 0 and all ports as outputs
out 03h, al ; send to command port
; wait >15mS
mov cx,07FFFh ; ?? s
delay1:
loop delay1
mov bl, 03h ; send "3" three times to initialize the LCD in mode 8bits
mov al, 030h
out 02, al ; send first "3" on C4-C7 , RS=0
again: mov al, 01h
out 01h, al ; portB B0=1 (E=1)
nop
nop
mov al, 00h
out 01h, al ; E=0
; wait >5mS
mov cx,01FFFh
delay2:
loop delay2
dec bl ; "3" sent 3 times?
jnz again ; NO , then repeat
; YES , now LCD is in 8bits mode 8
;----------------------------------------------
mov al, 020h ; mode 4bits
out 02h, al ; send "2" on C4-C7 , RS=0
mov al, 01h
out 01h, al ; portB B0=1 (E=1)
nop
nop
mov al, 00h
out 01h, al ; E=0
; wait 5mS
mov cx,0FFFh
delay3:
loop delay3
; At this point, the normal 4 wire command routine can be used
;---------------------------------------------------------------------------------
; Now we send the command "28h" Function set, 4 wire, 2 lines, 5x7 font
mov al, 020h ;
out 02h, al ; send "2" on C4-C7 , RS=0
out 01h, al ; portB B0=1 (E=1)
nop
nop
mov al, 00h
out 01h, al ; E=0
nop
mov al, 080h ;
out 02h, al ; send "8" on C4-C7 , RS=0
mov al, 01h
out 01h, al ; portB B0=1 (E=1)
nop
nop
mov al, 00h
out 01h, al ; E=0
; wait 5mS
mov cx,0FFFh
delay4:
loop delay4
;---------------------------------------------------------------------------------
; Now we send the command "0Ch" = Display on, cursor off, blink off
; mov al, 00h ; AL is already cleared
out 02h, al ; send "0" on C4-C7 , RS=0
mov al, 01h
out 01h, al ; portB B0=1 (E=1)
nop
nop
mov al, 00h
out 01h, al ; E=0
nop
mov al, 0C0h ;
out 02h, al ; send "C" on C4-C7 , RS=0
mov al, 01h
out 01h, al ; portB B0=1 (E=1)
nop
nop
mov al, 00h
out 01h, al ; E=0
; wait 5mS
mov cx,0FFFh
delay5:
loop delay5
;---------------------------------------------------------------------------------
; Now we send the command "06h" = Address increment, no scrolling
; mov al, 00h ; AL is already cleared
out 02h, al ; send "0" on C4-C7 , RS=0
mov al, 01h
out 01h, al ; portB B0=1 (E=1)
nop
nop
mov al, 00h
out 01h, al ; E=0
nop
mov al, 060h ;
out 02h, al ; send "6" on C4-C7 , RS=0
mov al, 01h
out 01h, al ; portB B0=1 (E=1)
nop
nop
mov al, 00h
out 01h, al ; E=0
; wait 5mS
mov cx,0FFFh
delay6:
loop delay6
;---------------------------------------------------------------------------------
; Now we send the command "01h" Clear LCD command
; mov al, 00h ; ALis already cleared
out 02h, al ; send "0" on C4-C7 , RS=0
mov al, 01h
out 01h, al ; portB B0=1 (E=1)
nop
nop
nop
mov al, 00h
out 01h, al ; E=0
nop
mov al, 010h ;
out 02h, al ; send "1" on C4-C7 , RS=0
mov al, 01h
out 01h, al ; portB B0=1 (E=1)
nop
nop
nop
mov al, 00h
out 01h, al ; E=0
; wait 5mS
mov cx,0FFFh
delay7:
loop delay7
;=============================================
; Send a character data to LCD
;write 'E' (45h) to the LCD
mov al, 041h
out 02h, al ; send "4" on C4-C7 , 1 on C0 (RS=1)
nop
nop
mov al, 01h
out 01h, al ; portB B0=1 (E=1)
nop
nop
mov al, 00h
out 01h, al ; E=0
nop
mov al, 051h
out 02h, al ; send "5" on C4-C7 ,1 on C0 (RS=1)
nop
nop
mov al, 01h
out 01h, al ; portB B0=1 (E=1)
nop
nop
mov al, 00h
out 01h, al ; E=0
;=============================
hlt ; stop