Post on 04-Jun-2018
Lecture (02)PIC16F84 (I)
By:
Dr. Ahmed ElShafee
Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers١
• Review of Memory Technologies
• The PIC 16 Series
• PIC 16F84A
• The PIC 16F84A Memory
• The Oscillator
• Instruction Cycle
• Power‐up and Reset
• Parallel ports
– Technical challenges
– Connecting to the parallel port
– The PIC 16F84A parallel ports
• Power supply
• Clock oscillator
Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers٢
PIC Microcontrollers
• Peripheral Interface Controller (PIC) was originally designed by General Instruments
• In the late 1970s, GI introduced PIC® 1650 and 1655 – RISC with 30 instructions.
• PIC was sold to Microchip
• Features: low‐cost, self‐contained, 8‐bit, Harvard structure, pipelined, RISC, single accumulator, with fixed reset and interrupt vectors.
Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers٣
PIC Families
• ‘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.Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers٤
PIC Family Stack Size Instruction Word Size
No of Instructions
Interrupt 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
12 Series PIC
•
Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers٥
•
Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers٦
PIC 12F675 Architecture
Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers٧
The PIC 16 Series
•
Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers٨
Device Pins Clock Memory Features
16F84A 18 ≤ 20 MHz 1 K ROM68 B RAM
64 B EEPROM
1 8‐bit timer1 5‐bit port1 8‐bit port
16LF84A Extended supply voltage range
16F84A‐04 ≤ 4 MHz
Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers٩
Device Pins Clock Memory Features
16F873A 28 ≤ 20 MHz 4 K ROM192 B RAM
128 B EEPROM
3 parallel ports,3 counter/timers,
2 capture/compare/PWM,2 serial,
5 10‐bit ADC,2 comparators
16F874A 40 ≤ 20 MHz 4 K ROM192 B RAM
128 B EEPROM
5 parallel ports,3 counter/timers,
2 capture/compare/PWM,2 serial,
8 10‐bit ADC,2 comparators
Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers١٠
Device Pins Clock Memory Features
16F876A 28 ≤ 20 MHz 8 K ROM368 B RAM
256 B EEPROM
3 parallel ports,3 counter/timers,
2 capture/compare/PWM,2 serial,
5 10‐bit ADC,2 comparators
16F877A 40 ≤ 20 MHz 8 K ROM368 B RAM
256 B EEPROM
5 parallel ports,3 counter/timers,
2 capture/compare/PWM,2 serial,
8 10‐bit ADC,2 comparators
16F84A
Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers١١
PIC 16F84A Architecture
•
Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers١٢
The 16F84A Status Register
• C: Carry/Borrow’
• DC: Digit Carry/Borrow’
• Z: Zero
• PD’: Power Down
• TO’: Time Out
• RP0: Register Bank Select
• RP1, IRP: Not implemented
Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers١٣
The 16F84A Memory
•
Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers١٤
Memory Technology Size Features
Program Flash 1K x 14 bits10,000
erase/write cycles
Data (File Registers)
SRAM 68 BytesRetains data down to 1.5 V
Data (EEPROM) EEPROM 64 Bytes10,000,000 erase/write
cycles
Stack SRAM 8 x 13 bits
Program Memory and Stack
Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers١٥
Configuration Word
Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers١٦
Allows the user to define certain configurable
features of the microcontroller, at the
time of program download.
Data memory and Special Function Registers
•
Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers١٧
FSR: File Select Register for indirect
addressing.
EEADR: EEPROM Address
EEDATA: EEPROM Data
EECON1: Control; RD, WREN, WR, EEIF
EECON2: 55H to AAH
The Oscillator
• It is necessary to provide the ‘clock’ signal.
• The clock is a continuously running fixed frequency logic square wave.
• The overall speed of the microcontroller operation is entirely dependent on this clock frequency.
• Higher frequency ‐> Higher Performance and higher power consumption.
Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers١٨
Instruction Cycle
• The main oscillator signal is divided by 4 to produce the instruction cycle time.
Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers١٩
Pipelining
• All PIC microcontrollers implement pipelining.
• Pipelining fails when one instruction changes the contents of the Program Counter.
Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers٢٠
Power‐up and Reset
• At power‐up, the Program Counter is forced to zero and the SFRs are reset so that peripherals are initially in a safe and disabled state.
• There is also a master clear input MCLR’.
Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers٢١
Summary
• The PIC 16 Series is a diverse and effective family of microcontrollers.
• The 16F84A architecture is representative of all 16 Series microcontrollers, with Harvard structure, pipelining and a RISC instruction set.
• The PIC 16F84A has a limited set of peripherals, chosen for small and low‐cost applications. It is thus a smaller member of the family, with features that are a subset of any of the larger ones.
• The 16F84A uses three distinct memory technologies for its different memory areas.
• A particular type of memory location is the Special Function Register, which acts as the link between the CPU and the peripherals.
• Reset mechanisms ensure that the CPU starts running when the appropriate operating conditions have been met, and can be used to restart the CPU in case of program failure.22
Data Transfer
• Almost any embedded system needs to transfer digital data between its CPU and the outside world.
– Direct user interface, including switches, keypads, light‐emitting diodes (LEDs) and displays
– Input measurement information, from external sensors, possibly being acquired through an analog‐to‐digital converter
– Output control information, for example to motors or other actuators
– Bulk data transfer to or from other systems or subsystems, moving in serial or parallel form, for example sending serial data to an external memory.
23Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers
Output Parallel Ports
24
Input Parallel Ports
25
Bi‐directional Parallel Ports
26
Port electrical characteristics
27
Modeling a logic gate output. (a) Generalized model. (b) Model of CMOS logic gate output
Schmitt trigger inputs
28
Schmitt trigger characteristics.(a) Buffer with Schmitt trigger input. (b) Input/output characteristic
• In electronics, a Schmitt trigger is a comparator circuit with hysteresis implemented by applying positive feedback to the noninverting input of a comparator or differential amplifier. It is an active circuit which converts an analog input signal to a digital output signal.
Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers٢٩
The ‘Open Drain’ output
30
(a) An ‘Open Drain’ output.
(b) Open Drain output driving load resistor.
(c) The ‘Wired-OR’ connection
Connecting to the parallel port(1) Switches
31
(a) SPDT connection (single pole double throw). (b) SPST with pull-up resistor (single pole single throw).
(c) SPST with pull-down resistor
Pull-up values in the range 10–100 kΩ
Connecting to the parallel port(2) Light‐emitting diodes
32
Connecting to the parallel port(2) Light‐emitting diodes
33
Driving LEDs from logic gates.(a) Gate output sourcing current to LED(b) Gate output sinking current from LED
Connecting to the parallel port(2) Light‐emitting diodes
34
The PIC 16F84A parallel ports
• Port A – 5 Bits
– RA3:RA0
– RA4/T0CKI
• Port B – 8 Bits
– RB0/INT
– RB3:RB1
– RB7:RB4: Interrupt on change
35
36
37
38
39
Port output characteristics ‐1
40
VOH vs. IOH (VDD = 3V, −40 to 125◦C)R = 130 Ω
Port output characteristics ‐2
41
VOL vs. IOL (VDD = 3V, −40 to 125◦C)
R = 36 Ω
The clock oscillator
• Faster clock gives faster execution, but more power consumption.
• The clock oscillator must give stable and accurate clock signal.
• Oscillator types:
– Resistor–capacitor (RC)
• Not precise
– Crystal or ceramic
• Precise frequency, fragile, should be near the MC
42
Oscillator types
43
(a) Resistor–capacitor (RC). (b) Crystal or ceramic
The 16F84A clock oscillator
• Types:
1) XT – crystal: 1‐4 MHz
2) HS – high speed: >= 4 MHz, with ceramic resonators.
3) LP – low power: <= 200 KHz, e.g., 32.768 kHz (i.e. 215),
4) RC – resistor‐capacitor
44
(a) Crystal or ceramic, HS, XT or LP. (b) Resistor–capacitor. (c) Externally supplied clock
45
Data Sheet Information
46
Power Supply
47
100 nF decoupling capacitor
RC Oscillator
48
16F
84A
ope
ratin
g co
nditi
ons
Summary – 1
• The parallel port allows ready exchange of digital data between the outside world and the controller CPU.
• It is important to understand the electrical characteristics of the parallel port and how they interact with external elements.
• While there is considerable diversity in the logic design of ports, they tend to follow similar patterns.
• The internal circuitry is worth understanding, as it leads to effective use of ports.
• The 16F84A has diverse and flexible parallel ports.
49
Summary – 2
• A microcontroller needs a clock signal in order to operate. The characteristics of the clock oscillator determine speed of operation and timing stability, and strongly influence power consumption. Active elements of the oscillator are usually built in to a microcontroller, but the designer must select the oscillator type, and its frequency and configuration.
• A microcontroller needs a power supply in order to operate. The requirements need to be understood and must be met by a supply of the appropriate type.
50
Thanks,..
See you next week (ISA),…
Dr. Ahmed ElShafee, ACU : Fall 2017, MicroControllers٥١