Codigo mplab de un contador con pic16f84
#include
; ************************** IGUALDADES***************************
w EQU 0 ; Destino w
f EQU 1 ; Destino f
STATUS EQU 03h ; Registro del STATUS
PORTA EQU 05h ; Registro Puerto A
PORTB EQU 06h ; Registro Puerto B
RP0 EQU 05h; Bit 5 del Registro STATUS
RP1 EQU 06h ; Bit 6 del Registro STATUS
Z EQU 02h ; Bit 1 del Registro STATUS
; ******************* IGUALDADES DE REGISTROS PARTICULARES*******************
REGA EQU 0X12 ; Registro A
REGX EQU 0x14 ; Registro X
; ************************* INICIALIZACION *************************
ORG 0 ; Posición del vector RESET.GOTO INICIO ; Comienza el programa después del vector de interrupción.
ORG 5 ; Una posición después de la interrupción.
; ***************************** PROGRAMA*****************************
INICIO bsf STATUS, RP1 ;
bcf STATUS, RP0 ; selecciona página 01.
clrf TRISA ; convierte el puerto A en salida.
movlw 0xFF
movwf TRISB ; convierte elpuerto B en entrada.
bcf STATUS, RP0 ; vuelve a la página 00.
movlw 0x08
movwf REGA ; carga en REGC un valor medio
SIGUE btfss PORTB, 7 ; se examina en bit 7 de PORTBgoto ARRIBA
goto ABAJO
ARRIBA movf REGA, 0
movwf PORTA
call RETARD
incf REGA, 1 ; se incrementa REGA un bit
movlw 0x10subwf REGA, 0 ; se examina si REGA sigue
btfss STATUS, 2 ; siendo menor o igual a 0F
goto SIGUE
clrf REGA ; si REGA es mayor a 0F se recarga con 00nop
goto SIGUE
ABAJO movf REGA, 0
movwf PORTA
call RETARD
decf REGA, 1 ; se decrementa REGA un bit
movlw 0xFF
subwf...
Regístrate para leer el documento completo.