Enhanced Mid-Range PIC16F1xxx Data Memory

Last modified by Microchip on 2023/11/22 16:34

Enhanced Mid-Range Memory Organization

Enhanced Mid-Range PIC® MCUs can contain up to 4096 bytes of addressable data memory. The data memory is partitioned into up to 32 memory banks with 128 bytes in each bank.

memory map

PIC16F1xxx data memory contains five data elements:

  • Core registers
  • Special Function Registers (SFGs)
  • General purpose memory
  • Common memory
  • Shadow registers

Back to top

Core Registers

The first 12 entries of each PIC16F1xxx data memory bank contain registers referred to as the core registers. These 12 registers are repeated on each bank. The core registers can be accessed from any active bank.

Core registers include information for:

  • General processing
  • Direct addressing of memory
  • Indirect addressing of memory
  • Interrupt control

Back to top

General Processing Registers

cr processing

STATUS Register

status register

TO - Indicates Watchdog Timer has expired
PD - Sleep instruction status
- Indicates if last instruction resulted in a 0
DC - last instruction resulted in a carry-out from the 4th low-order bit
- last instruction resulted in a carry-out from Most Significant bit

WREG Register

Referred to as the Working Register or W register, WREG serves as an accumulator.

Back to top

Direct Addressing Registers

cr direct

BSR (Bank Select Register)

bsr register

The lower five bits of BSR contain the bank number (0-31) of the active data bank. 

PCL and PCLATH Registers

These registers are used when writing to or reading from the 15-bit Program Counter. 

Back to top

Indirect Addressing Registers

cr indirect

INDF0, FSR0L, FSR0H,
INDF1, FSR1L, FSR1H
These six registers control the two indirect addressing channels on the MCU. 

Back to top

Interrupt Control Register

cr interrupt

INTCON

intcon register

GIE - Global interrupt enable
PEIE - Peripheral interrupt enable
TMR0IE - Timer 0 interrupt enable
INTE - External interrupt enable
IOCIE - Interrupt on change enable
TMR0IF - Timer 0 interrupt flag
INTF - External interrupt flag
IOCIF - Interrupt on change flag

INTCON is the control register for the PIC16F1xxx interrupts. 

Back to top

Special Functions Registers (SFRs)

In each of the PIC16F1xxx's data banks there are up to 20 Special Function Registers (SFRs). The SFRs are located just below the core registers starting at address xxCh. SFRs control the PIC16F1xxx peripherals, digital I/O ports , and oscillator settings.

Unlike the core registers, SFRs are NOT duplicated on each bank. Application programs need to ensure the appropriate bank has been selected before accessing an SFR.

sfrs

The SFRs for each PIC® MCU will vary. Consult the datasheet for the name and location of the SFRs for the MCU you are using.

Back to top

General Purpose Memory

The general purpose memory (RAM) is located on each memory bank just below the SFRs. This memory is available for application data.

gp memory

Back to top

Common Memory

The last 16 bytes of bank 0 (addresses 70h - 7Fh) are repeated on every data bank. This allows application programs to access variables located in these addresses without having to set BSR.

common ram

Back to top

Shadow Registers

Located in the bottom of bank 31 are the PIC16F1xxx shadow and stack registers. The shadow registers save the program's context by capturing several core registers when an interrupt occurs. The core registers are restored when a Return From Interrupt (RETFIE) instruction is executed. 

shadow registers

Back to top