13-9
INTERFACING WITH EXTERNAL MEMORY
Observe the following restrictions in choosing an address range for a chip-select output:
• The addresses in the address range must be contiguous.
• The size of the address range must be 2
n
bytes, where n = 8, 9, ..., 20. This corresponds to
block sizes of 256 bytes, 512 bytes, ..., 1 Mbyte.
• The base address of a 2
n
-byte address range must be on a 2
n
-byte boundary (that is, the base
address must be evenly divisible by 2
n
). For example, the base address of a 256-Kbyte
range must be 00000H, 40000H, 80000H, or C0000H. Table 13-6 shows the base addresses
for some address-range sizes.
• The address ranges for different chip-selects must not overlap, unless their BUSCONx
parameters (wait states, bus width, and multiplexing) have the same values. If BUSCONx
registers have different parameter values and an address in their overlapping region is
accessed, the results are unpredictable. See “Example of a Chip-select Setup” on page
13-12 for a chip-select initialization procedure that avoids this difficulty.
For an address range satisfying these restrictions, set up the ADDRCOMx and ADDRMSKx reg-
isters as follows:
• Place the 12 most-significant bits of the base address into bits BASE19:8 in the
ADDRCOMx register (Figure 13-2).
• For an address range of 2
n
bytes, set the n
1
most-significant bits of MASK19:8 in the
ADDRMSKx register (Figure 13-3), where n
1
= 20 – n.
For example, assume that chip-select output x is to be assigned to a 32-Kbyte address range with
base address E0000H. The address range size is 32 × 1024 = 2
15
, and n
1
= 20 –15 = 5. To set up
the registers, write the 12 most-significant bits of E0000H to BASE19:8 in the ADDRCOMx reg-
ister, and set the 5 most-significant bits of MASK19:8 in the ADDRMSKx register:
ADDRCOM
x
= 0E00H
ADDRMSK
x
= 0F80H
Table 13-6. Base Addresses for Several Sizes of the Address Range
Address-
Range Size
1 Mbyte 512 Kbyte 256 Kbyte 512 bytes 256 bytes
Base
Addresses
00000H 00000H 00000H 00000H 00000H
80000H 40000H 00200H 00100H
80000H • • • 00400H 00200H
C0000H 00600H 00300H
• • • • • •
FFB00H FFE00H
FFD00H FFF00H