CCS News

Extended RAM on 24 bit parts

Thursday 24 February, 2022

The 24 bit PIC® architecture allows for very easy access from most instructions to locations 0x0000 to 0x1FFF. There are some additional instructions to move data from a working register to a location in the 0x2000 to 0x7FFF range. Note that 0x0000 to 0x07FF (or 0x0FFF on some parts) are special function registers, not general RAM.

Some devices have more than 30K of RAM. For these devices a special method is required to access the RAM above 30K. This extended RAM is organized into pages of 32K bytes each. The only way to access that RAM from assembly is to set a page register to identify the RAM page and then use indirect addresses from 0x8000 to 0xFFFF. Note that the first page is used to map program memory into the RAM address space. The other pages are the extended RAM.

From C, the compiler will allocate variables into the first page of extended RAM only. To access additional memory special functions must be used.

The basic functions to access that RAM are:

write_extended_ram(p, addr, ptr, n);
Writes n bytes from ptr to extended RAM page p starting at address addr.

Reads n bytes from extended RAM page p starting at address addr to ptr.

The first page is 1.

Example Code:

write_extended_ram(1,0x100,WriteData,8); //Writes 8 bytes from WriteData to
//addresses 0x100 to 0x107 of
//extended RAM page 1.

read_extended_ram(1,0x100,ReadData,8); //Reads 8 bytes from addresses 0x100
//to 0x107 of extended RAM page 1
//to ReadData.

Like us on Facebook. Follow us on Twitter.

About CCS:

CCS is a leading worldwide supplier of embedded software development tools that enable companies to develop premium products based on Microchip PIC® MCU and dsPIC® DSC devices. Complete proven tool chains from CCS include a code optimizing C compiler, application specific hardware platforms and software development kits. CCS' products accelerate development of energy saving industrial automation, wireless and wired communication, automotive, medical device and consumer product applications. Established in 1992, CCS is a Microchip Premier 3rd Party Partner. For more information, please visit

PIC® MCU, MPLAB® IDE, MPLAB® ICD2, MPLAB® ICD3 and dsPIC® are registered trademarks of Microchip Technology Inc. in the U.S. and other countries.