SHOW:
|
|
- or go back to the newest paste.
| 1 | LIST P=16F84A | |
| 2 | INCLUDE <P16F84A.INC> | |
| 3 | __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC | |
| 4 | ; | |
| 5 | CBLOCK 0x0C ;Inicio del bloque de RAM | |
| 6 | Contador ;Variable Contador | |
| 7 | - | Limite ;Variable Limite |
| 7 | + | Limite ;Variable Limite |
| 8 | ENDC ;Fin del bloque de RAM | |
| 9 | ; | |
| 10 | #DEFINE Pulsador PORTB,0 ;Se redefine RB0 como Pulsador | |
| 11 | ; | |
| 12 | org 0 ;Inicio de la memoria | |
| 13 | goto Inicio ;Salta a Inicio | |
| 14 | org 4 ;Vector de interrupcion | |
| 15 | goto Interrupcion ;Salta a Interrupcion | |
| 16 | - | Inicio movlw b'00011111' ;Cargo W con 32 |
| 16 | + | Inicio movlw b'00011111' ;Cargo W con 32 |
| 17 | - | movwf Limite ;Cargo la variable Limite con 32 |
| 17 | + | movwf Limite ;Cargo la variable Limite con 32 |
| 18 | - | bsf STATUS,RP0 ;Acceso al Banco 1 |
| 18 | + | bsf STATUS,RP0 ;Acceso al Banco 1 |
| 19 | bsf Pulsador ;RB0/INT se configura como entrada. | |
| 20 | bsf OPTION_REG,INTEDG ;Interrupcion INT se activa por flanco de subida | |
| 21 | bcf STATUS,RP0 ;Acceso al Banco 0 | |
| 22 | clrf Contador ;Inicializa el contador | |
| 23 | movwf PORTA ;Mueve el valor del contador al puerto A | |
| 24 | movlw b'10010000' ;Habilita la interrupcion INT | |
| 25 | movwf INTCON ;Habilita la interrupcion General | |
| 26 | ; | |
| 27 | Main sleep ;Pasa a modo de bajo consumo | |
| 28 | goto Principal ;Salta a Main | |
| 29 | ; | |
| 30 | Interrupcion | |
| 31 | btfss Pulsador ;Comprueba si se preciona el pulsador | |
| 32 | goto FinInterrupcion ;Si no esta presionado salta a FinInterrupcion | |
| 33 | incf Contador,F ;Si esta presionado incrementa el contador | |
| 34 | - | sublw Limite ;Resta Limite a W (El contador) |
| 34 | + | sublw Limite ;Resta Limite a W (El contador) |
| 35 | - | btfsc STATUS,Z ;Si la resta es 0 llego a 32 y salta una posicion |
| 35 | + | btfsc STATUS,Z ;Si la resta es 0 llego a 32 y salta una posicion |
| 36 | - | goto FinInterrupcion ;Si no llego a 32, sigue a FinInterrupcion |
| 36 | + | goto FinInterrupcion ;Si no llego a 32, sigue a FinInterrupcion |
| 37 | - | clrf Contador ;Reinicia a 0 el contador |
| 37 | + | clrf Contador ;Reinicia a 0 el contador |
| 38 | ; | |
| 39 | FinInterrupcion | |
| 40 | bcf INTCON,INTF ;Limpia flag de reconocimiento (INTF) | |
| 41 | retfie ;Retorna y rehabilita las interrupciones (GIE=1) | |
| 42 | ; | |
| 43 | end |