Está en la página 1de 14

Microcontrolador

es
M.C. Gabriel Casarrubias Guerrero
Descripción del microcontrolador

High-Performance RISC CPU:

Solo 49 instrucciones
Todas se ejecutan en un ciclo de instrucción excepto los saltos a funciones.

Velocidad de operación:
Entrada de reloj/Oscilador hasta 32 MHz
Ciclo de instrucción de 125 ns

Capacidad de interrupción con contexto de guardado automático.

16 Niveles de profundidad del stack con reset por overflow/underflow

Modos de direccionamiento directo, indirecto y relativo.

MTF-1021
© 2017 Mecatronica
MICROCONTROLADORES
Tec All Rights reserved
2018 2
2.1 Componentes del microcontrolador
Oscilador interno de precisión de 32MHz a 31KHz seleccionable
Modo sleep ahorrador de energía.
Power on reset (POR)
Power up timer (PWRT)
Timer de puesta en marcha del oscilador (OST)
Brown out reset (BOR)
Master clear
Protección de código programable
Célula de alta resistencia Flash/Data EEPROM
o 100,000 escrituras Flash
o 1,000,000 escrituras data EEPROM
o Retención mayor de 40 años

MTF-1021
© 2017 Mecatronica
MICROCONTROLADORES
Tec All Rights reserved
2018 3
Bloques del microcontrolador
MEMORIA DEL PROGRAMA Oscilador MEMORIA DE DATOS
PIC16 Núcleo Volátil
No volátil Working (SRAM)
(Flash) Contiene los
Contiene las STATUS datos para el
instrucciones del control de las
programa que le dicen al instrucciones
OPTION
CPU que hacer

ALU

CPU
El cerebro
Ejecuta todas las
instrucciones,
lógica y procesamiento
matemático

MTF-1021
© 2017 Mecatronica
MICROCONTROLADORES
Tec All Rights reserved
2018 4
Bloques del microcontrolador
Memoria del programa Oscilador
MEMORIA DE
PIC16 Núcleo DATOS
Working
I/O PORTS
STATUS

OPTION 10 BIT ADC

ALU TIMERS

CPU EEPROM
Peripherals Hang
Off the Data Bus
Cap/ Com/ PWM

COMPARATORS SPI / I2C

VOLTAGE REF USART

MTF-1021
© 2017 Mecatronica
MICROCONTROLADORES
Tec All Rights reserved
2018 5
MEMORIA DE PROGRAMA FLASH
MEMORIA DEL PROGRAMA

Guarda las instrucciones (tu código)


Página 0 o Le dice al CPU que hacer

Dividida en páginas de 2K x 14 bit


Página 1
La cantidad de memoria depende del dispositivo específico
o 56 K x 14 max (32 pages)
Todas las instrucciones son de 14 bits de longitud
Página 2
o 1 instrucción = 1 Dirección de la memoria del programa

Página 3 MTF-1021
© 2017 Mecatronica
MICROCONTROLADORES
Tec All Rights reserved
2018 6
Memoria Flash del Programa
¿Por qué necesitamos paginar la memoria del programa?
MEMORIA DEL PROGRAMA
0000h

Con instrucciones de 14 bits, solo once pueden


07FFh Page 0 usarse para especificar la Dirección de memoria en un solo ciclo.
0800h

0FFFh Page 1 GOTO Instruction in Program Memory


13 12 11 10 9 8 7 6 5 4 3 2 1 0
1000h
Opcode

17FFh Page 2
1800h
211 = 2048 direcciones

1FFFh Page 3
MTF-1021
© 2017 Mecatronica
MICROCONTROLADORES
Tec All Rights reserved
2018 7
Memoria de datos SRAM
MEMORIA DE DATOS

Dividida en bancos de 128 x 8 bit


La cantidad de memoria de datos depende del dispositivo
o 4K x 8 max (63 banks) for the Enhanced Mid-Range core SFR

2 grupos de registros:
o Special Function Registers (SFR)
 Controlar CPU y funciones de los periféricos
o General Purpose Registers (GPR)
 Guarda las variables definidas por el usuario GPR

Bank 0
MTF-1021
© 2017 Mecatronica
MICROCONTROLADORES
Tec All Rights reserved
2018 8
Bancos de la memoria de datos
¿Por qué necesitamos los bancos de la memoria?

MEMORIA DE DATOS
Con instrucciones de 14 bits, solo 7 bits pueden ser
000h
SFR usados para especificar la Dirección en un ciclo

Byte Oriented Instruction (i.e. ADDWF)


13 12 11 10 9 8 7 6 5 4 3 2 1 0
GPR
Opcode

27 = 128 addresses
07Fh

Bank 0

MTF-1021
© 2017 Mecatronica
MICROCONTROLADORES
Tec All Rights reserved
2018 9
Seleccionando el banco active de la
memoria de datos.
Bank Select Register (BSR)
bit 7 bit 0
BSR4
BSR4 BSR3
BSR3 BSR2
BSR2 BSR1
BSR1 BSR0
BSR0

00000 = Bank 0
00001 = Bank 1
00010 = Bank 2
…….
Selecciona el banco antes 11111 = Bank 31
de accede a los registros
del mismo

MTF-1021
© 2017 Mecatronica
MICROCONTROLADORES
Tec All Rights reserved
2018 10
SFR memoria de datos
Registros de función especial
Bank 0 Bank 1 Bank 2
000 INDF0
INDF0 080 INDF0
INDF0 100 INDF0
INDF0 180 INDF0
INDF0
001 INDF1
INDF1 081 INDF1
INDF1 101 INDF1
INDF1 181 INDF1
INDF1
002 PCL
PCL 082 PCL
PCL 102 PCL
PCL 182 PCL
PCL
003 STATUS
STATUS 083 STATUS
STATUS 103 STATUS
STATUS 183 STATUS
STATUS
004 FSR0L
FSR0L 084 FSR0L
FSR0L 104 FSR0L
FSR0L 184 FSR0L
FSR0L
005 FSR0H
FSR0H 085 FSR0H
FSR0H 105 FSR0H
FSR0H 185 FSR0H
FSR0H
006 FSR1L
FSR1L 086 FSR1L
FSR1L 106 FSR1L
FSR1L 186 FSR1L
FSR1L
007 FSR1H
FSR1H 087 FSR1H
FSR1H 107 FSR1H
FSR1H 187 FSR1H
FSR1H
008 BSR
BSR 088 BSR
BSR 108 BSR
BSR 188 BSR
BSR
009 WREG
WREG 089 WREG
WREG 109 WREG
WREG 189 WREG
WREG
00A PCLATH
PCLATH 08A PCLATH
PCLATH 10A PCLATH
PCLATH 18A PCLATH
PCLATH
00B INTCON
INTCON 08B INTCON
INTCON 10B INTCON
INTCON 18B INTCON
INTCON

00C PORTA
PORTA 08C ADRESL
ADRESL 10C ADCNT
ADCNT 18C SSP1BUF
SSP1BUF
00D PORTB
PORTB 08D ADRESH
ADRESH 10D ADRPT
ADRPT 18D SSP1ADD
SSP1ADD

Ver hoja de datos para cada dispositivo en específico


MTF-1021
© 2017 Mecatronica
MICROCONTROLADORES
Tec All Rights reserved
2018 11
Set de instrucciones PIC16
35 instrucciones de solo una palabra
Todas se ejecutan en un ciclo de instrucción excepto los saltos
Byte
Byte Oriented
Oriented Operations
Operations Bit
Bit Oriented
Oriented Operations
Operations
addwf
addwf f,d
f,d Add
Add WW and
and ff bcf
bcf f,b f,b Bit
Bit Clear
Clear ff
andwf
andwf f,d
f,d AND
AND W W with
with ff bsf
bsf f,b f,b Bit
Bit Set
Set ff
clrf
clrf ff Clear
Clear ff btfsc
btfsc f,b
f,b Bit
Bit Test
Test f,f, Skip
Skip ifif Clear
Clear
clrw
clrw -- Clear
Clear WW btfss
btfss f,b
f,b Bit
Bit Test
Test f,f, Skip
Skip ifif Set
Set
comf
comf f,d
f,d Complement
Complement ff Literal
Literal and
and Control
Control Operations
Operations
decf
decf f,d
f,d Decrement
Decrement ff addlw
addlw kk Add
Add literal
literal and
and W W
decfsz
decfsz f,d
f,d Decrement
Decrement f,f, Skip
Skip ifif 00 andlw
andlw kk AND
AND literal
literal with
with W W
incf
incf f,d
f,d Increment
Increment ff call
call kk Call
Call subroutine
subroutine
incfsz
incfsz f,d
f,d Increment
Increment f,f, Skip
Skip ifif 00 clrwdt
clrwdt -- Clear
Clear Watchdog
Watchdog Timer Timer
iorwf
iorwf f,d
f,d Inclusive
Inclusive OR
OR W W with
with ff goto
goto kk Go
Go toto address
address
movf
movf f,d
f,d Move
Move ff iorlw
iorlw kk Inclusive
Inclusive OR OR literal
literal with
with W
W
movwf
movwf ff Move
Move W W to
to ff movlw
movlw kk Move
Move literal
literal to
to W W
nop
nop -- No
No Operation
Operation retfie
retfie -- Return
Return fromfrom interrupt
interrupt
rlf
rlf f,d
f,d Rotate
Rotate Left
Left ff through
through CarryCarry retlw
retlw kk Return
Return withwith literal
literal in in W
W
rrf
rrf f,df,d Rotate
Rotate Right
Right ff through
through Carry
Carry return
return -- Return
Return fromfrom Subroutine
Subroutine
subwf
subwf f,d
f,d Subtract
Subtract W W from
from ff sleep
sleep -- Go
Go into
into standby
standby mode mode
swapf
swapf f,d
f,d Swap
Swap nibbles
nibbles in in ff sublwk
sublwk Subtract
Subtract W W from
from literal
literal
xorwf
xorwf f,d
f,d Exclusive
Exclusive OROR W W with
with ff xorlw
xorlw kk Exclusive
Exclusive OR OR literal
literal with
with W
W
MTF-1021
© 2017 Mecatronica
MICROCONTROLADORES
Tec All Rights reserved
2018 12
Set de instrucciones PIC16

Byte
Byte Oriented
Oriented Operations
Operations
addwfc
addwfc f,d
f,d Add
Add with
with Carry
Carry W W and
and ff
asrf
asrf f,d
f,d Arithmetic
Arithmetic Right
Right Shift
Shift
lslf
lslf f,d
f,d Logical
Logical Left
Left Shift
Shift
lsrf
lsrf f,d
f,d Logical
Logical Right
Right Shift
Shift
subwfb
subwfb f,d
f,d Subtract
Subtract with
with Borrow
Borrow W W from
from ff
Literal
Literal and
and Control
Control Operations
Operations
movlp
movlp kk Move
Move Literal
Literal to
to PCLATH
PCLATH
movlp
movlp kk Move
Move Literal
Literal to
to BSR
BSR
bra
bra kk Branch
Branch Relative
Relative (signed)
(signed)
brw
brw -- Branch
Branch PCPC ++ W W (unsigned)
(unsigned)
callw
callw -- Call
Call PCLATH:W
PCLATH:W
addfsr
addfsr n,k Add
n,k kk Literal
Add Literal to
to FSRn
FSRn (signed)
(signed)
moviw
moviw n,mm Move
n,mm Move Indirect
Indirect toto W
W
movwi
movwi n,mm Move
n,mm Move W W to
to Indirect
Indirect
reset
reset -- Reset
Reset Hardware
Hardware & & Software
Software

MTF-1021
© 2017 Mecatronica
MICROCONTROLADORES
Tec All Rights reserved
2018 13
Guardado de contexto rápido
• Interrupciones guardan automáticamente el contexto
• W
• STATUS
• BSR
• FSRs
• PCLATH

• RETFIE automáticamente restaura el contexto


• No se puede deshabilitar el fast context save

MTF-1021
© 2017 Mecatronica
MICROCONTROLADORES
Tec All Rights reserved
2018 14

También podría gustarte