Vous êtes sur la page 1sur 4

list #include s

p=16f877A ; list directive to define processor <p16f877A.inc> ; processor specific variable definition

__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _HS_OSC & _WRT_OF F & _LVP_OFF & _CPD_OFF errorlevel -302 ;***** VARIABLE ;nueve portb_temp portb_ini EQU xor_temp EQU w_temp status_temp pclath_temp DEFINITIONS EQU 0x23 EQU 0x7A 0x7B 0x7C EQU 0x7D EQU 0x7E EQU 0x7F

; variable used for context saving ; variable used for context saving ; variable used for context saving

;********************************************************************** ORG 0x000 ; processor reset vector goto ORG movwf movf movwf movf movwf movf movwf temp goto Rutina_Interrupcion ; retrieve copy of PCLATH register ; restore pre-isr PCLATH register contents ; retrieve copy of STATUS register ; restore pre-isr STATUS register contents ; guarda el valor del protb que activo l ; restore pre-isr W register contents ; return from interrupt Salir_Interrupcion: movf pclath_temp,w movwf PCLATH movf status_temp,w movwf STATUS movf portb_temp,w movwf portb_ini a interrupcion en port_ini swapf w_temp,f swapf w_temp,w retfie main 0x004 w_temp STATUS,w status_temp PCLATH,w pclath_temp PORTB,w portb_temp ; go to beginning of program ; interrupt vector location ; save off current W register contents ; move status register into W register ; save off contents of STATUS register ; move pclath register into w register ; save off contents of PCLATH register ; guarda el valor del puerto b en portb_

main ;Configuracin**** clrf PORTC ;Banco1 bsf bcf clrf TRISC bsf STATUS,RP0 STATUS,RP1 ; portD=salida TRISB,0

bsf bsf movlw movwf ;Banco0 bcf bcf movlw movwf bsf bsf bsf

TRISB,4 TRISB,5 0x87 OPTION_REG STATUS,RP0 STATUS,RP1 .206 TMR0 INTCON,GIE INTCON,T0IE INTCON,RBIE

; RB0, RB1, RB2=entradas ; configura el TMR0

; carga el TMR0 ; Permite las interrupciones ; Habilita la interrupcion por T ; Habilita la interrupcion por RB4-R ; guarda el valor del portb antes de la

MRO B7 movf PORTB,w movwf portb_ini interrupcion IRB PP: ; nop Reset: CLRF digito ; goto elegir_modo ;elegir_modo: ; BTFSC ; goto ; goto Siguiente: MOVF CALL MOVWF CALL INCF MOVF XORLW BTFSC GOTO ; CLRF GOTO modo; Anterior Siguiente digito,W Tabla PORTC delay_1s digito,F digito,W 0x0A STATUS,Z Reset modo Siguiente ; ; ; ; ; ; ; ; ;

; ;

Anterior: ; CLRF modo ; INCF modo,F MOVF digito,W XORLW 0x00 BTFSS STATUS,Z ua si son iguales) GOTO Hacer_Nueve GOTO Decremento Decremento: DECF MOVF CALL MOVWF CALL ; MOVF digito,F digito,W Tabla PORTC delay_1s digito,W

; ; ; ; ; ; ; ;

XORentre drigito y 0x00 salta si es 1(salta si son diferentes,contin

; ; ; ;

XORLW BTFSC MOVLW MOVWF GOTO

0x00 STATUS,Z 0X09 digito Anterior

; ; ; ; ; ; ; ;

Hacer_Nueve: MOVLW 0x09 MOVWF digito CALL Tabla MOVWF PORTC CALL delay_1s DECF digito,F GOTO Anterior Tabla: ADDWF RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW goto PCL,F 0xFC 0x60 0xDA 0xF2 0x66 0xB6 0xBE 0xE0 0xFE 0xF6 PP ; ; ; ; ; ; ; ; ; ; ; 0 1 2 3 4 5 6 7 8 9 en en en en en en en en en en

cdigo cdigo cdigo cdigo cdigo cdigo cdigo cdigo cdigo cdigo

7 7 7 7 7 7 7 7 7 7

segmentos segmentos segmentos segmentos segmentos segmentos segmentos segmentos segmentos segmentos

Rutina_Interrupcion: btfsc INTCON,T0IF goto Rut_TMR0 btfsc INTCON,RBIF ; pregunta si se interrumpio por IRB goto Rut_IRB ;*** goto Salir_Interrupcion Rut_TMR0: movlw movwf btfss goto goto HacerD0_0: bcf goto HacerD0_1: bsf .206 TMR0 PORTC,0 HacerD0_1 HacerD0_0 PORTC,0 Salir_IntTMR0 PORTC,0

Salir_IntTMR0: bcf INTCON,T0IF goto Salir_Interrupcion

Rut_IRB: movf portb_temp,w xorwf portb_ini,w movwf xor_temp _temp btfsc xor_temp,4 cambio. si 1, rb4 cambio goto Int_RB4 goto Salir_IRB

; hace portb xor portb_ini y lo guarda en xor ; pregunta quien ha cambiado. si 0, rb5

Int_RB4: btfsc portb_temp,4 flanco de bajada. si 1, flanco de subida goto Pulso_RB4 goto Salir_IRB

; pregunta por el flanco. si 0,

Pulso_RB4:

MOVF XORLW BTFSC en decremento) ;goto ;goto ;cambiar_modo: GOTO GOTO ;goto

modo,W ; 0x00 STATUS,Z cambiar_modo Salir_IRB

; ; si es cero aslta (0 esta en incremento 1 esta

Siguiente Anterior Salir_IRB

Salir_IRB: bcf goto

INTCON,RBIF Salir_Interrupcion

include "ModDelay10M.asm" include "maintabla.asm" END ; directive 'end of program'

Vous aimerez peut-être aussi