Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Hacemos parpadear un led cuando se pulsa un botón,
- ; y permanece apagado cuando el botón no está siendo
- ; pulsado.
- ; PORTA,0----Pulsador
- ; PORTB,0----LED
- ;----------ZONA DE CONFIGURACIÓN--------------------------
- #include <p16f84a.inc>
- LIST p=16f84a
- __CONFIG _RC_OSC & _WDT_ON & _PWRTE_OFF & _CP_OFF
- ;---------ZONA DE CÓDIGO---------------------------------
- org 0
- tiempo EQU 0xC
- puertos
- bsf STATUS,RP0 ; Banco 1
- clrf TRISB ;Configuramos portB completo como salida
- movwf 0x01 ;Movemos 00000001 al registro W
- movwf TRISA ;Configuramos el bit 1 del puerto A como entrada
- bcf STATUS,RP0 ;Banco 0
- clrf PORTB ;Apagamos todas las salidas del puerto B
- call reset_tiempo ;Asigna 255 a tiempo
- loop
- btfsc PORTA,0 ;Si el botón está pulsado, ejecuta blink,
- goto blink ;si no está pulsado, vuelve a comprobar
- goto loop ;
- blink ;
- bsf PORTB,0 ;Encendemos el led
- call delay ;retardo
- bcf PORTB,0 ;Apagamos el led
- call delay ;retardo
- goto loop ;Volvemos a la comprobación del botón
- delay
- decfsz tiempo ;Decrementa tiempo y regresa cuando tiempo=0
- goto delay ;
- call reset_tiempo ;Tiempo=255
- return ;
- reset_tiempo
- movlw d'255' ;Cargamos 255 decimal al registro W
- movwf tiempo ;movemos W a tiempo, tiempo=d'255'
- return
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement