Professional Documents
Culture Documents
Introduction to PIC
MicrocontrollerUNIT-1
Introduction on PIC 16C7X
GENERAL DESCRIPTION
The PIC16C71X is a family of low-cost, high-performance, CMOS, fullystatic, 8-bit microcontrollers with integrated Analog-to-digital (A/D)
converters, in the PIC16CXX mid-range family.
The PIC16CXX microcontroller family has enhanced core features, eightlevel deep stack, and multiple internal and external interrupt sources.
There are four oscillator options, of which the single pin RC oscillator
provides a low-cost solution, the LP oscillator minimizes power
consumption, XT is a standard crystal, and the HS is for High Speed
crystals.
PIN Description
The clock input (from OSC1) is internally divided by four to generate four
non-overlapping quadrature clocks namely Q1, Q2, Q3 and Q4.
Internally, the program counter (PC) is incremented every Q1, the
instruction is fetched from the program memory and latched into the
instruction register in Q4.
The instruction is decoded and executed during the following Q1 through
Q4.
Instruction Flow/Pipelining
(Example
A fetch cycle begins with the program counter (PC) incrementing in Q1.
In the execution cycle, the fetched instruction is latched into the
Instruction Register (IR) in cycle Q1. This instruction is then decoded
and executed during the Q2, Q3, and Q4 cycles. Data memory is read
during Q2 (operand read) and written during Q4 (destination write).
MEMORY ORGANIZATION
Program Memory Organization
The PIC16C71X family has a 13-bit program counter capable of addressing an
8K x 14 program memory space. The amount of program memory available to
each device is listed below:
The reset vector is at 0000h and the interrupt vector is at 0004h
The data memory is partitioned into two Banks which contain the
General Purpose Registers and the Special Function Registers. Bit RP0 is
the bank select bit.
RP0 (STATUS<5>) = 1 Bank 1
RP0 (STATUS<5>) = 0 Bank 0
Each Bank extends up to 7Fh (128 bytes).
The lower locations of each Bank are reserved for the Special Function
Registers. Above the Special Function Registers are General Purpose
Registers implemented as static RAM.
Both Bank 0 and Bank 1 contain special function registers. Some "high
use" special function registers from Bank 0 are mirrored in Bank 1 for
code reduction and quicker access.
Instruction SET
Byte-oriented operations
Bit-oriented operations
Literal and control operations
All instructions are executed within one single instruction cycle, unless a conditional
test is true or the program counter is changed as a result of an instruction. In this
case, the execution takes two instruction cycles with the second cycle executed as a
NOP. One instruction cycle consists of four oscillator periods. Thus, for an oscillator
frequency of 4 MHz, the normal instruction execution time is 1 ms. If a conditional
test is true or the program counter is changed as a result of an instruction, the
instruction execution time is 2 ms.
1.
Bsf
2.
movlw 0xFF
3.
movwf TRISA
4.
;instruction movwf
2. Indirect Addressing
Indirect unlike direct addressing does not take an address from an instruction
but derives it from IRP bit of STATUS and FSR registers.
Addressed location is accessed via INDF register which in fact holds the
address indicated by a FSR.
In other words, any instruction which uses INDF as its register in reality
accesses data indicated by a FSR register. Let's say, for instance, that one
general purpose register (GPR) at address 0Fh contains a value of 20.
By writing a value of 0Fh in FSR register we will get a register indicator at
address 0Fh, and by reading from INDF register, we will get a value of 20,
which means that we have read from the first register its value without
accessing it directly (but via FSR and INDF).
It appears that this type of addressing does not have any advantages over
direct addressing, but certain needs do exist during programming which can
be solved smoothly only through indirect addressing.