Datasheet
PIC12F609/615/617/12HV609/615
DS41302D-page 30 2010 Microchip Technology Inc.
3.3 Reading the Flash Program
Memory
To read a program memory location, the user must
write two bytes of the address to the PMADRL and
PMADRH registers, and then set control bit RD
(PMCON1<0>). Once the read control bit is set, the
program memory Flash controller will use the second
instruction cycle after to read the data. This causes the
second instruction immediately following the “
BSF
PMCON1,RD
” instruction to be ignored. The data is
available in the very next cycle in the PMDATL and
PMDATH registers; it can be read as two bytes in the
following instructions. PMDATL and PMDATH regis-
ters will hold this value until another read or until it is
written to by the user (during a write operation).
EXAMPLE 3-1: FLASH PROGRAM READ
BANKSEL PM_ADR ; Change STATUS bits RP1:0 to select bank with PMADRL
MOVLW MS_PROG_PM_ADDR ;
MOVWF PMADRH ; MS Byte of Program Address to read
MOVLW LS_PROG_PM_ADDR ;
MOVWF PMADRL ; LS Byte of Program Address to read
BANKSEL PMCON1 ; Bank to containing PMCON1
BSF PMCON1, RD ; PM Read
NOP ; First instruction after BSF PMCON1,RD executes normally
NOP ; Any instructions here are ignored as program
; memory is read in second cycle after BSF PMCON1,RD
;
BANKSEL PMDATL ; Bank to containing PMADRL
MOVF PMDATL, W ; W = LS Byte of Program PMDATL
MOVF PMDATH, W ; W = MS Byte of Program PMDATL