0% found this document useful (0 votes)
57 views47 pages

Chapter 5 6 Introduction To The PIC Microcontroller

The document discusses the features of PIC microcontrollers including the PIC16F84. It describes the clock generator, reset, ports, CPU, memory organization, timers, and other components of the PIC16F84 microcontroller.

Uploaded by

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

Chapter 5 6 Introduction To The PIC Microcontroller

The document discusses the features of PIC microcontrollers including the PIC16F84. It describes the clock generator, reset, ports, CPU, memory organization, timers, and other components of the PIC16F84 microcontroller.

Uploaded by

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

Microprocessor

Microcontroller Systems

Chapters 5 & 6
Introduction to the
PIC Microcontroller

‫ ﻭﺟﺩﻱ ﺳﻠﻳﻣﺎﻥ ﺍﻟﺣﻠﺑﻲ‬.‫ ﻡ‬.‫ ﺩ‬:‫ﻣﺩﺭﺱ ﺍﻟﻣﺳﺎﻕ‬

12/6/2020 Dr. Eng. Wajdi Halabi 1


Outline of the Chapters 5 & 6
 Microprocessor Vs. Microcontroller
 PIC Microcontroller history and features
 PIC16F84 Microcontroller features
 PIC Clock Generator
 Reset
 Ports
 Center Processing Unit (CPU)
 Memory organization
 Timer & Prescalar
 Flash Memory
 RAM
 ROM
 EEPROM

12/6/2020 Dr. Eng. Wajdi Halabi 2


Microcontrollers
 Definition.

12/6/2020 Dr. Eng. Wajdi Halabi 3


Microcontrollers
 Overview.

 Basically, a microcontroller is a device which integrates a number of


the components of a microprocessor system onto a single microchip.

12/6/2020 Dr. Eng. Wajdi Halabi 4


Microprocessor Vs. Microcontroller
 Microcontroller vs General-Purpose Microprocessor

12/6/2020 Dr. Eng. Wajdi Halabi 5


 Microcontroller vs General-Purpose Microprocessor

12/6/2020 Dr. Eng. Wajdi Halabi 6


Microprocessor Vs. Microcontroller
 Microcontroller vs General-Purpose Microprocessor

12/6/2020 Dr. Eng. Wajdi Halabi 7


Microcontroller Features
 Microcontroller features.
 Processor
– Usually general-purpose but can be app-specific
 On-chip memory
– Often RAM for data, EEPROM/Flash for code
 Integrated peripherals
– Common peripherals
 Parallel I/O port(s)
 Clock generator(s)
 Timers/event counters
– Special-purpose devices such as:
 Analog-to-digital converter (sensor inputs)
 Mixed signal components
 Serial port + other serial interfaces (SPI, USB)
 Ethernet
12/6/2020 Dr. Eng. Wajdi Halabi 8
Microcontroller Features
 Microcontroller features.

 Benefits
 Typically low-power/low-cost
 Target for embedded applications
 Easily programmable
 Simple ISAs (RISC processors)
 Use of development kits simplifies process
 Limitations
 Small storage space (registers, memory)
 Restricted instruction set
 May be required to multiplex pins
 Not typically used for high performance

12/6/2020 Dr. Eng. Wajdi Halabi 9


Microcontroller Features
 There are five major 8-bit microcontrollers:
 Freescale Semiconductor's (formerly Motorola)
68HC08/68HC11
 Intel's 8051
 Atmel's AVR
 Zilog's Z8
 PIC from Microchip Technology.
 Each of the above microcontrollers has a unique
instruction set and register set; therefore, they are
not compatible with each other. Programs written
for one will not run on the others.
 There are 16-bit and 32-bit microcontrollers.

12/6/2020 Dr. Eng. Wajdi Halabi 10


PIC microcontrollers
history and features
 A Brief History of PIC microcontroller.

 In 1989, Microchip Technology Corporation


introduced an 8-bit μC called PIC (Peripheral
Interface Controller).
 This 8 pins chip contains a small amounts of data
RAM, a few hundred bytes of onchip ROM for
program, one timer, and a few pins for I/O ports.
 The family of 8-bit μC: 10xxx, 12xxx, 14xxx,
16xxx, 17xxx, and 18xxx

12/6/2020 Dr. Eng. Wajdi Halabi 11


