PIC16F1847-I/SO Microchip Technology, PIC16F1847-I/SO Datasheet - Page 20

no-image

PIC16F1847-I/SO

Manufacturer Part Number
PIC16F1847-I/SO
Description
14 KB Flash, 1K Bytes RAM, 32 MHz Int. Osc, 16 I/0, Enhanced Mid Range Core 18 S
Manufacturer
Microchip Technology
Datasheets

Specifications of PIC16F1847-I/SO

Lead Free Status / Rohs Status
Lead free / RoHS Compliant

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
PIC16F1847-I/SO
Manufacturer:
MICROCHIP
Quantity:
30 000
Part Number:
PIC16F1847-I/SO
0
PIC16(L)F1847
FIGURE 3-1:
3.1.1
There are two methods of accessing constants in pro-
gram memory. The first method is to use tables of
RETLW instructions. The second method is to set an
FSR to point to the program memory.
DS41453A-page 20
Note 1:
CALL, RETURN
RETFIE, RETLW
Reserved. Shadows to 0000h-1FFFh.
READING PROGRAM MEMORY AS
DATA
Rollover Page 0
Rollover Page 3
Stack (16 Levels)
Reset Vector
Interrupt Vector
PC<14:0>
Page 2
Page 3
Page 0
Page 1
PROGRAM MEMORY MAP
AND STACK FOR
PIC16F/LF1847
15
(1)
(1)
2000h
7FFFh
0000h
0004h
0005h-
07FFh
0800h-
0FFFh
1000h
1FFFh
17FFh
1800h
Preliminary
3.1.1.1
The RETLW instruction can be used to provide access
to tables of constants. The recommended way to create
such a table is shown in
EXAMPLE 3-1:
The BRW instruction makes this type of table very sim-
ple to implement. If your code must remain portable
with previous generations of microcontrollers, then the
BRW instruction is not available so the older table read
method must be used.
3.1.1.2
The program memory can be accessed as data by set-
ting bit 7 of the FSRxH register and reading the match-
ing INDFx register. The MOVIW instruction will place the
lower 8 bits of the addressed word in the W register.
Writes to the program memory cannot be performed via
the INDF registers. Instructions that access the pro-
gram memory via the FSR require one extra instruction
cycle to complete.
ing the program memory via an FSR.
The HIGH directive will set bit<7> if a label points to a
location in program memory.
EXAMPLE 3-2:
constants
my_function
constants
my_function
;THE PROGRAM MEMORY IS IN W
BRW
RETLW DATA0
RETLW DATA1
RETLW DATA2
RETLW DATA3
;… LOTS OF CODE…
MOVLW
CALL constants
;… THE CONSTANT IS IN W
RETLW DATA0
RETLW DATA1
RETLW DATA2
RETLW DATA3
;… LOTS OF CODE…
MOVLW
MOVWF
MOVLW
MOVWF
MOVIW 0[FSR1]
RETLW Instruction
Indirect Read with FSR
LOW constants
FSR1L
HIGH constants
FSR1H
Example 3-2
DATA_INDEX
RETLW INSTRUCTION
ACCESSING PROGRAM
MEMORY VIA FSR
 2011 Microchip Technology Inc.
Example
;Add Index in W to
;program counter to
;select data
;Index0 data
;Index1 data
;Index0 data
;Index1 data
demonstrates access-
3-1.

Related parts for PIC16F1847-I/SO