Академический Документы
Профессиональный Документы
Культура Документы
CPU ROM
ROM
RAM
RAM
PUERTOS CPU PUERTOS
PERIFERICOS
PERIFERICOS
MICROCONTROLADOR MICROPROCESADOR
PIC 16F84A
Memoria de
Unidad
Bus común de
direcciones Instrucciones
Central
8
+
De
Bus de Datos
Proceso Datos e
Instrucciones
10 9
Unidad Memoria de
Bus de dirección Bus dirección
Memoria de de instrucciones de datos
Central Datos
Instrucciones
14 De 8
1K x 14
Bus de Bus de
instrucciones Proceso Datos 512 x 8
PC
NIVEL 1
NIVEL 2
03FF H
NIVEL 3
0400 H .
.
NO IMPLEMENTADO .
NIVEL 8
1FFF H
13 0
MEMORIA DE DATOS
INDF INDF
TMR0 OPTION
PCL PCL
ESTADO ESTADO
FSR FSR
PUERTO A TRIS A
SFR PUERTO B TRIS B
EEDATA EECON1
EEADR EECON2
PCLATH PCLATH
INTCON INTCON
68 REGISTROS
GPR MAPEADOS EN
DE PROPOSITO
EL BANCO 0
GENERAL
BANCO 0 BANCO 1
CONFIGURACIÓN PUERTOS PIC 16F84
REGISTRO TRISB (BANCO 1)
1 1 1 1 0 0 0 0
RB7 . . . RB0
- - - 1 0 1 0 0
RA4 . . . RA0
1 1 1 1 0 0 0 0
RB7 . . . RB0
0 1 0 1 0 0 1 1
Entradas Salidas
REGISTRO DE ESTADO
7 6 5 4 3 2 1 0
x x x x x x x x
movlw .7
0 0 0 0 0 1 1 1
REGISTRO DE TRABAJO W (WORK)
INSTRUCCIÓN MOVW F f
W F
Ejm: movwf PORTB
Registro TRISB 0 0 0 0 0 0 0 0
Registro W 1 0 1 1 0 1 0 1
Registro PORTB x x x x x x x x
Movwf PORTB
Registro PORTB 1 0 1 1 0 1 0 1
REGISTRO DE TRABAJO W (WORK)
INSTRUCCIÓN MOVF f,d
F Destino
Si d = 0 El destino es W
Si d = 1 El destino es la misma fuente
Ejemplo 1:
1 1 0 0 1 1 1 0
1 1 0 0 1 1 1 0 movf PORTB,0 W
1 f,b
Ejm:
bsf PORTB,1
x x x x x x x x bsf PORTB,1 x x x x x x 1 x
PORTB PORTB
INSTRUCCIÓN BCF f,b
0 f,b
Ejm:
bcf PORTB,7
x x x x x x x x bcf PORTB,7 0 x x x x x x x
PORTB PORTB
INSTRUCCIÓN CLRF f
00h f
1 z
Ejm:
clrf PORTA
0 0 0 0 0 0 0 0
PORTA
x x x x x x x x clrf PORTA
PORTA
R. ESTADO <2> : Z =1
PROGRAMACIÓN
;AUTOR:
;PIC: 16F84A
;FUNCION: Prende un LED (RA0) si un pulsador NA (RB0) envia un 1 logico
;CARACTERISTICAS:
;OSCILADOR: XT
;WATCHDOG TIMER: OFF
;POWER UP TIMER: ON
;CODE PROTECT: OFF
INCLUDE "P16F84A.Inc"
ORG 00
goto INICIO
ORG 05
INICIO bsf STATUS,RP0 ;Salta al banco 1
clrf TRISA ;Puerto A como salida
movlw b'00000001'
movwf TRISB ;RB0 como entrada
bcf STATUS,RP0 ;Salta al banco 0
clrf PORTA ;Pone un 0 logico en las salidas
clrf PORTB ;Pone un 0 logico en las salidas
ORG 05
;**************************CONFIGURACION DE PUERTOS**************************
INICIO bsf STATUS,5 ;Salta al banco 1
movlw b'11111'
movwf TRISA ;Puerto A como entrada
clrf TRISB ;Puerto B como salida
bcf STATUS,5 ;Salta al banco 0
;
clrf PORTB ;borra puerto B por seguridad
movf PORTA,0 ;W = PORTA
movwf VALOR1 ;VALOR1 = W
movf VALOR1,1 ;Z=1 si PORTA = b'0000'
movlw .7 ;W = 7 (decimal)
movwf PORTB ;PORTB = 7 (decimal)
movf PORTB,1 ;Z=0 debido a PORTB no es igual cero
END
Cristal de 4 MHz:
REG1 0 0 0 0 0 0 1 1 REG1 0 0 0 0 0 0 0 1
;SUBRUTINA DE RETARDO:
RETARDO movlw VALOR1 ;W = 70
movwf REG1 ;REG1 = W
TRES movlw VALOR2 ;W = 70
movwf REG2 ;REG2 = W
DOS movlw VALOR3 ;W = 70
movwf REG3 ;REG3 = W
UNO decfsz REG3,1 ;DECREMENTA REG3 Y SI QUEDA “0” SALTA A UNO
goto UNO
decfsz REG2,1 ;DECREMENTA REG2 Y SI QUEDA “0” SALTA A DOS
goto DOS
decfsz REG1,1 ;DECREMENTA REG1 Y SI QUEDA “0” SALTA A TRES
goto TRES
retlw 0
REG1 1 0 1 0 0 0 1 1 REG1 0 0 1 0 0 0 0 1
REG1 0 0 1 0 0 0 1 1 REG1 1 0 1 0 0 0 0 1