Upload
peeyushkp
View
49
Download
4
Embed Size (px)
Citation preview
PIC
MICROCONTROLLERS
Peeyush.K.P.
ASE Ettimadai
What is an Embedded System?
Communication
Avionics
2
Consumer
Electronics
Automobile
Household Appliances
Office Equipments
System in which software is embedded into the
hardware ( firmware).
The core part of the system will be a programmable device.
What is an Embedded system?
The core part of the system will be a programmable device.
Automotive Embedded Systems
� Today’s high-end automobile have > 80
microprocessors:
� 4-bit microcontroller checks seat belt;
� microcontrollers run dashboard devices;
� 16/32-bit microprocessor controls engine.
4
� 16/32-bit microprocessor controls engine.
� Millions lines of code
Vending Machines
5
Sojourner
6
GPS Receivers
7
� Reduced number of components.
� Reduced size.
� Reduced cost.
� Reduced power consumption.
Why Embedded systems?
� Easier upgradation.
� Easier troubleshooting & maintenance.
� Best suited for specific controlling applications.
Why uC?
� Microprocessor:• Requires ‘external’ support hardware
• E.g., External RAM, ROM, Peripherals.
• Application:Processing-Arithmetic,logic operations.
� Microcontroller:Very little external support hardware/Stand alone.• Very little external support hardware/Stand alone.
• Most RAM, ROM and peripherals on chip.
• “Computer on a chip”, or “System on chip” (SOC)
• E.g., PIC = Peripheral Interface Controller
• Application: Controlling purposes.
Microcontroller
VARIOUS MICROCONTROLLERS
� 8 bit microcontrollers
� Microchip - PIC 12 & 16 Series.
� Atmel - 89c51
� Intel - 8051
� Motorola - 68HCxx series
� 16 bit microcontrollers
� Microchip - PIC 18 series
� 32 bit microcontrollers
� ARM Processors
� DSP based microcontrollers
� Shark
Two Different Architectures
RISC vs. CISC
� Reduced Instruction Set
Computer (RISC)
� Used in: SPARC, ALPHA,
Atmel AVR, etc.
� Few instructions
� Complex Instruction Set
Computer (CISC)
� Used in: 80X86, 8051,
68HC11, etc.
� Many instructions� Few instructions
(usually < 50)
� Only a few addressing
modes
� Executes 1 instruction in 1
internal clock cycle (Tcyc)
� Many instructions
(usually > 100)
� Several addressing modes
� Usually takes more than 1
internal clock cycle (Tcyc)
to execute
WHY PIC ?WHY PIC ?
WHY PIC ?
� PICs use the Harvard Architecture
� PICs and most Harvard chips are “RISC”
� 35 Instructions
Executes 1 instruction in 1 internal clock cycle � Executes 1 instruction in 1 internal clock cycle
� In-Circuit Serial Programmable (ICSP) – via two pins.
� Available in different packages
Features
� Power On Reset Timer
� Oscillator Startup Timer
� WatchDog Timer
Sink/Source Current – 25ma� Sink/Source Current – 25ma
� Flash Programming
POR/Oscillator Startup Timer
WatchDog Timer
00
01
02
..
....
FF
00
Roll Over
Sink/Source Current – 25ma
The PIC Family: Cores
PICs come with 1 of 3 CPU ‘cores’:
The Base-line : 12bit cores with 33 instructions.
Eg:12C50x, 12C67x
The Mid-Range : 14bit cores with 35 instructions. Eg:16C5x,16Cxxx
The High-End : 16bit cores with 58 instructions.
Eg:17C4x,17C7xx
‘Enhanced’ 16bit cores with 77 instructions: 18Cxxx
Areas of Application.
� Base-line
� Inexpensive controllers, glue logic, simple tasks.
� E.g., quadrature decoding, digital interfacing.
� Mid-range
� Multitasking programs, serial communication.
� E.g., Cheap data acquisition system and digital I/O � E.g., Cheap data acquisition system and digital I/O system for PC off COM ports, data logging.
� High-end
� RTOS, low end DSP, communications, big moosey applications.
� E.g., FEC converter, Rocket Flight Computer, cheap FFT chip.
ProgramMemory (ROM)-size
PIC program space is different for each chip.
Some examples are:
12C508 512 12bit instructions
16C71C 1024 (1k) 14bit instructions
16F877 8192 (8k) 14bit instructions
17C766 16384 (16k) 16bit instructions
ProgramMemory (ROM)-types
PICs have two different types of program storage:
EPROM (Erasable Programmable Read Only Memory)
Needs high voltage from a programmer to program (~13V)(~13V)
Needs windowed chips and UV light to erase
Note: One Time Programmable (OTP) chips are EPROM chips, but with no glass window. ( ‘CR’ )PIC Examples: Any ‘C’ part: 12C50x, 17C7xx, etc.
ProgramMemory (ROM)-types.
FLASH
Re-writable (even by chip itself)
Much faster to develop on! Much faster to develop on!
Finite number of writes (~100k Writes)
PIC Examples: Any ‘F’ part: 16F84, 16F87x,
18Fxxx (future)
Data Memory (RAM-volatile)
PICs use general purpose “file registers” for RAM (each
register is 8bits for all PICs)
Some examples are:
12C508 25 Bytes RAM12C508 25 Bytes RAM
16C71C 36 Bytes RAM
16F877 368 Bytes
17C766 902 Bytes RAM
Data Memory (EEPROM non-volatile)
� For permanent storage of data.
� Available in few PICs only.
Eg:16F8X,12CE5XX,16F87X� Eg:16F8X,12CE5XX,16F87X
Speed
PICs require a clock to work.
Can use crystals, clock oscillators, or even an RC circuit.
Some PICs have a built in 4MHz RC clock
- Not very accurate, but requires no external components!
Instruction speed = 1/4 clock speed (Tcyc = 4 * Tclk) Instruction speed = 1/4 clock speed (Tcyc = 4 * Tclk)
All PICs can be run from DC to their maximum spec’d speed:
12C50x 4MHz
12C67x 10MHz
16Cxxx 20MHz
17C4x /17C7xxx 33MHz
18Cxxx 40MHz
Peripherals
Different PICs have different on-board peripherals
Some common peripherals are:
� Tri-state (“floatable”) digital I/O pins.
� Analog to Digital Converters (ADC) (8, 10 and � Analog to Digital Converters (ADC) (8, 10 and 12bit, 50ksps).
� Serial communications: UART (RS-232C), SPI, I2C, CAN.
� Pulse Width Modulation (PWM) (10bit).
� Timers and counters (8 and 16bit).
� Watchdog timers, Brown out detect, LCD drivers.
Packages
PICs come in a huge variety of packages:
8 pin DIPs, SOICs: 12C50x (12bit) , 12C67x (14bit)
18pin DIPs, SOICs: 16C5X (12bit), 16Cxxx (14bit)
28pin DIPs, SOICs: 16C5X (12bit), 16Cxxx (14bit)28pin DIPs, SOICs: 16C5X (12bit), 16Cxxx (14bit)
40pin DIPs, SOICs: 16Cxxx (14bit), 17C4x (16bit)
44 - 68pin PLCCs*: 16Cxxx (14bit), 17Cxx (16bit)
Commonly used mid range series
PICs
� The 16F8x series- 16F84.
� The 16F7x series- 16F73,74,76,77.
� The 16F87x series- 16F873, 874,876,877.
Comparison of Commonly Used
Mid range series of PIC
882Stack levels
200ns200ns400ns
20MHz20MHz10MHz
Operating Speed
Clock input
Instruction cycle
87X7X16f8X
11NoSSP/SPI/I2C
YesYesNoInterrupt on Pin Change
11NoUSART/SCI
8bit X 2 + 16bit X 18bit X 2 + 16bit X 18bit X 1Timers
22NoCCP modules
10bit8bitNoADC
882Stack levels
YesNoYesData EEPROM
Comparison of Commonly Used
Mid range series of PIC
A,B
18
83
A,B,C,D,EA,B,CA,B,C,D,EA,B,CA,BI/O Ports
4028402818Total pins
77/87776/87674/87473/87384
YesYesYesYesNoNoBOR
8585NANAADC channels
YesNoYesNoNoNoPSP
2562561281286464EEPROM
36 B
512 B
13
368 B368 B192 B192 B 68 BData m/y
8 KB8 KB4 KB4 KB1 KBProg. m/y
3322332213I/O Pins
PIC 16F874/877
PIC 16F874/877
PIN DIAGRAM
PIC16F877A Block Diagram
Instruction
Bus
Must be
involved in all
arithmetic
Data Bus
Data
Memory
Instruction
Memory
Most
important
register in
the PIC
arithmetic
operations
PIC16F877A Memory
� The PIC16F877A has an 8192 (8k) 14bit instruction
program memory
� 368 Bytes Registers as Data Memory :
�Special Function Registers: used to control peripherals �Special Function Registers: used to control peripherals
and PIC behaviors
�General Purpose Registers: used to a normal
temporary storage space (RAM)
� 256 Bytes of nonvolatile EEPROM
PIC16F877A Memory Map
www.greytechnologies.net
SFR
INSTRUCTION SET
1) Move Literal Value To Work RegisterSyntax : MOVLW <LITERAL>
Eg: MOVLW 0X02
2) Move Content of Work Reg. To File Reg. Syntax : MOVWF <FILE REG>Syntax : MOVWF <FILE REG>
Eg : MOVWF PORTA
3) Move Content of File Reg. To Desti.Syntax : MOVF <FILE REG>,<DESTI.>
Eg : MOVF PORTA,0
Eg : MOVF PORTA,1
INSTRUCTION SET
1) Bit Set File RegisterSyntax : BSF <File Reg>,<Bit>
Eg: BSF PORTA,1
2) Bit Clear File RegisterSyntax : BCF <File Reg>,<Bit>Syntax : BCF <File Reg>,<Bit>
Eg : BCF PORTA,1
INSTRUCTION SET
1) Bit Test File Register Skip if SetSyntax : BTFSS <File Reg>,<Bit>
Eg: BTFSS PORTA,1
2) Bit Test File Register Skip if ClearSyntax : BTFSC <File Reg>,<Bit>Syntax : BTFSC <File Reg>,<Bit>
Eg : BTFSC PORTA,1
INSTRUCTION SET
1) Decrement File Register Skip if ZeroSyntax : DECFSZ <File Reg>,<Desti.>
Eg: DECFSZ COUNT,1
2) Increment File Register Skip if ZeroSyntax : INCFSZ <File Reg>,<Desti.>Syntax : INCFSZ <File Reg>,<Desti.>
Eg : INCFSZ COUNT,1
Programming PIC
Basic Circuit
Thank You For Thank You For
Your Kind Your Kind
Attention……Attention……Attention……Attention……