hola a todos os escribo por que necesito que me hechen una mano si es posible. Antes de nada utilizo niple completo con llave usb, he estado creando que describo a contnuacion:
Son 2 Circuitos:
1º CIRCUITO: Utilizando un pic 16f873A con cristal de 4Mhz, lcd 16x2, teclado matricial 4x4 y ds75176. El programa debe hacer lo siguiente:
Mostrar mensaje INTROD. PRECIO, despues tecleamos el precio (este debe ser de 4 cifras Obligatoriamente), cuando hemos introducido el precio Mostrar en pantalla PRECIO X.xxx, Cuando X (mayuscula) es diferente a E (hexadecimal) mostrar INTROD. PRODUCTO y Segun si pulsamos F1, F2, F3 o F4 Mostrara el nombre del producto con su precio previamente introducido. Despues de todo es viene la comunicacion RS485 y funciona si RA1 es igual a 1 Mandando 5 registros, Siendo el primero el indice de producto y los cuatro restantes el precio.
Bien despues de todo esto. Lo pruebo en proteus y funciona bien pero en protoboard no anda muy alla. Os adjunto el asambler.
;------------------------------------------------------------
; Código assembler generado por Niple V6.0.1
; Proyecto: teclado lcd
; Autor: ----------
; Fecha: 07/05/2009
; Fabricante: Microchip
; PIC: 16F873A
; Velocidad de reloj: 10 Mhz
; Descripcion: Teclado con comunicacion rs485 y visualizacion en lcd 16x2
;------------------------------------------------------------
LIST P=PIC16F873A
_HS_OSC equ 0x3FFE
_DEBUG_OFF equ 0x3FFF
_WDT_OFF equ 0x3FFB
_PWRTE_ON equ 0x3FF7
_BODEN_OFF equ 0x3FBF
_LVP_OFF equ 0x3F7F
_CPD_OFF equ 0x3FFF
_CP_OFF equ 0x3FFF
_WRT_ENABLE_OFF equ 0x3DFF
__config _HS_OSC & _DEBUG_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_OFF & _LVP_OFF & _CPD_OFF & _WRT_ENABLE_OFF & _CP_OFF
;------------------------------------------------------------
; Declaración de Registros
;------------------------------------------------------------
w equ 0x0000
pcl equ 0x0002
status equ 0x0003
porta equ 0x0005
portb equ 0x0006
portc equ 0x0007
pclath equ 0x000a
intcon equ 0x000b
pir1 equ 0x000c
rcsta equ 0x0018
txreg equ 0x0019
_np_w equ 0x0020
contador_tecla equ 0x0021
tecla equ 0x0022
num_display equ 0x0023
unid equ 0x0024
dece equ 0x0025
cent equ 0x0026
mil equ 0x0027
_np_status equ 0x0028
_np_banderas2 equ 0x0029
_np_temp1 equ 0x002a
_np_temp2 equ 0x002b
_np_temp3 equ 0x002c
_np_resultado equ 0x002f
_np_indice equ 0x0030
_np_tec equ 0x0031
_np_nro_lcd equ 0x0032
_np_msj_act equ 0x0033
_np_nro_msj equ 0x0034
_np_lcd_1 equ 0x0035
_np_tiempo equ 0x0036
_np_tiempo1 equ 0x0038
_np_tiempo2 equ 0x0039
_np_tiempo_inte equ 0x003a
_np_tiempo1_inte equ 0x003c
_np_tiempo2_inte equ 0x003d
_np_tiempo3_inte equ 0x0040
opcion equ 0x0081
trisa equ 0x0085
trisb equ 0x0086
trisc equ 0x0087
txsta equ 0x0098
spbrg equ 0x0099
adcon1 equ 0x009f
;------------------------------------------------------------
; Declaración de Bits
;------------------------------------------------------------
c equ 0 ;carry / borrow bit
gie equ 7 ;habilitador general de interrupciones
ra0 equ 0 ;bit 0 del puerto a
ra1 equ 1 ;bit 1 del puerto a
ra2 equ 2 ;bit 2 delpuerto a
ra3 equ 3 ;bit 3 del puerto a
ra4_t0cki equ 4 ;bit 4 del puerto a o entrada de reloj
ra5 equ 5 ;bit 5 del puerto a
rbie equ 3 ;habilitador de interrupción por cambio de estado puerto b4 a 7
rbif equ 0 ;rb port change interrupt flag bit
rc7 equ 7 ;bit 7 del puerto c
rp0 equ 5 ;registrer bank select bit
rp1 equ 6 ;registrer bank select bit
spen equ 7 ;
txif equ 4 ;bandera de interrupcion por fin de transmisión usart.
z equ 2 ;bit cero
sub_inte equ 0 ;bandera de subrrutina cancelada por interrupcion.
;------------------------------------------------------------
; Inicio
;------------------------------------------------------------
reset org 0
goto paso2
org 4
movwf _np_w
swapf _np_w,1
movf status,w
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
movwf _np_status
btfsc intcon,rbif
goto interrupción_rb47
salir_interrupcion
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
bsf _np_banderas2,sub_inte ;activar la bandera de rutina cancelada por interrupcion
movf _np_status,w
movwf status
swapf _np_w,w
retfie
_np_tabla_teclado
movf _np_indice,0
call _np_tabla_teclado_tabla
movwf _np_resultado
return
_np_tabla_teclado_tabla
addwf pcl,1
retlw 0x00 ; 0
retlw 0x01 ; 1
retlw 0x02 ; 2
retlw 0x03 ; 3
retlw 0xf1 ; f1
retlw 0x04 ; 4
retlw 0x05 ; 5
retlw 0x06 ; 6
retlw 0xf2 ; f2
retlw 0x07 ; 7
retlw 0x08 ; 8
retlw 0x09 ; 9
retlw 0xf3 ; f3
retlw 0x13 ; *
retlw 0x00 ; 0
retlw 0x14 ; #
retlw 0xf4 ; f4
;------------------------------------------------------------
; inicio de la interrupción por rb4 a 7
;------------------------------------------------------------
interrupción_rb47_salir
movf portb,w
bcf intcon,rbif
goto salir_interrupcion
interrupción_rb47
;leer un dato mediante el teclado matricial
call leer_teclado_b0_b1_b2_b3
movf _np_resultado,w
movwf tecla
movlw d'17' ;si el reg tecla < d'17'
subwf tecla,w
btfsc status,c
goto interrupción_rb47_salir
movf tecla,w ;consultar la tabla_np_tabla_teclado
movwf _np_indice
call _np_tabla_teclado
movf _np_resultado,w
movwf tecla
movlw d'4' ;si el reg contador_tecla < d'4'
subwf contador_tecla,w
btfsc status,c
goto inte_rb47_20
incf contador_tecla,1 ;contador_tecla = contador_tecla + 1
movf contador_tecla,w ;si el reg contador_tecla = d'01'
xorlw d'01'
btfss status,z
goto inte_rb47_15
inte_rb47_8
movf tecla,w
movwf unid
call usr_lcd_precio_produc
movf mil,w ;si el reg mil <> 0xe
xorlw 0xe
btfsc status,z
goto interrupción_rb47_salir
movlw .1 ;temporizador 500 mse
call tmp_1_mgc_i
movlw .25
call tmp_100_mc_i
call usr_lcd_intro_produc
inte_rb47_13
goto interrupción_rb47_salir
inte_rb47_15
movf contador_tecla,w ;si el reg contador_tecla = d'02'
xorlw d'02'
btfss status,z
goto inte_rb47_17
inte_rb47_16
movf unid,w
movwf dece
goto inte_rb47_8 ;cierra el ciclo
inte_rb47_17
movf contador_tecla,w ;si el reg contador_tecla = d'03'
xorlw d'03'
btfss status,z
goto inte_rb47_19
inte_rb47_18
movf dece,w
movwf cent
goto inte_rb47_16 ;cierra el ciclo
inte_rb47_19
movf cent,w
movwf mil
goto inte_rb47_18 ;cierra el ciclo
inte_rb47_20
movf tecla,w ;si el reg tecla = 0xf1
xorlw 0xf1
btfss status,z
goto inte_rb47_24
movlw d'1'
movwf num_display
call usr_lcd_sin_95
inte_rb47_23
goto interrupción_rb47_salir
inte_rb47_24
movf tecla,w ;si el reg tecla = 0xf2
xorlw 0xf2
btfss status,z
goto inte_rb47_28
movlw d'2'
movwf num_display
call usr_lcd_sin_98
inte_rb47_27
goto interrupción_rb47_salir
inte_rb47_28
movf tecla,w ;si el reg tecla = 0xf3
xorlw 0xf3
btfss status,z
goto inte_rb47_32
movlw d'3'
movwf num_display
call usr_lcd_diesel
inte_rb47_31
goto interrupción_rb47_salir
inte_rb47_32
movf tecla,w ;si el reg tecla = 0xf4
xorlw 0xf4
btfss status,z
goto interrupción_rb47_salir
movlw d'4'
movwf num_display
call usr_lcd_extra_diesel
inte_rb47_35
goto interrupción_rb47_salir
;------------------------------------------------------------
; programa principal
;------------------------------------------------------------
paso2
ini_reg
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
clrf _np_w
clrf contador_tecla
clrf tecla
clrf num_display
clrf unid
clrf dece
clrf cent
clrf mil
clrf _np_status
clrf _np_banderas2
clrf _np_temp1
clrf _np_temp2
clrf _np_temp3
clrf _np_resultado
clrf _np_indice
clrf _np_tec
clrf _np_nro_lcd
clrf _np_msj_act
clrf _np_nro_msj
clrf _np_lcd_1
clrf _np_tiempo
clrf _np_tiempo1
clrf _np_tiempo2
clrf _np_tiempo_inte
clrf _np_tiempo1_inte
clrf _np_tiempo2_inte
clrf _np_tiempo3_inte
clrf _np_w
n_ini_reg
movlw b'00000010' ;configurar el puerto a como xxsssses
bsf status,rp0 ;cambiar a banco 1
bcf status,rp1
movwf trisa
movlw b'00000111' ;puerto a = e/s digital
movwf adcon1
movlw b'11110000' ;configurar el puerto b como eeeessss
movwf trisb
movlw b'00000000' ;configurar el puerto c como ssssssss
movwf trisc
bcf status,rp0 ;cambiar a banco 0
clrf contador_tecla
clrf tecla
clrf num_display
movlw 0xe
movwf unid
movlw 0xe
movwf dece
movlw 0xe
movwf cent
movlw 0xe
movwf mil
bsf porta,ra0
bsf porta,ra2
bsf porta,ra3
bsf porta,ra4_t0cki
bsf porta,ra5
bsf portc,rc7
movlw b'00000001' ;seleccionar el lcd 1
movwf _np_nro_lcd
clrf _np_lcd_1
call lcd_inicio
call lcd_inicio
call lcd_inicio
call usr_lcd_int_precio
paso20
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
bsf intcon,gie ;activar habilitador general de interrupciones.
bsf intcon,rbie ;activar interrupción por rb4-7.
btfss porta,ra1 ;si el bit ra1 = 0
goto paso23
call usr_transmision
goto paso20 ;cierra el ciclo
paso23
nop
goto paso20 ;cierra el ciclo
;------------------------------------------------------------
; Declaración de Subrutinas
;------------------------------------------------------------
usr_lcd_precio_produc
movlw .6
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
movwf _np_nro_msj
call lcd_mensaje_actual
btfss _np_msj_act,0
goto usr_lcd_precio_produc2nc
movlw b'00001100'
call lcd_comando
movlw b'00000001'
call lcd_comando
usr_lcd_precio_produc2nc
movlw b'10000000'
call lcd_comando
movlw .80 ;p
call lcd_caracter
movlw .82 ;r
call lcd_caracter
movlw .69 ;e
call lcd_caracter
movlw .67 ;c
call lcd_caracter
movlw .73 ;i
call lcd_caracter
movlw .79 ;o
call lcd_caracter
movlw .32 ;espacio
call lcd_caracter
movlw .80 ;p
call lcd_caracter
movlw .82 ;r
call lcd_caracter
movlw .79 ;o
call lcd_caracter
movlw .68 ;d
call lcd_caracter
movlw .85 ;u
call lcd_caracter
movlw .67 ;c
call lcd_caracter
movlw .84 ;t
call lcd_caracter
movlw .79 ;o
call lcd_caracter
movlw b'11000111'
call lcd_comando
movlw .46 ;.
call lcd_caracter
usr_lcd_precio_produc2_var
movlw b'11000110'
call lcd_comando
movf mil,w ;enviar la variable mil al lcd.
addlw .48
call lcd_caracter
movlw b'11001000'
call lcd_comando
movf cent,w ;enviar la variable cent al lcd.
addlw .48
call lcd_caracter
movlw b'11001001'
call lcd_comando
movf dece,w ;enviar la variable dece al lcd.
addlw .48
call lcd_caracter
movlw b'11001010'
call lcd_comando
movf unid,w ;enviar la variable unid al lcd.
addlw .48
call lcd_caracter
usr_lcd_precio_produc3
goto usr_lcd_precio_produc_salir
usr_lcd_precio_produc_salir
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
return
usr_lcd_intro_produc
movlw .1
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
movwf _np_nro_msj
call lcd_mensaje_actual
btfss _np_msj_act,0
goto usr_lcd_intro_produc2nc
movlw b'00001100'
call lcd_comando
movlw b'00000001'
call lcd_comando
usr_lcd_intro_produc2nc
movlw b'10000000'
call lcd_comando
movlw .73 ;i
call lcd_caracter
movlw .78 ;n
call lcd_caracter
movlw .84 ;t
call lcd_caracter
movlw .46 ;.
call lcd_caracter
movlw .32 ;espacio
call lcd_caracter
movlw .80 ;p
call lcd_caracter
movlw .82 ;r
call lcd_caracter
movlw .79 ;o
call lcd_caracter
movlw .68 ;d
call lcd_caracter
movlw .85 ;u
call lcd_caracter
movlw .67 ;c
call lcd_caracter
movlw .84 ;t
call lcd_caracter
movlw .79 ;o
call lcd_caracter
movlw .46 ;.
call lcd_caracter
movlw .46 ;.
call lcd_caracter
usr_lcd_intro_produc3
goto usr_lcd_intro_produc_salir
usr_lcd_intro_produc_salir
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
return
usr_lcd_sin_95
movlw .2
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
movwf _np_nro_msj
call lcd_mensaje_actual
btfss _np_msj_act,0
goto usr_lcd_sin_952nc
movlw b'00001100'
call lcd_comando
movlw b'00000001'
call lcd_comando
usr_lcd_sin_952nc
movlw b'10000000'
call lcd_comando
movlw .83 ;s
call lcd_caracter
movlw .73 ;i
call lcd_caracter
movlw .78 ;n
call lcd_caracter
movlw .32 ;espacio
call lcd_caracter
movlw .80 ;p
call lcd_caracter
movlw .76 ;l
call lcd_caracter
movlw .79 ;o
call lcd_caracter
movlw .77 ;m
call lcd_caracter
movlw .79 ;o
call lcd_caracter
movlw .32 ;espacio
call lcd_caracter
movlw .57 ;9
call lcd_caracter
movlw .53 ;5
call lcd_caracter
movlw b'11000111'
call lcd_comando
movlw .46 ;.
call lcd_caracter
usr_lcd_sin_952_var
movlw b'11000110'
call lcd_comando
movf mil,w ;enviar la variable mil al lcd.
addlw .48
call lcd_caracter
movlw b'11001000'
call lcd_comando
movf cent,w ;enviar la variable cent al lcd.
addlw .48
call lcd_caracter
movlw b'11001001'
call lcd_comando
movf dece,w ;enviar la variable dece al lcd.
addlw .48
call lcd_caracter
movlw b'11001010'
call lcd_comando
movf unid,w ;enviar la variable unid al lcd.
addlw .48
call lcd_caracter
usr_lcd_sin_953
goto usr_lcd_sin_95_salir
usr_lcd_sin_95_salir
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
return
usr_lcd_sin_98
movlw .3
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
movwf _np_nro_msj
call lcd_mensaje_actual
btfss _np_msj_act,0
goto usr_lcd_sin_982nc
movlw b'00001100'
call lcd_comando
movlw b'00000001'
call lcd_comando
usr_lcd_sin_982nc
movlw b'10000000'
call lcd_comando
movlw .83 ;s
call lcd_caracter
movlw .73 ;i
call lcd_caracter
movlw .78 ;n
call lcd_caracter
movlw .32 ;espacio
call lcd_caracter
movlw .80 ;p
call lcd_caracter
movlw .76 ;l
call lcd_caracter
movlw .79 ;o
call lcd_caracter
movlw .77 ;m
call lcd_caracter
movlw .79 ;o
call lcd_caracter
movlw .32 ;espacio
call lcd_caracter
movlw .57 ;9
call lcd_caracter
movlw .56 ;8
call lcd_caracter
movlw b'11000111'
call lcd_comando
movlw .46 ;.
call lcd_caracter
usr_lcd_sin_982_var
movlw b'11000110'
call lcd_comando
movf mil,w ;enviar la variable mil al lcd.
addlw .48
call lcd_caracter
movlw b'11001000'
call lcd_comando
movf cent,w ;enviar la variable cent al lcd.
addlw .48
call lcd_caracter
movlw b'11001001'
call lcd_comando
movf dece,w ;enviar la variable dece al lcd.
addlw .48
call lcd_caracter
movlw b'11001010'
call lcd_comando
movf unid,w ;enviar la variable unid al lcd.
addlw .48
call lcd_caracter
usr_lcd_sin_983
goto usr_lcd_sin_98_salir
usr_lcd_sin_98_salir
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
return
usr_lcd_diesel
movlw .4
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
movwf _np_nro_msj
call lcd_mensaje_actual
btfss _np_msj_act,0
goto usr_lcd_diesel2nc
movlw b'00001100'
call lcd_comando
movlw b'00000001'
call lcd_comando
usr_lcd_diesel2nc
movlw b'10000000'
call lcd_comando
movlw .68 ;d
call lcd_caracter
movlw .73 ;i
call lcd_caracter
movlw .69 ;e
call lcd_caracter
movlw .83 ;s
call lcd_caracter
movlw .69 ;e
call lcd_caracter
movlw .76 ;l
call lcd_caracter
movlw b'11000111'
call lcd_comando
movlw .46 ;.
call lcd_caracter
usr_lcd_diesel2_var
movlw b'11000110'
call lcd_comando
movf mil,w ;enviar la variable mil al lcd.
addlw .48
call lcd_caracter
movlw b'11001000'
call lcd_comando
movf cent,w ;enviar la variable cent al lcd.
addlw .48
call lcd_caracter
movlw b'11001001'
call lcd_comando
movf dece,w ;enviar la variable dece al lcd.
addlw .48
call lcd_caracter
movlw b'11001010'
call lcd_comando
movf unid,w ;enviar la variable unid al lcd.
addlw .48
call lcd_caracter
usr_lcd_diesel3
goto usr_lcd_diesel_salir
usr_lcd_diesel_salir
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
return
usr_lcd_extra_diesel
movlw .5
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
movwf _np_nro_msj
call lcd_mensaje_actual
btfss _np_msj_act,0
goto usr_lcd_extra_diesel2nc
movlw b'00001100'
call lcd_comando
movlw b'00000001'
call lcd_comando
usr_lcd_extra_diesel2nc
movlw b'10000000'
call lcd_comando
movlw .69 ;e
call lcd_caracter
movlw .88 ;x
call lcd_caracter
movlw .84 ;t
call lcd_caracter
movlw .82 ;r
call lcd_caracter
movlw .65 ;a
call lcd_caracter
movlw .32 ;espacio
call lcd_caracter
movlw .68 ;d
call lcd_caracter
movlw .73 ;i
call lcd_caracter
movlw .69 ;e
call lcd_caracter
movlw .83 ;s
call lcd_caracter
movlw .69 ;e
call lcd_caracter
movlw .76 ;l
call lcd_caracter
movlw b'11000111'
call lcd_comando
movlw .46 ;.
call lcd_caracter
usr_lcd_extra_diesel2_var
movlw b'11000110'
call lcd_comando
movf mil,w ;enviar la variable mil al lcd.
addlw .48
call lcd_caracter
movlw b'11001000'
call lcd_comando
movf cent,w ;enviar la variable cent al lcd.
addlw .48
call lcd_caracter
movlw b'11001001'
call lcd_comando
movf dece,w ;enviar la variable dece al lcd.
addlw .48
call lcd_caracter
movlw b'11001010'
call lcd_comando
movf unid,w ;enviar la variable unid al lcd.
addlw .48
call lcd_caracter
usr_lcd_extra_diesel3
goto usr_lcd_extra_diesel_salir
usr_lcd_extra_diesel_salir
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
return
usr_lcd_int_precio
movlw .7
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
movwf _np_nro_msj
call lcd_mensaje_actual
btfss _np_msj_act,0
goto usr_lcd_int_precio2nc
movlw b'00001100'
call lcd_comando
movlw b'00000001'
call lcd_comando
usr_lcd_int_precio2nc
movlw b'10000000'
call lcd_comando
movlw .73 ;i
call lcd_caracter
movlw .78 ;n
call lcd_caracter
movlw .84 ;t
call lcd_caracter
movlw .82 ;r
call lcd_caracter
movlw .79 ;o
call lcd_caracter
movlw .68 ;d
call lcd_caracter
movlw .46 ;.
call lcd_caracter
movlw .32 ;espacio
call lcd_caracter
movlw .80 ;p
call lcd_caracter
movlw .82 ;r
call lcd_caracter
movlw .69 ;e
call lcd_caracter
movlw .67 ;c
call lcd_caracter
movlw .73 ;i
call lcd_caracter
movlw .79 ;o
call lcd_caracter
usr_lcd_int_precio3
goto usr_lcd_int_precio_salir
usr_lcd_int_precio_salir
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
return
usr_transmision
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
movf num_display,w ;enviar el dato num_display
movwf _np_temp1
call rs232_tc6_9600
movf unid,w ;enviar el dato unid
movwf _np_temp1
call rs232_tc6_9600
movf dece,w ;enviar el dato dece
movwf _np_temp1
call rs232_tc6_9600
movf cent,w ;enviar el dato cent
movwf _np_temp1
call rs232_tc6_9600
movf mil,w ;enviar el dato mil
movwf _np_temp1
call rs232_tc6_9600
usr_transmision3
goto usr_transmision_salir
usr_transmision_salir
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
return
leer_teclado_b0_b1_b2_b3
movlw d'100'
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
movwf _np_temp1
leer_teclado_tmp_1
decfsz _np_temp1,1
goto leer_teclado_tmp_1
bcf portb,0
bcf portb,1
bcf portb,2
bcf portb,3
btfss portb,4
goto leer_teclado_pres
btfss portb,5
goto leer_teclado_pres
btfss portb,6
goto leer_teclado_pres
btfss portb,7
goto leer_teclado_pres
clrf _np_tec
leer_teclado_rete
movlw .128
movwf _np_resultado
goto leer_teclado_tmp_2
leer_teclado_pres
movf _np_tec,w
btfss status,z
goto leer_teclado_rete
movlw d'01'
movwf _np_tec
movwf _np_temp1
clrf _np_temp2
leer_teclado_leer_filas
bsf portb,0
bsf portb,1
bsf portb,2
bsf portb,3
btfsc _np_temp1,0
bcf portb,0
btfsc _np_temp1,1
bcf portb,1
btfsc _np_temp1,2
bcf portb,2
btfsc _np_temp1,3
bcf portb,3
movlw d'01'
movwf _np_temp3
btfss portb,4
goto leer_teclado_salir
incf _np_temp3,1
btfss portb,5
goto leer_teclado_salir
incf _np_temp3,1
btfss portb,6
goto leer_teclado_salir
incf _np_temp3,1
btfss portb,7
goto leer_teclado_salir
incf _np_temp3,1
movlw d'4'
addwf _np_temp2,1
bcf status,c
rlf _np_temp1,1
btfss _np_temp1,4
goto leer_teclado_leer_filas
goto leer_teclado_tmp_2
leer_teclado_salir
movf _np_temp2,w
addwf _np_temp3,w
movwf _np_resultado
leer_teclado_tmp_2
bcf portb,0
bcf portb,1
bcf portb,2
bcf portb,3
movlw d'100'
movwf _np_temp1
leer_teclado_retorno
btfss portb,4
goto leer_teclado_ret1
btfss portb,5
goto leer_teclado_ret1
btfss portb,6
goto leer_teclado_ret1
btfss portb,7
goto leer_teclado_ret1
clrf _np_tec
leer_teclado_ret1
decfsz _np_temp1,1
goto leer_teclado_retorno
return
tmp_1_mgc_i
movwf _np_tiempo_inte
goto tmp_1_mgc_i_1
tmp_1_mgc_i_b2
nop
nop
nop
nop
nop
nop
nop
tmp_1_mgc_i_1
movlw .10
movwf _np_tiempo1_inte
tmp_1_mgc_i_b1
nop
nop
movlw .99
movwf _np_tiempo2_inte
tmp_1_mgc_i_bucle0
nop
nop
nop
movlw .200
movwf _np_tiempo3_inte
tmp_1_mgc_i_bucle
nop
nop
decfsz _np_tiempo3_inte,1
goto tmp_1_mgc_i_bucle
nop
nop
nop
decfsz _np_tiempo2_inte,1
goto tmp_1_mgc_i_bucle0
nop
nop
nop
decfsz _np_tiempo1_inte,1
goto tmp_1_mgc_i_b1
decfsz _np_tiempo_inte,1
goto tmp_1_mgc_i_b2
return
tmp_100_mc_i
movwf _np_tiempo_inte
goto tmp_100_mc_i_1
tmp_100_mc_i_b2
nop
nop
nop
nop
nop
nop
nop
tmp_100_mc_i_1
movlw .22
movwf _np_tiempo1_inte
tmp_100_mc_i_b1
movlw .150
movwf _np_tiempo2_inte
tmp_100_mc_i_bucle
decfsz _np_tiempo2_inte,1
goto tmp_100_mc_i_bucle
decfsz _np_tiempo1_inte,1
goto tmp_100_mc_i_b1
nop
decfsz _np_tiempo_inte,1
goto tmp_100_mc_i_b2
return
lcd_inicio
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
movlw .10 ;temporizador 50 mse
call tmp_100_mc
movlw .25
call tmp_1_mc
bcf portc,1
bcf portc,2
bsf portc,3
bcf portc,4
bcf portc,5
bsf portc,1
call lcd_busy
bcf portc,1
bcf portc,2
bsf portc,3
bcf portc,4
bcf portc,5
bsf portc,1
call lcd_busy
movlw b'00101000'
call lcd_comando
movlw b'00101000'
call lcd_comando
movlw .10 ;temporizador 50 mse
call tmp_100_mc
movlw .25
call tmp_1_mc
clrf _np_lcd_1
clrf _np_nro_msj
return
lcd_busy
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
movlw .5 ;temporizador 2 mse
call tmp_1_mc
return
lcd_comando
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
bcf portc,0
movwf _np_temp1
goto lcd_enviar
lcd_caracter
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
bsf portc,0
movwf _np_temp1
lcd_enviar
bcf portc,1
movwf _np_temp1
bcf portc,2
bcf portc,3
bcf portc,4
bcf portc,5
btfsc _np_temp1,4
bsf portc,2
btfsc _np_temp1,5
bsf portc,3
btfsc _np_temp1,6
bsf portc,4
btfsc _np_temp1,7
bsf portc,5
bsf portc,1
call lcd_busy
bcf portc,1
bcf portc,2
bcf portc,3
bcf portc,4
bcf portc,5
btfsc _np_temp1,0
bsf portc,2
btfsc _np_temp1,1
bsf portc,3
btfsc _np_temp1,2
bsf portc,4
btfsc _np_temp1,3
bsf portc,5
bsf portc,1
call lcd_busy
bcf portc,1
call lcd_busy
return
lcd_mensaje_actual
lcd_1
bcf status,rp0 ;cambiar a banco 0
bcf status,rp1
clrf _np_msj_act
movf _np_nro_msj,w
xorwf _np_lcd_1,w
btfss status,z
bsf _np_msj_act,0
movf _np_nro_msj,w
movwf _np_lcd_1
return
rs232_tc6_9600
;enviar un dato rs232 por portc,6 (por usart)
movlw b'00100110'
bsf status,rp0 ;cambiar a banco 1
bcf status,rp1
movwf txsta
movlw .64
movwf spbrg
bcf status,rp0 ;cambiar a banco 0
bsf rcsta,spen
movf _np_temp1,w
movwf txreg
rs232_tc6_9600_eperar
btfss pir1,txif
goto rs232_tc6_9600_eperar
return
tmp_100_mc
movwf _np_tiempo
goto tmp_100_mc_1
tmp_100_mc_b2
nop
nop
nop
nop
nop
nop
nop
tmp_100_mc_1
movlw .22
movwf _np_tiempo1
tmp_100_mc_b1
movlw .150
movwf _np_tiempo2
tmp_100_mc_bucle
decfsz _np_tiempo2,1
goto tmp_100_mc_bucle
decfsz _np_tiempo1,1
goto tmp_100_mc_b1
nop
decfsz _np_tiempo,1
goto tmp_100_mc_b2
return
tmp_1_mc
movwf _np_tiempo
goto tmp_1_mc_1
tmp_1_mc_b1
nop
nop
nop
nop
nop
nop
nop
tmp_1_mc_1
movlw .246
movwf _np_tiempo1
tmp_1_mc_b2
nop
decfsz _np_tiempo1,1
goto tmp_1_mc_b2
nop
nop
nop
nop
nop
decfsz _np_tiempo,1
goto tmp_1_mc_b1
return
;------------------------------------------------------------
; DATOS EN MEMORIA EEPROM
;------------------------------------------------------------
org 0x2100
data 0xff
data 0xff
data 0xff
data 0xff
data 0xff