PIC 16F877A Microcontroller Core Features: Unit 6
PIC 16F877A Microcontroller Core Features: Unit 6
Various Registers:
Fig. 6.2. shows various registers in PIC 16F877A.
Status Register
The Status register contains the arithmetic status of the ALU, the Reset status and the bank
select bits for data memory. The Status register can be the destination for any instruction, as
with any other register. If the Status register is the destination for an instruction that affects the
Z, DC or C bits, then the write to these three bits is disabled. These bits are set or cleared
according to the device logic. Furthermore, the TO and PD bits are not writable, therefore, the
result of an instruction with the Status register as destination may be different than intended.
For example, CLRF STATUS, will clear the upper three bits and set the Z bit. This leaves the
Status register as 000u u1uu (where u = unchanged). It is recommended, therefore, that only
BCF, BSF, SWAPF and MOVWF instructions are used to alter the Status register because
these instructions do not affect the Z, C or DC bits from the Status register.
Note: The C and DC bits operate as a borrow and digit borrow bit, respectively, in subtraction.
bit 7 IRP: Register Bank Select bit (used for indirect addressing)
1 = Bank 2, 3 (100h-1FFh)
0 = Bank 0, 1 (00h-FFh)
bit 6-5 RP1:RP0: Register Bank Select bits (used for direct addressing)
11 = Bank 3 (180h-1FFh)
10 = Bank 2 (100h-17Fh)
01 = Bank 1 (80h-FFh)
00 = Bank 0 (00h-7Fh)
Each bank is 128 bytes.
bit 4 TO: Time-out bit
1 = After power-up, CLRWDT instruction or SLEEP 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
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
bit 1 DC: Digit carry/borrow bit (ADDWF, ADDLW,SUBLW,SUBWF instructions)
(for borrow, the polarity is reversed)
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
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
Note: For borrow, the polarity is reversed. A subtraction is executed by adding the two’s
complement of the second operand. For rotate (RRF, RLF) instructions, this bit is loaded with
either the high, or low order bit of the source register.
OPTION_REG Register:
The OPTION_REG Register is a readable and writable register, which contains various control
bits to configure the TMR0 prescaler/WDT postscaler (single assignable register known also
as the prescaler), the external INT interrupt, TMR0 and the weak pull-ups on PORTB.
Note: To achieve a 1:1 prescaler assignment for the TMR0 register, assign the prescaler to the
Watchdog Timer.
bit 7 RBPU: PORTB Pull-up Enable bit
1 = PORTB pull-ups are disabled
0 = PORTB pull-ups are enabled by individual port latch values
bit 6 INTEDG: Interrupt Edge Select bit
1 = Interrupt on rising edge of RB0/INT pin
0 = Interrupt on falling edge of RB0/INT pin
bit 5 T0CS: TMR0 Clock Source Select bit
1 = Transition on RA4/T0CKI pin
0 = Internal instruction cycle clock (CLKO)
bit 4 T0SE: TMR0 Source Edge Select bit
1 = Increment on high-to-low transition on RA4/T0CKI pin
0 = Increment on low-to-high transition on RA4/T0CKI pin
bit 3 PSA: Prescaler Assignment bit
1 = Prescaler is assigned to the WDT
0 = Prescaler is assigned to the Timer0 module
bit 2-0 PS2:PS0: Prescaler Rate Select bits
Fig. 6.3 shows PIC 16F877A Program Memory Map and Stack.
Fig. 6.3 PIC 16F877A Program Memory Map and Stack