0% found this document useful (0 votes)
29 views40 pages

06-PIC A

Uploaded by

sara28206
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views40 pages

06-PIC A

Uploaded by

sara28206
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 40

PIC

9/20/6 Lecture 21 -PIC Architecture 1


History of PIC Microcontroller
• In late 1970s, General Instrument had a 16-bit processor
(CP1600) which was loosing its market-share due to increased
competition from Intel 8086 and Motorola 68000.
– Main disadvantage of CP1600 was limited IO capabilities.
• As a solution General Instruments designed a support Chip
– A special purpose processor which was called the Peripheral
Interface Controller (PIC) of the CP1600.
• By mid 80s the industry found that PIC itself can be used for
most control applications.
• General Instruments started a new subsidiary called Microchip
which began to develop the PIC as a full featured microcontroller
family.
9/20/6 Lecture 21 -PIC Architecture 3
PIC Architecture: Background
Microprocessor:
1. Requires ‘external’ support hardware
2. E.g., External RAM, ROM, Peripherals.

Microcontroller:
1. Very little external support hardware.
2. Most RAM, ROM and peripherals on chip.
3. “Computer on a chip”, or “System on chip” (SOC)
4. E.g., PIC = Peripheral Interface Controller
5. For example, PICs use:
 Data memory (RAM): a small number of 8bit registers
 Program memory (ROM): 12bit, 14bit or 16bit wide
(in EPROM, FLASH, or ROM)
PIC Architecture: Background
PICs and most Harvard chips are “RISC”
1. Reduced Instruction Set Computer (RISC)
2. Used in: SPARC, ALPHA, Atmel AVR, etc.
3. Few instructions (usually < 50)
4. Only a few addressing modes
5. Executes 1 instruction in 1 internal clock cycle (Tcyc)
Example:

1100XX 01010101
PIC16CXXX: MOVLW 0x55
1 word, 1 cycle
PIC Architecture

6
PIC16F887 Microcontroller Block Diagram
Microcontroller features
 CPU – processing unit
 Non-volatile program memory
 Re-settable non-volatile data memory
(EEPROM)
 RAM for data storage
 Direct support for various input/output

9/20/6 Lecture 21 -PIC Architecture 7


Some typical applications
 Automotive air bag systems
 Remote control
 Handheld tools
 Appliances – coffee pot, mixer, stove, refrigerator,
dish washer, washer, dryer
 Major home systems – heating and cooling
 Cordless phones and cell phones
 Security systems
 TV, DVD player/recorder, DVR, PVR
 Sound system
9/20/6 Lecture 21 -PIC Architecture 8
Come in 4-bit through 32-bit
 4-bit
 Very inexpensive
 8-bit
 Still very cheap – often ~$1.00 per chip
 16 and 32 bit
 Priced at $6.00 to 12.00 each
 Evaluation of requirements, chip capability,
and cost come into design decision
9/20/6 Lecture 21 -PIC Architecture 9
Typical automotive use
 Engine control – 32-bit microcontroller
 Fuel flow, fuel mixture, valve timing, throttle body
opening, spark timing
 Transmission control –16-bit microcontroller
 Audio system – 16-bit
 Antilock braking – 16-bit
 Up to fifty 8-bit microcontrollers for functions of
 Wiper control
 Electric Mirrors
 Air Bags
9/20/6 Lecture 21 -PIC Architecture 10
Microcontroller choice parameters
 Number of I/O pins
 Amount of program and data memory
 Speed
 Timer Resources
 Interrupt control
 Robustness
 Error recovery – watchdog timers
 Power, I/O expansion, math support
9/20/6 Lecture 21 -PIC Architecture 11
PIC architecture is a “Harvard” architecture
Von Neumann
Architecture
 Von Neumann Architecture:
 Fetches instructions and data
from a single memory space
8-bit 
Bus
P rogram Limits operating bandwidth
& Data
Memory
CP U
 Harvard Architecture:
Harvard  Uses two separate memory
Architecture
spaces for program instructions
and data
 Improved operating bandwidth
8-bit Data
Bus 
Memory Allows for different bus widths
14-bit
CP U
Bus
P rogram
Memory
Feature of Harvard architecture
 Near all instructions are single instruction
word instructions
 Only one fetch per instruction
 Instruction fetch and execute are pipelined so
you can operate at near clock rate instructions
per second
 2 separate buses
 One for instructions and one for data
9/20/6 Lecture 21 -PIC Architecture 13
Main Difference between AVR, ARM, 8051 and PIC
Microcontrollers

9/20/6 Lecture 21 -PIC Architecture 14


