
PIC16CR7X
DS21993C-page 30
2007 Microchip Technology Inc.
3.3
Reading the ROM Program
Memory
A program memory location may be read by writing two
bytes of the address to the PMADR and PMADRH reg-
isters and then setting control bit RD (PMCON1<0>).
Once the read control bit is set, the microcontroller will
use the next two instruction cycles to read the data. The
data is available in the PMDATA and PMDATH regis-
ters after the second NOP instruction. Therefore, it can
be read as two bytes in the following instructions. The
PMDATA and PMDATH registers will hold this value
until the next read operation.
3.4
Operation During Code-Protect
ROM program memory has its own code-protect mech-
anism. External Read operations by programmers are
disabled if this mechanism is enabled.
The microcontroller can read and execute instructions
out of the internal ROM program memory, regardless of
the state of the code-protect Configuration bits.
EXAMPLE 3-1:
ROM PROGRAM READ
TABLE 3-1:
REGISTERS ASSOCIATED WITH PROGRAM ROM
Address
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR,
BOR
Value on
all other
Resets
10Dh
PMADR
Address Register Low Byte
xxxx xxxx
uuuu uuuu
10Fh
PMADRH
—
Address Register High Byte
xxxx xxxx
uuuu uuuu
10Ch
PMDATA Data Register Low Byte
xxxx xxxx
uuuu uuuu
10Eh
PMDATH
—
Data Register High Byte
xxxx xxxx
uuuu uuuu
18Ch
PMCON1
—(1)
—
RD
1--- ---0
Legend:
x
= unknown, u = unchanged, r = reserved, – = unimplemented read as ‘0’. Shaded cells are not used during ROM
access.
Note
1:
This bit always reads as a ‘1’.
BSF
STATUS, RP1
;
BCF
STATUS, RP0
; Bank 2
MOVF
ADDRH, W
;
MOVWF
PMADRH
; MSByte of Program Address to read
MOVF
ADDRL, W
;
MOVWF
PMADR
; LSByte of Program Address to read
BSF
STATUS, RP0
; Bank 3 Required
Required
BSF
PMCON1, RD
; ROM Read Sequence
Sequence
NOP
; memory is read in the next two cycles after BSF PMCON1,RD
NOP
;
BCF
STATUS, RP0
; Bank 2
MOVF
PMDATA, W
; W = LSByte of Program PMDATA
MOVF
PMDATH, W
; W = MSByte of Program PMDATA