Specifications

Chapter 2 - Microcontroller PIC16F84
bsf STATUS, RP0
Instruction BSF sets the bit RP0 (RP0=1) in STATUS register and thus sets up bank1.
Usually, groups of instructions that are often in use, are connected into one unit which can easily
be recalled in a program, and whose name has a clear meaning, so called Macros. With their use,
selection between two banks becomes more clear and the program itself more legible.
BANK0 macro
Bcf STATUS, RP0 ;Select memory bank 0
Endm
BANK1 macro
Bsf STATUS, RP0 ;Select memory bank 1
Endm
Locations 0Ch - 4Fh are general purpose registers (GPR) which are used as RAM memory.
When locations 8Ch - CFh in Bank 1 are accessed, we actually access the exact same
locations in Bank 0. In other words , whenever you wish to access one of the GPR
registers, there is no need to worry about which bank we are in!
Program Counter
Program counter (PC) is a 13 bit register that contains the address of the instruction being
executed. By its incrementing or change (ex. in case of jumps) microcontroller executes program
instructions step-by-step.
Stack
PIC16F84 has a 13-bit stack with 8 levels, or in other words, a group of 8 memory locations of 13 -
bits width with special function. Its basic role is to keep the value of program counter after a jump
from the main program to an address of a subprogram . In order for a program to know how to go
back to the point where it started from, it has to return the value of a program counter from a
stack. When moving from a program to a subprogram, program counter is being pushed onto a
stack (example of this is CALL instruction). When executing instructions such as RETURN, RETLW
or RETFIE which were executed at the end of a subprogram, program counter was taken from a
stack so that program could continue where was stopped before it was interrupted. These
operations of placing on and taking off from a program counter stack are called PUSH and POP,
and are named according similar instructions on some bigger microcontrollers.
In System Programming
In order to program a program memory, microcontroller must be set to special working mode by
bringing up MCLR pin to 13.5V, and supply voltage Vdd has to be stabilized between 4.5V to 5.5V.
Program memory can be programmed serially using two 'data/clock' pins which must previously
be separated from device lines, so that errors wouldn't come up during programming.
Addressing modes
RAM memory locations can be accessed directly or indirectly.
Direct Addressing
Direct Addressing is done through a 9-bit address. This address is obtained by connecting 7th bit
of direct address of an instruction with two bits (RP1, RP0) from STATUS register as is shown on
the following picture. Any access to SFR registers can be an example of direct addressing.
http://www.mikroelektronika.co.yu/english/product/books/PICbook/2_06Poglavlje.htm (3 of 5) [4/2/2003 16:17:50]