USING EXTERNAL MEMORY

13.5 USING EXTERNAL MEMORY

Some Microchip devices allow the extension or replacement of program memory resources with external (off-chip) memory devices. How the emulator functions for these modes is discussed here.

• External Memory Access • Simulating External Memory Access

DS51519A-page 182

 2005 Microchip Technology Inc.

Getting Started with MPLAB SIM

13.5.1 External Memory Access

The amount of external memory accessed by selected devices and the method of access is discussed here.

13.5.1.1 PIC17CXXX PROGRAM MEMORY MODES PIC17CXXX devices are capable of operating in any one of several program memory

modes, using combinations of on-chip and external program memory. Available program memory modes are as follows:

• The Microprocessor mode permits access only to external program memory; the contents of the on-chip program memory are ignored. The program counter permits access to a linear program memory space and defines the amount of accessible program memory (see Section 13.5.1.4 “Program Counter”.) Microprocessor mode is the default mode of an unprogrammed device.

• The Microcontroller and Protected Microcontroller modes access only on-chip program memory. Attempts to read above the physical limit of the on-chip memory results in unknown data. The Protected Microcontroller mode also enables the code protection feature.

• The Extended Microcontroller mode allows access to both internal and external program memories as a single block. The device can access its entire on-chip program memory; above this, the device accesses external program memory up to the program counter accessible limit (see Section 13.5.1.4 “Program Counter”.) Execution automatically switches between the two memories, as required.

In all modes, the device has complete access to data RAM. For more information, consult the device data sheet section “Memory Organization”.

13.5.1.2 PIC18F6XXX/8XXX PROGRAM MEMORY MODES Certain PIC18F6XXX/8XXX devices are capable of operating in any one of several

Program Memory modes, using combinations of on-chip and external program memory. Please see the data sheet for your device to determine if it supports external memory.

For supported devices, available Program Memory modes are as follows: • The Microprocessor mode permits access only to external program memory; the

contents of the on-chip Flash memory are ignored. The program counter permits access to a linear program memory space and defines the amount of accessible program memory (see Section 13.5.1.4 “Program Counter”.)

• The Microprocessor with Boot Block mode accesses on-chip Flash memory from address 000000h to the end of the boot block. Above this, external program memory is accessed all the way up to the program counter accessible limit (see Section 13.5.1.4 “Program Counter”.) Program execution automatically switches between the two memories, as required.

• The Microcontroller mode accesses only on-chip Flash memory. Attempts to read above the physical limit of the on-chip Flash causes a read of all ‘0’s (a NOP instruction.)

• The Extended Microcontroller mode allows access to both internal and external program memories as a single block. The device can access its entire on-chip

Flash memory; above this, the device accesses external program memory up to the program counter accessible limit (see Section 13.5.1.4 “Program Counter”.) As with Boot Block mode, execution automatically switches between the two memories, as required.

In all modes, the device has complete access to data RAM and EEPROM. For more information, consult the device data sheet section “Memory Organization”.

 2005 Microchip Technology Inc.

DS51519A-page 183

MPLAB ® IDE User’s Guide

13.5.1.3 PIC18C601/801 ROMLESS DEVICES For PIC18C601/801 devices, all program memory address space is external. The

on-chip program counter permits access to a linear program memory space and defines the amount of accessible program memory (see Section 13.5.1.4 “Program Counter”.)

There is a provision for configuring the last 512 bytes of general purpose user RAM as program memory, called “Boot RAM”. See the device data sheet for more information.

13.5.1.4 PROGRAM COUNTER The size of the program counter will determine how much program memory can be

accessed, e.g., a 21-bit program counter permits access to a 2-Mbyte (1-Mword) program memory space (on-chip, off-chip or a combination of both types of program memory.)

13.5.1.5 CONFIGURATION BITS For PIC17CXXX and PIC18F6XXX/8XXX devices, a Program Memory mode is set by

using configuration bits. Depending on the device, the Processor Mode Select bits are located in a configuration register which is programmed when the device is programmed.

For PIC18C601/801 devices, External Bus Data Width is set as a configuration bit. For more information, consult the device data sheet section “Special Features of the

CPU”.

13.5.1.6 EXTERNAL MEMORY INTERFACE The External Memory Interface is a feature that allows the microcontroller to access

external memory devices (such as Flash, EPROM, SRAM, etc.) as program or data memory.

PIC17 Devices When either Microprocessor or Extended Microcontroller mode is selected, PORTC,

PORTD and PORTE are configured as the system bus. PORTC and PORTD are the multiplexed address/data bus and PORTE<2:0> is for the control signals. External components are needed to demultiplex the address and data.

For more information, see the Memory Organization, External Memory Interface section of the device data sheet.

PIC18 Devices Using the MEMCON register, the following may be configured: • External bus enable and disable

• 16-Bit mode – Word Write mode, Byte Select mode or Byte Write mode • Wait – Table read/write bus cycle wait counts (0-3 T CY )

For more information, see the External Memory Interface section of the device data sheet.

DS51519A-page 184

 2005 Microchip Technology Inc.

Getting Started with MPLAB SIM

13.5.2 Simulating External Memory Access

Simulating a device that uses external memory requires the following steps:

1. Setting Configuration Bits

2. Setting External Memory

13.5.2.1 SETTING CONFIGURATION BITS To set the values of configuration bits for your selected device, open the Configuration

Bits window by selecting Configure>Configuration Bits. In the Category column, find the bits you need to set and click on them to change their value.

Note: Configuration bits may also be set in code using __config. Refer to the device data sheet and header file ( .inc or .h) for more information.

13.5.2.2 SETTING EXTERNAL MEMORY To set up MPLAB IDE and MPLAB SIM to recognize external memory, select

Configure>External Memory. Then check “Use External Memory” and enter a range.

 2005 Microchip Technology Inc.

DS51519A-page 185

MPLAB ® IDE User’s Guide

NOTES:

DS51519A-page 186

 2005 Microchip Technology Inc.

MPLAB ® IDE USER’S GUIDE