PIC microcontrollers
history and features
 A Brief History of PIC microcontroller.

http://www.microchip.com
12/6/2020 Dr. Eng. Wajdi Halabi 12
PIC microcontrollers
history and features
 A Brief History of PIC microcontroller.

 They are all 8-bit processors that the CPU can work on
only 8 bits of data a time.
 Problem: not all 100% upwardly compatible in terms of
software when going from one family to another family.
 Ex.: 12xxx - 12-bit wide instructions
16xxx- 14-bit wide instructions
PIC18xxx - 16-bit wide with many new instructions

http://www.microchip.com
12/6/2020 Dr. Eng. Wajdi Halabi 13
PIC microcontrollers
history and features
 Advantages of PIC:

 30 to 100 times faster than other μCs (program


memory is integrated to the chip)
 Smaller size (on-board memory)
 Easy to program, reusable and
 inexpensive

12/6/2020 Dr. Eng. Wajdi Halabi 14


PIC microcontrollers
history and features
 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
12/6/2020 Dr. Eng. Wajdi Halabi 15
PIC microcontrollers
history and features
 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

12/6/2020 Dr. Eng. Wajdi Halabi 16


PIC16F84 Microcontroller Features
 18 pins, DIP18 type (Dual in Package) or SMD type

 Remarks:
RA0 - RA3: Pins on port A. No additional function
RA4 : TOCK1 which functions as a timer
RB0 : Interrupt input is an additional function.
RB1 - RB5: Pins on port B. No additional function.
RB6 : 'Clock' line in program mode.
RB7 : 'Data' line in program mode
MCLR : Reset input and Vpp programming voltage
Vss : Ground of power supply.
Vdd : Positive power supply pole.
OSC1 - OSC2 : Pins for connecting with oscillator.

12/6/2020 Dr. Eng. Wajdi Halabi 17


PIC16F84 Microcontroller Features

12/6/2020 Dr. Eng. Wajdi Halabi 18


PIC16F84 Microcontroller Features

PIC Clock Generator


 To provide a clock for executing a program or
program instructions of microcontroller.
 Types of PIC clock generator:
 A crystal & two capacitors
 Resonators or external resistor-capacitor pair
 Built-in resistor-capacitor Timer Resources

12/6/2020 Dr. Eng. Wajdi Halabi 19


PIC16F84 Microcontroller Features

PIC Clock Generator


 PIC16F84 can operate in four different oscillation
modes:
 LP low power crystal
 XT crystal/resonator
 HS high speed crystal/resonator
 RC resistor/capacitor
 Two configuration bits, FOSC1 & FOSC0 are
used to select one of these four modes

12/6/2020 Dr. Eng. Wajdi Halabi 20


PIC16F84 Microcontroller Features

PIC Clock Generator


 Crystal Oscillator/Ceramic Resonators
 For XT, LP or HS OSC configurations
 Crystal or ceramic resonator is connected to the
OSC1/CLKIN & OSC2/CLKOUT pins

12/6/2020 Dr. Eng. Wajdi Halabi 21


PIC16F84 Microcontroller Features

PIC Clock Generator

 A parallel cut crystal is used to design PIC16F84A


 The use of a series cut crystal may give a freq. out
of the crystal manufacturer’s Specifications

12/6/2020 Dr. Eng. Wajdi Halabi 22


PIC16F84 Microcontroller Features

PIC Clock
Generator

12/6/2020 Dr. Eng. Wajdi Halabi 23


PIC16F84 Microcontroller Features

PIC Clock Generator


 RC Oscillator
 Reduce cost for timing insensitive applications
 Variation of the oscillator frequency:
 operating temperature
 process parameter variation
 difference in lead frame
capacitance between package
types (low CEXT values)
 tolerance of the external
R & C components

12/6/2020 Dr. Eng. Wajdi Halabi 24


PIC16F84 Microcontroller Features

Reset
 Power-on Reset (POR)
 MCLR during normal operation
 MCLR during SLEEP
 WDT Reset (during
normal operation)
 WDT Wake-up
(during SLEEP)

12/6/2020 Dr. Eng. Wajdi Halabi 25


PIC16F84 Microcontroller Features

PORTS
 Physical connection of CPU and outside world – monitor