Main Difference between AVR, ARM, 8051 and PIC
Microcontrollers
8051 PIC AVR ARM
32-bit mostly also
Bus width 8-bit for standard core 8/16/32-bit 8/32-bit
available in 64-bit
UART, USART, LIN,
UART, USART, SPI,
PIC, UART, USART, I2C, SPI, CAN, USB,
Communication UART, I2C, (special purpose
LIN, CAN, Ethernet, Ethernet, I2S, DSP,
Protocols USART,SPI,I2C AVR support CAN,
SPI, I2S SAI (serial audio
USB, Ethernet)
interface), IrDA
12 Clock/instruction 4 Clock/instruction 1 clock/ instruction 1 clock/ instruction
Speed
cycle cycle cycle cycle
Flash, SRAM, Flash, SDRAM,
Memory ROM, SRAM, FLASH SRAM, FLASH
EEPROM EEPROM
ISA CLSC Some feature of RISC RISC RISC
Von Neumann Modified Harvard
Memory Architecture Harvard architecture Modified
architecture architecture
Power Consumption Average Low Low Low
PIC16,PIC17, PIC18, Tiny, Atmega, Xmega, ARMv4,5,6,7 and
Families 8051 variants
PIC24, PIC32 special purpose AVR series
NXP, Atmel, Silicon Apple, Nvidia,
Manufacturer Labs, Dallas, Cyprus, Microchip Average Atmel Qualcomm, Samsung
Infineon, etc. Electronics, and TI etc.
PIC18fXX8, LPC2148, ARM
Popular Atmega8, 16, 32,
AT89C51, P89v51, etc. PIC16f88X, Cortex-M0 to ARM 15
Microcontrollers Arduino Community
PIC32MXX Cortex-M7, etc.
What DO PICs look like ?
PIC's are low-cost, easy to use microcontrollers from
Microchip. The 12F, 16F and 18F series, all having
flash memory and the ability to be programmed "in-
circuit", allows designs to be tested during the
creation of the program.
Examples are: 16F877, 16F876, 16F628,
16F84, 18F452, 12F675 and 12F629

12Fxx (8pins) 16Fxx (18pins) 18Fxx (40pins)


16
v
http://www.microchip.com/stellent/images/mchpsiteimages/en537986.jpg
17
PIC Families
PIC Family Stack Size Instruction No of Interrupt
Word Size Instructions Vectors
12CX/12FX 2 12- or 14-bit 33 None
16C5X/16F5X 2 12-bit 33 None
16CX/16FX 8 14-bit 35 1
17CX 16 16-bit 58 4
18CX/18FX 32 16-bit 75 2

‘C’ implies CMOS technology; Complementary Metal Oxide Semiconductor

‘F’ insert indicates incorporation of Flash memory technology

Example: 16C84 was the first of its kind. It was later reissued as the 16F84,
incorporating Flash memory technology. It was then reissued as 16F84A.
18
9/20/6 Lecture 21 -PIC Architecture 19
PIC Microcontroller (PIC16F684)
 High performance, low cost, for embedded applications
 Only 35 different instructions
 Interrupt capability ?
 Direct, indirect, relative addressing mode
 Low Power
 8.5uA @ 32KHz, 2.0V
 Peripheral Features
 12 I/O pins with individual direction control
 10-bit A/D converter
 8/16-bit timer/counter
 Special Microcontroller Features
 Internal/external oscillator
 Power saving sleep mode
 High Endurance Flash/EEPROM cell
20
The PIC Family: 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 (T cyc = 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
Internal or external oscillator
 You can use the internal oscillator that PICs have
which produces frequency less than 8 MHz
 For accurate frequency and frequency stability, use a
external oscillators such ceramic resonator, crystal, or
RC circuit.
 Crystal oscillator is the most accurate and come in a
wide range of frequencies.
 For frequencies other than the PIC clock dividers
give, crystal should be used.

22
A/D converters and C/C modules
 All PICs have between 0 and 16 A/D
converters with 8/10-bit resolution
 8-16 bit Timers/Counters
 Comparator Modules (0-2)
Special-Function REGISTERS (SFR)

 In addition to registers which do not have any special and


predetermined function, every microcontroller has a number
of registers (SFR) whose function is predetermined by the
manufacturer.

 Their bits are connected (literally) to internal circuits of the


microcontroller such as timers, A/D converter, oscillators and
others, which means that they are directly in command of the
operation of these circuits, i.e. the microcontroller.

24
Interrupt System Registers
When an interrupt request arrives it does not mean that interrupt will
automatically occur, because it must also be enabled by the user (from
within the program). There are special bits used to enable or disable
interrupts:
• IE (stands for Interrupt Enable): special bits used to enable or
disable interrupts.
• IF (Interrupt Flag): Each interrupt is associated with another bit
called the flag which indicates that interrupt request has arrived
regardless of whether it is enabled or not.

25
Example:

PIC16F887 Microcontroller

26
9/20/6 Lecture 21 -PIC Architecture 27
9/20/6 Lecture 21 -PIC Architecture 28
9/20/6 Lecture 21 -PIC Architecture 29
9/20/6 Lecture 21 -PIC Architecture 30
Example: PIC16F887 Registers

9/20/6 Lecture 21 -PIC Architecture 31


32
33
9/20/6 Lecture 21 -PIC Architecture 34
35
9/20/6 Lecture 21 -PIC Architecture 36
9/20/6 Lecture 21 -PIC Architecture 37
9/20/6 Lecture 21 -PIC Architecture 38
9/20/6 Lecture 21 -PIC Architecture 39
Interrupt System Registers (Example:
PIC16F887)
 INTCON Register: The INTCON register contains various enable
and flag bits for TMR0 register overflow, PORTB change and external
INT pin interrupts.
 PIE1 Register: The PIE1 register contains the peripheral interrupt
enable bits.
 PIE2 Register: The PIE2 Register also contains the various interrupt
enable bits.
 PIR1 Register: The PIR1 register contains the interrupt flag bits.
 PIR2 Register: The PIR2 register contains the interrupt flag bits.
 PCON register: The PCON register contains only two flag bits used
to differentiate between a: power-on reset, brown-out reset, Watchdog
Timer Reset and external reset (through MCLR pin).
 PCL and PCLATH Registers: 13-bits wide program counter.
40

You might also like