PIC 16F84A
Publicado por Daniel (3 intervenciones) el 23/04/2007 16:49:16
Hola a todos/as soy principiante en esto. Estoy intentando leer las entradas configuradas en el Puerto B pero no hay manera. En este codigo estoy intentando leer una entrada y activar una salida del puertoA. Estoy haciendo lago mal?
Gracias adelantadas.
; ZONA DE DATOS **********************************************************************
LIST P=16F84A
INCLUDE <P16F84A.INC>
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
CBLOCK 0x0C
ENDC
#DEFINE salidahopper PORTA,0 ;
#DEFINE In1 PORTB,0 ; Billete 5€
#DEFINE In2 PORTB,1 ; Billete 10€
#DEFINE In3 PORTB,2 ; Billete 20€
#DEFINE In4 PORTB,3 ; Billete 50€
#DEFINE In5 PORTB,4
#DEFINE In6 PORTB,5
#DEFINE In7 PORTB,6
#DEFINE In8 PORTB,7
; ZONA DE CÓDIGOS ********************************************************************
ORG 0 ; El programa comienza en la dirección 0.
Inicio
bsf STATUS,RP0 ; Acceso al Banco 1.
bsf In1 ; Línea del pulsador configurada como entrada.
bsf In2
bsf In3
bsf In4
bsf In5
bsf In6
bsf In7
bsf In8
bcf OPTION_REG,NOT_RBPU
bcf OPTION_REG,INTEDG
bcf STATUS,RP0
bcf salidahopper
movlw b'10010000
movfw INTCON
Principal
btfss In1 ;Ves si está a cero
goto Es_0 ; Es cero
goto Es_1 ;no Es cero
Es_0
bcf salidahopper
goto Principal
Es_1
bsf salidahopper
goto Principal
;INCLUDE <RETARDOS.INC> ; Subrutinas de retardo.
END
Gracias adelantadas.
; ZONA DE DATOS **********************************************************************
LIST P=16F84A
INCLUDE <P16F84A.INC>
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
CBLOCK 0x0C
ENDC
#DEFINE salidahopper PORTA,0 ;
#DEFINE In1 PORTB,0 ; Billete 5€
#DEFINE In2 PORTB,1 ; Billete 10€
#DEFINE In3 PORTB,2 ; Billete 20€
#DEFINE In4 PORTB,3 ; Billete 50€
#DEFINE In5 PORTB,4
#DEFINE In6 PORTB,5
#DEFINE In7 PORTB,6
#DEFINE In8 PORTB,7
; ZONA DE CÓDIGOS ********************************************************************
ORG 0 ; El programa comienza en la dirección 0.
Inicio
bsf STATUS,RP0 ; Acceso al Banco 1.
bsf In1 ; Línea del pulsador configurada como entrada.
bsf In2
bsf In3
bsf In4
bsf In5
bsf In6
bsf In7
bsf In8
bcf OPTION_REG,NOT_RBPU
bcf OPTION_REG,INTEDG
bcf STATUS,RP0
bcf salidahopper
movlw b'10010000
movfw INTCON
Principal
btfss In1 ;Ves si está a cero
goto Es_0 ; Es cero
goto Es_1 ;no Es cero
Es_0
bcf salidahopper
goto Principal
Es_1
bsf salidahopper
goto Principal
;INCLUDE <RETARDOS.INC> ; Subrutinas de retardo.
END
Valora esta pregunta
0