Fabian Eduardo García
correos: wilmer_5050@hotmail.com
fabigarcia.48@hotmail.com
CONTADOR 7 SEGMENTOS DE 0-99
MATERIALES:
- PROTOBOAR
- PIC16F877A
- CRISTAL CUARZO 20MHZ
- 2 DISPLAY 7 SEGEMNTOS
- 2 TRANSISTORES 2N3904
- 2 CONDENSADORES DE 22 PICOS(CERAMICOS
- UNA RESISTENCIA DE 10K Y UNA DE 330 OHM
- 3 PULSADORES
CÓDIGO DEL PIC
list p=16f877a
#include <p16f877a.inc>
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _HS_OSC & _WRT_OFF & _LVP_OFF & _CPD_OFF
cblock 0x20
delay1
delay2
delay3
Unidades
Decenas
endc
#define _kte_delay3 h'0F'
org 0
goto Start
Configuración
clrf PORTB
bsf STATUS,RP0
movlw B'00000110'
movwf ADCON1
movlw 0xFF
movwf TRISA
clrf TRISB
clrf TRISC
bcf STATUS,RP0
return
MainLoop
call Configuración
clrf PORTB
clrf Unidades
clrf Decenas
Ver
call Mostrar
call Mostrar
return
Start
call Configuración
call Mostrar
btfsc PORTA,0
goto Incremento
PORTA,1
goto Decremento
goto Start
Incremento
call Ver
incf Unidades,F
movlw .10
xorwf Unidades,W
btfsc STATUS,Z
goto Incremento_Decenas
call Mostrar
goto Start
Incremento_Decenas
clrf Unidades
incf Decenas,F
movlw .10
xorwf Decenas,W
btfsc STATUS,Z
clrf Decenas
call Mostrar
goto Start
Decremento
call Ver
decf Unidades,F
movlw .210
xorwf Unidades,W
btfsc STATUS,Z
goto Decremento_Decenas
call Mostrar
goto Start
DDecenas
movlw .10
movwf Unidades
decf Decenas,F
movlw .100
xorwf Decenas,W
btfsc STATUS,Z
goto Start
movlw .10
movlw Decenas
call Mostrar
goto Start
tabla
addwf PCL,F
retlw 3Fh ; "0".
retlw 06h ; "1".
retlw 5Bh ; "2".
retlw 4Fh ; "3".
retlw 66h ; "4".
retlw 6Dh ; "5".
retlw 7Dh ; "6".
retlw 07h ; "7".
retlw 7Fh ; "8".
retlw 67h ; "9".
Delay
movlw _kte_delay3
movwf delay3
Loop:
decfsz delay1,f
goto Loop
decfsz delay2,f
goto Loop
decfsz delay3,f
goto Loop
return
Mostrar
movf Unidades,W
call Tabla_Code_7_Seg
bsf PORTC,5
bcf PORTC,4
movwf PORTB
call Delay
movf Decenas,W
call Tabla_Code_7_Seg
bcf PORTC,5
bsf PORTC,4
movwf PORTB
call Delay
return
end
ESPERO QUE LES SIRVA





