Lpc21 Series
Lpc21 Series
Lpc21 Series
Document information
Info Content
Keywords LPC2109/00, LPC2109/01, LPC2119, LPC2119/01, LPC2129,
LPC2129/01, LPC2114, LPC2114/01, LPC2124, LPC2124/01, LPC2194,
LPC2194/01, LPC2210, LPC2220, LPC2210/01, LPC2212, LPC2212/01,
LPC2214, LPC2214/01, LPC2290, LPC2290/01, LPC2292, LPC2292/01,
LPC2294, LPC2294/01, ARM, ARM7, 32-bit, Microcontroller
Abstract User manual for LPC2109/19/29/14/24/94 and
LPC2210/20/12/14/90/92/94 including /01 parts
NXP Semiconductors UM10114
LPC21xx and LPC22xx
Revision history
Rev Date Description
3.0 20080402 • Flash chapter updated with correct boot process flowchart.
• The Reinvoke ISP command has been removed from the ISP command description
because it is not implemented in the LPC21xx/LPC22xx.
• Description of CRP levels has been corrected, and CRP description for different
bootloader code versions has been added.
• Numbering of CAN controllers in the global CAN filter look-up table has been corrected
for /01 devices.
• Part ID’s have been updated for LPC2210/20 parts.
2.0 20080104 Integrated related parts into this manual and made numerous editorial and content updates
throughout the document:
• The format of this data sheet has been redesigned to comply with the new identity
guidelines of NXP Semiconductors.
• Legal texts have been adapted to the new company name where appropriate.
• Parts LPC2109, LPC2119, LPC2129, LPC2114, LPC2124, LPC2194, LPC2212,
LPC2214, LPC2290, LPC2292, LPC2294 and /01 parts added.
• PWM mode description updated.
• Fractional baud rate generator updated.
• CTCR register updated.
• ADC pin description updated.
• SPI clock conditions updated.
• JTAG pin description updated.
• Startup sequence diagram added.
• SPI master mode: SPI SSEL line conditioning for LPC2210/20 added in SPI pin
description table.
1.0 20051012 Moved the UM document into the new structured FrameMaker template. Many changes
were made to the format throughout the document. Here are the most important:
• UART0 and UART1 description updated (fractional baudrate generator and hardware
handshake features added - auto-CTS/RTS)
• ADC chapter updated with the dedicated result registers
• GPIO chapter updated with the description of the Fast IOs
Contact information
For more information, please visit: http://www.nxp.com
For sales office addresses, please send an email to: [email protected]
UM10114_3 © NXP B.V. 2008. All rights reserved.
1. Introduction
The LPC21xx and LPC22xx are based on a 16/32 bit ARM7TDMI-STM CPU with real-time
emulation and embedded trace support, together with 64/128/256 kilobytes (kB) of
embedded high speed flash memory. A 128-bit wide internal memory interface and a
unique accelerator architecture enable 32-bit code execution at maximum clock rate. For
critical code size applications, the alternative 16-bit Thumb Mode reduces code by more
than 30% with minimal performance penalty.
With their compact 64 and 144 pin packages, low power consumption, various 32-bit
timers, up to 12 external interrupt pins, and four channel 10-bit ADC and 46 GPIOs (64 pin
packages), or 8-channel 10-bit ADC and 112 GPIOs (144 pin package), these
microcontrollers are particularly targeted for industrial control, medical systems, access
control, and point-of-sale. With a wide range of serial communications interfaces, they are
also very well suited for communication gateways, protocol converters, and embedded soft
modems as well as many other general-purpose applications.
All parts exist in legacy versions and enhanced versions. Enhanced parts are equipped
with enhanced GPIO, SSP, ADC, UART, and timer peripherals. They are also backward
compatible to the “legacy” parts containing legacy versions of the same peripherals.
Therefore, enhanced parts contain all features of legacy parts as well. See Table 1–16 for
an overview.
To denote different versions the following suffixes are used (see Section 1–4 “Ordering
options”); no suffix, /00, /01, and /G. All /01 versions and the LPC2220 (no suffix) contain
enhanced features.
This user manual describes enhanced features together with legacy features for all
LPC21xx and LPC22xx parts. Part specific and legacy/enhanced specific pinning,
registers, and configurations are listed in a table at the beginning of each chapter (see for
example Table 6–52 “LPC21xx/22xx part-specific register bits” ). Use this table to
determine which parts of the user manual apply.
3. Features
4. Ordering options
4.1 LPC2109/2119/2129
Table 2. LPC2109/2119/2129 Ordering information
Type number Package
Name Description Version
LPC2109FBD64/00 LQFP64 plastic low profile quad flat package; 64 leads; SOT314-2
body 10 × 10 × 1.4 mm
LPC2109FBD64/01 LQFP64 plastic low profile quad flat package; 64 leads; SOT314-2
body 10 × 10 × 1.4 mm
LPC2119FBD64 LQFP64 plastic low profile quad flat package; 64 leads; SOT314-2
body 10 × 10 × 1.4 mm
LPC2119FBD64/00 LQFP64 plastic low profile quad flat package; 64 leads; SOT314-2
body 10 × 10 × 1.4 mm
LPC2119FBD64/01 LQFP64 plastic low profile quad flat package; 64 leads; SOT314-2
body 10 × 10 × 1.4 mm
4.2 LPC2114/2124
Table 4. LPC 2114/2124 Ordering information
Type number Package
Name Description Version
LPC2114FBD64 LQFP64 plastic low profile quad flat package; 64 leads; SOT314-2
body 10 × 10 × 1.4 mm
LPC2114FBD64/00 LQFP64 plastic low profile quad flat package; 64 leads; SOT314-2
body 10 × 10 × 1.4 mm
LPC2114FBD64/01 LQFP64 plastic low profile quad flat package; 64 leads; SOT314-2
body 10 × 10 × 1.4 mm
LPC2124FBD64 LQFP64 plastic low profile quad flat package; 64 leads; SOT314-2
body 10 × 10 × 1.4 mm
LPC2124FBD64/00 LQFP64 plastic low profile quad flat package; 64 leads; SOT314-2
body 10 × 10 × 1.4 mm
LPC2124FBD64/01 LQFP64 plastic low profile quad flat package; 64 leads; SOT314-2
body 10 × 10 × 1.4 mm
4.3 LPC2194
Table 6. LPC2194 Ordering information
Type number Package
Name Description Version
LPC2194HBD64 LQFP64 plastic low profile quad flat package; 64 leads; SOT314-2
body 10 × 10 × 1.4 mm
LPC2194HBD64/00 LQFP64 plastic low profile quad flat package; 64 leads; SOT314-2
body 10 × 10 × 1.4 mm
LPC2194HBD64/01 LQFP64 plastic low profile quad flat package; 64 leads; SOT314-2
body 10 × 10 × 1.4 mm
4.4 LPC2210/2220
Table 8. LPC2210/2220 Ordering information
Type number Package
Name Description Version
LPC2210FBD144 LQFP144 plastic low profile quad flat package; 144 SOT486-1
leads; body 20 × 20 × 1.4 mm
LPC2210FBD144/01 LQFP144 plastic low profile quad flat package; 144 SOT486-1
leads; body 20 × 20 × 1.4 mm
4.5 LPC2212/2214
Table 10. LPC2212/2214 Ordering information
Type number Package
Name Description Version
LPC2212FBD144 LQFP144 plastic low profile quad flat package; 144 leads; SOT486-1
body 20 × 20 × 1.4 mm
LPC2212FBD144/00 LQFP144 plastic low profile quad flat package; 144 leads; SOT486-1
body 20 × 20 × 1.4 mm
LPC2212FBD144/01 LQFP144 plastic low profile quad flat package; 144 leads; SOT486-1
body 20 × 20 × 1.4 mm
LPC2214FBD144 LQFP144 plastic low profile quad flat package; 144 leads; SOT486-1
body 20 × 20 × 1.4 mm
LPC2214FBD144/00 LQFP144 plastic low profile quad flat package; 144 leads; SOT486-1
body 20 × 20 × 1.4 mm
LPC2214FBD144/01 LQFP144 plastic low profile quad flat package; 144 leads; SOT486-1
body 20 × 20 × 1.4 mm
4.6 LPC2290
Table 12. LPC2290 Ordering information
Type number Package
Name Description Version
LPC2290FBD144 LQFP144 plastic low profile quad flat package; SOT486-1
144 leads; body 20 × 20 × 1.4 mm
LPC2290FBD144/01 LQFP144 plastic low profile quad flat package; SOT486-1
144 leads; body 20 × 20 × 1.4 mm
4.7 LPC2292/2294
Table 14. LPC2292/2294 Ordering information
Type number Package
Name Description Version
LPC2292FBD144 LQFP144 plastic low profile quad flat package; SOT486-1
144 leads; body 20 × 20 × 1.4 mm
LPC2292FBD144/00 LQFP144 plastic low profile quad flat package; SOT486-1
144 leads; body 20 × 20 × 1.4 mm
LPC2292FBD144/01 LQFP144 plastic low profile quad flat package; SOT486-1
144 leads; body 20 × 20 × 1.4 mm
LPC2292FET144/00 TFBGA144 plastic thin fine-pitch ball grid array package; SOT569-1
144 balls; body 12 × 12 × 0.8 mm
LPC2292FET144/01 TFBGA144 plastic thin fine-pitch ball grid array package; SOT569-1
144 balls; body 12 × 12 × 0.8 mm
LPC2292FET144/G TFBGA144 plastic thin fine-pitch ball grid array package; SOT569-1
144 balls; body 12 × 12 × 0.8 mm
5. Block diagram
LPC21xx TEST/DEBUG
TRACE MODULE
EMULATION
LPC22xx INTERFACE
SYSTEM
PLL
FUNCTIONS
ARM7TDMI-S
HIGH-SPEED system
P0, P1 VECTORED
GPI/O clock
AHB BRIDGE INTERRUPT
CONTROLLER
AMBA AHB
(Advanced High-performance Bus)
ARM7 local bus
INTERNAL INTERNAL
SRAM FLASH
CONTROLLER CONTROLLER AHB
DECODER
n × TD
CAN n × RD
REAL-TIME CLOCK
WATCHDOG
SYSTEM CONTROL
TIMER
Grey-shaded blocks indicate configuration or pinout dependent on part and version number, see Table 1–16.
Fig 1. LPC21xx and LPC22xx block diagram
6. Architectural overview
The LPC21xx/LPC22xx consist of an ARM7TDMI-S CPU with emulation support, the
ARM7 Local Bus for interface to on-chip memory controllers, the AMBA Advanced
High-performance Bus (AHB) for interface to the interrupt controller, and the ARM
Peripheral Bus (APB, a compatible superset of ARM’s AMBA Advanced Peripheral Bus)
for connection to on-chip peripheral functions. The LPC21xx/LPC22xx configures the
ARM7TDMI-S processor in little-endian byte order.
AHB peripherals are allocated a 2 megabyte range of addresses at the very top of the
4 gigabyte ARM memory space. Each AHB peripheral is allocated a 16 kB address space
within the AHB address space. LPC21xx/LPC22xx peripheral functions (other than the
interrupt controller) are connected to the APB bus. The AHB to APB bridge interfaces the
APB bus to the AHB bus. APB peripherals are also allocated a 2 megabyte range of
addresses, beginning at the 3.5 gigabyte address point. Each APB peripheral is allocated
a 16 kB address space within the APB address space.
The connection of on-chip peripherals to device pins is controlled by a Pin Connect Block
(see Section 8–6). This must be configured by software to fit specific application
requirements for the use of peripheral functions and pins.
7. ARM7TDMI-S processor
The ARM7TDMI-S is a general purpose 32-bit microprocessor, which 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 parts of the processing and memory systems
can operate continuously. Typically, while one instruction is being executed, its successor
is being decoded, and a third instruction is being fetched from memory.
The key idea behind THUMB is that of a super-reduced instruction set. Essentially, the
ARM7TDMI-S processor has two instruction sets:
THUMB code is able to provide up to 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-S processor is described in detail in the ARM7TDMI-S data sheet that
can be found on official ARM website.
The SRAM controller incorporates a write-back buffer in order to prevent CPU stalls
during back-to-back writes. The write-back buffer always holds the last data sent by
software to the SRAM. This data is only written to the SRAM when another write is
requested by software (the data is only written to the SRAM when software does another
write). If a chip reset occurs, actual SRAM contents will not reflect the most recent write
request (i.e. after a "warm" chip reset, the SRAM does not reflect the last write operation).
Any software that checks SRAM contents after reset must take this into account. Two
identical writes to a location guarantee that the data will be present after a Reset.
Alternatively, a dummy write operation before entering idle or power-down mode will
similarly guarantee that the last data written will be present in SRAM after a subsequent
Reset.
For an overview of how LPC21xx and LPC22xx parts and versions are described in this
manual, see Section 1–2 “How to read this manual”.
2. Memory maps
The LPC21xx and LPC22xx incorporate several distinct memory regions, shown in the
following figures. Figure 2–2 shows the overall map of the entire address space from the
user program viewpoint following reset. The interrupt vector area supports address
remapping, which is described later in this section.
0x8400 0000
0x83FF FFFF
EXTERNAL MEMORY BANKS 0 TO 4
0x8000 0000
2.0 GB 0x7FFF FFFF
BOOT BLOCK (RE-MAPPED FROM
ON-CHIP FLASH MEMORY) 0x7FFF E000
0x7FFF DFFF
0x0004 0000
0x0003 FFFF
UP TO 256 kB ON-CHIP FLASH MEMORY
4.0 GB
0xFFFF FFFF
AHB PERIPHERALS
RESERVED
RESERVED
Figures 3 through 4 and Table 2–18 show different views of the peripheral address space.
Both the AHB and APB peripheral areas are 2 megabyte spaces which are divided up into
128 peripherals. Each peripheral space is 16 kilobytes in size. This allows simplifying the
address decoding for each peripheral. All peripheral register addresses are word aligned
(to 32-bit boundaries) regardless of their size. This eliminates the need for byte lane
mapping hardware that would be required to allow byte (8-bit) or half-word (16-bit)
accesses to occur at smaller boundaries. An implication of this is that word and half-word
registers must be accessed all at once. For example, it is not possible to read or write the
upper byte of a word register separately.
0xFFFF C000
NOT USED
0xFFFF 8000
NOT USED
0xFFFF 4000
0xFFFF 0000
0xFFE1 0000
NOT USED
0xFFE0 C000
NOT USED
0xFFE0 8000
NOT USED
0xFFE0 4000
0xFFE0 0000
Because of the location of the interrupt vectors on the ARM7 processor (at addresses
0x0000 0000 through 0x0000 001C, as shown in Table 2–19 below), a small portion of the
Boot Block and SRAM spaces need to be re-mapped in order to allow alternative uses of
interrupts in the different operating modes described in Table 2–20. Re-mapping of the
interrupts is accomplished via the Memory Mapping Control features. To select a specific
memory mapping mode, see Table 6–62.
UM10114_3 © NXP B.V. 2008. All rights reserved.
The portion of memory that is re-mapped to allow interrupt processing in different modes
includes the interrupt vector area (32 bytes) and an additional 32 bytes, for a total of
64 bytes. The re-mapped code locations overlay addresses 0x0000 0000 through
0x0000 003F. The vector contained in the SRAM, external memory, and boot block must
contain branches to the actual interrupt handlers or to other instructions that accomplish
the branch to the interrupt handlers.
1. Minimize the need for the SRAM and Boot Block vectors to deal with arbitrary
boundaries in the middle of code space.
2. To provide space to store constants for jumping beyond the range of single word
branch instructions.
Re-mapped memory areas, including the boot block and interrupt vectors, continue to
appear in their original location in addition to the re-mapped address.
Details on re-mapping and examples can be found in Section 6–8.1 “Memory Mapping
control register (MEMMAP - 0xE01F C040)” on page 68.
0x4000 4000
0x4003 FFFF
ON-CHIP SRAM
Fig 5. Map of lower memory is showing re-mapped and re-mappable areas for a part
with on-chip flash memory
• Areas of the memory map that are not implemented for a specific ARM derivative. For
the LPC21xx and LPC22xx, those areas are:
– Address space between the on-chip non-volatile memory and On-Chip SRAM,
labelled "Reserved Address Space" in Figure 2–2 , and Figure 2–5. This is an
address range from 0x0002 0000 to 0x3FFF FFFF for the 128 kB flash device and
0x0004 0000 to 0x3FFF FFFF for the 256 kB flash device.
– Address space between on-chip SRAM and the boot block. This is the address
range from 0x4000 4000 to 0x7FFF DFFF, labelled "Reserved Address Space" in
Figure 2–2, and Figure 2–5.
– Address space between the top of the boot block and the APB peripheral space,
except space used for external memory (LPC2292/2294 only). This is the address
range from 0x8000 0000 to 0xDFFF FFFF, labelled "Reserved Address Space" in
Figure 2–2, and Figure 2–5.
– Reserved regions of the AHB and APB spaces. See Figure 2–3 and Table 2–18.
• Unassigned AHB peripheral spaces. See Figure 2–4.
• Unassigned APB peripheral spaces. See Table 2–18.
For these areas, both attempted data access and instruction fetch generate an exception.
In addition, a Prefetch Abort exception is generated for any instruction fetch that maps to
an AHB or APB peripheral address.
Within the address space of an existing APB peripheral, a data abort exception is not
generated in response to an access to an undefined address. Address decoding within
each peripheral is limited to that needed to distinguish defined registers within the
peripheral itself. For example, an access to address 0xE000 D000 (an undefined address
within the UART0 space) may result in an access to the register defined at address
0xE000 C000. Details of such address aliasing within a peripheral space are not defined
in the LPC21xx and LPC22xx documentation and are not a supported feature.
Note: The ARM core stores the Prefetch Abort flag along with the associated instruction
(which will be meaningless) in the pipeline and processes the abort only if an attempt is
made to execute the instruction fetched from the illegal address. This prevents accidental
aborts that could be caused by prefetches that occur when code is executed very near a
memory boundary.
For an overview of how LPC21xx and LPC22xx parts and versions are described in this
manual, see Section 1–2 “How to read this manual”.
2. Introduction
The MAM block in the LPC21xx and LPC22xx maximizes the performance of the ARM
processor when it is running code in flash memory using a dual flash bank.
3. Operation
Simply put, the Memory Accelerator Module (MAM) attempts to have the next ARM
instruction that will be needed in its latches in time to prevent CPU fetch stalls. The
method used is to split the flash memory into two banks, each capable of independent
accesses. Each of the two flash banks has its own prefetch buffer and branch trail buffer.
The branch trail buffers for the two banks capture two 128-bit lines of flash data when an
instruction fetch is not satisfied by either the prefetch buffer or branch trail buffer for its
bank, and for which a prefetch has not been initiated. Each prefetch buffer captures one
128-bit line of instructions from its flash bank at the conclusion of a prefetch cycle initiated
speculatively by the MAM.
Each 128 bit value includes four 32-bit ARM instructions or eight 16-bit Thumb
instructions. During sequential code execution, typically one flash bank contains or is
fetching the current instruction and the entire flash line that contains it. The other bank
contains or is prefetching the next sequential code line. After a code line delivers its last
instruction, the bank that contained it begins to fetch the next line in that bank.
Branches and other program flow changes cause a break in the sequential flow of
instruction fetches described above. When a backward branch occurs, there is a distinct
possibility that a loop is being executed. In this case the branch trail buffers may already
contain the target instruction. If so, execution continues without the need for a flash read
cycle. For a forward branch, there is also a chance that the new address is already
contained in one of the prefetch buffers. If it is, the branch is again taken with no delay.
When a branch outside the contents of the branch trail and prefetch buffers is taken, one
flash access cycle is needed to load the branch trail buffers. Subsequently, there will
typically be no further fetch delays until another such “Instruction Miss” occurs.
The flash memory controller detects data accesses to the flash memory and uses a
separate buffer to store the results in a manner similar to that used during code fetches.
This allows faster access to data if it is accessed sequentially. A single line buffer is
provided for data accesses, as opposed to the two buffers per flash bank that are provided
for code accesses. There is no prefetch function for data accesses.
4. MAM blocks
The Memory Accelerator Module is divided into several functional blocks:
• A flash address latch for each bank: An incrementor function is associated with the
bank 0 flash address latch.
• Two flash memory banks
• Instruction latches, data latches, address comparison latches
• Control and wait logic
Figure 3–6 shows a simplified block diagram of the Memory Accelerator Module data
paths.
In the following descriptions, the term “fetch” applies to an explicit flash read request from
the ARM. “Pre-fetch” is used to denote a flash read of instructions beyond the current
processor fetch address.
Flash programming operations are not controlled by the MAM but are handled as a
separate function. A “boot block” sector contains flash programming algorithms that may
be called as part of the application program and a loader that may be run to allow serial
programming of the flash memory.
The flash memories are wired so that each sector exists in both banks and that a sector
erase operation acts on part of both banks simultaneously. In effect, the existence of two
banks is transparent to the programming functions.
FLASH FLASH
MEMORY MEMORY
BANK 0 BANK 1
BUS
ARM LOCAL BUS
INTERFACE
BANK SELECTION
MEMORY DATA
Similarly, there is a 128-bit data latch and 13-bit data address latch, that are used during
data cycles. This single set of latches is shared by both flash banks. Each data access
that is not in the data latch causes a flash fetch of 4 words of data, which are captured in
the data latch. This speeds up sequential data operations, but has little or no effect on
random accesses.
In order to preclude the possibility of stale data being read from the flash memory, the
LPC21xx and LPC22xx MAM holding latches are automatically invalidated at the
beginning of any flash programming or erase operation. Any subsequent read from a flash
address will cause a new fetch to be initiated after the flash operation has completed.
Mode 0: MAM off. All memory requests result in a flash read operation (see Table
note 3–2). There are no instruction prefetches.
Mode 1: MAM partially enabled. Sequential instruction accesses are fulfilled from the
holding latches if the data is present. Instruction prefetch is enabled. Non-sequential
instruction accesses initiate flash read operations (see Table note 3–2). This means that
all branches cause memory fetches. All data operations cause a flash read because
buffered data access timing is hard to predict and is very situation dependent.
Mode 2: MAM fully enabled. Any memory request (code or data) for a value that is
contained in one of the corresponding holding latches is fulfilled from the latch.
Instruction prefetch is enabled. Flash read operations are initiated for instruction
prefetch and code or data values not available in the corresponding holding latches.
[1] The MAM actually uses latched data if it is available, but mimics the timing of a flash read operation. This
saves power while resulting in the same execution timing. The MAM can truly be turned off by setting the
fetch timing value in MAMTIM to one clock.
6. MAM configuration
After reset the MAM defaults to the disabled state. Software can turn memory access
acceleration on or off at any time. This allows most of an application to be run at the
highest possible performance, while certain functions can be run at a somewhat slower
but more predictable rate if more precise timing is required.
7. Register description
All registers, regardless of size, are on word address boundaries. Details of the registers
appear in the description of each function.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
Table 24. MAM Control Register (MAMCR - address 0xE01F C000) bit description
Bit Symbol Value Description Reset
value
1:0 MAM_mode 00 MAM functions disabled 0
_control 01 MAM functions partially enabled
10 MAM functions fully enabled
11 Reserved. Not to be used in the application.
7:2 - - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Table 25. MAM Timing register (MAMTIM - address 0xE01F C004) bit description
Bit Symbol Value Description Reset
value
2:0 MAM_fetch_ 000 0 - Reserved. 07
cycle_timing
001 1 - MAM fetch cycles are 1 processor clock (CCLK) in
duration
010 2 - MAM fetch cycles are 2 CCLKs in duration
011 3 - MAM fetch cycles are 3 CCLKs in duration
100 4 - MAM fetch cycles are 4 CCLKs in duration
101 5 - MAM fetch cycles are 5 CCLKs in duration
110 6 - MAM fetch cycles are 6 CCLKs in duration
111 7 - MAM fetch cycles are 7 CCLKs in duration
Warning: These bits set the duration of MAM flash fetch operations
as listed here. Improper setting of this value may result in incorrect
operation of the device.
7:3 - - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
For system clock slower than 20 MHz, MAMTIM can be 001. For system clock between
20 MHz and 40 MHz, flash access time is suggested to be 2 CCLKs, while in systems with
system clock faster than 40 MHz, 3 CCLKs are proposed. For system clocks of 60 MHz
and above, 4CCLK’s are needed.
For an overview of how LPC21xx and LPC22xx parts and versions are described in this
manual, see Section 1–2 “How to read this manual”.
2. Features
• Support for various static memory-mapped devices including RAM, ROM, flash, burst
ROM, and some external I/O devices
• Asynchronous page mode read operation in non-clocked memory subsystems
• Asynchronous burst mode read access to burst mode ROM devices
• Independent configuration for up to four banks, each up to 16 MB
• Programmable bus turnaround (idle) cycles (1 to 16)
• Programmable read and write WAIT states (up to 32) for static RAM devices
• Programmable initial and subsequent burst read WAIT state, for burst ROM devices
• Programmable write protection
• Programmable burst mode operation
• Programmable read byte lane enable control
3. Description
The external Static Memory Controller is an AMBA AHB slave module which provides an
interface between an AMBA AHB system bus and external (off-chip) memory devices. It
provides support for up to four independently configurable memory banks simultaneously.
Each memory bank is capable of supporting SRAM, ROM, Flash EPROM, Burst ROM
memory, or some external I/O devices.
Since the LPC22xx 144 pin packages pin out address lines A[23:0] only, the decoding
among the four banks uses address bits A[25:24]. The native location of the four banks is
at the start of the External Memory area identified in Figure 2–2, but Bank 0 can be used
for initial booting under control of the state of the BOOT[1:0] pins.
4. Pin description
Table 28. External Memory Controller pin description
Pin name Type Pin description
D[31:0] Input/Output External memory Data lines
A[23:0] Output External memory Address lines
OE Output Low-active Output Enable signal
BLS[3:0] Output Low-active Byte Lane Select signals
WE Output Low-active Write Enable signal
CS[3:0] Output Low-active Chip-Select signals
5. Register description
The external memory controller contains 4 registers as shown in Table 4–29.
Each register selects the following options for its memory bank:
• The number of idle clock cycles inserted between read and write accesses in this
bank, and between an access in another bank and an access in this bank, to avoid
bus contention between devices (1 to 17 clocks)
• The length of read accesses, except for subsequent reads from a burst ROM (3 to 35
clocks)
• The length of write accesses (3 to 19 clocks)
• Whether the bank is write-protected or not
• Whether the bank is 8, 16, or 32 bits wide
The table below shows the state of BCFG0[29:28] after the Boot Loader has run. The
hardware reset state of these bits is 10.
• External memory bank data bus width, defined within each configuration register (see
MW field in BCFG register)
• External memory bank type, being either byte (8 bits), halfword (16 bits) or word (32
bits) (see RBLE field in BCFG register)
Each memory bank can either be 8, 16 or 32 bits wide. The type of memory used to
configure a particular memory bank determines how the WE and BLS signals are
connected to provide byte, halfword and word access. For read accesses, it is necessary
to control the BLS signals by driving them either all HIGH, or all LOW.
This control is achieved by programming the Read Byte Lane Enable (RBLE) bit within
each configuration register. The following two sections explain why different connections
in respect of WE and BLS[3:0] are needed for different memory configurations.
Figure 4–7 (a), Figure 4–8 (a) and Figure 4–9 show 8-bit memory being used to configure
memory banks that are 8, 16 and 32 bits wide. In each of these configurations, the
BLS[3:0] signals are connected to write enable (WE) inputs of each 8-bit memory.
Note: The WE signal from the EMC is not used. For write transfers, the relevant BLS[3:0]
byte lane signals are asserted LOW and steer the data to the addressed bytes.
For read transfers, all of the BLS[3:0] lines are deasserted HIGH, which allows the
external bus to be defined for at least the width of the accessed memory.
If a memory bank is configured to be 32 bits wide, address lines A0 and A1 can be used
as non-address lines. If a memory bank is configured to 16 bits wide, A0 is not required.
However, 8 bit wide memory banks do require all address lines down to A0. Configuring
A1 and/or A0 line(s) to provide address or non-address function is accomplished using
bits 23 and 24 in Pin Function Select Register 2 (PINSEL2 register, see Table 8–88).
Symbol "a_b" in the following figures refers to the highest order address line in the data
bus. Symbol "a_m" refers to the highest order address line of the memory chip used in the
external memory interface.
See Section 8–6.5 “Boot control for LPC22xx parts” for how to boot from external memory.
CS
OE
CE CE CE CE
OE OE OE OE
BLS[3] WE BLS[2] WE BLS[1] WE BLS[0] WE
A[a_b:2]
CS
OE
WE
CE CE
OE OE
WE WE
BLS[3] UB BLS[1] UB
BLS[2] LB BLS[0] LB
A[a_b:2]
CS
OE
WE
CE
OE
WE
BLS[3] B3
BLS[2] B2
BLS[1] B1
BLS[0] B0
D[31:0] IO[31:0]
A[a_m:0]
A[a_b:2]
CS
OE
CE CE
OE OE
BLS[1] WE BLS[0] WE
A[a_b:1]
CS
OE
WE
CE
OE
WE
BLS[1] UB
BLS[0] LB
D[15:0] IO[15:0]
A[a_m:0]
A[a_b:1]
CS
OE
CE
OE
BLS[0] WE
D[7:0] IO[7:0]
A[a_m:0]
A[a_b:0]
Fig 9. 8 bit bank external memory interface (BCFGx bits MW = 00 and RBLE = 0)
1 wait state
(WST1=0)
XCLK
CS
OE
WE/BLS
addr
data
change valid data
valid address
2 wait states
(WST1=1)
XCLK
CS
OE
WE/BLS
addr
data
change valid data
valid address
Fig 10. External memory read access (WST1 = 0 and WST1 = 1 examples)
WST2 = 0
XCLK
CS
OE
WE/BLS
addr
data
valid data
valid address
WST2 = 1
XCLK
CS
OE
WE/BLS
addr
data
valid data
valid address
Fig 11. External memory write access (WST2 = 0 and WST2 = 1 examples)
Figure 4–10 and Figure 4–11 show typical read and write accesses to external memory.
Dashed lines on Figure 4–10 correspond to memory banks using 16/32 bit memory chips
having BLS lines connected to UB/LB or B[3:0] (see Section 4–5.2.2 and Figure 4–7 ,
Figure 4–8).
It is important to notice that some variations from Figure 4–10 and Figure 4–11 do exist in
some particular cases.
For example, when the first read access to the memory bank that has just been selected
is performed, CS and OE lines may become low one XCLK cycle earlier than it is shown in
Figure 4–11.
Likewise, in a sequence of several consecutive write accesses to SRAM, the last write
access will look like those shown in Figure 4–11. On the other hand, leading write cycles
in that case will have data valid one cycle longer. Also, isolated write access will be
identical to the one in Figure 4–11.
The EMC supports sequential access burst reads of up to four consecutive locations in 8,
16 or 32-bit memories. This feature supports burst mode ROM devices and increases the
bandwidth by using reduced (configurable) access time for three sequential reads
following a quad-location boundary read. Figure 4–12 shows an external memory burst
read transfer. The first burst read access has two wait states and subsequent accesses
have zero wait states.
XCLK
CS
OE
Fig 12. External burst memory read access (WST1 = 0 and WST1 = 1 examples)
For an overview of how LPC21xx and LPC22xx parts and versions are described in this
manual, see Section 1–2 “How to read this manual”.
2. Features
• ARM PrimeCell Vectored Interrupt Controller
• 32 interrupt request inputs
• 16 vectored IRQ interrupts
• 16 priority levels dynamically assigned to interrupt requests
• Software interrupt generation
3. Description
The Vectored Interrupt Controller (VIC) takes 32 interrupt request inputs and
programmably assigns them into 3 categories, FIQ, vectored IRQ, and non-vectored IRQ.
The programmable assignment scheme means that priorities of interrupts from the
various peripherals can be dynamically assigned and adjusted.
Fast Interrupt reQuest (FIQ) requests have the highest priority. If more than one request is
assigned to FIQ, the VIC ORs the requests to produce the FIQ signal to the ARM
processor. The fastest possible FIQ latency is achieved when only one request is
classified as FIQ because then the FIQ service routine can simply start dealing with that
device. But if more than one request is assigned to the FIQ class, the FIQ service routine
can read a word from the VIC that identifies which FIQ source(s) is (are) requesting an
interrupt.
Vectored IRQs have the middle priority, but only 16 of the 32 requests can be assigned to
this category. Any of the 32 requests can be assigned to any of the 16 vectored IRQ slots,
among which slot 0 has the highest priority and slot 15 has the lowest.
The VIC ORs the requests from all the vectored and non-vectored IRQs to produce the
IRQ signal to the ARM processor. The IRQ service routine can start by reading a register
from the VIC and jumping there. If any of the vectored IRQs are requesting, the VIC
provides the address of the highest-priority requesting IRQs service routine, otherwise it
provides the address of a default routine that is shared by all the non-vectored IRQs. The
default routine can read another VIC register to see what IRQs are active.
All registers in the VIC are word registers. Byte and halfword reads and write are not
supported.
4. Register description
The VIC implements the registers shown in Table 5–34. More detailed descriptions follow.
[1] Reset Value refers to the data stored in used bits only. It does not include reserved bits content.
5. VIC registers
The following section describes the VIC registers in the order in which they are used in the
VIC logic, from those closest to the interrupt request inputs to those most abstracted for
use by software. For most people, this is also the best order to read about the registers
when learning the VIC.
Table 35. Software Interrupt Register (VICSoftInt - address 0xFFFF F018) bit allocation
Reset value: 0x0000 0000
Bit 31 30 29 28 27 26 25 24
Symbol - - CAN4 RX CAN3 RX CAN2 RX CAN1 RX - -
Access R/W R/W R/W R/W R/W R/W R/W R/W
Bit 23 22 21 20 19 18 17 16
Symbol CAN4 TX CAN3 TX CAN2 TX CAN1 TX CAN ADC EINT3 EINT2
Common
Access R/W R/W R/W R/W R/W R/W R/W R/W
Bit 15 14 13 12 11 10 9 8
Symbol EINT1 EINT0 RTC PLL SPI1/SSP SPI0 I2C PW\M0
Access R/W R/W R/W R/W R/W R/W R/W R/W
Bit 7 6 5 4 3 2 1 0
Symbol UART1 UART0 TIMER1 TIMER0 ARMCore1 ARMCore0 - WDT
Access R/W R/W R/W R/W R/W R/W R/W R/W
Table 36. Software Interrupt Register (VICSoftInt - address 0xFFFF F018) bit description
Bit Symbol Reset Value Description
value
31-0 See 0 0 Do not force the interrupt request with this bit number. Writing
VICSoftInt zeroes to bits in VICSoftInt has no effect, see VICSoftIntClear
bit allocation (Section 5–5.2).
table. 1 Force the interrupt request with this bit number.
Table 38. Software Interrupt Clear Register (VICSoftIntClear - address 0xFFFF F01C) bit allocation
Reset value: 0x0000 0000
Bit 31 30 29 28 27 26 25 24
Symbol - - CAN4 RX CAN3 RX CAN2 RX CAN1 RX - -
Access WO WO WO WO WO WO WO WO
Bit 23 22 21 20 19 18 17 16
Symbol CAN4 TX CAN3 TX CAN2 TX CAN1 TX CAN ADC EINT3 EINT2
Common
Access WO WO WO WO WO WO WO WO
Bit 15 14 13 12 11 10 9 8
Symbol EINT1 EINT0 RTC PLL SPI1/SSP SPI0 I2C PWM
Access WO WO WO WO WO WO WO WO
Bit 7 6 5 4 3 2 1 0
Symbol UART1 UART0 TIMER1 TIMER0 ARMCore1 ARMCore0 - WDT
Access WO WO WO WO WO WO WO WO
Table 39. Software Interrupt Clear Register (VICSoftIntClear - address 0xFFFF F01C) bit
description
Bit Symbol Reset Value Description
value
31-0 See 0 0 Writing a 0 leaves the corresponding bit in VICSoftInt
VICSoftIntClear unchanged.
bit allocation 1 Writing a 1 clears the corresponding bit in the Software
table. Interrupt register, thus releasing the forcing of this request.
Table 40. Raw Interrupt Status Register (VICRawIntr - address 0xFFFF F008) bit description
VICRawIntr Description Reset
value
31:0 1:The hardware or software interrupt request with this bit number is 0
asserted.
0: Neither the hardware nor software interrupt request with this bit number
is asserted.
Table 41. Interrupt Enable Register (VICINtEnable - address 0xFFFF F010) bit description
VICIntEnable Description Reset
value
31:0 When this register is read, 1s indicate interrupt requests or software 0
interrupts that are enabled to contribute to FIQ or IRQ.
When this register is written, ones enable interrupt requests or software
interrupts to contribute to FIQ or IRQ, zeroes have no effect. See
Section 5–5.5 “Interrupt Enable Clear Register (VICIntEnClear -
0xFFFF F014)” on page 47 and Table 5–42 below for how to disable
interrupts.
Table 42. Software Interrupt Clear Register (VICIntEnClear - address 0xFFFF F014) bit
description
VICIntEnClear Description Reset
value
31:0 1: writing a 1 clears the corresponding bit in the Interrupt Enable 0
register, thus disabling interrupts for this request.
0: writing a 0 leaves the corresponding bit in VICIntEnable unchanged.
Table 43. Interrupt Select Register (VICIntSelect - address 0xFFFF F00C) bit description
VICIntSelect Description Reset
value
31:0 1: the interrupt request with this bit number is assigned to the FIQ 0
category.
0: the interrupt request with this bit number is assigned to the IRQ
category.
Table 44. IRQ Status Register (VICIRQStatus - address 0xFFFF F000) bit description
VICIRQStatus Description Reset
value
31:0 1: the interrupt request with this bit number is enabled, classified as 0
IRQ, and asserted.
Table 45. FIQ Status Register (VICFIQStatus - address 0xFFFF F004) bit description
VICFIQStatus Description Reset
value
31:0 1: the interrupt request with this bit number is enabled, classified as 0
FIQ, and asserted.
Table 46. Vector Control registers (VICVectCntl0-15 - addresses 0xFFFF F200-23C) bit
description
VICVectCntl0-15 Description Reset
value
4:0 The number of the interrupt request or software interrupt assigned to 0
this vectored IRQ slot. As a matter of good programming practice,
software should not assign the same interrupt number to more than
one enabled vectored IRQ slot. But if this does occur, the lower
numbered slot will be used when the interrupt request or software
interrupt is enabled, classified as IRQ, and asserted.
5 1: this vectored IRQ slot is enabled, and can produce a unique ISR 0
address when its assigned interrupt request or software interrupt is
enabled, classified as IRQ, and asserted.
31:6 Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
Table 47. Vector Address registers (VICVectAddr0-15 - addresses 0xFFFF F100-13C) bit
description
VICVectAddr0-15 Description Reset
value
31:0 When one or more interrupt request or software interrupt is (are) 0
enabled, classified as IRQ, asserted, and assigned to an enabled
vectored IRQ slot, the value from this register for the highest-priority
such slot will be provided when the IRQ service routine reads the
Vector Address register -VICVectAddr (Section 5–5.10).
Table 48. Default Vector Address register (VICDefVectAddr - address 0xFFFF F034) bit
description
VICDefVectAddr Description Reset
value
31:0 When an IRQ service routine reads the Vector Address register 0
(VICVectAddr), and no IRQ slot responds as described above, this
address is returned.
Table 49. Vector Address register (VICVectAddr - address 0xFFFF F030) bit description
VICVectAddr Description Reset
value
31:0 If any of the interrupt requests or software interrupts that are assigned 0
to a vectored IRQ slot is (are) enabled, classified as IRQ, and
asserted, reading from this register returns the address in the Vector
Address Register for the highest-priority such slot (lowest-numbered)
such slot. Otherwise it returns the address in the Default Vector
Address Register.
Writing to this register does not set the value for future reads from it.
Rather, this register should be written near the end of an ISR, to
update the priority hardware.
Table 50. Protection Enable register (VICProtection - address 0xFFFF F020) bit description
VICProtection Description Reset
value
0 1: the VIC registers can only be accessed in privileged mode. 0
0: VIC registers can be accessed in User or privileged mode.
31:1 Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
6. Interrupt sources
Table 5–51 lists the interrupt sources for each peripheral function. Each peripheral device
has one interrupt line connected to the Vectored Interrupt Controller, but may have several
internal interrupt flags. Individual interrupt flags may also represent more than one
interrupt source. See Table 5–33 for which flags are implemented for which parts.
VICINT
SOURCE
non-vectored IRQ interrupt logic
[31:0] IRQSTATUS[31:0]
IRQ NonVectIRQ
IRQSTATUS
RAWINTERRUPT INTSELECT [31:0]
[31:0] [31:0]
priority 0
vector interrupt 0
interrupt priority logic
address select
for
highest priority
SOURCE ENABLE VECTADDR VECTADDR0[31:0] interrupt
VECTCNTL[5:0] [31:0]
priority2
nVICIRQIN VICVECTADDRIN[31:0]
7. Spurious interrupts
Spurious interrupts are possible in the ARM7TDMI based microcontrollers such as the
LPC21xx and LPC22xx due to asynchronous interrupt handling. The asynchronous
character of the interrupt processing has its roots in the interaction of the core and the
VIC. If the VIC state is changed between the moments when the core detects an interrupt,
and the core actually processes an interrupt, problems may be generated.
1. VIC decides there is an IRQ interrupt and sends the IRQ signal to the core.
2. Core latches the IRQ state.
3. Processing continues for a few cycles due to pipelining.
4. Core loads IRQ address from VIC.
Furthermore, It is possible that the VIC state has changed during step 3. For example,
VIC was modified so that the interrupt that triggered the sequence starting with step 1) is
no longer pending -interrupt got disabled in the executed code. In this case, the VIC will
not be able to clearly identify the interrupt that generated the interrupt request, and as a
result the VIC will return the default interrupt VicDefVectAddr (0xFFFF F034).
1. Application code should be set up in a way to prevent the spurious interrupts from
occurring. Simple guarding of changes to the VIC may not be enough since, for
example, glitches on level sensitive interrupts can also cause spurious interrupts.
2. VIC default handler should be set up and tested properly.
If an IRQ interrupt is received during execution of the MSR instruction, then the behavior
will be as follows:
Although the example shows both IRQ and FIQ interrupts being disabled, similar behavior
occurs when only one of the two interrupt types is being disabled. The fact that the core
processes the IRQ after completion of the MSR instruction which disables IRQs does not
normally cause a problem, since an interrupt arriving just one cycle earlier would be
expected to be taken. When the interrupt routine returns with an instruction like:
The SPSR_IRQ is restored to the CPSR. The CPSR will now have the I bit and F bit set,
and therefore execution will continue with all interrupts disabled. However, this can cause
problems in the following cases:
Problem 2: FIQs and IRQs are both disabled by the same write to the CPSR. In this case,
if an IRQ is received during the CPSR write, FIQs will be disabled for the execution time of
the IRQ handler. This may not be acceptable in a system where FIQs must not be
disabled for more than a few cycles.
7.1.1 Workaround
There are 3 suggested workarounds. Which of these is most applicable will depend upon
the requirements of the particular system.
7.1.1.1 Solution 1: Test for an IRQ received during a write to disable IRQs
Add code similar to the following at the start of the interrupt routine.
This code will test for the situation where the IRQ was received during a write to disable
IRQs. If this is the case, the code returns immediately - resulting in the IRQ not being
acknowledged (cleared), and further IRQs being disabled.
Similar code may also be applied to the FIQ handler, in order to resolve the first issue.
7.1.1.2 Solution 2: Disable IRQs and FIQs using separate writes to the CPSR
This is the best workaround where the maximum time for which FIQs are disabled is
critical (it does not increase this time at all). However, it does not solve problem one, and
requires extra instructions at every point where IRQs and FIQs are disabled together.
This requires only the IRQ handler to be modified, and FIQs may be re-enabled more
quickly than by using workaround 1. However, this should only be used if the system can
guarantee that FIQs are never disabled while IRQs are enabled. It does not address
problem one.
Although multiple sources can be selected (VICIntSelect) to generate FIQ request, only
one interrupt service routine should be dedicated to service all available/present FIQ
request(s). Therefore, if more than one interrupt sources are classified as FIQ the FIQ
interrupt service routine must read VICFIQStatus to decide based on this content what to
do and how to process the interrupt request. However, it is recommended that only one
interrupt source should be classified as FIQ. Classifying more than one interrupt sources
as FIQ will increase the interrupt latency.
Following the completion of the desired interrupt service routine, clearing of the interrupt
flag on the peripheral level will propagate to corresponding bits in VIC registers
(VICRawIntr, VICFIQStatus and VICIRQStatus). Also, before the next interrupt can be
serviced, it is necessary that write is performed into the VICVectAddr register before the
return from interrupt is executed. This write will clear the respective interrupt flag in the
internal interrupt priority hardware.
In order to disable the interrupt at the VIC you need to clear corresponding bit in the
VICIntEnClr register, which in turn clears the related bit in the VICIntEnable register. This
also applies to the VICSoftInt and VICSoftIntClear in which VICSoftIntClear will clear the
respective bits in VICSoftInt. For example, if VICSoftInt = 0x0000 0005 and bit 0 has to be
cleared, VICSoftIntClear = 0x0000 0001 will accomplish this. Before the new clear
operation on the same bit in VICSoftInt using writing into VICSoftIntClear is performed in
the future, VICSoftIntClear = 0x0000 0000 must be assigned. Therefore writing 1 to any
bit in Clear register will have one-time-effect in the destination register.
If the watchdog is enabled for interrupt on underflow or invalid feed sequence only then
there is no way of clearing the interrupt. The only way you could perform return from
interrupt is by disabling the interrupt at the VIC (using VICIntEnClr).
Example: Assuming that UART0 and SPI0 are generating interrupt requests that are
classified as vectored IRQs (UART0 being on the higher level than SPI0), while UART1
and I2C are generating non-vectored IRQs, the following could be one possibility for VIC
setup:
VICIntSelect = 0x0000 0000 ; SPI0, I2C, UART1 and UART0 are IRQ =>
; bit10, bit9, bit7 and bit6=0
VICIntEnable = 0x0000 06C0 ; SPI0, I2C, UART1 and UART0 are enabled interrupts =>
; bit10, bit9, bit 7 and bit6=1
VICDefVectAddr = 0x... ; holds address at what routine for servicing
; non-vectored IRQs (i.e. UART1 and I2C) starts
VICVectAddr0 = 0x... ; holds address where UART0 IRQ service routine starts
VICVectAddr1 = 0x... ; holds address where SPI0 IRQ service routine starts
VICVectCntl0 = 0x0000 0026 ; interrupt source with index 6 (UART0) is enabled as
; the one with priority 0 (the highest)
VICVectCntl1 = 0x0000 002A ; interrupt source with index 10 (SPI0) is enabled
; as the one with priority 1
After any of IRQ requests (SPI0, I2C, UART0 or UART1) is made, microcontroller will
redirect code execution to the address specified at location 0x0000 0018. For vectored
and non-vectored IRQ’s the following instruction could be placed at 0x0000 0018:
This instruction loads PC with the address that is present in VICVectAddr register.
In case UART0 request has been made, VICVectAddr will be identical to VICVectAddr0,
while in case SPI0 request has been made value from VICVectAddr1 will be found here. If
neither UART0 nor SPI0 have generated IRQ request but UART1 and/or I2C were the
reason, content of VICVectAddr will be identical to VICDefVectAddr.
The following register descriptions include all LPC21xx and LPC22xx parts. Registers not
listed in Table 6–52 are identical for all parts.
For an overview of how LPC21xx and LPC22xx parts and versions are described in this
manual, see Section 1–2 “How to read this manual”.
[1] The PCONP bits common to all parts are: PCTIM0/1, PCUART0/1, PCI2C, PCSPI0/1, PCRTC, PCAD.
[2] Use the PCSSP bit to configure the SPI1 interface as SSP interface.
• Crystal Oscillator
• External Interrupt Inputs
• Miscellaneous System Controls and Status
• Memory Mapping Control
• PLL
• Power Control
• Reset
• APB Divider
• Wakeup Timer
Each type of function has its own register(s) if any are required and unneeded bits are
defined as reserved in order to allow future expansion. Unrelated functions never share
the same register addresses
3. Pin description
Table 6–53 shows pins that are associated with System Control block functions.
4. Register description
All registers, regardless of size, are on word address boundaries. Details of the registers
appear in the description of each function.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
5. Crystal oscillator
While an input signal of 50-50 duty cycle within a frequency range from 1 MHz to 50 MHz
can be used by the LPC21xx/22xx if supplied to its input XTAL1 pin, this microcontroller’s
onboard oscillator circuit supports external crystals in the range of 1 MHz to 30 MHz only.
If the on-chip PLL system or the boot-loader is used, the input clock frequency is limited to
an exclusive range of 10 MHz to 25 MHz.
The oscillator output frequency is called FOSC, and the ARM processor clock frequency is
referred to as CCLK for purposes of rate equations, etc. elsewhere in this document. FOSC
and CCLK are the same value unless the PLL is running and connected. Refer to the
Section 6–9 “Phase Locked Loop (PLL)” on page 69 for details and frequency limitations.
The onboard oscillator in the LPC21xx/LPC22xx can operate in one of two modes: slave
mode and oscillation mode.
In slave mode the input clock signal should be coupled by means of a capacitor of 100 pF
(CC in Figure 6–14, drawing a), with an amplitude of at least 200 mVrms. The XTAL2 pin
in this configuration can be left not connected. If slave mode is selected, the FOSC signal
of 50-50 duty cycle can range from 1 MHz to 50 MHz.
External components and models used in oscillation mode are shown in Figure 6–14,
drawings b and c, and in Table 6–55. Since the feedback resistance is integrated on chip,
only a crystal and the capacitances CX1 and CX2 need to be connected externally in case
of fundamental mode oscillation (the fundamental frequency is represented by L, CL and
RS). Capacitance CP in Figure 6–14, drawing c, represents the parallel package
capacitance and should not be larger than 7 pF. Parameters FC, CL, RS and CP are
supplied by the crystal manufacturer.
Choosing the oscillation mode as an on-board oscillator mode of operation, limits FOSC
clock selection to 1 MHz to 30 MHz.
LPC21xx/22xx LPC21xx/22xx
<=>
CC CL CP
Xtal
Clock CX1 CX2
RS
a) b) c)
Fig 14. Oscillator modes and models: a) slave mode of operation, b) oscillation mode of operation, c) external
crystal model used for CX1/X2 evaluation
Table 55. Recommended values for CX1/X2 in oscillation mode (crystal and external
components parameters)
Fundamental Crystal load Maximum crystal External load
oscillation frequency capacitance CL series resistance RS capacitors CX1, CX2
FOSC
1 MHz - 5 MHz 10 pF NA NA
20 pF NA NA
30 pF < 300 Ω 58 pF, 58 pF
5 MHz - 10 MHz 10 pF < 300 Ω 18 pF, 18 pF
20 pF < 300 Ω 38 pF, 38 pF
30 pF < 300 Ω 58 pF, 58 pF
10 MHz - 15 MHz 10 pF < 300 Ω 18 pF, 18 pF
20 pF < 220 Ω 38 pF, 38 pF
30 pF < 140 Ω 58 pF, 58 pF
15 MHz - 20 MHz 10 pF < 220 Ω 18 pF, 18 pF
20 pF < 140 Ω 38 pF, 38 pF
30 pF < 80 Ω 58 pF, 58 pF
20 MHz - 25 MHz 10 pF < 160 Ω 18 pF, 18 pF
20 pF < 90 Ω 38 pF, 38 pF
30 pF < 50 Ω 58 pF, 58 pF
25 MHz - 30 MHz 10 pF < 130 Ω 18 pF, 18 pF
20 pF < 50 Ω 38 pF, 38 pF
30 pF NA NA
f OSC selection
false
false
false
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
Writing ones to bits EINT0 through EINT3 in EXTINT register clears the corresponding
bits. In level-sensitive mode this action has an effect only when the pin is in its inactive
state.
Once a bit from EINT0 to EINT3 is set and an appropriate code starts to execute (handling
wakeup and/or external interrupt), this bit in EXTINT register must be cleared. Otherwise
the event that was just triggered by activity on the EINT pin will not be recognized in the
future.
For example, if a system wakes up from power-down using a low level on external
interrupt 0 pin, its post-wakeup code must reset the EINT0 bit in order to allow future entry
into the power-down mode. If the EINT0 bit is left set to 1, subsequent attempt(s) to invoke
Power-down mode will fail. The same goes for external interrupt handling.
More details on the Power-down mode will be discussed in the following chapters.
Table 57. External Interrupt Flag register (EXTINT - address 0xE01F C140) bit description
Bit Symbol Description Reset
value
0 EINT0 In level-sensitive mode, this bit is set if the EINT0 function is selected for its pin, and the pin is in 0
its active state. In edge-sensitive mode, this bit is set if the EINT0 function is selected for its pin,
and the selected edge occurs on the pin.
Up to two pins can be selected to perform the EINT0 function (see P0.1 and P0.16 description in
"Pin Configuration" chapter, Section 7–2 and Section 7–3).
This bit is cleared by writing a one to it, except in level sensitive mode when the pin is in its
active state (e.g. if EINT0 is selected to be low level sensitive and a low level is present on the
corresponding pin, this bit can not be cleared; this bit can be cleared only when the signal on the
pin becomes high).
1 EINT1 In level-sensitive mode, this bit is set if the EINT1 function is selected for its pin, and the pin is in 0
its active state. In edge-sensitive mode, this bit is set if the EINT1 function is selected for its pin,
and the selected edge occurs on the pin.
Up to two pins can be selected to perform the EINT1 function (see P0.3 and P0.14 description in
"Pin Configuration" chapter, Section 7–2 and Section 7–3).
This bit is cleared by writing a one to it, except in level sensitive mode when the pin is in its
active state (e.g. if EINT1 is selected to be low level sensitive and a low level is present on the
corresponding pin, this bit can not be cleared; this bit can be cleared only when the signal on the
pin becomes high).
2 EINT2 In level-sensitive mode, this bit is set if the EINT2 function is selected for its pin, and the pin is in 0
its active state. In edge-sensitive mode, this bit is set if the EINT2 function is selected for its pin,
and the selected edge occurs on the pin.
Up to two pins can be selected to perform the EINT2 function (see P0.7 and P0.15 description in
"Pin Configuration" chapter, Section 7–2 and Section 7–3).
This bit is cleared by writing a one to it, except in level sensitive mode when the pin is in its
active state (e.g. if EINT2 is selected to be low level sensitive and a low level is present on the
corresponding pin, this bit can not be cleared; this bit can be cleared only when the signal on the
pin becomes high).
3 EINT3 In level-sensitive mode, this bit is set if the EINT3 function is selected for its pin, and the pin is in 0
its active state. In edge-sensitive mode, this bit is set if the EINT3 function is selected for its pin,
and the selected edge occurs on the pin.
Up to three pins can be selected to perform the EINT3 function (see P0.9, P0.20 and P0.30
description in "Pin Configuration" chapter, Section 7–2 and Section 7–3).
This bit is cleared by writing a one to it, except in level sensitive mode when the pin is in its
active state (e.g. if EINT3 is selected to be low level sensitive and a low level is present on the
corresponding pin, this bit can not be cleared; this bit can be cleared only when the signal on the
pin becomes high).
7:4 - Reserved, user software should not write ones to reserved bits. The value read from a reserved NA
bit is not defined.
For an external interrupt pin to be a source that would wake up the microcontroller from
Power-down mode, it is also necessary to clear the corresponding bit in the External
Interrupt Flag register (Section 6–6.2 on page 62).
Table 58. Interrupt Wakeup register (INTWAKE - address 0xE01F C144) bit description
Bit Symbol Description Reset
value
0 EXTWAKE0 When one, assertion of EINT0 will wake up the processor from 0
Power-down mode.
1 EXTWAKE1 When one, assertion of EINT1 will wake up the processor from 0
Power-down mode.
2 EXTWAKE2 When one, assertion of EINT2 will wake up the processor from 0
Power-down mode.
3 EXTWAKE3 When one, assertion of EINT3 will wake up the processor from 0
Power-down mode.
7:4 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
Note: Software should only change a bit in this register when its interrupt is
disabled in the VICIntEnable register, and should write the corresponding 1 to the
EXTINT register before enabling (initializing) or re-enabling the interrupt, to clear
the EXTINT bit that could be set by changing the mode.
Table 59. External Interrupt Mode register (EXTMODE - address 0xE01F C148) bit
description
Bit Symbol Value Description Reset
value
0 EXTMODE0 0 Level-sensitivity is selected for EINT0. 0
1 EINT0 is edge sensitive.
1 EXTMODE1 0 Level-sensitivity is selected for EINT1. 0
1 EINT1 is edge sensitive.
Table 59. External Interrupt Mode register (EXTMODE - address 0xE01F C148) bit
description
Bit Symbol Value Description Reset
value
2 EXTMODE2 0 Level-sensitivity is selected for EINT2. 0
1 EINT2 is edge sensitive.
3 EXTMODE3 0 Level-sensitivity is selected for EINT3. 0
1 EINT3 is edge sensitive.
7:4 - - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Note: Software should only change a bit in this register when its interrupt is
disabled in the VICIntEnable register, and should write the corresponding 1 to the
EXTINT register before enabling (initializing) or re-enabling the interrupt, to clear
the EXTINT bit that could be set by changing the polarity.
Table 60. External Interrupt Polarity register (EXTPOLAR - address 0xE01F C14C) bit
description
Bit Symbol Value Description Reset
value
0 EXTPOLAR0 0 EINT0 is low-active or falling-edge sensitive (depending on 0
EXTMODE0).
1 EINT0 is high-active or rising-edge sensitive (depending on
EXTMODE0).
1 EXTPOLAR1 0 EINT1 is low-active or falling-edge sensitive (depending on 0
EXTMODE1).
1 EINT1 is high-active or rising-edge sensitive (depending on
EXTMODE1).
2 EXTPOLAR2 0 EINT2 is low-active or falling-edge sensitive (depending on 0
EXTMODE2).
1 EINT2 is high-active or rising-edge sensitive (depending on
EXTMODE2).
3 EXTPOLAR3 0 EINT3 is low-active or falling-edge sensitive (depending on 0
EXTMODE3).
1 EINT3 is high-active or rising-edge sensitive (depending on
EXTMODE3).
7:4 - - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
The external interrupt logic handles the case when more than one pin is selected for a
particular interrupt, depending on how the interrupt’s mode and polarity bits are set:
• In Low-Active Level Sensitive mode, the states of all pins selected for the same EINTx
functionality are digitally combined using a positive logic AND gate.
• In High-Active Level Sensitive mode, the states of all pins selected for the same
EINTx functionality are digitally combined using a positive logic OR gate.
• In Edge Sensitive mode, regardless of polarity, the pin with the lowest GPIO port
number is used. (Selecting multiple pins for an EINTx in edge-sensitive mode could
be considered a programming error.)
The signal derived by this logic processing multiple external interrupt pins is the “EINTi to
wakeup timer” signal in the following logic schematic Figure 6–16.
For example, if the EINT3 function is selected in the PINSEL0 and PINSEL1 registers for
pins P0.9, P0.20 and P0.30, and EINT3 is configured to be low level sensitive, the inputs
from all three pins will be logically ANDed. When more than one EINT pin is logically
ORed, the interrupt service routine can read the states of the pins from the GPIO port
using the IO0PIN and IO1PIN registers, to determine which pin(s) caused the interrupt.
wakeup enable
APB Read
(one bit of EXTWAKE)
of EXTWAKE
GLITCH
EINTi PCLK
FILTER
1 S
D S S
Q Q Q to VIC
R R
EXTMODEi
APB read of
EXTINT
PCLK PCLK
reset
write 1 to EXTINTi
7.1 System Control and Status flags register (SCS - 0xE01F C1A0)
Table 61. System Control and Status flags register (SCS - address 0xE01F C1A0) bit
description
Bit Symbol Value Description Reset
value
0 GPIO0M GPIO port 0 mode selection. 0
0 GPIO port 0 is accessed via APB addresses in a fashion
compatible with previous LCP2000 devices.
1 High speed GPIO is enabled on GPIO port 0, accessed via
addresses in the on-chip memory range. This mode
includes the port masking feature described in Section
9–5.5 “Fast GPIO port Mask register FIOMASK(FIO0MASK
- 0x3FFF C010, FIO1MASK - 0x3FFF C030)”
Table 61. System Control and Status flags register (SCS - address 0xE01F C1A0) bit
description
Bit Symbol Value Description Reset
value
1 GPIO1M GPIO port 1 mode selection. 0
0 GPIO port 1 is accessed via APB addresses in a fashion
compatible with previous LCP2000 devices.
1 High speed GPIO is enabled on GPIO port 1, accessed via
addresses in the on-chip memory range. This mode
includes the port masking feature described in Section
9–5.5 “Fast GPIO port Mask register FIOMASK(FIO0MASK
- 0x3FFF C010, FIO1MASK - 0x3FFF C030)”
31:2 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Table 62. Memory Mapping control register (MEMMAP - address 0xE01F C040) bit
description
Bit Symbol Value Description Reset
value
1:0 MAP 00 Boot Loader Mode. Interrupt vectors are re-mapped to Boot 00[1]
Block.
01 User flash mode. Interrupt vectors are not re-mapped and
reside in Flash memory
10 User RAM Mode. Interrupt vectors are re-mapped to Static
RAM.
11 User External memory Mode. Interrupt vectors are re-mapped
to external memory.
Remark: This mode is available in 144-pin parts with external
memory controller only. This value is reserved for parts
without external memory controller, and user software should
not write ones to reserved bits.
Warning: Improper setting of this value may result in incorrect
operation of the device.
7:2 - - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
[1] The hardware reset value of the MAP1:0 bits is 00 for LPC21xx/LPC22xx parts. The apparent reset value
visible to the user is different because it is altered by the Boot Loader code, which always runs initially at
reset.
For example, whenever a Software Interrupt request is generated, the ARM core will
always fetch 32-bit data "residing" on 0x0000 0008 see Table 2–19 “ARM exception
vector locations” on page 22. This means that when MEMMAP[1:0]=10 (User RAM
Mode), a read/fetch from 0x0000 0008 will provide data stored in 0x4000 0008. In case of
MEMMAP[1:0]=00 (Boot Loader Mode), a read/fetch from 0x0000 0008 will provide data
available also at 0x7FFF E008 (Boot Block remapped from on-chip Bootloader).
MEMMAP[1:1]=11 (User External Memory Mode) will result in fetching data from off-chip
memory at location 0x8000 0008.
PLL activation is controlled via the PLLCON register. The PLL multiplier and divider
values are controlled by the PLLCFG register. These two registers are protected in order
to prevent accidental alteration of PLL parameters or deactivation of the PLL. Since all
chip operations, including the Watchdog Timer, are dependent on the PLL when it is
providing the chip clock, accidental changes to the PLL setup could result in unexpected
behavior of the microcontroller. The protection is accomplished by a feed sequence
similar to that of the Watchdog Timer. Details are provided in the description of the
PLLFEED register.
The PLL is turned off and bypassed following a chip reset and when by entering
Power-down mode. The PLL is enabled by software only. The program must configure
and activate the PLL, wait for the PLL to Lock, then connect to the PLL as a clock source.
Warning: Improper setting of the PLL values may result in incorrect operation of the
device!
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
PLLC
CLOCK
SYNCHRONIZATION
0 direct
PSEL[1:0]
PD PD
PLLE
0 bypass
FOSC 1 CD
PHASE- FCCO
FREQUENCY CCO 0
0
PLOCK DETECTOR /2P
0 CCLK
1
PD 1
CD
FOUT
DIV-BY-M
MSEL<4:0>
MSEL[4:0]
Table 64. PLL Control register (PLLCON - address 0xE01F C080) bit description
Bit Symbol Description Reset
value
0 PLLE PLL Enable. When one, and after a valid PLL feed, this bit will 0
activate the PLL and allow it to lock to the requested frequency. See
PLLSTAT register, Table 6–66.
1 PLLC PLL Connect. When PLLC and PLLE are both set to one, and after a 0
valid PLL feed, connects the PLL as the clock source for the
microcontroller. Otherwise, the oscillator clock is used directly by the
microcontroller. See PLLSTAT register, Table 6–66.
7:2 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
The PLL must be set up, enabled, and Lock established before it may be used as a clock
source. When switching from the oscillator clock to the PLL output or vice versa, internal
circuitry synchronizes the operation in order to ensure that glitches are not generated.
Hardware does not insure that the PLL is locked before it is connected or automatically
disconnect the PLL if lock is lost during operation. In the event of loss of PLL lock, it is
likely that the oscillator clock has become unstable and disconnecting the PLL will not
remedy the situation.
Table 65. PLL Configuration register (PLLCFG - address 0xE01F C084) bit description
Bit Symbol Description Reset
value
4:0 MSEL PLL Multiplier value. Supplies the value "M" in the PLL frequency 0
calculations.
Note: For details on selecting the right value for MSEL see Section
6–9.9 “PLL frequency calculation” on page 73.
6:5 PSEL PLL Divider value. Supplies the value "P" in the PLL frequency 0
calculations.
Note: For details on selecting the right value for PSEL see Section
6–9.9 “PLL frequency calculation” on page 73.
7 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
Table 66. PLL Status register (PLLSTAT - address 0xE01F C088) bit description
Bit Symbol Description Reset
value
4:0 MSEL Read-back for the PLL Multiplier value. This is the value currently 0
used by the PLL.
6:5 PSEL Read-back for the PLL Divider value. This is the value currently 0
used by the PLL.
7 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
8 PLLE Read-back for the PLL Enable bit. When one, the PLL is currently 0
activated. When zero, the PLL is turned off. This bit is automatically
cleared when Power-down mode is activated.
9 PLLC Read-back for the PLL Connect bit. When PLLC and PLLE are both 0
one, the PLL is connected as the clock source for the
microcontroller. When either PLLC or PLLE is zero, the PLL is
bypassed and the oscillator clock is used directly by the
microcontroller. This bit is automatically cleared when Power-down
mode is activated.
10 PLOCK Reflects the PLL Lock status. When zero, the PLL is not locked. 0
When one, the PLL is locked onto the requested frequency.
15:11 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
The two writes must be in the correct sequence, and must be consecutive APB bus
cycles. The latter requirement implies that interrupts must be disabled for the duration of
the PLL feed operation. If either of the feed values is incorrect, or one of the previously
mentioned conditions is not met, any changes to the PLLCON or PLLCFG register will not
become effective.
Table 68. PLL Feed register (PLLFEED - address 0xE01F C08C) bit description
Bit Symbol Description Reset
value
7:0 PLLFEED The PLL feed sequence must be written to this register in order for 0x00
PLL configuration and control register changes to take effect.
The PLL output frequency (when the PLL is both active and connected) is given by:
1. Choose the desired processor operating frequency (CCLK). This may be based on
processor throughput requirements, need to support a specific set of UART baud
rates, etc. Bear in mind that peripheral devices may be running from a lower clock
than the processor (see Section 6–12 “APB divider” on page 80).
2. Choose an oscillator frequency (FOSC). CCLK must be the whole (non-fractional)
multiple of FOSC.
3. Calculate the value of M to configure the MSEL bits. M = CCLK / FOSC. M must be in
the range of 1 to 32. The value written to the MSEL bits in PLLCFG is M − 1 (see
Table 6–71.
4. Find a value for P to configure the PSEL bits, such that FCCO is within its defined
frequency limits. FCCO is calculated using the equation given above. P must have one
of the values 1, 2, 4, or 8. The value written to the PSEL bits in PLLCFG is 00 for
P = 1; 01 for P = 2; 10 for P = 4; 11 for P = 8 (see Table 6–70).
Value for P can be derived from P = FCCO / (CCLK x 2), using condition that FCCO must be
in range of 156 MHz to 320 MHz. Assuming the lowest allowed frequency for
FCCO = 156 MHz, P = 156 MHz / (2 x 60 MHz) = 1.3. The highest FCCO frequency criteria
produces P = 2.67. The only solution for P that satisfies both of these requirements and is
listed in Table 6–70 is P = 2. Therefore, PLLCFG[6:5] = 1 will be used.
In Power-down mode, the oscillator is shut down and the chip receives no internal clocks.
The processor state and registers, peripheral registers, and internal SRAM values are
preserved throughout Power-down mode and the logic levels of chip pins remain static.
The Power-down mode can be terminated and normal operation resumed by either a
reset or certain specific interrupts that are able to function without clocks. Since all
dynamic operation of the chip is suspended, Power-down mode reduces chip power
consumption to nearly zero.
Entry to Power-down and Idle modes must be coordinated with program execution.
Wakeup from Power-down or Idle modes via an interrupt resumes program execution in
such a way that no instructions are lost, incomplete, or repeated. Wake up from
Power-down mode is discussed further in Section 6–13 “Wakeup timer” on page 82.
A Power Control for Peripherals feature allows individual peripherals to be turned off if
they are not needed in the application, resulting in additional power savings.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
Table 73. Power Control register (PCON - address 0xE01F COCO) bit description
Bit Symbol Description Reset
value
0 IDL Idle mode - when 1, this bit causes the processor clock to be stopped, 0
while on-chip peripherals remain active. Any enabled interrupt from a
peripheral or an external interrupt source will cause the processor to
resume execution.
1 PD Power-down mode - when 1, this bit causes the oscillator and all 0
on-chip clocks to be stopped. A wakeup condition from an external
interrupt can cause the oscillator to restart, the PD bit to be cleared, and
the processor to resume execution.
7:2 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
Important: valid read from a peripheral register and valid write to a peripheral
register is possible only if that peripheral is enabled in the PCONP register!
Table 74. Power Control for Peripherals register (PCONP - address 0xE01F C0C4) bit
description
Bit Symbol Description Reset
value
0 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
1 PCTIM0 Timer/Counter 0 power/clock control bit. 1
2 PCTIM1 Timer/Counter 1 power/clock control bit. 1
3 PCUART0 UART0 power/clock control bit. 1
4 PCUART1 UART1 power/clock control bit. 1
5 PCPWM0 PWM0 power/clock control bit. 1
6 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
7 PCI2C The I2C interface power/clock control bit. 1
8 PCSPI0 The SPI0 interface power/clock control bit. 1
9 PCRTC The RTC power/clock control bit. 1
10 PCSPI1 The SPI1 interface power/clock control bit. 1
11 PCEMC The EMC power/clock control bit. 1
12 PCAD A/D Converter (ADC) power/clock control bit. 1
Note: Clear the PDN bit in the ADCR before clearing this bit, and set
this bit before setting PDN.
13 PCCAN1 CAN1 controller bit. 1
14 PCCAN2 CAN2 controller bit. 1
15 PCCAN3 CAN3 controller bit. 1
16 PCCAN4 CAN4 controller bit. 1
22:17 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
23 PCSSP The SSP interface power/clock control bit 0
Remark: Setting this bit to 1 and bit 10 (PSPI1) to 0, selects the SPI1
interface as SSP interface. At reset, SPI1 is enabled. See
Section 14–3 on page 219.
31:24 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
Power saving oriented systems should have 1s in the PCONP register only in positions
that match peripherals really used in the application. All other bits, declared to be
"Reserved" or dedicated to the peripherals not used in the current application, must be
cleared to 0.
11. Reset
Reset has two sources on the LPC21xx/LPC22xx: the RESET pin and Watchdog reset.
The RESET pin is a Schmitt trigger input pin with an additional glitch filter. Assertion of
chip reset by any source starts the wakeup timer (see description in Section 6–13
“Wakeup timer” in this chapter), causing reset to remain asserted until the external reset is
de-asserted, the oscillator is running, a fixed number of clocks have passed, and the
on-chip circuitry has completed its initialization. The relationship between reset, the
oscillator, and the wakeup timer during the startup sequence are shown in Figure 6–18.
See Figure 6–19 for a block diagram of the Reset logic.
The reset glitch filter allows the processor to ignore external reset pulses that are very
short, and also determines the minimum duration of RESET that must be asserted in
order to guarantee a chip reset. Once asserted, RESET pin can be deasserted only when
crystal oscillator is fully running and an adequate signal is present on the XTAL1 pin of the
microcontroller. Assuming that an external crystal is used in the crystal oscillator
subsystem, after power on, the RESET pin should be asserted for 10 ms. For all
subsequent resets, when the crystal oscillator is already running and a stable signal is on
the XTAL1 pin, the RESET pin needs to be asserted for 300 ns only.
When the internal reset is removed, the processor begins executing at address 0, which is
initially the reset vector mapped from the Boot Block. At that point, all of the processor and
peripheral registers have been initialized to predetermined values.
oscillator
VDD(3V3)
3.0 V[3]
GND
VDD(1V8)
1.65 V[3]
GND
002aad483
(1) Reset time: The time reset needs to be held LOW. This time depends on system parameters such as VDD(1V8), V3V3 risetime,
and the oscillator startup time. There are no restrictions from the microcontroller except that VDD(1V8), V3V3, and the oscillator
must be within the specific operating range.
(2) There are no sequencing requirements for V3V3 and VDD(1V8).
(3) When V3V3 and VDD(1V8) reach the minimum voltage, a reset is registered within two valid oscillator clocks.
(4) Typical startup time is 0.5 ms for a 12 mHz crystal.
Fig 18. Startup sequence diagram
reset to the
external
C on-chip circuitry
reset
Q
watchdog S reset to
reset PCON.PD
WAKE-UP TIMER
START
power
down
COUNT 2 n C
ABP read of
PLL PDBIT
in PCON
FOSC
to CPU
External and internal resets have some small differences. An external reset causes the
value of certain pins to be latched to configure the part. External circuitry cannot
determine when an internal reset occurs in order to allow setting up those special pins, so
those latches are not reloaded during an internal reset. Pins that are examined during an
external reset for various purposes are: P1.20/TRACESYNC, P1.26/RTCK (see
Section 7–2, Section 7–3, and Section 8–6 . Pin P0.14 (see Section 21–5) is examined by
on-chip bootloader when this code is executed after every reset.
1. The first purpose is to provide peripherals with desired PCLK via APB bus so that they
can operate at the speed chosen for the ARM processor. In order to achieve this, the
APB bus may be slowed down to one half or one fourth of the processor clock rate.
Because the APB bus must work properly at power up (and its timing cannot be
altered if it does not work since the APB divider control registers reside on the APB
bus), the default condition at reset is for the APB bus to run at one quarter speed.
2. The second purpose of the APB Divider is to allow power savings when an application
does not require any peripherals to run at the full processor rate.
The connection of the APB Divider relative to the oscillator and the processor clock is
shown in Figure 6–20. Because the APB Divider is connected to the PLL output, the PLL
remains active (if it was running) during Idle mode.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
Table 76. APB Divider register (APBDIV - address 0xE01F C100) bit description
Bit Symbol Value Description Reset
value
1:0 APBDIV 00 APB bus clock is one fourth of the processor clock. 00
01 APB bus clock is the same as the processor clock.
10 APB bus clock is one half of the processor clock.
11 Reserved. If this value is written to the APBDIV register,
it has no effect (the previous setting is retained).
3:2 - - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is not
defined.
5:4 XCLKDIV On the LPC22xx devices only, these bits control the 00
clock that can be driven onto the P3.23/A23/XCLK pin.
They have the same encoding as the APBDIV bits
above. Bits 13 and 27:25 in the PINSEL2 register
(Section 8–6.4) controls whether the pin carries A23 or
the clock selected by this field.
Remark:
If this field and APBDIV have the same value, the same
clock is used on the APB and XCLK. (This might be
useful for external logic dealing with the APB
peripherals).
00 XCLK clock is one fourth of the processor clock.
01 XCLK clock is the same as the processor clock.
10 XCLK clock is one half of the processor clock.
11 Reserved. If this value is written to the APBDIV register,
it has no effect (the previous setting is retained).
7:6 - - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is not
defined.
crystal oscillator or
processor clock
external clock source PLL0
(CCLK)
(FOSC)
APB clock
APB DIVIDER
(PCLK)
The purpose of the wakeup timer is to ensure that the oscillator and other analog
functions required for chip operation are fully functional before the processor is allowed to
execute instructions. This is important at power on, all types of reset, and whenever any of
the aforementioned functions are turned off for any reason. Since the oscillator and other
functions are turned off during Power-down mode, any wakeup of the processor from
Power-down mode makes use of the wakeup timer.
The wakeup timer monitors the crystal oscillator to check whether it is safe to begin code
execution. When power is applied to the chip, or some event caused the chip to exit
Power-down mode, some time is required for the oscillator to produce a signal of sufficient
amplitude to drive the clock logic. The amount of time depends on many factors, including
the rate of VDD ramp (in the case of power on), the type of crystal and its electrical
characteristics (if a quartz crystal is used) as well as any other external circuitry (e.g.
capacitors), and the characteristics of the oscillator itself under the existing ambient
conditions.
Once a clock is detected, the wakeup timer counts 4096 clocks and then enables the flash
memory to initialize. When the flash memory initialization is complete, the processor is
released to execute instructions if the external reset has been deasserted. If an external
clock source is used in the system (as opposed to a crystal connected to the oscillator
pins), the possibility that there could be little or no delay for oscillator start-up must be
considered. The wakeup timer design then ensures that any other required chip functions
will be operational prior to the beginning of program execution.
Any of the various resets can bring the microcontroller out of power-down mode, as can
the external interrupts EINT3:0. When one of these interrupts is enabled for wakeup and
its selected event occurs, an oscillator wakeup cycle is started. The actual interrupt (if
any) occurs after the wakeup timer expires and is handled by the Vectored Interrupt
Controller.
The pin multiplexing on the LPC21xx/LPC22xx (see Section 7–2, Section 7–3, and
Section 8–6) allows peripherals that share pins with external interrupts to, in effect, bring
the device out of Power-down mode. The following pin-function pairings allow interrupts
from events relating to UART0 or 1, SPI 0 or 1, or the I2C: RXD0 / EINT0, SDA / EINT1,
SSEL0 / EINT2, RXD1 / EINT3, DCD1 / EINT1, RI1 / EINT2, SSEL1 / EINT3.
To put the device in Power-down mode and allow activity on one or more of these buses
or lines to power it back up, software should reprogram the pin function to External
Interrupt, select the appropriate mode and polarity for the Interrupt, and then select
Power-down mode. Upon wakeup software should restore the pin multiplexing to the
peripheral function.
Details on the way Code Read Protection works can be found in Section 21–8 “Code
Read Protection (CRP)”.
Pin number
Table 7–79
1 P0[21]/PWM5/CAP1[3] P0[21]/PWM5/CAP1[3] P0[21]/PWM5/CAP1[3] P0[21]/PWM5/RD3/CAP1[3]
2 P0[22]/CAP0[0]/MAT0[0] P0[22]/CAP0[0]/MAT0[0] P0[22]/CAP0[0]/MAT0[0] P0[22]/TD3/CAP0[0]/MAT0[0]
3 P0[23] P0[23]/RD2 P0[23] P0[23]/RD2
5 P0[24] P0[24]/TD2 P0[24] P0[24]/TD2
9 P0[25]/RD1 P0[25]/RD1 P0[25] P0[25]/RD1
10 TD1 TD1 n.c. TD1
38 P0[12]/DSR1/MAT1[0] P0[12]/DSR1/MAT1[0] P0[12]/DSR1/MAT1[0] P0[12]/DSR1/MAT1[0]/RD4
39 P0[13]/DTR1/MAT1[1] P0[13]/DTR1/MAT1[1] P0[13]/DTR1/MAT1[1] P0[13]/DTR1/MAT1[1]/TD4
The SPI1 pins are shared with the SSP pins if the SSP interface is implemented. The
following parts have an SSP interface:
• LPC2194/01
• LPC2210/01, LPC2220
• LPC2212/01, LPC2214/01
• LPC2290/01
• LPC2292/01, LPC2294/01
For an overview of how LPC21xx and LPC22xx parts and versions are described in this
manual, see Section 1–2 “How to read this manual”.
54 P0[19]/MAT1[2]/MOSI1/CAP1[2]
53 P0[18]/CAP1[3]/MISO1/MAT1[3]
55 P0[20]/MAT1[3]/SSEL1/EINT3
64 P1[27]/TDO
52 P1[30]/TMS
56 P1[29]/TCK
60 P1[28]/TDI
63 VDDA(1V8)
58 VSSA(PLL)
51 VDD(3V3)
49 VDD(1V8)
57 RESET
62 XTAL1
61 XTAL2
59 VSSA
50 VSS
P0[21]/PWM5/RD3/CAP1[3] 1 48 P1[20]/TRACESYNC
P0[22]/TD3/CAP0[0]/MAT0[0] 2 47 P0[17]/CAP1[2]/SCK1/MAT1[2]
P0[23]/RD2 3 46 P0[16]/EINT0/MAT0[2]/CAP0[2]
P1[19]/TRACEPKT3 4 45 P0[15]/RI1/EINT2
P0[24]/TD2 5 44 P1[21]/PIPESTAT0
VSS 6 43 VDD(3V3)
VDDA(3V3) 7 LPC21xx 42 VSS
P1[18]/TRACEPKT2 8 LPC21xx/01 41 P0[14]/DCD1/EINT1
P0[25]/RD1 9 40 P1[22]/PIPESTAT1
TD1 10 39 P0[13]/DTR1/MAT1[1]/TD4
P0[27]/AIN0/CAP0[1]/MAT0[1] 11 38 P0[12]/DSR1/MAT1[0]/RD4
P1[17]/TRACEPKT1 12 37 P0[11]/CTS1/CAP1[1]
P0[28]/AIN1/CAP0[2]/MAT0[2] 13 36 P1[23]/PIPESTAT2
P0[29]/AIN2/CAP0[3]/MAT0[3] 14 35 P0[10]/RTS1/CAP1[0]
P0[30]/AIN3/EINT3/CAP0[0] 15 34 P0[9]/RXD1/PWM6/EINT3
P1[16]/TRACEPKT0 16 33 P0[8]/TXD1/PWM4
VDD(1V8) 17
VSS 18
P0[0]/TXD0/PWM1 19
P1[31]/TRST 20
P0[1]/RXD0/PWM3/EINT0 21
P0[2]/SCL/CAP0[0] 22
VDD(3V3) 23
P1[26]/RTCK 24
VSS 25
P0[3]/SDA/MAT0[0]/EINT1 26
P0[4]/SCK0/CAP0[1] 27
P1[25]/EXTIN0 28
P0[5]/MISO0/MAT0[1] 29
P0[6]/MOSI0/CAP0[2] 30
P0[7]/SSEL0/PWM2/EINT2 31
P1[24]/TRACECLK 32
P0[2]/SCL/ 22[3] I/O SCL — I2C-bus clock input/output. Open-drain output (for I2C-bus compliance).
CAP0[0]
I CAP0[0] — Capture input for Timer 0, channel 0.
P0[3]/SDA/ 26[3] I/O SDA — I2C-bus data input/output. Open-drain output (for I2C-bus compliance).
MAT0[0]/EINT1
O MAT0[0] — Match output for Timer 0, channel 0.
P0[4]/SCK0/ 27[1] I/O SCK0 — Serial clock for SPI0. SPI clock output from master or input to slave.
CAP0[1]
I CAP0[1] — Capture input for Timer 0, channel 1.
P0[5]/MISO0/ 29[1] I/O MISO0 — Master In Slave Out for SPI0. Data input to SPI master or data output
MAT0[1] from SPI slave.
P0[6]/MOSI0/ 30[1] I/O MOSI0 — Master Out Slave In for SPI0. Data output from SPI master or data input
CAP0[2] to SPI slave.
P0[7]/SSEL0/ 31[2] I SSEL0 — Slave Select for SPI0. Selects the SPI interface as a slave.
PWM2/EINT2
O PWM2 — Pulse Width Modulator output 2.
P0[28]/AIN1/ 13[4] I AIN1 — A/D converter, input 1. This analog input is always connected to its pin.
CAP0[2]/MAT0[2]
I CAP0[2] — Capture input for Timer 0, channel 2.
P0[29]/AIN2/ 14[4] I AIN2 — A/D converter, input 2. This analog input is always connected to its pin.
CAP0[3]/MAT0[3]
I CAP0[3] — Capture input for Timer 0, Channel 3.
P0[30]/AIN3/ 15[4] I AIN3 — A/D converter, input 3. This analog input is always connected to its pin.
EINT3/CAP0[0]
I EINT3 — External interrupt 3 input.
P1[0] to P1[31] I/O Port 1 is a 32-bit bidirectional I/O port with individual direction controls for each bit.
The operation of port 1 pins depends upon the pin function selected via the Pin
Connect Block. Pins 0 through 15 of port 1 are not available.
P1[16]/ 16[5] O Trace Packet, bit 0. Standard I/O port with internal pull-up.
TRACEPKT0
P1[17]/ 12[5] O Trace Packet, bit 1. Standard I/O port with internal pull-up.
TRACEPKT1
P1[18]/ 8[5] O Trace Packet, bit 2. Standard I/O port with internal pull-up.
TRACEPKT2
P1[19]/ 4[5] O Trace Packet, bit 3. Standard I/O port with internal pull-up.
TRACEPKT3
P1[20]/ 48[5] O Trace Synchronization. Standard I/O port with internal pull-up.
TRACESYNC Note: LOW on this pin while RESET is LOW, enables pins P1[25:16] to operate as
Trace port after reset.
P1[21]/ 44[5] O Pipeline Status, bit 0. Standard I/O port with internal pull-up.
PIPESTAT0
P1[22]/ 40[5] O Pipeline Status, bit 1. Standard I/O port with internal pull-up.
PIPESTAT1
P1[23]/ 36[5] O Pipeline Status, bit 2. Standard I/O port with internal pull-up.
PIPESTAT2
P1[24]/ 32[5] O Trace Clock. Standard I/O port with internal pull-up.
TRACECLK
[1] 5 V tolerant pad providing digital I/O functions with TTL levels and hysteresis and 10 ns slew rate control.
[2] 5 V tolerant pad providing digital I/O functions with TTL levels and hysteresis and 10 ns slew rate control. If configured for an input
function, this pad utilizes built-in glitch filter that blocks pulses shorter than 3 ns.
[3] Open drain 5 V tolerant digital I/O I2C-bus 400 kHz specification compatible pad. It requires external pull-up to provide an output
functionality. Open-drain functionality applies to all output functions on this pin.
[4] 5 V tolerant pad providing digital I/O (with TTL levels and hysteresis and 10 ns slew rate control) and analog input function. If configured
for a digital input function, this pad utilizes built-in glitch filter that blocks pulses shorter than 3 ns. When configured as an ADC input,
digital section of the pad is disabled.
[5] 5 V tolerant pad with built-in pull-up resistor providing digital I/O functions with TTL levels and hysteresis and 10 ns slew rate control.
The pull-up resistor’s value ranges from 60 kΩ to 300 kΩ.
144
109
1 108
LPC22xx
36 73
37
72
(1) Pin configuration is identical for devices with and without /00 and /01 suffixes.
Fig 22. LQFP144 pinning
ball A1
LPC22xx
index area
1 2 3 4 5 6 7 8 9 10 11 12 13
A
B
C
D
E
F
G
H
J
K
L
M
N
(1) Pin configuration is identical for devices with and without /00 and /01 suffixes.
Fig 23. TFBGA144 pinning
NXP Semiconductors
Table 80. LPC22xx Ball allocation
Row Column
1 2 3 4 5 6 7 8 9 10 11 12 13
A P2[22]/ VDDA(1V8) P1[28]/ P2[21]/ P2[18]/ P2[14]/ P1[29]/ P2[11]/ P2[10]/ P2[7]/D7 VDD(3V3) VDD(1V8) P2[4]/D4
D22 TDI D21 D18 D14 TCK D11 D10
B VDD(3V3) P1[27]/ XTAL2 VSSA(PLL) P2[19]/ P2[15]/ P2[12]/ P0[20]/ VDD(3V3) P2[6]/D6 VSS P2[3]/D3 VSS
TDO D19 D15 D12 MAT1[3]/
SSEL1/
EINT3
C P0[21]/ VSS XTAL1 VSSA RESET P2[16]/ P2[13]/ P0[19]/ P2[9]/D9 P2[5]/D5 P2[2]/D2 P2[1]/D1 VDD(3V3)
PWM5/ D16 D13 MAT1[2]/
CAP1[3] MOSI1/
CAP1[2]
D P0[24]/ P1[19]/ P0[23]/ P0[22]/ P2[20]/ P2[17]/ VSS P0[18]/ P2[8]/D8 P1[30]/ VSS P1[20]/ P0[17]/
TD2 TRACE RD2 CAP0[0]/ D20 D17 CAP1[3]/ TMS TRACE CAP1[2]/
PKT3 MAT0[0] MISO1/ SYNC SCK1/
MAT1[3] MAT1[2]
Rev. 03 — 2 April 2008
UM10114
© NXP B.V. 2008. All rights reserved.
MAT0[2]
K P3[27]/ P3[26]/ VDD(3V3) P3[22]/ P3[20]/ P0[1]/ P3[14]/ P1[25]/ P3[11]/ VDD(3V3) P0[10]/ VSS P3[4]/A4
WE CS1 A22 A20 RXD0/ A14 EXTIN0 A11 RTS1/
PWM3/ CAP1[0]
91 of 386
EINT0
xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxx x x x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xx xx xxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx x x
xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx xxx
Table 80. LPC22xx Ball allocation …continued
User manual
UM10114_3
NXP Semiconductors
Row Column
1 2 3 4 5 6 7 8 9 10 11 12 13
L P0[29]/ P0[30]/ P1[16]/ P0[0]/ P3[19]/ P0[2]/ P3[15]/ P0[4]/ P3[12]/ VSS P1[24]/ P0[8]/ P0[9]/
AIN2/ AIN3/ TRACE TXD0/ A19 SCL/ A15 SCK0/ A12 TRACE TXD1/ RXD1/
CAP0[3]/ EINT3/ PKT0 PWM1 CAP0[0] CAP0[1] CLK PWM4 PWM6/
MAT0[3] CAP0[0] EINT3
M P3[25]/ P3[24]/ VDD(3V3) P1[31]/ P3[18]/ VDD(3V3) P3[16]/ P0[3]/ P3[13]/ P3[9]/A9 P0[7]/ P3[7]/A7 P3[5]/A5
CS2 CS3 TRST A18 A16 SDA/ A13 SSEL0/
MAT0[0]/ PWM2/
EINT1 EINT2
N VDD(1V8) VSS P3[23]/ P3[21]/ P3[17]/ P1[26]/ VSS VDD(3V3) P0[5]/ P3[10]/ P0[6]/ P3[8]/A8 P3[6]/A6
A23/ A21 A17 RTCK MISO0/ A10 MOSI0/
XCLK MAT0[1] CAP0[2]
Rev. 03 — 2 April 2008
P0[2]/SCL/ 50[3] L6[3] I/O SCL — I2C-bus clock input/output. Open-drain output (for
CAP0[0] I2C-bus compliance).
P0[3]/SDA/ 58[3] M8[3] I/O SDA — I2C-bus data input/output. Open-drain output (for
MAT0[0]/EINT1 I2C-bus compliance).
P0[4]/SCK0/ 59[1] L8[1] I/O SCK0 — Serial clock for SPI0. SPI clock output from master
CAP0[1] or input to slave.
P0[5]/MISO0/ 61[1] N9[1] I/O MISO0 — Master In Slave OUT for SPI0. Data input to SPI
MAT0[1] master or data output from SPI slave.
P0[6]/MOSI0/ 68[1] N11[1] I/O MOSI0 — Master Out Slave In for SPI0. Data output from SPI
CAP0[2] master or data input to SPI slave.
P0[7]/SSEL0/ 69[2] M11[2] I SSEL0 — Slave Select for SPI0. Selects the SPI interface as
PWM2/EINT2 a slave.
P0[12]/DSR1/ 84[1] J13[1] I DSR1 — Data Set Ready input for UART1.
MAT1[0]/RD4
O MAT1[0] — Match output for Timer 1, channel 0.
P0[13]/DTR1/ 85[1] H10[1] O DTR1 — Data Terminal Ready output for UART1.
MAT1[1]/TD4
O MAT1[1] — Match output for Timer 1, channel 1.
P0[14]/DCD1/ 92[2] G10[2] I DCD1 — Data Carrier Detect input for UART1.
EINT1
I EINT1 — External interrupt 1 input.
Note: LOW on this pin while RESET is LOW forces on-chip
bootloader to take over control of the part after reset.
P0[27]/AIN0/ 23[4] H3[4] I AIN0 — ADC, input 0. This analog input is always connected
CAP0[1]/ to its pin.
MAT0[1]
I CAP0[1] — Capture input for Timer 0, channel 1.
P0[28]/AIN1/ 25[4] J1[4] I AIN1 — ADC, input 1. This analog input is always connected
CAP0[2]/ to its pin.
MAT0[2]
I CAP0[2] — Capture input for Timer 0, channel 2.
P0[29]/AIN2/ 32[4] L1[4] I AIN2 — ADC, input 2. This analog input is always connected
CAP0[3]/ to its pin.
MAT0[3]
I CAP0[3] — Capture input for Timer 0, Channel 3.
P0[30]/AIN3/ 33[4] L2[4] I AIN3 — ADC, input 3. This analog input is always connected
EINT3/CAP0[0] to its pin.
P1[0] to P1[31] I/O Port 1: Port 1 is a 32-bit bidirectional I/O port with individual
direction controls for each bit. The operation of port 1 pins
depends upon the pin function selected via the Pin Connect
Block.
Pins 2 through 15 of port 1 are not available.
P1[0]/CS0 91[5] G11[5] O CS0 — LOW-active Chip Select 0 signal.
(Bank 0 addresses range 0x8000 0000 to 0x80FF FFFF)
P1[16]/ 34[5] L3[5] O TRACEPKT0 — Trace Packet, bit 0. Standard I/O port with
TRACEPKT0 internal pull-up.
P1[17]/ 24[5] H4[5] O TRACEPKT1 — Trace Packet, bit 1. Standard I/O port with
TRACEPKT1 internal pull-up.
P1[18]/ 15[5] F2[5] O TRACEPKT2 — Trace Packet, bit 2. Standard I/O port with
TRACEPKT2 internal pull-up.
P1[19]/ 7[5] D2[5] O TRACEPKT3 — Trace Packet, bit 3. Standard I/O port with
TRACEPKT3 internal pull-up.
P1[21]/ 95[5] F11[5] O PIPESTAT0 — Pipeline Status, bit 0. Standard I/O port with
PIPESTAT0 internal pull-up.
P1[22]/ 86[5] H11[5] O PIPESTAT1 — Pipeline Status, bit 1. Standard I/O port with
PIPESTAT1 internal pull-up.
P1[23]/ 82[5] J11[5] O PIPESTAT2 — Pipeline Status, bit 2. Standard I/O port with
PIPESTAT2 internal pull-up.
P1[24]/ 70[5] L11[5] O TRACECLK — Trace Clock. Standard I/O port with internal
TRACECLK pull-up.
P1[25]/EXTIN0 60[5] K8[5] I EXTIN0 — External Trigger Input. Standard I/O with internal
pull-up.
P1[26]/RTCK 52[5] N6[5] I/O RTCK — Returned Test Clock output. Extra signal added to
the JTAG port. Assists debugger synchronization when
processor frequency varies. Bidirectional pin with internal
pull-up.
Note: LOW on this pin while RESET is LOW, enables pins
P1[31:26] to operate as Debug port after reset.
P1[27]/TDO 144[5] B2[5] O TDO — Test Data out for JTAG interface.
P1[29]/TCK 126[5] A7[5] I TCK — Test Clock for JTAG interface. This clock must be
slower than 1⁄6 of the CPU clock (CCLK) for the JTAG
interface to operate.
P1[30]/TMS 113[5] D10[5] I TMS — Test Mode Select for JTAG interface.
P2[0] to P2[31] I/O Port 2 — Port 2 is a 32-bit bidirectional I/O port with individual
direction controls for each bit. The operation of port 2 pins
depends upon the pin function selected via the Pin Connect
Block.
P2[10]/D10 120[5] A9[5] I/O D10 — External memory data line 10.
P2[11]/D11 124[5] A8[5] I/O D11 — External memory data line 11.
P2[12]/D12 125[5] B7[5] I/O D12 — External memory data line 12.
P2[13]/D13 127[5] C7[5] I/O D13 — External memory data line 13.
P2[14]/D14 129[5] A6[5] I/O D14 — External memory data line 14.
P2[15]/D15 130[5] B6[5] I/O D15 — External memory data line 15.
P2[16]/D16 131[5] C6[5] I/O D16 — External memory data line 16.
P2[17]/D17 132[5] D6[5] I/O D17 — External memory data line 17.
P2[18]/D18 133[5] A5[5] I/O D18 — External memory data line 18.
P2[19]/D19 134[5] B5[5] I/O D19 — External memory data line 19.
P2[20]/D20 136[5] D5[5] I/O D20 — External memory data line 20.
P2[21]/D21 137[5] A4[5] I/O D21 — External memory data line 21.
P2[22]/D22 1[5] A1[5] I/O D22 — External memory data line 22.
P2[23]/D23 10[5] E3[5] I/O D23 — External memory data line 23.
P2[24]/D24 11[5] E2[5] I/O D24 — External memory data line 24.
P2[25]/D25 12[5] E1[5] I/O D25 — External memory data line 25.
P2[26]/D26/ 13[5] F4[5] I/O D26 — External memory data line 26.
BOOT0
I BOOT0 — While RESET is low, together with BOOT1
controls booting and internal operation. Internal pull-up
ensures high state if pin is left unconnected.
P2[28]/D28 17[5] G2[5] I/O D28 — External memory data line 28.
P2[29]/D29 18[5] G1[5] I/O D29 — External memory data line 29.
P2[30]/D30/ 19[4] G3[2] I/O D30 — External memory data line 30.
AIN4
I AIN4 — ADC, input 4. This analog input is always connected
to its pin.
P2[31]/D31/ 20[4] G4[2] I/O D31 — External memory data line 31.
AIN5
I AIN5 — ADC, input 5. This analog input is always connected
to its pin.
P3[0] to P3[31] I/O Port 3 — Port 3 is a 32-bit bidirectional I/O port with individual
direction controls for each bit. The operation of port 3 pins
depends upon the pin function selected via the Pin Connect
Block.
P3[23]/A23/ 40[5] N3[5] I/O A23 — External memory address line 23.
XCLK
O XCLK — Clock output.
P3[28]/BLS3/ 28[4] J4[4] O BLS3 — LOW-active Byte Lane Select signal (Bank 3).
AIN7
I AIN7 — ADC, input 7. This analog input is always connected
to its pin.
P3[29]/BLS2/ 27[4] J3[4] O BLS2 — LOW-active Byte Lane Select signal (Bank 2).
AIN6
I AIN6 — ADC, input 6. This analog input is always connected
to its pin.
P3[30]/BLS1 97[4] E13[4] O BLS1 — LOW-active Byte Lane Select signal (Bank 1).
P3[31]/BLS0 96[4] F10[4] O BLS0 — LOW-active Byte Lane Select signal (Bank 0).
[1] 5 V tolerant pad providing digital I/O functions with TTL levels and hysteresis and 10 ns slew rate control.
[2] 5 V tolerant pad providing digital I/O functions with TTL levels and hysteresis and 10 ns slew rate control. If configured for an input
function, this pad utilizes built-in glitch filter that blocks pulses shorter than 3 ns.
[3] Open drain 5 V tolerant digital I/O I2C-bus 400 kHz specification compatible pad. It requires external pull-up to provide an output
functionality. Open-drain functionality applies to all output functions on this pin.
[4] 5 V tolerant pad providing digital I/O (with TTL levels and hysteresis and 10 ns slew rate control) and analog input function. If configured
for a digital input function, this pad utilizes built-in glitch filter that blocks pulses shorter than 3 ns. When configured as an ADC input,
digital section of the pad is disabled.
[5] 5 V tolerant pad with built-in pull-up resistor providing digital I/O functions with TTL levels and hysteresis and 10 ns slew rate control.
The pull-up resistor’s value ranges from 60 kΩ to 300 kΩ.
[6] 5 V tolerant pad providing digital input (with TTL levels and hysteresis) function only.
[7] Pad provides special analog functionality.
[1] The TD1 output, if available, is not shared with other pins.
Table 83. Pin select registers for 64-pin (LPC21xx) and 144-pin (LPC22xx) configurations
Parts PINSEL0 PINSEL1 PINSEL2 Boot control
all LPC21xx Table 8–86 Table 8–87 Table 8–88 n/a
all LPC22xx Table 8–86 Table 8–87 Table 8–89 Table 8–90
For an overview of how LPC21xx and LPC22xx parts and versions are described in this
manual, see Section 1–2 “How to read this manual”.
2. Features
Allows individual pin configuration.
3. Applications
The purpose of the Pin connect block is to configure the microcontroller pins to the
desired functions.
UM10114_3 © NXP B.V. 2008. All rights reserved.
4. Description
The pin connect block allows selected pins of the microcontroller to have more than one
function. Configuration registers control the multiplexers to allow connection between the
pin and the on chip peripherals.
Peripherals should be connected to the appropriate pins prior to being activated, and prior
to any related interrupt(s) being enabled. Activity of any enabled peripheral function that is
not mapped to a related pin should be considered undefined.
Selection of a single function on a port pin completely excludes all other functions
otherwise available on the same pin.
The only exception are the inputs to the A/D converter. Regardless of the function that is
selected for the port pin that also hosts the A/D input, this A/D input can be read at any
time, and variations of the voltage level on this pin will be reflected in the A/D readings.
However, valid analog reading(s) can be obtained if and only if the analog input function is
selected. Only then the proper interface circuit is active in between the physical pin and
the A/D module. In all other cases, the logic necessary for the digital function will be active
and will disrupt proper behavior of the A/D.
The direction control bit in the IO0DIR/IO1DIR register is effective only when the GPIO
function is selected for a pin. For other functions, direction is controlled automatically.
Each derivative typically has a different pinout and therefore a different set of functions
possible for each pin. Details for a specific derivative may be found in the appropriate data
sheet.
6. Register description
The Pin Control Module contains 3 registers as shown in Table 8–85 below.
The CAN bit settings are reserved for parts without CAN interfaces (see Table 8–82).
Table 86. Pin function Select register 0 (PINSEL0 - address 0xE002 C000) bit description )
Bit Symbol Value Function Reset value
1:0 P0.0 00 GPIO Port 0.0 0
01 TXD (UART0)
10 PWM1
11 Reserved
3:2 P0.1 00 GPIO Port 0.1 0
01 RxD (UART0)
10 PWM3
11 EINT0
5:4 P0.2[1] 00 GPIO Port 0.2 0
01 SCL (I2C)
10 Capture 0.0 (Timer 0)
11 Reserved
7:6 P0.3[1] 00 GPIO Port 0.3 0
01 SDA (I2C)
10 Match 0.0 (Timer 0)
11 EINT1
9:8 P0.4 00 GPIO Port 0.4 0
01 SCK0 (SPI0)
10 Capture 0.1 (Timer 0)
11 Reserved
11:10 P0.5 00 GPIO Port 0.5 0
01 MISO0 (SPI0)
10 Match 0.1 (Timer 0)
11 Reserved
Table 86. Pin function Select register 0 (PINSEL0 - address 0xE002 C000) bit description )
Bit Symbol Value Function Reset value
13:12 P0.6 00 GPIO Port 0.6 0
01 MOSI0 (SPI0)
10 Capture 0.2 (Timer 0)
11 Reserved
15:14 P0.7 00 GPIO Port 0.7 0
01 SSEL0 (SPI0)
10 PWM2
11 EINT2
17:16 P0.8 00 GPIO Port 0.8 0
01 TXD UART1
10 PWM4
11 Reserved
19:18 P0.9 00 GPIO Port 0.9 0
01 RxD (UART1)
10 PWM6
11 EINT3
21:20 P0.10 00 GPIO Port 0.10 0
01 RTS1 (UART1)
10 Capture 1.0 (Timer 1)
11 Reserved
23:22 P0.11 00 GPIO Port 0.11 0
01 CTS1 (UART1)
10 Capture 1.1 (Timer 1)
11 Reserved
25:24 P0.12 00 GPIO Port 0.12 0
01 DSR1 (UART1)
10 Match 1.0 (Timer 1)
11 RD4 (CAN 4)
27:26 P0.13 00 GPIO Port 0.13 0
01 DTR1 (UART1)
10 Match 1.1 (Timer 1)
11 TD4 (CAN 4)
29:28 P0.14 00 GPIO Port 0.14 0
01 DCD1 (UART1)
10 EINT1
11 Reserved
31:30 P0.15 00 GPIO Port 0.15 0
01 RI1 (UART1)
10 EINT2
11 Reserved
[1] All functions on this pin are open-drain outputs for I2C-bus compliance.
UM10114_3 © NXP B.V. 2008. All rights reserved.
The CAN bit settings are reserved for parts without CAN interfaces (see Table 8–82).
Table 87. Pin function Select register 1 (PINSEL1 - address 0xE002 C004) bit description
Bit Symbol Value Function Reset value
1:0 P0.16 00 GPIO Port 0.16 0
01 EINT0
10 Match 0.2 (Timer 0)
11 Capture 0.2 (Timer 0)
3:2 P0.17 00 GPIO Port 0.17 0
01 Capture 1.2 (Timer 1)
10 SCK1 (SSP)
11 Match 1.2 (Timer 1)
5:4 P0.18 00 GPIO Port 0.18 0
01 Capture 1.3 (Timer 1)
10 MISO1 (SSP)
11 Match 1.3 (Timer 1)
7:6 P0.19 00 GPIO Port 0.19 0
01 Match 1.2 (Timer 1)
10 MOSI1 (SSP)
11 Capture 1.2 (Timer 1)
9:8 P0.20 00 GPIO Port 0.20 0
01 Match 1.3 (Timer 1)
10 SSEL1 (SSP)
11 EINT3
11:10 P0.21 00 GPIO Port 0.21 0
01 PWM5
10 RD3 (CAN 3)
11 Capture 1.3 (Timer 1)
13:12 P0.22 00 GPIO Port 0.22 0
01 TD3 (CAN 3)
10 Capture 0.0 (Timer 0)
11 Match 0.0 (Timer 0)
15:14 P0.23 00 GPIO Port 0.23 0
01 RD2 (CAN2)
10 Reserved
11 Reserved
Table 87. Pin function Select register 1 (PINSEL1 - address 0xE002 C004) bit description
Bit Symbol Value Function Reset value
17:16 P0.24 00 GPIO Port 0.24 0
01 TD2 (CAN2)
10 Reserved
11 Reserved
19:18 P0.25 00 GPIO Port 0.25 0
01 RD1 (CAN1)
10 Reserved
11 Reserved
21:20 P0.26 00 Reserved 0
01 Reserved
10 Reserved
11 Reserved
23:22 P0.27 00 GPIO Port 0.27 01
01 AIN0
10 CAP0.1 (Timer 0)
11 MAT0.1 (Timer 0)
25:24 P0.28 00 GPIO Port 0.28 01
01 AIN1
10 Capture 0.2 (Timer 0)
11 Match 0.2 (Timer 0)
27:26 P0.29 00 GPIO Port 0.29 01
01 AIN2
10 Capture 0.3 (Timer 0)
11 Match 0.3 (Timer 0)
29:28 P0.30 00 GPIO Port 0.30 01
01 AIN3
10 EINT3
11 Capture 0.0 (Timer 0)
31:30 P0.31 00 Reserved 0
01 Reserved
10 Reserved
11 Reserved
Table 88. Pin function Select register 2 (PINSEL2 - 0xE002 C014) bit description
Bit Symbol Value Function Reset value
1:0 - - Reserved, user software should not write ones NA
to reserved bits. The value read from a reserved
bit is not defined.
2 GPIO/DEBUG 0 Pins P1.36-26 are used as GPIO pins. P1.26/RTCK
1 Pins P1.36-26 are used as a Debug port.
3 GPIO/TRACE 0 Pins P1.25-16 are used as GPIO pins. P1.20/
TRACESYNC
1 Pins P1.25-16 are used as a Trace port.
31:4 - - Reserved, user software should not write ones NA
to reserved bits. The value read from a reserved
bit is not defined.
Table 89. Pin function Select register 2 (PINSEL2 - 0xE002 C014) bit description
Bit Symbol Value Function Value after
reset
1:0 - NA Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
2 GPIO/ Controls the use of P1.31-26 pins.
DEBUG 0 Pins P1.31-26 are used as GPIO pins. P1.26/RTCK
1 Pins P1.31-26 are used as a Debug port.
3 GPIO/ Controls the use of P1.25-16 pins. P1.20/
TRACE 0 Pins P1.25-16 are used as GPIO pins. TRACESYNC
Table 89. Pin function Select register 2 (PINSEL2 - 0xE002 C014) bit description
Bit Symbol Value Function Value after
reset
5:4 CTRLDBP Controls the use of the data bus and strobe pins. At a reset triggered via the BOOT1:0 or
RESET pin, these bits are loaded with the content from lines BOOT1:0; if a BOOT10_SAVE
watchdog reset occurs, these two bits are loaded with the BOOT10_SAVE
register content (see Section 8–6.5 “Boot control for LPC22xx parts” on page
110).
Functions available based on PINSEL2[5:4] values
Pins 10 01 00 11
P1.1 OE P1.1
P2.7:0 D7:0 P2.7:0
P2.15:8 D15:8 P2.15:8
P2.27:16 D27:16 P2.27:16
P2.29:28 D29:28 P2.29:28 or reserved (see bit 20)
P2.30 D30 P2.30 or AIN4 (see bit 21)
P2.31 D31 P2.31 or AIN5 (see bit 22)
P1.0 CS0 P1.0
P3.31 BLS0 P3.31
P3.30 BLS1 P3.30
P3.28 BLS2 P3.28 or AIN7 (see bit 7)
P3.29 BLS3 P3.29 or AIN6 (see bit 6)
6 CTRLP329 If bits 5:4 are not 10, controls the use of pin P3.29: 1
0 P3.29 is a GPIO pin.
1 P3.29 is an ADC input pin (AIN6).
7 CTRLP328 If bits 5:4 are not 10, controls the use of pin P3.28: 1
0 P3.28 is a GPIO pin.
1 P3.28 is an ADC input pin (AIN7).
8 CTRLP327 Controls the use of pin P3.27: 0
0 P3.27 is a GPIO pin.
1 P3.27 is a Write Enable pin (WE).
10:9 - Reserved -
11 CTRLP326 Controls the use of pin P3.26: 0
0 P3.26 is a GPIO pin.
1 P3.26 is a chip/memory bank select pin (CS1).
12 - NA Reserved -
13 CTRLP323 If bits 25:23 are not 111, controls the use of pin P3.23/A23/XCLK: 0
0 P3.23 is a GPIO/address line pin (see bits 27:25).
1 P3.23 is XCLK output pin.
Table 89. Pin function Select register 2 (PINSEL2 - 0xE002 C014) bit description
Bit Symbol Value Function Value after
reset
15:14 CTRLP325 Controls the use of pin P3.25: 00
00 P3.25 is a GPIO pin.
01 P3.25 is a chip/memory bank select pin (CS2).
10 Reserved
11 Reserved
17:16 CTRLP324 Controls the use of pin P3.24: 00
00 P3.24 is a GPIO pin.
01 P3.24 is a chip/memory bank select pin (CS3).
10 Reserved
11 Reserved
19:18 - NA Reserved -
20 CTRLP229_28 If bits PINSEL2[5:4] are not 10, controls the use of pin P2.29:28: 0
0 P2.29 and P2.28 are GPIO pins.
1 Reserved
21 CTRLP230 If bits PINSEL2[5:4] are not 10, controls the use of pin P2.30: 1
0 P2.30 is a GPIO pin.
1 P2.30 is an ADC input pin (AIN4).
22 CTRLP231 If bits PINSEL2[5:4] are not 10, controls the use of pin P2.31: 1
0 P2.31 is a GPIO pin.
1 P2.31 is an ADC input pin (AIN5).
23 CTRLP300 Controls the use of pin P3.0: 1 if
0 P3.0/A0 is a GPIO pin. BOOT1:0 = 00
at RESET = 0,
1 P3.0/A0 is an address line. 0 otherwise
24 CTRLP301 Controls the use of pin P3.1: BOOT1 during
0 3.1/A1 is a GPIO pin. Reset
[1] See Section 4–6 on how to connect external memory to the LPC22xx.
When the LPC22xx hardware detects a rising edge on the Reset pin, it latches content
from BOOT[1:0] pins and stores it into bits 5 and 4 of the BOOT10_SAVE register
(0x3FFF 8030). Once this register is written, it is accessible for reading only.
Whenever the bootloader is executed, it reads the content of the BOOT10_SAVE register,
and configures the PINSEL2 (address and data bus structure) together with other
resources. For the bootloader flowchart details, see Figure 21–73 for parts with flash and
Figure 22–76 for flashless parts.
Not all pins are available on port 0 and port 1. The respective bits in the GPIO registers
are reserved.
For an overview of how LPC21xx and LPC22xx parts and versions are described in this
manual, see Section 1–2 “How to read this manual”.
2. Features
• Every physical GPIO port can be accessed either through registers providing
enhanced features and accelerated port access or through legacy registers providing
backward compatibility to earlier LPC2000 devices.
• Accelerated Fast GPIO functions (see Table 9–91):
– GPIO registers are relocated to the ARM local bus so that the fastest possible I/O
timing can be achieved.
– Mask registers allow treating sets of port bits as a group, leaving other bits
unchanged.
– All registers are byte, half-word, and word addressable.
– The entire port value can be written in one instruction.
• Bit-level set and clear registers allow a single instruction set or clear of any number of
bits in one port.
• Direction of each pin can be controlled individually.
• All I/O default to inputs after reset.
UM10114_3 © NXP B.V. 2008. All rights reserved.
• Backward compatibility with other earlier devices is maintained with legacy registers
appearing at the original addresses on the APB bus.
3. Applications
• General purpose I/O
• Driving LEDs, or other indicators
• Controlling off-chip devices
• Sensing digital inputs
4. Pin description
Table 92. GPIO pin description
Pin Type Description
P031:0] Input/ General purpose input/output. The number of GPIOs actually
P1[31:0] Output available depends on the use of alternate functions.
P2[31:0] Input/ External bus data/address lines shared with GPIO, digital and
P3[31:0] Output analog functions. The number of GPIOs/digital and analog
functions available depends on the selected bus structure.
5. Register description
LPC21xx/LPC22xx devices have two 32-bit General Purpose I/O ports. PORT0 and
PORT1 are controlled by two groups of 4 registers as shown in Table 9–93 and
Table 9–94. LPC22xx devices have two additional 32-bit ports, PORT2 and PORT3.
These ports can be configured either as external memory data address and data bus or as
GPIOs sharing pins with a handful of digital and analog functions. Details on PORT2 and
PORT3 usage can be found in Section 8–6.4.
Legacy registers shown in Table 9–93 allow backward compatibility with earlier family
devices, using existing code. The functions and relative timing of older GPIO
implementations is preserved.
The registers in Table 9–94 represent the enhanced Fast GPIO features available on the
PORT0 and PORT1 only. All of these registers are located directly on the local bus of the
CPU for the fastest possible read and write timing. An additional feature has been added
that provides byte and half-word addressability of all GPIO registers. A mask register
allows treating groups of bits in a single GPIO port separately from other bits on the same
port.
When PORT0 and/or PORT1 are used, the user must select whether a these ports will be
accessed via registers that provide enhanced features or a legacy set of registers (see
Section 6–7.1). While both of a port’s fast and legacy GPIO registers are controlling the
same physical pins, these two port control branches are mutually exclusive and operate
independently. For example, changing a pin’s output through a fast register will not be
observable trough the corresponding legacy register.
The following text will refer to the legacy GPIO as "the slow" GPIO, while GPIO equipped
with the enhanced features will be referred as "the fast" GPIO.
The "slow", legacy registers are word accessible only. The “fast” GPIO registers are byte,
half-word, and word accessible.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
Table 94. GPIO register map (local bus accessible registers - enhanced GPIO features)
Generic Description Access Reset PORT0 PORT1
Name value[1] Address & Name Address & Name
FIODIR Fast GPIO Port Direction control register. R/W 0x0000 0000 0x3FFF C000 0x3FFF C020
This register individually controls the FIO0DIR FIO1DIR
direction of each port pin.
FIOMASK Fast Mask register for port. Writes, sets, R/W 0x0000 0000 0x3FFF C010 0x3FFF C030
clears, and reads to port (done via writes to FIO0MASK FIO1MASK
FIOPIN, FIOSET, and FIOCLR, and reads of
FIOPIN). Only the bits enabled by zeroes in
this register are altered or cleared.
Table 94. GPIO register map (local bus accessible registers - enhanced GPIO features)
Generic Description Access Reset PORT0 PORT1
Name value[1] Address & Name Address & Name
FIOPIN Fast Port Pin value register using FIOMASK. R/W 0x0000 0000 0x3FFF C014 0x3FFF C034
The current state of digital port pins can be FIO0PIN FIO1PIN
read from this register, regardless of pin
direction or alternate function selection (as
long as pins is not configured as an input to
ADC). The value read is masked by ANDing
with FIOMASK. Writing to this register
places corresponding values in all bits
enabled by zeroes in FIOMASK.
FIOSET Fast Port Output Set register using R/W 0x0000 0000 0x3FFF C018 0x3FFF C038
FIOMASK. This register controls the state of FIO0SET FIO1SET
output pins. Writing 1s produces highs at the
corresponding port pins. Writing 0s has no
effect. Reading this register returns the
current contents of the port output register.
Only bits enabled by zeroes in FIOMASK
can be altered.
FIOCLR Fast Port Output Clear register using WO 0x0000 0000 0x3FFF C01C 0x3FFF C03C
FIOMASK0. This register controls the state FIO0CLR FIO1CLR
of output pins. Writing 1s produces lows at
the corresponding port pins. Writing 0s has
no effect. Only bits enabled by zeroes in
FIOMASK can be altered.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
5.1 GPIO port Direction register IODIR (IO0DIR - 0xE002 8008, IO1DIR -
0xE002 8018, IO2DIR - 0xE002 8028, IO3DIR - 0xE002 8038, FIO0DIR -
0x3FFF C000, FIO1DIR - 0x3FFF C020)
This word accessible register is used to control the direction of the pins when they are
configured as GPIO port pins. Direction bit for any pin must be set according to the pin
functionality.
Legacy registers are the IO0DIR, IO1DIR, IO2DIR and IO3DIR while the enhanced GPIO
functions are supported via the FIO0DIR and FIO1DIR registers.
Table 95. GPIO port 0 Direction register (IO0DIR - address 0xE002 8008) bit description
Bit Symbol Value Description Reset value
31:0 P0xDIR Slow GPIO Direction control bits. Bit 0 controls P0.0 ... bit 31 controls P0.31. 0x0000 0000
0 Controlled pin is input.
1 Controlled pin is output.
Table 96. GPIO port 1 Direction register (IO1DIR - address 0xE002 8018) bit description
Bit Symbol Value Description Reset value
31:0 P1xDIR Slow GPIO Direction control bits. Bit 0 in IO1DIR controls P1.0 ... Bit 31 in 0x0000 0000
IO1DIR controls P1.31.
0 Controlled pin is input.
1 Controlled pin is output.
Table 97. GPIO port 2 Direction register (IO2DIR - address 0xE002 8028) bit description
Bit Symbol Value Description Reset value
31:0 P2xDIR Slow GPIO Direction control bits. Bit 0 in IO2DIR controls P2.0 ... Bit 31 in 0x0000 0000
IO2DIR controls P2.31.
0 Controlled pin is input.
1 Controlled pin is output.
Table 98. GPIO port 3 Direction register (IO3DIR - address 0xE002 8038) bit description
Bit Symbol Value Description Reset value
31:0 P3xDIR Slow GPIO Direction control bits. Bit 0 in IO3DIR controls P3.0 ... Bit 31 in 0x0000 0000
IO3DIR controls P3.31.
0 Controlled pin is input.
1 Controlled pin is output.
Table 99. Fast GPIO port 0 Direction register (FIO0DIR - address 0x3FFF C000) bit description
Bit Symbol Value Description Reset value
31:0 FP0xDIR Fast GPIO Direction control bits. Bit 0 in FIO0DIR controls P0.0 ... Bit 31 in 0x0000 0000
FIO0DIR controls P0.31.
0 Controlled pin is input.
1 Controlled pin is output.
Table 100. Fast GPIO port 1 Direction register (FIO1DIR - address 0x3FFF C020) bit description
Bit Symbol Value Description Reset value
31:0 FP1xDIR Fast GPIO Direction control bits. Bit 0 in FIO1DIR controls P1.0 ... Bit 31 in 0x0000 0000
FIO1DIR controls P1.31.
0 Controlled pin is input.
1 Controlled pin is output.
In addition to the 32-bit long and word only accessible FIODIR register, every fast GPIO
port can also be controlled via several byte and half-word accessible registers listed in
Table 9–101 and Table 9–102. Next to providing the same functions as the FIODIR
register, these additional registers allow easier and faster access to the physical port pins.
Table 101. Fast GPIO port 0 Direction control byte and half-word accessible register description
Register Register Address Description Reset
name length (bits) value
& access
FIO0DIR0 8 (byte) 0x3FFF C000 Fast GPIO Port 0 Direction control register 0. Bit 0 in FIO0DIR0 0x00
register corresponds to P0.0 ... bit 7 to P0.7.
FIO0DIR1 8 (byte) 0x3FFF C001 Fast GPIO Port 0 Direction control register 1. Bit 0 in FIO0DIR1 0x00
register corresponds to P0.8 ... bit 7 to P0.15.
FIO0DIR2 8 (byte) 0x3FFF C002 Fast GPIO Port 0 Direction control register 2. Bit 0 in FIO0DIR2 0x00
register corresponds to P0.16 ... bit 7 to P0.23.
Table 101. Fast GPIO port 0 Direction control byte and half-word accessible register description
Register Register Address Description Reset
name length (bits) value
& access
FIO0DIR3 8 (byte) 0x3FFF C003 Fast GPIO Port 0 Direction control register 3. Bit 0 in FIO0DIR3 0x00
register corresponds to P0.24 ... bit 7 to P0.31.
FIO0DIRL 16 0x3FFF C000 Fast GPIO Port 0 Direction control Lower half-word register. Bit 0 in 0x0000
(half-word) FIO0DIRL register corresponds to P0.0 ... bit 15 to P0.15.
FIO0DIRU 16 0x3FFF C002 Fast GPIO Port 0 Direction control Upper half-word register. Bit 0 in 0x0000
(half-word) FIO0DIRU register corresponds to P0.16 ... bit 15 to P0.31.
Table 102. Fast GPIO port 1 Direction control byte and half-word accessible register description
Register Register Address Description Reset
name length (bits) value
& access
FIO1DIR0 8 (byte) 0x3FFF C020 Fast GPIO Port 1 Direction control register 0. Bit 0 in FIO1DIR0 0x00
register corresponds to P1.0 ... bit 7 to P1.7.
FIO1DIR1 8 (byte) 0x3FFF C021 Fast GPIO Port 1 Direction control register 1. Bit 0 in FIO1DIR1 0x00
register corresponds to P1.8 ... bit 7 to P1.15.
FIO1DIR2 8 (byte) 0x3FFF C022 Fast GPIO Port 1 Direction control register 2. Bit 0 in FIO1DIR2 0x00
register corresponds to P1.16 ... bit 7 to P1.23.
FIO1DIR3 8 (byte) 0x3FFF C023 Fast GPIO Port 1 Direction control register 3. Bit 0 in FIO1DIR3 0x00
register corresponds to P1.24 ... bit 7 to P1.31.
FIO1DIRL 16 0x3FFF C020 Fast GPIO Port 1 Direction control Lower half-word register. Bit 0 in 0x0000
(half-word) FIO1DIRL register corresponds to P1.0 ... bit 15 to P1.15.
FIO1DIRU 16 0x3FFF C022 Fast GPIO Port 1 Direction control Upper half-word register. Bit 0 in 0x0000
(half-word) FIO1DIRU register corresponds to P1.16 ... bit 15 to P1.31.
5.2 GPIO port output Set register IOSET (IO0SET - 0xE002 8004, IO1SET -
0xE002 8014, IO2SET - 0xE002 8024, IO3SET - 0xE002 8034, FIO0SET
- 0x3FFF C018, FIO1SET - 0x3FFF C038)
This register is used to produce a HIGH level output at the port pins configured as GPIO in
an OUTPUT mode. Writing 1 produces a HIGH level at the corresponding port pins.
Writing 0 has no effect. If any pin is configured as an input or a secondary function, writing
1 to the corresponding bit in the IOSET has no effect.
Reading the IOSET register returns the value of this register, as determined by previous
writes to IOSET and IOCLR (or IOPIN as noted above). This value does not reflect the
effect of any outside world influence on the I/O pins.
Legacy registers are the IO0SET, IO1SET, IO2SET and IO3SET while the enhanced
GPIOs are supported via the FIO0SET and FIO1SET registers. Access to a port pins via
the FIOSET register is conditioned by the corresponding FIOMASK register (see Section
9–5.5 “Fast GPIO port Mask register FIOMASK(FIO0MASK - 0x3FFF C010, FIO1MASK -
0x3FFF C030)”).
Table 103. GPIO port 0 output Set register (IO0SET - address 0xE002 8004 bit description
Bit Symbol Description Reset value
31:0 P0xSET Slow GPIO output value Set bits. Bit 0 in IO0SET corresponds to P0.0 ... Bit 31 0x0000 0000
in IO0SET corresponds to P0.31.
Table 104. GPIO port 1 output Set register (IO1SET - address 0xE002 8014) bit description
Bit Symbol Description Reset value
31:0 P1xSET Slow GPIO output value Set bits. Bit 0 in IO1SET corresponds to P1.0 ... Bit 31 0x0000 0000
in IO1SET corresponds to P1.31.
Table 105. GPIO port 2 output Set register (IO2SET - address 0xE002 8024) bit description
Bit Symbol Description Reset value
31:0 P2xSET Slow GPIO output value Set bits. Bit 0 in IO2SET corresponds to P2.0 ... Bit 31 0x0000 0000
in IO2SET corresponds to P2.31.
Table 106. GPIO port 3 output Set register (IO3SET - address 0xE002 8034) bit description
Bit Symbol Description Reset value
31:0 P3xSET Slow GPIO output value Set bits. Bit 0 in IO3SET corresponds to P3.0 ... Bit 31 0x0000 0000
in IO3SET corresponds to P3.31.
Table 107. Fast GPIO port 0 output Set register (FIO0SET - address 0x3FFF C018) bit description
Bit Symbol Description Reset value
31:0 FP0xSET Fast GPIO output value Set bits. Bit 0 in FIO0SET corresponds to P0.0 ... Bit 31 0x0000 0000
in FIO0SET corresponds to P0.31.
Table 108. Fast GPIO port 1 output Set register (FIO1SET - address 0x3FFF C038) bit description
Bit Symbol Description Reset value
31:0 FP1xSET Fast GPIO output value Set bits. Bit 0 in FIO1SET corresponds to P1.0 ... Bit 0x0000 0000
31 in FIO1SET corresponds to P1.31.
Aside from the 32-bit long and word only accessible FIOSET register, every fast GPIO
port can also be controlled via several byte and half-word accessible registers listed in
Table 9–109 and Table 9–110. Next to providing the same functions as the FIOSET
register, these additional registers allow easier and faster access to the physical port pins.
Table 109. Fast GPIO port 0 output Set byte and half-word accessible register description
Register Register Address Description Reset
name length (bits) value
& access
FIO0SET0 8 (byte) 0x3FFF C018 Fast GPIO Port 0 output Set register 0. Bit 0 in FIO0SET0 register 0x00
corresponds to P0.0 ... bit 7 to P0.7.
FIO0SET1 8 (byte) 0x3FFF C019 Fast GPIO Port 0 output Set register 1. Bit 0 in FIO0SET1 register 0x00
corresponds to P0.8 ... bit 7 to P0.15.
FIO0SET2 8 (byte) 0x3FFF C01A Fast GPIO Port 0 output Set register 2. Bit 0 in FIO0SET2 register 0x00
corresponds to P0.16 ... bit 7 to P0.23.
FIO0SET3 8 (byte) 0x3FFF C01B Fast GPIO Port 0 output Set register 3. Bit 0 in FIO0SET3 register 0x00
corresponds to P0.24 ... bit 7 to P0.31.
FIO0SETL 16 0x3FFF C018 Fast GPIO Port 0 output Set Lower half-word register. Bit 0 in 0x0000
(half-word) FIO0SETL register corresponds to P0.0 ... bit 15 to P0.15.
FIO0SETU 16 0x3FFF C01A Fast GPIO Port 0 output Set Upper half-word register. Bit 0 in 0x0000
(half-word) FIO0SETU register corresponds to P0.16 ... bit 15 to P0.31.
Table 110. Fast GPIO port 1 output Set byte and half-word accessible register description
Register Register Address Description Reset
name length (bits) value
& access
FIO1SET0 8 (byte) 0x3FFF C038 Fast GPIO Port 1 output Set register 0. Bit 0 in FIO1SET0 register 0x00
corresponds to P1.0 ... bit 7 to P1.7.
FIO1SET1 8 (byte) 0x3FFF C039 Fast GPIO Port 1 output Set register 1. Bit 0 in FIO1SET1 register 0x00
corresponds to P1.8 ... bit 7 to P1.15.
FIO1SET2 8 (byte) 0x3FFF C03A Fast GPIO Port 1 output Set register 2. Bit 0 in FIO1SET2 register 0x00
corresponds to P1.16 ... bit 7 to P1.23.
FIO1SET3 8 (byte) 0x3FFF C03B Fast GPIO Port 1 output Set register 3. Bit 0 in FIO1SET3 register 0x00
corresponds to P1.24 ... bit 7 to P1.31.
FIO1SETL 16 0x3FFF C038 Fast GPIO Port 1 output Set Lower half-word register. Bit 0 in 0x0000
(half-word) FIO1SETL register corresponds to P1.0 ... bit 15 to P1.15.
FIO1SETU 16 0x3FFF C03A Fast GPIO Port 1 output Set Upper half-word register. Bit 0 in 0x0000
(half-word) FIO1SETU register corresponds to P1.16 ... bit 15 to P1.31.
5.3 GPIO port output Clear register IOCLR (IO0CLR - 0xE002 800C,
IO1CLR - 0xE002 801C, IO2CLR - 0xE002 802C, IO3CLR -
0xE002 803C, FIO0CLR - 0x3FFF C01C, FIO1CLR - 0x3FFF C03C)
This register is used to produce a LOW level output at port pins configured as GPIO in an
OUTPUT mode. Writing 1 produces a LOW level at the corresponding port pin and clears
the corresponding bit in the IOSET register. Writing 0 has no effect. If any pin is configured
as an input or a secondary function, writing to IOCLR has no effect.
Legacy registers are the IO0CLR, IO1CLR, IO2CLR and IO3CLR while the enhanced
GPIOs are supported via the FIO0CLR and FIO1CLR registers. Access to a port pins via
the FIOCLR register is conditioned by the corresponding FIOMASK register (see Section
9–5.5 “Fast GPIO port Mask register FIOMASK(FIO0MASK - 0x3FFF C010, FIO1MASK -
0x3FFF C030)”).
Table 111. GPIO port 0 output Clear register 0 (IO0CLR - address 0xE002 800C) bit description
Bit Symbol Description Reset value
31:0 P0xCLR Slow GPIO output value Clear bits. Bit 0 in IO0CLR corresponds to P0.0 ... Bit 0x0000 0000
31 in IO0CLR corresponds to P0.31.
Table 112. GPIO port 1 output Clear register 1 (IO1CLR - address 0xE002 801C) bit description
Bit Symbol Description Reset value
31:0 P1xCLR Slow GPIO output value Clear bits. Bit 0 in IO1CLR corresponds to P1.0 ... Bit 0x0000 0000
31 in IO1CLR corresponds to P1.31.
Table 113. GPIO port 2 output Clear register 2 (IO2CLR - address 0xE002 802C) bit description
Bit Symbol Description Reset value
31:0 P2xCLR Slow GPIO output value Clear bits. Bit 0 in IO2CLR corresponds to P1.0 ... Bit 0x0000 0000
31 in IO2CLR corresponds to P2.31.
Table 114. GPIO port 3 output Clear register 3 (IO3CLR - address 0xE002 803C) bit description
Bit Symbol Description Reset value
31:0 P3xCLR Slow GPIO output value Clear bits. Bit 0 in IO3CLR corresponds to P1.0 ... Bit 0x0000 0000
31 in IO3CLR corresponds to P2.31.
Table 115. Fast GPIO port 0 output Clear register 0 (FIO0CLR - address 0x3FFF C01C) bit description
Bit Symbol Description Reset value
31:0 FP0xCLR Fast GPIO output value Clear bits. Bit 0 in FIO0CLR corresponds to P0.0 ... Bit 0x0000 0000
31 in FIO0CLR corresponds to P0.31.
Table 116. Fast GPIO port 1 output Clear register 1 (FIO1CLR - address 0x3FFF C03C) bit description
Bit Symbol Description Reset value
31:0 FP1xCLR Fast GPIO output value Clear bits. Bit 0 in FIO1CLR corresponds to P1.0 ... Bit 0x0000 0000
31 in FIO1CLR corresponds to P1.31.
Aside from the 32-bit long and word only accessible FIOCLR register, every fast GPIO
port can also be controlled via several byte and half-word accessible registers listed in
Table 9–117 and Table 9–118. Next to providing the same functions as the FIOCLR
register, these additional registers allow easier and faster access to the physical port pins.
Table 117. Fast GPIO port 0 output Clear byte and half-word accessible register description
Register Register Address Description Reset
name length (bits) value
& access
FIO0CLR0 8 (byte) 0x3FFF C01C Fast GPIO Port 0 output Clear register 0. Bit 0 in FIO0CLR0 register 0x00
corresponds to P0.0 ... bit 7 to P0.7.
FIO0CLR1 8 (byte) 0x3FFF C01D Fast GPIO Port 0 output Clear register 1. Bit 0 in FIO0CLR1 register 0x00
corresponds to P0.8 ... bit 7 to P0.15.
FIO0CLR2 8 (byte) 0x3FFF C01E Fast GPIO Port 0 output Clear register 2. Bit 0 in FIO0CLR2 register 0x00
corresponds to P0.16 ... bit 7 to P0.23.
FIO0CLR3 8 (byte) 0x3FFF C01F Fast GPIO Port 0 output Clear register 3. Bit 0 in FIO0CLR3 register 0x00
corresponds to P0.24 ... bit 7 to P0.31.
FIO0CLRL 16 0x3FFF C01C Fast GPIO Port 0 output Clear Lower half-word register. Bit 0 in 0x0000
(half-word) FIO0CLRL register corresponds to P0.0 ... bit 15 to P0.15.
FIO0CLRU 16 0x3FFF C01E Fast GPIO Port 0 output Clear Upper half-word register. Bit 0 in 0x0000
(half-word) FIO0SETU register corresponds to P0.16 ... bit 15 to P0.31.
Table 118. Fast GPIO port 1 output Clear byte and half-word accessible register description
Register Register Address Description Reset
name length (bits) value
& access
FIO1CLR0 8 (byte) 0x3FFF C03C Fast GPIO Port 1 output Clear register 0. Bit 0 in FIO1CLR0 register 0x00
corresponds to P1.0 ... bit 7 to P1.7.
FIO1CLR1 8 (byte) 0x3FFF C03D Fast GPIO Port 1 output Clear register 1. Bit 0 in FIO1CLR1 register 0x00
corresponds to P1.8 ... bit 7 to P1.15.
FIO1CLR2 8 (byte) 0x3FFF C03E Fast GPIO Port 1 output Clear register 2. Bit 0 in FIO1CLR2 register 0x00
corresponds to P1.16 ... bit 7 to P1.23.
Table 118. Fast GPIO port 1 output Clear byte and half-word accessible register description
Register Register Address Description Reset
name length (bits) value
& access
FIO1CLR3 8 (byte) 0x3FFF C03F Fast GPIO Port 1 output Clear register 3. Bit 0 in FIO1CLR3 register 0x00
corresponds to P1.24 ... bit 7 to P1.31.
FIO1CLRL 16 0x3FFF C03C Fast GPIO Port 1 output Clear Lower half-word register. Bit 0 in 0x0000
(half-word) FIO1CLRL register corresponds to P1.0 ... bit 15 to P1.15.
FIO1CLRU 16 0x3FFF C03E Fast GPIO Port 1 output Clear Upper half-word register. Bit 0 in 0x0000
(half-word) FIO1CLRU register corresponds to P1.16 ... bit 15 to P1.31.
5.4 GPIO port Pin value register IOPIN (IO0PIN - 0xE002 8000, IO1PIN -
0xE002 8010, IO2PIN - 0xE002 8020, IO3PIN - 0xE002 8030, FIO0PIN -
0x3FFF C014, FIO1PIN - 0x3FFF C034)
This register provides the value of port pins that are configured to perform only digital
functions. The register will give the logic value of the pin regardless of whether the pin is
configured for input or output, or as GPIO or an alternate digital function. As an example,
a particular port pin may have GPIO input, GPIO output, UART receive, and PWM output
as selectable functions. Any configuration of that pin will allow its current logic state to be
read from the corresponding IOPIN register.
If a pin has an analog function as one of its options, the pin state cannot be read if the
analog configuration is selected. Selecting the pin as an A/D input disconnects the digital
features of the pin. In that case, the pin value read in the IOPIN register is not valid.
Writing to the IOPIN register stores the value in the port output register, bypassing the
need to use both the IOSET and IOCLR registers to obtain the entire written value. This
feature should be used carefully in an application since it affects the entire port.
Legacy registers are the IO0PIN, IO1PIN, IO2PIN and IO3PIN while the enhanced GPIOs
are supported via the FIO0PIN and FIO1PIN registers. Access to a port pins via the
FIOPIN register is conditioned by the corresponding FIOMASK register (see Section
9–5.5 “Fast GPIO port Mask register FIOMASK(FIO0MASK - 0x3FFF C010, FIO1MASK -
0x3FFF C030)”).
Only pins masked with zeros in the Mask register (see Section 9–5.5 “Fast GPIO port
Mask register FIOMASK(FIO0MASK - 0x3FFF C010, FIO1MASK - 0x3FFF C030)”) will
be correlated to the current content of the Fast GPIO port pin value register.
Table 119. GPIO port 0 Pin value register (IO0PIN - address 0xE002 8000) bit description
Bit Symbol Description Reset value
31:0 P0xVAL Slow GPIO pin value bits. Bit 0 in IO0PIN corresponds to P0.0 ... Bit 31 in IO0PIN NA
corresponds to P0.31.
Table 120. GPIO port 1 Pin value register (IO1PIN - address 0xE002 8010) bit description
Bit Symbol Description Reset value
31:0 P1xVAL Slow GPIO pin value bits. Bit 0 in IO1PIN corresponds to P1.0 ... Bit 31 in IO1PIN NA
corresponds to P1.31.
Table 121. GPIO port 2 Pin value register (IO2PIN - address 0xE002 8020) bit description
Bit Symbol Description Reset value
31:0 P2xVAL Slow GPIO pin value bits. Bit 0 in IO2PIN corresponds to P1.0 ... Bit 31 in IO2PIN NA
corresponds to P2.31.
Table 122. GPIO port 3 Pin value register (IO3PIN - address 0xE002 8030) bit description
Bit Symbol Description Reset value
31:0 P3xVAL Slow GPIO pin value bits. Bit 0 in IO3PIN corresponds to P3.0 ... Bit 31 in IO3PIN NA
corresponds to P3.31.
Table 123. Fast GPIO port 0 Pin value register (FIO0PIN - address 0x3FFF C014) bit description
Bit Symbol Description Reset value
31:0 FP0xVAL Fast GPIO pin value bits. Bit 0 in FIO0PIN corresponds to P0.0 ... Bit 31 in FIO0PIN NA
corresponds to P0.31.
Table 124. Fast GPIO port 1 Pin value register (FIO1PIN - address 0x3FFF C034) bit description
Bit Symbol Description Reset value
31:0 FP1xVAL Fast GPIO pin value bits. Bit 0 in FIO1PIN corresponds to P1.0 ... Bit 31 in FIO1PIN NA
corresponds to P1.31.
Aside from the 32-bit long and word only accessible FIOPIN register, every fast GPIO port
can also be controlled via several byte and half-word accessible registers listed in
Table 9–125 and Table 9–126. Next to providing the same functions as the FIOPIN
register, these additional registers allow easier and faster access to the physical port pins.
Table 125. Fast GPIO port 0 Pin value byte and half-word accessible register description
Register Register Address Description Reset
name length (bits) value
& access
FIO0PIN0 8 (byte) 0x3FFF C014 Fast GPIO Port 0 Pin value register 0. Bit 0 in FIO0PIN0 register 0x00
corresponds to P0.0 ... bit 7 to P0.7.
FIO0PIN1 8 (byte) 0x3FFF C015 Fast GPIO Port 0 Pin value register 1. Bit 0 in FIO0PIN1 register 0x00
corresponds to P0.8 ... bit 7 to P0.15.
FIO0PIN2 8 (byte) 0x3FFF C016 Fast GPIO Port 0 Pin value register 2. Bit 0 in FIO0PIN2 register 0x00
corresponds to P0.16 ... bit 7 to P0.23.
FIO0PIN3 8 (byte) 0x3FFF C017 Fast GPIO Port 0 Pin value register 3. Bit 0 in FIO0PIN3 register 0x00
corresponds to P0.24 ... bit 7 to P0.31.
FIO0PINL 16 0x3FFF C014 Fast GPIO Port 0 Pin value Lower half-word register. Bit 0 in 0x0000
(half-word) FIO0PINL register corresponds to P0.0 ... bit 15 to P0.15.
FIO0PINU 16 0x3FFF C016 Fast GPIO Port 0 Pin value Upper half-word register. Bit 0 in 0x0000
(half-word) FIO0PINU register corresponds to P0.16 ... bit 15 to P0.31.
Table 126. Fast GPIO port 1 Pin value byte and half-word accessible register description
Register Register Address Description Reset
name length (bits) value
& access
FIO1PIN0 8 (byte) 0x3FFF C034 Fast GPIO Port 1 Pin value register 0. Bit 0 in FIO1PIN0 register 0x00
corresponds to P1.0 ... bit 7 to P1.7.
FIO1PIN1 8 (byte) 0x3FFF C035 Fast GPIO Port 1 Pin value register 1. Bit 0 in FIO1PIN1 register 0x00
corresponds to P1.8 ... bit 7 to P1.15.
FIO1PIN2 8 (byte) 0x3FFF C036 Fast GPIO Port 1 Pin value register 2. Bit 0 in FIO1PIN2 register 0x00
corresponds to P1.16 ... bit 7 to P1.23.
FIO1PIN3 8 (byte) 0x3FFF C037 Fast GPIO Port 1 Pin value register 3. Bit 0 in FIO1PIN3 register 0x00
corresponds to P1.24 ... bit 7 to P1.31.
FIO1PINL 16 0x3FFF C034 Fast GPIO Port 1 Pin value Lower half-word register. Bit 0 in 0x0000
(half-word) FIO1PINL register corresponds to P1.0 ... bit 15 to P1.15.
FIO1PINU 16 0x3FFF C036 Fast GPIO Port 1 Pin value Upper half-word register. Bit 0 in 0x0000
(half-word) FIO1PINU register corresponds to P1.16 ... bit 15 to P1.31.
A zero in this register’s bit enables an access to the corresponding physical pin via a read
or write access. If a bit in this register is one, the corresponding pin will not be changed
with write access and if read, will not be reflected in the updated FIOPIN register. For
software examples, see Section 9–6 “GPIO usage notes” on page 125
Table 127. Fast GPIO port 0 Mask register (FIO0MASK - address 0x3FFF C010) bit description
Bit Symbol Value Description Reset value
31:0 FP0xMASK Fast GPIO physical pin access control. 0x0000 0000
0 Pin is affected by writes to the FIOSET, FIOCLR, and FIOPIN registers.
Current state of the pin will be observable in the FIOPIN register.
1 Physical pin is unaffected by writes into the FIOSET, FIOCLR and FIOPIN
registers. When the FIOPIN register is read, this bit will not be updated with
the state of the physical pin.
Table 128. Fast GPIO port 1 Mask register (FIO1MASK - address 0x3FFF C030) bit description
Bit Symbol Value Description Reset value
31:0 FP1xMASK Fast GPIO physical pin access control. 0x0000 0000
0 Pin is affected by writes to the FIOSET, FIOCLR, and FIOPIN registers.
Current state of the pin will be observable in the FIOPIN register.
1 Physical pin is unaffected by writes into the FIOSET, FIOCLR and FIOPIN
registers. When the FIOPIN register is read, this bit will not be updated with
the state of the physical pin.
Aside from the 32-bit long and word only accessible FIOMASK register, every fast GPIO
port can also be controlled via several byte and half-word accessible registers listed in
Table 9–129 and Table 9–130. Next to providing the same functions as the FIOMASK
register, these additional registers allow easier and faster access to the physical port pins.
Table 129. Fast GPIO port 0 Mask byte and half-word accessible register description
Register Register Address Description Reset
name length (bits) value
& access
FIO0MASK0 8 (byte) 0x3FFF C010 Fast GPIO Port 0 Mask register 0. Bit 0 in FIO0MASK0 register 0x00
corresponds to P0.0 ... bit 7 to P0.7.
FIO0MASK1 8 (byte) 0x3FFF C011 Fast GPIO Port 0 Mask register 1. Bit 0 in FIO0MASK1 register 0x00
corresponds to P0.8 ... bit 7 to P0.15.
FIO0MASK2 8 (byte) 0x3FFF C012 Fast GPIO Port 0 Mask register 2. Bit 0 in FIO0MASK2 register 0x00
corresponds to P0.16 ... bit 7 to P0.23.
FIO0MASK3 8 (byte) 0x3FFF C013 Fast GPIO Port 0 Mask register 3. Bit 0 in FIO0MASK3 register 0x00
corresponds to P0.24 ... bit 7 to P0.31.
FIO0MASKL 16 0x3FFF C010 Fast GPIO Port 0 Mask Lower half-word register. Bit 0 in 0x0000
(half-word) FIO0MASKL register corresponds to P0.0 ... bit 15 to P0.15.
FIO0MASKU 16 0x3FFF C012 Fast GPIO Port 0 Mask Upper half-word register. Bit 0 in 0x0000
(half-word) FIO0MASKU register corresponds to P0.16 ... bit 15 to P0.31.
Table 130. Fast GPIO port 1 Mask byte and half-word accessible register description
Register Register Address Description Reset
name length (bits) value
& access
FIO1MASK0 8 (byte) 0x3FFF C010 Fast GPIO Port 1 Mask register 0. Bit 0 in FIO1MASK0 register 0x00
corresponds to P1.0 ... bit 7 to P1.7.
FIO1MASK1 8 (byte) 0x3FFF C011 Fast GPIO Port 1 Mask register 1. Bit 0 in FIO1MASK1 register 0x00
corresponds to P1.8 ... bit 7 to P1.15.
FIO1MASK2 8 (byte) 0x3FFF C012 Fast GPIO Port 1 Mask register 2. Bit 0 in FIO1MASK2 register 0x00
corresponds to P1.16 ... bit 7 to P1.23.
FIO1MASK3 8 (byte) 0x3FFF C013 Fast GPIO Port 1 Mask register 3. Bit 0 in FIO1MASK3 register 0x00
corresponds to P1.24 ... bit 7 to P1.31.
FIO1MASKL 16 0x3FFF C010 Fast GPIO Port 1 Mask Lower half-word register. Bit 0 in 0x0000
(half-word) FIO1MASKL register corresponds to P1.0 ... bit 15 to P1.15.
FIO1MASKU 16 0x3FFF C012 Fast GPIO Port 1 Mask Upper half-word register. Bit 0 in 0x0000
(half-word) FIO1MASKU register corresponds to P1.16 ... bit 15 to P1.31.
pin P0.7 is configured as an output pin (write to IO0DIR register). Then, the P0.7 output
pin is set to low (first write to IO0CLR register). A short high pulse follows on P0.7 (write
access to IO0SET), and the second write to IO0CLR register sets pin P0.7 back to low
level.
There are systems that can tolerate this delay of a valid output, but for some applications
simultaneous output of a binary content (mixed 0s and 1s) within a group of pins on a
single GPIO port is required. This can be accomplished by writing to the port’s IOPIN
register.
The following code will preserve existing output on PORT0 pins P0.[31:16] and P0.[7:0]
and at the same time set P0.[15:8] to 0xA5, regardless of the previous value of pins
P0.[15:8]:
The same outcome can be obtained using the fast port access.
FIO0MASK = 0xFFFF00FF;
FIO0PIN = 0x0000A500;
FIO0MASKL = 0x00FF;
FIO0PINL = 0xA500;
FIO0PIN1 = 0xA5;
Writing to the IOPIN register enables instantaneous output of a desired content on the
parallel GPIO. Binary data written into the IOPIN register will affect all output configured
pins of that parallel port: 0s in the IOPIN will produce low level pin outputs and 1s in IOPIN
will produce high level pin outputs. In order to change output of only a group of port’s pins,
the application must logically AND readout from the IOPIN with a mask. This mask must
contain 0s in bits corresponding to pins that will be changed, and 1s for all others. Finally,
this result has to be logically ORred with the desired content and stored back into the
IOPIN register. Example 2 from above illustrates output of 0xA5 on PORT0 pins 15 to 8
while leaving all other PORT0 output pins unchanged.
6.4 Output signal frequency considerations when using the legacy and
enhanced GPIO registers
The enhanced features of fast GPIO ports available on this microcontroller make the
performance of the GPIO pins more dependent on the details of the application code. In
particular, software access to a GPIO pin is 3.5 times faster through the fast GPIO
registers than through the legacy set of registers. As a result, the maximum output
frequency of the digital pin is increased 3.5 times if the fast GPIO registers are used. This
tremendous increase of the output frequency is less noticeable when plain C code is
used. The portion of an application handling the fast port output should be written in
assembly code and executed in the ARM mode to take full advantage of the fast GPIO
access.
The following is a code example in which the pin control section is written in assembly
language for ARM. It illustrates the difference between the fast and slow GPIO port output
capabilities. For the best performances, compile this code in the ARM mode and execute
from the on-chip SRAM memory.
Figure 9–24 illustrates the code from above executed from the LPC21xx/LPC22xx on-chip
SRAM. The PLL generated FCCLK =60 MHz out of external FOSC = 12 MHz and
VPBDIV = 1 (PCLK = CCLK).
Fig 24. Illustration of the fast and slow GPIO access and output showing 3.5 x increase of the pin output
frequency
The baud rate is determined by the register values U0DLL and U0DLM. Enhanced parts
also include a fractional baud rate generator for fine-tuning the baud rate. The fractional
baud rate settings are determined by the content of the U0FDR register.
For an overview of how LPC21xx and LPC22xx parts and versions are described in this
manual, see Section 1–2 “How to read this manual”.
2. Features
• 16 byte Receive and Transmit FIFOs
• Register locations conforming to ‘550 industry standard
• Receiver FIFO trigger points at 1, 4, 8, and 14 bytes
• Built-in fractional baud rate generator with autobauding capabilities.
• Mechanism that enables software and hardware flow control implementation
3. Pin description
Table 132: UART0 pin description
Pin Type Description
RXD0 Input Serial Input. Serial receive data.
TXD0 Output Serial Output. Serial transmit data.
4. Register description
UART0 contains registers organized as shown in Table 10–133. The Divisor Latch Access
Bit (DLAB) is contained in U0LCR[7] and enables access to the Divisor Latches.
The divisor latches are used to determine the baud rate for all UART transfers. When
setting up the part, follow these steps:
NXP Semiconductors
Table 133. UART0 register map
Name Description Bit functions and addresses Access Reset Address
MSB LSB value[1]
U0IIR Interrupt ID Reg. - - - - - - ABTO Int ABEO Int RO 0x01 0xE000 C008
FIFOs Enabled - - IIR3 IIR2 IIR1 IIR0
U0FCR FIFO Control RX Trigger - - - TX FIFO RX FIFO FIFO WO 0x00 0xE000 C008
UM10114
U0TER TX. Enable Reg. TXEN - - - - - - - R/W 0x80 0xE000 C030
© NXP B.V. 2008. All rights reserved.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
131 of 386
NXP Semiconductors UM10114
Chapter 10: LPC21xx/22xx Universal Asynchronous
The Divisor Latch Access Bit (DLAB) in U0LCR must be zero in order to access the
U0RBR. The U0RBR is always Read Only.
Since PE, FE and BI bits correspond to the byte sitting on the top of the RBR FIFO (i.e.
the one that will be read in the next read from the RBR), the right approach for fetching the
valid pair of received byte and its status bits is first to read the content of the U0LSR
register, and then to read a byte from the U0RBR.
Table 134: UART0 Receiver Buffer Register (U0RBR - address 0xE000 C000, when DLAB = 0,
Read Only) bit description
Bit Symbol Description Reset value
7:0 RBR The UART0 Receiver Buffer Register contains the oldest undefined
received byte in the UART0 Rx FIFO.
The Divisor Latch Access Bit (DLAB) in U0LCR must be zero in order to access the
U0THR. The U0THR is always Write Only.
Table 135: UART0 Transmit Holding Register (U0THR - address 0xE000 C000, when
DLAB = 0, Write Only) bit description
Bit Symbol Description Reset value
7:0 THR Writing to the UART0 Transmit Holding Register causes the data NA
to be stored in the UART0 transmit FIFO. The byte will be sent
when it reaches the bottom of the FIFO and the transmitter is
available.
4.3 UART0 Divisor Latch registers (U0DLL - 0xE000 C000 and U0DLM -
0xE000 C004, when DLAB = 1)
The UART0 Divisor Latch is part of the UART0 Baud Rate Generator and holds the value
used to divide the clock in order to produce the baud rate clock, which must be 16x the
desired baud rate (Equation 10–1). The U0DLL and U0DLM registers together form a 16
bit divisor where U0DLL contains the lower 8 bits of the divisor and U0DLM contains the
higher 8 bits of the divisor. A 0x0000 value is treated like a 0x0001 value as division by
zero is not allowed.The Divisor Latch Access Bit (DLAB) in U0LCR must be one in order
to access the UART0 Divisor Latches.
(1)
PCLK
UARTn baudrate = --------------------------------------------------------------------------------
16 × ( 256 × UnDLM + UnDLL )
Details on how to select the right value for U0DLL and U0DLM if the part includes a
fractional divider (see Table 10–131) can be found later on in this chapter.
Table 136: UART0 Divisor Latch LSB register (U0DLL - address 0xE000 C000, when
DLAB = 1) bit description
Bit Symbol Description Reset value
7:0 DLL The UART0 Divisor Latch LSB Register, along with the U0DLM 0x01
register, determines the baud rate of the UART0.
Table 137: UART0 Divisor Latch MSB register (U0DLM - address 0xE000 C004, when
DLAB = 1) bit description
Bit Symbol Description Reset value
7:0 DLM The UART0 Divisor Latch MSB Register, along with the U0DLL 0x00
register, determines the baud rate of the UART0.
Important: If the fractional divider is active (DIVADDVAL > 0) and DLM = 0, the value of
the DLL register must be 2 or greater.
Table 138: UARTn Fractional Divider Register (U0FDR - address 0xE000 C028,
U2FDR - 0xE007 8028, U3FDR - 0xE007 C028) bit description
Bit Function Value Description Reset
value
3:0 DIVADDVAL 0 Baud-rate generation pre-scaler divisor value. If this field is 0
0, fractional baud-rate generator will not impact the UARTn
baudrate.
7:4 MULVAL 1 Baud-rate pre-scaler multiplier value. This field must be 1
greater or equal 1 for UARTn to operate properly,
regardless of whether the fractional baud-rate generator is
used or not.
31:8 - NA Reserved, user software should not write ones to reserved 0
bits. The value read from a reserved bit is not defined.
This register controls the clock pre-scaler for the baud rate generation. The reset value of
the register keeps the fractional capabilities of UART0 disabled making sure that UART0
is fully software and hardware compatible with UARTs not equipped with this feature.
(2)
PCLK
UARTn baudrate = ----------------------------------------------------------------------------------------------------------------------------------
16 × ( 256 × UnDLM + UnDLL ) × ⎛⎝ 1 + -----------------------------⎞⎠
DivAddVal
MulVal
Where PCLK is the peripheral clock, U0DLM and U0DLL are the standard UART0 baud
rate divider registers, and DIVADDVAL and MULVAL are UART0 fractional baudrate
generator specific parameters.
The value of MULVAL and DIVADDVAL should comply to the following conditions:
1. 0 < MULVAL ≤ 15
2. 0 ≤ DIVADDVAL < 15
3. DIVADDVAL<MULVAL
The value of the U0FDR should not be modified while transmitting/receiving data or data
may be lost or corrupted.
If the U0FDR register value does not comply to these two requests, then the fractional
divider output is undefined. If DIVADDVAL is zero then the fractional divider is disabled,
and the clock will not be divided.
Calculating UART
baudrate (BR)
PCLK,
BR
DL est is an True
integer?
False DIVADDVAL = 0
MULVAL = 1
FR est = 1.5
False
1.1 < FR est < 1.9?
True
DLM = DL est[15:8]
DLL = DL est [7:0]
End
The closest value for FRest = 1.628 in the look-up Table 10–139 is FR = 1.625. It is
equivalent to DIVADDVAL = 5 and MULVAL = 8.
Based on these findings, the suggested UART setup would be: DLM = 0, DLL = 4,
DIVADDVAL = 5, and MULVAL = 8. According to Equation 10–2 the UART’s baud rate is
115384. This rate has a relative error of 0.16% from the originally specified 115200.
Table 140. UART0 Interrupt Enable Register (U0IER - address 0xE000 C004, when DLAB = 0)
bit description
Bit Symbol Value Description Reset
value
0 RBR U0IER[0] enables the Receive Data Available interrupt 0
Interrupt for UART0. It also controls the Character Receive
Enable Time-out interrupt.
0 Disable the RDA interrupts.
1 Enable the RDA interrupts.
1 THRE U0IER[1] enables the THRE interrupt for UART0. The 0
Interrupt status of this can be read from U0LSR[5].
Enable 0 Disable the THRE interrupts.
1 Enable the THRE interrupts.
2 RX Line U0IER[2] enables the UART0 RX line status interrupts. 0
Status The status of this interrupt can be read from U0LSR[4:1].
Interrupt 0 Disable the RX line status interrupts.
Enable
1 Enable the RX line status interrupts.
7:3 - - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is not
defined.
8 ABEOIntEn Enables the end of auto-baud interrupt. 0
0 Disable End of Auto-baud Interrupt.
1 Enable End of Auto-baud Interrupt.
9 ABTOIntEn Enables the auto-baud time-out interrupt. 0
0 Disable Auto-baud Time-out Interrupt.
1 Enable Auto-baud Time-out Interrupt.
31:10 - - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is not
defined.
Table 141: UART0 Interrupt Identification Register (U0IIR - address 0xE000 C008, read only)
bit description
Bit Symbol Value Description Reset
value
0 Interrupt Note that U0IIR[0] is active LOW. The pending interrupt can 1
Pending be determined by evaluating U0IIR[3:1].
0 At least one interrupt is pending.
1 No pending interrupts.
Table 141: UART0 Interrupt Identification Register (U0IIR - address 0xE000 C008, read only)
bit description
Bit Symbol Value Description Reset
value
3:1 Interrupt U0IER[3:1] identifies an interrupt corresponding to the 0
Identification UART0 Rx FIFO. All other combinations of U0IER[3:1] not
listed above are reserved (000,100,101,111).
011 1 - Receive Line Status (RLS).
010 2a - Receive Data Available (RDA).
110 2b - Character Time-out Indicator (CTI).
001 3 - THRE Interrupt
5:4 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
7:6 FIFO Enable These bits are equivalent to U0FCR[0]. 0
8 ABEOInt End of auto-baud interrupt. True if auto-baud has finished 0
successfully and interrupt is enabled.
9 ABTOInt Auto-baud time-out interrupt. True if auto-baud has timed 0
out and interrupt is enabled.
31:10 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Interrupts are handled as described in Table 10–142. Given the status of U0IIR[3:0], an
interrupt handler routine can determine the cause of the interrupt and how to clear the
active interrupt. The U0IIR must be read in order to clear the interrupt prior to exiting the
Interrupt Service Routine.
The UART0 RLS interrupt (U0IIR[3:1] = 011) is the highest priority interrupt and is set
whenever any one of four error conditions occur on the UART0 Rx input: overrun error
(OE), parity error (PE), framing error (FE) and break interrupt (BI). The UART0 Rx error
condition that set the interrupt can be observed via U0LSR[4:1]. The interrupt is cleared
upon an U0LSR read.
The UART0 RDA interrupt (U0IIR[3:1] = 010) shares the second level priority with the CTI
interrupt (U0IIR[3:1] = 110). The RDA is activated when the UART0 Rx FIFO reaches the
trigger level defined in U0FCR[7:6] and is reset when the UART0 Rx FIFO depth falls
below the trigger level. When the RDA interrupt goes active, the CPU can read a block of
data defined by the trigger level.
The CTI interrupt (U0IIR[3:1] = 110) is a second level interrupt and is set when the UART0
Rx FIFO contains at least one character and no UART0 Rx FIFO activity has occurred in
3.5 to 4.5 character times. Any UART0 Rx FIFO activity (read or write of UART0 RSR) will
clear the interrupt. This interrupt is intended to flush the UART0 RBR after a message has
been received that is not a multiple of the trigger level size. For example, if a peripheral
wished to send a 105 character message and the trigger level was 10 characters, the
CPU would receive 10 RDA interrupts resulting in the transfer of 100 characters and 1 to 5
CTI interrupts (depending on the service routine) resulting in the transfer of the remaining
5 characters.
[1] Values "0000", “0011”, “0101”, “0111”, “1000”, “1001”, “1010”, “1011”,”1101”,”1110”,”1111” are reserved.
[2] For details see Section 10–4.9 “UART0 Line Status Register (U0LSR - 0xE000 C014, Read Only)”
[3] For details see Section 10–4.1 “UART0 Receiver Buffer register (U0RBR - 0xE000 C000, when DLAB = 0, Read Only)”
[4] For details see Section 10–4.6 “UART0 Interrupt Identification Register (U0IIR - 0xE000 C008, Read Only)” and Section 10–4.2 “UART0
Transmit Holding Register (U0THR - 0xE000 C000, when DLAB = 0, Write Only)”
The UART0 THRE interrupt (U0IIR[3:1] = 001) is a third level interrupt and is activated
when the UART0 THR FIFO is empty provided certain initialization conditions have been
met. These initialization conditions are intended to give the UART0 THR FIFO a chance to
fill up with data to eliminate many THRE interrupts from occurring at system start-up. The
initialization conditions implement a one character delay minus the stop bit whenever
THRE=1 and there have not been at least two characters in the U0THR at one time since
the last THRE = 1 event. This delay is provided to give the CPU time to write data to
U0THR without a THRE interrupt to decode and service. A THRE interrupt is set
immediately if the UART0 THR FIFO has held two or more characters at one time and
currently, the U0THR is empty. The THRE interrupt is reset when a U0THR write occurs or
a read of the U0IIR occurs and the THRE is the highest interrupt (U0IIR[3:1] = 001).
Table 143: UART0 FIFO Control Register (U0FCR - address 0xE000 C008) bit description
Bit Symbol Value Description Reset value
0 FIFO Enable 0 UART0 FIFOs are disabled. Must not be used in the 0
application.
1 Active HIGH enable for both UART0 Rx and TX
FIFOs and U0FCR[7:1] access. This bit must be set
for proper UART0 operation. Any transition on this
bit will automatically clear the UART0 FIFOs.
Table 143: UART0 FIFO Control Register (U0FCR - address 0xE000 C008) bit description
Bit Symbol Value Description Reset value
1 RX FIFO 0 No impact on either of UART0 FIFOs. 0
Reset 1 Writing a logic 1 to U0FCR[1] will clear all bytes in
UART0 Rx FIFO and reset the pointer logic. This bit
is self-clearing.
2 TX FIFO 0 No impact on either of UART0 FIFOs. 0
Reset 1 Writing a logic 1 to U0FCR[2] will clear all bytes in
UART0 TX FIFO and reset the pointer logic. This bit
is self-clearing.
5:3 - 0 Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is
not defined.
7:6 RX Trigger These two bits determine how many receiver 0
Level UART0 FIFO characters must be written before an
interrupt is activated.
00 trigger level 0 (1 character or 0x01).
01 trigger level 1 (4 characters or 0x04).
10 trigger level 2 (8 characters or 0x08).
11 trigger level 3 (14 characters or 0x0E).
Table 144: UART0 Line Control Register (U0LCR - address 0xE000 C00C) bit description
Bit Symbol Value Description Reset value
1:0 Word Length 00 5 bit character length 0
Select 01 6 bit character length
10 7 bit character length
11 8 bit character length
2 Stop Bit Select 0 1 stop bit. 0
1 2 stop bits (1.5 if U0LCR[1:0]=00).
3 Parity Enable 0 Disable parity generation and checking. 0
1 Enable parity generation and checking.
5:4 Parity Select 00 Odd parity. Number of 1s in the transmitted character and the 0
attached parity bit will be odd.
01 Even Parity. Number of 1s in the transmitted character and the
attached parity bit will be even.
10 Forced "1" stick parity.
11 Forced "0" stick parity.
6 Break Control 0 Disable break transmission. 0
1 Enable break transmission. Output pin UART0 TXD is forced
to logic 0 when U0LCR[6] is active HIGH.
7 Divisor Latch 0 Disable access to Divisor Latches. 0
Access Bit (DLAB) 1 Enable access to Divisor Latches.
4.9 UART0 Line Status Register (U0LSR - 0xE000 C014, Read Only)
The U0LSR is a read-only register that provides status information on the UART0 TX and
RX blocks.
Table 145: UART0 Line Status Register (U0LSR - address 0xE000 C014, read only) bit description
Bit Symbol Value Description Reset value
0 Receiver Data U0LSR0 is set when the U0RBR holds an unread character and is cleared 0
Ready when the UART0 RBR FIFO is empty.
(RDR) 0 U0RBR is empty.
1 U0RBR contains valid data.
1 Overrun Error The overrun error condition is set as soon as it occurs. An U0LSR read clears 0
(OE) U0LSR1. U0LSR1 is set when UART0 RSR has a new character assembled
and the UART0 RBR FIFO is full. In this case, the UART0 RBR FIFO will not
be overwritten and the character in the UART0 RSR will be lost.
0 Overrun error status is inactive.
1 Overrun error status is active.
2 Parity Error When the parity bit of a received character is in the wrong state, a parity error 0
(PE) occurs. An U0LSR read clears U0LSR[2]. Time of parity error detection is
dependent on U0FCR[0].
Note: A parity error is associated with the character at the top of the UART0
RBR FIFO.
0 Parity error status is inactive.
1 Parity error status is active.
3 Framing Error When the stop bit of a received character is a logic 0, a framing error occurs. 0
(FE) An U0LSR read clears U0LSR[3]. The time of the framing error detection is
dependent on U0FCR0. Upon detection of a framing error, the Rx will attempt
to resynchronize to the data and assume that the bad stop bit is actually an
early start bit. However, it cannot be assumed that the next received byte will
be correct even if there is no Framing Error.
Note: A framing error is associated with the character at the top of the UART0
RBR FIFO.
0 Framing error status is inactive.
1 Framing error status is active.
4 Break Interrupt When RXD0 is held in the spacing state (all 0’s) for one full character 0
(BI) transmission (start, data, parity, stop), a break interrupt occurs. Once the
break condition has been detected, the receiver goes idle until RXD0 goes to
marking state (all 1’s). An U0LSR read clears this status bit. The time of break
detection is dependent on U0FCR[0].
Note: The break interrupt is associated with the character at the top of the
UART0 RBR FIFO.
0 Break interrupt status is inactive.
1 Break interrupt status is active.
5 Transmitter THRE is set immediately upon detection of an empty UART0 THR and is 1
Holding cleared on a U0THR write.
Register Empty 0 U0THR contains valid data.
(THRE))
1 U0THR is empty.
Table 145: UART0 Line Status Register (U0LSR - address 0xE000 C014, read only) bit description
Bit Symbol Value Description Reset value
6 Transmitter TEMT is set when both U0THR and U0TSR are empty; TEMT is cleared when 1
Empty either the U0TSR or the U0THR contain valid data.
(TEMT) 0 U0THR and/or the U0TSR contains valid data.
1 U0THR and the U0TSR are empty.
7 Error in RX U0LSR[7] is set when a character with a Rx error such as framing error, parity 0
FIFO error or break interrupt, is loaded into the U0RBR. This bit is cleared when the
(RXFE) U0LSR register is read and there are no subsequent errors in the UART0
FIFO.
0 U0RBR contains no UART0 RX errors or U0FCR[0]=0.
1 UART0 RBR contains at least one UART0 RX error.
Table 146: UART0 Scratch Pad Register (U0SCR - address 0xE000 C01C) bit description
Bit Symbol Description Reset value
7:0 Pad A readable, writable byte. 0x00
Table 147: Auto-baud Control Register (U0ACR - 0xE000 C020) bit description
Bit Symbol Value Description Reset value
0 Start This bit is automatically cleared after auto-baud 0
completion.
0 Auto-baud stop (auto-baud is not running).
1 Auto-baud start (auto-baud is running).Auto-baud run
bit. This bit is automatically cleared after auto-baud
completion.
1 Mode Auto-baud mode select bit. 0
0 Mode 0.
1 Mode 1.
2 AutoRestart 0 No restart 0
1 Restart in case of time-out (counter restarts at next
UART0 Rx falling edge)
7:3 - NA Reserved, user software should not write ones to 0
reserved bits. The value read from a reserved bit is not
defined.
Table 147: Auto-baud Control Register (U0ACR - 0xE000 C020) bit description
Bit Symbol Value Description Reset value
8 ABEOIntClr End of auto-baud interrupt clear bit (write only 0
accessible). Writing a 1 will clear the corresponding
interrupt in the U0IIR. Writing a 0 has no impact.
9 ABTOIntClr Auto-baud time-out interrupt clear bit (write only 0
accessible). Writing a 1 will clear the corresponding
interrupt in the U0IIR. Writing a 0 has no impact.
31:10 - NA Reserved, user software should not write ones to 0
reserved bits. The value read from a reserved bit is not
defined.
4.11.1 Auto-baud
The UART0 auto-baud function can be used to measure the incoming baud-rate based on
the ”AT" protocol (Hayes command). If enabled the auto-baud feature will measure the bit
time of the receive data stream and set the divisor latch registers U0DLM and U0DLL
accordingly.
Auto-baud is started by setting the U0ACR Start bit. Auto-baud can be stopped by clearing
the U0ACR Start bit. The Start bit will clear once auto-baud has finished and reading the
bit will return the status of auto-baud (pending/finished).
Two auto-baud measuring modes are available which can be selected by the U0ACR
Mode bit. In mode 0 the baud-rate is measured on two subsequent falling edges of the
UART0 Rx pin (the falling edge of the start bit and the falling edge of the least significant
bit). In mode 1 the baud-rate is measured between the falling edge and the subsequent
rising edge of the UART0 Rx pin (the length of the start bit).
The U0ACR AutoRestart bit can be used to automatically restart baud-rate measurement
if a time-out occurs (the rate measurement counter overflows). If this bit is set the rate
measurement will restart at the next falling edge of the UART0 Rx pin.
• The U0IIR ABTOInt interrupt will get set if the interrupt is enabled (U0IER ABToIntEn
is set and the auto-baud rate measurement counter overflows).
• The U0IIR ABEOInt interrupt will get set if the interrupt is enabled (U0IER ABEOIntEn
is set and the auto-baud has completed successfully).
(3)
2 × P CLK PCLK
ratemin = ------------------------- ≤ UART0 baudrate ≤ ------------------------------------------------------------------------------------------------------------ = ratemax
16 × 2 15 16 × ( 2 + databits + paritybits + stopbits )
1. On U0ACR Start bit setting, the baud-rate measurement counter is reset and the
UART0 U0RSR is reset. The U0RSR baud rate is switch to the highest rate.
2. A falling edge on UART0 Rx pin triggers the beginning of the start bit. The rate
measuring counter will start counting PCLK cycles optionally pre-scaled by the
fractional baud-rate generator.
3. During the receipt of the start bit, 16 pulses are generated on the RSR baud input with
the frequency of the (fractional baud-rate pre-scaled) UART0 input clock,
guaranteeing the start bit is stored in the U0RSR.
4. During the receipt of the start bit (and the character LSB for mode = 0) the rate
counter will continue incrementing with the pre-scaled UART0 input clock (PCLK).
5. If Mode = 0 then the rate counter will stop on next falling edge of the UART0 Rx pin. If
Mode = 1 then the rate counter will stop on the next rising edge of the UART0 Rx pin.
6. The rate counter is loaded into U0DLM/U0DLL and the baud-rate will be switched to
normal operation. After setting the U0DLM/U0DLL the end of auto-baud interrupt
U0IIR ABEOInt will be set, if enabled. The U0RSR will now continue receiving the
remaining bits of the ”A/a" character.
start bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 parity stop
UART0 RX
start bit LSB of 'A' or 'a'
U0ACR start
rate counter
16xbaud_rate
16 cycles 16 cycles
start bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 parity stop
UART0 RX
start bit LSB of 'A' or 'a'
U0ACR start
rate counter
16xbaud_rate
16 cycles
Table 10–148 describes how to use TXEn bit in order to achieve software flow control.
Table 148: UART0 Transmit Enable Register (U0TER - address 0xE000 C030) bit description
Bit Symbol Description Reset
value
6:0 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
7 TXEN When this bit is 1, as it is after a Reset, data written to the THR is output 1
on the TXD pin as soon as any preceding data has been sent. If this bit
is cleared to 0 while a character is being sent, the transmission of that
character is completed, but no further characters are sent until this bit is
set again. In other words, a 0 in this bit blocks the transfer of characters
from the THR or TX FIFO into the transmit shift register. Software
implementing software-handshaking can clear this bit when it receives
an XOFF character (DC3). Software can set this bit again when it
receives an XON (DC1) character.
5. Architecture
The architecture of the UART0 is shown below in the block diagram.
The APB interface provides a communications link between the CPU or host and the
UART0.
The UART0 receiver block, U0RX, monitors the serial input line, RXD0, for valid input.
The UART0 RX Shift Register (U0RSR) accepts valid characters via RXD0. After a valid
character is assembled in the U0RSR, it is passed to the UART0 RX Buffer Register FIFO
to await access by the CPU or host via the generic host interface.
The UART0 transmitter block, U0TX, accepts data written by the CPU or host and buffers
the data in the UART0 TX Holding Register FIFO (U0THR). The UART0 TX Shift Register
(U0TSR) reads the data stored in the U0THR and assembles the data to transmit via the
serial output pin, TXD0.
The UART0 Baud Rate Generator block, U0BRG, generates the timing enables used by
the UART0 TX block. The U0BRG clock input source is the APB clock (PCLK). The main
clock is divided down per the divisor specified in the U0DLL and U0DLM registers. This
divided down clock is a 16x oversample clock, NBAUDOUT.
The interrupt interface contains registers U0IER and U0IIR. The interrupt interface
receives several one clock wide enables from the U0TX and U0RX blocks.
Status information from the U0TX and U0RX is stored in the U0LSR. Control information
for the U0TX and U0RX is stored in the U0LCR.
U0TX
NTXRDY
TXD0
U0THR U0TSR
U0BRG
U0DLL NBAUDOUT
U0DLM RCLK
U0RX
NRXRDY
INTERRUPT
RXD0
U0RBR U0RSR
U0INTR U0IER
U0IIR
U0FCR
U0LSR
U0SCR
U0LCR
PA[2:0]
PSEL
PSTB
PWRITE
APB
PD[7:0] DDIS
INTERFACE
AR
MR
PCLK
The baud rate is determined by the register values U1DLL and U1DLM. Enhanced parts
also include a fractional baud rate generator for fine-tuning the baud rate. The fractional
baud rate settings are determined by the content of the U1FDR register.
For an overview of how LPC21xx and LPC22xx parts and versions are described in this
manual, see Section 1–2 “How to read this manual”.
2. Features
• UART1 is identical to UART0 with the addition of a modem interface.
• UART1 contains 16 byte Receive and Transmit FIFOs.
• Register locations conform to ‘550 industry standard.
• Receiver FIFO trigger points at 1, 4, 8, and 14 bytes.
• Fractional baud rate generator with autobauding capabilities is built-in.
• Mechanism enables software and hardware flow control implementation.
• Standard modem interface signals are included, and flow control (auto-CTS/RTS) is
fully supported in hardware.
3. Pin description
Table 150. UART1 pin description
Pin Type Description
RXD1 Input Serial Input. Serial receive data.
TXD1 Output Serial Output. Serial transmit data.
CTS1 Input Clear To Send. Active LOW signal indicates if the external modem is ready to accept transmitted
data via TXD1 from the UART1. In normal operation of the modem interface (U1MCR[4] = 0), the
complement value of this signal is stored in U1MSR[4]. State change information is stored in
U1MSR[0] and is a source for a priority level 4 interrupt, if enabled (U1IER[3] = 1).
DCD1 Input Data Carrier Detect. Active LOW signal indicates if the external modem has established a
communication link with the UART1 and data may be exchanged. In normal operation of the
modem interface (U1MCR[4]=0), the complement value of this signal is stored in U1MSR[7]. State
change information is stored in U1MSR3 and is a source for a priority level 4 interrupt, if enabled
(U1IER[3] = 1).
DSR1 Input Data Set Ready. Active LOW signal indicates if the external modem is ready to establish a
communications link with the UART1. In normal operation of the modem interface (U1MCR[4] = 0),
the complement value of this signal is stored in U1MSR[5]. State change information is stored in
U1MSR[1] and is a source for a priority level 4 interrupt, if enabled (U1IER[3] = 1).
4. Register description
UART1 contains registers organized as shown in Table 76. The Divisor Latch Access Bit
(DLAB) is contained in U1LCR[7] and enables access to the Divisor Latches.
The divisor latches are used to determine the baud rate for all UART transfers. When
setting up the part, follow these steps:
NXP Semiconductors
Table 151. UART1 register map
Name Description Bit functions and addresses Access Reset Address
MSB LSB value[1]
U1IIR Interrupt ID Reg. - - - - - - ABTO Int ABEO Int RO 0x01 0xE001 0008
FIFOs Enabled - - IIR3 IIR2 IIR1 IIR0
U1FCR FIFO Control RX Trigger - - - TX FIFO RX FIFO FIFO WO 0x00 0xE001 0008
UM10114
© NXP B.V. 2008. All rights reserved.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
NXP Semiconductors UM10114
Chapter 11: LPC21xx/22xx Universal Asynchronous
The Divisor Latch Access Bit (DLAB) in U1LCR must be zero in order to access the
U1RBR. The U1RBR is always Read Only.
Since PE, FE and BI bits correspond to the byte sitting on the top of the RBR FIFO (i.e.
the one that will be read in the next read from the RBR), the right approach for fetching the
valid pair of received byte and its status bits is first to read the content of the U1LSR
register, and then to read a byte from the U1RBR.
Table 152. UART1 Receiver Buffer Register (U1RBR - address 0xE001 0000, when DLAB = 0
Read Only) bit description
Bit Symbol Description Reset value
7:0 RBR The UART1 Receiver Buffer Register contains the oldest undefined
received byte in the UART1 RX FIFO.
The Divisor Latch Access Bit (DLAB) in U1LCR must be zero in order to access the
U1THR. The U1THR is always Write Only.
Table 153. UART1 Transmitter Holding Register (U1THR - address 0xE001 0000, when
DLAB = 0 Write Only) bit description
Bit Symbol Description Reset value
7:0 THR Writing to the UART1 Transmit Holding Register causes the data NA
to be stored in the UART1 transmit FIFO. The byte will be sent
when it reaches the bottom of the FIFO and the transmitter is
available.
4.3 UART1 Divisor Latch registers 0 and 1 (U1DLL - 0xE001 0000 and
U1DLM - 0xE001 0004, when DLAB = 1)
The UART0 Divisor Latch is part of the UART0 Baud Rate Generator and holds the value
used to divide the clock in order to produce the baud rate clock, which must be 16x the
desired baud rate (Equation 11–4). The U1DLL and U1DLM registers together form a 16
bit divisor where U1DLL contains the lower 8 bits of the divisor and U1DLM contains the
higher 8 bits of the divisor. A 0x0000 value is treated like a 0x0001 value as division by
zero is not allowed.The Divisor Latch Access Bit (DLAB) in U1LCR must be one in order
to access the UART1 Divisor Latches.
(4)
PCLK
UARTn baudrate = --------------------------------------------------------------------------------
16 × ( 256 × UnDLM + UnDLL )
Details on how to select the right value for U1DLL and U1DLM if the part includes a
fractional divider (see Table 11–149) can be found later on in this chapter.
Table 154: UART1 Divisor Latch LSB register (U1DLL - address 0xE001 C000, when
DLAB = 1) bit description
Bit Symbol Description Reset value
7:0 DLL The UART0 Divisor Latch LSB Register, along with the U1DLM 0x01
register, determines the baud rate of the UART1.
Table 155: UART0 Divisor Latch MSB register (U1DLM - address 0xE001 C004, when
DLAB = 1) bit description
Bit Symbol Description Reset value
7:0 DLM The UART1 Divisor Latch MSB Register, along with the U1DLL 0x00
register, determines the baud rate of the UART1.
Important: If the fractional divider is active (DIVADDVAL > 0) and DLM = 0, the value of
the DLL register must be 2 or greater.
Table 156. UART1 Fractional Divider Register (U1FDR - address 0xE001 0028) bit description
Bit Function Value Description Reset
value
3:0 DIVADDVAL 0 Baud-rate generation pre-scaler divisor value. If this field is 0
0, fractional baud-rate generator will not impact the UARTn
baudrate.
7:4 MULVAL 1 Baud-rate pre-scaler multiplier value. This field must be 1
greater or equal 1 for UARTn to operate properly,
regardless of whether the fractional baud-rate generator is
used or not.
31:8 - NA Reserved, user software should not write ones to reserved 0
bits. The value read from a reserved bit is not defined.
This register controls the clock pre-scaler for the baud rate generation. The reset value of
the register keeps the fractional capabilities of UART1 disabled making sure that UART1
is fully software and hardware compatible with UARTs not equipped with this feature.
(5)
PCLK
UARTn baudrate = ----------------------------------------------------------------------------------------------------------------------------------
16 × ( 256 × UnDLM + UnDLL ) × ⎛⎝ 1 + -----------------------------⎞⎠
DivAddVal
MulVal
Where PCLK is the peripheral clock, U1DLM and U1DLL are the standard UART1 baud
rate divider registers, and DIVADDVAL and MULVAL are UART1 fractional baudrate
generator specific parameters.
The value of MULVAL and DIVADDVAL should comply to the following conditions:
1. 0 < MULVAL ≤ 15
2. 0 ≤ DIVADDVAL < 15
3. DIVADDVAL<MULVAL
The value of the U1FDR should not be modified while transmitting/receiving data or data
may be lost or corrupted.
If the U1FDR register value does not comply to these two requests, then the fractional
divider output is undefined. If DIVADDVAL is zero then the fractional divider is disabled,
and the clock will not be divided.
Calculating UART
baudrate (BR)
PCLK,
BR
DL est is an True
integer?
False DIVADDVAL = 0
MULVAL = 1
FR est = 1.5
False
1.1 < FR est < 1.9?
True
DLM = DL est[15:8]
DLL = DL est [7:0]
End
The closest value for FRest = 1.628 in the look-up Table 11–157 is FR = 1.625. It is
equivalent to DIVADDVAL = 5 and MULVAL = 8.
Based on these findings, the suggested UART setup would be: DLM = 0, DLL = 4,
DIVADDVAL = 5, and MULVAL = 8. According to Equation 11–5 the UART’s baud rate is
115384 Bd. This rate has a relative error of 0.16% from the originally specified 115200 Bd.
Table 158. UART1 Interrupt Enable Register (U1IER - address 0xE001 0004, when DLAB = 0)
bit description
Bit Symbol Value Description Reset value
0 RBR U1IER[0] enables the Receive Data Available 0
Interrupt interrupt for UART1. It also controls the Character
Enable Receive Time-out interrupt.
0 Disable the RDA interrupts.
1 Enable the RDA interrupts.
1 THRE U1IER[1] enables the THRE interrupt for UART1. 0
Interrupt The status of this interrupt can be read from
Enable U1LSR[5].
0 Disable the THRE interrupts.
1 Enable the THRE interrupts.
2 RX Line U1IER[2] enables the UART1 RX line status 0
Interrupt interrupts. The status of this interrupt can be read
Enable from U1LSR[4:1].
0 Disable the RX line status interrupts.
1 Enable the RX line status interrupts.
3 Modem U1IER[3] enables the modem interrupt. The status 0
Status of this interrupt can be read from U1MSR[3:0].
Interrupt 0 Disable the modem interrupt.
Enable
1 Enable the modem interrupt.
6:4 - - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is
not defined.
7 CTS If auto-CTS mode is enabled this bit 0
Interrupt enables/disables the modem status interrupt
Enable generation on a CTS1 signal transition. If auto-CTS
mode is disabled a CTS1 transition will generate an
interrupt if Modem Status Interrupt Enable
(U1IER[3]) is set.
In normal operation a CTS1 signal transition will
generate a Modem Status Interrupt unless the
interrupt has been disabled by clearing the
U1IER[3] bit in the U1IER register. In auto-CTS
mode a transition on the CTS1 bit will trigger an
interrupt only if both the U1IER[3] and U1IER[7] bits
are set.
0 Disable the CTS interrupt.
1 Enable the CTS interrupt.
8 ABEOIntEn Enables the end of auto-baud interrupt. 0
0 Disable End of Auto-baud Interrupt.
1 Enable End of Auto-baud Interrupt.
9 ABTOIntEn Enables the auto-baud time-out interrupt. 0
0 Disable Auto-baud Time-out Interrupt.
1 Enable Auto-baud Time-out Interrupt.
31:10 - - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is
not defined.
Table 159. UART1 Interrupt Identification Register (U1IIR - address 0xE001 0008, read only)
bit description
Bit Symbol Value Description Reset value
0 Interrupt Note that U1IIR[0] is active LOW. The pending 1
Pending interrupt can be determined by evaluating
U1IIR[3:1].
0 At least one interrupt is pending.
1 No interrupt is pending.
3:1 Interrupt U1IER[3:1] identifies an interrupt corresponding to 0
Identification the UART1 Rx FIFO. All other combinations of
U1IER[3:1] not listed above are reserved
(100,101,111).
011 1 - Receive Line Status (RLS).
010 2a - Receive Data Available (RDA).
110 2b - Character Time-out Indicator (CTI).
001 3 - THRE Interrupt.
000 4 - Modem Interrupt.
5:4 - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is
not defined.
7:6 FIFO Enable These bits are equivalent to U1FCR[0]. 0
8 ABEOInt End of auto-baud interrupt. True if auto-baud has 0
finished successfully and interrupt is enabled.
9 ABTOInt Auto-baud time-out interrupt. True if auto-baud has 0
timed out and interrupt is enabled.
31:10 - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is
not defined.
Interrupts are handled as described in Table 11–160. Given the status of U1IIR[3:0], an
interrupt handler routine can determine the cause of the interrupt and how to clear the
active interrupt. The U1IIR must be read in order to clear the interrupt prior to exiting the
Interrupt Service Routine.
The UART1 RLS interrupt (U1IIR[3:1] = 011) is the highest priority interrupt and is set
whenever any one of four error conditions occur on the UART1RX input: overrun error
(OE), parity error (PE), framing error (FE) and break interrupt (BI). The UART1 Rx error
condition that set the interrupt can be observed via U1LSR[4:1]. The interrupt is cleared
upon an U1LSR read.
The UART1 RDA interrupt (U1IIR[3:1] = 010) shares the second level priority with the CTI
interrupt (U1IIR[3:1] = 110). The RDA is activated when the UART1 Rx FIFO reaches the
trigger level defined in U1FCR7:6 and is reset when the UART1 Rx FIFO depth falls below
the trigger level. When the RDA interrupt goes active, the CPU can read a block of data
defined by the trigger level.
The CTI interrupt (U1IIR[3:1] = 110) is a second level interrupt and is set when the UART1
Rx FIFO contains at least one character and no UART1 Rx FIFO activity has occurred in
3.5 to 4.5 character times. Any UART1 Rx FIFO activity (read or write of UART1 RSR) will
clear the interrupt. This interrupt is intended to flush the UART1 RBR after a message has
been received that is not a multiple of the trigger level size. For example, if a peripheral
wished to send a 105 character message and the trigger level was 10 characters, the
CPU would receive 10 RDA interrupts resulting in the transfer of 100 characters and 1 to 5
CTI interrupts (depending on the service routine) resulting in the transfer of the remaining
5 characters.
[1] Values "0000" (see Table note 11–2), “0011”, “0101”, “0111”, “1000”, “1001”, “1010”,
“1011”,”1101”,”1110”,”1111” are reserved.
[2] For details see Section 11–4.10 “UART1 Line Status Register (U1LSR - 0xE001 0014, Read Only)”
[3] For details see Section 11–4.1 “UART1 Receiver Buffer Register (U1RBR - 0xE001 0000, when DLAB = 0
Read Only)”
[4] For details see Section 11–4.6 “UART1 Interrupt Identification Register (U1IIR - 0xE001 0008, Read Only)”
and Section 11–4.2 “UART1 Transmitter Holding Register (U1THR - 0xE001 0000, when DLAB = 0 Write
Only)”
The UART1 THRE interrupt (U1IIR[3:1] = 001) is a third level interrupt and is activated
when the UART1 THR FIFO is empty provided certain initialization conditions have been
met. These initialization conditions are intended to give the UART1 THR FIFO a chance to
fill up with data to eliminate many THRE interrupts from occurring at system start-up. The
initialization conditions implement a one character delay minus the stop bit whenever
THRE = 1 and there have not been at least two characters in the U1THR at one time since
the last THRE = 1 event. This delay is provided to give the CPU time to write data to
U1THR without a THRE interrupt to decode and service. A THRE interrupt is set
UM10114_3 © NXP B.V. 2008. All rights reserved.
immediately if the UART1 THR FIFO has held two or more characters at one time and
currently, the U1THR is empty. The THRE interrupt is reset when a U1THR write occurs or
a read of the U1IIR occurs and the THRE is the highest interrupt (U1IIR[3:1] = 001).
Table 161. UART1 FIFO Control Register (U1FCR - address 0xE001 0008) bit description
Bit Symbol Value Description Reset value
0 FIFO Enable 0 UART1 FIFOs are disabled. Must not be used in the application. 0
1 Active HIGH enable for both UART1 Rx and TX FIFOs and
U1FCR[7:1] access. This bit must be set for proper UART1
operation. Any transition on this bit will automatically clear the
UART1 FIFOs.
1 RX FIFO Reset 0 No impact on either of UART1 FIFOs. 0
1 Writing a logic 1 to U1FCR[1] will clear all bytes in UART1 Rx
FIFO and reset the pointer logic. This bit is self-clearing.
2 TX FIFO Reset 0 No impact on either of UART1 FIFOs. 0
1 Writing a logic 1 to U1FCR[2] will clear all bytes in UART1 TX
FIFO and reset the pointer logic. This bit is self-clearing.
5:3 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
7:6 RX Trigger These two bits determine how many receiver UART1 FIFO 0
Level characters must be written before an interrupt is activated.
00 trigger level 0 (1 character or 0x01).
01 trigger level 1 (4 characters or 0x04).
10 trigger level 2 (8 characters or 0x08).
11 trigger level 3 (14 characters or 0x0E).
Table 162. UART1 Line Control Register (U1LCR - address 0xE001 000C) bit description
Bit Symbol Value Description Reset value
1:0 Word Length 00 5 bit character length. 0
Select 01 6 bit character length.
10 7 bit character length.
11 8 bit character length.
2 Stop Bit Select 0 1 stop bit. 0
1 2 stop bits (1.5 if U1LCR[1:0]=00).
Table 162. UART1 Line Control Register (U1LCR - address 0xE001 000C) bit description
Bit Symbol Value Description Reset value
3 Parity Enable 0 Disable parity generation and checking. 0
1 Enable parity generation and checking.
5:4 Parity Select 00 Odd parity. Number of 1s in the transmitted character and the 0
attached parity bit will be odd.
01 Even Parity. Number of 1s in the transmitted character and the
attached parity bit will be even.
10 Forced "1" stick parity.
11 Forced "0" stick parity.
6 Break Control 0 Disable break transmission. 0
1 Enable break transmission. Output pin UART1 TXD is forced
to logic 0 when U1LCR[6] is active HIGH.
7 Divisor Latch 0 Disable access to Divisor Latches. 0
Access Bit (DLAB) 1 Enable access to Divisor Latches.
Table 163. UART1 Modem Control Register (U1MCR - address 0xE001 0010) bit description
Bit Symbol Value Description Reset value
0 DTR Control Source for modem output pin, DTR. This bit reads as 0 when 0
modem loopback mode is active.
1 RTS Control Source for modem output pin RTS. This bit reads as 0 when 0
modem loopback mode is active.
3:2 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
4 Loopback Mode The modem loopback mode provides a mechanism to perform 0
Select diagnostic loopback testing. Serial data from the transmitter is
connected internally to serial input of the receiver. Input pin,
RXD1, has no effect on loopback and output pin, TXD1 is held
in marking state. The four modem inputs (CTS, DSR, RI and
DCD) are disconnected externally. Externally, the modem
outputs (RTS, DTR) are set inactive. Internally, the four modem
outputs are connected to the four modem inputs. As a result of
these connections, the upper four bits of the U1MSR will be
driven by the lower four bits of the U1MCR rather than the four
modem inputs in normal mode. This permits modem status
interrupts to be generated in loopback mode by writing the
lower four bits of U1MCR.
0 Disable modem loopback mode.
1 Enable modem loopback mode.
5:3 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
6 RTSen Auto-RTS control bit. 0
0 Disable auto-RTS flow control.
1 Enable auto-RTS flow control.
Table 163. UART1 Modem Control Register (U1MCR - address 0xE001 0010) bit description
Bit Symbol Value Description Reset value
7 CTSen Auto-CTS control bit. 0
0 Disable auto-CTS flow control.
1 Enable auto-CTS flow control.
4.9.1.1 Auto-RTS
The auto-RTS function is enabled by setting the RTSen bit. Auto-RTS data flow control
originates in the U1RBR module and is linked to the programmed receiver FIFO trigger
level. If auto-RTS is enabled, the data-flow is controlled as follows:
When the receiver FIFO level reaches the programmed trigger level, RTS1 is deasserted
(to a high value). It is possible that the sending UART sends an additional byte after the
trigger level is reached (assuming the sending UART has another byte to send) because it
might not recognize the deassertion of RTS1 until after it has begun sending the additional
byte. RTS1 is automatically reasserted (to a low value) once the receiver FIFO has
reached the previous trigger level. The reassertion of RTS1 signals to the sending UART
to continue transmitting data.
If Auto-RTS mode is disabled, the RTS Control bit controls the RTS1 output of the
UART1. If Auto-RTS mode is enabled, hardware controls the RTS1 output, and the actual
value of RTS1 will be copied in the RTS Control bit of the UART1. As long as Auto-RTS is
enabled, the value of the RTS Control bit is read-only for software.
Example: Suppose the UART1 operating in type 550 has trigger level in U1FCR set to 0x2
then if Auto-RTS is enabled the UART1 will deassert the RTS1 output as soon as the
receive FIFO contains 8 bytes (Table 11–161). The RTS1 output will be reasserted as
soon as the receive FIFO hits the previous trigger level: 4 bytes.
UART1 Rx
~
~
RTS1 pin
UART1 Rx
FIFO read
~~
~ ~
4.9.1.2 Auto-CTS
The auto-CTS function is enabled by setting the CTSen bit. If auto-CTS is enabled the
transmitter circuitry in the U1TSR module checks CTS1 input before sending the next data
byte. When CTS1 is active (LOW), the transmitter sends the next byte. To stop the
transmitter from sending the following byte, CTS1 must be released before the middle of
the last stop bit that is currently being sent. In auto-CTS mode a change of the CTS1
signal does not trigger a modem status interrupt unless the CTS Interrupt Enable bit is set,
Delta CTS bit in the U1MSR will be set though. Table 11–164 lists the conditions for
generating a Modem Status interrupt.
The auto-CTS function reduces interrupts to the host system. When flow control is
enabled, a CTS1 state change does not trigger host interrupts because the device
automatically controls its own transmitter. Without auto-CTS, the transmitter sends any
data present in the transmit FIFO and a receiver overrun error can result. Figure 11–30
illustrates the auto-CTS functional timing.
UART1 TX
~
~
~
~
CTS1 pin
~
~
While starting transmission of the initial character the CTS1 signal is asserted.
Transmission will stall as soon as the pending transmission has completed. The UART will
continue transmitting a 1 bit as long as CTS1 is deasserted (HIGH). As soon as CTS1
gets deasserted transmission resumes and a start bit is sent followed by the data bits of
the next character.
4.10 UART1 Line Status Register (U1LSR - 0xE001 0014, Read Only)
The U1LSR is a read-only register that provides status information on the UART1 TX and
RX blocks.
Table 165. UART1 Line Status Register (U1LSR - address 0xE001 0014, read only) bit description
Bit Symbol Value Description Reset
value
0 Receiver Data U1LSR[0] is set when the U1RBR holds an unread character and is cleared when 0
Ready the UART1 RBR FIFO is empty.
(RDR) 0 U1RBR is empty.
1 U1RBR contains valid data.
1 Overrun Error The overrun error condition is set as soon as it occurs. An U1LSR read clears 0
(OE) U1LSR[1]. U1LSR[1] is set when UART1 RSR has a new character assembled and
the UART1 RBR FIFO is full. In this case, the UART1 RBR FIFO will not be
overwritten and the character in the UART1 RSR will be lost.
0 Overrun error status is inactive.
1 Overrun error status is active.
2 Parity Error When the parity bit of a received character is in the wrong state, a parity error 0
(PE) occurs. An U1LSR read clears U1LSR[2]. Time of parity error detection is
dependent on U1FCR[0].
Note: A parity error is associated with the character at the top of the UART1 RBR
FIFO.
0 Parity error status is inactive.
1 Parity error status is active.
3 Framing Error When the stop bit of a received character is a logic 0, a framing error occurs. An 0
(FE) U1LSR read clears U1LSR[3]. The time of the framing error detection is dependent
on U1FCR0. Upon detection of a framing error, the RX will attempt to resynchronize
to the data and assume that the bad stop bit is actually an early start bit. However, it
cannot be assumed that the next received byte will be correct even if there is no
Framing Error.
Note: A framing error is associated with the character at the top of the UART1 RBR
FIFO.
0 Framing error status is inactive.
1 Framing error status is active.
4 Break Interrupt When RXD1 is held in the spacing state (all 0’s) for one full character transmission 0
(BI) (start, data, parity, stop), a break interrupt occurs. Once the break condition has
been detected, the receiver goes idle until RXD1 goes to marking state (all 1’s). An
U1LSR read clears this status bit. The time of break detection is dependent on
U1FCR[0].
Note: The break interrupt is associated with the character at the top of the UART1
RBR FIFO.
0 Break interrupt status is inactive.
1 Break interrupt status is active.
5 Transmitter THRE is set immediately upon detection of an empty UART1 THR and is cleared on 1
Holding a U1THR write.
Register Empty 0 U1THR contains valid data.
(THRE)
1 U1THR is empty.
6 Transmitter TEMT is set when both U1THR and U1TSR are empty; TEMT is cleared when 1
Empty either the U1TSR or the U1THR contain valid data.
(TEMT) 0 U1THR and/or the U1TSR contains valid data.
1 U1THR and the U1TSR are empty.
Table 165. UART1 Line Status Register (U1LSR - address 0xE001 0014, read only) bit description
Bit Symbol Value Description Reset
value
7 Error in RX U1LSR[7] is set when a character with a RX error such as framing error, parity error 0
FIFO or break interrupt, is loaded into the U1RBR. This bit is cleared when the U1LSR
(RXFE) register is read and there are no subsequent errors in the UART1 FIFO.
0 U1RBR contains no UART1 RX errors or U1FCR[0]=0.
1 UART1 RBR contains at least one UART1 RX error.
Table 166. UART1 Modem Status Register (U1MSR - address 0xE001 0018) bit description
Bit Symbol Value Description Reset value
0 Delta CTS Set upon state change of input CTS. Cleared on an U1MSR read. 0
0 No change detected on modem input, CTS.
1 State change detected on modem input, CTS.
1 Delta DSR Set upon state change of input DSR. Cleared on an U1MSR read. 0
0 No change detected on modem input, DSR.
1 State change detected on modem input, DSR.
2 Trailing Edge RI Set upon LOW to HIGH transition of input RI. Cleared on an U1MSR read. 0
0 No change detected on modem input, RI.
1 LOW-to-HIGH transition detected on RI.
3 Delta DCD Set upon state change of input DCD. Cleared on an U1MSR read. 0
0 No change detected on modem input, DCD.
1 State change detected on modem input, DCD.
4 CTS Clear To Send State. Complement of input signal CTS. This bit is connected to 0
U1MCR[1] in modem loopback mode.
5 DSR Data Set Ready State. Complement of input signal DSR. This bit is connected 0
to U1MCR[0] in modem loopback mode.
6 RI Ring Indicator State. Complement of input RI. This bit is connected to 0
U1MCR[2] in modem loopback mode.
7 DCD Data Carrier Detect State. Complement of input DCD. This bit is connected to 0
U1MCR[3] in modem loopback mode.
Table 167. UART1 Scratch Pad Register (U1SCR - address 0xE001 0014) bit description
Bit Symbol Description Reset value
7:0 Pad A readable, writable byte. 0x00
Table 168. Auto-baud Control Register (U1ACR - 0xE001 0020) bit description
Bit Symbol Value Description Reset value
0 Start This bit is automatically cleared after auto-baud 0
completion.
0 Auto-baud stop (auto-baud is not running).
1 Auto-baud start (auto-baud is running).Auto-baud run
bit. This bit is automatically cleared after auto-baud
completion.
1 Mode Auto-baud mode select bit. 0
0 Mode 0.
1 Mode 1.
2 AutoRestart 0 No restart 0
1 Restart in case of time-out (counter restarts at next
UART1 Rx falling edge)
7:3 - NA Reserved, user software should not write ones to 0
reserved bits. The value read from a reserved bit is not
defined.
8 ABEOIntClr End of auto-baud interrupt clear bit (write only 0
accessible). Writing a 1 will clear the corresponding
interrupt in the U1IIR. Writing a 0 has no impact.
9 ABTOIntClr Auto-baud time-out interrupt clear bit (write only 0
accessible). Writing a 1 will clear the corresponding
interrupt in the U1IIR. Writing a 0 has no impact.
31:10 - NA Reserved, user software should not write ones to 0
reserved bits. The value read from a reserved bit is not
defined.
4.14 Auto-baud
The UART1 auto-baud function can be used to measure the incoming baud-rate based on
the ”AT" protocol (Hayes command). If enabled the auto-baud feature will measure the bit
time of the receive data stream and set the divisor latch registers U1DLM and U1DLL
accordingly.
Auto-baud is started by setting the U1ACR Start bit. Auto-baud can be stopped by clearing
the U1ACR Start bit. The Start bit will clear once auto-baud has finished and reading the
bit will return the status of auto-baud (pending/finished).
Two auto-baud measuring modes are available which can be selected by the U1ACR
Mode bit. In mode 0 the baud-rate is measured on two subsequent falling edges of the
UART1 Rx pin (the falling edge of the start bit and the falling edge of the least significant
bit). In mode 1 the baud-rate is measured between the falling edge and the subsequent
rising edge of the UART1 Rx pin (the length of the start bit).
The U1ACR AutoRestart bit can be used to automatically restart baud-rate measurement
if a time-out occurs (the rate measurement counter overflows). If this bit is set the rate
measurement will restart at the next falling edge of the UART1 Rx pin.
• The U1IIR ABTOInt interrupt will get set if the interrupt is enabled (U1IER ABToIntEn
is set and the auto-baud rate measurement counter overflows).
• The U1IIR ABEOInt interrupt will get set if the interrupt is enabled (U1IER ABEOIntEn
is set and the auto-baud has completed successfully).
(6)
2 × P CLK PCLK
ratemin = ------------------------- ≤ UART 1 baudrate ≤ ------------------------------------------------------------------------------------------------------------ = ratemax
16 × 2 15 16 × ( 2 + databits + paritybits + stopbits )
1. On U1ACR Start bit setting, the baud-rate measurement counter is reset and the
UART1 U1RSR is reset. The U1RSR baud rate is switch to the highest rate.
2. A falling edge on UART1 Rx pin triggers the beginning of the start bit. The rate
measuring counter will start counting PCLK cycles optionally pre-scaled by the
fractional baud-rate generator.
3. During the receipt of the start bit, 16 pulses are generated on the RSR baud input with
the frequency of the (fractional baud-rate pre-scaled) UART1 input clock,
guaranteeing the start bit is stored in the U1RSR.
4. During the receipt of the start bit (and the character LSB for mode = 0) the rate
counter will continue incrementing with the pre-scaled UART1 input clock (PCLK).
5. If Mode = 0 then the rate counter will stop on next falling edge of the UART1 Rx pin. If
Mode = 1 then the rate counter will stop on the next rising edge of the UART1 Rx pin.
6. The rate counter is loaded into U1DLM/U1DLL and the baud-rate will be switched to
normal operation. After setting the U1DLM/U1DLL the end of auto-baud interrupt
U1IIR ABEOInt will be set, if enabled. The U1RSR will now continue receiving the
remaining bits of the ”A/a" character.
start bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 parity stop
UART1 RX
start bit LSB of 'A' or 'a'
U1ACR start
rate counter
16xbaud_rate
16 cycles 16 cycles
start bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 parity stop
UART1 RX
start bit LSB of 'A' or 'a'
U1ACR start
rate counter
16xbaud_rate
16 cycles
Table 11–169 describes how to use TXEn bit in order to achieve software flow control.
Table 169. UART1 Transmit Enable Register (U1TER - address 0xE001 0030) bit description
Bit Symbol Description Reset value
6:0 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
7 TXEN When this bit is 1, as it is after a Reset, data written to the THR 1
is output on the TXD pin as soon as any preceding data has
been sent. If this bit cleared to 0 while a character is being sent,
the transmission of that character is completed, but no further
characters are sent until this bit is set again. In other words, a 0
in this bit blocks the transfer of characters from the THR or TX
FIFO into the transmit shift register. Software can clear this bit
when it detects that the a hardware-handshaking TX-permit
signal CTS has gone false, or it can clear this bit with software
handshaking, when it receives an XOFF character (DC3).
Software can set this bit again when it detects that the
TX-permit signal has gone true, or when it receives an XON
(DC1) character.
5. Architecture
The architecture of the UART1 is shown below in the block diagram.
The APB interface provides a communications link between the CPU or host and the
UART1.
The UART1 receiver block, U1RX, monitors the serial input line, RXD1, for valid input.
The UART1 RX Shift Register (U1RSR) accepts valid characters via RXD1. After a valid
character is assembled in the U1RSR, it is passed to the UART1 RX Buffer Register FIFO
to await access by the CPU or host via the generic host interface.
The UART1 transmitter block, U1TX, accepts data written by the CPU or host and buffers
the data in the UART1 TX Holding Register FIFO (U1THR). The UART1 TX Shift Register
(U1TSR) reads the data stored in the U1THR and assembles the data to transmit via the
serial output pin, TXD1.
The UART1 Baud Rate Generator block, U1BRG, generates the timing enables used by
the UART1 TX block. The U1BRG clock input source is the APB clock (PCLK). The main
clock is divided down per the divisor specified in the U1DLL and U1DLM registers. This
divided down clock is a 16x oversample clock, NBAUDOUT.
The modem interface contains registers U1MCR and U1MSR. This interface is
responsible for handshaking between a modem peripheral and the UART1.
The interrupt interface contains registers U1IER and U1IIR. The interrupt interface
receives several one clock wide enables from the U1TX and U1RX blocks.
Status information from the U1TX and U1RX is stored in the U1LSR. Control information
for the U1TX and U1RX is stored in the U1LCR.
MODEM U1TX
NTXRDY
TXD1
U1THR U1TSR
CTS
DSR U1MSR
RI
U1BRG
DCD
DTR
U1DLL NBAUDOUT
RTS
U1MCR
U1DLM RCLK
U1RX NRXRDY
INTERRUPT
RXD1
U1RBR U1RSR
U1INTR U1IER
U1IIR
U1FCR
U1LSR
U1SCR
U1LCR
PA[2:0]
PSEL
PSTB
PWRITE
APB
PD[7:0] INTERFACE DDIS
AR
MR
PCLK
For an overview of how LPC21xx and LPC22xx parts and versions are described in this
manual, see Section 1–2 “How to read this manual”.
2. Features
• Standard I2C compliant bus interfaces that may be configured as Master, Slave, or
Master/Slave.
• Arbitration between simultaneously transmitting masters without corruption of serial
data on the bus.
• Programmable clock to allow adjustment of I2C transfer rates.
• Bidirectional data transfer between masters and slaves.
• Serial clock synchronization allows devices with different bit rates to communicate via
one serial bus.
• Serial clock synchronization can be used as a handshake mechanism to suspend and
resume serial transfer.
• The I2C-bus may be used for test and diagnostic purposes.
3. Applications
Interfaces to external I2C standard parts, such as serial RAMs, LCDs, tone generators,
etc.
4. Description
A typical I2C-bus configuration is shown in Figure 12–33. Depending on the state of the
direction bit (R/W), two types of data transfers are possible on the I2C-bus:
• Data transfer from a master transmitter to a slave receiver. The first byte transmitted
by the master is the slave address. Next follows a number of data bytes. The slave
returns an acknowledge bit after each received byte.
• Data transfer from a slave transmitter to a master receiver. The first byte (the slave
address) is transmitted by the master. The slave then returns an acknowledge bit.
Next follows the data bytes transmitted by the slave to the master. The master returns
an acknowledge bit after all received bytes other than the last byte. At the end of the
last received byte, a “not acknowledge” is returned. The master device generates all
of the serial clock pulses and the START and STOP conditions. A transfer is ended
with a STOP condition or with a repeated START condition. Since a repeated START
condition is also the beginning of the next serial transfer, the I2C-bus will not be
released.
The LPC21xx/22xx I2C interface is byte oriented, and have four operating modes: master
transmitter mode, master receiver mode, slave transmitter mode and slave receiver
mode.
The I2C interface complies with entire I2C specification, supporting the ability to turn
power off to the LPC21xx/22xx without causing a problem with other devices on the same
I2C-bus. This is sometimes a useful capability, but intrinsically limits alternate uses for the
same pins if the I2C interface is not used.
pull-up pull-up
resistor resistor
SDA
I 2C bus
SCL
SDA SCL
5. Pin description
Table 170. I2C Pin Description
Pin Type Description
SDA Input/Output I2C serial data
SCL Input/Output I2C Serial clock
Remark: The SDA and SCL outputs are open-drain outputs for I2C-bus compliance.
The first byte transmitted contains the slave address of the receiving device (7 bits) and
the data direction bit. In this mode the data direction bit (R/W) should be 0 which means
Write. The first byte transmitted contains the slave address and Write bit. Data is
transmitted 8 bits at a time. After each byte is transmitted, an acknowledge bit is received.
START and STOP conditions are output to indicate the beginning and the end of a serial
transfer.
The I2C interface will enter master transmitter mode when software sets the STA bit. The
I2C logic will send the START condition as soon as the bus is free. After the START
condition is transmitted, the SI bit is set, and the status code in the I2STAT register is
0x08. This status code is used to vector to a state service routine which will load the slave
address and Write bit to the I2DAT register, and then clear the SI bit. SI is cleared by
writing a 1 to the SIC bit in the I2CONCLR register. The STA bit should be cleared after
writing the slave address.
When the slave address and R/W bit have been transmitted and an acknowledgment bit
has been received, the SI bit is set again, and the possible status codes now are 0x18,
0x20, or 0x38 for the master mode, or 0x68, 0x78, or 0xB0 if the slave mode was enabled
(by setting AA to 1). The appropriate actions to be taken for each of these status codes
are shown in Table 12–186 to Table 12–189.
When the slave address and data direction bit have been transmitted and an
acknowledge bit has been received, the SI bit is set, and the Status Register will show the
status code. For master mode, the possible status codes are 0x40, 0x48, or 0x38. For
slave mode, the possible status codes are 0x68, 0x78, or 0xB0. For details, refer to
Table 12–187.
002aaa930
After a repeated START condition, I2C may switch to the master transmitter mode.
Fig 36. A Master Receiver switches to Master Transmitter after sending Repeated START
I2EN must be set to 1 to enable the I2C function. AA bit must be set to 1 to acknowledge
its own slave address or the general call address. The STA, STO and SI bits are set to 0.
After I2ADR and I2CONSET are initialized, the I2C interface waits until it is addressed by
its own address or general address followed by the data direction bit. If the direction bit is
0 (W), it enters slave receiver mode. If the direction bit is 1 (R), it enters slave transmitter
mode. After the address and direction bit have been received, the SI bit is set and a valid
status code can be read from the Status register (I2STAT). Refer to Table 12–188 for the
status codes and actions.
002aaa933
The output for I2C is a special pad designed to conform to the I2C specification.
INPUT COMPARATOR
FILTER
SDA
OUTPUT
SHIFT REGISTER ACK
STAGE
I2DAT
8
APB BUS
BIT COUNTER/
ARBITRATION &
SYNC LOGIC PCLK
INPUT
FILTER TIMING &
CONTROL
LOGIC
SCL
interrupt
OUTPUT SERIAL CLOCK
STAGE GENERATOR
I2CONSET
I2CONCLR CONTROL REGISTER & SCL DUTY
I2SCLH CYCLE REGISTERS
I2SCLL
16
status STATUS
STATUS REGISTER
bus DECODER
I2STAT
8
7.3 Comparator
The comparator compares the received 7-bit slave address with its own slave address (7
most significant bits in I2ADR). It also compares the first received 8-bit byte with the
general call address (0x00). If an equality is found, the appropriate status bits are set and
an interrupt is requested.
Arbitration may also be lost in the master receiver mode. Loss of arbitration in this mode
can only occur while the I2C block is returning a “not acknowledge: (logic 1) to the bus.
Arbitration is lost when another device on the bus pulls this signal LOW. Since this can
occur only at the end of a serial byte, the I2C block generates no further clock pulses.
Figure 12–40 shows the arbitration procedure.
SCL line
1 2 3 4 8 9
ACK
The synchronization logic will synchronize the serial clock generator with the clock pulses
on the SCL line from another device. If two or more master devices generate clock pulses,
the “mark” duration is determined by the device that generates the shortest “marks,” and
the “space” duration is determined by the device that generates the longest “spaces”.
Figure 12–41 shows the synchronization procedure.
SDA line
SCL line
(2)
high low
period period
A slave may stretch the space duration to slow down the bus master. The space duration
may also be stretched for handshaking purposes. This can be done after each bit or after
a complete byte transfer. the I2C block will stretch the SCL space duration after a byte has
been transmitted or received and the acknowledge bit has been transferred. The serial
interrupt flag (SI) is set, and the stretching continues until the serial interrupt flag is
cleared.
The contents of the I2C control register may be read as I2CONSET. Writing to I2CONSET
will set bits in the I2C control register that correspond to ones in the value written.
Conversely, writing to I2CONCLR will clear bits in the I2C control register that correspond
to ones in the value written.
four modes of the I2C block are used. The 5-bit status code is latched into the five most
significant bits of the status register when the serial interrupt flag is set (by hardware) and
remains stable until the interrupt flag is cleared by software. The three least significant bits
of the status register are always zero. If the status code is used as a vector to service
routines, then the routines are displaced by eight address locations. Eight bytes of code is
sufficient for most of the service routines (see the software example in this section).
8. Register description
Each I2C interface contains 7 registers as shown in Table 12–173 below.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
Table 174. I2C Control Set register (I2CONSET - address 0xE001 C000) bit description
Bit Symbol Description Reset
value
1:0 - Reserved. User software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
2 AA Assert acknowledge flag. See the text below.
3 SI I2C interrupt flag. 0
4 STO STOP flag. See the text below. 0
5 STA START flag. See the text below. 0
6 I2EN I2C interface enable. See the text below. 0
7 - Reserved. User software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
I2EN I2C Interface Enable. When I2EN is 1, the I2C interface is enabled. I2EN can be
cleared by writing 1 to the I2ENC bit in the I2CONCLR register. When I2EN is 0, the I2C
interface is disabled.
When I2EN is “0”, the SDA and SCL input signals are ignored, the I2C block is in the “not
addressed” slave state, and the STO bit is forced to “0”.
I2EN should not be used to temporarily release the I2C-bus since, when I2EN is reset, the
I2C-bus status is lost. The AA flag should be used instead.
STA is the START flag. Setting this bit causes the I2C interface to enter master mode and
transmit a START condition or transmit a repeated START condition if it is already in
master mode.
When STA is 1 and the I2C interface is not already in master mode, it enters master mode,
checks the bus and generates a START condition if the bus is free. If the bus is not free, it
waits for a STOP condition (which will free the bus) and generates a START condition
after a delay of a half clock period of the internal clock generator. If the I2C interface is
already in master mode and data has been transmitted or received, it transmits a repeated
START condition. STA may be set at any time, including when the I2C interface is in an
addressed slave mode.
STA can be cleared by writing 1 to the STAC bit in the I2CONCLR register. When STA is
0, no START condition or repeated START condition will be generated.
If STA and STO are both set, then a STOP condition is transmitted on the I2C-bus if it the
interface is in master mode, and transmits a START condition thereafter. If the I2C
interface is in slave mode, an internal STOP condition is generated, but is not transmitted
on the bus.
STO is the STOP flag. Setting this bit causes the I2C interface to transmit a STOP
condition in master mode, or recover from an error condition in slave mode. When STO is
1 in master mode, a STOP condition is transmitted on the I2C-bus. When the bus detects
the STOP condition, STO is cleared automatically.
In slave mode, setting this bit can recover from an error condition. In this case, no STOP
condition is transmitted to the bus. The hardware behaves as if a STOP condition has
been received and it switches to “not addressed” slave receiver mode. The STO flag is
cleared by hardware automatically.
SI is the I2C Interrupt Flag. This bit is set when the I2C state changes. However, entering
state F8 does not set SI since there is nothing for an interrupt service routine to do in that
case.
While SI is set, the low period of the serial clock on the SCL line is stretched, and the
serial transfer is suspended. When SCL is high, it is unaffected by the state of the SI flag.
SI must be reset by software, by writing a 1 to the SIC bit in I2CONCLR register.
AA is the Assert Acknowledge Flag. When set to 1, an acknowledge (low level to SDA)
will be returned during the acknowledge clock pulse on the SCL line on the following
situations:
The AA bit can be cleared by writing 1 to the AAC bit in the I2CONCLR register. When AA
is 0, a not acknowledge (high level to SDA) will be returned during the acknowledge clock
pulse on the SCL line on the following situations:
1. A data byte has been received while the I2C is in the master receiver mode.
2. A data byte has been received while the I2C is in the addressed slave receiver mode.
Table 175. I2C Control Set register (I2CONCLR - address 0xE001 C018) bit description
Bit Symbol Description Reset
value
1:0 - Reserved. User software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
2 AAC Assert acknowledge Clear bit.
3 SIC I2C interrupt Clear bit. 0
4 - Reserved. User software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
5 STAC START flag Clear bit. 0
6 I2ENC I2C interface Disable bit. 0
7 - Reserved. User software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
AAC is the Assert Acknowledge Clear bit. Writing a 1 to this bit clears the AA bit in the
I2CONSET register. Writing 0 has no effect.
SIC is the I2C Interrupt Clear bit. Writing a 1 to this bit clears the SI bit in the I2CONSET
register. Writing 0 has no effect.
STAC is the Start flag Clear bit. Writing a 1 to this bit clears the STA bit in the I2CONSET
register. Writing 0 has no effect.
I2ENC is the I2C Interface Disable bit. Writing a 1 to this bit clears the I2EN bit in the
I2CONSET register. Writing 0 has no effect.
Table 176. I2C Status register (I2STAT - address 0xE001) bit description
Bit Symbol Description Reset value
2:0 - These bits are unused and are always 0. 0
7:3 Status These bits give the actual status information about the I2C interface. 0x1F
The three least significant bits are always 0. Taken as a byte, the status register contents
represent a status code. There are 26 possible status codes. When the status code is
0xF8, there is no relevant information available and the SI bit is not set. All other 25 status
codes correspond to defined I2C states. When any of these states entered, the SI bit will
be set. For a complete list of status codes, refer to tables from Table 12–186 to
Table 12–189.
Table 177. I2C Data register (I2DAT - address 0xE001 C008) bit description
Bit Symbol Description Reset value
7:0 Data This register holds data values that have been received, or are to 0
be transmitted.
Table 178. I2C Slave Address register (I2ADR - address 0xE001 C00C) bit description
Bit Symbol Description Reset value
0 GC General Call enable bit. 0
7:1 Address The I2C device address for slave mode. 0x00
8.6 I2C SCL High duty cycle register (I2SCLH - 0xE001 C010)
Table 179. I2C SCL High Duty Cycle register (I2SCLH - address 0xE001 C010) bit description
Bit Symbol Description Reset value
15:0 SCLH Count for SCL HIGH time period selection. 0x0004
UM10114_3 © NXP B.V. 2008. All rights reserved.
8.7 I2C SCL Low duty cycle register (I2SCLL - 0xE001 C014)
Table 180. I2C SCL Low Duty Cycle register (I2SCLL - address 0xE001 C014) bit description
Bit Symbol Description Reset value
15:0 SCLL Count for SCL LOW time period selection. 0x0004
8.8 Selecting the appropriate I2C data rate and duty cycle
Software must set values for the registers I2SCLH and I2SCLL to select the appropriate
data rate and duty cycle. I2SCLH defines the number of PCLK cycles for the SCL high
time, I2SCLL defines the number of PCLK cycles for the SCL low time. The frequency is
determined by the following formula (PCLK is the frequency of the peripheral bus APB):
(7)
PCLK
I 2 C bitfrequency = ---------------------------------------------------------
I2CSCLH + I2CSCLL
The values for I2SCLL and I2SCLH should not necessarily be the same. Software can set
different duty cycles on SCL by setting these two registers. For example, the I2C-bus
specification defines the SCL low time and high time at different values for a 400 kHz I2C
rate. The value of the register must ensure that the data rate is in the I2C data rate range
of 0 through 400 kHz. Each register value must be greater than or equal to 4.
Table 12–181 gives some examples of I2C-bus rates based on PCLK frequency and
I2SCLL and I2SCLH values.
• Master Transmitter
• Master Receiver
• Slave Receiver
UM10114_3 © NXP B.V. 2008. All rights reserved.
• Slave Transmitter
Data transfers in each mode of operation are shown in Figures 42 to 46. Table 12–182
lists abbreviations used in these figures when describing the I2C operating modes.
In Figures 42 to 46, circles are used to indicate when the serial interrupt flag is set. The
numbers in the circles show the status code held in the I2STAT register. At these points, a
service routine must be executed to continue or complete the serial transfer. These
service routines are not critical since the serial transfer is suspended until the serial
interrupt flag is cleared by software.
When a serial interrupt routine is entered, the status code in I2STAT is used to branch to
the appropriate service routine. For each status code, the required software action and
details of the following serial transfer are given in tables from Table 12–186 to
Table 12–190.
The I2C rate must also be configured in the I2SCLL and I2SCLH registers. I2EN must be
set to logic 1 to enable the I2C block. If the AA bit is reset, the I2C block will not
acknowledge its own slave address or the general call address in the event of another
device becoming master of the bus. In other words, if AA is reset, the I2C interface cannot
enter a slave mode. STA, STO, and SI must be reset.
The master transmitter mode may now be entered by setting the STA bit. The I2C logic will
now test the I2C-bus and generate a start condition as soon as the bus becomes free.
When a START condition is transmitted, the serial interrupt flag (SI) is set, and the status
code in the status register (I2STAT) will be 0x08. This status code is used by the interrupt
service routine to enter the appropriate state service routine that loads I2DAT with the
slave address and the data direction bit (SLA+W). The SI bit in I2CON must then be reset
before the serial transfer can continue.
When the slave address and the direction bit have been transmitted and an
acknowledgment bit has been received, the serial interrupt flag (SI) is set again, and a
number of status codes in I2STAT are possible. There are 0x18, 0x20, or 0x38 for the
master mode and also 0x68, 0x78, or 0xB0 if the slave mode was enabled (AA = logic 1).
The appropriate action to be taken for each of these status codes is detailed in
Table 12–186. After a repeated start condition (state 0x10). The I2C block may switch to
the master receiver mode by loading I2DAT with SLA+R).
When the slave address and the data direction bit have been transmitted and an
acknowledgment bit has been received, the serial interrupt flag (SI) is set again, and a
number of status codes in I2STAT are possible. These are 0x40, 0x48, or 0x38 for the
master mode and also 0x68, 0x78, or 0xB0 if the slave mode was enabled (AA = 1). The
appropriate action to be taken for each of these status codes is detailed in Table 12–187.
After a repeated start condition (state 0x10), the I2C block may switch to the master
transmitter mode by loading I2DAT with SLA+W.
The upper 7 bits are the address to which the I2C block will respond when addressed by a
master. If the LSB (GC) is set, the I2C block will respond to the general call address
(0x00); otherwise it ignores the general call address.
The I2C-bus rate settings do not affect the I2C block in the slave mode. I2EN must be set
to logic 1 to enable the I2C block. The AA bit must be set to enable the I2C block to
acknowledge its own slave address or the general call address. STA, STO, and SI must
be reset.
When I2ADR and I2CON have been initialized, the I2C block waits until it is addressed by
its own slave address followed by the data direction bit which must be “0” (W) for the I2C
block to operate in the slave receiver mode. After its own slave address and the W bit
have been received, the serial interrupt flag (SI) is set and a valid status code can be read
from I2STAT. This status code is used to vector to a state service routine. The appropriate
UM10114_3 © NXP B.V. 2008. All rights reserved.
action to be taken for each of these status codes is detailed in Table 104. The slave
receiver mode may also be entered if arbitration is lost while the I2C block is in the master
mode (see status 0x68 and 0x78).
If the AA bit is reset during a transfer, the I2C block will return a not acknowledge (logic 1)
to SDA after the next received data byte. While AA is reset, the I2C block does not
respond to its own slave address or a general call address. However, the I2C-bus is still
monitored and address recognition may be resumed at any time by setting AA. This
means that the AA bit may be used to temporarily isolate the I2C block from the I2C-bus.
MT
successful
transmission
S SLA W A DATA A P
to a Slave
Receiver
next transfer
started with a
S SLA W
Repeated Start
condition
Not 10H
Acknowledge
received after A P R
the Slave
address
20H
to Master
receive
Not
mode,
Acknowledge
A P entry
received after a
= MR
Data byte
30H
arbitration lost
in Slave other Master other Master
A OR A A OR A
address or continues continues
Data byte
38H 38H
arbitration lost
and other Master
A
addressed as continues
Slave
to corresponding
68H 78H B0H
states in Slave mode
MR
successful
transmission to S SLA R A DATA A DATA A P
a Slave
transmitter
next transfer
started with a
S SLA R
Repeated Start
condition
10H
Not Acknowledge
received after the A P W
Slave address
48H
to Master
transmit
mode, entry
= MT
arbitration lost in
Slave address or other Master other Master
A OR A A
Acknowledge bit continues continues
38H 38H
arbitration lost
other Master
and addressed A
continues
as Slave
to corresponding
68H 78H B0H states in Slave
mode
from Master to Slave
88H
arbitration lost as
Master and addressed A
as Slave
68H
reception of the
General Call address
GENERAL CALL A DATA A DATA A P OR S
and one or more Data
bytes
98h
arbitration lost as
Master and addressed
A
as Slave by General
Call
78h
DATA A any number of data bytes and their associated Acknowledge bits
arbitration lost as
Master and A
addressed as Slave
If the AA bit is reset during a transfer, the I2C block will transmit the last byte of the transfer
and enter state 0xC0 or 0xC8. The I2C block is switched to the not addressed slave mode
and will ignore the master receiver if it continues the transfer. Thus the master receiver
receives all 1s as serial data. While AA is reset, the I2C block does not respond to its own
slave address or a general call address. However, the I2C-bus is still monitored, and
address recognition may be resumed at any time by setting AA. This means that the AA
bit may be used to temporarily isolate the I2C block from the I2C-bus.
UM10114_3 © NXP B.V. 2008. All rights reserved.
If the I2C hardware detects a repeated START condition on the I2C-bus before generating
a repeated START condition itself, it will release the bus, and no interrupt request is
generated. If another master frees the bus by generating a STOP condition, the I2C block
will transmit a normal START condition (state 0x08), and a retry of the total serial data
transfer can commence.
If the STA flag in I2CON is set by the routines which service these states, then, if the bus
is free again, a START condition (state 0x08) is transmitted without intervention by the
CPU, and a retry of the total serial transfer can commence.
If the SDA line is obstructed by another device on the bus (e.g., a slave device out of bit
synchronization), the problem can be solved by transmitting additional clock pulses on the
SCL line (see Figure 12–48). The I2C hardware transmits additional clock pulses when
the STA flag is set, but no START condition can be generated because the SDA line is
pulled LOW while the I2C-bus is considered free. The I2C hardware attempts to generate
a START condition after every two additional clock pulses on the SCL line. When the SDA
line is eventually released, a normal START condition is transmitted, state 0x08 is
entered, and the serial transfer continues.
If a forced bus access occurs or a repeated START condition is transmitted while SDA is
obstructed (pulled LOW), the I2C hardware performs the same action as described above.
In each case, state 0x08 is entered after a successful START condition is transmitted and
normal serial transfer continues. Note that the CPU is not involved in solving these bus
hang-up problems.
The I2C hardware only reacts to a bus error when it is involved in a serial transfer either as
a master or an addressed slave. When a bus error is detected, the I2C block immediately
switches to the not addressed slave mode, releases the SDA and SCL lines, sets the
interrupt flag, and loads the status register with 0x00. This status code may be used to
vector to a state service routine which either attempts the aborted serial transfer again or
simply recovers from the error condition as shown in Table 12–190.
OTHER MASTER
S SLA W A DATA A S P S SLA
CONTINUES
time limit
STA flag
STO flag
SDA line
SCL line
start
condition
STA flag
(2) (3)
(1) (1)
SDA line
SCL line
start
condition
Fig 48. Recovering from a bus obstruction caused by a low level on SDA
9.15 Initialization
In the initialization example, the I2C block is enabled for both master and slave modes.
For each mode, a buffer is used for transmission and reception. The initialization routine
performs the following functions:
• I2ADR is loaded with the part’s own slave address and the general call bit (GC)
• The I2C interrupt enable and interrupt priority bits are set
• The slave mode is enabled by simultaneously setting the I2EN and AA bits in I2CON
and the serial clock frequency (for master modes) is defined by loading CR0 and CR1
in I2CON. The master routines must be started in the main program.
The I2C hardware now begins checking the I2C-bus for its own slave address and general
call. If the general call or the own slave address is detected, an interrupt is requested and
I2STAT is loaded with the appropriate state information.
1. Load I2ADR with own Slave Address, enable general call recognition if needed.
2. Enable I2C interrupt.
3. Write 0x44 to I2CONSET to set the I2EN and AA bits, enabling Slave functions. For
Master only functions, write 0x40 to I2CONSET.
1. Load I2DAT with first data byte from Master Transmit buffer.
2. Write 0x04 to I2CONSET to set the AA bit.
3. Write 0x08 to I2CONCLR to clear the SI flag.
4. Increment Master Transmit buffer pointer.
5. Exit
1. Decrement the Master data counter, skip to step 5 if not the last data byte.
2. Write 0x14 to I2CONSET to set the STO and AA bits.
3. Write 0x08 to I2CONCLR to clear the SI flag.
4. Exit
5. Load I2DAT with next data byte from Master Transmit buffer.
6. Write 0x04 to I2CONSET to set the AA bit.
7. Write 0x08 to I2CONCLR to clear the SI flag.
8. Increment Master Transmit buffer pointer
9. Exit
8. Exit
1. Read data byte from I2DAT into the Slave Receive buffer.
2. Decrement the Slave data counter, skip to step 5 if not the last data byte.
3. Write 0x0C to I2CONCLR to clear the SI flag and the AA bit.
4. Exit.
5. Write 0x04 to I2CONSET to set the AA bit.
6. Write 0x08 to I2CONCLR to clear the SI flag.
7. Increment Slave Receive buffer pointer.
8. Exit
1. Read data byte from I2DAT into the Slave Receive buffer.
2. Write 0x0C to I2CONCLR to clear the SI flag and the AA bit.
3. Exit
1. Load I2DAT from Slave Transmit buffer with first data byte.
2. Write 0x04 to I2CONSET to set the AA bit.
3. Write 0x08 to I2CONCLR to clear the SI flag.
4. Set up Slave Transmit mode data buffer.
5. Increment Slave Transmit buffer pointer.
6. Exit
1. Load I2DAT from Slave Transmit buffer with first data byte.
2. Write 0x24 to I2CONSET to set the STA and AA bits.
3. Write 0x08 to I2CONCLR to clear the SI flag.
4. Set up Slave Transmit mode data buffer.
5. Increment Slave Transmit buffer pointer.
6. Exit
Remark: For enhanced parts only, the SPI1 interface can be selected as an SSP interface
using the same pins as SPI1 (see Section 14–1).
For an overview of how LPC21xx and LPC22xx parts and versions are described in this
manual, see Section 1–2 “How to read this manual”.
2. Features
• Two complete and independent SPI controllers
• Compliant with Serial Peripheral Interface (SPI) specification
• Synchronous, serial, and full duplex communication
• Combined SPI master and slave
• Maximum data bit rate of one eighth of the input clock rate
• 8 bit only or 8 to 16 bit per transfer
3. Description
In the first part of the timing diagram, note two points. First, the SPI is illustrated with
CPOL set to both 0 and 1. The second point to note is the activation and de-activation of
the SSEL signal. When CPHA = 0, the SSEL signal will always go inactive between data
transfers. This is not guaranteed when CPHA = 1 (the signal can remain active).
SCK (CPOL = 0)
SCK (CPOL = 1)
SSEL
CPHA = 0
Cycle # CPHA = 0 1 2 3 4 5 6 7 8
MOSI (CPHA = 0) BIT 1 BIT 2 BIT 3 BIT 4 BIT 5 BIT 6 BIT 7 BIT 8
MISO (CPHA = 0) BIT 1 BIT 2 BIT 3 BIT 4 BIT 5 BIT 6 BIT 7 BIT 8
CPHA = 1
Cycle # CPHA = 1 1 2 3 4 5 6 7 8
MOSI (CPHA = 1) BIT 1 BIT 2 BIT 3 BIT 4 BIT 5 BIT 6 BIT 7 BIT 8
MISO (CPHA = 1) BIT 1 BIT 2 BIT 3 BIT 4 BIT 5 BIT 6 BIT 7 BIT 8
The data and clock phase relationships are summarized in Table 13–192. This table
summarizes the following for each setting of CPOL and CPHA.
The definition of when an 8 bit transfer starts and stops is dependent on whether a device
is a master or a slave, and the setting of the CPHA variable.
When a device is a master, the start of a transfer is indicated by the master having a byte
of data that is ready to be transmitted. At this point, the master can activate the clock, and
begin the transfer. The transfer ends when the last clock cycle of the transfer is complete.
When a device is a slave, and CPHA is set to 0, the transfer starts when the SSEL signal
goes active, and ends when SSEL goes inactive. When a device is a slave, and CPHA is
set to 1, the transfer starts on the first clock edge when the slave is selected, and ends on
the last clock edge where data is sampled.
The SPI control register contains a number of programmable bits used to control the
function of the SPI block. The settings for this register must be set up prior to a given data
transfer taking place.
The SPI status register contains read only bits that are used to monitor the status of the
SPI interface, including normal functions, and exception conditions. The primary purpose
of this register is to detect completion of a data transfer. This is indicated by the SPIF bit.
The remaining bits in the register are exception condition indicators. These exceptions will
be described later in this section.
The SPI data register is used to provide the transmit and receive data bytes. An internal
shift register in the SPI block logic is used for the actual transmission and reception of the
serial data. Data is written to the SPI data register for the transmit case. There is no buffer
between the data register and the internal shift register. A write to the data register goes
directly into the internal shift register. Therefore, data should only be written to this register
when a transmit is not currently in progress. Read data is buffered. When a transfer is
complete, the receive data is transferred to a single byte data buffer, where it is later read.
A read of the SPI data register returns the value of the read data buffer.
The SPI clock counter register controls the clock rate when the SPI block is in master
mode. This needs to be set prior to a transfer taking place, when the SPI block is a
master. This register has no function when the SPI block is a slave.
The I/Os for this implementation of SPI are standard CMOS I/Os. The open drain SPI
option is not implemented in this design. When a device is set up to be a slave, its I/Os are
only active when it is selected by the SSEL signal being active.
1. Set the SPI clock counter register to the desired clock rate.
2. Set the SPI control register to the desired settings.
3. Write the data to transmitted to the SPI data register. This write starts the SPI data
transfer.
4. Wait for the SPIF bit in the SPI status register to be set to 1. The SPIF bit will be set
after the last cycle of the SPI data transfer.
5. Read the SPI status register.
6. Read the received data from the SPI data register (optional).
7. Go to step 3 if more data is required to transmit.
Note: A read or write of the SPI data register is required in order to clear the SPIF status
bit. Therefore, if the optional read of the SPI data register does not take place, a write to
this register is required in order to clear the SPIF status bit.
Note: A read or write of the SPI data register is required in order to clear the SPIF status
bit. Therefore, at least one of the optional reads or writes of the SPI data register must
take place, in order to clear the SPIF status bit.
4. Pin description
Table 193. SPI pin description
Pin Type Pin description
name
SCK0/ Input/ Serial Clock. The SPI is a clock signal used to synchronize the transfer of data across the SPI
SCK1 Output interface. The SPI is always driven by the master and received by the slave. The clock is
programmable to be active high or active low. The SPI is only active during a data transfer. Any other
time, it is either in its inactive state, or tri-stated.
SSEL0/ Input Slave Select. The SPI slave select signal is an active low signal that indicates which slave is currently
SSEL1 selected to participate in a data transfer. Each slave has its own unique slave select signal input. The
SSEL must be low before data transactions begin and normally stays low for the duration of the
transaction. If the SSEL signal goes high any time during a data transfer, the transfer is considered to
be aborted. In this event, the slave returns to idle, and any data that was received is thrown away.
There are no other indications of this exception. This signal is not directly driven by the master. It could
be driven by a simple general purpose I/O under software control.
Remark: Flashless LPC22xx and all legacy parts (/00 and no suffix) configured to operate as a
SPI master MUST select SSEL functionality on an appropriate pin and have HIGH level on this
pin in order to act as a master.
For all other LPC21xx and LPC22xx parts, the SSEL pin can be used for a different function when the
SPI interface is only used in Master mode. For example, the pin hosting the SSEL function can be
configured as an output digital GPIO pin and can be used to select one of the SPI slaves.
MISO0/ Input/ Master In Slave Out. The MISO signal is a unidirectional signal used to transfer serial data from the
MISO1 Output slave to the master. When a device is a slave, serial data is output on this signal. When a device is a
master, serial data is input on this signal. When a slave device is not selected, the slave drives the
signal high impedance.
MOSI0/ Input/ Master Out Slave In. The MOSI signal is a unidirectional signal used to transfer serial data from the
MOSI1 Output master to the slave. When a device is a master, serial data is output on this signal. When a device is a
slave, serial data is input on this signal.
5. Register description
The SPI contains 5 registers as shown in Table 13–194. All registers are byte, half word
and word accessible.
[1] Reset Value refers to the data stored in used bits only. It does not include the content of reserved bits.
Table 195. SPI Control Register (S0SPCR - address 0xE002 0000 and S1SPCR - address
0xE003 0000) bit description
Bit Symbol Value Description Reset
value
1:0 - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is not
defined.
2 BitEnable[1] 0 The SPI controller sends and receives 8 bits of data per 0
transfer.
1 The SPI controller sends and receives the number of bits
selected by bits 11:8.
3 CPHA 0 Clock phase control determines the relationship between 0
the data and the clock on SPI transfers, and controls
when a slave transfer is defined as starting and ending.
Data is sampled on the first clock edge of SCK. A transfer
starts and ends with activation and deactivation of the
SSEL signal.
1 Data is sampled on the second clock edge of the SCK. A
transfer starts with the first clock edge, and ends with the
last sampling edge when the SSEL signal is active.
4 CPOL 0 Clock polarity control. 0
SCK is active high.
1 SCK is active low.
Table 195. SPI Control Register (S0SPCR - address 0xE002 0000 and S1SPCR - address
0xE003 0000) bit description
Bit Symbol Value Description Reset
value
5 MSTR 0 Master mode select. 0
The SPI operates in Slave mode.
1 The SPI operates in Master mode.
6 LSBF 0 LSB First controls which direction each byte is shifted 0
when transferred.
SPI data is transferred MSB (bit 7) first.
1 SPI data is transferred LSB (bit 0) first.
7 SPIE 0 Serial peripheral interrupt enable. 0
SPI interrupts are inhibited.
1 A hardware interrupt is generated each time the SPIF or
MODF bits are activated.
11:8 BITS[1] When bit 2 of this register is 1, this field controls the 0000
number of bits per transfer:
1000 8 bits per transfer
1001 9 bits per transfer
1010 10 bits per transfer
1011 11 bits per transfer
1100 12 bits per transfer
1101 13 bits per transfer
1110 14 bits per transfer
1111 15 bits per transfer
0000 16 bits per transfer
15:12 - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is not
defined.
Table 196. SPI Status Register (S0SPSR - address 0xE002 0004 and S1SPSR - address
0xE003 0004) bit description
Bit Symbol Description Reset value
2:0 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
3 ABRT Slave abort. When 1, this bit indicates that a slave abort has 0
occurred. This bit is cleared by reading this register.
4 MODF Mode fault. when 1, this bit indicates that a Mode fault error has 0
occurred. This bit is cleared by reading this register, then writing
the SPI control register.
Table 196. SPI Status Register (S0SPSR - address 0xE002 0004 and S1SPSR - address
0xE003 0004) bit description
Bit Symbol Description Reset value
5 ROVR Read overrun. When 1, this bit indicates that a read overrun has 0
occurred. This bit is cleared by reading this register.
6 WCOL Write collision. When 1, this bit indicates that a write collision has 0
occurred. This bit is cleared by reading this register, then
accessing the SPI data register.
7 SPIF SPI transfer complete flag. When 1, this bit indicates when a SPI 0
data transfer is complete. When a master, this bit is set at the
end of the last cycle of the transfer. When a slave, this bit is set
on the last data sampling edge of the SCK. This bit is cleared by
first reading this register, then accessing the SPI data register.
Note: This is not the SPI interrupt flag. This flag is found in the
SPINT register.
5.3 SPI Data Register (S0SPDR - 0xE002 0008, S1SPDR - 0xE003 0008)
This bi-directional data register provides the transmit and receive data for the SPI.
Transmit data is provided to the SPI by writing to this register. Data received by the SPI
can be read from this register. When a master, a write to this register will start a SPI data
transfer. Writes to this register will be blocked from when a data transfer starts to when the
SPIF status bit is set, and the status register has not been read.
Table 197. SPI Data Register (S0SPDR - address 0xE002 0008, S1SPDR - address
0xE003 0008) bit description
Bit Symbol Description Reset value
15:0 Data SPI Bi-directional data port. 0
5.4 SPI Clock Counter Register (S0SPCCR - 0xE002 000C and S1SPCCR -
0xE003 000C)
This register controls the frequency of a master’s SCK. The register indicates the number
of SPI peripheral clock cycles that make up an SPI clock.
In Master mode, this register must be an even number greater than or equal to 8.
Violations of this can result in unpredictable behavior. The SPI SCK rate may be
calculated as: PCLK / SnSPCCR value. The PCLK rate is CCLK /APB divider rate as
determined by the APBDIV register contents (see Table 6–76).
In Slave mode, the SPI clock rate provided by the master must not exceed 1/8 of the
peripheral clock. The content of the S0SPCCR register is not relevant.
Table 198. SPI Clock Counter Register (S0SPCCR - address 0xE002 000C and S1SPCCR -
address 0xE003 000C) bit description
Bit Symbol Description Reset value
7:0 Counter SPI Clock counter setting. 0x00
Table 199. SPI Interrupt Register (S0SPINT - address 0xE002 001C and S1SPINT - address
0xE003 001C) bit description
Bit Symbol Description Reset
value
0 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
7:1 SPI Interrupt SPI interrupt flag. Set by the SPI interface to generate an interrupt. 0
Cleared by writing a 1 to this bit.
Note: This bit will be set once when SPIE = 1 and at least one of
SPIF and MODF bits changes from 0 to 1. However, only when the
SPI Interrupt bit is set and SPI Interrupt is enabled in the VIC, SPI
based interrupt can be processed by interrupt handling software.
6. Architecture
The block diagram of the SPI solution implemented in SPI0 and SPI1 interface is shown in
the Figure 13–50.
MOSI_IN
MOSI_OUT
MISO_IN
MISO_OUT
SCK_IN
SCK_OUT
SS_IN
SPI CLOCK
GENERATOR &
SPI Interrupt DETECTOR
SPI REGISTER
APB Bus INTERFACE
SCK_OUT_EN
MOSI_OUT_EN
MISO_OUT_EN
OUTPUT
ENABLE
LOGIC
The SSP interface shares its pins with the SPI1 interface. To select the SSP peripheral,
select the PCSSP bit in the PCONP register (Section 6–10.3). Note that the default
interface on Reset is the SPI1 interface.
For an overview of how LPC21xx and LPC22xx parts and versions are described in this
manual, see Section 1–2 “How to read this manual”.
2. Features
• Compatible with Motorola SPI, 4-wire TI SSI, and National Semiconductor Microwire
buses
• Synchronous serial communication
• Master or slave operation
• 8-frame FIFOs for both transmit and receive
• 4 to 16 bit frame
3. Description
The SSP is a Synchronous Serial Port (SSP) controller capable of operation on an SPI,
4-wire SSI, or Microwire bus. It can interact with multiple masters and slaves on the bus.
Only a single master and a single slave can communicate on the bus during a given data
transfer. Data transfers are in principle full duplex, with frames of 4 to 16 bits of data
flowing from the master to the slave and from the slave to the master. In practice it is often
the case that only one of these data flows carries meaningful data.
While the SSP and SPI1 peripherals share the same physical pins, it is not possible to
have both of these two peripherals active at the same time. Bit 10 (PSPI1) and bit 21
(PSSP) residing in the Section 6–10.3 control the activity of the SPI1 and SSP module
respectively. The corresponding peripheral is enabled when its control bit is 1, and it is
disabled when the control bit is 0. After power-on reset, SPI1 is enabled, maintaining the
backward compatibility with other NXP LPC2000 microcontrollers. Any attempt to write 1
to PSPI1 and PSSP bits at the same time will result in PSPI = 1 and PSSP = 0.
To switch on the fly from SPI1 to SSP and back, first disable the active peripheral’s
interrupt(s), both in the peripheral’s and VIC’s registers. Next, clear all pending interrupt
flags (if any set). Only then, the currently enabled peripheral can be turned off in the
PCONP register. After this, the other serial interface can be enabled.
It is important to disable the currently used peripheral by clearing its bit in the PCONP
register only at the very end of the peripheral’s shut-down procedure. Otherwise, having 0
in a bit in PCONP will disable all clocks from coming into the peripheral controlled by that
bit. Then, reading from the peripheral’s registers will not yield valid data and write and/or
modify access will be banned, i.e. no content can be changed. Consequently, if any of the
interrupt triggering flags are left active in the peripheral’s register(s) when the peripheral is
disabled via the PCONP, the invoked ISR may not be able to successfully service pending
interrupt, and the same interrupt may keep overloading the microcontroller even though its
peripheral is disabled.
4. Bus description
CLK
FS
DX/DR MSB LSB
4 to 16 bits
CLK
FS
DX/DR MSB LSB MSB LSB
4 to 16 bits 4 to 16 bits
For device configured as a master in this mode, CLK and FS are forced LOW, and the
transmit data line DX is tristated whenever the SSP is idle. Once the bottom entry of the
transmit FIFO contains data, FS is pulsed HIGH for one CLK period. The value to be
transmitted is also transferred from the transmit FIFO to the serial shift register of the
transmit logic. On the next rising edge of CLK, the MSB of the 4 to 16-bit data frame is
shifted out on the DX pin. Likewise, the MSB of the received data is shifted onto the DR
pin by the off-chip serial slave device.
Both the SSP and the off-chip serial slave device then clock each data bit into their serial
shifter on the falling edge of each CLK. The received data is transferred from the serial
shifter to the receive FIFO on the first rising edge of CLK after the LSB has been latched.
The CPHA control bit selects the clock edge that captures data and allows it to change
state. It has the most impact on the first bit transmitted by either allowing or not allowing a
clock transition before the first data capture edge. When the CPHA phase control bit is
LOW, data is captured on the first clock edge transition. If the CPHA clock phase control
bit is HIGH, data is captured on the second clock edge transition.
SCK
SSEL
MSB LSB
MOSI
4 to 16 bits
SCK
SSEL
4 to 16 bits 4 to 16 bits
One half SCK period later, valid master data is transferred to the MOSI pin. Now that both
the master and slave data have been set, the SCK master clock pin goes HIGH after one
further half SCK period.
The data is now captured on the rising and propagated on the falling edges of the SCK
signal.
In the case of a single word transmission, after all bits of the data word have been
transferred, the SSEL line is returned to its idle HIGH state one SCK period after the last
bit has been captured.
However, in the case of continuous back-to-back transmissions, the SSEL signal must be
pulsed HIGH between each data word transfer. This is because the slave select pin
freezes the data in its serial peripheral register and does not allow it to be altered if the
CPHA bit is logic zero. Therefore the master device must raise the SSEL pin of the slave
device between each data transfer to enable the serial peripheral data write. On
completion of the continuous transfer, the SSEL pin is returned to its idle state one SCK
period after the last bit has been captured.
SCK
SSEL
MSB LSB
MOSI
MISO Q MSB LSB Q
4 to 16 bits
Data is then captured on the falling edges and propagated on the rising edges of the SCK
signal.
In the case of a single word transfer, after all bits have been transferred, the SSEL line is
returned to its idle HIGH state one SCK period after the last bit has been captured.
For continuous back-to-back transfers, the SSEL pin is held LOW between successive
data words and termination is the same as that of the single word transfer.
SCK
SSEL
MSB LSB
MOSI
4 to 16 bits
SCK
SSEL
4 to 16 bits 4 to 16 bits
One half period later, valid master data is transferred to the MOSI line. Now that both the
master and slave data have been set, the SCK master clock pin becomes LOW after one
further half SCK period. This means that data is captured on the falling edges and be
propagated on the rising edges of the SCK signal.
In the case of a single word transmission, after all bits of the data word are transferred, the
SSEL line is returned to its idle HIGH state one SCK period after the last bit has been
captured.
However, in the case of continuous back-to-back transmissions, the SSEL signal must be
pulsed HIGH between each data word transfer. This is because the slave select pin
freezes the data in its serial peripheral register and does not allow it to be altered if the
CPHA bit is logic zero. Therefore the master device must raise the SSEL pin of the slave
device between each data transfer to enable the serial peripheral data write. On
completion of the continuous transfer, the SSEL pin is returned to its idle state one SCK
period after the last bit has been captured.
SCK
SSEL
MSB LSB
MOSI
MISO Q MSB LSB Q
4 to 16 bits
After all bits have been transferred, in the case of a single word transmission, the SSEL
line is returned to its idle HIGH state one SCK period after the last bit has been captured.
For continuous back-to-back transmissions, the SSEL pins remains in its active LOW
state, until the final bit of the last word has been captured, and then returns to its idle state
as described above. In general, for continuous back-to-back transfers the SSEL pin is
held LOW between successive data words and termination is the same as that of the
single word transfer.
SK
CS
MSB LSB
SO
8 bit control
SI 0 MSB LSB
4 to 16 bits
output data
Microwire format is very similar to SPI format, except that transmission is half-duplex
instead of full-duplex, using a master-slave message passing technique. Each serial
transmission begins with an 8-bit control word that is transmitted from the SSP to the
off-chip slave device. During this transmission, no incoming data is received by the SSP.
After the message has been sent, the off-chip slave decodes it and, after waiting one
serial clock after the last bit of the 8-bit control message has been sent, responds with the
required data. The returned data is 4 to 16 bits in length, making the total frame length
anywhere from 13 to 25 bits.
The off-chip serial slave device latches each control bit into its serial shifter on the rising
edge of each SK. After the last bit is latched by the slave device, the control byte is
decoded during a one clock wait-state, and the slave responds by transmitting data back
to the SSP. Each bit is driven onto SI line on the falling edge of SK. The SSP in turn
latches each bit on the rising edge of SK. At the end of the frame, for single transfers, the
CS signal is pulled HIGH one clock period after the last bit has been latched in the receive
serial shifter, that causes the data to be transferred to the receive FIFO.
Note: The off-chip slave device can tristate the receive line either on the falling edge of
SK after the LSB has been latched by the receive shiftier, or when the CS pin goes HIGH.
For continuous transfers, data transmission begins and ends in the same manner as a
single transfer. However, the CS line is continuously asserted (held LOW) and
transmission of data occurs back to back. The control byte of the next frame follows
directly after the LSB of the received data from the current frame. Each of the received
values is transferred from the receive shifter on the falling edge SK, after the LSB of the
frame has been latched into the SSP.
SK
CS
4 to 16 bits 4 to 16 bits
output data output data
Figure 14–58 illustrates these setup and hold time requirements. With respect to the SK
rising edge on which the first bit of receive data is to be sampled by the SSP slave, CS
must have a setup of at least two times the period of SK on which the SSP operates. With
respect to the SK rising edge previous to this edge, CS must have a hold of at least one
SK period.
tSETUP=2*tSK
t HOLD= tSK
SK
CS
SI
5. Register description
The SSP contains 9 registers as shown in Table 14–201. All registers are byte, half word
and word accessible.
[1] Reset Value refers to the data stored in used bits only. It does not include reserved bits’ content.
Table 202: SSP Control Register 0 (SSPCR0 - address 0xE005 C000) bit description
Bit Symbol Value Description Reset
value
3:0 DSS Data Size Select. This field controls the number of bits 0000
transferred in each frame. Values 0000-0010 are not
supported and should not be used.
0011 4 bit transfer
0100 5 bit transfer
0101 6 bit transfer
0110 7 bit transfer
0111 8 bit transfer
1000 9 bit transfer
1001 10 bit transfer
1010 11 bit transfer
1011 12 bit transfer
1100 13 bit transfer
1101 14 bit transfer
1110 15 bit transfer
1111 16 bit transfer
5:4 FRF Frame Format. 00
00 SPI
01 SSI
10 Microwire
11 This combination is not supported and should not be used.
Table 202: SSP Control Register 0 (SSPCR0 - address 0xE005 C000) bit description
Bit Symbol Value Description Reset
value
6 CPOL 0 Clock Out Polarity. This bit is only used in SPI mode. 0
SSP controller captures serial data on the first clock transition
of the frame, that is, the transition away from the inter-frame
state of the clock line.
1 SSP controller captures serial data on the second clock
transition of the frame, that is, the transition back to the
inter-frame state of the clock line.
7 CPHA 0 Clock Out Phase. This bit is only used in SPI mode. 0
SSP controller maintains the bus clock low between frames.
1 SSP controller maintains the bus clock high between frames.
15:8 SCR Serial Clock Rate. The number of prescaler-output clocks per 0x00
bit on the bus, minus one. Given that CPSDVR is the prescale
divider, and the VPB clock PCLK clocks the prescaler, the bit
frequency is PCLK / (CPSDVSR * [SCR+1]).
Table 203: SSP Control Register 1 (SSPCR1 - address 0xE005 C004) bit description
Bit Symbol Value Description Reset
Value
0 LBM 0 Loop Back Mode. 0
During normal operation.
1 Serial input is taken from the serial output (MOSI or MISO)
rather than the serial input pin (MISO or MOSI
respectively).
1 SSE 0 SSP Enable. 0
The SSP controller is disabled.
1 The SSP controller will interact with other devices on the
serial bus. Software should write the appropriate control
information to the other SSP registers and interrupt
controller registers, before setting this bit.
2 MS 0 Master/Slave Mode.This bit can only be written when the 0
SSE bit is 0.
The SSP controller acts as a master on the bus, driving the
SCLK, MOSI, and SSEL lines and receiving the MISO line.
1 The SSP controller acts as a slave on the bus, driving
MISO line and receiving SCLK, MOSI, and SSEL lines.
3 SOD Slave Output Disable. This bit is relevant only in slave 0
mode (MS = 1). If it is 1, this blocks this SSP controller
from driving the transmit data line (MISO).
7:4 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Table 204: SSP Data Register (SSPDR - address 0xE005 C008) bit description
Bit Symbol Description Reset value
15:0 DATA Write: software can write data to be sent in a future frame to this 0
register whenever the TNF bit in the Status register is 1,
indicating that the Tx FIFO is not full. If the Tx FIFO was
previously empty and the SSP controller is not busy on the bus,
transmission of the data will begin immediately. Otherwise the
data written to this register will be sent as soon as all previous
data has been sent (and received). If the data length is less than
16 bits, software must right-justify the data written to this register.
Read: software can read data from this register whenever the
RNE bit in the Status register is 1, indicating that the Rx FIFO is
not empty. When software reads this register, the SSP controller
returns data from the least recent frame in the Rx FIFO. If the
data length is less than 16 bits, the data is right-justified in this
field with higher order bits filled with 0s.
Table 205: SSP Status Register (SSPSR - address 0xE005 C00C) bit description
Bit Symbol Description Reset value
0 TFE Transmit FIFO Empty. This bit is 1 is the Transmit FIFO is 1
empty, 0 if not.
1 TNF Transmit FIFO Not Full. This bit is 0 if the Tx FIFO is full, 1 if not. 1
2 RNE Receive FIFO Not Empty. This bit is 0 if the Receive FIFO is 0
empty, 1 if not.
3 RFF Receive FIFO Full. This bit is 1 if the Receive FIFO is full, 0 if 0
not.
4 BSY Busy. This bit is 0 if the SSP controller is idle, or 1 if it is 0
currently sending/receiving a frame and/or the Tx FIFO is not
empty.
7:5 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
Table 206: SSP Clock Prescale Register (SSPCPSR - address 0xE005 C010) bit description
Bit Symbol Description Reset value
7:0 CPSDVSR This even value between 2 and 254, by which PCLK is divided 0
to yield the prescaler output clock. Bit 0 always reads as 0.
Important: the SSPCPSR value must be properly initialized or the SSP controller will not
be able to transmit data correctly.
UM10114_3 © NXP B.V. 2008. All rights reserved.
In Slave mode, the SSP clock rate provided by the master must not exceed 1/12 of the
peripheral clock. The content of the SSPCPSR register is not relevant.
Table 207: SSP Interrupt Mask Set/Clear Register (SSPIMSC - address 0xE005 CF014) bit
description
Bit Symbol Description Reset value
0 RORIM Software should set this bit to enable interrupt when a Receive 0
Overrun occurs, that is, when the Rx FIFO is full and another
frame is completely received. The ARM spec implies that the
preceding frame data is overwritten by the new frame data
when this occurs.
1 RTIM Software should set this bit to enable interrupt when a Receive 0
Timeout condition occurs. A Receive Timeout occurs when the
Rx FIFO is not empty, and no new data has been received, nor
has data been read from the FIFO, for 32 bit times.
2 RXIM Software should set this bit to enable interrupt when the Rx 0
FIFO is at least half full.
3 TXIM Software should set this bit to enable interrupt when the Tx 0
FIFO is at least half empty.
7:4 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Table 208: SSP Raw Interrupt Status Register (SSPRIS - address 0xE005 C018) bit
description
Bit Symbol Description Reset value
0 RORRIS This bit is 1 if another frame was completely received while the 0
RxFIFO was full. The ARM spec implies that the preceding
frame data is overwritten by the new frame data when this
occurs.
1 RTRIS This bit is 1 if when there is a Receive Timeout condition. 0
Note: A Receive Timeout can be negated if further data is
received.
2 RXRIS This bit is 1 if the Rx FIFO is at least half full. 0
3 TXRIS This bit is 1 if the Tx FIFO is at least half empty. 1
7:4 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Table 209: SSP Masked Interrupt Status Register (SSPMIS -address 0xE005 C01C) bit
description
Bit Symbol Description Reset value
0 RORMIS This bit is 1 if another frame was completely received while the 0
RxFIFO was full, and this interrupt is enabled.
1 RTMIS This bit is 1 when there is a Receive Timeout condition and 0
this interrupt is enabled.
Note: A Receive Timeout can be negated if further data is
received.
2 RXMIS This bit is 1 if the Rx FIFO is at least half full, and this interrupt 0
is enabled.
3 TXMIS This bit is 1 if the Tx FIFO is at least half empty, and this 0
interrupt is enabled.
7:4 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Table 210: SSP interrupt Clear Register (SSPICR - address 0xE005 C020) bit description
Bit Symbol Description Reset value
0 RORIC Writing a 1 to this bit clears the “frame was received when Undefined
RxFIFO was full” interrupt.
1 RTIC Writing a 1 to this bit clears the Receive Timeout interrupt. Undefined
7:2 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
For an overview of how LPC21xx and LPC22xx parts and versions are described in this
manual, see Section 1–2 “How to read this manual”.
2. Features
• A 32-bit Timer/Counter with a programmable 32-bit Prescaler.
• Counter or Timer operation
• External Event Counting capabilities.
• Up to four 32-bit capture channels per timer, that can take a snapshot of the timer
value when an input signal transitions. A capture event may also optionally generate
an interrupt.
• Four 32-bit match registers that allow:
– Continuous operation with optional interrupt generation on match.
– Stop timer on match with optional interrupt generation.
– Reset timer on match with optional interrupt generation.
• Up to four external outputs corresponding to match registers, with the following
capabilities:
– Set low on match.
UM10114_3 © NXP B.V. 2008. All rights reserved.
3. Applications
• Interval Timer for counting internal events.
• Pulse Width Demodulator via Capture inputs.
• Free running timer.
• External Event/Clock counter.
4. Description
The Timer/Counter is designed to count cycles of the peripheral clock (PCLK) or an
externally-supplied clock, and can optionally generate interrupts or perform other actions
at specified timer values, based on four match registers. It also includes four capture
inputs to trap the timer value when an input signal transitions, optionally generating an
interrupt.
5. Pin description
Table 15–212 gives a brief summary of each of the Timer/Counter related pins.
6. Register description
Each Timer/Counter contains the registers shown in Table 15–213. More detailed
descriptions follow.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
6.1 Interrupt Register (IR, TIMER0: T0IR - 0xE000 4000 and TIMER1: T1IR
- 0xE000 8000)
The Interrupt Register consists of four bits for the match interrupts and four bits for the
capture interrupts. If an interrupt is generated then the corresponding bit in the IR will be
high. Otherwise, the bit will be low. Writing a logic one to the corresponding IR bit will reset
the interrupt. Writing a zero has no effect.
Table 214: Interrupt Register (IR, TIMER0: T0IR - address 0xE000 4000 and TIMER1: T1IR - address 0xE000 8000) bit
description
Bit Symbol Description Reset value
0 MR0 Interrupt Interrupt flag for match channel 0. 0
1 MR1 Interrupt Interrupt flag for match channel 1. 0
2 MR2 Interrupt Interrupt flag for match channel 2. 0
3 MR3 Interrupt Interrupt flag for match channel 3. 0
4 CR0 Interrupt Interrupt flag for capture channel 0 event. 0
5 CR1 Interrupt Interrupt flag for capture channel 1 event. 0
6 CR2 Interrupt Interrupt flag for capture channel 2 event. 0
7 CR3 Interrupt Interrupt flag for capture channel 3 event. 0
6.2 Timer Control Register (TCR, TIMER0: T0TCR - 0xE000 4004 and
TIMER1: T1TCR - 0xE000 8004)
The Timer Control Register (TCR) is used to control the operation of the Timer/Counter.
Table 215: Timer Control Register (TCR, TIMER0: T0TCR - address 0xE000 4004 and TIMER1:
T1TCR - address 0xE000 8004) bit description
Bit Symbol Description Reset value
0 Counter Enable When one, the Timer Counter and Prescale Counter are 0
enabled for counting. When zero, the counters are
disabled.
1 Counter Reset When one, the Timer Counter and the Prescale Counter 0
are synchronously reset on the next positive edge of
PCLK. The counters remain reset until TCR[1] is
returned to zero.
7:2 - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is not
defined.
6.3 Count Control Register (CTCR, TIMER0: T0CTCR - 0xE000 4070 and
TIMER1: T1TCR - 0xE000 8070)
Remark: This register is available for LPC21xx/01, LPC22xx/01, and LPC2220 only.
The Count Control Register (CTCR) is used to select between Timer and Counter mode,
and in Counter mode to select the pin and edge(s) for counting.
When Counter Mode is chosen as a mode of operation, the CAP input (selected by the
CTCR bits 3:2) is sampled on every rising edge of the PCLK clock. After comparing two
consecutive samples of this CAP input, one of the following four events is recognized:
rising edge, falling edge, either of edges or no changes in the level of the selected CAP
input. Only if the identified event corresponds to the one selected by bits 1:0 in the CTCR
register, the Timer Counter register will be incremented.
Effective processing of the externally supplied clock to the counter has some limitations.
Since two successive rising edges of the PCLK clock are used to identify only one edge
on the CAP selected input, the frequency of the CAP input can not exceed one half of the
PCLK clock. Consequently, duration of the high/low levels on the same CAP input in this
case can not be shorter than 1/PCLK.
Table 216: Count Control Register (CTCR, TIMER0: T0CTCR - address 0xE000 4070 and
TIMER1: T1TCR - address 0xE000 8070) bit description
Bit Symbol Value Description Reset
value
1:0 Counter/ This field selects which rising PCLK edges can increment 00
Timer Timer’s Prescale Counter (PC), or clear PC and increment
Mode Timer Counter (TC).
00 Timer Mode: every rising PCLK edge
01 Counter Mode: TC is incremented on rising edges on the
CAP input selected by bits 3:2.
10 Counter Mode: TC is incremented on falling edges on the
CAP input selected by bits 3:2.
11 Counter Mode: TC is incremented on both edges on the CAP
input selected by bits 3:2.
Table 216: Count Control Register (CTCR, TIMER0: T0CTCR - address 0xE000 4070 and
TIMER1: T1TCR - address 0xE000 8070) bit description
Bit Symbol Value Description Reset
value
3:2 Count When bits 1:0 in this register are not 00, these bits select 00
Input which CAP pin is sampled for clocking:
Select 00 CAPn.0 (CAP0.0 for TIMER0 and CAP1.0 for TIMER1)
01 CAPn.1 (CAP0.1 for TIMER0 and CAP1.1 for TIMER1)
10 CAPn.2 (CAP0.2 for TIMER0 and CAP1.2 for TIMER1)
11 CAPn.3 (CAP0.3 for TIMER0 and CAP1.3 for TIMER1)
Note: If Counter mode is selected for a particular CAPn input
in the TnCTCR, the 3 bits for that input in the Capture
Control Register (TnCCR) must be programmed as 000.
However, capture and/or interrupt can be selected for the
other 3 CAPn inputs in the same timer.
7:4 - - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
6.4 Timer Counter (TC, TIMER0: T0TC - 0xE000 4008 and TIMER1:
T1TC - 0xE000 8008)
The 32-bit Timer Counter is incremented when the Prescale Counter reaches its terminal
count. Unless it is reset before reaching its upper limit, the TC will count up through the
value 0xFFFF FFFF and then wrap back to the value 0x0000 0000. This event does not
cause an interrupt, but a Match register can be used to detect an overflow if needed.
6.5 Prescale Register (PR, TIMER0: T0PR - 0xE000 400C and TIMER1:
T1PR - 0xE000 800C)
The 32-bit Prescale Register specifies the maximum value for the Prescale Counter.
6.6 Prescale Counter Register (PC, TIMER0: T0PC - 0xE000 4010 and
TIMER1: T1PC - 0xE000 8010)
The 32-bit Prescale Counter controls division of PCLK by some constant value before it is
applied to the Timer Counter. This allows control of the relationship of the resolution of the
timer versus the maximum time before the timer overflows. The Prescale Counter is
incremented on every PCLK. When it reaches the value stored in the Prescale Register,
the Timer Counter is incremented and the Prescale Counter is reset on the next PCLK.
This causes the TC to increment on every PCLK when PR = 0, every 2 PCLKs when
PR = 1, etc.
6.8 Match Control Register (MCR, TIMER0: T0MCR - 0xE000 4014 and
TIMER1: T1MCR - 0xE000 8014)
The Match Control Register is used to control what operations are performed when one of
the Match Registers matches the Timer Counter. The function of each of the bits is shown
in Table 15–217.
Table 217: Match Control Register (MCR, TIMER0: T0MCR - address 0xE000 4014 and TIMER1: T1MCR - address
0xE000 8014) bit description
Bit Symbol Value Description Reset
value
0 MR0I 1 Interrupt on MR0: an interrupt is generated when MR0 matches the value in the TC. 0
0 This interrupt is disabled
1 MR0R 1 Reset on MR0: the TC will be reset if MR0 matches it. 0
0 Feature disabled.
2 MR0S 1 Stop on MR0: the TC and PC will be stopped and TCR[0] will be set to 0 if MR0 matches 0
the TC.
0 Feature disabled.
3 MR1I 1 Interrupt on MR1: an interrupt is generated when MR1 matches the value in the TC. 0
0 This interrupt is disabled
4 MR1R 1 Reset on MR1: the TC will be reset if MR1 matches it. 0
0 Feature disabled.
5 MR1S 1 Stop on MR1: the TC and PC will be stopped and TCR[0] will be set to 0 if MR1 matches 0
the TC.
0 Feature disabled.
6 MR2I 1 Interrupt on MR2: an interrupt is generated when MR2 matches the value in the TC. 0
0 This interrupt is disabled
7 MR2R 1 Reset on MR2: the TC will be reset if MR2 matches it. 0
0 Feature disabled.
8 MR2S 1 Stop on MR2: the TC and PC will be stopped and TCR[0] will be set to 0 if MR2 matches 0
the TC.
0 Feature disabled.
9 MR3I 1 Interrupt on MR3: an interrupt is generated when MR3 matches the value in the TC. 0
0 This interrupt is disabled
10 MR3R 1 Reset on MR3: the TC will be reset if MR3 matches it. 0
0 Feature disabled.
11 MR3S 1 Stop on MR3: the TC and PC will be stopped and TCR[0] will be set to 0 if MR3 matches 0
the TC.
0 Feature disabled.
15:12 - Reserved, user software should not write ones to reserved bits. The value read from a NA
reserved bit is not defined.
6.10 Capture Control Register (CCR, TIMER0: T0CCR - 0xE000 4028 and
TIMER1: T1CCR - 0xE000 8028)
The Capture Control Register is used to control whether one of the four Capture Registers
is loaded with the value in the Timer Counter when the capture event occurs, and whether
an interrupt is generated by the capture event. Setting both the rising and falling bits at the
same time is a valid configuration, resulting in a capture event for both edges. In the
description below, "n" represents the Timer number, 0 or 1.
Table 218: Capture Control Register (CCR, TIMER0: T0CCR - address 0xE000 4028 and TIMER1: T1CCR - address
0xE000 8028) bit description
Bit Symbol Value Description Reset
value
0 CAP0RE 1 Capture on CAPn.0 rising edge: a sequence of 0 then 1 on CAPn.0 will cause CR0 to 0
be loaded with the contents of TC.
0 This feature is disabled.
1 CAP0FE 1 Capture on CAPn.0 falling edge: a sequence of 1 then 0 on CAPn.0 will cause CR0 to 0
be loaded with the contents of TC.
0 This feature is disabled.
2 CAP0I Interrupt on CAPn.0 event: a CR0 load due to a CAPn.0 event will generate an 0
1 interrupt.
0 This feature is disabled.
3 CAP1RE 1 Capture on CAPn.1 rising edge: a sequence of 0 then 1 on CAPn.1 will cause CR1 to 0
be loaded with the contents of TC.
0 This feature is disabled.
4 CAP1FE 1 Capture on CAPn.1 falling edge: a sequence of 1 then 0 on CAPn.1 will cause CR1 to 0
be loaded with the contents of TC.
0 This feature is disabled.
5 CAP1I Interrupt on CAPn.1 event: a CR1 load due to a CAPn.1 event will generate an 0
1 interrupt.
0 This feature is disabled.
6 CAP2RE 1 Capture on CAPn.2 rising edge: A sequence of 0 then 1 on CAPn.2 will cause CR2 to 0
be loaded with the contents of TC.
0 This feature is disabled.
7 CAP2FE 1 Capture on CAPn.2 falling edge: a sequence of 1 then 0 on CAPn.2 will cause CR2 to 0
be loaded with the contents of TC.
0 This feature is disabled.
8 CAP2I 1 Interrupt on CAPn.2 event: a CR2 load due to a CAPn.2 event will generate an 0
interrupt.
0 This feature is disabled.
Table 218: Capture Control Register (CCR, TIMER0: T0CCR - address 0xE000 4028 and TIMER1: T1CCR - address
0xE000 8028) bit description
Bit Symbol Value Description Reset
value
9 CAP3RE 1 Capture on CAPn.3 rising edge: a sequence of 0 then 1 on CAPn.3 will cause CR3 to 0
be loaded with the contents of TC.
0 This feature is disabled.
10 CAP3FE 1 Capture on CAPn.3 falling edge: a sequence of 1 then 0 on CAPn.3 will cause CR3 to 0
be loaded with the contents of TC
0 This feature is disabled.
11 CAP3I Interrupt on CAPn.3 event: a CR3 load due to a CAPn.3 event will generate an 0
1 interrupt.
0 This feature is disabled.
15:12 - Reserved, user software should not write ones to reserved bits. The value read from a NA
reserved bit is not defined.
6.11 External Match Register (EMR, TIMER0: T0EMR - 0xE000 403C; and
TIMER1: T1EMR - 0xE000 803C)
The External Match Register provides both control and status of the external match pins
MAT(0-3). Bits EM3:0 can be written only when Timer is disabled (bit 1 in Timer Control
Register is 0). Only under this condition an initial output level on MAT pin(s) can be set.
Once the Timer is enabled, EM3:0 can be changed only by Timer’s activities specified by
the EMC bits.
Table 219: External Match Register (EMR, TIMER0: T0EMR - address 0xE000 403C and TIMER1: T1EMR -
address0xE000 803C) bit description
Bit Symbol Description Reset
value
0 EM0 External Match 0. This bit reflects the state of output MAT0.0/MAT1.0, whether or not this 0
output is connected to its pin. When a match occurs between the TC and MR0, this output
of the timer can either toggle, go low, go high, or do nothing. Bits EMR[5:4] control the
functionality of this output.
1 EM1 External Match 1. This bit reflects the state of output MAT0.1/MAT1.1, whether or not this 0
output is connected to its pin. When a match occurs between the TC and MR1, this output
of the timer can either toggle, go low, go high, or do nothing. Bits EMR[7:6] control the
functionality of this output.
2 EM2 External Match 2. This bit reflects the state of output MAT0.2/MAT1.2, whether or not this 0
output is connected to its pin. When a match occurs between the TC and MR2, this output
of the timer can either toggle, go low, go high, or do nothing. Bits EMR[9:8] control the
functionality of this output.
3 EM3 External Match 3. This bit reflects the state of output MAT0.3/MAT1.3, whether or not this 0
output is connected to its pin. When a match occurs between the TC and MR3, this output
of the timer can either toggle, go low, go high, or do nothing. Bits EMR[11:10] control the
functionality of this output.
5:4 EMC0 External Match Control 0. Determines the functionality of External Match 0. Table 15–220 00
shows the encoding of these bits.
7:6 EMC1 External Match Control 1. Determines the functionality of External Match 1. Table 15–220 00
shows the encoding of these bits.
Table 219: External Match Register (EMR, TIMER0: T0EMR - address 0xE000 403C and TIMER1: T1EMR -
address0xE000 803C) bit description
Bit Symbol Description Reset
value
9:8 EMC2 External Match Control 2. Determines the functionality of External Match 2. Table 15–220 00
shows the encoding of these bits.
11:10 EMC3 External Match Control 3. Determines the functionality of External Match 3. Table 15–220 00
shows the encoding of these bits.
15:12 - Reserved, user software should not write ones to reserved bits. The value read from a NA
reserved bit is not defined.
Figure 15–60 shows a timer configured to stop and generate an interrupt on match. The
prescaler is again set to 2 and the match register set to 6. In the next clock after the timer
reaches the match value, the timer enable bit in TCR is cleared, and the interrupt
indicating that a match occurred is generated.
PCLK
prescale
2 0 1 2 0 1 2 0 1 2 0 1
counter
timer
4 5 6 0 1
counter
timer counter
reset
interrupt
Fig 59. A timer cycle in which PR=2, MRx=6, and both interrupt and reset on match are enabled
PCLK
prescale counter 2 0 1 2 0
timer counter
4 5 6
TCR[0]
1 0
(counter enable)
interrupt
Fig 60. A timer cycle in which PR=2, MRx=6, and both interrupt and stop on match are enabled
8. Architecture
The block diagram for TIMER/COUNTER0 and TIMER/COUNTER1 is shown in
Figure 15–61.
MATCH REGISTER 0
MATCH REGISTER 1
MATCH REGISTER 2
MATCH REGISTER 3
INTERRUPT REGISTER
CONTROL
=
MAT[3:0]
INTERRUPT =
CAP[3:0]
STOP ON MATCH =
RESET ON MATCH
=
LOAD[3:0]
CSN
CAPTURE REGISTER 0 TIMER COUNTER
CAPTURE REGISTER 1 CE
CAPTURE REGISTER 2
CAPTURE REGISTER 3
TCI
PCLK
PRESCALE COUNTER
For an overview of how LPC21xx and LPC22xx parts and versions are described in this
manual, see Section 1–2 “How to read this manual”.
2. Features
• Seven match registers allow up to 6 single edge controlled or 3 double edge
controlled PWM outputs, or a mix of both types. The match registers also allow:
– Continuous operation with optional interrupt generation on match.
– Stop timer on match with optional interrupt generation.
– Reset timer on match with optional interrupt generation.
• An external output for each match register with the following capabilities:
– Set low on match.
– Set high on match.
– Toggle on match.
– Do nothing on match.
• Supports single edge controlled and/or double edge controlled PWM outputs. Single
edge controlled PWM outputs all go high at the beginning of each cycle unless the
output is a constant low. Double edge controlled PWM outputs can have either edge
occur at any position within a cycle. This allows for both positive going and negative
going pulses.
• Pulse period and width can be any number of timer counts. This allows complete
flexibility in the trade-off between resolution and repetition rate. All PWM outputs will
occur at the same repetition rate.
• Double edge controlled PWM outputs can be programmed to be either positive going
or negative going pulses.
• Match register updates are synchronized with pulse outputs to prevent generation of
erroneous pulses. Software must "release" new match values before they can
become effective.
• May be used as a standard timer if the PWM mode is not enabled.
• A 32-bit Timer/Counter with a programmable 32-bit Prescaler.
3. Description
The PWM is based on the standard Timer block and inherits all of its features, although
only the PWM function is pinned out on the LPC21xx/LPC22xx. The Timer is designed to
count cycles of the peripheral clock (PCLK) and optionally generate interrupts or perform
other actions when specified timer values occur, based on seven match registers. It also
includes four capture inputs to save the timer value when an input signal transitions, and
optionally generate an interrupt when those events occur. The PWM function is in addition
to these features, and is based on match register events.
The ability to separately control rising and falling edge locations allows the PWM to be
used for more applications. For instance, multi-phase motor control typically requires
three non-overlapping PWM outputs with individual control of all three pulse widths and
positions.
Two match registers can be used to provide a single edge controlled PWM output. One
match register (PWMMR0) controls the PWM cycle rate, by resetting the count upon
match. The other match register controls the PWM edge position. Additional single edge
controlled PWM outputs require only one match register each, since the repetition rate is
the same for all PWM outputs. Multiple single edge controlled PWM outputs will all have a
rising edge at the beginning of each PWM cycle, when an PWMMR0 match occurs.
Three match registers can be used to provide a PWM output with both edges controlled.
Again, the PWMMR0 match register controls the PWM cycle rate. The other match
registers control the two PWM edge positions. Additional double edge controlled PWM
outputs require only two match registers each, since the repetition rate is the same for all
PWM outputs.
With double edge controlled PWM outputs, specific match registers control the rising and
falling edge of the output. This allows both positive going PWM pulses (when the rising
edge occurs prior to the falling edge), and negative going PWM pulses (when the falling
edge occurs prior to the rising edge).
Figure 16–62 shows the block diagram of the PWM. The portions that have been added to
the standard timer block are on the right hand side and at the top of the diagram.
Match 1 PWMENA1
R EN
MATCH 0
PWMSEL2
PWM2
LATCH ENABLE REGISTER CLEAR MUX S Q
= Match 4 PWMENA4
R EN
CSN =
PWMSEL5
PWM5
MUX S Q
Match 5 PWMENA5
R EN
CE PWM6
MUX S Q
TCI
Match 6 PWMENA6
PRESCALE COUNTER R EN
PWMENA1..6 PWMSEL2..6
ENABLE MAXVAL
RESET
PRESCALE REGISTER PWM CONTROL REGISTER
TIMER CONTROL REGISTER
A sample of how PWM values relate to waveform outputs is shown in Figure 16–63. PWM
output logic is shown in Figure 16–62 that allows selection of either single or double edge
controlled PWM outputs via the multiplexers controlled by the PWMSELn bits. The match
register selections for various PWM outputs is shown in Table 16–221. This
implementation supports up to N-1 single edge PWM outputs or (N-1)/2 double edge
PWM outputs, where N is the number of match registers that are implemented. PWM
types can be mixed if desired.
PWM2
PWM4
PWM5
1 27 41 53 65 78 100
(counter is reset)
The waveforms below show a single PWM cycle and demonstrate PWM outputs under the
following conditions:
The timer is configured for PWM mode (counter resets to one).
Match 0 is configured to reset the timer/counter when a match event occurs.
All PWM related Match registers are configured for toggle on match.
Control bits PWMSEL2 and PWMSEL4 are set.
The Match register values are as follows:
MR0 = 100 (PWM rate)
MR1 = 41, MR2 = 78 (PWM2 output)
MR3 = 53, MR$ = 27 (PWM4 output)
MR5 = 65 (PWM5 output)
Fig 63. Sample PWM waveforms
[1] Identical to single edge mode in this case since Match 0 is the neighboring match register. Essentially,
PWM1 cannot be a double edged output.
[2] It is generally not advantageous to use PWM channels 3 and 5 for double edge PWM outputs because it
would reduce the number of double edge PWM outputs that are possible. Using PWM 2, PWM4, and
PWM6 for double edge PWM outputs provides the most pairings.
2. Each PWM output will go low when its match value is reached. If no match occurs (i.e.
the match value is greater than the PWM rate), the PWM output remains continuously
high.
1. The match values for the next PWM cycle are used at the end of a PWM cycle (a time
point which is coincident with the beginning of the next PWM cycle), except as noted
in rule 3.
2. A match value equal to 0 or the current PWM rate (the same as the Match channel 0
value) have the same effect, except as noted in rule 3. For example, a request for a
falling edge at the beginning of the PWM cycle has the same effect as a request for a
falling edge at the end of a PWM cycle.
3. When match values are changing, if one of the "old" match values is equal to the
PWM rate, it is used again once if the neither of the new match values are equal to 0
or the PWM rate, and there was no old match value equal to 0.
4. If both a set and a clear of a PWM output are requested at the same time, clear takes
precedence. This can occur when the set and clear match values are the same as in,
or when the set or clear value equals 0 and the other value equals the PWM rate.
5. If a match value is out of range (i.e. greater than the PWM rate value), no match event
occurs and that match channel has no effect on the output. This means that the PWM
output will remain always in one state, allowing always low, always high, or
"no change" outputs.
4. Pin description
Table 16–222 gives a brief summary of each of PWM related pins.
5. Register description
The PWM function adds new registers and registers bits as shown in Table 16–223 below.
[1] Reset Value refers to the data stored in used bits only. It does not include reserved bits content.
Table 224: PWM Interrupt Register (PWMIR - address 0xE001 4000) bit description
Bit Symbol Description Reset value
0 PWMMR0 Interrupt Interrupt flag for PWM match channel 0. 0
1 PWMMR1 Interrupt Interrupt flag for PWM match channel 1. 0
2 PWMMR2 Interrupt Interrupt flag for PWM match channel 2. 0
Table 224: PWM Interrupt Register (PWMIR - address 0xE001 4000) bit description
Bit Symbol Description Reset value
3 PWMMR3 Interrupt Interrupt flag for PWM match channel 3. 0
7:4 - Reserved, user software should not write ones to 0000
reserved bits. The value read from a reserved bit is
not defined.
8 PWMMR4 Interrupt Interrupt flag for PWM match channel 4. 0
9 PWMMR5 Interrupt Interrupt flag for PWM match channel 5. 0
10 PWMMR6 Interrupt Interrupt flag for PWM match channel 6. 0
15:11 - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is
not defined.
Table 225: PWM Timer Control Register (PWMTCR - address 0xE001 4004 ) bit description
Bit Symbol Value Description Reset
Value
0 Counter Enable 1 The PWM Timer Counter and PWM Prescale Counter 0
are enabled for counting.
0 The counters are disabled.
1 Counter Reset 1 The PWM Timer Counter and the PWM Prescale 0
Counter are synchronously reset on the next positive
edge of PCLK. The counters remain reset until this bit is
returned to zero.
0 Clear reset.
2 - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is not
defined.
3 PWM Enable 1 PWM mode is enabled (counter resets to 1). PWM mode 0
causes the shadow registers to operate in connection
with the Match registers. A program write to a Match
register will not have an effect on the Match result until
the corresponding bit in PWMLER has been set,
followed by the occurrence of a PWM Match 0 event.
Note that the PWM Match register that determines the
PWM rate (PWM Match Register 0 - MR0) must be set
up prior to the PWM being enabled. Otherwise a Match
event will not occur to cause shadow register contents to
become effective.
0 Timer mode is enabled (counter resets to 0).
7:4 - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is not
defined.
Table 226: Match Control Register (MCR, TIMER0: T0MCR - address 0xE000 4014 and
TIMER1: T1MCR - address 0xE000 8014) bit description
Bit Symbol Value Description Reset
Value
0 PWMMR0I 1 Interrupt on PWMMR0: an interrupt is generated when 0
PWMMR0 matches the value in the PWMTC.
0 This interrupt is disabled.
1 PWMMR0R 1 Reset on PWMMR0: the PWMTC will be reset if PWMMR0 0
matches it.
0 This feature is disabled.
2 PWMMR0S 1 Stop on PWMMR0: the PWMTC and PWMPC will be stopped 0
and PWMTCR[0] will be set to 0 if PWMMR0 matches the
PWMTC.
0 This feature is disabled
Table 226: Match Control Register (MCR, TIMER0: T0MCR - address 0xE000 4014 and
TIMER1: T1MCR - address 0xE000 8014) bit description
Bit Symbol Value Description Reset
Value
3 PWMMR1I 1 Interrupt on PWMMR1: an interrupt is generated when 0
PWMMR1 matches the value in the PWMTC.
0 This interrupt is disabled.
4 PWMMR1R 1 Reset on PWMMR1: the PWMTC will be reset if PWMMR1 0
matches it.
0 This feature is disabled.
5 PWMMR1S 1 Stop on PWMMR1: the PWMTC and PWMPC will be stopped 0
and PWMTCR[0] will be set to 0 if PWMMR1 matches the
PWMTC.
0 This feature is disabled.
6 PWMMR2I 1 Interrupt on PWMMR2: an interrupt is generated when 0
PWMMR2 matches the value in the PWMTC.
0 This interrupt is disabled.
7 PWMMR2R 1 Reset on PWMMR2: the PWMTC will be reset if PWMMR2 0
matches it.
0 This feature is disabled.
8 PWMMR2S 1 Stop on PWMMR2: the PWMTC and PWMPC will be stopped 0
and PWMTCR[0] will be set to 0 if PWMMR2 matches the
PWMTC.
0 This feature is disabled
9 PWMMR3I 1 Interrupt on PWMMR3: an interrupt is generated when 0
PWMMR3 matches the value in the PWMTC.
0 This interrupt is disabled.
10 PWMMR3R 1 Reset on PWMMR3: the PWMTC will be reset if PWMMR3 0
matches it.
0 This feature is disabled
11 PWMMR3S 1 Stop on PWMMR3: The PWMTC and PWMPC will be 0
stopped and PWMTCR[0] will be set to 0 if PWMMR3
matches the PWMTC.
0 This feature is disabled
12 PWMMR4I 1 Interrupt on PWMMR4: An interrupt is generated when 0
PWMMR4 matches the value in the PWMTC.
0 This interrupt is disabled.
13 PWMMR4R 1 Reset on PWMMR4: the PWMTC will be reset if PWMMR4 0
matches it.
0 This feature is disabled.
14 PWMMR4S 1 Stop on PWMMR4: the PWMTC and PWMPC will be stopped 0
and PWMTCR[0] will be set to 0 if PWMMR4 matches the
PWMTC.
0 This feature is disabled
15 PWMMR5I 1 Interrupt on PWMMR5: An interrupt is generated when 0
PWMMR5 matches the value in the PWMTC.
0 This interrupt is disabled.
Table 226: Match Control Register (MCR, TIMER0: T0MCR - address 0xE000 4014 and
TIMER1: T1MCR - address 0xE000 8014) bit description
Bit Symbol Value Description Reset
Value
16 PWMMR5R Reset on PWMMR5: the PWMTC will be reset if PWMMR5 0
1 matches it.
0 This feature is disabled.
17 PWMMR5S 1 Stop on PWMMR5: the PWMTC and PWMPC will be stopped 0
and PWMTCR[0] will be set to 0 if PWMMR5 matches the
PWMTC.
0 This feature is disabled
18 PWMMR6I 1 Interrupt on PWMMR6: an interrupt is generated when 0
PWMMR6 matches the value in the PWMTC.
0 This interrupt is disabled.
19 PWMMR6R 1 Reset on PWMMR6: the PWMTC will be reset if PWMMR6 0
matches it.
0 This feature is disabled.
20 PWMMR6S 1 Stop on PWMMR6: the PWMTC and PWMPC will be stopped 0
and PWMTCR[0] will be set to 0 if PWMMR6 matches the
PWMTC.
0 This feature is disabled
31:21 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Table 227: PWM Control Register (PWMPCR - address 0xE001 404C) bit description
Bit Symbol Valu Description Reset
e Value
1:0 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
2 PWMSEL2 1 Selects double edge controlled mode for the PWM2 output. 0
0 Selects single edge controlled mode for PWM2.
3 PWMSEL3 1 Selects double edge controlled mode for the PWM3 output. 0
0 Selects single edge controlled mode for PWM3.
4 PWMSEL4 1 Selects double edge controlled mode for the PWM4 output. 0
0 Selects single edge controlled mode for PWM4.
5 PWMSEL5 1 Selects double edge controlled mode for the PWM5 output. 0
0 Selects single edge controlled mode for PWM5.
6 PWMSEL6 1 Selects double edge controlled mode for the PWM6 output. 0
0 Selects single edge controlled mode for PWM6.
8:7 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
9 PWMENA1 1 The PWM1 output enabled. 0
0 The PWM1 output disabled.
Table 227: PWM Control Register (PWMPCR - address 0xE001 404C) bit description
Bit Symbol Valu Description Reset
e Value
10 PWMENA2 1 The PWM2 output enabled. 0
0 The PWM2 output disabled.
11 PWMENA3 1 The PWM3 output enabled. 0
0 The PWM3 output disabled.
12 PWMENA4 1 The PWM4 output enabled. 0
0 The PWM4 output disabled.
13 PWMENA5 1 The PWM5 output enabled. 0
0 The PWM5 output disabled.
14 PWMENA6 1 The PWM6 output enabled. 0
0 The PWM6 output disabled.
15 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
For example, if PWM2 is configured for double edge operation and is currently running, a
typical sequence of events for changing the timing would be:
The order of writing the two PWM Match registers is not important, since neither value will
be used until after the write to PWMLER. This insures that both values go into effect at the
same time, if that is required. A single value may be altered in the same way if needed.
The function of each of the bits in the PWMLER is shown in Table 16–228.
Table 228: PWM Latch Enable Register (PWMLER - address 0xE001 4050) bit description
Bit Symbol Description Reset
value
0 Enable PWM Writing a one to this bit allows the last value written to the 0
Match 0 Latch PWM Match 0 register to be become effective when the timer
is next reset by a PWM Match event. Section 16–5.7 “PWM
Match Control Register (PWMMCR - 0xE001 4014)”.
1 Enable PWM Writing a one to this bit allows the last value written to the 0
Match 1 Latch PWM Match 1 register to be become effective when the timer
is next reset by a PWM Match event. Section 16–5.7 “PWM
Match Control Register (PWMMCR - 0xE001 4014)”.
2 Enable PWM Writing a one to this bit allows the last value written to the 0
Match 2 Latch PWM Match 2 register to be become effective when the timer
is next reset by a PWM Match event. See Section 16–5.7
“PWM Match Control Register (PWMMCR - 0xE001 4014)”.
3 Enable PWM Writing a one to this bit allows the last value written to the 0
Match 3 Latch PWM Match 3 register to be become effective when the timer
is next reset by a PWM Match event. See Section 16–5.7
“PWM Match Control Register (PWMMCR - 0xE001 4014)”.
4 Enable PWM Writing a one to this bit allows the last value written to the 0
Match 4 Latch PWM Match 4 register to be become effective when the timer
is next reset by a PWM Match event. See Section 16–5.7
“PWM Match Control Register (PWMMCR - 0xE001 4014)”.
5 Enable PWM Writing a one to this bit allows the last value written to the 0
Match 5 Latch PWM Match 5 register to be become effective when the timer
is next reset by a PWM Match event. See Section 16–5.7
“PWM Match Control Register (PWMMCR - 0xE001 4014)”.
6 Enable PWM Writing a one to this bit allows the last value written to the 0
Match 6 Latch PWM Match 6 register to be become effective when the timer
is next reset by a PWM Match event. See Section 16–5.7
“PWM Match Control Register (PWMMCR - 0xE001 4014)”.
7 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
For an overview of how LPC21xx and LPC22xx parts and versions are described in this
manual, see Section 1–2 “How to read this manual”.
2. Features
• Internally resets chip if not periodically reloaded.
• Debug mode.
• Enabled by software but requires a hardware reset or a watchdog reset/interrupt to be
disabled.
• Incorrect/Incomplete feed sequence causes reset/interrupt if enabled.
• Flag to indicate Watchdog reset.
• Programmable 32-bit timer with internal pre-scaler.
• Selectable time period from (TPCLK x 256 x 4) to (TPCLK x 232 x 4) in multiples of
TPCLK x 4.
3. Applications
The purpose of the watchdog is to reset the microcontroller within a reasonable amount of
time if it enters an erroneous state. When enabled, the watchdog will generate a system
reset if the user program fails to "feed" (or reload) the watchdog within a predetermined
amount of time.
For interaction of the on-chip watchdog and other peripherals, especially the reset and
boot-up procedures, please read Section 6–11 of this document.
4. Description
The watchdog consists of a divide by 4 fixed pre-scaler and a 32-bit counter. The clock is
fed to the timer via a pre-scaler. The timer decrements when clocked. The minimum value
from which the counter decrements is 0xFF. Setting a value lower than 0xFF causes 0xFF
to be loaded in the counter. Hence the minimum watchdog interval is (TPCLK x 256 x 4)
and the maximum watchdog interval is (TPCLK x 232 x 4) in multiples of (TPCLK x 4). The
watchdog should be used in the following manner:
When the Watchdog counter underflows, the program counter will start from 0x0000 0000
as in the case of external reset. The Watchdog Time-Out Flag (WDTOF) can be examined
to determine if the watchdog has caused the reset condition. The WDTOF flag must be
cleared by software.
5. Register description
The watchdog contains 4 registers as shown in Table 17–229 below.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
Once the WDEN and/or WDRESET bits are set they can not be cleared by software. Both
flags are cleared by an external reset or a watchdog timer underflow.
WDTOF The Watchdog Time-Out Flag is set when the watchdog times out. This flag is
cleared by software.
WDINT The Watchdog Interrupt Flag is set when the watchdog times out. This flag is
cleared when any reset occurs. Once the watchdog interrupt is serviced, it can be
disabled in the VIC or the watchdog interrupt request will be generated indefinitely.
Table 231: Watchdog Mode register (WDMOD - address 0xE000 0000) bit description
Bit Symbol Description Reset value
0 WDEN WDEN Watchdog interrupt Enable bit (Set Only). 0
1 WDRESET WDRESET Watchdog Reset Enable bit (Set Only). 0
2 WDTOF WDTOF Watchdog Time-Out Flag. 0 (Only after
external reset)
3 WDINT WDINT Watchdog interrupt Flag (Read Only). 0
7:4 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Table 232: Watchdog Timer Constant register (WDTC - address 0xE000 0004) bit description
Bit Symbol Description Reset value
31:0 Count Watchdog time-out interval. 0x0000 00FF
Remark: Interrupts must be disabled during the feed sequence. An abort condition will
occur if an interrupt happens during the feed sequence.
Table 233: Watchdog Feed register (WDFEED - address 0xE000 0008) bit description
Bit Symbol Description Reset value
7:0 Feed Feed value should be 0xAA followed by 0x55. NA
Table 234: Watchdog Timer Value register (WDTV - address 0xE000 000C) bit description
Bit Symbol Description Reset value
31:0 Count Counter timer value. 0x0000 00FF
6. Block diagram
The block diagram of the Watchdog is shown below in the Figure 17–64.
WDTC
feed sequence
feed error
feed ok
WDFEED
enable
count 1
WDTV CURRENT WD
register TIMER COUNT
SHADOW BIT
WDMOD
register WDEN 2 WDTOF WDINT WDRESET 2
reset
interrupt
(1) Counter is enabled only when the WDEN bit is set and a valid feed sequence is done.
(2) WDEN and WDRESET are sticky bits. Once set they can’t be cleared until the watchdog
underflows or an external reset occurs.
Fig 64. Watchdog block diagram
For an overview of how LPC21xx and LPC22xx parts and versions are described in this
manual, see Section 1–2 “How to read this manual”.
2. Features
• Measures the passage of time to maintain a calendar and clock.
• Ultra low power design to support battery powered systems.
• Provides Seconds, Minutes, Hours, Day of Month, Month, Year, Day of Week, and
Day of Year.
• Programmable reference clock divider allows adjustment of the RTC to match various
crystal frequencies.
3. Description
The Real Time Clock (RTC) is designed to provide a set of counters to measure time
during system power on and off operation. The RTC has been designed to use little power
in power down mode, making it suitable for battery powered systems where the CPU is
not running continuously (sleep mode).
4. Architecture
PCLK
CLK32k
REFERENCE CLOCK DIVIDER
MUX
(PRESCALER)
CLOCK GENERATOR
strobe
CLK1 CCLK
ALARM
TIME COUNTERS COMPARATORS
REGISTERS
INTERRUPT GENERATOR
5. Register description
The RTC includes a number of registers. The address space is split into four sections by
functionality. The first eight addresses are the Miscellaneous Register Group
(Section 18–5.2). The second set of eight locations are the Time Counter Group
(Section 18–5.12). The third set of eight locations contain the Alarm Register Group
(Section 18–5.14). The remaining registers control the Reference Clock Divider.
The Real Time Clock includes the register shown in Table 18–235. Detailed descriptions
of the registers follow.
[1] Registers in the RTC other than those that are part of the Prescaler are not affected by chip Reset. These
registers must be initialized by software if the RTC is enabled. Reset value reflects the data stored in used
bits only. It does not include reserved bits content.
Table 237: Interrupt Location Register (ILR - address 0xE002 4000) bit description
Bit Symbol Description Reset
value
0 RTCCIF When one, the Counter Increment Interrupt block generated an interrupt. NA
Writing a one to this bit location clears the counter increment interrupt.
1 RTCALF When one, the alarm registers generated an interrupt. Writing a one to NA
this bit location clears the alarm interrupt.
7:2 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
Table 238: Clock Tick Counter Register (CTCR - address 0xE002 4004) bit description
Bit Symbol Description Reset
value
0 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
15:1 Clock Tick Prior to the Seconds counter, the CTC counts 32,768 clocks per NA
Counter second. Due to the RTC Prescaler, these 32,768 time increments may
not all be of the same duration. Refer to the Section 18–7 “Reference
clock divider (prescaler)” on page 271 for details.
Table 239: Clock Control Register (CCR - address 0xE002 4008) bit description
Bit Symbol Description Reset
value
0 CLKEN Clock Enable. When this bit is a one the time counters are enabled. NA
When it is a zero, they are disabled so that they may be initialized.
1 CTCRST CTC Reset. When one, the elements in the Clock Tick Counter are NA
reset. The elements remain reset until CCR[1] is changed to zero.
3:2 CTTEST Test Enable. These bits should always be zero during normal NA
operation.
7:4 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
Table 240: Counter Increment Interrupt Register (CIIR - address 0xE002 400C) bit description
Bit Symbol Description Reset
value
0 IMSEC When 1, an increment of the Second value generates an interrupt. NA
1 IMMIN When 1, an increment of the Minute value generates an interrupt. NA
2 IMHOUR When 1, an increment of the Hour value generates an interrupt. NA
3 IMDOM When 1, an increment of the Day of Month value generates an NA
interrupt.
4 IMDOW When 1, an increment of the Day of Week value generates an interrupt. NA
5 IMDOY When 1, an increment of the Day of Year value generates an interrupt. NA
6 IMMON When 1, an increment of the Month value generates an interrupt. NA
7 IMYEAR When 1, an increment of the Year value generates an interrupt. NA
Table 241: Alarm Mask Register (AMR - address 0xE002 4010) bit description
Bit Symbol Description Reset
value
0 AMRSEC When 1, the Second value is not compared for the alarm. NA
1 AMRMIN When 1, the Minutes value is not compared for the alarm. NA
2 AMRHOUR When 1, the Hour value is not compared for the alarm. NA
3 AMRDOM When 1, the Day of Month value is not compared for the alarm. NA
4 AMRDOW When 1, the Day of Week value is not compared for the alarm. NA
5 AMRDOY When 1, the Day of Year value is not compared for the alarm. NA
6 AMRMON When 1, the Month value is not compared for the alarm. NA
7 AMRYEAR When 1, the Year value is not compared for the alarm. NA
The Consolidated Time Registers are read only. To write new values to the Time
Counters, the Time Counter addresses should be used.
Table 242: Consolidated Time register 0 (CTIME0 - address 0xE002 4014) bit description
Bit Symbol Description Reset
value
5:0 Seconds Seconds value in the range of 0 to 59 NA
7:6 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
13:8 Minutes Minutes value in the range of 0 to 59 NA
15:14 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
20:16 Hours Hours value in the range of 0 to 23 NA
23:21 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
26:24 Day Of Week Day of week value in the range of 0 to 6 NA
31:27 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
Table 243: Consolidated Time register 1 (CTIME1 - address 0xE002 4018) bit description
Bit Symbol Description Reset
value
4:0 Day of Month Day of month value in the range of 1 to 28, 29, 30, or 31 NA
(depending on the month and whether it is a leap year).
7:5 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
11:8 Month Month value in the range of 1 to 12. NA
15:12 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
27:16 Year Year value in the range of 0 to 4095. NA
31:28 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
Table 244: Consolidated Time register 2 (CTIME2 - address 0xE002 401C) bit description
Bit Symbol Description Reset
value
11:0 Day of Year Day of year value in the range of 1 to 365 (366 for leap years). NA
31:12 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
[1] These values are simply incremented at the appropriate intervals and reset at the defined overflow point.
They are not calculated and must be correctly initialized in order to be meaningful.
No provision is made in the LPC21xx/LPC22xx to retain RTC status upon power loss, or
to maintain time incrementation if the clock source is lost, interrupted, or altered. Loss of
chip power will result in complete loss of all RTC register contents. Entry to Power Down
mode will cause a lapse in the time update. Altering the RTC timebase during system
operation (by reconfiguring the PLL, the APB timer, or the RTC prescaler) will result in
some form of accumulated time error.
The reference clock divider consists of a 13-bit integer counter and a 15-bit fractional
counter. The reasons for these counter sizes are as follows:
PREINT = int (PCLK / 32768) − 1. The value of PREINT must be greater than or equal to
1.
Table 249: Prescaler Integer register (PREINT - address 0xE002 4080) bit description
Bit Symbol Description Reset
value
12:0 Prescaler Integer Contains the integer portion of the RTC prescaler value. 0
15:13 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Table 250: Prescaler Integer register (PREFRAC - address 0xE002 4084) bit description
Bit Symbol Description Reset
value
14:0 Prescaler Contains the integer portion of the RTC prescaler value. 0
Fraction
15 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
With this prescaler setting, exactly 32,768 clocks per second will be provided to the RTC
by counting 2 PCLKs 32,767 times, and 3 PCLKs once.
In this case, 5,760 of the prescaler output clocks will be 306 (305 + 1) PCLKs long, the
rest will be 305 PCLKs long.
In a similar manner, any PCLK rate greater than 65.536 kHz (as long as it is an even
number of cycles per second) may be turned into a 32 kHz reference clock for the RTC.
The only caveat is that if PREFRAC does not contain a zero, then not all of the 32,768 per
second clocks are of the same length. Some of the clocks are one PCLK longer than
others. While the longer pulses are distributed as evenly as possible among the remaining
pulses, this "jitter" could possibly be of concern in an application that wishes to observe
the contents of the Clock Tick Counter (CTC) directly(Section 18–5.4 “Clock Tick Counter
Register (CTCR - 0xE002 4004)” on page 266).
PCLK
to clock tick counter (APB clock)
CLK
COMBINATORIAL LOGIC
13 extend
reload
15
13 15
APB bus
For example, if PREFRAC bit 14 is a one (representing the fraction 1/2), then half of the
cycles counted by the 13-bit counter need to be longer. When there is a 1 in the LSB of
the Fraction Counter, the logic causes every alternate count (whenever the LSB of the
Fraction Counter=1) to be extended by one PCLK, evenly distributing the pulse widths.
Similarly, a one in PREFRAC bit 13 (representing the fraction 1/4) will cause every fourth
cycle (whenever the two LSBs of the Fraction Counter=10) counted by the 13-bit counter
to be longer.
Table 251. Prescaler cases where the Integer Counter reload value is incremented
Fraction Counter PREFRAC Bit
14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
--- ---- ---- ---1 1 - - - - - - - - - - - - - -
--- ---- ---- --10 - 1 - - - - - - - - - - - - -
--- ---- ---- -100 - - 1 - - - - - - - - - - - -
--- ---- ---- 1000 - - - 1 - - - - - - - - - - -
--- ---- ---1 0000 - - - - 1 - - - - - - - - - -
--- ---- --10 0000 - - - - - 1 - - - - - - - - -
--- ---- -100 0000 - - - - - - 1 - - - - - - - -
--- ---- 1000 0000 - - - - - - - 1 - - - - - - -
--- ---1 0000 0000 - - - - - - - - 1 - - - - - -
--- --10 0000 0000 - - - - - - - - - 1 - - - - -
--- -100 0000 0000 - - - - - - - - - - 1 - - - -
--- 1000 0000 0000 - - - - - - - - - - - 1 - - -
--1 0000 0000 0000 - - - - - - - - - - - - 1 - -
-10 0000 0000 0000 - - - - - - - - - - - - - 1 -
100 0000 0000 0000 - - - - - - - - - - - - - - 1
Remark: /01 devices contain an updated CAN controller with improved interrupt behavior
in Full-CAN mode. Care should be taken when using the global CAN filter look-up table
(LUT) because the numbering of CAN interfaces in the LUT is different for /01 devices
(see Section 19–9):
For an overview of how LPC21xx and LPC22xx parts and versions are described in this
manual, see Section 1–2 “How to read this manual”.
2. CAN controllers
The Controller Area Network (CAN) is a serial communications protocol which efficiently
supports distributed real-time control with a very high level of security. Its domain of
application ranges from high speed networks to low cost multiplex wiring.
The CAN block is intended to support multiple CAN buses simultaneously, allowing the
device to be used as a gateway, switch, or router among a number of CAN buses in
industrial or automotive applications.
Each CAN Controller has a register structure similar to the NXP SJA1000 and the
PeliCAN Library block, but the 8 bit registers of those devices have been combined in
32 bit words to allow simultaneous access in the ARM environment. The main operational
difference is that the recognition of received Identifiers, known in CAN terminology as
Acceptance Filtering, has been removed from the CAN controllers and centralized in a
global Acceptance Filter. This Acceptance Filter is described after the CAN Controllers in
Section 19–10 to Section 19–12.
3. Features
• One, two, or four CAN controllers and buses.
• Data rates to 1 Mbits/second on each bus.
• 32 bit register and RAM access.
• Compatible with CAN specification 2.0B, ISO 11898-1.
• Global Acceptance Filter recognizes 11 and 29 bit Rx Identifiers for all CAN buses.
• Acceptance Filter can provide FullCAN-style automatic reception for selected
Standard Identifiers.
4. Pin description
Table 253. CAN Pin descriptions
Pin Name Type Description
RD4/3/2/1 Inputs Serial Input: from CAN transceivers.
TD4/3/2/1 Outputs Serial Outputs: to CAN transceivers.
In the following register tables, the column “Reset Value” shows how a hardware reset
affects each bit or field, while the column “RM Set” indicates how each bit or field is
affected if software sets the RM bit, or RM is set because of a Bus-Off condition. Note that
while hardware reset sets RM, in this case the setting noted in the “Reset Value” column
prevails over that shown in the “RM Set” column, in the few bits where they differ. In both
columns, X indicates the bit or field is unchanged.
Table 257. Mode register (MOD: CAN1MOD - address 0xE004 4000, CAN2MOD - address
0xE004 8000, CAN3MOD - address 0x004 C000, CAN4MOD - address 0x005 0000)
bit description
Bit Symbol Value Function Reset RM
Value Set
0 RM 0 The CAN Controller operates, and certain registers can not be 1 1
written.
1 Reset Mode - CAN operation is disabled, and writable
registers can be written.
1 LOM 0 The CAN controller acknowledges a successfully-received 0 x
message on its CAN.
1 Listen Only Mode - the controller gives no acknowledgment on
CAN, even if a message is successfully received. Messages
cannot be sent, and the controller operates in “error passive”
mode. This mode is intended for software bit rate detection
and “hot plugging”.
2 STM 0 A transmitted message must be acknowledged to be 0 x
considered successful.
1 Self Test Mode - the controller will consider a Tx message
successful if there is no acknowledgment. Use this state in
conjunction with the SRR bit in CANCMR.
3 TPM 0 The priority of the 3 Transmit Buffers depends on their CAN 0 x
IDs.
1 The priority of the 3 Transmit Buffers depends on their Tx
Priority fields.
4 SM 0 Normal operation 0 0
1 Sleep Mode - the CAN controller sleeps if it is not requesting
an interrupt, and there is no bus activity. See the Sleep Mode
description Section 19–7.2 on page 291.
5 RPM 0 RX and TX pins are LOW for a dominant bit. 0 0
1 Reverse Polarity Mode - RX pins are High for a dominant bit.
6 - - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
7 TM 0 Normal operation 0 0
1 Test Mode. The state of the RX pin is clocked onto the TX pin.
Note 1: The LOM and STM bits can only be written if the RM bit is 1 prior to the write
operation.
Table 258. Command register (CMR: CAN1CMR- address 0xE004 4004, CAN2CMR - address 0xE004 8004,
CAN3CMR - address 0x004 C004, CAN4CMR - address 0x005 0004) bit description
Bit Symbol Function Reset RM
Value Set
0 TR 1: Transmission Request -- the message, previously written to the 0 0
CANTFI, CANTID, and optionally the CANTDA and CANTDB registers, is
queued for transmission.
1 AT 1: Abort Transmission -- if not already in progress, a pending Transmission 0 0
Request is cancelled. If this bit and TR are set in the same write operation,
frame transmission is attempted once, and no retransmission is attempted
if an error is flagged nor if arbitration is lost.
2 RRB 1: Release Receive Buffer -- the information in the CANRFS, CANRID, and 0 0
if applicable the CANRDA and CANRDB registers is released, and
becomes eligible for replacement by the next received frame. If the next
received frame is not available, writing this command clears the RBS bit in
CANSR.3
3 CDO 1: Clear Data Overrun -- The Data Overrun bit in CANSR is cleared. 0 0
4 SRR 1: Self Reception Request -- the message, previously written to the 0 0
CANTFS, CANTID, and optionally the CANTDA and CANTDB registers, is
queued for transmission. This differs from the TR bit above in that the
receiver is not disabled during the transmission, so that it receives the
message if its Identifier is recognized by the Acceptance Filter.
5 STB1 1: Select Tx Buffer 1 for transmission 0 0
6 STB2 1: Select Tx Buffer 2 for transmission 0 0
7 STB3 1: Select Tx Buffer 3 for transmission 0 0
Table 259. Global Status Register (GSR: CAN1GSR - address 0xE004 0008, CAN2GSR -
address 0xE004 8008, CAN3GSR - address 0xE004 C008, CAN4GSR address
0xE005 0008) bit description
Bit Symbol Value Function Reset RM
Value Set
0 RBS 1 Receive Buffer Status -- a received message is available 0 0
in the CANRFS, CANRID, and if applicable the CANRDA
and CANRDB registers. This bit is cleared by the Release
Receive Buffer command in CANCMR, if no subsequent
received message is available.
1 DOS 0 No data overrun has occurred since the last Clear Data 0 0
Overrun command was written to CANCMR (or since
Reset).
1 Data Overrun Status -- a message was lost because the
preceding message to this CAN controller was not read
and released quickly enough.
2 TBS 0 As least one previously-queued message for this CAN 1 X
controller has not yet been sent, and therefore software
should not write to the CANTFI, CANTID, CANTDA, nor
CANTDB registers of that (those) Tx buffer(s).
1 Transmit Buffer Status -- no transmit message is pending
for this CAN controller (in any of the 3 Tx buffers), and
software may write to any of the CANTFI, CANTID,
CANTDA, and CANTDB registers.
3 TCS 0 At least one requested transmission has not been 1 0
successfully completed.
1 Transmit Complete Status -- all requested transmission(s)
has (have) been successfully completed.
4 RS 1 Receive Status: the CAN controller is receiving a 0 0
message.
5 TS 1 Transmit Status: The CAN controller is sending a 0 0
message
6 ES 1 Error Status: one or both of the Transmit and Receive 0 0
Error Counters has reached the limit set in the Error
Warning Limit register.
7 BS 1 Bus Status: the CAN controller is currently prohibited from 0 0
bus activity because the Transmit Error Counter reached
its limiting value of 255.
15:8 - - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
23:16 RXERR - The current value of the Rx Error Counter. 0 X
31:24 TXERR - The current value of the Tx Error Counter. 0 X
Bits 24-31 are captured when CAN arbitration is lost. At the same time, if the ALIE bit in
CANIER is 1, the ALI bit in this register is set, and a CAN interrupt can occur. Once either
of these bytes is captured, its value will remain the same until it is read, at which time it is
released to capture a new value.
The clearing of bits 1-9 and the releasing of bits 16-23 and 24-31 all occur on any read
from CANICR, regardless of whether part or all of the register is read. This means that
software should always read CANICR as a word, and process and deal with all bits of the
register as appropriate for the application.
Table 260. Interrupt and Capture register (ICR: CR: CAN1ICR- address 0xE004 400C,
CAN2ICR - 0xE004 address 800C, CAN3ICR - address 0xE004 C00C, CAN4ICR -
address 0xE005 000C) bit description
Bit Symbol Value Function Reset RM
Value Set
0 RI 1 Receive Interrupt -- this bit is set whenever the RBS bit 0 0
in CANSR and the RIE bit in CANIER are both 1,
indicating that a received message is available.=.
1 TI1 1 Transmit Interrupt 1 -- this bit is set when the TBS1 bit 0 0
in CANSR goes from 0 to 1, indicating that Transmit
buffer 1 is available, and the TIE1 bit in CANIER is 1.
2 Ei 1 Error Warning Interrupt -- this bit is set on every change 0 X
(set or clear) of the Error Status or Bus Status bit in
CANSR, if the EIE bit in CAN is 1 at the time of the
change.
3 DOI 1 Data Overrun Interrupt -- this bit is set when the DOS 0 0
bit in CANSR goes from 0 to 1, if the DOIE bit in CANIE
is 1.
4 WUI 1 Wake-Up Interrupt: this bit is set if the CAN controller is 0 0
sleeping and bus activity is detected, if the WUIE bit in
CANIE is 1.
5 EPI 1 Error Passive Interrupt -- this bit is set if the EPIE bit in 0 0
CANIE is 1, and the CAN controller switches between
Error Passive and Error Active mode in either direction.
6 ALI 1 Arbitration Lost Interrupt -- this bit is set if the ALIE bit 0 0
in CANIE is 1, and the CAN controller loses arbitration
while attempting to transmit.
7 BEI 1 Bus Error Interrupt -- this bit is set if the BEIE bit in 0 X
CANIE is 1, and the CAN controller detects an error on
the bus.
8 IDI 1 ID Ready Interrupt -- this bit is set if the IDIE bit in 0 0
CANIE is 1, and a CAN Identifier has been received.
Table 260. Interrupt and Capture register (ICR: CR: CAN1ICR- address 0xE004 400C,
CAN2ICR - 0xE004 address 800C, CAN3ICR - address 0xE004 C00C, CAN4ICR -
address 0xE005 000C) bit description
Bit Symbol Value Function Reset RM
Value Set
9 TI2 1 Transmit Interrupt 2 -- this bit is set when the TBS2 bit 0 0
in CANSR goes from 0 to 1, indicating that Transmit
buffer 2 is available, and the TIE2 bit in CANIER is 1.
10 TI3 1 Transmit Interrupt 3-- this bit is set when the TBS3 bit 0 0
in CANSR goes from 0 to 1, indicating that Transmit
buffer 3 is available, and the TIE3 bit in CANIER is 1.
15:11 - - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is not
defined.
20:16 ERRBIT Error Code Capture: when the CAN controller detects a 0 X
bus error, the location of the error within the frame is
captured in this field. The value reflects an internal
state variable, and as a result is not very linear:
00010 ID28:21
00011 Start of Frame
00100 SRTR bit
00101 IDE bit
00110 ID20:18
00111 ID17:13
01000 CRC
01001 Res.Bit 0
01010 Data field
01011 DLC
01100 RTR bit
01101 Res.Bit 1
01110 ID4:0
01111 ID12:5
10001 Active Error flag
10010 Intermission
10011 Dominant OK bits
10110 Passive error flag
10111 Error delimiter
11000 CRC delimiter
11001 Ack slot
11010 End of Frame
11011 Ack delimiter
11100 Overload flag
21 ERRDIR When the CAN controller detects a bus error, the 0 X
direction of the current bit is captured in this bit.
0 Transmitting
1 Receiving
Table 260. Interrupt and Capture register (ICR: CR: CAN1ICR- address 0xE004 400C,
CAN2ICR - 0xE004 address 800C, CAN3ICR - address 0xE004 C00C, CAN4ICR -
address 0xE005 000C) bit description
Bit Symbol Value Function Reset RM
Value Set
23;22 ERRC When the CAN controller detects a bus error, the type 0 X
of error is captured in this field:
00 Bit error
01 Form error
10 Stuff error
11 Other error
28:24 ALCBIT - Each time arbitration is lost while trying to send on the 0 X
CAN, the bit number within the frame is captured into
this field. 0 indicates arbitration loss in the first (MS) bit
of the Identifier … 31 indicates loss in the RTR bit of an
extended frame. After this byte is read, the ALI bit is
cleared and a new Arbitration Lost interrupt can occur.
31:29 - - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is not
defined.
Table 261. Interrupt Enable register (IER: CAN1IER - address 0xE004 4010, CAN2IER -
address 0xE004 8010, CAN3IER - address 0xE004 C010, CAN4IER - address
0xE005 0010) bit description
Bit Symbol Function Reset RM
Value Set
0 RIE Receiver Interrupt Enable. 0 X
1 TIE1 Transmit Interrupt Enable (1). 0 X
2 EIE Error Warning Interrupt Enable. 0 X
3 DOIE Data Overrun Interrupt Enable. 0 X
4 WUIE Wake-Up Interrupt Enable. 0 X
5 EPIE Error Passive Interrupt Enable. 0 X
6 ALIE Arbitration Lost Interrupt Enable. 0 X
7 BEIE Bus Error Interrupt Enable. 0 X
8 IDIE ID Ready Interrupt Enable. 0 X
9 TIE2 Transmit Interrupt Enable (2). 0 X
10 TIE3 Transmit Interrupt Enable (3). 0 X
31:11 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
Table 262. Bus Timing Register (BTR: CAN1BTR - address 0xE004 4014, CAN2BTR -
address 0xE004 8014, CAN3BTR - address 0xE004 C014, CAN4BTR - address
0xE005 0014) bit description
Bit Symbol Value Function Reset RM
Value Set
9:0 BRP Baud Rate Prescaler. The VPB clock is divided by (this 0 X
value plus one) to produce the CAN clock.
13:10 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
15:14 SJW The Synchronization Jump Width is (this value plus one) 0 X
CAN clocks.
19:16 TESG1 The delay from the nominal Sync point to the sample point 1100 X
is (this value plus one) CAN clocks.
22:20 TESG2 The delay from the sample point to the next nominal sync 001 X
point is (this value plus one) CAN clocks. The nominal CAN
bit time is (this value plus the value in TSEG1 plus 3) CAN
clocks.
23 SAM 0 The bus is sampled once (recommended for high speed 0 X
buses)
1 The bus is sampled 3 times (recommended for low to
medium speed buses)
31:24 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Table 263. Error Warning Limit register (EWL: CAN1EWL - address 0xE004 4018, CAN2EWL -
address 0xE004 8018, CAN3EWL - address 0xE004 C018, CAN4EWL - address
0xE005 0018) bit description
Bit Symbol Function Reset RM
Value Set
7:0 EWL During CAN operation, this value is compared to both the Tx 9610 = 0x60 X
and Rx Error Counters. If either of these counter matches this
value, the Error Status (ES) bit in CANSR is set.
6.8 Status Register (SR - CAN1SR 0xE004 401C, CAN2SR - 0xE004 801C,
CAN3SR - 0xE004 C01C, CAN4SR - 0xE005 001C)
This register contains three status bytes, in which the bits not related to transmission are
identical to the corresponding bits in the Global Status Register, while those relating to
transmission reflect the status of each of the 3 Tx Buffers. See Table 19–256 for details on
specific CAN channel register address.
Table 264. Status Register (SR - CAN1SR 0xE004 401C, CAN2SR - 0xE004 801C, CAN3SR -
0xE004 C01C, CAN4SR - 0xE005 001C) bit description
Bit Symbol Value Function Reset RM
Value Set
0, 8, 16 RBS These bits are identical to the RSB bit in the GSR. 0 0
1, 9, 17 DOS These bits are identical to the DOS bit in the GSR. 0 0
2, 10, 18 TBS1, 0 Software should not write to any of the CANTFI, 1 X
TBS2, CANTID, CANTDA, and CANTDB registers for this Tx
TBS3 Buffer.
1 Software may write a message into the CANTFI,
CANTID, CANTDA, and CANTDB registers for this Tx
Buffer.
3, 11, 19 TCS1, 0 The previously requested transmission for this Tx 1 0
TCS2, Buffer is not complete.
TCS3 1 The previously requested transmission for this Tx
Buffer has been successfully completed.
4, 12, 20 RS These bits are identical to the RS bit in the GSR. 0 0
5, 13, 21 TS1, 1 The CAN Controller is transmitting a message from 0 0
TS2, this Tx Buffer.
TS3
6, 14, 22 ES These bits are identical to the ES bit in the GSR. 0 0
7, 15, 23 BS These bits are identical to the BS bit in the GSR. 0 0
31:24 - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is
not defined.
Table 265. Receive Frame Status register (RFS - CAN1RFS - address 0xE004 4020, CAN2RFS
- address 0xE004 8020, CAN3RFS - address 0xE004 C020, CAN4RFS - address
0xE005 0020) bit description
Bit Symbol Function Reset RM
Value Set
9:0 ID Index If the BP bit (below) is 0, this value is the zero-based number of the 0 X
Lookup Table RAM entry at which the Acceptance Filter matched
the received Identifier. Disabled entries in the Standard tables are
included in this numbering, but will not be matched. See Section
19–11 “Examples of acceptance filter tables and ID index values” on
page 299 for examples of ID Index values.
10 BP If this bit is 1, the current message was received in AF Bypass 0 X
mode, and the ID Index field (above) is meaningless.
15:11 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
19:16 DLC The field contains the Data Length Code (DLC) field of the current 0 X
received message. When RTR = 0, this is related to the number of
data bytes available in the CANRDA and CANRDB registers as
follows:
0000-0111 = 0 to 7 bytes1000-1111 = 8 bytes
With RTR = 1, this value indicates the number of data bytes
requested to be sent back, with the same encoding.
29:20 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
30 RTR This bit contains the Remote Transmission Request bit of the 0 X
current received message. 0 indicates a Data Frame, in which (if
DLC is non-zero) data can be read from the CANRDA and possibly
the CANRDB registers. 1 indicates a Remote frame, in which case
the DLC value identifies the number of data bytes requested to be
sent using the same Identifier.
31 FF A 0 in this bit indicates that the current received message included 0 X
an 11 bit Identifier, while a 1 indicates a 29 bit Identifier. This affects
the contents of the CANid register described below.
Table 266. Receive Identifier register when FF = 0 (RID: CAN1RID - address 0xE004 4024,
CAN2RID - address 0xE004 8024, CAN3RID - address 0xE004 C024, CAN4RID -
address 0xE005 0024) bit description
Bit Symbol Function Reset Value RM Set
10:0 ID The 11 bit Identifier field of the current received 0 X
message. In CAN 2.0A, these bits are called ID10-0,
while in CAN 2.0B they’re called ID29-18.
31:11 - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is not
defined.
Table 268. Receive Data register A (RDA: CAN1RDA - address 0xE004 4028, CAN2RDA -
address 0xE004 8028, CAN3RDA - address 0xE004 C028, CAN4RDA - address
0xE005 0028) bit description
Bit Symbol Function Reset RM
Value Set
7:0 Data 1 If the DLC field in CANRFS >= 0001, this contains the first Data 0 X
byte of the current received message.
15:8 Data 2 If the DLC field in CANRFS >= 0010, this contains the first Data 0 X
byte of the current received message.
23:16 Data 3 If the DLC field in CANRFS >= 0011, this contains the first Data 0 X
byte of the current received message.
31:24 Data 4 If the DLC field in CANRFS >= 0100, this contains the first Data 0 X
byte of the current received message.
Table 269. Receive Data register B (RDB: CAN1RDB - address 0xE004 402C, CAN2RDB -
address 0xE004 802C, CAN3RDB - address 0xE004 C02C, CAN4RDB - address
0xE005 002C) bit description
Bit Symbol Function Reset RM
Value Set
7:0 Data 5 If the DLC field in CANRFS >= 0101, this contains the first Data 0 X
byte of the current received message.
15:8 Data 6 If the DLC field in CANRFS >= 0110, this contains the first Data 0 X
byte of the current received message.
23:16 Data 7 If the DLC field in CANRFS >= 0111, this contains the first Data 0 X
byte of the current received message.
31:24 Data 8 If the DLC field in CANRFS >= 1000, this contains the first Data 0 X
byte of the current received message.
Table 271. Transfer Identifier register when FF=0 (TID1, 2, 3: CAN1TIDn - addresses
0xE004 4034, 44, 54; CAN2TIDn - addresses 0xE004 8034, 44, 54; CAN3TIDn -
addresses 0xE004 C034, 44, 54; CAN4TIDn - addresses 0xE005 0034, 44, 54) bit
description
Bit Symbol Function Reset RM
Value Set
10:0 ID The 11 bit Identifier to be sent in the next transmit message. 0 X
31:11 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
Table 273. Transmit Data register A (TDA1, 2, 3: CAN1TDAn - addresses 0xE004 4038, 48, 58;
CAN2TDAn - addresses 0xE004 8038, 48, 58; CAN3TDAn - addresses 0xE004
C038, 48, 58; CAN4TDAn - addresses 0xE005 0038, 48, 58) bit description
Bit Symbol Function Reset RM
Value Set
7:0 Data 1 If RTR = 0 and DLC >= 0001 in the corresponding CANTFI, this 0 X
byte is sent as the first Data byte of the next transmit message.
15;8 Data 2 If RTR = 0 and DLC >= 0010 in the corresponding CANTFI, this 0 X
byte is sent as the 2nd Data byte of the next transmit message.
23:16 Data 3 If RTR = 0 and DLC >= 0011 in the corresponding CANTFI, this 0 X
byte is sent as the 3rd Data byte of the next transmit message.
31:24 Data 4 If RTR = 0 and DLC >= 0100 in the corresponding CANTFI, this 0 X
byte is sent as the 4th Data byte of the next transmit message.
Table 274. Transmit Data register B (TDB1, 2, 3: CAN1TDBn - addresses 0xE004 403C, 4C,
5C; CAN2TDBn - addresses 0xE004 803C, 4C, 5C; CAN3TDBn - addresses 0xE004
C03C, 4C, 5C; CAN4TDBn - addresses 0xE005 003C, 4C, 5C) bit description
Bit Symbol Function Reset RM
Value Set
7:0 Data 5 If RTR = 0 and DLC >= 0101 in the corresponding CANTFI, this 0 X
byte is sent as the 5th Data byte of the next transmit message.
15;8 Data 6 If RTR = 0 and DLC >= 0110 in the corresponding CANTFI, this 0 X
byte is sent as the 6th Data byte of the next transmit message.
23:16 Data 7 If RTR = 0 and DLC >= 0111 in the corresponding CANTFI, this 0 X
byte is sent as the 7th Data byte of the next transmit message.
31:24 Data 8 If RTR = 0 and DLC >= 1000 in the corresponding CANTFI, this 0 X
byte is sent as the 8th Data byte of the next transmit message.
The Tx and Rx error counters can be written if RM in CANMOD is 1. Writing 255 to the Tx
Error Counter forces the CAN Controller to Bus-Off state. If Bus-Off (BS in CANSR) is 1,
writing any value 0 through 254 to the Tx Error Counter clears Bus-Off. When software
clears RM in CANMOD thereafter, only one Bus Free condition (11 consecutive recessive
bits) is needed before operation resumes.
The CAN Controller wakes up (and sets WUI in the CAN Interrupt register if WUIE in the
CAN Interrupt Enable register is 1) in response to a) a dominant bit on the CAN bus, or b)
software clearing SM in the CAN Mode register. A sleeping CAN Controller, that wakes up
in response to bus activity, is not able to receive an initial message, until after it detects
Bus_Free (11 consecutive recessive bits). If an interrupt is pending or the CAN bus is
active when software sets SM, the wakeup is immediate.
7.3 Interrupts
Each CAN Controller produces 3 interrupt requests, Receive, Transmit, and “other status”.
The Transmit interrupt is the OR of the Transmit interrupts from the three Tx Buffers. Each
Receive and Transmit interrupt request from each controller is assigned its own channel in
the Vectored Interrupt Controller (VIC), and can have its own interrupt service routine. The
“other status” interrupts from all of the CAN controllers, and the Acceptance Filter LUTerr
condition, are ORed into one VIC channel.
The CAN controller selects among multiple enabled Tx Buffers dynamically, just before it
sends each message.
If Standard (11 bit) Identifiers are used in the application, at least one of 3 tables in
Acceptance Filter RAM must not be empty. If the optional “fullCAN mode” is enabled, the
first table contains Standard identifiers for which reception is to be handled in this mode.
The next table contains individual Standard Identifiers and the third contains ranges of
Standard Identifiers, for which messages are to be received via the CAN Controllers. The
tables of fullCAN and individual Standard Identifiers must be arranged in ascending
numerical order, one per halfword, two per word. Since each CAN bus has its own
address map, each entry also contains the number of the CAN Controller to which it
applies. The numbering of CAN controllers depends on the CAN peripheral implemented:
31 29 26 16
15 13 10 0
DIS NOT
CONTROLLER # IDENTIFIER
ABLE USED
The table of Standard Identifier Ranges contains paired upper and lower (inclusive)
bounds, one pair per word. These must also be arranged in ascending numerical order.
31 29 26 16 10 0
NOT USED
NOT USED
DISABLE
DISABLE
The disable bits in Standard entries provide a means to turn response, to particular CAN
Identifiers or ranges of Identifiers, on and off dynamically. When the Acceptance Filter
function is enabled, only the disable bits in Acceptance Filter RAM can be changed by
software. Response to a range of Standard addresses can be enabled by writing 32 zero
bits to its word in RAM, and turned off by writing 32 one bits (0xFFFF FFFF) to its word in
RAM. Only the disable bits are actually changed. Disabled entries must maintain the
ascending sequence of Identifiers.
If Extended (29 bit) Identifiers are used in the application, at least one of the other two
tables in Acceptance Filter RAM must not be empty, one for individual Extended Identifiers
and one for ranges of Extended Identifiers. The table of individual Extended Identifiers
must be arranged in ascending numerical order.
31 29 28 0
CONTROLLER # IDENTIFIER
The table of ranges of Extended Identifiers must contain an even number of entries, of the
same form as in the individual Extended Identifier table. Like the Individual Extended
table, the Extended Range must be arranged in ascending numerical order. The first and
second (3rd and 4th …) entries in the table are implicitly paired as an inclusive range of
Extended addresses, such that any received address that falls in the inclusive range is
received (accepted). Software must maintain the table to consist of such word pairs.
There is no facility to receive messages to Extended identifiers using the fullCAN method.
Five address registers point to the boundaries between the tables in Acceptance Filter
RAM: fullCAN Standard addresses, Standard Individual addresses, Standard address
ranges, Extended Individual addresses, and Extended address ranges. These tables
must be consecutive in memory. The start of each of the latter four tables is implicitly the
end of the preceding table. The end of the Extended range table is given in an End of
Tables register. If the start address of a table equals the start of the next table or the End
Of Tables register, that table is empty.
When the Receive side of a CAN controller has received a complete Identifier, it signals
the Acceptance Filter of this fact. The Acceptance Filter responds to this signal, and reads
the Controller number, the size of the Identifier, and the Identifier itself from the Controller.
It then proceeds to search its RAM to determine whether the message should be received
or ignored.
If fullCAN mode is enabled and the CAN controller signals that the current message
contains a Standard identifier, the Acceptance Filter first searches the table of identifiers
for which reception is to be done in fullCAN mode. Otherwise, or if the AF doesn’t find a
match in the fullCAN table, it searches its individual Identifier table for the size of Identifier
signalled by the CAN controller. If it finds an equal match, the AF signals the CAN
controller to retain the message, and provides it with an ID Index value to store in its
Receive Frame Status register.
If the Acceptance Filter does not find a match in the appropriate individual Identifier table,
it then searches the Identifier Range table for the size of Identifier signalled by the CAN
controller. If the AF finds a match to a range in the table, it similarly signals the CAN
controller to retain the message, and provides it with an ID Index value to store in its
Receive Frame Status register. If the Acceptance Filter does not find a match in either the
individual or Range table for the size of Identifier received, it signals the CAN controller to
discard/ignore the received message.
Figure 19–70 below is a more detailed and graphic example of the address registers,
table layout, and ID Index values. It shows:
• A Standard Individual table starting at the start of Acceptance Filter RAM and
containing 26 Identifiers, followed by:
• A Standard Group table containing 12 ranges of Identifiers, followed by:
• An Extended Individual table containing 3 Identifiers, followed by:
• An Extended Group table containing 2 ranges of Identifiers.
VPB base +
column_lower column_upper
address
0
00d = 00h 0 1
1
04d = 04h 2
2 3
22
44d = 2Ch 22 23
23
24
48d = 30h 24 25
25
2 6 26 d
52d = 34h
38 38 d
lower_boundary 41 41 d
112d = 70h
group EFF table
Fig 70. Detailed example of acceptance filter tables and ID index values
In order to set this bit and use this mode, two other conditions must be met with respect to
the contents of Acceptance Filter RAM and the pointers into it:
• The Standard Frame Individual Start Address Register (SFF_sa) must be greater than
or equal to the number of IDs for which automatic receive storage is to be done, times
two. SFF_sa must be rounded up to a multiple of 4 if necessary.
• The EndOfTable register must be less than or equal to 0x800 minus 6 times the
SFF_sa value, to allow 12 bytes of message storage for each ID for which automatic
receive storage will be done.
• The area between the start of Acceptance Filter RAM and the SFF_sa address, is
used for a table of individual Standard IDs and CAN Controller/bus identification,
sorted in ascending order and in the same format as in the Individual Standard ID
table (see Figure 19–67 “Entry in FullCAN and individual standard identifier tables” on
page 294). Entries can be marked as “disabled” as in the other Standard tables. If
there are an odd number of “FullCAN” ID’s, at least one entry in this table must be so
marked.
• The first (SFF_sa)/2 IDindex values are assigned to these automatically-stored ID’s.
That is, IDindex values stored in the Rx Frame Status Register, for IDs not handled in
this way, are increased by (SFF_sa)/2 compared to the values they would have when
eFCAN is 0.
• When a Standard ID is received, the Acceptance Filter searches this table before the
Standard Individual and Group tables.
• When a message is received for a controller and ID in this table, the Acceptance filter
reads the received message out of the CAN controller and stores it in Acceptance
Filter RAM, starting at (EndOfTable) + its IDindex*12.
• The format of such messages is shown in Table 19–287.
Table 287. Format of automatically stored Rx message
Address 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
The FF, RTR, and DLC fields are as described in Table 19–265. Hardware sets the SEM
field to 01 when it begins to update a message, and to 11 when it finishes doing so.
Software should clear SEM to 00 as part of accessing a message. Software must access
the three words in a message in a particular way to ensure that they are all from the same
received message. Figure 19–71 below shows how software should use the SEM field to
ensure this.
START
SEM == 01?
SEM == 00?
For an overview of how LPC21xx and LPC22xx parts and versions are described in this
manual, see Section 1–2 “How to read this manual”.
2. Features
• 10 bit successive approximation analog to digital converter
• Input multiplexing among 4 pins or 8 pins
• Power-down mode
• Measurement range 0 V to VDDA
• 10 bit conversion time ≥ 2.44 μs (400,000 conversions per second)
• Burst conversion mode for single or multiple inputs
• Optional conversion on transition on input pin or Timer Match signal
• Dedicated result register to reduce interrupt overhead for every analog pin (see
Table 20–288)
3. Description
Basic clocking for the ADC is provided by the APB clock. A programmable divider is
included in each converter to scale this clock to the 4.5 MHz (max) clock needed by the
successive approximation process. A fully accurate conversion requires 11 of these
clocks.
4. Pin description
Table 20–289 gives a brief summary of each of ADC related pins.
Remark: When the ADC is not used, the VDDA pin must be connected to the power supply
VDD(3V3), and pin VSSA must be grounded. These pins should not be left floating.
5. Register description
The ADC registers are shown in Table 20–290.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
Table 291. ADC Control Register (ADCR - address 0xE003 4000) bit description
Bit Symbol Value Description Reset
value
26:24 START When the BURST bit is 0, these bits control whether and when an ADC conversion is 0
started:
000 No start (this value should be used when clearing PDN to 0).
001 Start conversion now.
010 Start conversion when the edge selected by bit 27 occurs on
P0.16/EINT0/MAT0.2/CAP0.2 pin.
011 Start conversion when the edge selected by bit 27 occurs on P0.22/CAP0.0/MAT0.0 pin.
100 Start conversion when the edge selected by bit 27 occurs on MAT0.1.
101 Start conversion when the edge selected by bit 27 occurs on MAT0.3.
110 Start conversion when the edge selected by bit 27 occurs on MAT1.0.
111 Start conversion when the edge selected by bit 27 occurs on MAT1.1.
27 EDGE This bit is significant only when the START field contains 010-111. In these cases: 0
1 Start conversion on a falling edge on the selected CAP/MAT signal.
0 Start conversion on a rising edge on the selected CAP/MAT signal.
31:28 - Reserved, user software should not write ones to reserved bits. The value read from a NA
reserved bit is not defined.
Table 293. ADC Status Register (ADSTAT - address 0xE003 4004) bit description
Bit Symbol Description Reset
value
0 DONE0 This bit mirrors the DONE status flag from the result register for ADC channel 0. 0
1 DONE1 This bit mirrors the DONE status flag from the result register for ADC channel 1. 0
2 DONE2 This bit mirrors the DONE status flag from the result register for ADC channel 2. 0
3 DONE3 This bit mirrors the DONE status flag from the result register for ADC channel 3. 0
4 DONE4 This bit mirrors the DONE status flag from the result register for ADC channel 4. 0
5 DONE5 This bit mirrors the DONE status flag from the result register for ADC channel 5. 0
6 DONE6 This bit mirrors the DONE status flag from the result register for ADC channel 6. 0
7 DONE7 This bit mirrors the DONE status flag from the result register for ADC channel 7. 0
8 OVERRUN0 This bit mirrors the OVERRRUN status flag from the result register for ADC channel 0. 0
9 OVERRUN1 This bit mirrors the OVERRRUN status flag from the result register for ADC channel 1. 0
10 OVERRUN2 This bit mirrors the OVERRRUN status flag from the result register for ADC channel 2. 0
11 OVERRUN3 This bit mirrors the OVERRRUN status flag from the result register for ADC channel 3. 0
12 OVERRUN4 This bit mirrors the OVERRRUN status flag from the result register for ADC channel 4. 0
13 OVERRUN5 This bit mirrors the OVERRRUN status flag from the result register for ADC channel 5. 0
14 OVERRUN6 This bit mirrors the OVERRRUN status flag from the result register for ADC channel 6. 0
15 OVERRUN7 This bit mirrors the OVERRRUN status flag from the result register for ADC channel 7. 0
16 ADINT This bit is the ADC interrupt flag. It is one when any of the individual ADC channel Done 0
flags is asserted and enabled to contribute to the ADC interrupt via the ADINTEN register.
31:17 - Reserved, user software should not write ones to reserved bits. The value read from a NA
reserved bit is not defined.
Table 294. ADC Interrupt Enable Register (ADINTEN - address 0xE003 400C) bit description
Bit Symbol Value Description Reset
value
0 ADINTEN0 0 Completion of a conversion on ADC channel 0 will not generate an interrupt. 0
1 Completion of a conversion on ADC channel 0 will generate an interrupt.
1 ADINTEN1 0 Completion of a conversion on ADC channel 1 will not generate an interrupt. 0
1 Completion of a conversion on ADC channel 1 will generate an interrupt.
2 ADINTEN2 0 Completion of a conversion on ADC channel 2 will not generate an interrupt. 0
1 Completion of a conversion on ADC channel 2 will generate an interrupt.
Table 294. ADC Interrupt Enable Register (ADINTEN - address 0xE003 400C) bit description
Bit Symbol Value Description Reset
value
3 ADINTEN3 0 Completion of a conversion on ADC channel 3 will not generate an interrupt. 0
1 Completion of a conversion on ADC channel 3 will generate an interrupt.
4 ADINTEN4 0 Completion of a conversion on ADC channel 4 will not generate an interrupt. 0
1 Completion of a conversion on ADC channel 4 will generate an interrupt.
5 ADINTEN5 0 Completion of a conversion on ADC channel 5 will not generate an interrupt. 0
1 Completion of a conversion on ADC channel 5 will generate an interrupt.
6 ADINTEN6 0 Completion of a conversion on ADC channel 6 will not generate an interrupt. 0
1 Completion of a conversion on ADC channel 6 will generate an interrupt.
7 ADINTEN7 0 Completion of a conversion on ADC channel 7 will not generate an interrupt. 0
1 Completion of a conversion on ADC channel 7 will generate an interrupt.
8 ADGINTEN 0 Only the individual ADC channels enabled by ADINTEN7:0 will generate 1
interrupts.
1 Only the global DONE flag in ADDR is enabled to generate an interrupt.
31:9 - Reserved, user software should not write ones to reserved bits. The value read NA
from a reserved bit is not defined.
5.5 ADC Data Registers (ADDR0 to ADDR7- 0xE003 4010 to 0xE003 402C)
The ADC Data Register hold the result when an ADC conversion is complete, and also
include the flags that indicate when a conversion has been completed and when a
conversion overrun has occurred.
Table 295. ADC Data Registers (ADDR0 to ADDR7 - 0xE003 4010 to 0xE003 402C) bit description
Bit Symbol Description Reset
value
5:0 - Reserved, user software should not write ones to reserved bits. The value read from a NA
reserved bit is not defined.
15:6 RESULT When DONE is 1, this field contains a binary fraction representing the voltage on the AIN pin, NA
divided by the voltage on the VREF pin (V/VREF). Zero in the field indicates that the voltage on
the AIN pin was less than, equal to, or close to that on VSSA, while 0x3FF indicates that the
voltage on AIN was close to, equal to, or greater than that on VREF.
29:16 - Reserved, user software should not write ones to reserved bits. The value read from a NA
reserved bit is not defined.
30 OVERRUN This bit is 1 in burst mode if the results of one or more conversions was (were) lost and
overwritten before the conversion that produced the result in the RESULT bits.This bit is
cleared by reading this register.
31 DONE This bit is set to 1 when an ADC conversion completes. It is cleared when this register is read. NA
6. Operation
on a specified edge of either of 2 Capture/Match pins. The pin state from the selected pad
or the selected Match signal, XORed with ADCR bit 27, is used in the edge detection
logic.
6.2 Interrupts
An interrupt request is asserted to the Vectored Interrupt Controller (VIC) when the DONE
bit is 1. Software can use the Interrupt Enable bit for the ADC in the VIC to control whether
this assertion results in an interrupt. DONE is negated when the ADDR is read.
For an overview of how LPC21xx and LPC22xx parts and versions are described in this
manual, see Section 1–2 “How to read this manual”.
3. Features
• In-System Programming: In-System programming (ISP) means programming or
reprogramming the on-chip flash memory using the boot loader software and a serial
port. This can be done when the part resides in the end-user board.
• In Application Programming: In-Application (IAP) programming means performing
erase and write operation on the on-chip flash memory, as directed by the end-user
application code.
4. Applications
The flash boot loader provides both In-System and In-Application programming interfaces
for programming the on-chip flash memory.
5. Description
The flash boot loader code is executed every time the part is powered on or reset. The
loader can execute the ISP command handler or the user application code. A LOW level
after reset at the P0.14 pin is considered as an external hardware request to start the ISP
command handler. Assuming that a proper signal is present on XTAL1 pin when the rising
edge on RESET pin is generated, it may take up to 3 ms before P0.14 is sampled and the
decision on whether to continue with user code or ISP handler is made. If P0.14 is
sampled low and the watchdog overflow flag is set, the external hardware request to start
the ISP command handler is ignored. If there is no request for the ISP command handler
execution (P0.14 is sampled HIGH after reset), a search is made for a valid user program.
If a valid user program is found then the execution control is transferred to it. If a valid user
program is not found, the auto-baud routine is invoked.
Pin P0.14, which is used as hardware request for ISP, requires special attention. Since
P0.14 is in high impedance mode after reset, it is important that the user provides external
hardware (a pull-up resistor or other device) to put the pin in a defined state. Otherwise
unintended entry into ISP mode may occur.
0x0003 FFFF
8 kB BOOT BLOCK RE-MAPPED TO
HIGHER ADDRESS RANGE
0x0003 E000
Fig 72. Map of lower memory after reset for 256 kB flash devices
If the signature is not valid, the auto-baud routine synchronizes with the host via serial port
0. The host should send a ’?’ (0x3F) as a synchronization character and wait for a
response. The host side serial port settings should be 8 data bits, 1 stop bit and no parity.
The auto-baud routine measures the bit time of the received synchronization character in
terms of its own frequency and programs the baud rate generator of the serial port. It also
sends an ASCII string ("Synchronized<CR><LF>") to the Host. In response to this host
should send the same string ("Synchronized<CR><LF>"). The auto-baud routine looks at
the received characters to verify synchronization. If synchronization is verified then
"OK<CR><LF>" string is sent to the host. Host should respond by sending the crystal
frequency (in kHz) at which the part is running. For example, if the part is running at 10
MHz, the response from the host should be "10000<CR><LF>". "OK<CR><LF>" string is
sent to the host after receiving the crystal frequency. If synchronization is not verified then
the auto-baud routine waits again for a synchronization character. For auto-baud to work
correctly, the crystal frequency should be greater than or equal to 10 MHz. The on-chip
PLL is not used by the boot code.
Once the crystal frequency is received the part is initialized and the ISP command handler
is invoked. For safety reasons an "Unlock" command is required before executing the
commands resulting in flash erase/write operations and the "Go" command. The rest of
the commands can be executed without the unlock command. The Unlock command is
required to be executed once per ISP session. The Unlock command is explained in
Section 21–9 “ISP commands” on page 321.
RESET
INITIALIZE
CRP no
ENABLED?
yes
WATCHDOG
FLAG SET?
no
no
BOOT
yes
EXTERNAL?
CRP3 ENABLED?
CRP no
ENABLED?
no
RUN AUTO-BAUD
no AUTO-BAUD
SUCCESSFUL?
yes
The grey-shaded area is specific to the boot process for LPC22xx parts with external memory. CRP3 is available starting with
bootloader versions 1.68 (see Table 21–301).
Fig 73. Boot process flowchart
6. Sector numbers
Some IAP and ISP commands operate on "sectors" and specify sector numbers. The
following table indicates the correspondence between sector numbers and memory
addresses for LPC21xx/LPC22xx devices containing 64 kB, 128 kB, or 256 kB of flash
respectively. IAP, ISP, and RealMonitor routines are located in the boot block. The boot
block is present at the top of each flash memory. Because of the boot block, only 56 kB of
64 kB, 120 kB of the 128 kB, and 248 kB of the 256 kB flash devices are available for user
code. ISP and IAP commands do not allow write/erase/go operation on the boot block.
The operation of ECC is transparent to the running application. The ECC content itself is
stored in a flash memory not accessible by user’s code to either read from it or write into it
on its own. A byte of ECC corresponds to every consecutive 128 bits of the user
accessible Flash. Consequently, Flash bytes from 0x0000 0000 to 0x0000 000F are
protected by the first ECC byte, Flash bytes from 0x0000 0010 to 0x0000 001F are
protected by the second ECC byte, etc.
Whenever the CPU requests a read from Flash, both 128 bits of raw data containing the
specified memory location and the matching ECC byte are evaluated. If the ECC
mechanism detects a single error in the fetched data, a correction will be applied before
data are provided to the CPU. When a write request into the user’s Flash is made, write of
user specified content is accompanied by a matching ECC value calculated and stored in
the ECC memory.
When a sector of user’s Flash memory is erased, corresponding ECC bytes are also
erased. Once an ECC byte is written, it can not be updated unless it is erased first.
Therefore, for the implemented ECC mechanism to perform properly, data must be written
into the flash memory in groups of 16 bytes (or multiples of 16), aligned as described
above.
In case a CRP mode is enabled and access to the chip is allowed via the ISP, an
unsupported or restricted ISP command will be terminated with return code
CODE_READ_PROTECTION_ENABLED.
Table 300. Code read protection options for different bootloader revisions
Option 1 (CRP1) Option 2 (CRP2) Option 3 (CRP 3) Option 4 (bootloader code
rev. 1.65 only)
JTAG access is blocked. JTAG access is blocked. JTAG access is blocked. JTAG access is blocked.
Supports partial flash • ISP commands No ISP commands are • ISP commands
updates. allowed: Echo; Set allowed when P0.14 is pulled allowed: Erase (all
• ISP commands Baud; Erase (all sectors LOW and a valid user sectors only); Prepare
allowed: Echo; Set only); Blank Check (fail program is present in flash Sector; Unlock.
Baud; Erase (except returns value 0 at sector 0. • ISP commands not
sector 0, must erase all location 0); Prepare allowed: Echo; Set
to erase sector 0); Blank Sector; Unlock; Read Baud; Blank Check (fail
Check (fail returns value Part ID; Read Boot code returns value 0 at
0 at location 0); Prepare version. location 0); Write to
Sector; Unlock; Read • ISP commands not RAM; Read Memory;
Part ID; Read Boot code allowed: Write to RAM; Copy RAM to Flash; Go;
version; Write to RAM Read Memory; Copy Compare; Read Part ID;
(addresses above RAM to Flash; Go; Read Boot code version.
0x4000 0200); Copy Compare.
RAM to Flash (except
sector 0)
• ISP commands not
allowed: Write to RAM
below address 0x4000
0200; Read Memory;
Copy RAM to Flash
(write to sector 0); Erase
sector 0; Go; Compare.
Table 21–301 shows which code read protection options can be selected for any
implemented boot loader revision. Note that parts with boot loader revisions ≤ 1.60 do not
allow code read protection.
9. ISP commands
The following commands are accepted by the ISP command handler. Detailed status
codes are supported for each command. The command handler sends the return code
INVALID_COMMAND when an undefined command is received. Commands and return
codes are in ASCII format.
CMD_SUCCESS is sent by ISP command handler only when received ISP command has
been completely executed and the new ISP command can be given by the host.
Exceptions from this rule are "Set Baud Rate", "Write to RAM", "Read Memory", and "Go"
commands.
Table 305. Correlation between possible ISP baudrates and external crystal frequency (in
MHz)
ISP Baudrate .vs. 9600 19200 38400 57600 115200 230400
External Crystal Frequency
10.0000 + + +
11.0592 + + +
12.2880 + + +
14.7456 + + + + + +
15.3600 +
18.4320 + + +
19.6608 + + +
24.5760 + + +
25.0000 + + +
ISP command handler compares it with the check-sum of the received bytes. If the
check-sum matches, the ISP command handler responds with "OK<CR><LF>" to
continue further transmission. If the check-sum does not match, the ISP command
handler responds with "RESEND<CR><LF>". In response the host should retransmit the
bytes.
9.6 Prepare sector(s) for write operation <start sector number> <end
sector number>
This command makes flash write/erase operation a two step process.
9.7 Copy RAM to Flash <Flash address> <RAM address> <no of bytes>
Table 310. ISP Copy command
Command C
Input Flash Address(DST): Destination Flash address where data bytes are to be
written. The destination address should be a 256 byte boundary.
RAM Address(SRC): Source RAM address from where data bytes are to be read.
Number of Bytes: Number of bytes to be written. Should be 256 | 512 | 1024 |
4096.
Return Code CMD_SUCCESS |
SRC_ADDR_ERROR (Address not on word boundary) |
DST_ADDR_ERROR (Address not on correct boundary) |
SRC_ADDR_NOT_MAPPED |
DST_ADDR_NOT_MAPPED |
COUNT_ERROR (Byte count is not 256 | 512 | 1024 | 4096) |
SECTOR_NOT_PREPARED_FOR WRITE_OPERATION |
BUSY |
CMD_LOCKED |
PARAM_ERROR |
CODE_READ_PROTECTION_ENABLED
Description This command is used to program the flash memory. The "Prepare Sector(s) for
Write Operation" command should precede this command. The affected sectors are
automatically protected again once the copy command is successfully executed.
The boot block cannot be written by this command. This command is blocked when
code read protection is enabled.
Example "C 0 1073774592 512<CR><LF>" copies 512 bytes from the RAM address
0x4000 8000 to the flash address 0.
Define the IAP location entry point. Since the 0th bit of the IAP location is set there will be
a change to Thumb instruction set when the program counter branches to this address.
Define data structure or pointers to pass IAP command table and result table to the IAP
function:
or
Define pointer to function type, which takes two parameters and returns void. Note the IAP
returns the result with the base address of the table residing in R1.
UM10114_3 © NXP B.V. 2008. All rights reserved.
iap_entry=(IAP) IAP_LOCATION;
Whenever you wish to call IAP you could use the following statement.
The IAP call could be simplified further by using the symbol definition file feature
supported by ARM Linker in ADS (ARM Developer Suite). You could also call the IAP
routine using assembly code.
The following symbol definitions can be used to link IAP routine and user application:
#<SYMDEFS># ARM Linker, ADS1.2 [Build 826]: Last Updated: Wed May 08 16:12:23 2002
0x7fffff90 T rm_init_entry
0x7fffffa0 A rm_undef_handler
0x7fffffb0 A rm_prefetchabort_handler
0x7fffffc0 A rm_dataabort_handler
0x7fffffd0 A rm_irqhandler
0x7fffffe0 A rm_irqhandler2
0x7ffffff0 T iap_entry
As per the ARM specification (The ARM Thumb Procedure Call Standard SWS ESPC
0002 A-05) up to 4 parameters can be passed in the r0, r1, r2 and r3 registers
respectively. Additional parameters are passed on the stack. Up to 4 parameters can be
returned in the r0, r1, r2 and r3 registers respectively. Additional parameters are returned
indirectly via memory. Some of the IAP calls require more than 4 parameters. If the ARM
suggested scheme is used for the parameter passing/returning then it might create
problems due to difference in the C compiler implementation from different vendors. The
suggested parameter passing scheme reduces such risk.
The flash memory is not accessible during a write or erase operation. IAP commands,
which results in a flash write/erase operation, use 32 bytes of space in the top portion of
the on-chip RAM for execution. The user program should not use this space if IAP flash
programming is permitted in the application.
COMMAND CODE
command
PARAMETER 1 parameter table
PARAMETER 2
ARM REGISTER r0
PARAMETER n
ARM REGISTER r1
STATUS CODE
RESULT 1 command
result table
RESULT 2
RESULT n
2. Description
The bootloader is designed as a tool that enables the user to load system specific
application for further programming of in system available off-chip Flash and/or RAM
resources. The bootloader itself does not contain any external memory programming
algorithms. The bootloader implemented in flashless LPC21xx/LPC22xx supports a
limited set of commands dedicated to code download and its execution from on-chip RAM
only. UART0 is the sole serial channel the boot loader can use for data download.
Although a fractional divider is available in the UART0, it is not used by the on-chip serial
bootloader.
The serial boot loader code is executed every time the part is powered on or reset occurs.
The loader executes the initial portion of the ISP command handler and pin P0.14 is
sampled in software. Assuming that a proper signal is present on XTAL1 pin when the
rising edge on RESET pin is generated, it may take up to 3 ms before P0.14 is sampled
and the decision on whether to continue with user code or ISP handler is made.
If there is no request for the ISP command handler execution (P0.14 was HIGH after a
reset), the external memory bank 0 configuration register will be programmed with the
requested boot memory data width (8, 16 or 32 bit wide, based on BOOT pins at reset,
see Section 8–6.5). The interrupt vectors will be mapped from the external memory bank
0, and code residing in the external boot memory bank 0 will be executed.
A LOW level after reset at the P0.14 pin is considered as the external hardware request to
start the ISP command handler.
If P0.14 is sampled LOW and the watchdog overflow flag is not set, the part will continue
with executing ISP handler code, which starts with the auto-bauding procedure.
If P0.14 is sampled LOW and the watchdog overflow flag is set, the external hardware
request to start the ISP command handler is ignored, and external code is executed as in
case when P0.14 is HIGH after reset.
Pin P0.14 that is used as hardware request for ISP requires special attention. Since P0.14
is in high impedance mode after reset, it is important that the user provides external
hardware (a pull-up resistor or other device) to put the pin in a defined state. Otherwise
unintended entry into ISP mode may occur.
UM10114_3 © NXP B.V. 2008. All rights reserved.
However, if the ISP handler was not invoked by P0.14, the interrupt vectors residing in the
boot sector of the off-chip memory (bank 0) will become active and the bottom 64 bytes of
the external boot sector will become visible in the memory region starting from the
address 0x0000 0000.
0x0001 FFFF
If ISP handler was requested via P0.14, the auto-baud routine synchronizes with the host
via serial port 0. The host should send a synchronization character(’?’) and wait for a
response. The host side serial port settings should be 8 data bits, 1 stop bit and no parity.
The auto-baud routine measures the bit time of the received synchronization character in
terms of its own frequency and programs the baud rate generator of the serial port. It also
sends an ASCII string ("Synchronized<CR><LF>") to the host. In response to this the host
should send the received string ("Synchronized<CR><LF>"). The auto-baud routine looks
at the received characters to verify synchronization. If synchronization is verified then
"OK<CR><LF>" string is sent to the host. The host should respond by sending the crystal
UM10114_3 © NXP B.V. 2008. All rights reserved.
frequency (in kHz) at which the part is running. For example if the part is running at
10 MHz a valid response from the host should be "10000<CR><LF>". "OK<CR><LF>"
string is sent to the host after receiving the crystal frequency. If synchronization is not
verified then the auto-baud routine waits again for a synchronization character. For
auto-baud to work correctly, the crystal frequency should be greater than or equal to
10 MHz. The on-chip PLL is not used by the boot code.
Once the crystal frequency is received the part is initialized and the ISP command handler
is invoked. For safety reasons an "Unlock" command is required before executing the
"Go" command. The rest of the commands can be executed without the unlock command.
The "Unlock" command is required to be executed once per ISP session. Unlock
command is explained in the "ISP Commands" section.
4. Communication protocol
All ISP commands should be sent as single ASCII strings. Strings should be terminated
with Carriage Return (CR) and/or Line Feed (LF) control characters. Extra <CR> and
<LF> characters are ignored. All ISP responses are sent as <CR><LF> terminated ASCII
strings. Data is sent and received in UU-encoded format.
RESET
INITIALIZE
Yes
WATCHDOG
FLAG SET?
No
EXECUTE EXTERNAL
USER CODE
ENTER ISP No
MODE?
(PO.14 LOW?)
Yes
RUN AUTO-BAUD
No
AUTO-BAUD
SUCCESSFUL?
Yes
RECEIVE CRYSTAL
FREQUENCY
CMD_SUCCESS is sent by ISP command handler only when received ISP command has
been completely executed and the new ISP command can be given by the host.
Exceptions from this rule are "Set Baud Rate", "Write to RAM", "Read Memory", and "Go"
commands.
Table 331. Correlation between possible ISP baudrates and external crystal frequency (in
MHz)
ISP Baudrate 9600 19200 38400 57600 115200 230400
.vs.
external crystal frequency
10.0000 + + +
11.0592 + + +
12.2880 + + +
14.7456 + + + + + +
15.3600 +
Table 331. Correlation between possible ISP baudrates and external crystal frequency (in
MHz)
ISP Baudrate 9600 19200 38400 57600 115200 230400
.vs.
external crystal frequency
18.4320 + + +
19.6608 + + +
24.5760 + + +
25.0000 + + +
parameter table should be big enough to hold all the results in case if number of results
are more than number of parameters. Parameter passing is illustrated in Figure 22–77.
The number of parameters and results vary according to the IAP command. The
maximum number of parameters is 3, passed to the "Compare" command. The maximum
number of results is 1, returned in case of every of three available IAP commands. The
command handler sends the status code INVALID_COMMAND when an undefined
command is received. The IAP routine resides at 0x7FFF FFF0 location and it is thumb
code.
Define the IAP location entry point. Since the 0th bit of the IAP location is set there will be
a change to Thumb instruction set when the program counter branches to this address.
Define data or pointers to pass IAP command table and result table to the IAP function
or
Define pointer to function type, which takes two parameters and returns void. Note the IAP
returns the result with the base address of the table residing in R1.
iap_entry=(IAP) IAP_LOCATION;
Whenever you wish to call IAP you could use the following statement.
The IAP call could be simplified further by using the symbol definition file feature
supported by ARM Linker in ADS (ARM Developer Suite). You could also call the IAP
routine using assembly code.
The following symbol definitions can be used to link IAP routine and user application.
#<SYMDEFS># ARM Linker, ADS1.2 [Build 826]: Last Updated: Wed May 08 16:12:23 2002
0x7fffff90 T rm_init_entry
0x7fffffa0 A rm_undef_handler
0x7fffffb0 A rm_prefetchabort_handler
0x7fffffc0 A rm_dataabort_handler
0x7fffffd0 A rm_irqhandler
0x7fffffe0 A rm_irqhandler2
0x7ffffff0 T iap_entry
UM10114_3 © NXP B.V. 2008. All rights reserved.
As per the ARM specification (The ARM Thumb Procedure Call Standard SWS ESPC
0002 A-05) up to 4 parameters can be passed in the r0, r1, r2 and r3 registers
respectively. Additional parameters are passed on the stack. Up to 4 parameters can be
returned in the r0, r1, r2 and r3 registers respectively. Additional parameters are returned
indirectly via memory. If the ARM suggested scheme is used for the parameter
passing/returning then it might create problems due to difference in the C compiler
implementation from different vendors. The suggested parameter passing scheme
reduces such risk.
COMMAND CODE
command
PARAMETER 1 parameter table
PARAMETER 2
ARM REGISTER r0
PARAMETER n
ARM REGISTER r1
STATUS CODE
RESULT 1 command
result table
RESULT 2
RESULT n
17.3 Compare
Table 344. IAP Compare command description
Command Compare
Input Command Code 56
Param0(DST): Starting address (on or off-chip) from where data bytes are to be
compared. This address should be a word boundary.
Param1(SRC): Starting address (on or off-chip) from where data bytes are to be
compared. This address should be a word boundary.
Param2: Number of bytes to be compared. Count should be in multiple of 4.
Status Code CMD_SUCCESS |
COMPARE_ERROR |
COUNT_ERROR (Byte count is not multiple of 4)
ADDR_ERROR
ADDR_NOT_MAPPED
Result Result0: Offset of the first mismatch if the Status Code is COMPARE_ERROR.
Description This command is used to compare the memory contents at two locations.
Compare result may not be correct when source or destination address contains
any of the first 64 bytes starting from address zero. After any reset the first 64 bytes
are remapped to on-chip ROM boot sector.
For an overview of how LPC21xx and LPC22xx parts and versions are described in this
manual, see Section 1–2 “How to read this manual”.
2. Features
• No target resources are required by the software debugger in order to start the
debugging session.
• Allows the software debugger to talk via a JTAG (Joint Test Action Group) port directly
to the core.
• Inserts instructions directly in to the ARM7TDMI-S core.
• The ARM7TDMI-S core or the System state can be examined, saved or changed
depending on the type of instruction inserted.
• Allows instructions to execute at a slow debug speed or at a fast system speed.
3. Applications
The EmbeddedICE logic provides on-chip debug support. The debugging of the target
system requires a host computer running the debugger software and an EmbeddedICE
protocol convertor. EmbeddedICE protocol convertor converts the Remote Debug
Protocol commands to the JTAG data needed to access the ARM7TDMI-S core present
on the target system.
4. Description
The ARM7TDMI-S Debug Architecture uses the existing JTAG1 port as a method of
accessing the core. The scan chains that are around the core for production test are
reused in the debug state to capture information from the databus and to insert new
information into the core or the memory. There are two JTAG-style scan chains within the
ARM7TDMI-S. A JTAG-style Test Access Port Controller controls the scan chains. In
addition to the scan chains, the debug architecture uses EmbeddedICE logic which
resides on chip with the ARM7TDMI-S core. The EmbeddedICE has its own scan chain
that is used to insert watchpoints and breakpoints for the ARM7TDMI-S core. The
EmbeddedICE logic consists of two real time watchpoint registers, together with a control
and status register. One or both of the watchpoint registers can be programmed to halt the
ARM7TDMI-S core. Execution is halted when a match occurs between the values
programmed into the EmbeddedICE logic and the values currently appearing on the
address bus, databus and some control signals. Any bit can be masked so that its value
1.For more details refer to IEEE Standard 1149.1 - 1990 Standard Test Access Port and Boundary Scan Architecture.
does not affect the comparison. Either watchpoint register can be configured as a
watchpoint (i.e. on a data access) or a break point (i.e. on an instruction fetch). The
watchpoints and breakpoints can be combined such that:
• The conditions on both watchpoints must be satisfied before the ARM7TDMI core is
stopped. The CHAIN functionality requires two consecutive conditions to be satisfied
before the core is halted. An example of this would be to set the first breakpoint to
trigger on an access to a peripheral and the second to trigger on the code segment
that performs the task switching. Therefore when the breakpoints trigger the
information regarding which task has switched out will be ready for examination.
• The watchpoints can be configured such that a range of addresses are enabled for
the watchpoints to be active. The RANGE function allows the breakpoints to be
combined such that a breakpoint is to occur if an access occurs in the bottom 256
bytes of memory but not in the bottom 32 bytes.
The ARM7TDMI-S core has a Debug Communication Channel function in-built. The
debug communication channel allows a program running on the target to communicate
with the host debugger or another separate host without stopping the program flow or
even entering the debug state. The debug communication channel is accessed as a
co-processor 14 by the program running on the ARM7TDMI-S core. The debug
communication channel allows the JTAG port to be used for sending and receiving data
without affecting the normal program flow. The debug communication channel data and
control registers are mapped in to addresses in the EmbeddedICE logic.
5. Pin description
Table 346. EmbeddedICE Pin Description
Pin name Type Description
TMS Input Test Mode Select. The TMS pin selects the next state in the TAP state
machine.
TCK Input Test Clock. This allows shifting of the data in, on the TMS and TDI pins. It
is a positive edge triggered clock with the TMS and TCK signals that
define the internal state of the device.
Remark: This clock must be slower than 1⁄6 of the CPU clock (CCLK) for
the JTAG interface to operate.
TDI Input Test Data In. This is the serial data input for the shift register.
TDO Output Test Data Output. This is the serial data output from the shift register.
Data is shifted out of the device on the negative edge of the TCK signal.
nTRST Input Test Reset. The nTRST pin can be used to reset the test logic within the
EmbeddedICE logic.
RTCK Output Returned Test Clock. Extra signal added to the JTAG port. Required for
designs based on ARM7TDMI-S processor core. Multi-ICE (Development
system from ARM) uses this signal to maintain synchronization with
targets having slow or widely varying clock frequency. For details refer to
"Multi-ICE System Design considerations Application Note 72 (ARM DAI
0072A)".
7. Register description
The EmbeddedICE logic contains 16 registers as shown in Table 23–347. below. The
ARM7TDMI-S debug architecture is described in detail in "ARM7TDMI-S (rev 4) Technical
Reference Manual" (ARM DDI 0234A) published by ARM Limited and is available via
Internet.
8. Block diagram
The block diagram of the debug environment is shown below in Figure 23–78.
JTAG PORT
serial
parallel
EMBEDDED ICE
interface
INTERFACE 5
EMBEDDED ICE
PROTOCOL
CONVERTER
ARM7TDMI-S
TARGET BOARD
For an overview of how LPC21xx and LPC22xx parts and versions are described in this
manual, see Section 1–2 “How to read this manual”.
2. Features
• Closely track the instructions that the ARM core is executing.
• One external trigger input
• 10 pin interface
• All registers are programmed through JTAG interface.
• Does not consume power when trace is not being used.
• THUMB instruction set support
3. Applications
As the microcontroller has significant amounts of on-chip memories, it is not possible to
determine how the processor core is operating simply by observing the external pins. The
ETM provides real-time trace capability for deeply embedded processor cores. It outputs
information about processor execution to a trace port. A software debugger allows
configuration of the ETM using a JTAG interface and displays the trace information that
has been captured, in a format that a user can easily understand.
4. Description
The ETM is connected directly to the ARM core and not to the main AMBA system bus. It
compresses the trace information and exports it through a narrow trace port. An external
Trace Port Analyzer captures the trace information under software debugger control.
Trace port can broadcast the Instruction trace information. Instruction trace (or PC trace)
shows the flow of execution of the processor and provides a list of all the instructions that
were executed. Instruction trace is significantly compressed by only broadcasting branch
addresses as well as a set of status signals that indicate the pipeline status on a cycle by
cycle basis. Trace information generation can be controlled by selecting the trigger
resource. Trigger resources include address comparators, counters and sequencers.
Since trace information is compressed the software debugger requires a static image of
the code being executed. Self-modifying code can not be traced because of this
restriction.
[1] For details refer to ARM documentation "Embedded Trace Macrocell Specification (ARM IHI 0014E)".
5. Pin description
Table 349. ETM Pin Description
Pin Name Type Description
TRACECLK Output Trace Clock. The trace clock signal provides the clock for the trace
port. PIPESTAT[2:0], TRACESYNC, and TRACEPKT[3:0] signals are
referenced to the rising edge of the trace clock. This clock is not
generated by the ETM block. It is to be derived from the system clock.
The clock should be balanced to provide sufficient hold time for the
trace data signals. Half rate clocking mode is supported. Trace data
signals should be shifted by a clock phase from TRACECLK. Refer to
Figure 3.14 page 3.26 and figure 3.15 page 3.27 in "ETM7 Technical
Reference Manual" (ARM DDI 0158B), for example circuits that
implements both half-rateclocking and shifting of the trace data with
respect to the clock. For TRACECLK timings refer to section 5.2 on
page 5-13 in "Embedded Trace Macrocell Specification" (ARM IHI
0014E).
PIPESTAT[2:0] Output Pipe Line status. The pipeline status signals provide a cycle-by-cycle
indication of what is happening in the execution stage of the processor
pipeline.
TRACESYNC Output Trace synchronization. The trace sync signal is used to indicate the
first packet of a group of trace packets and is asserted HIGH only for
the first packet of any branch address.
TRACEPKT[3:0] Output Trace Packet. The trace packet signals are used to output packaged
address and data information related to the pipeline status. All packets
are eight bits in length. A packet is output over two cycles. In the first
cycle, Packet[3:0] is output and in the second cycle, Packet[7:4] is
output.
EXTIN[0] Input External Trigger Input
7. Register description
The ETM contains 29 registers as shown in Table 24–350 below. They are described in
detail in the ARM IHI 0014E document published by ARM Limited, which is available via
the Internet.
8. Block diagram
The block diagram of the ETM debug environment is shown below in Figure 24–79.
APPLICATION PCB
CONNECTOR
TRACE TRACE
10
PORT
ANALYZER ETM
TRIGGER PERIPHERAL
PERIPHERAL
CONNECTOR
Host RAM
running
ARM
debugger JTAG 5
INTERFACE
UNIT
ROM
EMBEDDED ICE
LAN
For an overview of how LPC21xx and LPC22xx parts and versions are described in this
manual, see Section 1–2 “How to read this manual”.
2. Features
• Allows user to establish a debug session to a currently running system without halting
or resetting the system.
• Allows user time-critical interrupt code to continue executing while other user
application code is being debugged.
3. Applications
Real time debugging.
4. Description
RealMonitor is a lightweight debug monitor that allows interrupts to be serviced while user
debug their foreground application. It communicates with the host using the DCC (Debug
Communications Channel), which is present in the EmbeddedICE logic. RealMonitor
provides advantages over the traditional methods for debugging applications in ARM
systems. The traditional methods include:
Angel is designed to load and debug independent applications that can run in a variety of
modes, and communicate with the debug host using a variety of connections (such as a
serial port or ethernet). Angel is required to save and restore full processor context, and
the occurrence of interrupts can be delayed as a result. Angel, as a fully functional
target-based debugger, is therefore too heavyweight to perform as a real-time monitor.
Multi-ICE is a hardware debug solution that operates using the EmbeddedICE unit that is
built into most ARM processors. To perform debug tasks such as accessing memory or
the processor registers, Multi-ICE must place the core into a debug state. While the
processor is in this state, which can be millions of cycles, normal program execution is
suspended, and interrupts cannot be serviced.
RealMonitor combines features and mechanisms from both Angel and Multi-ICE to
provide the services and functions that are required. In particular, it contains both the
Multi-ICE communication mechanisms (the DCC using JTAG), and Angel-like support for
processor context saving and restoring. RealMonitor is pre-programmed in the on-chip
ROM memory (boot sector). When enabled It allows user to observe and debug while
parts of application continue to run. Refer to Section 25–5 “How To Enable RealMonitor”
on page 360 for details.
DEBUGGER
REALMONITOR.DLL RMHOST
RDI 1.5.1 RT
RealMonitor
JTAG UNIT
protocol
DCC transmissions
over the JTAG link
RMTARGET
TARGET BOARD AND
target
PROCESSOR
APPLICATION
4.2 RMHost
This is located between a debugger and a JTAG unit. The RMHost controller,
RealMonitor.dll, converts generic Remote Debug Interface (RDI) requests from the
debugger into DCC-only RDI messages for the JTAG unit. For complete details on
debugging a RealMonitor-integrated application from the host, see the ARM RMHost User
Guide (ARM DUI 0137A).
4.3 RMTarget
This is pre-programmed in the on-chip ROM memory (boot sector), and runs on the target
hardware. It uses the EmbeddedICE logic, and communicates with the host using the
DCC. For more details on RMTarget functionality, see the RealMonitor Target Integration
Guide (ARM DUI 0142A).
SWI abort
undef
stop
SWI abort
undef
RUNNING STOPPED PANIC
go
A debugger such as the ARM eXtended Debugger (AXD) or other RealMonitor aware
debugger, that runs on a host computer, can connect to the target to send commands and
receive data. This communication between host and target is illustrated in Figure 25–80.
The target component of RealMonitor, RMTarget, communicates with the host component,
RMHost, using the Debug Communications Channel (DCC), which is a reliable link whose
data is carried over the JTAG connection.
While user application is running, RMTarget typically uses IRQs generated by the DCC.
This means that if user application also wants to use IRQs, it must pass any
DCC-generated interrupts to RealMonitor.
When one of these exceptions occur that is not handled by user application, the following
happens:
• RealMonitor enters a loop, polling the DCC. If the DCC read buffer is full, control is
passed to rm_ReceiveData() (RealMonitor internal function). If the DCC write buffer is
free, control is passed to rm_TransmitData() (RealMonitor internal function). If there is
nothing else to do, the function returns to the caller. The ordering of the above
comparisons gives reads from the DCC a higher priority than writes to the
communications link.
• RealMonitor stops the foreground application. Both IRQs and FIQs continue to be
serviced if they were enabled by the application at the time the foreground application
was stopped.
RM_UNDEF_HANDLER()
RESET
RM_PREFETCHABORT_HANDLER()
RM_DATAABORT_HANDLER()
UNDEF RM_IRQHANDLER()
SWI
sharing IRQs between RealMonitor and user IRQ handler
PREFETCH
ABORT RM_IRQHANDLER2()
DATA ABORT
APP_IRQDISPATCH
RESERVED
APP_IRQHANDLER2()
OR
IRQ
FIQ
IMPORT rm_init_entry
IMPORT rm_prefetchabort_handler
IMPORT rm_dataabort_handler
IMPORT rm_irqhandler2
IMPORT rm_undef_handler
IMPORT User_Entry ;Entry point of user application.
CODE32
ENTRY
;Define exception table. Instruct linker to place code at address 0x0000 0000
; /*********************************************************************
; * Setup Vectored Interrupt controller. DCC Rx and Tx interrupts
; * generate Non Vectored IRQ request. rm_init_entry is aware
; * of the VIC and it enables the DBGCommRX and DBGCommTx interrupts.
; * Default vector address register is programmed with the address of
; * Non vectored app_irqDispatch mentioned in this example. User can setup
; * Vectored IRQs or FIQs here.
; *********************************************************************/
END
RM_OPT_DATALOGGING=FALSE
This option enables or disables support for any target-to-host packets sent on a non
RealMonitor (third-party) channel.
RM_OPT_STOPSTART=TRUE
This option enables or disables support for all stop and start debugging features.
RM_OPT_SOFTBREAKPOINT=TRUE
RM_OPT_HARDBREAKPOINT=TRUE
Enabled for cores with EmbeddedICE-RT. This device uses ARM-7TDMI-S Rev 4 with
EmbeddedICE-RT.
RM_OPT_HARDWATCHPOINT=TRUE
Enabled for cores with EmbeddedICE-RT. This device uses ARM-7TDMI-S Rev 4 with
EmbeddedICE-RT.
RM_OPT_SEMIHOSTING=FALSE
This option enables or disables support for SWI semi-hosting. Semi-hosting provides
code running on an ARM target use of facilities on a host computer that is running an
ARM debugger. Examples of such facilities include the keyboard input, screen output,
and disk I/O.
RM_OPT_SAVE_FIQ_REGISTERS=TRUE
This option determines whether the FIQ-mode registers are saved into the registers
block when RealMonitor stops.
RM_OPT_READBYTES=TRUE
RM_OPT_WRITEBYTES=TRUE
RM_OPT_READHALFWORDS=TRUE
RM_OPT_WRITEHALFWORDS=TRUE
RM_OPT_READWORDS=TRUE
RM_OPT_WRITEWORDS=TRUE
RM_OPT_EXECUTECODE=FALSE
Enables/Disables support for executing code from "execute code" buffer. The code
must be downloaded first.
RM_OPT_GETPC=TRUE
This option enables or disables support for the RealMonitor GetPC packet. Useful in
code profiling when real monitor is used in interrupt mode.
RM_EXECUTECODE_SIZE=NA
RM_OPT_GATHER_STATISTICS=FALSE
This option enables or disables the code for gathering statistics about the internal
operation of RealMonitor.
RM_DEBUG=FALSE
RM_OPT_BUILDIDENTIFIER=FALSE
This option determines whether a build identifier is built into the capabilities table of
RMTarget. Capabilities table is stored in ROM.
RM_OPT_SDM_INFO=FALSE
SDM gives additional information about application board and processor to debug tools.
RM_OPT_MEMORYMAP=FALSE
This option determines whether a memory map of the board is built into the target and
made available through the capabilities table
RM_OPT_USE_INTERRUPTS=TRUE
This option specifies whether RMTarget is built for interrupt-driven mode or polled
mode.
RM_FIFOSIZE=NA
This option specifies the size, in words, of the data logging FIFO buffer.
CHAIN_VECTORS=FALSE
This option allows RMTarget to support vector chaining through µHAL (ARM HW
abstraction API).
1. Abbreviations
Table 352. Acronym list
Acronym Description
ADC Analog-to-Digital Converter
AMBA Advanced Microcontroller Bus Architecture
APB Advanced Peripheral Bus
CAN Controller Area Network
CISC Complex Instruction Set Computer
FIFO First In, First Out
GPIO General Purpose Input/Output
I/O Input/Output
JTAG Joint Test Action Group
PLL Phase-Locked Loop
PWM Pulse Width Modulator
RISC Reduced Instruction Set Computer
SPI Serial Peripheral Interface
SRAM Static Random Access Memory
SSI Synchronous Serial Interface
SSP Synchronous Serial Port
TTL Transistor-Transistor Logic
UART Universal Asynchronous Receiver/Transmitter
2. Legal information
2.1 Definitions Suitability for use — NXP Semiconductors products are not designed,
authorized or warranted to be suitable for use in medical, military, aircraft,
space or life support equipment, nor in applications where failure or
Draft — The document is a draft version only. The content is still under
malfunction of an NXP Semiconductors product can reasonably be expected
internal review and subject to formal approval, which may result in
to result in personal injury, death or severe property or environmental
modifications or additions. NXP Semiconductors does not give any
damage. NXP Semiconductors accepts no liability for inclusion and/or use of
representations or warranties as to the accuracy or completeness of
NXP Semiconductors products in such equipment or applications and
information included herein and shall have no liability for the consequences of
therefore such inclusion and/or use is at the customer’s own risk.
use of such information.
Applications — Applications that are described herein for any of these
products are for illustrative purposes only. NXP Semiconductors makes no
2.2 Disclaimers representation or warranty that such applications will be suitable for the
specified use without further testing or modification.
General — Information in this document is believed to be accurate and
reliable. However, NXP Semiconductors does not give any representations or
warranties, expressed or implied, as to the accuracy or completeness of such 2.3 Trademarks
information and shall have no liability for the consequences of use of such
Notice: All referenced brands, product names, service names and trademarks
information.
are the property of their respective owners.
Right to make changes — NXP Semiconductors reserves the right to make I2C-bus — logo is a trademark of NXP B.V.
changes to information published in this document, including without
limitation specifications and product descriptions, at any time and without
notice. This document supersedes and replaces all information supplied prior
to the publication hereof.
3. Tables
Table 1. LPC21xx and LPC22xx legacy/enhanced parts address 0xFFFF F008) bit description . . . . . . . 46
overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 Table 41. Interrupt Enable Register (VICINtEnable -
Table 2. LPC2109/2119/2129 Ordering information . . . .5 address 0xFFFF F010) bit description . . . . . . . 47
Table 3. LPC2109/2119/2129 Ordering options . . . . . . .6 Table 42. Software Interrupt Clear Register (VICIntEnClear
Table 4. LPC 2114/2124 Ordering information . . . . . . . .6 - address 0xFFFF F014) bit description. . . . . . 47
Table 5. LPC2114/2124 Ordering options . . . . . . . . . . . .7 Table 43. Interrupt Select Register (VICIntSelect - address
Table 6. LPC2194 Ordering information . . . . . . . . . . . . .7 0xFFFF F00C) bit description . . . . . . . . . . . . . 47
Table 7. LPC2194 Ordering options . . . . . . . . . . . . . . . .7 Table 44. IRQ Status Register (VICIRQStatus - address
Table 8. LPC2210/2220 Ordering information . . . . . . . . .7 0xFFFF F000) bit description. . . . . . . . . . . . . . 47
Table 9. LPC2210/2220 Ordering options . . . . . . . . . . . .8 Table 45. FIQ Status Register (VICFIQStatus - address
Table 10. LPC2212/2214 Ordering information . . . . . . . . .8 0xFFFF F004) bit description. . . . . . . . . . . . . . 48
Table 11. LPC2212/2214 Ordering options . . . . . . . . . . . .9 Table 46. Vector Control registers (VICVectCntl0-15 -
Table 12. LPC2290 Ordering information . . . . . . . . . . . . .9 addresses 0xFFFF F200-23C) bit description . 48
Table 13. LPC2290 Ordering options . . . . . . . . . . . . . . . .9 Table 47. Vector Address registers (VICVectAddr0-15 -
Table 14. LPC2292/2294 Ordering information . . . . . . . . .9 addresses 0xFFFF F100-13C) bit description . 48
Table 15. LPC2292/2294 Ordering options . . . . . . . . . . .10 Table 48. Default Vector Address register (VICDefVectAddr
Table 16. LPC21xx/22xx part-specific configuration. . . . .12 - address 0xFFFF F034) bit description. . . . . . 49
Table 17. LPC21xx and LPC22xx memory and peripheral Table 49. Vector Address register (VICVectAddr - address
configuration . . . . . . . . . . . . . . . . . . . . . . . . . . .15 0xFFFF F030) bit description. . . . . . . . . . . . . . 49
Table 18. APB peripheries and base addresses . . . . . . .21 Table 50. Protection Enable register (VICProtection -
Table 19. ARM exception vector locations . . . . . . . . . . . .22 address 0xFFFF F020) bit description . . . . . . . 49
Table 20. LPC21xx and LPC22xx memory mapping Table 51. Connection of interrupt sources to the Vectored
modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22 Interrupt Controller . . . . . . . . . . . . . . . . . . . . . . 50
Table 21. MAM responses to program accesses of various Table 52. LPC21xx/22xx part-specific register bits . . . . . 57
types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28 Table 53. Pin summary . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Table 22. MAM responses to data accesses of various Table 54. Summary of system control registers. . . . . . . . 59
types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28 Table 55. Recommended values for CX1/X2 in oscillation
Table 23. Summary of MAM registers . . . . . . . . . . . . . . .29 mode (crystal and external components
Table 24. MAM Control Register (MAMCR - address parameters) . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
0xE01F C000) bit description . . . . . . . . . . . . . .29 Table 56. External interrupt registers. . . . . . . . . . . . . . . . 62
Table 25. MAM Timing register (MAMTIM - address Table 57. External Interrupt Flag register (EXTINT - address
0xE01F C004) bit description . . . . . . . . . . . . . .30 0xE01F C140) bit description. . . . . . . . . . . . . . 63
Table 26. Suggestions for MAM timing selection . . . . . . .30 Table 58. Interrupt Wakeup register (INTWAKE - address
Table 27. Address ranges of the external memory banks 32 0xE01F C144) bit description. . . . . . . . . . . . . . 64
Table 28. External Memory Controller pin description . . .32 Table 59. External Interrupt Mode register (EXTMODE -
Table 29. External Memory Controller register map . . . . .32 address 0xE01F C148) bit description. . . . . . . 64
Table 30. Bank Configuration Registers 0-3 (BCFG0-3 - Table 60. External Interrupt Polarity register (EXTPOLAR -
0xFFE0 0000 to 0xFFE0 000C) address address 0xE01F C14C) bit description . . . . . . 65
description . . . . . . . . . . . . . . . . . . . . . . . . . . . .33 Table 61. System Control and Status flags register (SCS -
Table 31. Default memory widths at reset . . . . . . . . . . . .34 address 0xE01F C1A0) bit description . . . . . . 67
Table 32. External memory and system requirements . . .39 Table 62. Memory Mapping control register (MEMMAP -
Table 33. LPC21xx/22xx part-specific interrupts . . . . . . .41 address 0xE01F C040) bit description. . . . . . . 68
Table 34. VIC register map. . . . . . . . . . . . . . . . . . . . . . . .43 Table 63. PLL registers . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Table 35. Software Interrupt Register (VICSoftInt - address Table 64. PLL Control register (PLLCON - address
0xFFFF F018) bit allocation . . . . . . . . . . . . . . .45 0xE01F C080) bit description. . . . . . . . . . . . . . 71
Table 36. Software Interrupt Register (VICSoftInt - address Table 65. PLL Configuration register (PLLCFG - address
0xFFFF F018) bit description . . . . . . . . . . . . . .45 0xE01F C084) bit description. . . . . . . . . . . . . . 71
Table 37. Software Interrupt Clear Register Table 66. PLL Status register (PLLSTAT - address
(VICSoftIntClear - 0xFFFF F01C). . . . . . . . . . .45 0xE01F C088) bit description. . . . . . . . . . . . . . 72
Table 38. Software Interrupt Clear Register Table 67. PLL Control bit combinations . . . . . . . . . . . . . . 73
(VICSoftIntClear - address 0xFFFF F01C) bit Table 68. PLL Feed register (PLLFEED - address
allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46 0xE01F C08C) bit description . . . . . . . . . . . . . 73
Table 39. Software Interrupt Clear Register Table 69. Elements determining PLL’s frequency . . . . . . 73
(VICSoftIntClear - address 0xFFFF F01C) bit Table 70. PLL Divider values . . . . . . . . . . . . . . . . . . . . . . 74
description . . . . . . . . . . . . . . . . . . . . . . . . . . . .46 Table 71. PLL Multiplier values . . . . . . . . . . . . . . . . . . . . 75
Table 40. Raw Interrupt Status Register (VICRawIntr - Table 72. Power control registers . . . . . . . . . . . . . . . . . . 76
UM10114_3 © NXP B.V. 2008. All rights reserved.
Table 73. Power Control register (PCON - address 0xE002 8034) bit description . . . . . . . . . . . . . 119
0xE01F COCO) bit description . . . . . . . . . . . . .76 Table 107.Fast GPIO port 0 output Set register (FIO0SET -
Table 74. Power Control for Peripherals register (PCONP - address 0x3FFF C018) bit description. . . . . . 119
address 0xE01F C0C4) bit description . . . . . . .77 Table 108.Fast GPIO port 1 output Set register (FIO1SET -
Table 75. APB divider register map . . . . . . . . . . . . . . . . .81 address 0x3FFF C038) bit description. . . . . . 119
Table 76. APB Divider register (APBDIV - address Table 109.Fast GPIO port 0 output Set byte and half-word
0xE01F C100) bit description . . . . . . . . . . . . . .81 accessible register description. . . . . . . . . . . . 119
Table 77. LPC21xx part-specific pin configurations 64-pin Table 110. Fast GPIO port 1 output Set byte and half-word
packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84 accessible register description. . . . . . . . . . . . 120
Table 78. LPC22xx part-specific pin configurations 144-pin Table 111. GPIO port 0 output Clear register 0 (IO0CLR -
packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84 address 0xE002 800C) bit description . . . . . . 120
Table 79. LPC21xx Pin description (64-pin packages) . .86 Table 112. GPIO port 1 output Clear register 1 (IO1CLR -
Table 80. LPC22xx Ball allocation . . . . . . . . . . . . . . . . .91 address 0xE002 801C) bit description . . . . . . 120
Table 81. LPC22xx Pin description (144 pin packages) .93 Table 113. GPIO port 2 output Clear register 2 (IO2CLR -
Table 82. CAN configuration in the LPC21xx/22xx pin address 0xE002 802C) bit description . . . . . . 120
connect registers . . . . . . . . . . . . . . . . . . . . . .101 Table 114. GPIO port 3 output Clear register 3 (IO3CLR -
Table 83. Pin select registers for 64-pin (LPC21xx) and address 0xE002 803C) bit description . . . . . . 121
144-pin (LPC22xx) configurations . . . . . . . . .101 Table 115. Fast GPIO port 0 output Clear register 0
Table 84. Pin function Select register bits . . . . . . . . . . .102 (FIO0CLR - address 0x3FFF C01C) bit
Table 85. Pin connect block register map . . . . . . . . . . .103 description . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
Table 86. Pin function Select register 0 (PINSEL0 - address Table 116. Fast GPIO port 1 output Clear register 1
0xE002 C000) bit description ) . . . . . . . . . . .103 (FIO1CLR - address 0x3FFF C03C) bit
Table 87. Pin function Select register 1 (PINSEL1 - address description . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
0xE002 C004) bit description . . . . . . . . . . . .105 Table 117. Fast GPIO port 0 output Clear byte and half-word
Table 88. Pin function Select register 2 (PINSEL2 - accessible register description. . . . . . . . . . . . 121
0xE002 C014) bit description . . . . . . . . . . . .107 Table 118. Fast GPIO port 1 output Clear byte and half-word
Table 89. Pin function Select register 2 (PINSEL2 - accessible register description. . . . . . . . . . . . 121
0xE002 C014) bit description . . . . . . . . . . . .107 Table 119. GPIO port 0 Pin value register (IO0PIN - address
Table 90. Boot control on BOOT1:0 . . . . . . . . . . . . . . . . 110 0xE002 8000) bit description . . . . . . . . . . . . . 122
Table 91. GPIO features. . . . . . . . . . . . . . . . . . . . . . . . . 111 Table 120.GPIO port 1 Pin value register (IO1PIN - address
Table 92. GPIO pin description . . . . . . . . . . . . . . . . . . . 113 0xE002 8010) bit description . . . . . . . . . . . . . 122
Table 93. GPIO register map (legacy APB accessible Table 121.GPIO port 2 Pin value register (IO2PIN - address
registers). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 0xE002 8020) bit description . . . . . . . . . . . . . 123
Table 94. GPIO register map (local bus accessible registers Table 122.GPIO port 3 Pin value register (IO3PIN - address
- enhanced GPIO features) . . . . . . . . . . . . . . 115 0xE002 8030) bit description . . . . . . . . . . . . . 123
Table 95. GPIO port 0 Direction register (IO0DIR - address Table 123.Fast GPIO port 0 Pin value register (FIO0PIN -
0xE002 8008) bit description . . . . . . . . . . . . . 116 address 0x3FFF C014) bit description. . . . . . 123
Table 96. GPIO port 1 Direction register (IO1DIR - address Table 124.Fast GPIO port 1 Pin value register (FIO1PIN -
0xE002 8018) bit description . . . . . . . . . . . . . 116 address 0x3FFF C034) bit description. . . . . . 123
Table 97. GPIO port 2 Direction register (IO2DIR - address Table 125.Fast GPIO port 0 Pin value byte and half-word
0xE002 8028) bit description . . . . . . . . . . . . . 117 accessible register description. . . . . . . . . . . . 123
Table 98. GPIO port 3 Direction register (IO3DIR - address Table 126.Fast GPIO port 1 Pin value byte and half-word
0xE002 8038) bit description . . . . . . . . . . . . . 117 accessible register description. . . . . . . . . . . . 124
Table 99. Fast GPIO port 0 Direction register (FIO0DIR - Table 127.Fast GPIO port 0 Mask register (FIO0MASK -
address 0x3FFF C000) bit description . . . . . . 117 address 0x3FFF C010) bit description. . . . . . 124
Table 100.Fast GPIO port 1 Direction register (FIO1DIR - Table 128.Fast GPIO port 1 Mask register (FIO1MASK -
address 0x3FFF C020) bit description . . . . . . 117 address 0x3FFF C030) bit description. . . . . . 124
Table 101.Fast GPIO port 0 Direction control byte and Table 129.Fast GPIO port 0 Mask byte and half-word
half-word accessible register description . . . . 117 accessible register description. . . . . . . . . . . . 125
Table 102.Fast GPIO port 1 Direction control byte and Table 130.Fast GPIO port 1 Mask byte and half-word
half-word accessible register description . . . . 118 accessible register description. . . . . . . . . . . . 125
Table 103.GPIO port 0 output Set register (IO0SET - address Table 131.LPC21xx/22xx part-specific registers. . . . . . . 129
0xE002 8004 bit description . . . . . . . . . . . . . . 118 Table 132:UART0 pin description . . . . . . . . . . . . . . . . . . 130
Table 104.GPIO port 1 output Set register (IO1SET - address Table 133.UART0 register map . . . . . . . . . . . . . . . . . . . 131
0xE002 8014) bit description . . . . . . . . . . . . . 119 Table 134:UART0 Receiver Buffer Register (U0RBR -
Table 105.GPIO port 2 output Set register (IO2SET - address address 0xE000 C000, when DLAB = 0, Read
0xE002 8024) bit description . . . . . . . . . . . . . 119 Only) bit description . . . . . . . . . . . . . . . . . . . 132
Table 106.GPIO port 3 output Set register (IO3SET - address Table 135:UART0 Transmit Holding Register (U0THR -
address 0xE000 C000, when DLAB = 0, Write Table 162.UART1 Line Control Register (U1LCR - address
Only) bit description . . . . . . . . . . . . . . . . . . . .132 0xE001 000C) bit description. . . . . . . . . . . . . 160
Table 136:UART0 Divisor Latch LSB register (U0DLL - Table 163.UART1 Modem Control Register (U1MCR -
address 0xE000 C000, when DLAB = 1) bit address 0xE001 0010) bit description . . . . . . 161
description . . . . . . . . . . . . . . . . . . . . . . . . . . .133 Table 164.Modem status interrupt generation . . . . . . . . 163
Table 137:UART0 Divisor Latch MSB register (U0DLM - Table 165.UART1 Line Status Register (U1LSR - address
address 0xE000 C004, when DLAB = 1) bit 0xE001 0014, read only) bit description. . . . . 164
description . . . . . . . . . . . . . . . . . . . . . . . . . . .133 Table 166.UART1 Modem Status Register (U1MSR -
Table 138:UARTn Fractional Divider Register (U0FDR - address 0xE001 0018) bit description . . . . . . 165
address 0xE000 C028, U2FDR - 0xE007 8028, Table 167.UART1 Scratch Pad Register (U1SCR - address
U3FDR - 0xE007 C028) bit description . . . . .133 0xE001 0014) bit description . . . . . . . . . . . . . 165
Table 139.Fractional Divider setting look-up table. . . . . .136 Table 168.Auto-baud Control Register (U1ACR -
Table 140.UART0 Interrupt Enable Register (U0IER - 0xE001 0020) bit description . . . . . . . . . . . . . 166
address 0xE000 C004, when DLAB = 0) bit Table 169.UART1 Transmit Enable Register (U1TER -
description . . . . . . . . . . . . . . . . . . . . . . . . . . .137 address 0xE001 0030) bit description . . . . . . 169
Table 141:UART0 Interrupt Identification Register (U0IIR - Table 170.I2C Pin Description. . . . . . . . . . . . . . . . . . . . . 172
address 0xE000 C008, read only) Table 171.I2CCONSET used to configure Master mode 173
bit description . . . . . . . . . . . . . . . . . . . . . . . . .137 Table 172.I2CONSET used to configure Slave mode . . 174
Table 142:UART0 interrupt handling . . . . . . . . . . . . . . . .139 Table 173.I2C register map . . . . . . . . . . . . . . . . . . . . . . . 180
Table 143:UART0 FIFO Control Register (U0FCR - address Table 174.I2C Control Set register (I2CONSET - address
0xE000 C008) bit description . . . . . . . . . . . . .139 0xE001 C000) bit description. . . . . . . . . . . . . 181
Table 144:UART0 Line Control Register (U0LCR - address Table 175.I2C Control Set register (I2CONCLR - address
0xE000 C00C) bit description . . . . . . . . . . . . .140 0xE001 C018) bit description. . . . . . . . . . . . . 182
Table 145:UART0 Line Status Register (U0LSR - address Table 176.I2C Status register (I2STAT - address 0xE001) bit
0xE000 C014, read only) bit description. . . . .141 description . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Table 146:UART0 Scratch Pad Register (U0SCR - address Table 177.I2C Data register (I2DAT - address 0xE001 C008)
0xE000 C01C) bit description . . . . . . . . . . . . .142 bit description. . . . . . . . . . . . . . . . . . . . . . . . . 183
Table 147:Auto-baud Control Register (U0ACR - Table 178.I2C Slave Address register (I2ADR - address
0xE000 C020) bit description . . . . . . . . . . . . .142 0xE001 C00C) bit description . . . . . . . . . . . . 183
Table 148:UART0 Transmit Enable Register (U0TER - Table 179.I2C SCL High Duty Cycle register (I2SCLH -
address 0xE000 C030) bit description . . . . . .146 address 0xE001 C010) bit description . . . . . . 183
Table 149.LPC21xx/22xx part-specific registers . . . . . . .148 Table 180.I2C SCL Low Duty Cycle register (I2SCLL -
Table 150.UART1 pin description . . . . . . . . . . . . . . . . . .149 address 0xE001 C014) bit description . . . . . . 184
Table 151.UART1 register map . . . . . . . . . . . . . . . . . . .151 Table 181.Example I2C clock rates. . . . . . . . . . . . . . . . . 184
Table 152.UART1 Receiver Buffer Register (U1RBR - Table 182.Abbreviations used to describe an I2C
address 0xE001 0000, when DLAB = 0 Read operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Only) bit description . . . . . . . . . . . . . . . . . . . .152 Table 183.I2CONSET used to initialize Master Transmitter
Table 153.UART1 Transmitter Holding Register (U1THR - mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
address 0xE001 0000, when DLAB = 0 Write Table 184.I2CADR usage in Slave Receiver mode . . . . 186
Only) bit description . . . . . . . . . . . . . . . . . . . .152 Table 185.I2CONSET used to initialize Slave Receiver mode
Table 154:UART1 Divisor Latch LSB register (U1DLL - 186
address 0xE001 C000, when DLAB = 1) bit Table 186.Master Transmitter mode . . . . . . . . . . . . . . . . 192
description . . . . . . . . . . . . . . . . . . . . . . . . . . .153 Table 187.Master Receiver mode. . . . . . . . . . . . . . . . . . 193
Table 155:UART0 Divisor Latch MSB register (U1DLM - Table 188.Slave Receiver mode. . . . . . . . . . . . . . . . . . . 194
address 0xE001 C004, when DLAB = 1) bit Table 189.Slave Transmitter mode . . . . . . . . . . . . . . . . . 196
description . . . . . . . . . . . . . . . . . . . . . . . . . . .153 Table 190.Miscellaneous States . . . . . . . . . . . . . . . . . . . 198
Table 156.UART1 Fractional Divider Register (U1FDR - Table 191.LPC21xx/22xx SPI configurations . . . . . . . . . 209
address 0xE001 0028) bit description . . . . . .153 Table 192.SPI data to clock phase relationship . . . . . . . 211
Table 157.Fractional Divider setting look-up table. . . . . .156 Table 193.SPI pin description . . . . . . . . . . . . . . . . . . . . . 214
Table 158.UART1 Interrupt Enable Register (U1IER - Table 194.SPI register map . . . . . . . . . . . . . . . . . . . . . . 215
address 0xE001 0004, when DLAB = 0) bit Table 195.SPI Control Register (S0SPCR - address
description . . . . . . . . . . . . . . . . . . . . . . . . . . .157 0xE002 0000 and S1SPCR - address
Table 159.UART1 Interrupt Identification Register (U1IIR - 0xE003 0000) bit description . . . . . . . . . . . . . 215
address 0xE001 0008, read only) bit Table 196.SPI Status Register (S0SPSR - address
description . . . . . . . . . . . . . . . . . . . . . . . . . . .158 0xE002 0004 and S1SPSR - address
Table 160.UART1 interrupt handling . . . . . . . . . . . . . . . .159 0xE003 0004) bit description . . . . . . . . . . . . . 216
Table 161.UART1 FIFO Control Register (U1FCR - address Table 197.SPI Data Register (S0SPDR - address
0xE001 0008) bit description . . . . . . . . . . . . .160 0xE002 0008, S1SPDR - address 0xE003 0008)
CAN4MOD - address 0x005 0000) bit CAN2TFIn - addresses 0xE004 8030, 40, 50;
description . . . . . . . . . . . . . . . . . . . . . . . . . . .279 CAN3TFIn - addresses 0xE004 C030, 40, 50;
Table 258.Command register (CMR: CAN1CMR- address CAN4TFIn - addresses 0xE005 0030, 40, 50) bit
0xE004 4004, CAN2CMR - address description . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
0xE004 8004, CAN3CMR - address 0x004 C004, Table 271.Transfer Identifier register when FF=0 (TID1, 2, 3:
CAN4CMR - address 0x005 0004) bit CAN1TIDn - addresses 0xE004 4034, 44, 54;
description . . . . . . . . . . . . . . . . . . . . . . . . . . .280 CAN2TIDn - addresses 0xE004 8034, 44, 54;
Table 259. Global Status Register (GSR: CAN1GSR - CAN3TIDn - addresses 0xE004 C034, 44, 54;
address 0xE004 0008, CAN2GSR - address CAN4TIDn - addresses 0xE005 0034, 44, 54) bit
0xE004 8008, CAN3GSR - address 0xE004 description . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
C008, CAN4GSR address 0xE005 0008) bit Table 272.Transfer Identifier register when FF = 1. . . . . 290
description . . . . . . . . . . . . . . . . . . . . . . . . . . .281 Table 273.Transmit Data register A (TDA1, 2, 3: CAN1TDAn
Table 260.Interrupt and Capture register (ICR: CR: - addresses 0xE004 4038, 48, 58; CAN2TDAn -
CAN1ICR- address 0xE004 400C, CAN2ICR - addresses 0xE004 8038, 48, 58; CAN3TDAn -
0xE004 address 800C, CAN3ICR - address addresses 0xE004 C038, 48, 58; CAN4TDAn -
0xE004 C00C, CAN4ICR - address 0xE005 addresses 0xE005 0038, 48, 58) bit
000C) bit description. . . . . . . . . . . . . . . . . . . .282 description . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
Table 261.Interrupt Enable register (IER: CAN1IER - Table 274.Transmit Data register B (TDB1, 2, 3: CAN1TDBn
address 0xE004 4010, CAN2IER - address - addresses 0xE004 403C, 4C, 5C; CAN2TDBn -
0xE004 8010, CAN3IER - address 0xE004 C010, addresses 0xE004 803C, 4C, 5C; CAN3TDBn -
CAN4IER - address 0xE005 0010) bit addresses 0xE004 C03C, 4C, 5C; CAN4TDBn -
description . . . . . . . . . . . . . . . . . . . . . . . . . . .284 addresses 0xE005 003C, 4C, 5C) bit
Table 262. Bus Timing Register (BTR: CAN1BTR - address description . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
0xE004 4014, CAN2BTR - address 0xE004 8014, Table 275.Central Transit Status Register (CANTxSR -
CAN3BTR - address 0xE004 C014, CAN4BTR - address 0xE004 0000) bit description . . . . . . 292
address 0xE005 0014) bit description . . . . . .285 Table 276.Central Receive Status register (CANRxSR -
Table 263.Error Warning Limit register (EWL: CAN1EWL - address 0xE004 0004) bit description . . . . . . 293
address 0xE004 4018, CAN2EWL - address Table 277.Central Miscellaneous Status Register (CANMSR
0xE004 8018, CAN3EWL - address 0xE004 - address 0xE004 0008) bit description . . . . . 293
C018, CAN4EWL - address 0xE005 0018) bit Table 278.Acceptance Filter Mode Register (AFMR -
description . . . . . . . . . . . . . . . . . . . . . . . . . . .285 address 0xE003 C000) bit description . . . . . . 296
Table 264. Status Register (SR - CAN1SR 0xE004 401C, Table 279.Standard Frame Individual Start Address register
CAN2SR - 0xE004 801C, CAN3SR - 0xE004 (SFF_sa - address 0xE003 C004) bit
C01C, CAN4SR - 0xE005 001C) bit description . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
description . . . . . . . . . . . . . . . . . . . . . . . . . . .286 Table 280.Standard Frame Group Start Address register
Table 265.Receive Frame Status register (RFS - CAN1RFS (SFF_GRP_sa - address 0xE003 C008) bit
- address 0xE004 4020, CAN2RFS - address description . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
0xE004 8020, CAN3RFS - address 0xE004 C020, Table 281.Extended Frame Start Address register (EFF_sa -
CAN4RFS - address 0xE005 0020) bit address 0xE003 C00C) bit description . . . . . 297
description . . . . . . . . . . . . . . . . . . . . . . . . . . .287 Table 282.Extended Frame Group Start Address register
Table 266.Receive Identifier register when FF = 0 (RID: (EFF_GRP_sa - address 0xE003 C010) bit
CAN1RID - address 0xE004 4024, CAN2RID - description . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
address 0xE004 8024, CAN3RID - address Table 283.End of AF Tables register (ENDofTable - address
0xE004 C024, CAN4RID - address 0xE005 0024) 0xE003 C014) bit description. . . . . . . . . . . . . 298
bit description . . . . . . . . . . . . . . . . . . . . . . . . .287 Table 284.LUT Error Address register (LUTerrAd - address
Table 267.Receive Identifier register when FF = 1 . . . . .288 0xE003 C018) bit description. . . . . . . . . . . . . 298
Table 268.Receive Data register A (RDA: CAN1RDA - Table 285.LUT Error register (LUTerr - address
address 0xE004 4028, CAN2RDA - address 0xE003 C01C) bit description . . . . . . . . . . . . 298
0xE004 8028, CAN3RDA - address 0xE004 Table 286.Example of acceptance filter tables and ID index
C028, CAN4RDA - address 0xE005 0028) bit values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
description . . . . . . . . . . . . . . . . . . . . . . . . . . .288 Table 287.Format of automatically stored Rx message . 301
Table 269.Receive Data register B (RDB: CAN1RDB - Table 288.LPC21xx/22xx part-specific registers. . . . . . . 303
address 0xE004 402C, CAN2RDB - address Table 289.ADC pin description . . . . . . . . . . . . . . . . . . . . 304
0xE004 802C, CAN3RDB - address 0xE004 Table 290.ADC registers. . . . . . . . . . . . . . . . . . . . . . . . . 305
C02C, CAN4RDB - address 0xE005 002C) bit Table 291.ADC Control Register (ADCR - address
description . . . . . . . . . . . . . . . . . . . . . . . . . . .288 0xE003 4000) bit description . . . . . . . . . . . . . 306
Table 270.Transmit Frame Information register (TFI1, 2, 3 - Table 292.ADC Global Data Register (ADGDR - address
CAN1TF1n - addresses 0xE004 4030, 40, 50; 0xE003 4004) bit description . . . . . . . . . . . . . 307
4. Figures
Fig 1. LPC21xx and LPC22xx block diagram . . . . . . . . 11 Fig 40. Arbitration procedure. . . . . . . . . . . . . . . . . . . . . 178
Fig 2. LPC21xx and LPC22xx system memory map . . .18 Fig 41. Serial clock synchronization . . . . . . . . . . . . . . . 179
Fig 3. Peripheral memory map. . . . . . . . . . . . . . . . . . . .19 Fig 42. Format and States in the Master Transmitter
Fig 4. AHB peripheral map . . . . . . . . . . . . . . . . . . . . . .20 mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Fig 5. Map of lower memory is showing re-mapped and Fig 43. Format and States in the Master Receiver
re-mappable areas for a part with on-chip flash mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23 Fig 44. Format and States in the Slave Receiver mode 190
Fig 6. Simplified block diagram of the Memory Accelerator Fig 45. Format and States in the Slave Transmitter mode .
Module (MAM) . . . . . . . . . . . . . . . . . . . . . . . . . . .27 191
Fig 7. 32 bit bank external memory interfaces (BGFGx Bits Fig 46. Simultaneous repeated START conditions from two
MW = 10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36 masters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
Fig 8. 16 bit bank external memory interfaces (BCFGx bits Fig 47. Forced access to a busy I2C-bus . . . . . . . . . . . 200
MW = 01) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37 Fig 48. Recovering from a bus obstruction caused by a low
Fig 9. 8 bit bank external memory interface (BCFGx bits level on SDA . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
MW = 00 and RBLE = 0) . . . . . . . . . . . . . . . . . . .37 Fig 49. SPI data transfer format
Fig 10. External memory read access (WST1 = 0 and (CPHA = 0 and CPHA = 1) . . . . . . . . . . . . . . . . 211
WST1 = 1 examples) . . . . . . . . . . . . . . . . . . . . . .38 Fig 50. SPI block diagram . . . . . . . . . . . . . . . . . . . . . . . 218
Fig 11. External memory write access (WST2 = 0 and Fig 51. Texas Instruments synchronous serial frame format:
WST2 = 1 examples) . . . . . . . . . . . . . . . . . . . . . .38 a) single frame transfer and b)
Fig 12. External burst memory read access (WST1 = 0 and continuous/back-to-back two frames. . . . . . . . . 221
WST1 = 1 examples) . . . . . . . . . . . . . . . . . . . . . .39 Fig 52. Motorola SPI frame format with CPOL=0 and
Fig 13. Block diagram of the Vectored Interrupt CPHA=0 ( a) single transfer and b) continuous
Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52 transfer). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
Fig 14. Oscillator modes and models: a) slave mode of Fig 53. SPI frame format with CPOL=0 and CPHA=1. . 223
operation, b) oscillation mode of operation, c) Fig 54. SPI frame format with CPOL = 1 and CPHA = 0 ( a)
external crystal model used for CX1/X2 single and b) continuous transfer). . . . . . . . . . . 224
evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60 Fig 55. SPI frame format with CPOL = 1 and CPHA = 1225
Fig 15. FOSC selection algorithm . . . . . . . . . . . . . . . . . . .61 Fig 56. Microwire frame format (single transfer) . . . . . . 226
Fig 16. External interrupt logic . . . . . . . . . . . . . . . . . . . . .67 Fig 57. Microwire frame format (continuos transfers) . . 227
Fig 17. PLL block diagram . . . . . . . . . . . . . . . . . . . . . . . .70 Fig 58. Microwire setup and hold details. . . . . . . . . . . . 227
Fig 18. Startup sequence diagram . . . . . . . . . . . . . . . . . .79 Fig 59. A timer cycle in which PR=2, MRx=6, and both
Fig 19. Reset block diagram including the wakeup timer.80 interrupt and reset on match are enabled . . . . . 243
Fig 20. APB divider connections . . . . . . . . . . . . . . . . . . .82 Fig 60. A timer cycle in which PR=2, MRx=6, and both
Fig 21. LPC21xx pin configuration interrupt and stop on match are enabled . . . . . 244
(LQFP64 pin package). . . . . . . . . . . . . . . . . . . . .85 Fig 61. Timer block diagram . . . . . . . . . . . . . . . . . . . . . 245
Fig 22. LQFP144 pinning . . . . . . . . . . . . . . . . . . . . . . . . .90 Fig 62. PWM block diagram. . . . . . . . . . . . . . . . . . . . . . 248
Fig 23. TFBGA144 pinning . . . . . . . . . . . . . . . . . . . . . . .90 Fig 63. Sample PWM waveforms . . . . . . . . . . . . . . . . . 249
Fig 24. Illustration of the fast and slow GPIO access and Fig 64. Watchdog block diagram. . . . . . . . . . . . . . . . . . 262
output showing 3.5 x increase of the pin output Fig 65. RTC block diagram . . . . . . . . . . . . . . . . . . . . . . 264
frequency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .128 Fig 66. RTC prescaler block diagram . . . . . . . . . . . . . . 273
Fig 25. Algorithm for setting UART dividers. . . . . . . . . .135 Fig 67. Entry in FullCAN and individual standard identifier
Fig 26. Autobaud a) mode 0 and b) mode 1 waveform..145 tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
Fig 27. UART0 block diagram . . . . . . . . . . . . . . . . . . . .147 Fig 68. Entry in standard identifier range table . . . . . . . 294
Fig 28. Algorithm for setting UART dividers. . . . . . . . . .155 Fig 69. Entry in either extended identifier table . . . . . . . 295
Fig 29. Auto-RTS functional timing . . . . . . . . . . . . . . . .162 Fig 70. Detailed example of acceptance filter tables and ID
Fig 30. Auto-CTS functional timing . . . . . . . . . . . . . . . .163 index values . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
Fig 31. Autobaud a) mode 0 and b) mode 1 waveform .168 Fig 71. Semaphore procedure for reading an auto-stored
Fig 32. UART1 block diagram . . . . . . . . . . . . . . . . . . . .170 message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
Fig 33. I2C-bus Configuration . . . . . . . . . . . . . . . . . . . .172 Fig 72. Map of lower memory after reset for 256 kB flash
Fig 34. Format in the Master Transmitter mode. . . . . . .173 devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
Fig 35. Format of Master Receiver mode . . . . . . . . . . .174 Fig 73. Boot process flowchart . . . . . . . . . . . . . . . . . . . 316
Fig 36. A Master Receiver switches to Master Transmitter Fig 74. IAP parameter passing . . . . . . . . . . . . . . . . . . . 330
after sending Repeated START . . . . . . . . . . . . .174 Fig 75. Map of the microcontroller’s memory after reset336
Fig 37. Format of Slave Receiver mode . . . . . . . . . . . .175 Fig 76. Boot process flowchart . . . . . . . . . . . . . . . . . . . 339
Fig 38. Format of Slave Transmitter mode . . . . . . . . . .175 Fig 77. IAP parameter passing . . . . . . . . . . . . . . . . . . . 346
Fig 39. I2C serial interface block diagram . . . . . . . . . . .177 Fig 78. EmbeddedICE debug environment block
UM10114_3 © NXP B.V. 2008. All rights reserved.
diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .352
Fig 79. ETM debug environment block diagram . . . . . .356
Fig 80. RealMonitor components . . . . . . . . . . . . . . . . . .358
Fig 81. RealMonitor as a state machine . . . . . . . . . . . .359
Fig 82. Exception handlers . . . . . . . . . . . . . . . . . . . . . .362
5. Contents
Chapter 1: Introductory information
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 4.4 LPC2210/2220 . . . . . . . . . . . . . . . . . . . . . . . . . 7
2 How to read this manual . . . . . . . . . . . . . . . . . . 3 4.5 LPC2212/2214 . . . . . . . . . . . . . . . . . . . . . . . . . 8
3 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 4.6 LPC2290 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.7 LPC2292/2294 . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.1 Legacy features common to all LPC21xx and
LPC22xx parts . . . . . . . . . . . . . . . . . . . . . . . . . 4 5 Block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2 Enhanced features . . . . . . . . . . . . . . . . . . . . . . 5 6 Architectural overview . . . . . . . . . . . . . . . . . . 12
4 Ordering options . . . . . . . . . . . . . . . . . . . . . . . . 5 7 ARM7TDMI-S processor . . . . . . . . . . . . . . . . . 13
4.1 LPC2109/2119/2129 . . . . . . . . . . . . . . . . . . . . . 5 8 On-chip flash memory system. . . . . . . . . . . . 13
4.2 LPC2114/2124 . . . . . . . . . . . . . . . . . . . . . . . . . 6 9 On-chip Static RAM (SRAM). . . . . . . . . . . . . . 14
4.3 LPC2194. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4.9 UART1 Modem Control Register (U1MCR - 4.12 UART1 Scratch Pad Register (U1SCR -
0xE001 0010) . . . . . . . . . . . . . . . . . . . . . . . . 161 0xE001 001C) . . . . . . . . . . . . . . . . . . . . . . . 165
4.9.1 Auto-flow control . . . . . . . . . . . . . . . . . . . . . . 162 4.13 UART1 Auto-baud Control Register (U1ACR -
4.9.1.1 Auto-RTS . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 0xE001 0020). . . . . . . . . . . . . . . . . . . . . . . . 166
4.9.1.2 Auto-CTS . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 4.14 Auto-baud . . . . . . . . . . . . . . . . . . . . . . . . . . 166
4.10 UART1 Line Status Register (U1LSR - 4.15 Auto-baud modes. . . . . . . . . . . . . . . . . . . . . 167
0xE001 0014, Read Only) . . . . . . . . . . . . . . 163 4.16 UART1 Transmit Enable Register (U1TER -
4.11 UART1 Modem Status Register (U1MSR - 0xE001 0030). . . . . . . . . . . . . . . . . . . . . . . . 168
0xE001 0018) . . . . . . . . . . . . . . . . . . . . . . . . 165 5 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . 169
6.10 Capture Control Register (CCR, TIMER0: T0CCR 6.11 External Match Register (EMR, TIMER0: T0EMR
- 0xE000 4028 and TIMER1: T1CCR - - 0xE000 403C; and TIMER1: T1EMR -
0xE000 8028) . . . . . . . . . . . . . . . . . . . . . . . . 241 0xE000 803C) . . . . . . . . . . . . . . . . . . . . . . . 242
7 Example timer operation . . . . . . . . . . . . . . . 243
8 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . 244
6.1 Mode Register (MOD: CAN1MOD - 0xE004 4000, 6.14 Transmit Identifier register (TID1, 2, 3 - CAN1TIDn
CAN2MOD - 0xE004 8000, CAN3MOD - 0x004 - 0xE004 4034, 44, 54; CAN2TIDn -
C000, CAN4MOD - 0x005 0000) . . . . . . . . . 279 0xE004 8034, 44, 54; CAN3TIDn - 0xE004 C034,
6.2 Command Register (CMR: CAN1CMR- 44, 54; CAN4TIDn - 0xE005 0034, 44, 54) . 289
0xE004 4004, CAN2CMR - 0xE004 8004, 6.15 Transmit Data register A (TDA1, 2, 3: CAN1TDAn
CAN3CMR - 0x004 C004, CAN4CMR - 0x005 - 0xE004 4038, 48, 58; CAN2TDAn -
0004) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 0xE004 8038, 48, 58; CAN3TDAn - 0xE004 C038,
6.3 Global Status Register (GSR: CAN1GSR - 48, 58; CAN4TDAn - 0xE005 0038, 48, 58). 290
0xE004 0008, CAN2GSR - 0xE004 8008, 6.16 Transmit Data Register B (TDB1, 2, 3: CAN1TDBn
CAN3GSR - 0xE004 C008, CAN4GSR 0xE005 - 0xE004 403C, 4C, 5C; CAN2TDBn -
0008) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 0xE004 803C, 4C, 5C; CAN3TDBn - 0xE004
6.4 Interrupt and Capture Register (ICR: CAN1ICR- C03C, 4C, 5C; CAN4TDBn - 0xE005 003C, 4C,
0xE004 400C, CAN2ICR - 0xE004 800C, 5C) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
CAN3ICR - 0xE004 C00C, CAN4ICR - 0xE005 7 CAN controller operation . . . . . . . . . . . . . . . 291
000C) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282 7.1 Error handling . . . . . . . . . . . . . . . . . . . . . . . 291
6.5 Interrupt Enable Register (IER: CAN1IER - 7.2 Sleep mode . . . . . . . . . . . . . . . . . . . . . . . . . 291
0xE004 4010, CAN2IER 0xE004 8010, CAN3IER 7.3 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
- 0xE004 C010, CAN4IER - 0xE005 0010). . 284 7.4 Transmit priority . . . . . . . . . . . . . . . . . . . . . . 292
6.6 Bus Timing Register (BTR: CAN1BTR -
8 Centralized CAN registers . . . . . . . . . . . . . . 292
0xE004 4014, CAN2BTR - 0xE004 8014,
8.1 Central Transmit Status Register (CANTxSR -
CAN3BTR - 0xE004 C014, CAN4BTR - 0xE005
0xE004 0000). . . . . . . . . . . . . . . . . . . . . . . . 292
0014) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
8.2 Central Receive Status Register (CANRxSR -
6.7 Error Warning Limit Register (EWL: CAN1EWL -
0xE004 0004). . . . . . . . . . . . . . . . . . . . . . . . 293
0xE004 4018, CAN2EWL - 0xE004 8018,
8.3 Central Miscellaneous Status Register (CANMSR
CAN3EWL - 0xE004 C018, CAN4EWL - 0xE005
- 0xE004 0008) . . . . . . . . . . . . . . . . . . . . . . 293
0018) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
6.8 Status Register (SR - CAN1SR 0xE004 401C, 9 Global acceptance filter . . . . . . . . . . . . . . . . 293
CAN2SR - 0xE004 801C, CAN3SR - 0xE004 10 Acceptance filter registers . . . . . . . . . . . . . . 296
C01C, CAN4SR - 0xE005 001C) . . . . . . . . . 286 10.1 Acceptance Filter Mode Register (AFMR -
6.9 Receive Frame Status register (RFS - CAN1RFS 0xE003 C000) . . . . . . . . . . . . . . . . . . . . . . . 296
- 0xE004 4020, CAN2RFS - 0xE004 8020, 10.2 Standard Frame Individual Start Address register
CAN3RFS - 0xE004 C020, CAN4RFS - 0xE005 (SFF_sa - 0xE003 C004) . . . . . . . . . . . . . . . 296
0020) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 10.3 Standard Frame Group Start Address Register
6.10 Receive Identifier register (RID - CAN1RID - (SFF_GRP_sa - 0xE003 C008) . . . . . . . . . . 297
0xE004 4024, CAN2RID - 0xE004 8024, 10.4 Extended Frame Start Address Register (EFF_sa
CAN3RID - 0xE004 C024, CAN4RID - 0xE005 - 0xE003 C00C) . . . . . . . . . . . . . . . . . . . . . . 297
0024) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 10.5 Extended Frame Group Start Address Register
6.11 Receive Data register A (RDA: CAN1RDA - (EFF_GRP_sa - 0xE003 C010) . . . . . . . . . . 297
0xE004 4028, CAN2RDA - 0xE004 8028, 10.6 End of AF Tables register (ENDofTable -
CAN3RDA - 0xE004 C028, CAN4RDA - 0xE005 0xE003 C014) . . . . . . . . . . . . . . . . . . . . . . . 298
0028) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 10.7 LUT Error Address register (LUTerrAd -
6.12 Receive Data register B (RDB: CAN1RDB - 0xE003 C018) . . . . . . . . . . . . . . . . . . . . . . . 298
0xE004 402C, CAN2RDB - 0xE004 802C, 10.8 LUT Error register (LUTerr - 0xE003 C01C) 298
CAN3RDB - 0xE004 C02C, CAN4RDB - 0xE005 11 Examples of acceptance filter tables and ID
002C) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 index values. . . . . . . . . . . . . . . . . . . . . . . . . . 299
6.13 Transmit Frame Information register (TFI1, 2, 3 - 12 Fullcan mode . . . . . . . . . . . . . . . . . . . . . . . . . 300
CAN1TF1n - 0xE004 4030, 40, 50; CAN2TFIn -
0xE004 8030, 40, 50; CAN3TFIn - 0xE004 C030,
40, 50; CAN4TFIn - 0xE005 0030, 40, 50) . . 289
386 Please be aware that important notices concerning this document and the product(s)
described herein, have been included in section ‘Legal information’.