06-PIC A
06-PIC A
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
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)
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