0% found this document useful (0 votes)
85 views35 pages

Lecture 06 - 07 AV-314 PIC 16F887 CLOCK

The document discusses oscillator types and configurations for the PIC16F887 microcontroller. It describes the two internal oscillators: the high-frequency HFINTOSC operating at 8MHz and the low-frequency LFINTOSC at 31kHz. The OSCCON register is used to select the internal oscillator frequency and choose between internal and external oscillators. External oscillators can be quartz crystals, ceramic resonators, or RC circuits connected to the OSC1 and OSC2 pins. The configuration word selects the external oscillator mode as RC, XT, HS, etc. The fail-safe monitor ensures the external oscillator clock is stable by switching to the internal oscillator if it fails to start up within 2

Uploaded by

Saqib Sher
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)
85 views35 pages

Lecture 06 - 07 AV-314 PIC 16F887 CLOCK

The document discusses oscillator types and configurations for the PIC16F887 microcontroller. It describes the two internal oscillators: the high-frequency HFINTOSC operating at 8MHz and the low-frequency LFINTOSC at 31kHz. The OSCCON register is used to select the internal oscillator frequency and choose between internal and external oscillators. External oscillators can be quartz crystals, ceramic resonators, or RC circuits connected to the OSC1 and OSC2 pins. The configuration word selects the external oscillator mode as RC, XT, HS, etc. The fail-safe monitor ensures the external oscillator clock is stable by switching to the internal oscillator if it fails to start up within 2

Uploaded by

Saqib Sher
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/ 35

AV-314

Digital Systems-Embedded Systems


Lecture No 06 & 07

“PIC16F887 Oscillators
Textbook (Bates) Section 1.2
PIC 16x Datasheet
PIC Microcontrollers (mikroElectronika) Chapter 08

Number of Slides: 36
1
Objective

• To learn about Oscillator types and


associated options and configurations

2
PIC 16Fx Overview

3
PIC16F887 Pinout

4
PIC16F887 OSCILLATOR

SFR 5
Types of Oscillator
• Internal Oscillator
• External Oscillator

• System Clock Select (SCS) bit of the OSCCON


register selects external or internal

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)

• It is factory calibrated and operates at 8MHz

• HFINTOSC is enabled by selecting one of seven frequencies (between


8 MHz and 125 kHz) and setting the System Clock Source (SCS) bit of
the OSCCON register

• The low-frequency oscillator LFINTOSC is un-calibrated and operates


at 31 kHz

• It is enabled by selecting this frequency (bits of the OSCCON register)


and setting the SCS bit of the same register

13
Oscillator Control (SFR)

• OSTS – Oscillator Start-up Time-out Status bit indicates which


clock source is currently in use. This bit is read only
1 – External clock oscillator is in use; and
0 – One of internal clock oscillators is in use (HFINTOSC or
LFINTOSC)
• HTS – HFINTOSC Status bit (125 kHz - 8 MHz) indicates whether
high-frequency internal oscillator operates in a stable way.
1 – HFINTOSC is stable; and
0 – HFINTOSC is not stable

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)

• OSC1 Pin is available


as GPIO
• OSC2 Pin outputs
selected internal
oscillator frequency
divided by 4

17
Internal Oscillator (INTSCIO Mode)

• Both OSC(1 & 2) pins


are available as GPIOs

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

•No delay required for


frequency stabilization

•Better reliability.

•Stopping clock will halt


the program while
keeping the data intact

24
Oscillator Selection by Config Word

25
External Oscillator in LP, XT or HS Modes

LP mode (Low Power) is used for low-frequency quartz


crystal only.This mode is designed to drive only 32.768 kHz
crystals. Current consumption is minimum.

XT mode is used for intermediate-frequency quartz crystals


up to 8 MHz. Current consumption is medium.

HS mode (High Speed) is used for high-frequency quartz


crystals over 8 MHz. Current consumption is maximum.

26
External Oscillator Modes

27
External Oscillator

Quarts Crystal Ceramic Resonator

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

You might also like