OR control other components OR devices
 A group of pins which can be accessed simultaneously OR
set the desired combination of zeros and ones
 All port pins can be designated as input OR output

12/6/2020 Dr. Eng. Wajdi Halabi 26


PIC16F84 Microcontroller Features

PORTS: PORTB & TRISB


 PORTA is a 5-bit wide, bi-directional port
 TRISA: data direction register of PORTA
 TRISA = 1, PORTA is
an input (output driver
in Hi-impedance mode)
 TRISA = 0, PORTA is
an output (contents of
the output latch on
the selected pin)

12/6/2020 Dr. Eng. Wajdi Halabi 27


PIC16F84 Microcontroller Features

PORTS: PORTB & TRISB


 PORTB is a 8-bit wide, bi-directional port
 TRISB: data direction register of PORTB
 TRISB = 1, PORTB is
an input (output driver
in HI-impedance mode)
 TRISB = 0, PORTB is
an output (contents
of the output latch on
the selected pin)

12/6/2020 Dr. Eng. Wajdi Halabi 28


PIC16F84 Microcontroller Features

Center Processing Unit (CPU)


 The brain of the µC
 Connect all parts of the µC through a data bus & and an
address bus
 Find, fetch, decode & execute the right instruction
 CPU resources:
 Registers: store temporary information
 ALU: performing arithmetic functions
 Program counter: point to the address of the next instruction to be
executed
 Instruction decoder: interpret the instruction fetched into the CPU

12/6/2020 Dr. Eng. Wajdi Halabi 29


PIC16F84 Microcontroller Features

Center Processing Unit (CPU)

12/6/2020 Dr. Eng. Wajdi Halabi 30


PIC16F84 Microcontroller Features

Center Processing Unit (CPU)


 Arithmetic Logic Unit (ALU)
 Add, subtract, move (left @ right within a register) and logic
operations
 PIC16F84 contains an 8-bit ALU & 8-bit working registers
(WREG)
 ALU instructions: two operands OR one operand
 Two operands: WREG + file register OR immediate constant
 Registers: GPR (General Purposes Registers) & SFP (Special
Function Registers)
 One operand: WREG OR a file register
 Execution of ALU instructions can affect STATUS bits, which are
carry (C), digit carry (DC), and zero (Z).

12/6/2020 Dr. Eng. Wajdi Halabi 31


PIC16F84 Microcontroller Features

Center Processing Unit (CPU)


 Arithmetic Logic Unit (ALU)
 Add, subtract, move (left @ right within a register) and logic
operations
 PIC16F84 contains an 8-bit ALU & 8-bit working registers
(WREG)
 ALU instructions: two operands OR one operand
 Two operands: WREG + file register OR immediate constant
 Registers: GPR (General Purposes Registers) & SFP (Special
Function Registers)
 One operand: WREG OR a file register
 Execution of ALU instructions can affect STATUS bits, which are
carry (C), digit carry (DC), and zero (Z).
12/6/2020 Dr. Eng. Wajdi Halabi 32
PIC16F84 Microcontroller Features

Center Processing Unit (CPU)

12/6/2020 Dr. Eng. Wajdi Halabi 33


PIC16F84 Microcontroller Features

MEMORY ORGANIZATION
 PIC16F84 has two separate memory blocks: data &
program
 Data block: GPR and SFR registers in RAM memory
(read/write memory- static memory), EEPROM memory
 Program block: FLASH memory

12/6/2020 Dr. Eng. Wajdi Halabi 34


PIC16F84 Microcontroller Features

Memory Organization
of PIC16F84

12/6/2020 Dr. Eng. Wajdi Halabi 35


MEMORY ORGANIZATION:
Program Memory
 Used for storing programs (opcodes), directly under control of
program counter (PC)
 Wake up memory (address 0000H) when PIC is powered up.
 Has been carried out in FLASH technology (indicated by the
letter F in the part number, C for one-time programmable
(OTP)): possible to program a µC many times
 Size of 1024 locations, 14 bits width
 Locations 0000h & 0004h are reserved for reset & interrupt
vector, respectively
 The 1st 1Kx14 (0000h-03FFh) are physically implemented
address
 Accessing a location of physically implemented address will
