INGENIERA ELECTRNICA
MICROCONTROLADOR PIC DE
MICROCHIP
Ing. Lenin Llanos Len
Familias de uC PIC
Gama Media
Gama Baja
PIC
10F
PIC
12F
Gama Alta
PIC
16F
PIC
18F
PIC
24F
DSPIC
PIC32
Familias de uC PIC
microcontroladores
de
gama
media,
en
14KB
28 pin
8 bit Timer
16 bit Timer
USART
SPI I2C
ADC
14KB
40 pin
8 bit Timer
16 bit Timer
USART
SPI I2C
ADC
PIC
16F88
3.5KB
18 pin
8 bit Timer
16 bit Timer
USART
PIC
16F877A
PIC
16F628A
1.75KB
18 pin
8 bit Timer
PIC
16F876A
PIC
16F84A
Familia 16F
7KB
18 pin
8 bit Timer
16 bit Timer
USART
SPI I2C
ADC
PIC 16F88
18 Pines
7 KB memoria de
368 bytes memoria RAM
256 bytes EEPROM
2 Comparadores
7 Canales A/D
1 Canal PWM
Comunicacin Serial, SPI,
I2C
PIC
16F88
programa
PIC 16F88
PIC
16F84A
16F88
PIC
16F88
Lenguajes de Programacin
Bajo Nivel
Assembler
Alto Nivel
C Basic Otros
Lenguaje Assembler
VENTAJAS
Velocidad rpida en ejecucin.
Ahorro en memoria de
programa.
Pocas instrucciones.
Conocimiento a fondo del
funcionamiento del
microcontrolador.
Entorno de desarrollo gratuito
(MPLAB)
DESVENTAJAS
Un poco difcil para el
principiante.
Susceptible a errores.
Ardua tarea para encontrar
errores.
DESVENTAJAS
No compatible entre marcas
entre si.
Mayor consuma de memoria.
Costo elevado.
Hardware de Programacin
Tipos de Programadores
Herramientas de Simulacin
MICROCONTROLADOR PIC
16F88
Ing. Lenin Llanos Len
Circuito de Alimentacin
Circuito de Reloj
Circuito de Reloj RC
Circuito de Reset
Arquitectura Interna
Procesador Central
Memoria de Programa
Memoria de Datos
Memoria de Programa
Memoria de Programa
Memoria Flash de 4K
palabras (14 bits) y
direccionada por el PC
que tiene un tamao
de 13 bits.
Pila con 8 niveles de
profundidad.
El vector de reset
ocupa la direccin
0000h y el vector de
interrupcin la 0004h.
Memoria de Datos
Memoria de Datos
RP1
BANCO
BANCO 1
BANCO 2
BANCO 3
BANCO 4
Memoria de Datos
Tamaos de Memoria
RP1
BANCO
BANCO 1
BANCO 2
BANCO 3
BANCO 4
LENGUAJE ASSEMBLER
Ing. Lenin Llanos Len
Lenguaje Assembler
Lenguaje de Mquina
Lenguaje Assembler
Instrucciones de Programa
REPERTORIO DE INSTRUCCIONES
Instrucciones
Instrucciones
Instrucciones
Instrucciones
Instrucciones
Instrucciones
Instrucciones
de carga.
aritmticas.
lgicas.
de bit.
de salto.
para manejo de subrutinas.
especiales.
INSTRUCCIONES DE CARGA
NEMNICO
DESCRIPCIN
FLAGS AFECTADOS
CLRF f
00 (f)
CLRW
00 (w)
MOVF f,d
(f) (destino)
d=0 : destino = w
d=1 : destino = f
MOVLW k
k (W)
Ninguno
MOVWF f
(w) (f)
Ninguno
INSTRUCCIONES ARITMTICAS
NEMNICO
DESCRIPCIN
FLAGS AFECTADOS
ADDLW k
(w) + k (w)
C, DC, Z
ADDWF f,d
C, DC, Z
DECF f,d
(f) 1 (destino)
INCF f,d
(f) + 1 (destino)
SUBLW k
k (w) (w)
C, DC, Z
SUBWF f,d
C, DC, Z
INSTRUCCIONES LGICAS
NEMNICO
DESCRIPCIN
FLAGS AFECTADOS
ANDLW k
ANDWF f,d
COMF f,d
(/f) (destino)
IORLW k
(w) or k (w)
IORWF f,d
INSTRUCCIONES LGICAS
NEMNICO
DESCRIPCIN
FLAGS
AFECTADOS
RLF f,d
RRF f,d
SWAPF f,d
Ninguno
XORLW k
XORWF f,d
INSTRUCCIONES DE BIT
NEMNICO
DESCRIPCIN
FLAGS AFECTADOS
BCF f,b
Ninguno
BSF f,b
Ninguno
INSTRUCCIONES DE SALTO
NEMNICO
DESCRIPCIN
FLAGS
AFECTADOS
BTFSC f,b
Ninguno
BTFSS f,b
Ninguno
decfsz f,d
(f) 1 (destino)
y salta si es cero
Ninguno
incfsz f,d
(f) + 1 (destino)
y salta si es cero
Ninguno
goto k
Salta a la direccin k
Ninguno
NEMNICO
DESCRIPCIN
FLAGS
AFECTADOS
CALL k
Llamada a subrutina
Ninguno
RETFIE
Retorno de una
Interrupcin
Ninguno
RETLW k
Ninguno
RETURN
Ninguno
INSTRUCCIONES ESPECIALES
NEMNICO
DESCRIPCIN
FLAGS AFECTADOS
CLRWDT
/TO, /PD
NOP
No operacin
Ninguno
SLEEP
/TO, /PD
PRIMER PROGRAMA
U1
16
15
FREQ=4MHz
RA7/OSC1/CLKIN
RA0/AN0
RA6/OSC2/CLKOUT
RA1/AN1
RA2/AN2/CVREF/VREFRA5/MCLR RA3/AN3/C1OUT/VREF+
RA4/AN4/T0CKI/C2OUT
R1
RB0/INT/CCP1
RB1/SDI/SDA
RB2/SDO/RX/DT
RB3/CCP1
RB4/SCK/SCL
RB5/SS/TX/CK
RB6/AN5/T1OSO/T1CKI
RB7/AN6/T1OSI
10k
PIC16F88
17
18
1
2
3
6
7
8
9
10
11
12
13
R3
330
D1
LED-GREEN
PRIMER PROGRAMA
PRIMER PROGRAMA
PRIMER PROGRAMA
PRIMER PROGRAMA
4 Click en Siguiente.
PRIMER PROGRAMA
PRIMER PROGRAMA
PRIMER PROGRAMA
PRIMER PROGRAMA
PRIMER PROGRAMA
9 Click Finalizar.
PRIMER PROGRAMA
PRIMER PROGRAMA
PRIMER PROGRAMA
Definicin de
PIC y Variables
Configuracin
de Puertos
Led Apagado
SI
Pulsador
NO
Presionado
?
Prender
Led
Apagar
Led
PRIMER PROGRAMA
Definicin de
PIC y Variables
list p=16f88
#include p16f88.inc
__CONFIG _CONFIG1, _CPD_OFF & _CP_OFF & _DEBUG_OFF &
_LVP_OFF & _MCLR_ON & _PWRTE_ON & _WDT_OFF
&_WRT_PROTECT_OFF & _XT_OSC & _BODEN_OFF
Led equ 0
Pulsador equ 0
PRIMER PROGRAMA
Configuracin
de Puertos
org 0x00
goto Inicio
org 0x05
Inicio
bsf STATUS,RP0
bsf TRISA,0
bcf TRISB,0
clrf ANSEL
bcf STATUS,RP0
Led Apagado
bcf PORTB,Led
PRIMER PROGRAMA
Bucle
btfsc PORTA,Pulsador
SI
Pulsador
Presionado
?
goto Apagar
NO
Apagar
Led
Prender
Led
Apagar
bsf PORTB,Led
bcf PORTB,Led
goto Bucle
PRIMER PROGRAMA
RA0/AN0
RA1/AN1
VREF/VREFQ=4MHz
OUT/VREF+
0CKI/C2OUT
B0/INT/CCP1
B1/SDI/SDA
/SDO/RX/DT
RB3/CCP1
B4/SCK/SCL
B5/SS/TX/CK
1OSO/T1CKI
7/AN6/T1OSI
PRIMER PROGRAMA
U1
16
17
15
18
1
24
3
6
R1
7
10k
8
9
10
11
12
13
R2
R2
10k
10k
RA7/OSC1/CLKIN
RA0/AN0
RA6/OSC2/CLKOUT
RA1/AN1
RA2/AN2/CVREF/VREFRA5/MCLR RA3/AN3/C1OUT/VREF+
RA4/AN4/T0CKI/C2OUT
R3
330
PIC16F88
RB0/INT/CCP1
RB1/SDI/SDA
RB2/SDO/RX/DT
D1 RB3/CCP1
LED-GREEN
RB4/SCK/SCL
RB5/SS/TX/CK
RB6/AN5/T1OSO/T1CKI
RB7/AN6/T1OSI
17
18
1
2
3
6
7
8
9
10
11
12
13
R3
330
D1
LED-GREEN