Lecture 4 (Pc's Conflicted Copy 2020-03-24)
Lecture 4 (Pc's Conflicted Copy 2020-03-24)
Status Register
• The STATUS register contains the arithmetic status of the ALU, the RESET status
and the bank select bit for data memory.
• As with any register, the STATUS register can be the destination for any
instruction. 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 device arithmetic and logic results.
• Only the BCF, BSF, SWAPF and MOVWF instructions should be used to alter
the STATUS register because these instructions do not affect any status bit. The C
and DC bits operate as a borrow and digit borrow out bit, respectively, in
subtraction.
1
Status Register
2
Status Register
bit 5 RP0 : Register Bank Select bits (used for direct addressing)
1 = Bank 1 (80h - FFh)
0 = Bank 0 (00h - 7Fh)
3
Option Register
The OPTION_REG register is a readable and writable register which contains various control
bits to configure the
• Timer (TMR0)/ Watchdog (WDT) prescaler,
• the external INT interrupt, TMR0, and
• the weak pull-ups on PORTB.
4
Option Register
The INDF register is not a physical register. Addressing INDF actually addresses the register
whose address is contained in the FSR register (FSR is a pointer). This is indirect addressing.
An effective 9-bit address is obtained by concatenating the 8-bit FSR register and the IRP bit
STATUS<bit 7>), as shown in the figure below. However, IRP is not used in the PIC16F8X.
6
INDF and FSR Registers
7
INDF and FSR Registers
8
EEPROM Memory in PIC16F84
microcontroller
9
2.1- Data EEPROM Memory
• PIC16F84 has 64 bytes of EEPROM memory
locations on addresses from 00h to 63h
• those can be written to or read from (read/write
memory).
• The most important characteristic of this memory is
that it does not lose its contents during power supply
turned off.
EECON1 at address 88h, which contains control bits that control the read/write operation on
EEPROM memory.
• EECON1 is the control register with five low order bits physically implemented.
• The upper-three bits are nonexistent and read as '0's.
• Control bits RD and WR initiate read and write, respectively.
• The WREN bit, when set, will allow a write operation.
• The WRERR bit is set when a write operation is interrupted by a MCLR reset
9
EECON1 Register
bit 1 WR: Write Control bit
1 = Initiates a write cycle.
0 = Write cycle to the EEPROM is complete
10
Reading the EEPROM Data Memory
13
Lecture 2 page 14
Writing to the EEPROM Data Memory
16
Lecture 2 page 14
EEPROM Write Verify
Generally, the EEPROM write failure will be a bit
which was written as a ’0’, but reads back as a ’1’ or
vice versa.
18