;--------------------------------------------------------------------------
;*********** MANEJO DE LCD 2X16 A 8 BITS *********
;--------------------------------------------------------------------------
LIST P=16F84A
RADIX HEX
#INCLUDE "P16F84A.INC"
;--------------------------------------------------------------------------
;*********** ASIGNACIONES *******************
;--------------------------------------------------------------------------
ret0 equ 20h
ret1 equ 21h
ret2 equ 22h
regreg equ 23h
regdato equ 24h
reg1 equ 28h
reg2 equ 29h
rs equ 01h
rw equ 02h
e equ 03h
rb0 equ 00h
rb1 equ 01h
rb2 equ 02h
rb3 equ 03h
rb4 equ 04h
rb5 equ 05h
rb6 equ 06h
rb7 equ 07h
;--------------------------------------------------------------------------------
;********* ORIGEN **************
;--------------------------------------------------------------------------------
ORG 00H
GOTO INICIO
;--------------------------------------------------------------------------------
;********* SUBRUTINAS **************
;--------------------------------------------------------------------------------
ORG 05H
;--------------------------------------------------------------------
; RETARDO DE 0,5 SEGUNDOS
;--------------------------------------------------------------------
ret05s movlw .239
movwf ret0
salto42 movlw .232
movwf ret1
salto43 clrwdt
salto44 goto salto45
salto45 goto salto46
salto46 clrwdt
decfsz ret1,f
goto salto43
decfsz ret0,f
goto salto42
goto salto47
salto47 goto salto48
salto48 goto salto49
salto49 clrwdt
return
;-------------------------------------------------------------------
; RETARDO DE 10 uS
;-------------------------------------------------------------------
retardo movlw 05h
movwf ret0
salto11 decfsz ret0,f
goto salto11
return
;--------------------------------------------------------------------
; RETARDO DE 5 MILISEGUNDOS
;--------------------------------------------------------------------
ret5ms movlw .6
movwf ret0
salto91 movlw .207
movwf ret1
salto92 clrwdt
decfsz ret1,f
goto salto92
decfsz ret0,f
goto salto91
goto salto93
salto93 clrwdt
return
;-------------------------------------------------------------------
; RETARDO DE 200 mS
;-------------------------------------------------------------------
r200ms movlw .156
movwf ret0
salto31 movlw .213
movwf ret1
salto32 clrwdt
clrwdt
decfsz ret1,f
goto salto32
decfsz ret0,f
goto salto31
goto salto33
salto33 goto salto34
salto34 clrwdt
return
;------------------------------------------------------------------------------------
;******************* rutina de control del lcd ********************************
;------------------------------------------------------------------------------------
lcd_e bsf porta,e
nop
bcf porta,e
return
lcd_busy
bcf porta,rs
bsf porta,rw
bsf porta,e
nop
l_busy btfsc portb,rb7
goto l_busy
bcf porta,e
bcf porta,rs
bcf porta,rw
return
lcd_reg call lcd_busy
movf regreg,w
movwf portb
bcf porta,rs
call lcd_e
nop
return
lcd_dato
call lcd_busy
movf regdato,w
movwf portb
bsf porta,rs
call lcd_e
nop
return
;--------------------------------------------------------------------------------
;**********************programa principal******************************
;--------------------------------------------------------------------------------
inicio call ret05s ;esperar 0,5 segundos
bcf status,rp1
bsf status,rp0 ;seleccionar banco 1
movlw xxh
movwf trisa
clrf trisb
bcf status,rp0 ;volver al banco 0
clrf portb
call ret05s
call ret05s ;esperar 1 segundo
;LLAMAR A SUBRUTINA DE INICIALIZACION DE LCD
jump1 movlw 01h
movwf regreg
call lcd_reg ;cursor en primer linea
mues1 clrf reg1
ciclo1 movf reg1,w
call tabla1
movwf regdato
call lcd_dato
movlw 5fh ;retardo entre caracteres
movwf reg2
salto1 call retardo
call retardo
decfsz reg2,f
goto salto1
incf reg1,f
movlw 10h
subwf reg1,w
btfss status,z
goto ciclo1
movlw 0c0h
movwf regreg
call lcd_reg ;cursor en segunda linea
mues2 clrf reg1
ciclo2 movf reg1,w
call tabla2
movwf regdato
call lcd_dato
movlw 5fh ;retardo entre caracteres
movwf reg2
salto2 call retardo
call retardo
decfsz reg2,f
goto salto2
incf reg1,f
movlw 10h
subwf reg1,w
btfss status,z
goto ciclo2
;--------------------------------------------------------------------------------------
;********** tablas de mesajes a mostrar en lcd ****************************************
;--------------------------------------------------------------------------------------
org xxxxh
TABLA1 ADDWF PCL,F
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
TABLA2 ADDWF PCL,F
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
RETLW " "
end