You are on page 1of 25

Architecture of PIC

 Peripheral Interface Controller is a family of


Micro controller by Microchip Technology.
 It Uses Harvard Architecture.
 Here we have separate Data and Program
memories.

Harvard von-Neumann

Program
Data Program and
CPU CPU
Memory Memory Data
Memory
Feature of 16F877
 8 kB of FLASH Program Memory.
 256 bytes of EEPROM Data Memory.
 33 input or output pins.
 20 MHz operating speed(200 ns instruction
cycle)
 High performance RISC CPU.

PIC 16F877 2
Feature of 16F877
 Only 35 simple word instructions.
  Power on Reset (POR).
 Power-Up Timer (PWRT)
 Wide operating voltage range (2.0 –
5.56)volts.
 Low power consumption .
PIC 16F877 Block Diagram

PIC 16F877 4
CPU

A PIC CPU consists of several sub units such


as instruction decoder, ALU, accumulator,
control unit, etc.
 It normally supports Reduced Instruction Set
Computer (RISC) architecture. RISC
Architecture has only 35 instructions.The
execution time is very less 5 MIPS(Million
Instructions per second)
MEMORY

 As like normal microcontrollers, the PIC chip


also has certain amount of RAM, ROM,
EEPROM, other flash memory, etc.
 8 KB of FLASH Program Memory.
 256 bytes of EEPROM Data Memory.
ALU

 ALU normally performs all the arithmetic


operations. One of the operand is normally in
W-Register and second operand can be in any
other register.
BUS

 Address Bus- 13 Bit


 Data Bus- 8 Bit
Brown out delay

 When the power supply drops below a certain


voltage(4 v in case of PIC),it causes PIC to
reset.
Power On Reset

 The Reset function will set the Program


counter to the starting address.
WDT
 A watch dog timer is a simple timer circuit that performs a
specific operation after a certain period of time if something
goes wrong.
 Suppose we have written a program which is compiled
successfully and when we simulate it every time seems to
work fine.
 Then we program the PIC.
 However after a long period of time the program gets stuck
somewhere .
 What needs it this case is some kind of reset if the program is
gets stuck.
 This is a purpose of a watchdog timer circuit.
 When the WDT is enable, a counter starts at 00 and increment
by 1 unit until it reaches FF.
PIC 16F877 11
WDT…..

 When it goes from FF to 00 the PIC will be reset, irrespective


of what it is doing.
 The only way we can stop the WDT, from resetting the WDT
back to 00 throughout the program which is done by the
processor.
 Which indicates that the processor functioning is going on.
 Watchdog timer is thus increases the system reliability.

PIC 16F877 12
W Register

 It is similar to Accumulator in 8051.


 It is an 8 bit register.
 It is only used for ALU operation.
Status Register


Status register is an eight bit register that contains the arithmetic status of the arithmetic
logic unit (ALU), the reset status and the bank select bits for the data memory. The detailed
explanation of status register is given below.

Carry bit(C)

When two 8-bit operands are added ,a 9 bits result occurs,Because the result of addition may
exceeds 256(FFH).
The 9th bit is copied in the Carry bit.
Bit 0 (C): Carry/borrow bit (ADDWF, ADDLW, SUBLW, SUBWF instructions)
1 = A carry-out from the Most Significant bit of the result occurred
0 = No carry-out from the Most Significant bit of the result occurred.

PIC 16F877
14
Digit carry(DC)

 This bit indicates a Carry from the lower 4 bits.During 8 bit


addition.
 If set,it means there is a carry from the 3rd bit to 4th bit position.
 (1 = A carry-out from the 4th low order bit of the result
occurred
 0 = No carry-out from the 4th low order bit of the result.

PIC 16F877 15
Zero(Z)

 Many arithmetic and logic instructions affect


the zero flag.
 if result is zero, Zbit is set, otherwise cleared.
Bit 2, (Z): Zero bit
1 = the result of an arithmetic or logic
operation is zero
0 = the result of an arithmetic or logic
operation is not zero.)
PIC 16F877 16
TO and PD(active low)

 Used along with the SLEEP mode of PIC.


During the sleep mode the microcontroller save lots of power.
After coming out of this mode, the CPU can check these two
status bits to determine which kind of event is responsible to
bring it out of the SLEEP mode
Bit 4, (TO): this is a time-out bit used for timing and counting,
sleep and reset functions.
1 = after power-up, CLRWDT instruction
0 = A WDT time-out occurred
Bit 3, (PD): Power-down bit
1 = after power-up or by the CLRWDT instruction
0 = by execution of the SLEEP instruction
RP0 and RP1

 There are four memory banks ,each of 128


bytes in size.
 For bank selection 2 bits are needed, making
the effective address 9-bit wide.
Direct addressing mode

Microchip has provided only direct addressing mode


for the register file with 7-bits address plus
remaining 8th and 9th bits frozen in the STATUS
REGISTER bits RP1:RP0.

 11 = Bank 3 (180h-1FFh)
 10 = Bank 2 (100h-17Fh)
 01 = Bank 1 (80h-FFh)
 00 = Bank 0 (00h-7Fh)

PIC 16F877 19
Use of RP1:RP0 bits in direct
addressing mode

PIC 16F877 20
Indirect addressing mode

 IRP bit is used for indirect addressing.


 The IRP bit allows selecting either
 1= Bank 2 & bank 3
 0= Bank 0 & bank 1
 The IPR bit and FSR decide the effective 9 bit
address.

PIC 16F877
21
Use of IPR bits in indirect
addressing mode

22
PIC 16F877
FSR (File Selection Register)

 FSR is the pointer used for indirect memory


addressing in the whole register file.
 In PIC every instruction that can be used for direct
addressing may also be used in a different way for
indirect addressing.
 The only difference in indirect addressing mode is
that one has to write the address byte in FSR .

PIC 16F877 23
PCLATH (Program Counter Latch)
 Different from the program counter.
 Any write to PCL will cause the contents of PCLATH to be transferred to
the 13 bit PC higher locations.

PIC 16F877 24
Input/output ports

 PIC 16F877 series normally has five input/output ports.


 They are used for the input/output interfacing with other devices/circuits.
 Most of these port pins are multiplexed for handling alternate function for
peripheral features on the devices.
 The PIC 16F877 chip basically has 5 input/output ports.
 PORT A
 PORT B
 PORT C
 PORT D
 PORT E

PIC 16F877 25

You might also like