The LPC288x is an ARM7-based microcontroller for portable applications requiring low
power and high performance. It includes a USB 2.0 High Speed device interface, an
external memory interface that can interface to SDRAM and Flash, an MMC/SD memory
card interface, A/D and D/A converters, and serial interfaces including UART , I
Architectural enhancements like multi-channel DMA, processor cache, simultaneous
operations on multiple internal buses, and flexible clock generation help ensure that the
LPC288x can handle more demanding applications than many competing devices. The
chip can be powered from a single battery, from the USB, or from regulated 1.8 and 3.3V.
• ARM7TDMI processor with 8 kB cache operating at up to 60 MHz
• 1 MB on-chip Flash Program Memory with 128-bit access for high performance
• 64 kB SRAM
• 32 kB ROM
• On-chip DC-DC converter can generate all required voltages from a single battery or
from USB power
• Multiple internal buses allow simultaneous GP DMA, USB DMA, and program
execution from on-chip Flash without co nt en tio n.
• External memory controller supports Flash, SRAM, ROM, and SDRAM.
• Advanced Vectored Interrupt Controller, supporting up to 30 vectored interrupts
• Innovative Event Router allows interrupt, power-up, and clock-start capabilities from
up to 105 sources
• Multi-channel GP DMA controller that can be used with most on-chip peripherals as
well as for memory-to-memory transfers.
• Serial Interfaces:
– Hi-Speed or Full-speed USB 2.0 Device (480 or 12 Mbits/s) with on-chip PHYsical
layer
– UART with fractional baud rate generation, flow control, IrDA support, and FIFOs
2
– I
C Interface
2
– I
S (Inter-IC Sound) interface for independent stereo digital audio input and output
• Secure Digital (SD) / MultiMediaCard (MMC) memory card interface
• 10 bit A/D Converter with 5-channel input multiplexing
• 16 bit stereo A/D and D/A converters with gain control and optional DMA
• Advanced clock generation and power control reduce power consumption
• Two 32-bit Timers with selectable prescalers
• 8-bit LCD interface bus
• Real Time Clock can be clocked by 32 kHz oscillator or another source
• Watchdog Ti mer with interrupt and/or reset capabilities
The LPC288x includes an ARM7TDMI CPU with an 8kB cache, an AMBA Adva nc ed
High-performance Bus (AHB) interfacing to high speed on-chip peripherals and internal
and external memory, and four AMBA Advanced Peripheral Buses (APBs) for connection
to other on-chip peripheral functions. The LPC288x permanently configures the
ARM7TDMI processor for little-endian byte order.
The LPC288x includes a multi-layer AHB and four separate APBs, in order to minimize
interference between the USB controller, other DMA operations, and processo r act ivity.
Bus masters include the ARM7 itself, the USB block, and the general purpose DMA
controller.
UM10208
Chapter 1: LPC2800 Introductory information
Lower speed peripheral functions are connected to the APBs. Four AHB-to-APB bridges
interface the APBs to the AHB.
5.ARM7TDMI processor
The ARM7TDMI is a general purpose 32 bit microprocessor that offers high performance
and very low power consumption. The ARM architecture is based on Reduced Instruction
Set Computer (RISC) principles, and the instruction set and related decode mechanism
are much simpler than those of microprogrammed Complex Instruction Set Computers.
This simplicity results in a high instruction throughput and impressive real-time interrupt
response from a small and cost-effective processor core.
Pipeline techniques are employed so that all part s of the pro cessing and memory systems
can operate continuously. T ypically, while one instr uction is b eing e xecuted, it s successo r
is being decoded, and a third instruction is being fetched from memory.
The ARM7TDMI processor also employs a unique architectural strategy known as
THUMB, which makes it ideally suited to high-volume applications with memory
restrictions, or applications where code density is an issue.
The key idea behind THUMB is that of a super-reduced instruction set. Essentially, the
ARM7TDMI processor has two instruction sets:
• The standard 32 bit ARM instruction set.
• A 16 bit THUMB instruction set.
The THUMB set’s 16 bit instruction length allows it to approach twice the density of
standard ARM code while retaining most of the ARM’s performance advantage over a
traditional 16 bit processor using 16 bit registers. This is possible because THUMB code
operates on the same 32 bit register set as ARM code.
THUMB code be as little as 65% of the code size of ARM, and 160% of the performance
of an equivalent ARM processor connected to a 16 bit memory system.
The ARM7TDMI processor is described in detail on the ARM website.
6.On-Chip flash memory system
The LPC2888 includes a 1 MB Flash memory system. This memory may be used for both
code and data storage. Programming of the Flash memory may be accomplished in
several ways. It may be programmed In System via the USB port. The application
program may also erase and/or program the Flash while the application is running,
allowing a great degree of flexibility for data storage and field firmware upgrades.
The Flash is 128 bits wide and includes buffering to allow 3 out of 4 sequential read
operations to operate without wait states.
7.On-Chip Static RAM
The LPC288x includes 64 kB of static RAM that may be used for code and/or data
storage.
UM10208
Chapter 1: LPC2800 Introductory information
8.On-Chip ROM
The LPC288x includes 32 kB of Read Only Memory that may be used for code and/or
constant storage. Execution begins in on-chip ROM after a Reset.
Philips provides a standard boot code in this ROM that reads the state of the Mode inputs
and accordingly does one of the following:
1. starts execution in internal Flash,
2. starts execution in external memory,
3. performs a hardware self-test, or
4. downloads code from the USB interface into on-chip RAM and transfers control to the
downloaded code.
ARM processors have a single 4 GB address space. The following table shows how this
space is used on the LPC288x. Addresses not shown in this table are not used.
Table 1.LPC288x memory usage
Address range General useAddress range details and description
0x0000 0000 to
0x0FFF FFFF
0x1000 0000 to
0x1FFF FFFF
0x2000 0000 to
0x5FFF FFFF
0x8000 0000 to
0x8FFF FFFF
Cacheable area0x0020 0000 - 0x0020 7FFFInternal ROM (32 kB)
0x0040 0000 - 0x0040 FFFFInternal RAM (64 kB)
(other addresses)Software can map other internal and external
memory into this area, to improve its effective
access time.
Peripheral devices on the LPC288x are distributed among the ARM High-speed Bus
(AHB) and four ARM Peripheral Buses (APBs). The following table indicates which bus
each device is connected to. Addresses not shown in this table are not used.
Table 2.LPC288x Peripheral devices
Address allocationBusRegister addresses (inclusive) Peripheral de vice
Upon reset, the LPC288x executes code from an internal ROM. This code allows four
possible types of startup. These are:
• Execute code from internal flash memory.
• Execute code from external memory bank 0.
• Download code from USB to memory.
• Test mode. Toggles a port pin to indicate basic device functionality.
Internal pulldowns on the P2.3 and P2.2 pins cause them to read as 0 when u nconnected.
This results in the default startup mode being execution from internal Flash memory. One
or two external pullup resistors can cause startup to use one of the other modes, as
shown in Table 3–3
Table 3.Boot flow chart
P2.3/Mode2P2.2/Mode1 Mode selected
00Execute user program from internal flash memory.
01Execute user program from external memory on bank 0.
10Download program from USB port to memory.
11Test mode.
.
3.Boot mode descriptions
The boot process is illustrated in figure 1. The following discussion describes each boot
mode in more detail.
Mode 0: Execute user program from internal flash memory
This is the default mode if the P2.3 and P2.2 pins are left unconnected. The Flash
memory begins at address 0x1040_0000. This is the address branched to in this mode.
In order to prevent accidental execution of an unprogrammed Flash, the ROM code
checks for a specific valid user program marker value in memory prior to branching into
the Flash memory. This marker is stored as address 0x104F_F800, 2K bytes below the
top of the 1MB Flash memory. The value expected here is 0xAA55_AA55. If Mode 0 is
selected and the valid user program marker va lue is not fo un d in the Fla s h , con tr ol is
transferred to Mode 2 (USB download mode ).
Mode 1: Execute user program from external memory on static memory bank 0
Static bank 0 of external memory controller is used in a default configuration to execute a
user program. The configuration of static bank 0 following reset is for a bus wid th of 16 bit s
and an active low chip select. The starting address used for the external static memory is
0x2000_0000. The full address range for bank 0 is 0x4000_000 0 through 0x401F_FFFF,
a 2 megabyte space.
Mode 2: Download program from USB port to memory (DFU mode)
The purpose of this mode is to allow programming of the internal Flash memory via USB.
Files to be download must be specially formatted in order to be handled by the ROM
download code. A conversion program and a DFU downloader are available from Philips.
Mode 3: Test mode
This mode is a simple test for device function. Port pin P2.1 is toggled to indicate basic
functionality of the device in its current environment.
The ARM CPU in the LPC288x has been extended with a 2-way set-associative cache
controller. The cache is 8 kB in size and can store both data and instruction code.
The biggest benefit of this cache is that if code is run from non-zero-wait sta te memory, for
instance the internal FLASH controller, these memories can still behave almost as if they
are zero-wait state memory. If code is executed from the cache, the CPU will run at 1
clock per instruction most of the time.
The trade-off in introducing this cache is that each AHB access that bypasses the cache
will have an extra wait state inserted. So, it is generally advisable that both instruction
caching and data caching are turned on for most regions of on and off-chip memory.
• 8 kB in a 2-way set-associative cache
• Configured as 2×128 cache lines of eight 32-bit words each
• Sixteen pages of address mapping each allow any address range to be selected for
caching
3.Cache definitions
• A 2-way cache includes two cache lines that can be used for each memory address.
• A cache line is 8 consecutive 32 bit words. The cache contains 128 cache lines, each
with 2 ways, making 8 kB total.
• The association of memory addresses to cache lines is that cache line 0 corresponds
with address word addresses 0x0 to 0x07, cache line 1 corresponds with word
addresses 0x08 to 0x0F, etc. After 1024 words, this repeats. Thus, word address 0,
word address 1024, word address 2048, ... all map to cache line 0.
• A tag word is associated with each cache line. The tag includes the address each
cache line is currently associated with, a "dirty" flag that indicates if the line has been
written to since it was read from memory, and a "Least Recently Used" tag that
identifies which of the two cache lines should be overwritten if another address that
maps there is accessed by the CPU.
• For the purposes of cache operation, memory is divided into pages of 2 megabytes,
composed of 4 kB sub-pages (1024 words of 32 bits).
• A cache line is marked as "dirty" when the CPU writes to an address which is
currently in the cache. In this case, the data in the "real" memory no longer reflects the
actual value. The entire cache line is marked as dirty when any element within that
cache line is written.
• A cache miss is defined as a read or write by the CPU to an address in memory which
• A cache hit is defined as a read or write by th e CPU to an address in memory which is
• A cache flush is the act of writing a dirty cache line back to memory.
4.Description
Figure 4–4 shows the structure of the cache and how memory addresses map to cache
lines. For caching purposes, memory is divided into pages of 2 megabytes of 4 kB
sub-pages (1024 words of 32 bits). The sub-pages correspond to 128 cache lines (128
entries of eight 32-bit words).
The associated cache line in memory will be stored in cache memory at a fixed position.
An example sequence could begin with an access to one of the first 8 words of a 2
megabyte page of memory. These words will be stored on the first cache line (cache line
0) of Way_0. An access to one of the second 8 words in the same page will be stored on
the second cache line (cache line 1) of Way_0. Later, if an address that maps to cache
line 0 is read from a different portion of memory, it will be stored in Way_1 (since Way_1
has not yet been used). If still another address mapping to cache line 0 is read, the Least
Recently Used tag is used to decide whether the new line will be stored in Way_0 or
Way_1. The least recently used previously cached line must be r emoved, and the new
line stored in its place. In this example, the way that is overwritten will be Way_0, since
Way_1 was used more recently. If the cache line that must be removed is marked as
“dirty”, it will be written back to memory prior to being overwritten by the new memory line.
UM10208
Chapter 4: LPC2800 Cache
currently in cache.
Note that the cache can be set to work only for instruction accesses, only for data
accesses, or for both. This is done via the DATA_ENABLE and INSTRUCTION_ENABLE
bits in the CACHE_SETTINGS register.
The cache has 16 configurable pages, each being 2 megabytes in size. The cache treats
these 16 pages as if they occupy the bottom 32 Megabytes of the system memory map,
which is their default mapping. The cache can re-map any of these pages such that the
physical address is above the lower 32 megabytes.
In Figure 4–5
On the left of the diagram, memory is shown with no remapping, as issued by the CPU.
, a diagram showing physical memory and a virtual page mapping is given.
On the right, a higher physical address is shown mapped into a lower address fo r caching
purposes. To accomplish this, a page is used as a virtual page. Accessing this virtual
page, the cache will re-map the AHB bus address to the higher address range during a
cache miss, cache flush or a write access to the virt ua l page.
In Figure 4–5, page 2 of the lower 32 megabytes of address space has been mapped to
an address in the external static memory space by placing a value of 0x104 in the
PAGE_ADDRESS_2 register. Details of this remapping may be found in the descriptions
of the PAGE_ADDRESS registers later in this chapter.
When re-mapping points to a higher page in the memory map, that page may still also be
accessed directly by the CPU using the original absolute address of the page. In that
case, the cache takes no part in the access. This allows both cached and non-cached
access to the same address region if needed.
Each of the 16 configurable cache pages can be individually enabled and disabled, as
well as having a virtual address programmed.
Following reset, the cache is disabled. The address, data, and control signals of the CPU
AHB bus is routed directly to the multilayer AHB matrix. The response from whichever
functional block is targeted by the address is routed directly to the CPU.
The cache can be enabled by setting the DATA_ENABLE and/or
INSTRUCTION_ENABLE bits in the CACHE_SETTINGS register.
4.1.1Cache function details
For each page of the cache which is enabled, the following points apply:
• If data is read, and not in the cache (a cache miss), a lin e of eight 32-bit words is r ead
• If data is read and is found in the cache (a cache hit), data is read from cache with 0
• If data is written and the location is not in the cache (a cache miss), the data is written
• If data is written, and the location is in the cache because this location has been read
• If a dirty line is about to be discarded because of a cache miss (the cache line needs
• When a cache line is read from memory and stored in the cache (in Way_0 or
UM10208
Chapter 4: LPC2800 Cache
from the AHB bus. In the meantime, the CPU is stalled (and in low power mode if
clock gating is enabled.)
wait states.
directly to memory.
before (a cache hit), then data is written to the cache with 0 wait states, and the line is
marked as dirty.
to be reused for a different memor y region), the old line is first wr itten back to memory
(a cache line flush).
Way_1), the cache controller will mark the other half of the cache line at the same
address as Least Recently Used (LRU) in its tag memory.
5.Register description
The cache controller includes the registers shown in Table4–5. These registers are
accessible in the APB2 address space. It is recommended that the clock gating option be
enabled in the CGU for the APB interface of the CPU in order to reduce power
consumption. Each register is described in more detail in the following sections.
Note: the APB interface of the CPU configuration hardware must be set to run at the same
BASE_CLK frequency as the AHB interface of the CPU before any register is written.
Table 5.Cache and memory mapping registers
AddressRegister nameDescriptionReset
0x8010 4000CACHE_RST_STATMonitors the reset state of the cache.0RO
0x8010 4004CACHE_SETTINGSControls the overall configuration of the cache.0R/W
0x8010 4008CACHE_PAGE_CTRLAllows individual enabling or disabling of caching for the
0x8010 400CC_RD_MISSESIf cache performance analysis is enabled in the
0RO
CACHE_SETTINGS register, this register indicates the
number of times that a cache line is read from memory
(cache read misses).
NXP Semiconductors
UM10208
Chapter 4: LPC2800 Cache
Table 5.Cache and memory mapping registers
AddressRegister nameDescriptionReset
value
0x8010 4010C_FLUSHESIf cache performance analysis is enabled in the
CACHE_SETTINGS register, this register indicates the
number of times that a dirty cache line has been written
back to memory (cache flushes).
0x8010 4014C_WR_MISSESIf cache performance analysis is enabled in the
CACHE_SETTINGS register, this register indicates the
number of times that a write occurs to an address not in
the cache (cache write misses).
0x8010 4018PAGE_ADDRESS_0Re-mapping address for page 0.0R/W
0x8010 401CPAGE_ADDRESS_1Re-mapping address for page 1. The reset value points
this page to the Boot ROM.
0x8010 4020PAGE_ADDRESS_2Re-mapping address for page 2. The reset value points
this page to the on-chip SRAM.
0x8010 4024PAGE_ADDRESS_3Re-mapping address for page 3. The reset value points
this page to the on-chip SRAM.
0x8010 4028PAGE_ADDRESS_4Re-mapping address for page 4. The reset value points
this page to on-chip Flash memory.
0x8010 402CPAGE_ADDRESS_5Re-mapping address for page 5. The reset value points
this page to external static memory bank 0.
0x8010 4030PAGE_ADDRESS_6Re-mapping address for page 6. The reset value points
this page to external static memory bank 0.
0x8010 4034PAGE_ADDRESS_7Re-mapping address for page 7. The reset value points
this page to external SDRAM.
0x8010 4038PAGE_ADDRESS_8Re-mapping address for page 8. The reset value points
this page to external SDRAM.
0x8010 403CPAGE_ADDRESS_9Re-mapping address for page 9.0x400R/W
0x8010 4040PAGE_ADDRESS_10Re-mapping address for page 10.0x401R/W
0x8010 4044PAGE_ADDRESS_11Re-mapping address for page 11.0x102R/W
0x8010 4048PAGE_ADDRESS_12Re-mapping address for page 12.0x104R/W
0x8010 404CPAGE_ADDRESS_13Re-mapping address for page 13.0x106R/W
0x8010 4050PAGE_ADDRESS_14Re-mapping address for page 14.0xER/W
0x8010 4054PAGE_ADDRESS_15Re-mapping address for page 15.0xFR/W
0x8010 4058CPU_CLK_GATEControls gating of the CPU clock when the CPU is
stalled.
0RO
0RO
0x1R/W
0x2R/W
0x2R/W
0x82R/W
0x100R/W
0x100R/W
0x180R/W
0x180R/W
0R/W
Access
5.1Cache Reset Status register (CACHE_RST_STAT, 0x8010 4000)
The read-only CACHE_RST_STAT register monitors the re set status of the cache
controller. If the CACHE_RST bit in the CACHE_SETTINGS register is set and then
cleared by software, this bit indicates the status of the ongoing reset. The reset of the
cache tag memory will take 128 CPU clock-cycles to complete. Table 4–6
definitions for the CACHE_RST_STAT register.
The CACHE_SETTINGS register controls the general setup of the cache, allows r esetting
of the entire cache, and controls the cache performance analysis feature. Table 4–7
shows the bit definitions for the CACHE_SETTINGS register.
0CACHE_RSTCache controller reset control. This bit resets the cache
1DATA_ENABLEEnables use of the cache for storing data.
2INSTRUCTION_ENABLE Enables use of the cache for storing instructions.
UM10208
Chapter 4: LPC2800 Cache
value
0
1: Cache reset is ongoing.
When the cache is reset, sof tware should poll
CACHE_STATUS until it is 0.
value
0
hardware internally, clearing all tags so that the entire
cache is considered empty. This t akes 128 CPU clock
cycles to complete. The reset progress can be followed
by reading register CACHE_RST_STAT.
0 : De-assert reset to the Flash controller .
1 : Assert reset to the Flash controller.
Note: the cache MUST be reset before it is enabled. It is
recommended to include this procedure at system
startup.
0
0 : All storage of data in the cache is disabled. This
applies to all 16 pages.
1 : Storage of data in the cache is enabled. This applies
to all pages enabled via the CACHE_PAGE_CTRL
register.
0
0 : All storage of instructions in the cache is disabled.
This applies to all 16 pages.
1 : Storage of instructions in the cache is enabled. This
applies to all pages enabled via the
CACHE_PAGE_CTRL register.
3PERF_ANAL_RSTAllows a software reset of the cache performance
UM10208
Chapter 4: LPC2800 Cache
value
0
analysis counters in the registers C_RD_MISSES,
C_FLUSHES, and C_WR_MISSES.
0 : Allow performance analysis counters to run, if
enabled.
1 : Reset the cache performance analysis counters.
This has an effect only if performance analysis is
enabled.
4PERF_ANAL_ENAControls the cache performance analysis counters in
the registers C_RD_MISSES, C_FLUSHES, and
C_WR_MISSES. Performance analysis should be
disabled when not needed in order to save power.
0 : Performance analysis is disabled.
1 : Performance analysis is enabled.
31:5 -Reserved. Do not write 1s to reserved bits. The values
read from reserved bits is not defined.
5.3Cache Page Enable Control register (CACHE_PAGE_CTRL,
0x8010 4008)
The CACHE_P AGE_CTRL register a llows individual enabling of caching of each of the 16
pages. Table 4–8
Table 8.Cache Page Enable Control register (CACHE_PAGE_CTRL, 0x8010 4008)
Bit SymbolDescriptionReset
0PAGE_0_ENAThis bit enables caching for page 0.
1PAGE_1_ENAThis bit enables caching for page 1, as described for bit 0.0
2PAGE_2_ENAThis bit enables caching for page 2, as described for bit 0.0
3PAGE_3_ENAThis bit enables caching for page 3, as described for bit 0.0
4PAGE_4_ENAThis bit enables caching for page 4, as described for bit 0.0
5PAGE_5_ENAThis bit enables caching for page 5, as described for bit 0.0
6PAGE_6_ENAThis bit enables caching for page 6, as described for bit 0.0
7PAGE_7_ENAThis bit enables caching for page 7, as described for bit 0.0
8PAGE_8_ENAThis bit enables caching for page 8, as described for bit 0.0
9PAGE_9_ENAThis bit enables caching for page 9, as described for bit 0.0
10PAGE_10_ENA Thi s bit enables caching for page 10, as described for bit 0.0
11PAGE_11_ENA This bit enables caching for page 11, as described for bit 0.0
12PAGE_12_ENA Thi s bit enables caching for page 12, as described for bit 0.0
13PAGE_13_ENA Thi s bit enables caching for page 13, as described for bit 0.0
shows the bit definitions for the CACHE_PAGE_CTRL register.
0: Caching for this page is disabled.
1: Caching for this page is enabled.
Table 8.Cache Page Enable Control register (CACHE_PAGE_CTRL, 0x8010 4008)
Bit SymbolDescriptionReset
14PAGE_14_ENA Thi s bit enables caching for page 14, as described for bit 0.0
15PAGE_15_ENA Thi s bit enables caching for page 15, as described for bit 0.0
31:16 -Reserved. Do not write 1s to reserved bits. The values read
Note: If data caching has been enabled for a writable page, and software then disables
caching, there may be “dirty data” in the cache that still needs to be written to memory.
The C_RD_MISSES register allows reading the number of times that a cache line fill has
occurred (a cache read miss) since the last time that the performance analysis registers
have been reset. The counter only operates if pe rformance analysis has been e nabled via
the PERF_ANAL_ENA bit in the CACHE_SETTINGS register. In order to save power,
performance analysis should be turned off if it is not actually being used.
UM10208
Chapter 4: LPC2800 Cache
value
-
from reserved bits is not defined.
5.5Cache Flushes counter (C_FLUSHES, 0x8010 4010)
The C_FLUSHES register allows reading the number of times that a cache line has been
written back to memory (a cache flush) since the last time that the performance analysis
registers have been reset. A cache line is written back to memory only if it has been
marked as dirty (due to its contents being changed) and the cache line is subsequently
required for normal continuing cache operation. The co unter only operates if perfor mance
analysis has been enabled via the PERF_ANAL_ENA bit in the CACHE_SETTINGS
register. In order to save power, performance analysis should be turned off if it is not
actually being used.
The C_WR_MISSES register allows reading the number of times that a write has
occurred to a memory address that is not in the cache (a cache write miss). The counter
only operates if performance analysis has been enabled via the PERF_ANAL_ENA bit in
the CACHE_SETTINGS register. In order to save power, performance analysis should be
turned off if it is not actually being used.
The 16 P AGE_ADDRESS registers allow remapping of addresses in the range supported
by the cache (the bottom 32 megabytes of memory space) so that they apply to other
address ranges. When the CPU performs an access to an address in the cache range,
any value in the related PAGE_ADDRESS register will replace the top 11 bits of the 32-bit
address. By leaving the bottom 21 bits unaltered, each increment of the value in an
P AGE_ADDRESS register corresponds to a shift of 2 megabytes. In this manner , software
can control which memory address ranges are cached.
For example, if the CPU accesses the address 0x0121_4A90, and the
PAGE_ADDRESS_9 register contains the value 0x82, caching activity and the CPU
access will apply to address 0x1041_4A90:
10:0UPPR_ADDRThis value will replace the top 11 bits of the 32-bit
address coming from the CPU. When the CPU performs
an access to the related page, the address which is
placed on the AHB bus will depend on the value of this
register.
31:11-Reserved. Do not write 1s to reserved bits. The values
read from reserved bits is not defined.
see
Table 4–5
-
5.8CPU Clock Gate control (CPU_CLK_GATE, 0x8010 4058)
The CPU_CLK_GATE register allows saving power by gating the CPU clock when the
CPU is stalled waiting for bus access. Table 4–11
CPU_CLK_GATE register.
Table 11.CPU Clock Gate control (CPU_CLK_GATE, 0x8010 4058)
BitSymbolDescriptionReset
0CPU_CLK_GATE This bit controls clock gating to the CPU. When clock gating is
enabled, power is saved by not clocking the CPU when it is
stalled waiting for bus access.
0: The CPU clock is running continuously.
1: The CPU clock is gated off while the CPU is stalled.
31:1-Reserved. Do not write 1s to reserved bits. The values read
from reserved bits is not defined.
6.Cache programming procedures
6.1Cache initialization
1. Clear the cache:
Set and reset the CACHE_RST bit in the CACHE_SETTINGS register (one clock
cycle is sufficient).
The status flag CACHE_RST_STAT in the CACHE_STATUS indicates whether a
cache reset is ongoing. Software should poll this bit before the cache is enabled.
2. Program the virtual address for each page, if needed:
Software can enable those parts of the memory map that are to be cacheable, by
setting the appropriate bits in the CACHE_PAGE_CTRL register.
Each bit represents one page (2 megabytes) of memory space:
– bit 0 enables 0x0000_0000 to 0x0020_0000 as cached (page 0),
– bit 1 enables 0x0020_0000 to 0x0040_0000 as cached (page 1),
– bit 2 enables 0x0040_0000 to 0x0060_0000 as cached (page 2),
– etc.
3. Program the virtual address for each page, if needed:
The 11 bits programmed for each page represents the top 11 bits of a 32-bit address
that will be put on the AHB bus. This allows any part of the entire 32-bit address range
to be remapped into the bottom 32 megabytes of space, in pages of 2 megabytes.
The PAGE_ADDRESS registers DO NOT reset to a value such that remapping is not
in force, so they should always be initialized even if remapping is not needed in the
application.
Example:
Say address location 0x10400000 (in on-chip Flash) must be mapped for page 3.
That can be done this way:
*PAGE_ADDRESS_3 = (0x10400000 >> 21); // = 0x082;
If the CPU reads address 0x00600004 (an address inside page 3) , then address
0x10400004 is provided to the AHB bus.
Note: care must be taken if remapping a page from which the code is currently
running, or a page that is being used for data, stack or heap storage.
4. Enable the cache for data and /or instructions:
Cache flushing may be required if caching of data is enabled, or when the virtual address
of a page must be changed while this page has caching enabled. Cache flushing is only
necessary if data-caching is enabled.
UM10208
Chapter 4: LPC2800 Cache
Enable the cache by setting the DATA_ENABLE and/or INSTRUCTION_ENABLE bits
in the CACHE_SETTINGS register.
For enabling cache functions, these two bits apply to all cache pages that ar e enabled
via the CACHE_P AGE_CTRL register. For disabling cache functions, these bits apply
to all 16 cache pages, regardless of the setting of the CACHE_PAGE_CTRL register.
The entire cache can be programmed to:
– cache only instructions
– cache only data
– cache both instructions and data
If neither of the two enable bits is set, the cache is disabled.
If data is written to cached memory , the new dat a will initially end up only inside the cache,
and the related cache line marked as dirty. This data is not yet stored in the true physical
location in memory. Since the cache applies only to the ARM7, not to other AHB masters,
if another master (such as the GPDMA) is programmed to copy this data, it will copy the
old data. If the programmer want s to guarantee that the d at a inside the cache is written to
memory, the programmer has to flush the cache.
The cache controller does not include a direct method to cause an immediate cache flush .
If software needs to flush the entire cache, a simple way to accomplish this is to fill the
cache with read-only data (for instance ROM data). This results in every cache line being
checked to see if it is dirty, and written back to memory if needed. Only 1 out of the 8
words from memory corresponding to each cache line must be read in order to flush one
cache line. A total of 256 cache lines must be read in order to fully flush the cache. Below
is a C language example to replace the cache contents, thereby flushing its the cache.
void flush_cache (int * cache_start) {
volatile int * flush_pointer = (volatile int *) cache_start;
volatile int cache_dummy;
int i;
for (i=0;i<2048;i+=8) cache_dummy = flush_pointer[i];
}
Example: Calling the flush_cache procedure with a value of 0x1200 will read 8 kB of
read-only code starting from 0x1200 into the cache, ef fectively flushing all dirty data from
the cache.
A subset of this procedure could be used to flush a portion of the cache (as little as one
cache line) if the line and its original address is known. Any two data locations other than
the location of the currently cached data that maps to the same cache line can be read.
This will cause any of the originally cached data to be flushed if it is marked as dirty.
Cache flushing may be necessary in the following cases:
1. When data caching is enabled for a page , and another bus master such as the GPMA
2. When data caching is enabled for a page, and caching for this page is about to be
3. When data caching in the CACHE_SETTINGS register is about to be disabled. This is
4. When the virtual address of a cached page is about to be changed. This applies for
6.3Avoiding cache flushing
It may be possible to avoid cache flushing in some cases. If the performance dif ference is
not critical, data caching can simply not be enabled. Performance reductions in the 20 to
30% range are possible if data caching is disabled, depending on the application.
UM10208
Chapter 4: LPC2800 Cache
uses this data as well.
disabled. When the caching for a page is disabled, every word is read directly from
memory , bypassin g the cache. If any dat a has been written to that p age, the CPU may
read the wrong data.
a more general version of case 2.
both instruction and data caching. The cache controller is not aware of any changes
made to the address mapping. If the address mapping is changed, software must
ensure that any altered cache contents are flushed. Also, if code was executed from
the page that is about to be remapped, it must be flushed to prevent later execution of
the wrong instructions.
Another way to avoid data caching in certain cases is to have 2 pages that point to the
same memory address range. One page would be set as cacheable, the other as not
cacheable. Data written to the non-cached page is written dire ctly to memory , so other bus
masters can make use of this data without any need to flush the ca che. Ca re mus t be
taken not to write data to one p age, and read the same dat a from the othe r page . This can
be done by separating portions of the page that may be changing from portions that will
not be changing. Changeable portions would be both read and written in the non-cached
address range, while static data would be read from the cached address range.
6.4CPU and cache clocking
The CPU clocking is somewhat different than the rest of the AHB system. Where the rest
of the AHB system is clocked by the CGU (the AHB-BASE_CLOCK, possibly modified by
a fractional divider), the CPU and cache system use the AHB clock as a reference to
generate internal clocks from the AHB_BASE_CLOCK. Inside the cache system is a
clock-gate that uses the reference clock to enable or disable the base clock going to the
CPU and cache system.
Figure 4–6
show some internal signals to illustrate the timing. First, “CPU clock” is the clock as seen
by the CPU. Second, “CPU clock enable” is the signal that determines when the CPU
receives a clock when clock gating is enabled. The CPU clock enable signal goes low one
AHB clock prior to the time when the CPU clock is prevented.
Following is a description of each case shown:
shows timing of some cases of different clock selection settings. These figu res
1. CPU clock gating off, fractional divider not used.
In this case, there is no CPU clock-gating and a fractional di vider for the AHB clock is
not selected. This results in a free-running clock for the AHB, cache and CPU, all
running at the same frequency. This is the reset condition of the system.
Case 1: CPU clock gating off, fractional divider not used.
CPU clock
AHB0 Clock
Internal cache clock
Internal CPU clock
CPU clock enable
Case 2: CPU clock gating off, fractional divider set to 1/7.
CPU clock
AHB0 Clock
Internal cache clock
Internal CPU clock
CPU clock enable
Case 3: CPU clock gating enabled, fractional divider set to 1/7.
2. CPU clock gating off, fractional divider set to 1/7.
3. CPU clock gating enabled, fractional divider set to 1/7.
UM10208
Chapter 4: LPC2800 Cache
In this case, the AHB fractional divider has been set to generate a bus clock once
every 7 base clock cycles.
In this case, CPU clock gating has been enabled. The CPU clock enable signal is
generated by the cache when the CPU must wait because either the cache is read ing
or writing data on the AHB bus, or the cache is jumping in between cache lines,
adding a single wait state.
The LPC2888 includes one megabyte of flash memory. This memory is located on the
AHB and is accessible by all AHB masters. In contrast, the LPC2880 does not include any
on-chip flash memory.
• Flash memory is an AHB slave for data transfer.
• APB slave interface for programmatic flash programming and erasure.
• Interrupt capability when flash erasure or programming is completed.
The flash memory controller has an AHB slave port for transfer of instructions and dat a to
the CPU in response to normal read requests. There is also a APB port for configuring the
Flash controller and for accomplishing programming functions.
3.1Flash organization
The Flash memory is organized into 64 kB large sectors and 8 kB small sectors. For
1 MB of total Flash, there are 15 large sectors and 8 small sectors. The organization of
these sectors and corresponding add ress ra ng e s is shown in Figure 5–7
The flash memory produces 128 bits of data for each read operation. These four words
of data are referred to as a flash word. During progra mming, four flash words are
programmed at a time.
.
3.2Flash buffering
Because the Flash memory is 128 bits wide, while the AHB is a 32 bit interface, a buffer
between the Flash memory and the AHB can reduce power by limiting the number of
Flash reads required, as well as speed up response to reads of consecutive Flash
locations.
A Flash read is a slow process compared to the AHB cycle time. With buffering, the
average read time is reduced, which can improve system performance. A single level
buffer receives data from a Flash read and retains it until another flash read is required.
When an AHB read requires data from the same Flash Wor d as the previous read, a Flash
read is not performed, and read data is given without wait states. During sequential
program execution, a Flash read will only be required for every fourth ARM instruction, or
every eighth Thumb instruction.
When an AHB read requires data from a different Flash Word than the previous read, a
new Flash read is performed and wait states occur until the new read data is available.
The flash buffer is automatically invalidated after:
The Flash controller takes data from the memory after a predefined number of clock
cycles. These clock cycles are called wait states and can be programmed in the
WAIT_STATES field of the F_WAIT register. The optimal number of wait states de pends
on the clock frequency of the AHB clock. As a result, the number of wait states should
typically be changed if the CPU clock rate is changed. To prevent incorrect reads, wait
states should be changed to a larger value just before increasing the CPU clock rate, or
changed to a smaller value just after decreasing the CPU clock rate.
4.In-Application flash programming
4.1Introduction
Programming the embedded flash memory requires a specific sequence of events,
controlled primarily by software.
UM10208
Chapter 5: LPC2800 Flash
The flash memory is organized in sectors, as shown in Figure 5–7
before data can be written into them. The flash memory also has built in protection against
accidental programming.
As software write words to addresses in the Flash memory address range (0x104x xxxx),
the hardware transfers a Flash word (4 words, 16 bytes) into an internal page buffer, af ter
each write to an address 0x104x xxxC. A Flash page is the unit in which the Flash is
programmed: 512 bytes.
Figure 5–8
shaded part of the flow chart represents functions that are done au to m atic ally by the
hardware of the flash controller.
shows a flow chart for programming the flash memory on the LPC2888. The
2. Erasing sectors that have been previously programmed
3. Presetting data latches for each flash word to be programmed
4. Writing
5. Loading
6. Programming
NXP Semiconductors
7. Restoring protection to sectors that have been operated upon
These steps are described in more detail in the following sections.
4.2Sector protection and un-protection
A sector is unprotected by writing an even value to its base address (the starting address
of the sector), followed by writing the unprotect trigger value to the F_CTRL register. The
trigger value for (un)protecting has the following bits set: FC_LOAD_REQ,
FC_PROTECT, FC_WEN, FC_FUNC, and FC_CS. The ot he r bits are zero .
A sector is protected by writing an odd value to its base address, followed by the same
trigger value that was used to unprotect the sector.
4.3Erasing sectors
First, a sector to be erased must be unprotected as described above. Before the erasing,
the erase time must be selected in the timer register FPT_TIME field of the
F_PROG_TIME register, and the timer must be enabled via the FPT_ENABLE field of the
in the same register. During erasing, the timer register counts down to zero. Therefore, the
timer register must be rewritten prior to every erase cycle.
UM10208
Chapter 5: LPC2800 Flash
The programmed erase time must satisfy the requirement:
(512 × FPT_TIME + 2) × (AHB clock time) ≥ 400ms
Which is to say, write FPT_TIME with the integer greater than or equal to:
((400,000,000 / AHB t
A single sector is erased by writing any value to an address within that sector, followed by
writing the erase trigger value to the F_CTRL register. The trigger value for erasing has
the following bits set: FC_PROG_REQ, FC_PROTECT, and FC_CS. The other bits are
zero.
For erasing and other programmi ng ope rat io n s, the Fla sh mod u l e ne ed s a 66 kHz cl ock .
This clock is derived from the AHB clock, dividing it by a factor programmed in the
CLK_DIV field of the F_CLK_TIME register. A value of zero in this field inactivates the
FLASH PROGRAMMING clock.
Erasing multiple sectors can be done with only one longer erase cycle. First all sectors
except the last are selected for erasure. Then the last sector is erased using the single
sector erase procedure. A sector is selected for er as ur e by wr iting any value to an
address within that sector, followed by writing the select for erase trigger value to the
F_CTRL register. This trigger value has the following bits set: FC_LOAD_REQ,
FC_PROTECT, FC_WEN, and FC_CS. The other bits are zero.
The Flash controller can optionally generate an interrup t request when erasing is finished,
otherwise the FS_DONE flag in the F_STAT register can be polled by software to
determine when erasure is complete.
The Flash memory has data latches to store the data that is to be programmed into the
Flash array. When only a part of a Flash page (512 bytes) has to be programmed, the data
latches for the rest of the page must be preset to logical ones. This can be done with a
single control by setting and clearing the FC_SET_DATA bit in the F_CTRL register.
It is possible to read back the data latches by setting bit FD_RD_LATCH in the F_CTRL
register.
4.5Writing and loading
Writing a Word to the Flash controller is done via the AHB. Every write takes 2 clock
cycles (1 wait state), and results in a partial update of the data input of the Flash module.
Writing is done one word at a time. Byte or halfword writing is not possible. However,
because writing logical ones leaves the Flash contents unchanged, it is possible to do
byte writing by encapsulating this byte in a Word of logical ones. This encapsulation must
be done by the AHB master that initiates the transfer.
Every fourth write, a Flash Word (four data words) is loaded automatically into the data
latches of the Flash module. Loading is done per Flash Word.
UM10208
Chapter 5: LPC2800 Flash
For example, when addresses 0x00 through 0x0C are to be loaded, loading is done
automatically after writing to address 0x0C (note that these four addresses form a single
complete Flash Word). This requires that values are already written to addresses 0x00 to
0x08.
Loading can also be done manually by writing a 1 to the FC_LOADREQ bit in the F_CTRL
register.
4.6Programming
First, a sector to be erased must be unprotected as previous ly described. Progr amming is
the data transfer from the data latches of the Flash module into the Flash array. Before
programming, the programming time must be written to the FPT_TIME field of the
F_PROG_TIME register, and the timer must be enabled via the FPT_ENABLE bit in the
F_PROG_TIME register. During programming, the timer register counts down to zero.
Therefore, the timer register must be rewritten before every programming cycle.
The programmed programming time must satisfy the requirement:
(512 × FPT_TIME + 2) × (AHB clock time) ≥ 1ms
Which is to say, write FPT_TIME with the integer greater than or equal to:
((1,000,000 / AHB tcyc (in ns)) - 2) / 512
Programming is started by writing a trigger value to the F_CTRL register. The trigger value
for programming has the following bits set: FC_PROG_REQ, FC_PROTECT, FC_FUNC,
and FC_CS. The other bits are zero.
The page address that is offered to the Flash modu le during programming is the page
address of the most recent write to an address within the Flash memory range.
For programming and erase op er a tion s, the Flash module needs a 66 kHz clock. This
clock is derived from the AHB clock, dividing it by a factor programmed in the CLK_DIV
field of the F_CLK_TIME register. A value of zero in this field inactivates the FLASH
PROGRAMMING clock.
The flash controller can optionally generate an interrupt requ est when programming is
finished.
4.7Program/erase timer
A built-in timer is used to control the program time or erase time. The timer is started by
writing the program or erase time to the FPT_TIME field of the F_PROG_TIME register,
and by enabling it via the FPT_ENABLE bit in the same register. During programming or
erasing, the timer register counts down to zero, and its current value is returned when
reading the F_PROG_TIME register. This timer reading can be used to observe the
progress of programming/erasing.
While the timer is counting down, the flash memory controller is only partly accessible:
• Reads of the flash memory are stalled, using AHB wait states.
• Writes to the flash controller registers are stalled.
• Reads of flash controller registers are completed normally without stalling.
UM10208
Chapter 5: LPC2800 Flash
This can have significant impact on system behavior. It should be insured that the Flash
memory is not busy (the FPT_TIME field in the F_PROG_TIME register = 0 and the
FS_RDY bit in the F_STAT register =1) prior to attempting to read Flash data or write to a
Flash controller register.
5.Register description
The Flash memory controller has registers to set the wait states for normal operation and
registers to control program/erase operations. Flash controller registers are listed in
Table 5–12
Table 12.Flash memory controlle r registers
OffsetRegister nameDescriptionAccessReset
0x8010 2000F_CTRLFlash control registerR/W0x5
0x8010 2004F_STATFlash status registerRO0x45
0x8010 2008F_PROG_TIMEFlash program time registerR/W0
0x8010 2010F_WAITFlash read wait state registerR/W0xC004
0x8010 201CF_CLK_TIMEFlash clock divider for 66 kHz
0x8010 2FECF_INT_SETSet interrupt status bitsWO0x8000 5030FLASH_PDAllows turning off the Flash memory
for power savings.
0x8000 5034FLASH_INITMonitors Flash readiness, such as
recovery from Power Down mode.
R/W1
R/W-
5.1Flash Control register (F_CTRL-0x8010 2000)
The Flash Control register is used to select read modes and to control the programm ing of
the flash memory. The fields in the F_CTRL register are shown in Table 5–13
Table 13.Flash Control re gister (F_CTRL-0x8010 2 000)
Table 13.Flash Control re gister (F_CTRL-0x8010 2 000)
BitsNameDescriptionAccess Reset
12FC_PROG_REQ Request Flash programming.
13-Reserved, user software should not write ones to
14FC_CLR_BUFClear flash data buffer.
15FC_LOAD_REQ Flash data load request.
31:16 -Reserved, user software should not write ones to
UM10208
Chapter 5: LPC2800 Flash
value
R/W0
0: no effect.
1 : request for programming.
-reserved bits. The value read from a reserved bit is not
defined.
R/W0
0 : no effect.
1 : set all bits to 1.
R/W0
0 : no request.
1 : write register to Flash, only valid when FC_FUNC =
1. Data load is automatically triggered after the last
word was written to the load register.
-reserved bits. The value read from a reserved bit is not
defined.
5.2Flash Status register (F_STAT - 0x8010 2004)
The Flash Status register is a read-only register that provides Flash status information
during programming operations. The fields in the F_STAT register are shown in
Table 5–14
Table 14.Flash Status register (F_STAT - 0x8010 2004)
Bits NameDescriptionAccess Reset
0FS_DONEProgramming cycle done.
1FS_PROGGNT Flash bus lock grant.
2FS_RDYFlash ready indication.
4:3-Reserved, user software should not write ones to
5FS_ERRFlash read bit error detection.
31:6 -Reserved. The value read from a reserved bit is not
.
0 : during program/erase.
1 : total program/erase finished (Flash not busy with
program or erase).
0 : Flash bus lock request for program/erase is not
granted.
1 : Flash bus lock request for program/erase is granted.
0 : read, program, or erase is in progress.
1 : Flash is ready for read, program, or erase.
reserved bits. The value read from a reserved bit is not
defined.
0 : no errors detected.
1 : a bit error was detected and corrected.
5.3Flash Program Time register (F_PROG_TIME - 0x8010 2008)
The Flash Program Time register controls the timer for all Flash programming tasks. It
also allows to read the remaining program or erase time. The fields in the F_PROG_TIME
register are shown in Table 5–15
Table 15.Flash Program Time register (F_PROG_TIME - 0x8010 2008)
BitsNameDescriptionAccess Reset
14:0FPT_TIMEProgramming timer. Remaining program/erase time is
15FPT_ENABLE Program timer Enable.
31:16 -Reserved, user software should not write ones to
5.4Flash Wait States register (F_WAIT - 0x8010 2010)
UM10208
Chapter 5: LPC2800 Flash
.
value
R/W0
512 × FPT_TIME clock cycles.
R/W0
0 : timer disabled.
1 : timer enabled.
-reserved bits. The value read from a reserved bit is not
defined.
The Flash Wait State register controls the number of wait states that are used for flash
reads. The fields in the F_WAIT register are shown in Table 5–16
Table 16.Flash Wait States register (F_WAIT - 0x8010 2010)
BitsNameDescriptionAccess Reset
7:0WAIT_STATES Defines the number of wait states used for flash read
operations.
13:8-Reserved, user software should not write ones to
reserved bits. The value read from a reserved bit is not
defined.
15:14 -Reserved, these bits must be left at the reset state (both
bits = 1)
31:16 -Reserved, user software should not write ones to
reserved bits. The value read from a reserved bit is not
defined.
The Flash Clock Divider register controls the divider for the clock that is used by Flash
programming and erase operations. This clock must be set up to provide 66 kHz prior to
beginning programming or erase operations. The fields in the F_CLK_TIME register are
shown in Table 5–17
31:12 -Reserved, user software should not write ones to reserved
5.6Interrupt registers
These flash interrupt registers determine when the flash memory controller issues an
interrupt request to the system interrupt controller. the Flash memory interrupt is asserted
when the corresponding interrupt flag and interrupt enable are both equal to one.
UM10208
Chapter 5: LPC2800 Flash
value
R/W0
0x000 : no programming clock is available to the Flash
memory.
Other : a programming clock is applied to Flash memory. The
frequency is the AHB clock frequency divided by (CLK_DIV ×
3) + 1. This must be programmed such that the Flash
Programming clock frequency is 66 kHz ± 20%.
--
bits. The value read from a reserved bit is not defined.
5.6.1Flash Interrupt Status register (F_INT_STAT - 0x8010 2FE0)
The Flash Interrupt Status register allows reading the interrupt flags that are associated
with flash programming and erase functions. The fields in the F_INT_STAT register are
shown in Table 5–18
Table 18.Flash Interrupt Status register (F_INT_STAT - 0x8010 2FE0)
Bits NameDescriptionAccess Reset
0END_OF_ERASEEnd-of-erase interrupt flag bit. This bit is set when
1END_OF_PROGRAM End-of-Program interrupt flag bit. This bit is set
31:2 -Reserved. The value read from a reserved bit is
.
the erase process for all requested sectors is
finished or when a 1 is written to
F_INT_SET[0].This bit is cleared when a 1 is
written to F_INT_CLR[0].
when a programming operation is completed or
when a 1 is written to F_INT_SET[1]. This bit is
cleared when a 1 is written to F_INT_CLR[1].
not defined.
5.6.2Flash Interrupt Set register (F_INT_SET - 0x8010 2FEC)
The Flash Interrupt Set register allows setting of individual interrupt flags for the Flash
memory. These flags may be read in the F_INT_STAT register. Software setting of
interrupt flags can, for example, allow simulation of Flash programming during code
development. The fields in the F_INT_SET reg iste r ar e sh own in Table 5–19
value
RO0
RO0
--
.
Note: software setting of interrupt flags will cause an interrupt request to be generated if
the corresponding enable bit in the F_INTEN register equals one, and if the interrupt is
enabled in the system interrupt controller.
The Flash Interrupt Clear register allows clearing of individual interrupt flags for the flash
memory. These flags may be read in the F_INT_STAT register. The fields in the
F_INT_CLR register are shown in Table 5–20
Table 20.Flash Interrupt Clear reg is te r (F_INT_CLR - 0x8010 2FE8)
Bits Name DescriptionAccess Reset
1:0CLR_INT These bits allow software clearing of interrupt flag bits in the
31:2Reserved, user software should not write ones to reserved bits. --
UM10208
Chapter 5: LPC2800 Flash
value
WO-
F_INT_STAT register.
0 : leave the corresponding bit unchanged.
1: set the corresponding bit.
.
value
WO-
F_INT_STAT register.
0 : leave the corresponding bit unchanged.
1: clear the corresponding bit.
The Flash Interrupt Enable register indicates which of the interrupt flags that are
associated with programming and erase functions are enabled to send interrupt requests
to the interrupt controller. Additional control of interrupts is provided by the interrupt
controller itself. The fields in the F_INTEN register are shown in Table 5–21
This bit is set when a 1 is written to F_INTEN_SET[0].
This bit is cleared when a 1 is written to F_INTEN_CLR[0].
1EOP_ENABLE End-of-Program interrupt enable bit.
This bit is set when a 1 is written to F_INTEN_SET[1].
This bit is cleared when a 1 is written to F_INTEN_CLR[1].
31:2 -Reserved. The value read from a reserved bit is not
defined.
.
RO0
RO0
--
5.6.5Flash Interrupt Enable Set register (F_INTEN_SET - 0x8010 2FDC)
The Flash Interrupt Enable Set register allows setting of individual in terrupt ena ble bit s for
the interrupt flags that are associated with programming and erase functions. The fiel ds in
the F_INTEN_SET register are shown in Table 5–22
The Flash Interrupt Enable Clear register allows clearing of individual interrupt enable bits
for the interrupt flags that are associated with programming and erase functions. The
fields in the F_INTEN_CLR register are shown in Table 5–23
1:0CLR_ENABLE These bits allow software clearing of interrupt enable bits
31:2 -Reserved, user software should not write o nes to reserved
UM10208
Chapter 5: LPC2800 Flash
value
WO0
the F_INT_STAT register.
0 : leave the corresponding bit unchanged.
1: set the corresponding bit.
--
bits.
.
value
WO0
in the F_INT_STAT register.
0 : leave the corresponding bit unchanged,
1: clear the corresponding bit.
--
bits.
5.6.7Flash Power Down register (FLASH_PD - 0x8000 5030)
The FLASH_PD register allows shutting down the Flash memory system in order to save
power if it is not needed. During power-up an d whe n the Fla sh me mor y exits power down
mode, it requires additional time for internal initialization, see the FLASH_INIT register
description. The fields in the FLASH_PD register are shown in Table 5–24
Table 24.Flash Power Down register (FLASH_PD - 0x8000 5030)
Bits NameDescriptionAccess Reset
0FLASH_PD Flash memory system Power Down control.
0: The Flash is powered down.
1: The Flash system is powered up, time must be allowed for
internal initialization prior to accessing Flash memory.
31:1 -Reserved, user software should not write ones to reserved
bits. The value read from a reserved bit is not defined.
During power-up or when the Flash has been in Power down mode and then re-activated
(see the FLASH_PD register), this status allows determining when the Flash has
completed its internal initialization and is ready for use. When the MODE pins indicate
execution from Flash (see the Boot Process chapter), the boot code waits for this status
bit to be 0 before reading the valid program marker word from Flash. The fields in the
FLASH_INIT register are shown in Table 5–25
The LPC288x includes an on-chip power system which allows the device to be powered
by a standard single cell battery (AA or AAA for example), as well as from a USB port or
other power source.
The LPC288x needs two supply voltages, 3.3V and 1.8V, for various internal functions.
When power is available from a higher voltage source such as USB, two internal Low
Dropout regulators (LDO regulators ) redu ce the incoming voltage to those needed by the
LPC288x. When only a low voltage battery supply is available, two DC-DC converters
boost the voltage up to the needed levels. Switching between the two modes is supporte d.
For example, a handheld, battery powered device can be plugged into a USB port and
use that power while connected in order to save battery life. For the sake of brevity, the
entire power regulation system is referred to as the DC-DC converter.
The basic connections within the DC-DC converter are shown in Figure 6–9. Depicted are
two inductive DC-DC converters, which are used when the chip is operated from a battery
supply. These converters deliver 1.8 V and 3.3 V to the pins DCDC_V
DCDC_V
Figure 6–9
When the chip is supplied from USB or other higher voltage source (in the range of 4.0 V
to 5.5 V), the DC-DC converters will be turned off and the two linear regulators will be
used instead, producing similar voltages on the DCDC_V
An internal bandgap reference and a Ring Oscillator are connected such that they are
powered whenever either the battery supply or the USB supply is receiving power. The
DC-DC controller checks the DC-DC converter output voltages when they are operating
and uses that information to adjust the converters to keep the output voltage in range.
During the start-up the DC-DC Controller uses the Ring Oscillator to control the switching
regulators. After start-up, software may switch the DC-DC clock to the 12 MHz crystal.
DDO(3V3)
.
UM10208
Chapter 6: LPC2800 DC-DC converter
DDO(1V8)
respectively . No te that externally req uired component s are not sho wn in
pins.
DDO
and
When operating from a battery supply, the output voltage of DCDC_V
DCDC_V
registers DCDCADJUST1 and DCDCADJUST2.
DDO(1V8)
can be controlled by software. This is done via 3 adjustment bits in the
DDO(3V3)
2.1Local power
As previously mentioned, the internal bandgap reference and the Ring Oscillator are
powered whenever either the USB or battery supply is available. The power selected is
USB power (divided by 3) if it is available, followed by battery power if available.
2.2Supply_OK
The output of the DC-DC converters or LDO regulators are monitored by comparators that
indicate when the supply is providing both 1.8 and 3.3 V power. This indication is used
internally by the DC-DC converter and is defined here so that it may be shown in the
power timing diagrams later in this section.
2.3Battery connection in an application
Figure 6–10 below shows an example of how the DC-DC Converter may be connected in
an application that uses battery and/or USB power.
. External power may be supplied from any suitable
NXP Semiconductors
DCDC_V
DDO(3v3)
DCDC_V
DDO(1v8)
DCDC_V
DDO(3v3)
DCDC_V
BAT
DCDC_V
USB
STOP
START
DCDC_GND
DCDC_CLEAN
DCDC_LX1
DCDC_LX2
DCDC_V
SS1
DCDC_V
SS2
LPC288x
L18
L17
N18
N17
N16
P18
R18
P17
M16
L16
M18
M17
T18
External
power
source
External regulator
or DC-DC
converter
3.3V
1.8V
External regulator
or DC-DC
converter
1.8V Power Pins
3.3V Power Pins
UM10208
Chapter 6: LPC2800 DC-DC converter
Fig 11. Example of DC-DC converter connections when the DC-DC convert er is no t use d.
3.DC-DC converter timing
Several cases are given to illustrate operation of the DC-DC Converter block. The first
shows timing when the ST AR T signal is used to activa te the chip when only battery power
is available. The second shows timing when USB power is connected when no battery
power is available. The third shows switching from battery power to USB power.
3.1START and STOP from battery power
Figure 6–12 shows the timing of the DC-DC Converter while being started and stopped
when powered by a battery supply. Note that timing and voltage levels are not to scale.
A negative edge at the START input activates the DC-DC converter. When minimum
supply voltages are detected for DCDC_V
becomes true. After about 1 ms (determined by a number of clock periods of the Ring
Oscillator), the internal active-low reset signal is de-asserted. Once started, additional
edges on the START pin have no effect on the DC-D C Converter.
The upper trace shows the effect on external circuitry as the DC-DC converter powers up,
as in the application example in Figure 6–10
A positive edge on the STOP signal causes the DC-DC converter to shut off and the
internal reset to be asserted.
UM10208
Chapter 6: LPC2800 DC-DC converter
Fig 12. START and STOP of the internal DC-DC converter when battery po wered
Remark: The change in voltage level on the START signal is due to the connection of this
signal in the application. See Figure 6–10
DCDC_V
DDO(3V3)
are combined for use with START and STOP switches.
, which shows how battery voltage and
3.2START and STOP from USB power
Figure 6–13 shows the timing of the DC-DC Converter while USB power is applied and
removed. Note that timing and voltage levels are not to scale.
Application of USB power when the device is not operating causes an automatic start-up.
The internal reset remains asserted for about 1 ms after power becomes ava ilable from
the DC-DC Converter. Re moving USB power causes an automatic STOP.
Fig 13. Internal DC-DC(2) USB powered (no battery present)
3.3Switching from battery power to USB power
Figure 6–14 shows the timing of the DC-DC Converter when powered by a battery supply ,
and USB power is cycled. Note that timing and voltage levels are not to scale.
The figure shows the DC-DC running (due to a prior START) from battery power. USB
power is then applied, causing the DC-DC converters to be turned off, while power is
switched to use the output of the LDO regulators. USB power is always used prefer entially
if it is available. When USB power is disconnected, a STOP is generated and the device
goes to the off state.
* DC-DC output voltage may vary during the change from DC-DC output to LDO output.
(internal
reset_n)
Supply_OK
DC-DC
enable
** Between Stop and Start, the device is in the idle mode, supplies DCDC_V
DDO(3V3)
and
DCDC_V
DDO(1V8)
are present, but only a small current is required.
**
*
DCDC_V
DDO(1V8)
and
DCDC_V
DDO(3v3)
UM10208
Chapter 6: LPC2800 DC-DC converter
Fig 14. Change from battery to USB supply and off
4.DC-DC registers
The DC-DC Converter block includes 3 registers. Two allow fine adjustment of the output
voltages of the DC-DC converters (not the LDO regulator outputs). The third allows
switching the DC-DC Converter clock from the internal Ring Oscillator to 12 MHz from the
CGU. The registers are shown in Table 6–26
Table 26.DC-DC converter registers
NameSizeDescriptionAccessReset valueAddress
DCDCADJUST13Output voltage adjustment value for DCDC
DCDCADJUST23Output voltage adjustment value for DCDC
DCDCCLKSEL1Clock selecti on for DC-DC convertersR/W00x8000 500C
The DC-DC converter may be operated from the Ring oscillator contained in the DC-DC
converter block or from the 12 MHz clock source from the CGU. If a clock from the CGU is
used, it must be configured and stable at the CGU output before the DC-DC converter is
asked to switch clock sources.
Chapter 7: Clock Generation Unit (CGU) and power control
Rev. 02 — 31 May 2007User manual
• Two oscillators, 12 MHz main clock and the optional 32.768 kHz “RTC” clock.
• Two clock-multiplying phase-locked loops (PLLs).
• Generates 66 clocks for LPC288x modules.
• Generates 31 clock-synchronized reset signals for LPC288x modules.
• Includes 17 fractional dividers:
– can output one base clock pulse per their multiply/divide period, or
– can approximate a 50-50 duty cycle of their multiply/divide period
• Software reset capability for each reset domain.
• Each clock domain can have its clock disabled
2.Description
The Clock Generation Unit generates clock and reset signals for the various modules of
the LPC288x. A block diagram of the CGU is shown in Figure 7–15
clocks, including the two oscillators, two PLLs, and 3 clocks from input pins.
The selection stages select among the main clocks, al though they ar e more complex th an
simple selectors in order to avoid glitches when they are being dynamically switched
between main clocks. The outputs of the selection stages are called “base clocks”. Some
selection stages and base clocks are dedicated to a particular spreading stage and
contains the elements shown in Figure 7–16.
NXP Semiconductors
module clock. More typically, a selection sta ge and base clock serve multiple spreading
stages and module clocks, which can also use the output(s) of one or more fractional
dividers.
Fractional dividers multiply their base clock input by an integer “n” and divide it by another
integer “m”. Since n must be less than m, a fractional divider’s output always has a slower
frequency than its base frequency.
Each spreading stage is connected to a particular base clock, and can ena bl e or disa ble
its output clock under control of a register bit. Some spreading stages include an enable
input that allows clock pulses only when it is active: on the LPC288x this is used for
peripheral registers that do not have dynamic roles such as interrupting or change
detection, such that these registers can be clocked only when the processor is accessing
that module. A spreading stage that is connected to a fractional divider can produce
clocks under the control of the fractional divider. This can take the form of outputting a
high pulse of the base clock once per the divider’s multiply/divide period, or this pulse can
be “stretched” to provide an approximate 50-50 duty cycle of the multiply/divide period.
Finally, an output of the Event Router block is used as a “wakeup” signal that globally
enables the clocks for those spreading stages that are programmatically selected for such
wakeup.
UM10208
Chapter 7: LPC2800 CGU
The clocks produced by the spreading stages are used to provide clock-synchronized
reset signals for the various LPC288x modules and for sub-modules within them. Each
reset signal is asserted due to a low on the RESET
because software writes to a software reset register for that module or sub-module.
3.Register descriptions
3.1CGU configuration registers
The registers that control central aspects of the CGU are listed in Table 7–32 and
described individually thereafter.
Table 32.CGU configuration registers
NameDescriptionAccess Reset
PMODEPower Mode Register. This 2-bit register
controls whether modules selected for “wakeup”
operation receive clocking.
WDBARK Watchdog Bark Register. Software can read
this register to determine whether a reset is due
to the Watchdog Timer.
OSC32EN 32 kHz Oscillator Control Register. This 1-bit
register enables or disables the 32kHz oscillator.
OSCEN12 MHz Oscillator Control Register . This 1-bit
0BarkThis read-only bit is set by a Watchdog reset and cleared by a low
31:1-Reserved. The value read from a reserved bit is not defined-
Table 35.32 kHz Oscillator Control (OSC32EN - 0x8000 4C08)
BitSymbolDescriptionReset
0When this bit is 1, as it is after a reset, the 32 kHz oscillator runs.1
31:1-Reserved, user software should not write ones to reserved bits. The
UM10208
Chapter 7: LPC2800 CGU
selected for “wakeup” operation receive clocks. When software writes
1 1 to this field, clocking to those modules is disabled until a rising edge
on the Event Router’s Wakeup output. Don’t write 10 or 00 to this field.
value read from a reserved bit is not defined.
value
0 (RESET)
on RESET
. Software can read it to determine which kind of reset
has occurred.
value read from a reserved bit is not defined.
1 (WDT)
value
01
-
value
-
Table 36.Fast Oscillator Control (OSCEN - 0x8000 4C10)
BitSymbolDescriptionReset
value
0When this bit is 1, as it is after a reset, the fast oscillator runs. Software
1
could clear this bit (to save power) if the whole CGU is driven by some
combination of the 32KHz oscillator and the clock input pins.
31:1-Reserved, user software should not write ones to reserved bits. The
The main PLL typically uses the fast (12 MHz) oscillator as its input and multiplies it up to
a clock rate at which the processor and core peripherals can operate. Figure 7–17
the block diagram of the Main PLL.
Fig 17. Main PLL Block Diagram
UM10208
Chapter 7: LPC2800 CGU
shows
Table 7–37 describes the registers that are related to the main PLL.
Table 37.Main PLL registers
NameDescriptionAccess Reset
value
LPFINInput Select Register. This field selects the main
PLL’s input clock (CLKIN)
0000 32 kHz oscillator
0001 Fast (12 MHz) oscillator
0010 MCLKI pin
0011 BCKI pin
0100 WSI pin
0111 High Speed PLL
(values not shown are reserved and should not be
written)
LPPDNPower Down Register. When bit 0 of this register is
1, as it is after a reset, the main PLL is powered down.
Write a 0 to this bit after writing the LPMSEL and
LPPSEL registers, to start the main PLL.
LPMBYP Multiplier Bypass Register. Wh en bit 0 of this
register is 1, CLKIN is routed to the Post Divider, the
CCO is powered down, and the Feedback Divider and
the Phase/Frequency Comparator are not used.
LPLOCK Lock Status. A 1 in bit 0 of this read-only register
indicates that the main PLL has achieved
synchronization lock, so that its output can be used for
clocking.
LPDBYP Divisor Bypass Register. When bit 0 of this register
LPMSEL Multiplication Factor. If LPMBYP is 0, program this
LPPSEL Division Factor. If LPDBYP is 0, program this 2-bit
is 1, the Post Divider is not used.
5-bit register to get the desired output clock: F
= F
register so that
160 MHz
* (LPMSEL+1).
CLKIN
≤ F
CLKOUT
(LPPSEL+1)
* 2
≤ 320 MHz
CLKOUT
UM10208
Chapter 7: LPC2800 CGU
Address
value
R/W00x8000 4CF4
R/W00x8000 4CF8
R/W00x8000 4CFC
Note that 2
(LPPSEL+1)
= 2, 4, 8, or 16.
The state of the LPMBYP and LPDBYP bits determine the operating mode of the Main
PLL, as described in Table 7–38
Table 38.Main PLL Operating Modes
LPMBYP LPDBYP Operation
00Normal Mode. The PLL output clock (clkout) is the selected input clock
multiplied by (LPMSEL+1). The post divider is used, and the FCCO
frequency is F
MHz.
01Divisor Bypass Mode. The PLL output clock (clkout) is the selected input
clock multiplied by (LPMSEL+1), but the post divider is not used. This
means that F
operate many LPC288x modules: a fractional divider can be used to scale
the clock down to a usable rate.
10Multiplier Bypass Mode. The PLL output clock is the selected input clock
divided by 2
is in a relatively inactive mode, and the conditions for resumin g normal
operation are more complex than can be indicated by the Event Router’s
Wakeup facility.
11Total Bypass Mode. The PLL output clock is the selected input clock. This
is a useless mode because the selected input clock is always an alternative
to the PLL output clock.
.
CLKOUT
CLKOUT
(LPPSEL+1)
(LPPSEL+1)
* 2
must be between 160 and 320 MHz. This is too fast to
. This could be used to save power when the LPC288x
, which must be between 160 and 320
3.3Main PLL example
Suppose that the fast oscillator is 12 MHz and you want the main PLL to run at 60 MHz.
Program the main PLL registers as follows:
• leave the LPFIN register 0001 as at reset, to use the fast oscillator,
• write 4 to LPMSEL, which makes the PLL output clock 12MHz x (4+1) = 60 MHz,
• write 1 to LPPSEL, which causes the PLL CCO frequency to be 4 x 60M = 240 MHz
(the center frequency of the CCO operating range),
• write 0 to LPPDN, to start the main PLL,
• read LPLOCK repeatedly until it is 1, indicating that the main PLL has started,
• program one or more selection stages to use the main PLL as their clock input.
The high speed PLL includes an optional initial divider stage , a multiplier stage, and an
optional final divider stage. Any of 5 input clocks can be selected as the input to the initial
divider . The output of the initial divider st age is th e input to the multiplier, and the output of
the multiplier is the input to the final divider. The output of the final divider is the output of
the high speed PLL, and is one of the base clocks available to the selection stages.
The values by which the initial divider, multiplier, and final divider stages multiply or divide
their inputs are integers. They are related to (somewhat theoretical) numerical values
called NSEL, MSEL, and PSEL as shown in Table 7–39
T able 39.HS PLL Multiplication and Division Factors
StageName of factor # bits xSEL ValueMultiplier/divisor
Initial divider NSEL80-2551-256
MultiplierMSEL150-32767 Even values 2-65536
Final divider PSEL50-31Even values 2-64
The developer’s main task in using the HP PLL is to select a multiplier and dividers that
will allow the derivation of the desired output clock from one of the available input clocks.
This choice is constrained by the operating limitations of the multiplier stage. The
multiplier input clock must be between 4 kHz and 150 MHz, and the multiplier output clock
must be between 275 and 550 MHz.
UM10208
Chapter 7: LPC2800 CGU
.
If more than one combination of NSEL, MSEL, and PSEL can produce the desired clock
from one of the available input clocks, select among them as follows:
1. To maximize reliability of the Lock status bit and minimize startup time, choose
combinations in which the multiplier input clock is
between 100 kHz and 20 MHz.
2. If more than one combination remains after applying recommendation 1, choose
combinations that don’t involve initial division over those that do. This minimizes
phase noise and jitter.
3. If more than one combination remains after applying recommendation 2, there are two
possible approaches. First, a PLL oscillator frequency causes the PLL to consume
less power. For lower power operation, choose the settings that give the lowest
frequency of the multiplier output clock (in the range of 275 and 550 MHz). Second,
the PLL oscillator is most stable in the center of its frequency range, so the
combination for which the multiplier output frequency is closest to its center frequency
of 412 MHz can be used.
Many PLL modules, including the Main PLL described in the previous section, allow
software to program values like NSEL, MSEL, and PSEL directly into registers. However,
the high speed PLL requires that the multiplicatio n an d div isio n fac to rs be ma pped to
specific control register values that are not obvious functions of the factors themselves.
The next section describes several ways of deriving these control register values.
3.5Deriving Control Register Values from Multiplier and Divisor Factors
The initial division factor NSEL determines the value for control register HPNDEC. The
multiplication factor MSEL determines the values for the HPMDEC, HPSELR, HPSELI,
and HPSELP registers, and the final division factor PSEL determines the value for the
HPPDEC register. There are three ways of mapping from NSEL, MSEL, and PSEL to the
associated register values.
In this method, the application must include three tables called NTAB, MTAB, and PTAB in
memory, the contents of which were calculated by a standalone program as part of the
development of the LPC288x. In order to obtain the specific register values, software must
use the desired xSEL value as an index into the correspon ding memory t ab le, and extract
the register values as shown in Table 7–40
Table 40.HS PLL Multiplication and Division Memory Tables
Memory
table
NTABNSEL810 HPNDEC256 halfwords
MTABMSEL1530 HPMDEC, HPSELR, HPSELI, HPSELP 32k words
PTABPSEL57 HPPDEC32 bytes
3.5.2Manual Memory Table Lookup
Some applications may not have room in memory for the tables used in the previous
method (particularly MTAB). In this case, for each multiplier or divisor required by the
application, obtain the files that can be used as memory tables as described above, look
up each desired xSEL value in the files (comments identify the indices), and extract the
associated control register values.
Indexedbyindex
bits
output
bits
UM10208
Chapter 7: LPC2800 CGU
.
Write to register(s)Table size
(512 bytes)
(128k bytes)
3.5.3Common HP PLL Applications
Table 7–41 shows multiplier and divisor values that derive common frequencies from the
Fast oscillator running at 12 MHz, with the associated values for the HPNDEC, HPMDEC,
HPPDEC, HPSELR, HPSELI, and HPSELP registers. All values are decimal.
Table 41.Common HP PLL Applications (Fin = 12 MHz)
3:0HPSelectThis register selects the HS PLL’s input clock. Values other than those
shown below are reserved and should not be written to this field.
0001 Fast (12 MHz) oscillator
0010 MCLKI pin
0011 BCKI pin
0100 WSI pin
1000 Main PLL
31:4-Reserved, user software should not write ones to reserved bits. The
Table 44.Initial Divider Control Register (HPNDEC - 0x8000 4CB4)
BitSymbolDescriptionReset
9:0NDECIf bit 4 of the HPMODE register is 0, the HS PLL first divides its input
31:10 -Reserved, user software should not write ones to reserved bits. The
Table 45.Multiplier Control Register (H PMDEC - 0x8000 4CB0)
BitSymbolDescriptionReset
16:0MDECThe HS PLL multiplies the clock resulting from the initial division (if
31:17 -Reserved, user software should not write ones to reserved bits. The
UM10208
Chapter 7: LPC2800 CGU
clock by 1 through 256 inclusive. The value written to this register
depends on the divisor NSEL, and can be determined as described in
Section 7–3.5
that the result is between 4 kHz and 150 MHz. Lock indication is most
reliable if this result is between 100 kHz and 20 MHz.
value read from a reserved bit is not defined.
any) by even values between 2 and 65536 inclusive. The value written
to this register depends on the multiplier MSEL, and can be
determined as described in Section 7–3.5
divisor, and multiplier must be selected so that the multiplied clock is
between 275 and 550 MHz.
value read from a reserved bit is not defined.
. The input clock and initial divisor must be selected so
. The input clock, initial
value
0
-
value
0
-
Table 46.Final Divider Control Register (HPPDEC - 0x8000 4CB8)
BitSymbolDescriptionReset
value
6:0PDECThe output of the HS PLL is the multiplied clock divided by even values
0
between 2 and 64 inclusive. The value written to this register depends
on the divisor PSEL, and can be determined as described in
Section 7–3.5
. Given the range limits on the multiplied clock, the HS
PLL can generate clocks between 4.3 and 275 MHz.
31:7-Reserved, user software should not write ones to reserved bits. The
-
value read from a reserved bit is not defined.
Table 47.Mode Register (HPMODE - 0x8000 4CBC)
BitSymbolDescriptionReset
value
0HPCLKEN A 1 in this bit enables the HP PLL output clock.0
2HPPDA 1 in this bit powers down the HP PLL.1
4DIRECTIA 1 in this bit disables the initial divider. Set this bit if it’s possible to
0
generate the desired output clock without the initial divider, as this
minimizes phase noise and jitter.
5FREERUN A 1 in this bit disables feedback and allows the HP PLL to free run at
0
its current rate, even if the input clock is lost.
all
others
-Reserved, user software should not write ones to reserved bits. The
value read from a reserved bit is not defined.
0HPLOCKLock Status. A 1 in this bit indicates that the HS PLL has achieved
1HPFREEFree Running Status. This bit is 1 if the HS PLL is in free-running
31:2-Reserved. The value read from a reserved bit is not defined.-
Table 49.Rate Change Request Regis ter (HPREQ - 0x8000 4CC8)
BitSymbolDescriptionReset
0HPMREQAfter dynamically changing the MDEC, SELI, SELR, and/or SELP
1HPNREQAfter dynamically changing the NDEC register, write a 1 to this bit, wait
2HPPREQAfter dynamically changing the PDEC register, write a 1 to this bit, wait
31:3-Reserved, user software should not write ones to reserved bits. The
UM10208
Chapter 7: LPC2800 CGU
value
0
synchronization lock, so that its output can be used for clocking. At
slow input frequencies this bit is not reliable: a ti meout of 500 uS
should be applied to waiting for it to be set.
0
mode.
value
0
registers, write a 1 to this bit, wait for the MACK bit in HP ACK to be set,
then clear this bit, then wait for MACK to be 0.
0
for the NACK bit in HPACK to be set, then clear this bit, then wait for
NACK to be 0.
0
for the PACK bit in HPACK to be set, then clear this bit, then wait for
P ACK to be 0.
4:0SELPThe value to be written to this field depends on the multiplication factor,
31:5-Reserved, user software should not write ones to reserved bits. The
3.7High Speed PLL Programming and Operation
Chapter 7: LPC2800 CGU
and can be determined as described in Section 7–3.5
value read from a reserved bit is not defined.
and can be determined as described in Section 7–3.5
value read from a reserved bit is not defined.
UM10208
value
0
.
-
value
0
.
-
3.7.1Power-down procedure
Setting up the high speed PLL involves the following steps:
1. If the PLL is in operation:
a. write 0 to the SCRs of any selection stages that use the PLL, to disable use of the
PLL’s output.
b. write 0x004 to HPMODE to power it down
2. If necessary, write a new value to HPFIN. (The reset value selects the 12 MHz
oscillator, which is the most commonly used input clock.)
3. Determine the values corresponding to the desired multiplication and division factors
by one of the methods described in Section 7–3.5
HPMDEC, HPPDEC, HPSELR, HPSELI, and HPSELP registers,
4. Write 0x001, 0x009, 0x011, or 0x019 to HPMODE, to start the PLL.
5. Read HPSTAT periodically until the LOCK bit is 1, indicating that the high speed PLL
has achieved synchronization lock. Subject this waiting to a time-out as described in
Section 7–3.7.3
.
6. Program one or more selection stages to use the high speed PLL as their clock input.
3.7.2Handshake procedure
The steps above are simple enough to serve for reprogramming, but there is an
alternative that allows software to make rate changes more quickly than waiting for a
complete power-up:
, and write them to the HPNDEC,
1. Write 0 to the SCRs of any selection stages that use the PLL, to disable use of the
PLL’s output.
2. For each of HPNSEL, (HPMSEL, HPSELR, HPSELI, HPSELP), and HPPSEL that
need to be changed:
a. determine the new value(s) as described in Section 7–3.5
,
b. write the value(s) to the appropriate register(s),
3. Read HPST AT periodically until the LOCK bit is 1. (This will happen more quickly than
4. Program the selection stages to use the PLL output.
3.7.3Lock Time-outs
When software waits for the LOCK bit to be set in either of the preceding procedures, it
should limit the waiting time to prevent system hang-ups. If the input clock is less than 100
kHz the Lock indication is not reliable. In this case use a time-out of 500 uS, and proceed
onward to use the clock if LOCK is not set by this time. For any clock frequency, it’s
possible that an error in a control register value will prevent locking. So for faster
frequencies, make the time-out 2 seconds, and post an error result to the calling routine if
this time-out occurs.
UM10208
Chapter 7: LPC2800 CGU
c. write a 1 to the appropriate bit of the HPREQ register,
d. read the HPACK register repeate dly until the corresponding bit is 1,
e. write a 0 to the appropria te bit of th e HPREQ reg ist er,
f. read HPACK repeatedly until the corresponding bit 0 is 0.
in the power-down procedure.) Subject this waiting to a time-out as described in
Section 7–3.7.3
.
3.8Selection stage registers
Each of the 11 selection stages in the CGU includes the first four registers listed in
Switch Configuration Registers. These 4-bit
registers enable or disable the output of the
selection stage, select between the two “sides”
of the stage, and allow resetting the stage.
Some SCRs reset to 0001 (running), others to
1001 (stopped).
Frequency Select 1 Registers. These 4-bit
registers select among the main clocks for “side
1” of the selection stage. All FSR1 registers
reset to selecting the fast oscillator.
Frequency Select 2 Registers. These 4-bit
registers select among the main clocks for “side
2” of the selection stage. All FSR2 registers
reset to selecting the 32 kHz oscillator.
Switch Status Registers. These 6-bit
read-only registers indicate which side of the
stage is selected, and its frequency selection.
Base Control Registers. These 1-bit registers
allow software to start multiple fractional dividers
synchronously (simultaneously).
. Selection stages that drive more than one fractional divider include Base
0ENF1A 1 in this bit enables side 1 of the stage.1
1ENF2A 1 in this bit enables side 2 of the stage. Don’t set both ENF1 and
2SCRESWriting a 1 to this bit resets the selection stage.0
3SCSTOPA 1 in this bit disables the output of the stage.varies
31:4-Reserved, user software should not write ones to reserved bits. The
3:0SELECTThis field selects the main clock for “side 1” of the selection stage:
31:4-Reserved, user software should not write ones to reserved bits. The
UM10208
Chapter 7: LPC2800 CGU
value
0
ENF2.
-
value read from a reserved bit is not defined.
value
0001
0000: 32 kHz oscillator
0001: Fast oscillator
0010: MCI Clock pin
0011: DAI BCLK pin
0100: DAI WS pin
01 11: High Speed PLL
1000: Main PLL
(other values are reserved and should not be written)
3:0SELECTThis field selects the main clock for “side 2” of the selection stage:
0
0000: 32 kHz oscillator
0001: Fast oscillator
0010: MCI Clock pin
0011: DAI BCLK pin
0100: DAI WS pin
01 11: High Speed PLL
1000: Main PLL
(other values are reserved and should not be written)
31:4-Reserved, user software should not write ones to reserved bits. The
-
value read from a reserved bit is not defined.
Table 58.Switch Status Registers (SYSSSR-DAISSR; 0x8000 4084-40A8)
BitSymbolDescriptionReset
value
0ENF1This bit is 1 if side 1 of the stage is enabled.1
1ENF2This bit is 1 if side 2 of the stage is enabled.0
5:2This field reflects the main clock selection of the enabled side. 0001
31:6-Reserved. The value read from a reserved bit is not defined.-
Table 59.Base Control Registers (SYSBCR-DAIOBCR; 0x8000 43F0-43F8)
BitSymbolDescriptionReset
0FDRUNWrite a 0 to this bit to disable operation of all the Fractional Dividers
31:1-Reserved, user software should not write ones to reserved bits. The
3.9Selection stage programming
Operationally, each selection stage selects among the 7 main clocks of the CGU, but it is
more complex than a simple selector to allow software to switch the selection without
producing a glitch on the stage’ s output (base clo ck). To switch a selection stage from one
main clock to another, software should:
1. Read the SSR to determine which side of the stage is currently enabled.
2. Write FSR1 or FSR2, whichever is not enabled, with the select code for the new main
3. AND the value from step 1 with 3, then XOR it with 3, then write the result to the SCR
UM10208
Chapter 7: LPC2800 CGU
value
1
connected to this selection stage, overriding their individual RUN bits.
After all fractional dividers and other CGU registers have been
programmed as desired, write a 1 back to this register to start all of the
FDs simultaneously.
-
value read from a reserved bit is not defined.
clock.
to switch to the opposite side.
After software completes step 3, the selection stage first disables the old main clock
during its low time, then waits one stage of the new main clock before driving its output
from the new main clock. This process prevents glitches (minimum high or low time
violations) on the output/base clock.
3.10Fractional divider registers
Each of the 17 fractional dividers in the CGU includes the registers described below.
0FDRUNA 1 in this bit enables the fractional divider00X8000 43FC,
1FDRESWriting 1 to this bit resets the fractional divider. 0
2FDSTRCH When this bit is 0, as it is after a reset, one high-going
12:3 in
DAIOFDCR4,
10:3 in
all others
22:13 in
DAIOFDCR4,
18:1 1 in
all others
31:23 in
DAIOFDCR4
31:19 in all
others
pulse of the base clock will be enabled on the output per
cycle of the fractional divider. If this bit is 1 the pulse will
be stretched to approximate a 50-50% duty cycle.
MADDTo configure the fractional divider to multiply the base
clock by “n” and divide it by “m” (n must be less than m),
write m-n to this field.
MSUBTo configure the fractional divider to multiply the base
clock by “n” and divide it by “m” (n must be less than m),
write -n (two’s complement) to this field. This value
need not have its MS bit set: that is, it doesn’t have to
look like a negative number.
ReservedReserved, user software should not write ones to
reserved bits. The value read from a reserved bit is not
defined.
[1] The fraction n/m must be always smaller than one and greater than zero.
a) When using clock stretching, the fraction must be smaller or equal to 1/2.
b) To obtain the best possible 50% duty cycle when clock stretching is used, n/m should equal a division by a 2 power value (i.e. 1/2,
1/4, 1/8...). Using other fractions will result in a best approximation.
3.11Fractional divider programming
To set up a fractional divider for operation, software should:
1. If the fractional divider was already opera tin g:
a. Read its FDCR,
b. Clear the RUN bit,
c. Write the result value back to the FDCR.
2. Write the desired values of MADD, MSUB, and the STRETCH bit, with the RESET bit
set, to the FDCR,
3. Write the value from step 2, without the RESET bit, to the FDCR,
4. Write the value from step 3, with the RUN bit, to the FDCR.
Note: the higher resolution of fractional divider DAIOFDCR4 is intended for use in
generating Word Select (WS) clocks.
3.12Spreading stage registers
Each of the 66 spreading stages in the CGU includes the first two registe rs listed in
Table 7–61
. Spreading stages that have at least one fractional divider available to them
DescriptionAccess
Power Control Registers. These 5-bit registers control whether and when the clock
runs.
Power Status Registers. These 2-bit read-only registers indicate whether the clock is
running and its wakeup status.
Enable Select Registers. These registers only exist in spreading stages that have a
fractional divider available to them. They control whether the spreading stage clock is
controlled by a fractional divider, and, for those stages that have more than one
fractional divider available to them, which fractional divider controls the spreading stage.
3.12.1Power control registers
The registers shown in Table 7–62 have the format shown in Table 7–63.
0PCRUNA 0 in this bit disables the output clock of the spreading stage.1
1PCAUTOA 0 in this bit overrules bits 2 and 3, so that the clock output is
2WAKE_ENA 0 in this bit makes this spreading stage independent of the wakeup
3EXTEN_EN A 1 in this bit puts this clock under control of a signal from the target
4ENOUT_EN If this bit is 1, the spreading stage places its enable status on an
31:5-Reserved, user software should not write ones to reserved bits. The
UM10208
Chapter 7: LPC2800 CGU
controlled only by the RUN bit and (if app l ica ble) the selected
fractional divider. When this bit is 1, bits 2 and 3 have the effects
described below.
signal from the Event Router. If this bit is 1, this clock is enabled by a
rising edge on wakeup, and disabled when software writes 11 to the
Mode field of the Power Mode Control register (Table 7–33 on
page 54).
module or submodule. On the LPC288x this feature is used for
registers that have no dynamic operational aspects, and the control
signals are APB module select signals (PSEL). Set this bit only as
indicated in Table 7–64
internal output named “enableout”. Set this bit only in AHB0PCR,
CPUPCR2, RAMPCR, and ROMPCR.
value read from a reserved bit is not defined.
.
value
1
1
0
0
-
Table 64.External enables validity by spreading stages
0PSACTIVEThis bit is 1 if the clock is functional.1
1PSAWAKEThis bit indicates the wakeup status of the clock.1
31:2-Reserved. The value read from a reserved bit is not defined.-
3.12.3Enable select registers
The registers shown in Table 7–67 have the format shown in Table 7–68. Five of the 66
spreading stages have no ESR.
0ESR_ENA 0 in this bit causes the spreading stage output clock to be
0
the same as the input clock from the selection stage (when
the selection stage clock is enabled). A 1 in this bit places
the spreading stage’s clock under the control of a fractional
divider, so that when it is enabled, it runs at a lower
frequency than the selection stage’s clock. (This register
only exists in stages that have at least one fractional
divider available to them.)
1, 3:1, or none
(see
Table 7–69
)
ESR_SELFor spreading stages connected to the SYS and DAIO
selection stages, this value can be 0 through 5 to select
among the six available fractional dividers. For spreading
0
stages connected to the AHB0 selection stage, bit 1 can be
0 or 1 to select between the two available fractional
dividers. For other selection stages that have only one
fractional divider available, only the ESR_EN bit is
implemented in the ESR. Table 7–69
shows which ESRs
have 3-bit and 1-bit ESR_SEL fields.
31:1,2, or 4
(see
Table 7–69
-Reserved, user software should not write ones to reserved
bits. The value read from a reserved bit is not defined.
The final stage of the CGU includes flip-flops that generate a synchronized reset signal for
each of the modules that use the clocks generated by the spreading stages. Each of the
synchronized resets is asserted due to a software reset, power-on reset (RESET pin low)
or a watchdog timer reset.
Each of the modules shown in Table 7–70
register with the name and address indicated. Th ese register bit s all reset to 1. Unless the
module is not to be used, software will need to write a 1 back to its software reset register
before it can operate again.
Table 70.Software reset registers
NameAddressModule(s) or Submodule
APB0RES0x8000 4C18 APB0 including CGU, System Config, Event Router, RTC, ADC,
WDT, IOCONF. Do not clear this bit!
APB0RES20x8000 4C1C APB0 bridge. Do not clear this bit!
APB1RES0x8000 4C20 APB1.
APB1RES20x8000 4C24 APB1 bridge.
APB2RES0x8000 4C28 APB2.
APB3RES0x8000 4C2C APB3.
APB3RES20x8000 4C30 APB3 bridge.
MMIORES0x8000 4C34 Interrupt Controller
AHB0RES0x8000 4C38 Processor, RAM, ROM, other AHB. Do not cl ea r this bi t !
T0RES0x8000 4C3C Timer 0
T1RES0x8000 4C40 Timer 1
can be reset if software writes a 0 to bit 0 of the
Table 7–71 shows the organization of the CGU. All seven main clocks are available to all
of the selection stages. Each spreading stage can only use the output of its selection
stage, plus the outputs of the fractional divider(s) shown in the thir d column (if any). In the
“Spreading Stage Registers” column, “xxx” stands in for “PCR” and “PSR” for all spreading
stages, plus “ESR” for the spreading stages listed in Table 7–67
describes what module(s) the clock is used in, and how it’s used.
32 kHz Osc
12 MHz Osc
MCLK pin
BCKI pin
WSI pin
Main PLL
HS PLL
Selection
stages
SYSSYSFDCR0
Fractional
divider
registers
SYSFDCR1
SYSFDCR2
SYSFDCR3
SYSFDCR4
SYSFDCR5
Spreading
stage
registers
APB0xxx0APB0_CLK
APB1xxx0APB1_CLK
APB2xxx0APB2_CLK
APB3xxx0APB3_CLK
MMIOxxx0MMIO_HCLKAHB clock for interrupt controller
AHB0xxxAHB0_CLK
MCIxxx0MCI_PCLKPCLK for MCI/FD interface
MCIxxx1MCI_MCLKMCI clock for MCI/FD interface
UARTxxx0UART_PCLKAPB clock for UART
FLSHxxx0FLASH_CLKmain clock for Flash
FLSHxxx1FLASH_TCLK test clock for Flash
FLSHxxx2FLASH_PCLK PCLK for Flash
LCDxxx0LCD_PCLKPCLK for LCD interface
LCDxxx1LCD_CLKLCD bus clock for LCD interface
DMAxxx0DMA_PCLKPCLK for DMA channels
DMAxxx1DMA_GCLKgated register clock for DMA channels
USBxxx0USB_HCLKAHB clock for USB interface
CPUxxx0CPU_CLKmain processor clock
CPUxxx1CPU_PCLKPCLK for processor
CPUxxx2CPU_GCLKgated HCLK for processor registers
RAMxxxRAM_CLKclock for internal RAM
ROMxxxROM_CLKclock for internal ROM
EMCxxx0EMC_CLKExternal Memory Controller
EMCxxx1EMC_CLK2External Memory Controller
MMIOxxx1MMIO_CLKmain clock for interrupt controller
32 kHz Osc
12 MHz Osc
MCLK pin
BCKI pin
WSI pin
Main PLL
HS PLL
Selection
stages
APB0APB0FDCR0
APB1APB1FDCRAPB1xxx1APB1_PCLK
APB3APB3FDCRAPB3xxx1APB3_PCLK
DCDCDCDCxxxDCDC_CLKclock for DC-DC Converter
RTCRTCxxxRTC_CLK32clock for Real Time Clock
MCIMCIxxx2MCI_CLKclock for MCI/FD bus
UARTUARTFDCRUARTxxx1UART_CLKUART baud rate clock
DAIODAIOFDCR0
SCONxxxSCON_PCLKclock for Streaming Configuration registers
DAIxxx0DAI_PCLKclock for DAI APB interface
DAOxxx0DAO_PCLKclock for DAO APB interface
SIOxxxSIO_PCLKStream I/O clock: used for I
SAI1xxxSAI1_PCLKclock for SAI1
SAI4xxxSAI4_PCLKclock for SAI4
SAO1xxxSAO1_PCLKclock for SAO1
SAO2xxxSAO2_PCLKclock for SAO2
DDACxxx0DDAC_PCLKclock for Dual DAC APB interface
EDGExxxEDGE_PCLKclock for DAO edge detector
DADCxxx0DADC_PCLKclock for Dual ADC APB interface
5.1Example 1: Programming the MCI and the LCD interface using the
CGU
In this example, the main PLL uses the fast (12 MHz) oscillator as input and multiplies it
up to 60 MHz. This example uses the “SYS” selection stage and registers SYSFDCR1
and SYSFDCR3 as Fractional Divider registers (compare to Table 7–71
Table 72.Structure of the CGU
Main
clocks
32 kHz Osc
12 MHz
Osc
MCLK pin
BCKI pin
WSI pin
Main PLL
HS PLL
Selection
stages
SYSSYSFDCR0
Fractional
divider
registers
SYSFDCR1
SYSFDCR2
SYSFDCR3
SYSFDCR4
SYSFDCR5
UM10208
Chapter 7: LPC2800 CGU
):
Spreading
stage
registers
APB0xxx0APB0_CLK
APB1xxx0APB1_CLK
APB2xxx0APB2_CLK
APB3xxx0APB3_CLK
MMIOxxx0MMIO_HCLKAHB clock for interrupt controller
AHB0xxxAHB0_CLK
MCIxxx0MCI_PCLKPCLK for MCI/FD interface
MCIxxx1MCI_MCLKMCI clock for MCI/FD interface
UARTxxx0UART_PCLKAPB clock for UART
FLSHxxx0FLASH_CLKmain clock for Flash
FLSHxxx1FLASH_TCLK test clock for Flash
FLSHxxx2FLASH_PCLK PCLK for Flash
LCDxxx0LCD_PCLKPCLK for LCD interface
LCDxxx1LCD_CLKLCD bus clock for LCD interface
DMAxxx0DMA_PCLKPCLK for DMA channels
DMAxxx1DMA_GCLKgated register clock for DMA channels
USBxxx0USB_HCLKAHB clock for USB interface
CPUxxx0CPU_CLKmain processor clock
CPUxxx1CPU_PCLKPCLK for processor
CPUxxx2CPU_GCLKgated HCLK for processor registers
RAMxxxRAM_CLKclock for internal RAM
ROMxxxROM_CLKclock for internal ROM
EMCxxx0EMC_CLKExternal Memory Controller
EMCxxx1EMC_CLK2External Memory Controller
MMIOxxx1MMIO_CLKmain clock for interrupt controller
Clock nameClock description
The selection stage (SYS) selects the Main PLL and generates the output clock (SYS
base clock, i.e. 60 MHz) which is fed to all the SYS spreading stages.
Except the MCI_MCLK (MCI clock for MCI/SD interface) and the LCD_CLK (LCD bus
clock for LCD interface), the rest of the spreading stage output clocks (see Table 7–71
)
are selected to be the same as the input clock ( SYS base clock) from the selection stage
( SYS ), i.e. 60 MHz. The MCI_MCLK (MCI clock for MCI/SD interface) is programmed as
5/12 of the SYS base clock by the fractional divider (SYSFDCR1), i.e. 25 MHz. The
LCD_CLK (LCD bus clock for LCD interface) is programmed as 1/10 of the SYS base
clock by the fractional divider (SYSFDCR3), i.e. 6 MHz.
/*********************** Main PLL Setup***************************/
LPPDN = 0x00000001; /* Power down the main PLL */
LPFIN = 0x00000001; /* Select main oscillator as PLL's input clock */
LPMSEL = 0x00000004; /* Multiply input clock by (4 + 1) = 5 */
LPPSEL = 0x00000001; /* Make CCO equal to 4 times PLL output */
LPPDN = 0x00000000; /* Power up the main PLL */
while (LPLOCK == 0x00000000) {}; /* Wait for PLL to lock */
/*********************** Selection Stage ***************************/
if (SYSSSR & CGU_FSR1) {
SYSFSR2 = CGU_FSR_MAIN_PLL; /* Select Main PLL as main clock */
SYSSCR = (SYSSCR & 0xC) | CGU_FSR2; /* Enable side 2 */
} else {
SYSFSR1 = CGU_FSR_MAIN_PLL; /* Select Main PLL as main clock */
SYSSCR = (SYSSCR & 0xC) | CGU_FSR1; /* Enable side 1 */
}
/*********************** Programming the Fractional Divider registers ***************************/
/* Setup SYS Fractional Divider #1 for MCI_MCLK, MCI clock of SD/MCI interface */
/* MCI_MCLK, MCI clock of SD/MCI interface = (5/12) * SYS base clock */
SYSFDCR1 &= ~CGU_FDCR_FDRUN; /* Stop the fractional divider */
SYSFDCR1 = ((SYSFDCR1_MSUB << 11) /* Set MSUB = -n */
| (SYSFDCR1_MADD << 3) /* Set MADD = m - n */
| CGU_FDCR_FDSTRCH /* Enable stretch */
| CGU_FDCR_FDRES); /* Reset fractional divider */
SYSFDCR1 &= ~CGU_FDCR_FDRES; /* Clear reset bit */
SYSFDCR1 |= CGU_FDCR_FDRUN; /* Restart the fractional divider */
/* Setup SYS Fractional Divider #3 for LCD_CLK, LCD bus clock of LCD interface */
/* LCD_CLK, LCD bus clock of LCD interface = (1/10) * SYS base clock */
SYSFDCR3 &= ~CGU_FDCR_FDRUN; /* Stop the fractional divider */
SYSFDCR3 = ((SYSFDCR3_MSUB << 11) /* Set MSUB = -n */
| (SYSFDCR3_MADD << 3) /* Set MADD = m - n */
| CGU_FDCR_FDSTRCH /* Enable stretch */
| CGU_FDCR_FDRES); /* Reset fractional divider */
SYSFDCR3 &= ~CGU_FDCR_FDRES; /* Clear reset bit */
SYSFDCR3 |= CGU_FDCR_FDRUN; /* Restart the fractional divider */
/******************************** Spreading stage *************************************/
/* Choose clocks for spreading stages under SYS */
APB0ESR0 = 0x0; /* The same as the SYS base clock */
APB1ESR0 = 0x0; /* The same as the SYS base clock */
APB2ESR0 = 0x0; /* The same as the SYS base clock */
APB3ESR0 = 0x0; /* The same as the SYS base clock */
MMIOESR0 = 0x0; /* The same as the SYS base clock */
AHB0ESR = 0x0; /* The same as the SYS base clock */
MCIESR0 = 0x0; /* The same as the SYS base clock */
UARTESR0 = 0x0; /* The same as the SYS base clock */
FLSHESR0 = 0x0; /* The same as the SYS base clock */
FLSHESR1 = 0x0; /* The same as the SYS base clock */
FLSHESR2 = 0x0; /* The same as the SYS base clock */
LCDESR0 = 0x0; /* The same as the SYS base clock */
DMAESR0 = 0x0; /* The same as the SYS base clock */
DMAESR1 = 0x0; /* The same as the SYS base clock */
USBESR0 = 0x0; /* The same as the SYS base clock */
CPUESR0 = 0x0; /* The same as the SYS base clock */
CPUESR1 = 0x0; /* The same as the SYS base clock */
CPUESR2 = 0x0; /* The same as the SYS base clock */
RAMESR = 0x0; /* The same as the SYS base clock */
ROMESR = 0x0; /* The same as the SYS base clock */
EMCESR0 = 0x0; /* The same as the SYS base clock */
EMCESR1 = 0x0; /* The same as the SYS base clock */
MMIOESR1 = 0x0; /* The same as the SYS base clock */
UM10208
MCIESR1 = CGU_ESR_FD1; /* Select spreading stage MCI_MCLK, MCI clock of SD/MCI interface */
LCDESR1 = CGU_ESR_FD3; /* Select spreading stage LCD_CLK, LCD bus clock of LCD interface */
• Using SDRAM with the external memory controller requires that the EMC_CLK
(External memory controller) and the EMC_CLK2 (External memory controller) are
the same frequency. The SDRAM also requires that the EMC_CLK (External memory
controller) and the EMC_CLK2 (External me mo ry con tro lle r) ar e no t hig he r than
33 MHz.
In this example, the main PLL uses the fast (12 MHz) oscillator as its input and multiplies
it up to 60 MHz. This example uses the “SYS” selection stage and registers SYSFDCR0,
SYSFDCR1 and SYSFDCR3 as Fractional Divider registers (compare to Table 7–71
Table 73.Structure of the CGU
Main
clocks
32 kHz Osc
12 MHz
Osc
MCLK pin
BCKI pin
WSI pin
Main PLL
HS PLL
Selection
stages
SYSSYSFDCR0
Fractional
divider
registers
SYSFDCR1
SYSFDCR2
SYSFDCR3
SYSFDCR4
SYSFDCR5
UM10208
Chapter 7: LPC2800 CGU
Spreading
stage
registers
APB0xxx0APB0_CLK
APB1xxx0APB1_CLK
APB2xxx0APB2_CLK
APB3xxx0APB3_CLK
MMIOxxx0MMIO_HCLKAHB clock for interrupt controller
AHB0xxxAHB0_CLK
MCIxxx0MCI_PCLKPCLK for MCI/FD interface
MCIxxx1MCI_MCLKMCI clock for MCI/FD interface
UARTxxx0UART_PCLKAPB clock for UART
FLSHxxx0FLASH_CLKmain clock for Flash
FLSHxxx1FLASH_TCLK test clock for Flash
FLSHxxx2FLASH_PCLK PCLK for Flash
LCDxxx0LCD_PCLKPCLK for LCD interface
LCDxxx1LCD_CLKLCD bus clock for LCD interface
DMAxxx0DMA_PCLKPCLK for DMA channels
DMAxxx1DMA_GCLKgated register clock for DMA channels
USBxxx0USB_HCLKAHB clock for USB interface
CPUxxx0CPU_CLKmain processor clock
CPUxxx1CPU_PCLKPCLK for processor
CPUxxx2CPU_GCLKgated HCLK for processor registers
RAMxxxRAM_CLKclock for internal RAM
ROMxxxROM_CLKclock for internal ROM
MMIOxxx1MMIO_CLKmain clock for interrupt controller
Clock nameClock description
):
The selection stage (SYS) selects the Main PLL and generates output clock (SYS base
clock, i.e. 60MHz) which is fed to all the SYS spreading stages.
Except for the MCI_MCLK ( MCI clock for MCI/SD interface ), the LCD_CLK ( LCD bus
clock for LCD interface ) and the CPU_CLK ( main processor clock ), the rest of the
spreading stage output clocks are programmed as 1/2 of the SYS base clock by the
fractional divider (SYSFDCR0), i.e. 30 MHz. The MCI_MCLK (MCI clock for MCI/SD
interface) is programmed as 5/12 of the SYS base clock by the fractional divider
(SYSFDCR1), i.e. 25 MHz. The LCD_CLK (LCD bus clock for LCD interface) is
programmed as 1/10 of the SYS base clock by the fractional divider (SYSFDCR3), i.e.
6 MHz. The CPU_CLK (main processor clock) is the same as the input clock (SYS base
clock) from the selection stage (SYS), i.e. 60 MHz. Because the CPU_CLK ( main
processor clock ) is higher than ( twice ) the CPU_GCLK ( gated HCLK for processor
registers ), the bit 4 ( ENOUT_EN ) of the power control register ( CPUPCR2 ) for the
CPU_GCLK ( gated HCLK for processor registers ) must be set.
/*********************** Main PLL Setup***************************/
LPPDN = 0x00000001; /* Power down the main PLL */
LPFIN = 0x00000001; /* Select main oscillator as PLL's input clock */
LPMSEL = 0x00000004; /* Multiply input clock by (4 + 1) = 5 */
LPPSEL = 0x00000001; /* Make CCO equal to 4 times PLL output */
LPPDN = 0x00000000; /* Power up the main PLL */
while (LPLOCK == 0x00000000) {}; /* Wait for PLL to lock */
/*********************** Selection Stage ***************************/
if (SYSSSR & CGU_FSR1) {
SYSFSR2 = CGU_FSR_MAIN_PLL; /* Select Main PLL as main clock */
SYSSCR = (SYSSCR & 0xC) | CGU_FSR2; /* Enable side 2 */
} else {
SYSFSR1 = CGU_FSR_MAIN_PLL; /* Select Main PLL as main clock */
SYSSCR = (SYSSCR & 0xC) | CGU_FSR1; /* Enable side 1 */
}
/*********************** Programming the Fractional Divider registers ***************************/
/* Setup SYS Fractional Divider #0 for AHB clock */
EMCESR1 = CGU_ESR_FD0; /* Select spreading stage EMC_CLK2, external memory controller */
MMIOESR1 = CGU_ESR_FD0; /* Select spreading stage MMIO_CLK, main clock for interrupt controller */
MCIESR1 = CGU_ESR_FD1; /* Select spreading stage MCI_MCLK, MCI clock for SD/MCI interface */
LCDESR1 = CGU_ESR_FD3; /* Select spreading stage LCD_CLK, LCD bus clock for LCD interface */
CPUESR0 = 0x0; /* The same as the SYS base clock */
/* Configuration of power control register */
CPUPCR2 |= CGU_PCR_ENOUT_EN /* Set ENOUT_EN bit such that CPU_CLK ( main processor clock ) */
/* can be higher than CPU_GCLK ( gated HCLK for processor registers ) */
/* Configuration of base control register */
SYSBCR = CGU_BCR_FDRUN; /* Start fractional dividers */
UM10208
5.3Low power operations
Major power savings may be accomplished by the appropriate programming of the
following registers in the CGU block.
Clock generation unit and power control
1. 12 MHz Oscillator Control register (OSCEN - ad d res s 0x 8 00 0 4C10):
When the bit 0 is set to 1, as it is after a reset, the 12MHz oscillator runs. The
application could clear this bit to save power if the whole CGU is driven by some
combination of the 32 KHz oscillator and the clock input pins.
2.
Fractional Divider Configuration registers:
If the application uses any of the Fractional Divider Configuration registers, then the
bits MADD and MSUB should be as large as possible in order to minimize powe r
consumption.
Power control registers:
3.
–
The application initialization code should write all zeroes to each of the unnamed
Power Control registers to minimize power consumption. The application
initialization code should also write all zeroes to each of the Power Control register
of the unused peripherals.
– A 1 in the bit 3 (EXTEN_EN) of the Power Control register puts the corresponding
clock under control of a signal from the target module or sub module. This
functionality is typically used to reduce power consumption by disabling a clock
whenever it is not required. Set this bit only as indicated in Table 7–64
– If the bit 2 (WAKE_EN) is 1, then the corresponding clock is enabled by a rising
edge on the Event Router’s Wakeup output, and disabled when the application
writes 3 to the CGUMode bits of the Power Mode register.
Applications that have floating inputs are recommended to switch to GPIO configuration to
save power. These pins shou ld then be set as outputs.
.
There are also some registers in other blocks of the LPC288x that can also contribute to
power savings and they are listed below:
Flash Power Down register (FLASH_PD - address 0x8000 5030):
Bit 0 (FLASH_PD) of the Flash Power Down register (FLASH_PD - 0x80005030) allows
shutting down the flash memory system in order to save power if it is not needed.
External memory controller
1. EMC Control register (EMCControl - address 0x8000 8000):
2.
3.
UM10208
Chapter 7: LPC2800 CGU
Bit 4 (PERF_ANAL_ENA) of this register controls the cache performance analysis
counters in the registers C_RD_MISSES, C_FLUSHES, and C_WR_MISSES.
Performance analysis should be disabled when not needed in order to save power.
CPU Clock Gate Control register (CPU_CLK_GATE - address 0x8010 4058):
Bit 0 (CPU_CLK_GATE) controls clock gating to the CPU. When clock gating is
enabled, power is saved by not clocking the CPU when it is stalled waiting for bus
access.
If the EMC is unused, then the application could clear bit 0 (MPMC Enable) of this
register to disable the EMC, when the EMC is in idle state. Disabling the EMC
reduces power consumption.
Dynamic Control register (EMCDynamicControl - address 0x8000 8020):
A 0 in bit 1 (Force CLKOUT) of this register saves power by stopping CLKOUT when
there are no SDRAM transactions and during self-refresh mode.
Static Memory Configuration registers:
A one in the bit 19 (Write buffer Enable) of the Static Memory Configuration registers
enables the write buffers, which reduces external memory traffic. This improves
memory bandwidth and reduces power consumption.
When the bit 0 (PWR_UP) of this register is 0, all bus interface inputs are gated. Besides
the first element in the ripple counter, and the optional alarm clock sampling flip flop, all
loads to the 32.768 kHz clock are gated to reduce power. However, the application must
always write a 1 to this bit before it can access any of the other registers in the RTC.
Analog-to-digital conver ter
1. A/D Control register (ADCCON - 0x80002420):
A zero in the bit 1 (ADCENAB) of this register disables the digital portion of the ADC.
A/D Power Down register (ADCPD - 0x80005028):
2.
A one in the bit 0 (ADCPD) of this register removes power from th e analog A/D circuit.
USB controller
USB Clock Enable register (USBClkEn - 0x80005050):
A one in the bit 0 (CLKEN) of this register enables the clock to the USB controller. The
application can write a 0 to this bit, to save power if the USB is not used.
• A zero in the bit 8 (RDYNPON) of this register powers down the right DAC.
• A zero in the bit 9 (LDYNPON) powers down the left DAC.
UM10208
Chapter 7: LPC2800 CGU
–
A one in the bit 0 (RSD_PD) of this register powers down the right
single-to-differential converter.
– A one in the bit 1 (LSD_PD) powers down the left single-to-differential converter.
– A one in the bit 7 (RPGA_PD) powers down the RPGA.
– A one in the bit 12 (LPGA_PD) powers down the LPGA.
Dual ADC Control register (DADCCTRL - 0x802003A8):
–
A one in the bit 3 (RPD) of this register powers down the RADC.
– A one in the bit 7 (LPD) powers down the LADC.
SD/MCI card interface
1. MCI Clock Enable register (MCICLKEN - 0x8000502C):
A one in the bit 0 (MCICLKEN) of this register enables the clock for the SD/MMC card
interface. The application can write a 0 to this bit, to save power if the SD/MMC card
interface is not used.
Clock Control Register (MCIClock - 0x80100004):
2.
A one in the bit 9 (PwrSave) stops the clock when the bus is idle.
The LPC288x External Memory Controller (EMC) is a multi-port memory controller that
supports asynchronous static memory devices such as RAM, ROM and Flash, as well as
dynamic memories such as Single Data Rate SDRAM. It complies with ARM’s Advanced
Microcontroller Bus Architecture (AMBA).
• Dynamic memory interface support including Single Data Rate SDRAM.
• Asynchronous static memory device support including RAM, ROM, and Flash, with or
without asynchronous page mode.
• Low transaction latency.
• Read and write buffers to reduce latency and to improve performance.
• 8 bit and 16 bit static memory support.
• 16 bit SDRAM memory support.
• Static memory features include:
– Asynchronous page mode read.
– Programmable wait states.
– Bus turnaround delay.
– Output enable , and wr ite en a ble delays .
• Extended wait.
• One chip select for synchronous memory and three chip selects for static memory
devices.
• Power-saving modes dynamically control CKE and CLKOUT to SDRAMs.
• Dynamic memory self-refresh mode controlled by software.
• Controller supports 2 k, 4 k, and 8 k row address synchronous memory parts. That is
typically 512 MB, 256 MB, and 128 MB parts, with 4, 8, or 16 data lines per device.
• Separate reset domains allow for auto-refresh through a chip reset if desired.
Note: Synchronous static memory devices (synchronous burst mode) are not supported.
3.Supported dynamic memory devices
This section provides examples of dynamic memory devices that are supported by the
EMC.
Note: This is not an exhaustive list of supported devices.
SamsungK4S280432128 MB32 M x 4
SamsungK4S280832128 MB16 M x 8
SamsungK4S281632128 MB8 M x 16
MicronMT48LC32M4A2128 MB32 M x 4
MicronMT48LC16M8A2128 MB16 M x 8
MicronMT48LC8M16A2128 MB8 M x 16
MicronMT48LC4M32A2128 MB4 M x 32
InfineonHY39S128400128 MB32 M x 4
InfineonHY39S128800128 MB16 M x 8
InfineonHY39S128160128 MB8 M x 16
HynixHY57V28420128 MB32M x 4
HynixHY57V28820128 MB16M x 8
HynixHY57V281620128 MB8 M x 16
HynixHY57V283220128 MB4 M x 32
SamsungK4S560432256 MB64 M x 4
SamsungK4S560832256 MB32 M x 8
SamsungK4S561632E256 MB16 M x 16
MicronMT48LC64M4A2256 MB64 M x 4
MicronMT48LC32M8A2256 MB32 M x 8
MicronMT48LC16M16A2256 MB16 M x 16
MicronMT48LC8M32A2256 MB8 M x 32
InfineonHY39S256400256 MB64 M x 4
InfineonHY39S256800256 MB32 M x 8
InfineonHY39S256160256 MB16 M x 32
HynixHY57V56420256 MB64M x 4
HynixHY57V56820256 MB32M x 8
HynixHY57V561620256 MB16 M x 32
HynixHY5V52256 MB8 M x 32
SamsungK4S510632512 MB128 M x 4
SamsungK4S510732512 MB64 M x 8
SamsungK4S511632B512 MB32 M x 16
MicronMT48LC128M4A2512 MB128 M x 4
MicronMT48LC48M8A2512 MB64 M x 8
MicronMT48LC32M16A2512 MB32 M x 16
InfineonHY39S512400512 MB128 M x 4
InfineonHY39S512800512 MB64 M x 8
InfineonHY39S512160512 MB32 M x 16
HynixHY5V72512 MB16 M x 32
This section provides examples of static memory devices that are supported by the EMC:
• Examples of ROM devices.
• Examples of SRAM devices.
• Examples of page mode flash devices.
Note: This is not an exhaustive list of supported devices.
4.1Examples of ROM devices
The EMC supports the 128 MB Samsung K3N9V100M.
4.2Examples of SRAM devices
The EMC supports the following devices:
• 256 kb IDT IDT71V256.
• 4 MB Samsung K6F4016.
• 8 MB Samsung K6F8016.
• 8 MB Samsung K6F8008.
UM10208
Chapter 8: LPC2800 EMC
4.3Examples of page mode flash devices
The EMC supports the 4 MB Intel 28F320J3.
5.Implementation / Operation notes
To eliminate the possibility of endianness problems, all data transfers to and from the
registers of the EMC must be 32 bits wide.
Note: If an register access is attempted with a size other than a word (32 bits), it causes
an ERROR response to the AHB bus and the transfer is terminated.
5.1Memory width
External memory transactions can be 8 or 16 bits wide. A 32-bit access is automatically
divided by the EMC into 2 or 4 external memory transactions. A 16-bit access to an
8-bit-wide static memory is automatically divided by the EMC into 2 external memory
transactions.
5.2Write protected memory areas
Write transactions to write-protected memory areas genera te an ERROR resp onse to the
AHB bus and the transfer is terminated.
The AHB interface reads and writes via buffers to improve memory bandwid th and re duce
transaction latency. The EMC contains four 16-word buffers. The buffers can be used as
read buffers, write buffers, or a combination of both. The buffers are allocated
automatically.
The buffers can be enabled or disabled for each memory area using the EMCStaticConfig
and EMCDynamicConfig Registers.
5.3.1Write buffers
Write buffers are used to:
• Merge write transactions so that the number of external transactions are minimi zed.
• Reduce external memory traffic. This improves memory bandwidth and reduces
UM10208
Chapter 8: LPC2800 EMC
Buffer data until the EMC can complete the write transaction, improving AHB write
latency.
Convert all dynamic memory write transactions into quadword bursts on the external
memory interface. This enhances transfer efficiency for dynamic memory.
power consumption.
Write buffer operation:
• If the buffers are enabled, an AHB write operation writes into the Least Recently Used
(LRU) buffer, if empty.
If the LRU buffer is not empty, the contents of the buffer are flushed to memory to
make space for the AHB write data.
• If a buffer contains write data it is marked as dirty, and its contents are written to
memory before the buffer can be reallocated.
The write buffers are flushed whenever:
• The memory controller state machine is not busy performing accesses to external
memory.
The memory controller state machine is not busy performing accesses to external
memory, and an AHB interface is writing to a different buffer.
Note: For dynamic memory, the smallest buffer flush is a quadword of data. For static
memory, the smallest buffer flush is a byte of data.
5.3.2Read buffers
Read buffers are used to:
• Buffer read requests fro m memory. Future read requests that hit the buffer read the
data from the buffer rather than memory, reducing transaction latency.
Convert all read transactions into quadword bursts on the external memory interface.
This enhances transfer efficiency for dynamic memory.
• Reduce external memory traffic. This improves memory bandwidth and reduces
• If the buffers are enabled and the r ead data is cont ained in one o f the buffers, the read
data is provided directly from the buffer.
• If the read data is not contained in a buffer, the LRU buffer is selected. If the buffer is
dirty (contains write dat a), the write data is flushed to memory. When an empty buffer
is available the read command is posted to the memory.
A buffer filled by performing a read from memory is marked as not-dirty (not containing
write data) and its contents are not flushed back to th e memory controller unless a
subsequent AHB transfer performs a write that hits the buffer.
6.Low-power operation
In many systems, the contents of the memory system have to be maintained during
low-power sleep modes. The EMC provides a mecha nism to place the dynamic memo ries
into self-refresh mode.
Self-refresh mode can be entered by software by setting the SREFREQ bit in the
EMCDynamicControl Register and polling the SREFACK bit in the EMCStatus Register.
UM10208
Chapter 8: LPC2800 EMC
Any transactions to memory that are generated while the memory controller is in
self-refresh mode are rejected and an error response is generated to the AHB bus.
Clearing the SREFREQ bit in the EMCDynamicControl Register returns the memory to
normal operation. See the memory data sheet for refresh requirements.
Note: Static memory can be accessed normally when the SDRAM memory is in
self-refresh mode.
6.1Low-power SDRAM Deep-sleep mode
The EMC supports JEDEC low-power SDRAM deep-sleep mode. Deep- sleep mode can
be entered by setting the deep-sleep mode (DP) bit in the EMCDynamicControl Register.
The device is then put into a low-power mode where the device is powered down and no
longer refreshed. All data in the memory is lost.
6.2Low-Power SDRAM partial array refresh
The EMC supports JEDEC low-power SDRAM partial array refresh. Partial array refresh
can be programmed by initializing the SDRAM memory device appropriately. When the
memory device is put into self-refresh mode only the memory banks specified are
refreshed. The memory banks that are not refreshed lose their data contents.
7.Memory bank select
The LPC288x provides four independently-configurable memory chip selects:
• Pins STCS2 through STCS0 are used to select static memory devices.
• Pins DYCS is used to select dynamic memory devices.
Static memory chip select ranges are each 2 megabytes in size, while the dynamic
memory chip select covers a range of 64 megabytes. Table 8–75
ranges of the chip selects.
Chip select pinAddress rangeMemory typeSize of range
STCS00x2000 0000 - 0x201F FFFF and
STCS10x2400 0000 - 0x241F FFFF and
STCS20x2800 0000 - 0x281F FFFF and
DYCS0x3000 0000 - 0x33FF FFFF and
8.Reset
The EMC receives two reset signals. One is called nPOR, and is asserted when chip
power is applied. nPOR affects all of the register bits in the EMC. The other signal is
called HRESETn, and is driven from the external Reset pin, the Watchdog Timer, and the
software reset facility of the CGU. HRESETn affects fewer register bits, so that refresh
activity and the contents of external dynamic memory are not lost during a "softer" reset.
UM10208
Chapter 8: LPC2800 EMC
Static2 MB
0x4000 0000 - 0x401F FFFF
Static2 MB
0x4400 0000 - 0x441F FFFF
Static2 MB
0x4800 0000 - 0x481F FFFF
Dynamic64 MB
0x5000 0000 - 0x53FF FFFF
9.Pin description
Table 8–76 shows the interface and control signal pins for the EMC on the LPC288x.
T able 76.Pad interface and control signal descriptions
NameTypeValu e on
A[20:0]Output LowDepends on
D[15:0] Input/
OEOutput HighDepends on
BLS[1:0]Output HighDepends on
WEOutput HighDepends on
STCS[2:0]Output HighDepends on
DYCSOutput HighHighSDRAM chip select.
CASOutput HighHighColumn address strobe. Used for SDRAM
RASOutput HighHighRow address strobe. Used for SDRAM devices.
Output
POR reset
Data
outputs =
Low
Value du ring
self-refresh
static memory
accesses
Depends on
static memory
accesses
static memory
accesses
static memory
accesses
static memory
accesses
static memory
accesses
Description
External memory address output. Used for both
static and SDRAM devices. SDRAM memories
only use A[14:0].
External memory data lines. These are inputs
when data is read from external memory and
outputs when data is written to external
memory.
Low active output enable for static memory
devices.
Low active byte lane selects. Used for static
memory devices.
Low active write enable. Used for SDRAM and
static memories.
T able 76.Pad interface and control signal descriptions
NameTypeValu e on
POR reset
MCLKOOutput Follows
CCLK
CKEOutput HighLowSDRAM clock enable.
DQM[1:0]Output HighHighData mask outputs. Used for SDRAM devices
RPOOutput LowPer bits 15:14
Value du ring
self-refresh
Follows CCLK SDRAM clock.
of the
EMCDynamic
Control
register
Description
and static memories.
Reset power down to SyncFlash memory.
10. Register description
The EMC registers are shown in Table 8–77.
Table 77.EMC register summary
AddressRegister NameDescriptionWarm
0x8000 8000EMCControlControls operation of the memory controller.0x10x3R/W
0x8000 8004EMCStatusProvides EMC status information.-0x5RO
0x8000 8008EMCConfigConfigures operation of the memory controller-0R/W
0x8000 8020EMCDynamicControlControls dynamic memory operation.-0x006 R/W
0x8000 8024EMCDynamicRefreshConfigures dynamic memory refresh operation.-0R/W
0x8000 8028EMCDynamic
ReadConfig
0x8000 8030EMCDynamicRPSelects the precharge command period.-0x0FR/W
0x8000 8034EMCDynamicRASSelects the active to precharge command period.-0xFR/W
0x8000 8038EMCDynamicSREXSelects the self-refresh exit time.-0xFR/W
0x8000 803CEMCDynamicAPRSelects the last-data-out to active command time.-0xFR/W
0x8000 8040EMCDynamicDALSelects the data-in to active command time.-0 xFR/W
0x8000 8044EMCDynamicWRSelects the write recovery time.-0xFR/W
0x8000 8048EMCDynamicRCSelects the active to active command period.-0x1FR/W
0x8000 804CEMCDynamicRFCSelects the auto-refresh period.-0x1FR/W
0x8000 8050EMCDynamicXSRSelects the exit self-refresh to active command time.-0x1FR/W
0x8000 8054EMCDynamicRRDSelects the active bank A to active bank B latency.-0xFR/W
0x8000 8058EMCDynamicMRDSelects the load mode register to active command time.-0xFR/W
0x8000 8080EMCStaticExtendedWaitTime long static memory read and write transfers.-0R/W
0x8000 8100EMCDynamicConfigSelects the configuration information for dynamic
0x8000 8104EMCDynamicRasCasSelects the RAS and CAS latencies for dynamic memory. -0x303 R/W
0x8000 8200EMCStaticConfig0Selects the memory configuration for static chip select 0.-0R/W
0x8000 8204EMCStatic WaitWen0Selects the delay from chip select 0 to write enable.-0R/W
0x8000 8208EMCStaticWaitOen0Selects the delay from chip select 0 or address change,
whichever is later, to output enable.
0x8000 820CEMCStaticWaitRd0Selects the delay from chip select 0 to a read access.-0x1FR/W
0x8000 8210EMCStaticWaitPage0Selects the delay for asynchronous page mode
sequential accesses for chip select 0.
0x8000 8214EMCStaticWaitWr0Selects the delay from chip select 0 to a write access.-0x1FR/W
0x8000 8218EMCStaticWaitTurn0Selects the number of bus turnaround cycles for chip
select 0.
0x8000 8220EMCStaticConfig1Selects the memory configuration for static chip select 1.-0R/W
0x8000 8224EMCStatic WaitWen1Selects the delay from chip select 1 to write enable.-0R/W
0x8000 8228EMCStaticWaitOen1Selects the delay from chip select 1 or address change,
whichever is later, to output enable.
0x8000 822CEMCStaticWaitRd1Selects the delay from chip select 1 to a read access.-0x1FR/W
0x8000 8230EMCStaticWaitPage1Selects the delay for asynchronous page mode
sequential accesses for chip select 1.
0x8000 8234EMCStaticWaitWr1Selects the delay from chip select 1 to a write access.-0x1FR/W
0x8000 8238EMCStaticWaitTurn1Selects the number of bus turnaround cycles for chip
select 1.
0x8000 8240EMCStaticConfig2Selects the memory configuration for static chip select 2.-0R/W
0x8000 8244EMCStaticWaitWen2Selects the delay from chip select 2 to write enable.-0R/W
0x8000 8248EMCStaticWaitOen2Selects the delay from chip select 2 or address change,
whichever is later, to output enable.
0x8000 824CEMCStaticWaitRd2Selects the delay from chip select 2 to a read access.-0x1FR/W
0x8000 8250EMCStaticWaitPage2Selects the delay for asynchronous page mode
sequential accesses for chip select 2.
0x8000 8254EMCStatic aitWr2Selects the delay from chip select 2 to a write access.-0x1FR/W
0x8000 8258EMCStaticWaitTurn2Selects the number of bus turnaround cycles for chip
select 2.
0x8000 5064EMCMiscOne static control bit, one dynamic control bit00R/W
10.1EMC Control Register (EMCControl - 0x8000 8000)
The EMCControl Register is a read/write register that controls operation of the memory
controller. The control bits can be altered during normal operation. Table 8–78
EMCControl Register.
Table 78.EMC Control Register (EMCControl - address 0x8000 8000)
BitNameDescriptionPOR
0MPMC
1Address
2Low
31:3-Reserved, user software should not write ones to reserved bits. The
Enable
Mirror
Power
Mode
UM10208
Chapter 8: LPC2800 EMC
shows the
This bit is set, so that the EMC is enabled, by both power-on and warm
reset. Write a 0 to this bit to disable the EMC, when the EMC is in idle
[1]
Disabling the EMC reduces power consumption. When the
state.
EMC is disabled, the memory is not refreshed. Write a 1 to this bit to
re-enable the EMC.
This bit is set by power-on reset. When this bit is 1, accesses to the
address ranges that would otherwise activate chip select 0, activate
chip select 1 instead. In applications that allow booting from external
memory, connect chip select 1 to the external device from which the
system should boot. Write a 0 to this bit to make chip selects 0 and 1
independent.
This bit is cleared by both power-on and warm reset. Write a 1 to this
bit to put the EMC into low-power mode, when the EMC is in idle
[1]
. Low-power mode reduces memory controller power
state.
consumption. Dynamic memory is refreshed as necessary. W rite a 0 to
this bit to restore normal mode.
value read from a reserved bit is not defined.
Reset
Value
1
1
0
-
[1] The external memory cannot be accessed in low-power or disabled state. If a memory access is performed
an AHB error response is generated. The EMC registers can be programmed in low-power and/or disabled
state.
The read-only EMCStatus Register provides EMC status information. Table 8–79 shows
the bit assignments for the EMCStatus Register.
Table 79.EMC Status Register (EMCStatus - address 0x8000 8004)
BitSymbolDescriptionPOR
0BusyThis read-only bit is 1 if the EMC is busy performing memory
1Write Buffer
2Self-Refresh
31:3 -Reserved. The value read from a reserved bit is not defined.-
Status
Acknowledge
UM10208
Chapter 8: LPC2800 EMC
transactions, commands, auto-refresh cycles, or is in self-refresh
mode. Read this bit, and if necessary wait for it to be 0, before
setting low-power or disabled mode in the EMCControl Register.
Power-on reset sets this bit because it sets self-refresh mode.
After a warm reset, this bit reflects whether self-refresh mode is in
effect.
This read-only bit is 1 if write buffers are enabled, and they
contain data from a previous write operation. Read this bit, and if
necessary wait for it to be 0, before setting low-power or disabled
mode in the EMCControl Register. Power-on reset clears this bit.
This read-only bit is 1 if the EMC is in self-refresh mode.
Power-on reset sets this bit because it sets self-refresh mode.
Software can request self-refresh mode in the Dynamic Memory
Control Register, or in the EMCMisc Register (10.28 on page
109). This bit lags whichever request is used by a short
The EMCConfig Register configures the operation of the memory controller. This register
should be modified only during system initialization, or when there are no current or
outstanding transactions. This can be ensured by waiting until the EMCStatus Register
indicates "not Busy" and "write buffers empty", and then entering low-power or disabled
mode. This register is accessed with one wait state. Table 8–80
Register.
10.4Dynamic Memory Control Register (EMCDynamicControl 0x8000 8020)
The EMCDynamicControl Register controls dynamic memory operation. The control bits
can be altered during normal operation. Table 8–81
Register.
Table 81.Dynamic Control Register (EMCDynamicControl - address 0x8000 8020)
BitSymbolDescriptionPOR
0Force CKEWhen this bit is 0, as it is after a power-on reset, the CKE output
1Force CLKOUT When this bit is 1, as it is after a power-on reset, CLKOUT to
2Self-refresh
4:3-Reserved, user software should not write ones to reserved bits.
5MMCWhen this bit is 0, as it is after a power-on reset, the CLKOUT
6-Reserved, user software should not write ones to reserved bits.
8:7SDRAM
12:9-Reserved, user software should not write ones to reserved bits.
Request
initialization
UM10208
Chapter 8: LPC2800 EMC
shows the EMCDynamicControl
to dynamic memory is driven high only during dynamic memory
operations, which saves power. Write a 1 to this bit at the start of
SDRAM initialization, to force CKE high continuously. Write a 0 to
this bit at the end of SDRAM initialization.
dynamic memory runs continuously. Write a 0 to this bit to save
power by stopping CLKOUT when there are no SDRAM
transactions and during self-refresh mode.
When this bit is 1, as it after a power-on reset, dynamic memory
is placed in self-refresh mode. In self-refresh mode, data in
dynamic memory will be preserved if the LPC288x is stopped or
even powered down. Write 0 to this bit to switch the EMC and
dynamic memory to normal operating mode. Write a 1 to this bit
when the application is about to enter a low-power mode in which
it would not refresh dynamic memory. The self-refresh
acknowledge bit in the EMCStatus Register can be read to
determine the current operating mode of the EMC.
The value read from a reserved bit is not defined.
signal is controlled by bit 1 as described above. Write a 1 to this
bit to completely stop/disable CLKOUT.
The value read from a reserved bit is not defined.
SDRAM initialization code needs to sequence this field to issue
commands to the dynamic memory, among the following values
in the order given:
11: NOP command
10: PALL command (precharge all)
01: MODE command
00: NORMAL command
See “SDRAM initialization” on page 110 for more information.
The value read from a reserved bit is not defined.
“Low-power SDRAM Deep-sleep mode” on page 88 for more
information.
This field controls the RPOUT signal to reset Micron-compatible
Control
in conjunction with the dynamic memory clock control (CS) field.
SyncFlash memory:
0x: 0V
10: 3V
11 : do not write this value
The value read from a reserved bit is not defined.
UM10208
Chapter 8: LPC2800 EMC
Reset
Value
0
-
The EMCDynamicRefresh Register controls refresh timing for dynamic memory. This
register should only be modified during system initialization, or when there are no current
or outstanding transactions. This can be ensured by waiting until the EMC is idle, and the n
entering low-power or disabled mode. However, these control bits can, if necessary, be
altered during normal operation. This register is accessed with one wait st ate.
10:0REFRESH When this field is 000, as it is after a power-on reset, dynamic memory
31:11 -Reserved, user software should not write ones to reserved bits. The
shows the EMCDynamicRefresh Register.
Reset
Value
0x000
refresh cycles are not performed (note that power-on reset sets
self-refresh mode). Otherwise this field selects the refresh period, in
units of 16 AHB HCLK cycles. That is, 0x001 sets the refresh period as
16 HCLKs, 0x002 sets it as 32 HCLKS, and so on.
-
value read from a reserved bit is not defined.
For example, for a refresh period of 16 µs, and an HCLK frequency of 50 MHz, the
following value must be programmed into this register:
(16
× 10-6× 50 × 10
6
) / 16 = 50 or 0x32
If refresh through warm reset is requested (by setting the EMC_Reset_Disable bit), the
refresh timing must be adjusted to allow a sufficient refresh rate when the clock rate is
reduced during the wakeup period of a reset cycle. During this period, HCLK runs at
12 MHz. Therefore 12 MHz must be considered the clock rate for refresh calculations, if
refresh through warm reset is desired.
Note: Refresh cycles are evenly distributed, bu t the r e mig ht be slig ht va ria tio ns in the
timing of refresh cycles, depending on the status of the memory controller.
The EMCDynamicReadConfig Register controls the dynamic memory read strategy. This
register must only be modified during system initialization. This register is accessed with
one wait state.
31:2--Reserved, user software should not write ones to reserved
shows the EMCDynamicReadConfig Register.
address 0x8000 8028)
00Clock out delayed strategy, using CLKOUT (command not
strategy
01Command delayed strategy, using AHBHCLKDELAY
10Command delayed strategy plus one clock cycle, using AHB
11Command delayed strategy plus two clock cycles, using AHB
delayed, clock out delayed). POR reset value.
(command delayed, clock out not delayed).
HCLKDELAY (command delayed, clock out not delayed).
HCLKDELAY (command delayed, clock out not delayed).
bits. The value read from a reserved bit is not defined.
10.7Dynamic Memory Percentage Command Period Register
(EMCDynamictRP - 0x8000 8030)
The EMCDynamicTRP Register controls the prec ha rg e co mma nd pe riod, tRP. This
register must only be modified during system initialization. This value is normally found in
SDRAM data sheets as t
. This register is accessed with one wait state.
RP
Reset
Value
00
-
Table 8–84
Table 84.Dynamic Memory Percentage Command Period Register (EMCDynamictRP -
BitSymbolDescriptionPOR
3:0Precharge
31:4-Reserved, user software should not write ones to reserved bits.
SDRAM initialization code should write this field with one less
command
period (t
RP
)
than the number of AHB HCLK cycles that equals or just
exceeds the tRP time specified for the dynamic memory. The
power-on reset value would select 16 AHB HCLK cycles.
The value read from a reserved bit is not defined.
Reset
Value
0xF
-
NXP Semiconductors
10.8Dynamic Memory Active to Precharge Command Period Register
(EMCDynamictRAS - 0x8000 8034)
UM10208
Chapter 8: LPC2800 EMC
The EMCDynamicTRAS Register controls the active-to-precharg e command period, t
This register should only be modified during system initialization, or when there are no
current or outstanding transactions. This can be ensured by waiting until the EMC is idle,
and then entering low-power or disabled mode. This value is normally found in SDRAM
data sheets as t
Table 8–85
Table 85.Dynamic Memory Active to Precharge Command Period Register
BitSymbolDescriptionPOR
3:0Active-to-
31:4-Reserved, user software should not write ones to reserved bits.
shows the EMCDynamicTRAS Register.
(EMCDynamictRAS - address 0x8000 8034)
precharge
command
period (t
. This register is accessed with one wait state.
RAS
SDRAM initialization code should write this field with one less
than the number of AHB HCLK cycles that equals or just
exceeds the tRAS time specified for the dynamic memory. The
)
RAS
power-on reset value would select 16 AHB HCLK cycles.
The value read from a reserved bit is not defined.
10.9Dynamic Memory Self-refresh Exit Time Register
(EMCDynamictSREX - 0x8000 8038)
The EMCDynamicTSREX Register controls the self-refresh exit time, t
should only be modified during system initialization, or when there are no current or
outstanding transactions. This can be ensured by waiting until the EMC is idle, and then
entering low-power or disabled mode. This va lue is normally fo und in SDRAM dat a sheet s
as t
accessed with one wait state.
. For devices without this parameter use the value of tXSR. This register is
SREX
. This register
SREX
RAS
Reset
Value
0xF
-
.
Table 8–86
Table 86.Dynamic Memory Self-refresh Exit Time Register (EMCDynamictSREX - address
BitSymbolDescriptionPOR
3:0Self-refresh exit
31:4-Reserved, user software should not write ones to reserved bits.
SDRAM initialization code should write this field with one less
)
time (t
SREX
than the number of AHB HCLK cycles that equals or just
exceeds the tSREX or tXSR time specified for the dynamic
memory. The power-on reset value would select 16 AHB HCLK
cycles.
The value read from a reserved bit is not defined.
Reset
Value
0xF
-
NXP Semiconductors
10.10Dynamic Memory Last Data Out to Active Time Register
(EMCDynamictAPR - 0x8000 803C)
UM10208
Chapter 8: LPC2800 EMC
The EMCDynamicTAPR Register controls the last-data-out to active command ti me, t
This register should only be modified during system initialization, or when there are no
current or outstanding transactions. This can be ensured by waiting until the EMC is idle,
and then entering low-power or disabled mode. This value is normally found in SDRAM
data sheets as tAPR. This register is accessed with one wait state.
Table 8–87
Table 87.Memory Last Data Out to Active Time Register (EMCDynamictAPR - address
BitSymbolDescriptionPOR
3:0Last-data-out to
31:4-Reserved, user software should not write ones to reserved bits.
shows the EMCDynamicTAPR Register.
0x8000 803C)
SDRAM initialization code should write this field with one less
active command
APR
)
time (t
than the number of AHB HCLK cycles that equals or just
exceeds the tAPR time specified for the dynamic memory. The
power-on reset value would select 16 AHB HCLK cycles.
The value read from a reserved bit is not defined.
10.11Dynamic Memory Data-in to Active Command Time Register
(EMCDynamictDAL - 0x8000 8040)
The EMCDynamicTDAL Register controls the data-in to active command time, t
register should only be modified during system initialization, or when there are no current
or outstanding transactions. This can be ensured by waiting until the EMC is idle, and the n
entering low-power or disabled mode. This va lue is normally fo und in SDRAM dat a sheet s
as t
DAL
, or t
. This register is accessed with one wait state.
APW
DAL
APR
Reset
Value
0xF
-
. This
.
Table 8–88
T able 88.Dynamic Memory Data-in to Active Command Time Register (EMCDynamictDAL -
BitSymbolDescriptionPOR
3:0Data-in to active
31:4-Reserved, user software should not write ones to reserved bits.
shows the bit assignments for the EMCDynamicTDAL Register.
address 0x8000 8040)
SDRAM initialization code should write this field with one less
)
command (t
than the number of AHB HCLK cycles that equals or just
DAL
exceeds the tDAL or tAPW time specified for the dynamic
memory. The power-on reset value would select 16 AHB HCLK
cycles.
The value read from a reserved bit is not defined.
Reset
Value
0xF
-
NXP Semiconductors
10.12Dynamic Memory Write Recovery Time Register (EMCDynamictWR 0x8000 8044)
The EMCDynamicTWR Register controls the write reco very tim e, tWR. This register
should only be modified during system initialization, or when there are no current or
outstanding transactions. This can be ensured by waiting until the EMC is idle, and then
entering low-power or disabled mode. This va lue is normally fo und in SDRAM dat a sheet s
as t
WR
, t
DPL
, t
RWL
, or t
Chapter 8: LPC2800 EMC
. This register is accessed with one wait state.
RDL
UM10208
Table 8–89
Table 89.Dynamic Memory Write recover Time Register (EMCDynamictWR - address
BitSymbolDescriptionPOR Reset
3:0Write
31:4 -Reserved, user software should not write ones to reserved
shows the bit assignments for the EMCDynamicTWR Register.
0x8000 8044)
SDRAM initialization code should write this field with one
recovery time
)
(t
WR
less than the number of AHB HCLK cycles that equals or
just exceeds the tWR, tDPL, tRWL, or tRDL time specified
for the dynamic memory. The power-on reset value would
select 16 AHB HCLK cycles.
bits. The value read from a reserved bit is not defined.
Value
0xF
-
10.13Dynamic Memory Active to Active Command Period Register
(EMCDynamictRC - 0x8000 8048)
The EMCDynamicTRC Register controls the active-to-active-command period, tRC. This
register should only be modified during system initialization, or when there are no current
or outstanding transactions. This can be ensured by waiting until the EMC is idle, and the n
entering low-power or disabled mode. This va lue is normally fo und in SDRAM dat a sheet s
as t
. This register is accessed with one wait state.
RC
Table 8–90
Table 90.Dynamic Memory Active to Active Command Period Register (EMCDynamictRC -
BitSymbolDescriptionPOR Reset
4:0Active-to-active-
31:5-Reserved, user software should not write ones to reserved
shows the EMCDynamictRC Register.
address 0x8000 8048)
SDRAM initialization code should write this field with one
command
period (t
RC
)
less than the number of AHB HCLK cycles that equals or
just exceeds the tRC time specified for the dynamic
memory. The power-on reset value would select 32 AHB
HCLK cycles.
bits. The value read from a reserved bit is not defined.
Value
0x1F
-
10.14Dynamic Memory Auto-refresh Period Register (EMCDynamictRFC 0x8000 804C)
The EMCDynamicTRFC Register controls the auto-refresh period, and
auto-refresh-to-active-command period, t
system initialization, or when there are no current or outstanding tran sactions. This can be
ensured by waiting until the EMC is idle, and then entering low-power or disabled mode.
This value is normally found in SDRAM data sheets as t
register is accessed with one wait state.
UM10208
Chapter 8: LPC2800 EMC
, or sometimes as tRC. This
RFC
Table 8–91
Table 91.Dynamic Memory Auto-refresh Period Register (EMCDynamictRFC - address
BitSymbolDescriptionPOR Reset
4:0Auto-refresh
31:5-Reserved, user software should not write ones to
shows the EMCDynamicTRFC Register.
0x8000 804C)
SDRAM initialization code should write this field with one
period and
auto-refresh to
active command
period (t
RFC
less than the number of AHB HCLK cycles that equals or
just exceeds the tRFC or tRC time specified for the
dynamic memory. The power-on reset value would select
)
32 AHB HCLK cycles.
reserved bits. The value read from a reserved bit is not
The EMCDynamicTXSR Register controls the exit-s elf- re fr es h- to -a ctiv e- co mm a nd ti me ,
t
. This register should only be modified during system initialization, or when there are
XSR
no current or outstanding transactions. This can be ensured by waiting until the EMC is
idle, and then entering low-power or disabled mode. This value is normally found in
SDRAM data sheets as t
31:5-Reserved, user software should not write ones to
shows the EMCDynamicTXSR Register.
0x8000 8050)
to active
command time
)
(t
XSR
. This register is accessed with one wait state.
XSR
SDRAM initialization code should write this field with one
less than the number of AHB HCLK cycles that equals or
just exceeds the tXSR time specified for the dynamic
memory. The power-on reset value would select 32 AHB
HCLK cycles.
reserved bits. The value read from a reserved bit is not
defined.
Value
0x1F
-
10.16Dynamic Memory Active Bank A to Active Bank B Time Register
(EMCDynamictRRD - 0x8000 8054)
The EMCDynamicTRRD Register controls the active-bank-A-to-active-bank-B latency,
. This register should only be modified during system initialization, or when there are
t
RRD
no current or outstanding transactions. This can be ensured by waiting until the EMC is
idle, and then entering low-power or disabled mode. This value is normally found in
SDRAM data sheets as t