| ??? 02/13/09 19:24 Read: times |
#162371 - Sorry Responding to: ???'s previous message |
Here is the full code
.equ locat, 0x2000 ;Location for this program
.equ lcd_horiz_size, 20
.equ lcd_vert_size, 2
.equ lcd_bytes_per_line, (128 / lcd_vert_size)
.equ lcd_clear_cmd, 0x01 ;clears display
.equ lcd_home_cmd, 0x02 ;put cursor at home position
.equ lcd_on_cmd, 0x0C ;turn on display (cursor off)
.equ lcd_shift_cmd, 0x10
.equ lcd_config_cmd, 0x38 ;config 8 bit, 2 lines, 5x7
.equ lcd_command_wr, 0xFE00
.equ lcd_status_rd, 0xFE01
.equ lcd_data_wr, 0xFE02
.equ lcd_data_rd, 0xFE03
.equ cout, 0x0030
.equ cin, 0x0032
.equ phex, 0x0034
.equ phex16, 0x0036
.equ pstr, 0x0038
.equ newline, 0x0048
.equ port_a, 0xF800
.equ port_abc_pgm, 0xF803
.org locat
.db 0xA5,0xE5,0xE0,0xA5 ;signiture bytes
.db 35,255,0,0 ;id (35=prog)
.db 0,0,0,0 ;prompt code vector
.db 0,0,0,0 ;reserved
.db 0,0,0,0 ;reserved
.db 0,0,0,0 ;reserved
.db 0,0,0,0 ;user defined
.db 255,255,255,255 ;length and checksum (255=unused)
.db "Practica 2: LCD",0 ;max 31 characters, plus the zero
.org locat+64 ;executable code begins here
begin:
mov dptr, #mesg_start ;print a message for the user
lcall pstr
acall lcd_init
acall lcd_clear ;setup the LCD
acall lcd_home
mov r4, #0 ;r4/r5 will remember cursor position
mov r5, #1
mov dptr, #mesg_start_lcd
acall lcd_pstr ;print a message on the LCD top line
sjmp reposition_cursor ;start the cursor on second line
main2: acall lcd_cout
inc r4 ;keep up with cursor position
cjne r4, #lcd_horiz_size, main_loop
mov r4, #0 ;if right edge, return to left side
inc r5
cjne r5, #lcd_vert_size, reposition_cursor
mov r5, #0 ;if bottom edge, return to top line
reposition_cursor:
mov a, r4
mov r2, a
mov a, r5
mov r3, a
acall lcd_set_xy ;set the cursor back onto screen
sjmp main_loop
main_loop:
mov dptr, #port_a
movx a,@dptr
anl a,#0Fh
jz msg00 ;
dec a
jz msg01 ;
dec a ;
jz msg02;
dec a;
jz msg03;
dec a;
jz msg04;
dec a;
jz msg05 ;
dec a
jz msg06 ;
dec a ;
jz msg07;
dec a;
jz msg08;
dec a;
jz msg09;
dec a;
jz msg0A ;
dec a
jz msg0B ;
dec a ;
jz msg0C;
dec a;
jz msg0D;
dec a;
jz msg0E;
dec a;
jz msg0F ;
cjne a, #27, main2
ljmp 0
msg00:
mov dptr, #msg0
acall lcd_pstr
ljmp main_loop ;ajmp main_loop
msg01:
mov dptr, #msg1
acall lcd_pstr
ljmp main_loop ;ajmp main_loop
msg02:
mov dptr, #msg2
acall lcd_pstr
ljmp main_loop ;ajmp main_loop
msg03:
mov dptr, #msg3
acall lcd_pstr
ljmp main_loop ;ajmp main_loop
msg04:
mov dptr, #msg4
acall lcd_pstr
ljmp main_loop ;ajmp main_loop
msg05:
mov dptr, #msg5
acall lcd_pstr
ljmp main_loop ;ajmp main_loop
msg06:
mov dptr, #msg6
acall lcd_pstr
ljmp main_loop ;ajmp main_loop
msg07:
mov dptr, #msg7
acall lcd_pstr
ljmp main_loop ;ajmp main_loop
msg08:
mov dptr, #msg8
acall lcd_pstr
ljmp main_loop ;ajmp main_loop
msg09:
mov dptr, #msg9
acall lcd_pstr
ljmp main_loop ;ajmp main_loop
msg0A:
mov dptr, #msgA
acall lcd_pstr
ljmp main_loop ;ajmp main_loop
msg0B:
mov dptr, #msgB
acall lcd_pstr
ljmp main_loop ;ajmp main_loop
msg0C:
mov dptr, #msgC
acall lcd_pstr
ljmp main_loop ;ajmp main_loop
msg0D:
mov dptr, #msgD
acall lcd_pstr
ljmp main_loop ;ajmp main_loop
msg0E:
mov dptr, #msgE
acall lcd_pstr
ljmp main_loop ;ajmp main_loop
msg0F:
mov dptr, #msgF
acall lcd_pstr
ljmp main_loop ;ajmp main_loop
mesg_start:
.db "Ingresa un valor binario",13,10
.db "mediante el uso del DIP Switch",13,10,0
mesg_start_lcd:
.db "Ingresa un valor Bin",0
msg0:
.db "El camino, mal viaje",0
msg1:
.db "Ahora hay que seguir",0
msg2:
.db "Si tu no comprendes ",0
msg3:
.db "Todo estara igual...",0
msg4:
.db "Solo sigue adelante ",0
msg5:
.db "Olvidate de lo demas",0
msg6:
.db "Escucha todo momento",0
msg7:
.db "Observa cada lamento",0
msg8:
.db "Notaras solo la luz ",0
msg9:
.db "Olvidaras el futuro ",0
msgA:
.db "Conoceras el pasado ",0
msgB:
.db "A pesar de todo eso ",0
msgC:
.db "No importara conocer",0
msgD:
.db "Ya que todo al final",0
msgE:
.db "Dependera de tu boca",0
msgF:
.db "Y del camino en ti. ",0
;----------------------------------------------------------------
; General purpose routines for accessing the LCD
;----------------------------------------------------------------
lcd_cout:
push dpl
push dph
push acc
acall lcd_busy
mov dptr, #lcd_data_wr
pop acc
movx @dptr, a
pop dph
pop dpl
ret
lcd_pstr:
clr a
movc a, @a+dptr
inc dptr
jz lcd_pstr_end
acall lcd_cout
sjmp lcd_pstr
lcd_pstr_end:
ret
lcd_busy:
mov dptr, #lcd_status_rd
lcd_busy_wait:
movx a, @dptr
jb acc.7, lcd_busy_wait
ret
lcd_set_xy:
mov a, r2
add a, #256 - lcd_horiz_size
jnc lcd_set_xok
mov r2, #lcd_horiz_size - 1
lcd_set_xok:
mov a, r3
add a, #256 - lcd_vert_size
jnc lcd_set_yok
mov r3, #lcd_vert_size - 1
lcd_set_yok:
acall lcd_busy
mov a, r3
mov b, #lcd_bytes_per_line
mul ab
add a, r2
orl a, #0x80 ;msb set for set DD RAM address
mov dptr, #lcd_command_wr
movx @dptr, a
ret
lcd_init:
lcall lcd_busy
mov dptr, #lcd_command_wr
mov a, #lcd_config_cmd
movx @dptr, a
lcall lcd_busy
mov dptr, #lcd_command_wr
mov a, #lcd_on_cmd
movx @dptr, a
lcall lcd_busy
mov dptr, #lcd_command_wr
mov a, #lcd_shift_cmd
movx @dptr, a
ret
lcd_clear:
lcall lcd_busy
mov dptr, #lcd_command_wr
mov a, #lcd_clear_cmd
movx @dptr, a
ret
lcd_home:
lcall lcd_busy
mov dptr, #lcd_command_wr
mov a, #lcd_home_cmd
movx @dptr, a
ret
|
| Topic | Author | Date |
| Need some help with port reading and LCD displaying. | 01/01/70 00:00 | |
| be more specific in your statement of the problem! | 01/01/70 00:00 | |
| is other part(LCD) working? | 01/01/70 00:00 | |
| The LCD actually is working | 01/01/70 00:00 | |
| It worked better than mine | 01/01/70 00:00 | |
| You still have no loop | 01/01/70 00:00 | |
| Nearly perfectly working | 01/01/70 00:00 | |
| what is Your default code? | 01/01/70 00:00 | |
| My actual code | 01/01/70 00:00 | |
| that's not 'code' | 01/01/70 00:00 | |
| Sorry | 01/01/70 00:00 | |
| Is this really all of it? | 01/01/70 00:00 | |
Yeah, it's all of it | 01/01/70 00:00 | |
| thank you for the answer | 01/01/70 00:00 | |
| Compare Jump NOT Equal | 01/01/70 00:00 |



