Indirect Addressing in the PIC16F1xxx MCU

Indirect Addressing Registers

Enhanced Mid-Range PIC® MCUs have two channels which indirectly access data memory. Each channel uses 3 core registers to implement indirect addressing.

FSR0L, FSR0H, and INDF0 control channel 0

FSR1L, FSR1H, and INDF1 control channel 1


Register Usage

The INDFn registers are not physical registers. Any instruction that accesses an INDFn register actually accesses the register at the address specified by the File Select Registers (FSR1H/FSR1L or FSR0H/FSR0L)

To access an address indirectly: first write the address into FSRn, then execute an instruction with INDFn as the operand.

Sample Code using Indirect Addressing


Indirect Addressing Modes

The FSR registers form a 16-bit address that allows an address space with 65536 possible values. Depending on the value placed in FSRn registers, a PIC16F1xxx MCU will access the memory in one of three different modes:

Traditional Data Memory Access

When the value of FSRn is between 0h and FFFh instructions using INDFn will access the memory in the Traditional Access Method. In this mode of operation all memory locations including Special Function Registers, General Purpose RAM, and the Common memory are accessable through INDFn.


Linear Data Memory Access

Each memory bank contains 80 bytes of general purpose memory (addresses 20h-6Fh). When the application requires an array or buffer of data which exceeds 80 bytes, traditional indirect access may not provide convenient interface to the data structure. The linear addressing method is designed to handle data structures larger than 80 bytes.

When FSRxH<7:5> contains '001' the general purpose sections of the data banks are accessed as if they were one contiguous memory block. When an FSR is incremented beyond the GPR limit of a bank, the GPR memory of the next bank is automatically accessed making the entire GPR memory appear as one contiguous block.


Program Memory (FLASH) Access

To make constant data access easier, the entire program Flash memory can be mapped to the FSR space. When Bit7 of the FSRxH register is set, the remaining 15 bits of FSR point to an address in Program memory. In the Program Memory mode the MCU's flash memory contents can be read, but not altered. When accessed, only the lower 8 bits of the program memory are read. Access to an unimplemented memory address will always return a '0'.

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.