You are on page 1of 4

__CONFIG _FOSC_XT & _WDTE_OFF & _PWRTE_OFF & _BOREN_OFF & _LVP_OFF & _CPD_OFF &

_WRT_OFF & _CP_OFF
LIST P=16F877A
INCLUDE <P16F877A.INC>
RADIX HEX
;ZONA ETIQUETAS----------------------------------------------------------------
CBLOCK 0x20
CONTA_0
CONTA_1
CONTA_2
CONTA_3
CONTA_4
GRADO
UN
DEC
DATO
VALOR_1
VALOR_2
ENDC
;ZONA DE MACROS----------------------------------------------------------------
MOVLF MACRO K,F
MOVLW K
MOVWF F
ENDM

MOVFF MACRO F1,F2
MOVF F1,0
MOVWF F2
ENDM

;ZONA DE PROGRAMACION----------------------------------------------------------
ORG 0x00
GOTO INICIO

ORG 0x05
INICIO
CALL INIC_ADC
CALL INIC_A
CALL INIC_C
CALL INIC_D
PROGRAMA_PRINCIPAL
BCF STATUS,5
BCF STATUS,6;BANCO_0-----------------------------------------------------------
CALL INIC_REG
CONVERSOR_ADC
CALL ADC_ON
INICIO_CONVER
;CALL INIC_REG
CALL TIME_ADQ
BSF ADCON0,2
TEST_CONVER
BTFSC ADCON0,2
GOTO TEST_CONVER

BSF STATUS,5
BCF STATUS,6
MOVF ADRESL,0

BCF STATUS,5

0 GOTO VISUALIZAR INCF DEC MOVLW D'10' SUBWF UN.0 MOVWF PORTD MOVLF B'00000001'.PORTC CALL RETARDO_5ms CLRF PORTD CLRF PORTC MOVF UN.ZONA DE SUBRUTINAS------------------------------------------------------------ INIC_ADC BANKSEL ADCON1 .0 CALL TABLA MOVWF PORTD MOVLF B'00000010'.0 BTFSS STATUS.0 RRF DATO.1 .0 CALL TABLA MOVWF PORTD MOVLF B'00000100'.0 MOVWF UN CARGA MOVLW D'10' BSF STATUS. BCF STATUS.2 MOVLW D'10' SUBWF DEC.6 MOVWF DATO BCF STATUS.FIN GOTO CARGA CLRF UN CLRF DEC GOTO VISUALIZAR VISUALIZAR MOVF GRADO.0 SUBWF UN.PORTC CALL RETARDO_5ms CLRF PORTD CLRF PORTC MOVF DEC.PORTC CALL RETARDO_5ms CLRF PORTD CLRF PORTC GOTO PROGRAMA_PRINCIPAL .2 .ALTERNATIVOS BCF STATUS.0 BTFSS STATUS.1 MOVF DATO.

DEC RETURN TABLA ADDWF PCL.0 RETURN ADC_OFF BCF ADCON0.PORTA RETURN INIC_C BANKSEL TRISC MOVLF 0x00.1 RETLW 0x3F .MOVLF B'10001110'.ADCON0 RETURN INIC_A BANKSEL TRISA MOVLF 0x01.PORTC RETURN INIC_D BANKSEL TRISD MOVLF 0x00.DATO MOVLF 0x00.TRISA BANKSEL PORTA MOVLF 0x00.CONTA_0 NOP DECFSZ CONTA_0.VALOR_1 MOVLF 0x00.PORTD RETURN ADC_ON BSF ADCON0.0 RETURN TIME_ADQ MOVLF 0x0F.1 RETLW 0x5B .CONTA_0 MOVLF 0x00.GRADO MOVLF 0x00.TRISC BANKSEL PORTC MOVLF 0x00.TRISD BANKSEL PORTD MOVLF 0x00.4 RETLW 0x6D . CON JUSTIFICACION A LA DERECHA BANKSEL ADCON0 MOVLF B'01000001'.3 RETLW 0x66 .1 GOTO $-1 RETURN INIC_REG MOVLF 0x00.VALOR_2 MOVLF 0x61.ADCON1.0 RETLW 0x06 .SE CONFIGURO COMO ANALOGICO EL RA0.2 RETLW 0x4F .5 .UN MOVLF 0x00.

6 RETLW 0x07 .9 RETARDO_1ms MOVLF 0xF7.8 RETLW 0x67 .7 RETLW 0x7F . RETLW 0x7D .CONTA_1 NOP DECFSZ CONTA_1 GOTO $-2 RETURN RETARDO_5ms MOVLF 0x05.CONTA_2 CALL RETARDO_1ms DECFSZ CONTA_2 GOTO $-2 RETURN END .