2. Microprocessors & Microcontrollers KAFAZ- 1
Version 2021 Khalil Zeineddine
P
I
C
1
6
F
8
7
7
A
Chapter _1:
To know:
1. Introduction to PIC16F877a
2. Pin out of PIC
3. Internal architecture of PIC
4. Basic elements of PIC
Contents_1:
PIC Introduction
Peripheral Interface Controllers (PIC) is one of the advanced
microcontrollers developed by microchip technologies. These microcontrollers
are widely used in modern electronics applications. A PIC controller
integrates all type of advanced interfacing ports and memory modules.
These controllers are more advanced than normal microcontroller like
8051. The first PIC chip was announced in 1975 (PIC1650). As like normal
microcontroller, the PIC chip also combines a microprocessor unit called
CPU and is integrated with various types of memory modules (RAM, ROM,
EEPROM ,etc), I/O ports, timers/counters, communication ports, etc.
All PIC microcontroller family uses Harvard architecture. This architecture
has the program and data accessed from separate memories so the device has
a program memory bus and a data memory bus (more than 8 lines in a normal
bus).
This improves the bandwidth (data throughput) over traditional von
Neumann architecture where program and data are fetched from the same
memory (accesses over the same bus). Separating program and data memory
3. Microprocessors & Microcontrollers KAFAZ- 2
Version 2021 Khalil Zeineddine
P
I
C
1
6
F
8
7
7
A
further allows instructions to be sized differently than the 8-bit wide data
word. Now we will move to PIC16F877A.
Introduction au PIC16F877a
The essential elements of the PIC 16F877 are:
• A flash EEPROM type program memory of 8K 14-bit words,
• A data RAM of 368 bytes,
• A 256-byte EEPROM memory,
• 05 input output ports, A (6 bits), B (8 bits), C (8 bits), D (8 bits) and E (3
bits)
• 10-bit Analog to Digital converter with 8 selectable inputs,
• USART, Universal serial port, asynchronous mode and synchronous
mode
• SSP, Synchronous serial port
• Three TIMERS with their Prescaler, TMR0, TMR1, TMR2
• Two comparison modules and Capture CCP1 and CCP2
• 15 interrupt sources,
• Clock generator, quartz (up to 20 MHz)
• Code protection,
• Operating voltage from 2 to 5V,
• Sets of 35 instructions.
4. Microprocessors & Microcontrollers KAFAZ- 3
Version 2021 Khalil Zeineddine
P
I
C
1
6
F
8
7
7
A
Pin out :
The PIC 16F877A box described in the figure below includes 40 pins:
1. 33 input / output pins (5 following ports):
• Port A: 6 I / O pins numbered from RA0 to RA5
• Port B: 8 I / O pins numbered from RB0 to RB7
• Port C: 8 I / O pins numbered from RC0 to RC7
• Port D: 8 I / O pins numbered from RD0 to RD7
• Port E: 3 I / O pins numbered from RE0 to RE2
Max output current: 20mA / pin; 200mA / port
5. Microprocessors & Microcontrollers KAFAZ- 4
Version 2021 Khalil Zeineddine
P
I
C
1
6
F
8
7
7
A
2. The VDD and VSS pins are used to power the PIC. Note that we have 2
"VDD" connections and 2 "VSS" connections.
3. The pins OSC1 and OSC2 or CLKIN and CLOUT are used to operate the
internal oscillator of the PIC.
4. The MCLR pin is used to initialize the MC in the event of power-up,
external reset, watchdog and in the event of supply voltage drop.
Internal Architecture
1. The CPU executes the program instructions (encoded in 14 bits),
processes and generates operations on digital information.
2. The 368 byte Random Access Memory (RAM) is used for temporary
storage of data and results.
3. The 256-byte read-only memory (EEPROM) keeps valuable data
semi-permanently.
4. The 8k x 14bits FLASH memory is used to store the program
(instructions).
5. The clock generates the signal that rates the execution of instructions.
6. Bidirectional ports (A - E) allow communication with the outside; the
lines of each port can be programmed as input or output.
7. The timers (3), programmable modules whose functions are:
• Astable (periodic signals)
• Monostable (impulse)
• Counter
• PWM signals (direct current motor control).
8. The 10-bit analog / digital converter ADC - 8 inputs available from 0
to 5V; the results of the conversions are stored in internal registers.
6. Microprocessors & Microcontrollers KAFAZ- 5
Version 2021 Khalil Zeineddine
P
I
C
1
6
F
8
7
7
A
The basic elements of the PIC 16F877A
1. The clock
The clock can be either internal or external. The internal clock consists of a
crystal oscillator or an RC oscillator. With the Quartz oscillator, we can
have frequencies up to 20 MHz depending on the type of μC.
2. The ALU and the W accumulator
The ALU is an 8-Bit Arithmetic and Logic Unit which performs basic
arithmetic and logic operations.
Accumulator W is an 8-bit working register, all two-operand operations go
through it.
Can we have :
An instruction on a single operand which is usually a register
located in RAM.
An instruction on 2 operands. In this case, one of the two
operands is always the accumulator W, the other can be either a
register or a constant.
3. RAM memory
The addressable RAM memory space is 512 positions of 1 byte each:
7. Microprocessors & Microcontrollers KAFAZ- 6
Version 2021 Khalil Zeineddine
P
I
C
1
6
F
8
7
7
A
96 positions are reserved for the SFR (Special Function Registers)
which are the PIC configuration registers.
The remaining 416 positions constitute the GPR registers (General
Propose Registers) or user RAM. On the 16F877, 3 blocks of 16
bytes each are not physically implanted resulting in a user RAM
capacity of 368 GPR.
4. Permanent memories
The PIC 16F877 has 2 permanent memories.
PROGRAM EEPROM memory with a capacity of 8k 14-bit words.
The DATA EEPROM memory with a capacity of 256 bytes.