cause a wraparound
12/6/2020 Dr. Eng. Wajdi Halabi 36
MEMORY ORGANIZATION:
Program Memory

Program Memory
Organization

12/6/2020 Dr. Eng. Wajdi Halabi 37


MEMORY ORGANIZATION:
Data Memory
 Also known as file register: data storage, scratch pad & registers for internal
use and functions
 Special Function Registers (SFR).
 8-bit wide
 ALU status, timers, serial communication, I/O ports, ADC, & etc
 function of each SFR is fixed in design, used to control µC or peripheral
 access either directly (names @ addresses) or indirectly (FSR – File Select Register)
 classified into core and peripheral sets
 control bits (RP1, RP0) in STATUS register are used for bank selection
 General Purpose Registers (GPR)
 8-bit wide
 also called general purpose RAM (GP RAM)
 used for data storage & scratch pad
 accessed directly
 addresses in Bank 0 & Bank 1 are mapped together
 Location of SFR and GPR vary from chip to chip, even among members of
the same family
12/6/2020 Dr. Eng. Wajdi Halabi 38
MEMORY ORGANIZATION:
Program Memory

Data Memory
Organization

12/6/2020 Dr. Eng. Wajdi Halabi 39


MEMORY ORGANIZATION:
Program Memory

12/6/2020 Dr. Eng. Wajdi Halabi 40


MEMORY ORGANIZATION:
Program Memory
 SFR File Memory
 Legend: x = unknown, u = unchanged, - = unimplemented, read
as '0', q = value depends on condition
 Note
 1: The upper byte of the program counter is not directly accessible.
PCLATH is a slave register for PC<12:8>. The contents of PCLATH can
be transferred to the upper byte of the program counter, but the contents
of PC<12:8> are never transferred to PCLATH.
 2: The TO and PD status bits in the STATUS register are not affected by
a MCLR Reset.
 3: Other (non power-up) RESETS include: external RESET through
MCLR and the Watchdog Timer Reset.
 4: On any device RESET, these pins are configured as inputs.
 5: This is the value that will be in the port output latch.

12/6/2020 Dr. Eng. Wajdi Halabi 41


PIC16F84 Microcontroller Features

Timer & Prescalar


 Establish relation between a real dimension such as “time” and
a variable which represents status of a time within a
microcontroller
 PIC16F84 has an 8-bit timer, whose its value is continually
increasing to 255 and then it starts all over again: 0, 1, 2, 3, …,
255, 0, 1,… etc
 Prescaler divides oscillator clock before it reaches logic that
increases timer status.
 The first three bits in OPTION register defines divisor
 256 is the highest divisor, means timer clock would increase by
one at every 256th clock
12/6/2020 Dr. Eng. Wajdi Halabi 42
PIC16F84 Microcontroller Features

Timer &
Prescalar

12/6/2020 Dr. Eng. Wajdi Halabi 43


PIC16F84 Microcontroller Features

Flash Memory
 Store permanent information on some palmsized computers
(operating system & core applications)
 Unlike RAM (random-access memory), flash memory can
continue to store information in the absence of a power source.
 Unlike ROM (read-only memory), we can write/update to flash
memory
 More expensive than ROM

12/6/2020 Dr. Eng. Wajdi Halabi 44


PIC16F84 Microcontroller Features

RAM
 Random-access memory
 The most common computer memory to perform necessary
tasks while the computer is on
 An integrated circuit memory chip allows information to be
stored or accessed in any order and all storage locations are
equally accessible.

12/6/2020 Dr. Eng. Wajdi Halabi 45


PIC16F84 Microcontroller Features

ROM
 Read Only Memory
 Non-volatile: hold programs and data that must be retained
even the computer is turned off
 data cannot be easily written to ROM; depending on the
technology used in the ROM, writing may require special
hardware, or may be impossible.
 A computer's BIOS may be stored in ROM.

12/6/2020 Dr. Eng. Wajdi Halabi 46


PIC16F84 Microcontroller Features

EEPROM
 Electrically Erasable Programmable Read Only Memory
 ROM that can be erased electronically and reprogrammed in-
circuit (or with a device programmer).
 EEPROM is very similar to flash memory. The biggest
difference is that the bytes (words) of an EEPROM can be
erased individually.

12/6/2020 Dr. Eng. Wajdi Halabi 47

You might also like