LIST p=16f628a
#include <p16f628a.inc>
SEG1 equ 0x4a
SEG2 equ 0x4d
MIN1 equ 0x4f
MIN2 equ 0x20
HOR1 equ 0x24
HOR2 equ 0x28
SAVE equ 0x5a
EVENTO equ 0x5d
reg1 equ 0x5f
reg2 equ 0x3f
reg3 equ 0x3A
DATOLCD equ 0x3d
org 0x00
goto inicio
org 0x05
inicio movlw 0x07
movwf CMCON
call bancouno
clrf TRISB
clrf TRISA
call bancocero
call LCD_INITIALIZATION
call relojRESET
goto seg1
again clrf SEG1
clrf SEG2
clrf MIN1
clrf MIN2
clrf HOR1
clrf HOR2
clrf EVENTO
clrf SAVE
call q
seg1 call ubicoLCDseg1
call ret1segconLCD ;me ubico
incf SEG1,f
movf SEG1,w
call tabla
movwf SAVE
movf SAVE,w
xorlw 0x00
btfss STATUS,Z
goto $+2
goto seg2
movf SAVE,w
call escribe
call retardo
goto seg1
seg2 clrf SEG1
call y
incf SEG2,f
movf SEG2,w
call tabla
movwf SAVE
xorlw '6'
btfss STATUS,Z
goto $+2
goto min1
call ubicoLCDseg2
movf SAVE,w
call escribe
call retardo
goto seg1
min1
clrf SEG2
call t
incf MIN1,f
movf MIN1,w
call tabla
movwf SAVE
xorlw 0x00
btfss STATUS,Z
goto $+2
goto min2
call ubicoLCDmin1
movf SAVE,w
call escribe
call retardo
goto seg1
min2
clrf MIN1
call r
incf MIN2,f
movf MIN2,w
call tabla
movwf SAVE
xorlw '6'
btfss STATUS,Z
goto $+2
goto hor1
call ubicoLCDmin2
movf SAVE,w
call escribe
call retardo
goto seg1
hor1 clrf MIN2
call e
incf HOR1,f
movf HOR1,w
call tabla
movwf SAVE
xorlw '4'
btfss STATUS,Z
goto d
movf SAVE,w
btfss EVENTO,0
goto d
goto again
d movf SAVE,w
xorlw 0x00
btfss STATUS,Z
goto $+2
goto hor2
call ubicoLCDhor1
movf SAVE,w
call escribe
call retardo
goto seg1
hor2 clrf HOR1
call w
incf HOR2,f
movf HOR2,w
call tabla
movwf SAVE
xorlw '2'
btfss STATUS,Z
goto $+2
bsf EVENTO,0
call ubicoLCDhor2
movf SAVE,w
call escribe
call retardo
goto seg1
tabla addwf PCL,f
retlw '0'
retlw '1'
retlw '2'
retlw '3'
retlw '4'
retlw '5'
retlw '6'
retlw '7'
retlw '8'
retlw '9'
retlw 0x00
bancocero bcf STATUS,RP0
bcf STATUS,RP1
return
bancouno bsf STATUS,RP0
bcf STATUS,RP1
return
q call ubicoLCDhor2
movlw '0'
call escribe
call retardo
w call ubicoLCDhor1
movlw '0'
call escribe
call retardo
e call ubicoLCDmin2
movlw '0'
call escribe
call retardo
r call ubicoLCDmin1
movlw '0'
call escribe
call retardo
t call ubicoLCDseg2
movlw '0'
call escribe
call retardo
y call ubicoLCDseg1
movlw '0'
call escribe
call retardo
return
ubicoLCDhor2
movlw b'10000000'
call LCD_REGSWAP
call retardo
return
ubicoLCDhor1
movlw b'10000001'
call LCD_REGSWAP
call retardo
return
ubicoLCDmin2
movlw b'10000011'
call LCD_REGSWAP
call retardo
return
ubicoLCDmin1
movlw b'10000100'
call LCD_REGSWAP
call retardo
return
ubicoLCDseg2
movlw b'10000110'
call LCD_REGSWAP
call retardo
return
ubicoLCDseg1
movlw b'10000111'
call LCD_REGSWAP
call retardo
return
relojRESET
movlw '0'
call escribe
call retardo
movlw '0'
call escribe
call retardo
movlw ':'
call escribe
call retardo
movlw '0'
call escribe
call retardo
movlw '0'
call escribe
call retardo
movlw ':'
call escribe
call retardo
movlw '0'
call escribe
call retardo
movlw '0'
call escribe
call retardo
return
LCD_INITIALIZATION
call retardo
movlw b'00110000'
call LCD_REG
call retardo
movlw b'00110000'
call LCD_REG
call retardo
movlw b'00110000'
call LCD_REG
call retardo
movlw b'00100000'
call LCD_REG
call retardo
MOVLW b'00101000'
call LCD_REGSWAP
call retardo
MOVLW b'00000001' ;Borrar LCD y Home
CALL LCD_REGSWAP
call retardo
MOVLW b'00000110'
CALL LCD_REGSWAP
call retardo
MOVLW b'00001100' ;LCD On, cursor Off,Parpadeo Off
CALL LCD_REGSWAP
call retardo
MOVLW b'10000000' ;Direccion caracter
CALL LCD_REGSWAP
call retardo
return
LCD_REG bcf PORTA,0
movwf PORTB
goto ENABLE
ENABLE bsf PORTA,1
nop
bcf PORTA,1
return
LCD_REGSWAP bcf PORTA,0
movwf DATOLCD
movf DATOLCD,w
andlw b'11110000'
movwf PORTB
bsf PORTA,1
nop
bcf PORTA,1
swapf DATOLCD,w
andlw b'11110000'
movwf PORTB
goto ENABLE
escribe bsf PORTA,0
movwf DATOLCD
movf DATOLCD,w
andlw b'11110000'
movwf PORTB
bsf PORTA,1
nop
bcf PORTA,1
swapf DATOLCD,w
andlw b'11110000'
movwf PORTB
goto ENABLE
retardo movlw 0x10
movwf reg2
movlw 0xff
movwf reg1
decfsz reg1,f
goto $-1
decfsz reg2,f
goto $-5
return
retardogosu
movlw 0x10
movwf reg3
movlw 0xff
movwf reg2
movlw 0xff
movwf reg1
decfsz reg1,f
goto $-1
decfsz reg2,f
goto $-5
decfsz reg3,f
goto $-9
return
ret1segconLCD nop ; para la simulacion.
return
; x ejemplo aca la tabla y no anda :(
end