User`s manual

Rabbit 4000 Designer’s Handbook rabbit.com 35
As the compiler compiles code for the extended code window, it checks to see if the code has passed the
midpoint of the window or 0xF000. When the code passes 0xF000, the compiler generates code to slide
the window down by 4 KB so that the code at F000+x becomes resident at 0xE000+x. This automatic pag-
ing results in the code being divided into segments that are typically 4 KB long, but which can be very
short or as long as 8 KB. Transfer of control within each segment can be accomplished by 16-bit address-
ing. Between segments, physical addressing (19- to 24-bit depending on configuration) is required.
Assembly blocks are limited to 4 KB because the compiler cannot generate automatic paging code in
assembly.
5.5 Memory Planning
Design conventions for memory configuration of a Rabbit 4000-based system specify flash and SRAM.
5.5.1 Flash
Code is typically stored in flash memory, so the size of code must be anticipated. Usually code size up to
1 MB is handled by one or two flash memory chips. If you are writing a program from scratch, remember
that 1 MB of code is equivalent to 50,000 to 100,000 C statements, and such a large program can take
years to write. If you are using Dynamic C libraries, it is fairly easy to have this much code in your appli-
cation.
Constant data tables can be conveniently placed in extended memory using the xdata and xstring
declarations supported by Dynamic C, so the amount of space needed for constant data can be added to the
amount of space needed for code.The far keyword can also be used to create constants in xmem using stan-
dard C variables.
5.5.2 Static RAM
C programs vary in how much RAM will be required and having more RAM is necessary for debugging.
Since debugging and program testing generally operate more powerfully and faster when sufficient RAM
is available to hold the program and data, most controllers based on the Rabbit 4000 use a dual footprint
for RAM that can accommodate 128K x 8 or 512K x 8, which are both in 32-pin packages. The base RAM
is interfaced to /CS1 and /WE1, and /OE1.
RAM is required for the following items:
Root Variables - maximum of 40-44 KB, and about 4 KB more if separate I&D space is enabled.
Stack Pages - stack is usually 4 KB, rarely more than 20 KB.
Debugging - as a convenience on prototype units, 1 MB is usually enough to accommodate programs. It
is not necessary to debug in RAM, but may be desirable.
Extended Memory (a.k.a., xmem) - can be used for code and data, such as communications applica-
tions or data logging applications. The amount needed depends on the application.
Table 5-3 Typical Interface Between the Rabbit 4000 and Memory
Primary Flash SRAM Secondary Flash
/CS0, /OE0 and /WE0 /CS1, /OE1 and /WE1 /CS2, /OE0 and /WE0