Lecture 06 - 07 AV-314 PIC 16F887 CLOCK
Lecture 06 - 07 AV-314 PIC 16F887 CLOCK
“PIC16F887 Oscillators
Textbook (Bates) Section 1.2
PIC 16x Datasheet
PIC Microcontrollers (mikroElectronika) Chapter 08
Number of Slides: 36
1
Objective
2
PIC 16Fx Overview
3
PIC16F887 Pinout
•
4
PIC16F887 OSCILLATOR
SFR 5
Types of Oscillator
• Internal Oscillator
• External Oscillator
6
INTERNAL OSCILLATOR
7
Internal Oscillator
• PIC16F887 consists of two separate, internal oscillators:
• HFINTOSC
– High-frequency internal oscillator which operates at 8MHz
– Factory calibrated
• LFINTOSC
– Low-frequency internal oscillator which operates at 31 kHz
– Watchdog timer, Powerup timer and Fail safe clock
monitor use the same timer
8
Clock Control
9
Oscillator Control (SFR)
• Contains
– Frequency Selection bits (IRCF2, IRCF1, IRCF0)
– Frequency Status bits (HTS, LTS)
– System Clock Control/Status Bits (SCS, OSTS)
10
Oscillator Control (SFR)
11
Oscillator Control (SFR)
12
Internal Oscillator Control
• HFINTOSC is connected to the post scaler (frequency divider)
13
Oscillator Control (SFR)
14
Oscillator Control (SFR)
• LTS – LFINTOSC Status bit (31 kHz) indicates whether low-frequency
internal oscillator operates in a stable way
1 – LFINTOSC is stable;
0 – LFINTOSC is not stable
• SCS – System Clock Select bit determines which oscillator is to be
used as a clock source
1 – Internal oscillator is used for system clock;
0 – External oscillator is used for system clock;
The oscillator mode is set by bits in Config Word which are written to
the microcontroller memory during programming
15
Oscillator Selection by Config Word
16
Internal Oscillator (INTOSC Mode)
17
Internal Oscillator (INTSCIO Mode)
18
EXTERNAL OSCILLATOR
19
External Oscillator
• External oscillator is connected to the OSC1 and
OSC2 pins
• Relies on external circuitry for the clock signal and
frequency stabilization
-quarts crystal
-ceramic resonator
-resistor-capacitor circuit
• Oscillator mode is selected by FOSC<2:0> bits in
the Config Word
20
Oscillator Selection by Config Word
21
External Oscillator (RC &RCIO Mode)
F=1/T
T=R*C
•More flexible
•Cheapest
•Less Accurate
22
Oscillator Selection by Config Word
23
External Oscillator EC Mode (0-20 MHz)
EC=External Clock
•Better reliability.
24
Oscillator Selection by Config Word
25
External Oscillator in LP, XT or HS Modes
26
External Oscillator Modes
27
External Oscillator
28
Selecting Oscillator Modes: MikroC Pro
29
Fail Safe Monitor
T=?
30
Fail Safe Monitor
• Detects a failed oscillator by comparing the
internal and external clock sources
• In case it takes more than 2mS for the
external oscillator clock to come, the clock
source will be automatically switched
• The internal oscillator will thereby continue
operating controlled by the bits of the
OSCCON register
31
Enabling Fail Safe Monitor
32
SUMMARY
SFR 33
34
End of Lecture
35