flat assembler
Message board for the users of flat assembler.
Index
> Main > How to initialize an LCD module? |
Author |
|
delta67 23 Jul 2012, 22:21
Thanks to SHOORICK I finally fixed the code:
Code: ; 2x16 LCD module connected to the 8088 SBC via 8255 PIO: ; - D4-D7 are connected to portC C4-C7 ; - E is connected to PORTC C0 ; - RS is connected to portC C1 ; 8255 : PORTA= 00 PORTB=01 PORTC=02 PORT COMMAND=03 ;========================================= rom_size = 2000h ; for a 8K octet EPROM you should set the rom_size to $2000 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 on command port ; wait >15mS mov cx,07FFFh ; ?? s delay1: loop delay1 ;---------------------------------------------- mov al, 020h ; mode 4bits mov sp,@F JMP lcd_command @@: dw @F @@: ; wait 5mS mov cx,0FFFh delay2: loop delay2 ; 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, 028h ; mov sp,@F JMP lcd_command @@: dw @F @@: ; wait 5mS mov cx,0FFFh delay3: loop delay3 ;--------------------------------------------------------------------------------- ; Now we send the command "0Ch" = Display on, cursor off, blink off mov al, 0x0C ; mov sp,@F JMP lcd_command @@: dw @F @@: ; wait 5mS mov cx,0FFFh delay4: loop delay4 ;--------------------------------------------------------------------------------- ; Now we send the command "06h" = Address increment, no scrolling mov al, 0x06 ; mov sp,@F JMP lcd_command @@: dw @F @@: ; wait 5mS mov cx,0FFFh delay5: loop delay5 ;--------------------------------------------------------------------------------- ; Now we send the command "01h" Clear LCD command mov al, 0x01 ; mov sp,@F JMP lcd_command @@: dw @F @@: ; wait 5mS mov cx,0FFFh delay6: loop delay6 ;============================================= ; Send a character data to LCD ;write 'E' (45h) to the LCD mov al, 0x45 ; mov sp,@F JMP lcd_data @@: dw @F @@: hlt ;======================================== lcd_command: xor bl,bl ; set RS=0 jmp lcd_write lcd_data: mov bl,2 ; set RS=1 lcd_write: mov ah,al ; al - byte to send and al,0xF0 or al,bl out 0x02,al mov al,0x01; E is connected to C0 out 0x03,al ; turn E on dec al out 0x03,al ; turn E off mov al,ah mov cl,4 shl al,cl and al,0xF0 or al,bl out 0x02,al mov al,0x01; out 0x03,al ; turn E on dec al out 0x03,al ; turn E off ret ;----------------------------------------- times rom_size - 16 - $ db rom_empty ; on remplit l'espace vide par FFh sauf les derniers 16 octets ;----------------------------------------- boot: ; vecteur reset : FFFF0 jmp (rom_start shr 4):start ;----------------------------------------- times rom_size - $ db rom_empty ; on remplit le rest vide du 16 octets |
|||
23 Jul 2012, 22:21 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.