Subido por Jorge Gonzales

OSCILADOR

Anuncio
list p=16f1829
; PIC16F1829 Configuration Bit Settings
; Assembly source line config statements
#include "p16f1829.inc"
; CONFIG1
; __config 0xC7C4
__CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_ON & _IESO_OFF & _FCMEN_OFF
; CONFIG2
; __config 0xDCFF
__CONFIG _CONFIG2, _WRT_OFF & _PLLEN_OFF & _STVREN_OFF & _BORV_LO & _LVP_OFF
CBLOCK 0x40
CONT
CONT1
CONT2
ENDC
org 0x00
Inicio
;congiguracion del osc interno
BANKSEL OSCCON ;BANCO 1
MOVLW b'01110010' ;Fosc_int = 8Mhz
movwf OSCCON
;configuracion de puertos I/O
BANKSEL PORTA ;BANCO 0
CLRF PORTA
BANKSEL LATA
CLRF LATA
BANKSEL ANSELA ; PINES SON DE TIPO DIGITAL
CLRF ANSELA
BANKSEL TRISA
MOVLW b'00001100'; DEFINIR ENTRADAS Y SALIDAS (1 ENTRADAS 0 SALIDAS) MOVWF TRISA
MOVWF TRISA
BCF OPTION_REG,7
Banksel WPUA ;Banco 4
;movlw b'00001100' ;RA2:PULLUP
;MOVWF WPUA
BSF WPUA,2 ;RA2:PULLUP
BANKSEL PORTA
BANKSEL PORTC ;BANCO 0
CLRF PORTC
BANKSEL LATC
CLRF LATC
BANKSEL ANSELC ; PINES SON DE TIPO DIGITAL
CLRF ANSELC
BANKSEL TRISC
MOVLW b'00000000'; DEFINIR ENTRADAS Y SALIDAS (1 ENTRADAS 0 SALIDAS) MOVWF TRISA
MOVWF TRISC
BEFORECICLO
Call RETARDO Call RETARDO Call RETARDO
Call RETARDO
BANKSEL PORTC
CLRF PORTC
CICLO
BANKSEL PORTA
BTFSC PORTA,RA2 ;LECTURA
GOTO CICLO
Call RETARDO Call RETARDO Call RETARDO
Call RETARDO
LED_UD
BANKSEL PORTC
CLRF PORTC
BSF PORTC,0
BSF PORTC,7 ;LECTURA
BANKSEL PORTA
BTFSC PORTA,RA2
GOTO $+2
GOTO DUB ; SI PRESIONO EL PULSADOR CAMBIO BANKSEL PORTC;FIN LECTURA
CALL RETARDO
BCF PORTC,0
BCF PORTC,7
BSF PORTC,1
BSF PORTC,6 ;LECTURA
BANKSEL PORTA
BTFSC PORTA,RA2
GOTO $+2
GOTO DUB
BANKSEL PORTC;FIN LECTURA
CALL RETARDO
BCF PORTC,1
BCF PORTC,6
BSF PORTC,2
BSF PORTC,5 ;LECTURA
BANKSEL PORTA
BTFSC PORTA,RA2
GOTO $+2
GOTO DUB
BANKSEL PORTC;FIN LECTURA
CALL RETARDO
BCF PORTC,2
BCF PORTC,5
BSF PORTC,3
BSF PORTC,4 ;LECTURA
BANKSEL PORTA
BTFSC PORTA,RA2
GOTO $+2
GOTO DUB
BANKSEL PORTC;FIN LECTURA
CALL RETARDO
BCF PORTC,3
BCF PORTC,4 ;LECTURA
BANKSEL PORTA
BTFSC PORTA,RA2
GOTO LED_UD
DUB
Call RETARDO Call RETARDO Call RETARDO
Call RETARDO
LED_DU
BANKSEL PORTC
CLRF PORTC
BSF PORTC,3
BSF PORTC,4 BANKSEL PORTA ;INICIO LECTURA
BTFSC PORTA,RA2
GOTO $+2
GOTO BEFORECICLO
BANKSEL PORTC;FIN LECTURA
CALL RETARDO
BCF PORTC,3
BCF PORTC,4
BSF PORTC,2
BSF PORTC,5
BANKSEL PORTA ;INICIO LECTURA
BTFSC PORTA,RA2
GOTO $+2
GOTO BEFORECICLO
BANKSEL PORTC;FIN LECTURA
CALL RETARDO
BCF PORTC,2
BCF PORTC,5
BSF PORTC,1
BSF PORTC,6
BANKSEL PORTA ;INICIO LECTURA
BTFSC PORTA,RA2
GOTO $+2
GOTO BEFORECICLO
BANKSEL PORTC;FIN LECTURA
CALL RETARDO
BCF PORTC,1
BCF PORTC,6
BSF PORTC,0
BSF PORTC,7
BANKSEL PORTA ;INICIO LECTURA
BTFSC PORTA,RA2
GOTO $+2
GOTO BEFORECICLO
BANKSEL PORTC;FIN LECTURA
CALL RETARDO
BCF PORTC,0
BCF PORTC,7
BANKSEL PORTA ;INICIO LECTURA
BTFSC PORTA,RA2
GOTO $+2
GOTO BEFORECICLO
GOTO LED_DU ;FIN LECTURA
RETARDO
MOVLW d'5'
MOVWF CONT2
DECFSZ CONT2,F
GOTO $+2
GOTO SALIR
MOVLW d'200'
MOVWF CONT1
DECFSZ CONT1,F
GOTO $+2
GOTO $-7
MOVLW d'165'
MOVWF CONT
DECFSZ CONT,F
GOTO $-1
GOTO $-7
SALIR RETURN
COMPROBAR
BANKSEL PORTA
BTFSS PORTA,RA2
GOTO LED_DU
BANKSEL PORTC
SALIDA
END
Descargar