UM10161
LPC2101/02/03 User manual
Rev. 3 — 2 October 2008

User manual

Document information
Info

Content

Keywords

LPC2101, LPC2102, LPC2103, ARM, ARM7, embedded, 32-bit,
microcontroller

Abstract

LPC2101/02/03 User manual revisionUM10161

NXP Semiconductors

LPC2101/02/03 User manual

Revision history
Rev

Date

Description

03

20081002

LPC2101/02/03 User manual

Modifications:• Description of pins VBAT, RTCX1, RTCX2, VDDA, and VDD(1V8) updated.
• Bit description for bits CPOL and CPHA in SSPCR0 register updated.
• Pin description for ADC pins updated.
• PLCC44 pin configuration removed.
• HVQFN48 pin configuration added.
• I2C pin description in pin configuration updated.
• Timer2/3 register names PWM2/3CON updated.
• Description of JTAG pin TCK updated.
• Bit description in CTC register updated.
• Various editorial updates.
• Description of fractional baudrate generator updated for UART0 and UART1.
• Bit description of the PCONP register updated.
0220070801

LPC2101/02/03 User manual

Modifications:• SCL1 and SDA1 pins described as not open-drain.
01

20060112

Initial version

Contact information
For more information, please visit: http://www.nxp.com
For sales office addresses, please send an email to: salesaddresses@nxp.com
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

2 of 285

UM10161
Chapter 1: LPC2101/02/03 Introductory informationRev. 3 — 2 October 2008

User manual

1. Introduction
The LPC2101/02/03 microcontrollers are based on a 16-bit/32-bit ARM7TDMI-S CPU withreal-time emulation that combines the microcontroller with 8 kB, 16 kB, or 32 kB of
embedded high speed flash memory. A 128-bit wide memory interface and a uniqueaccelerator architecture enable 32-bit code execution at the maximum clock rate. For
critical performance in interrupt service routines and DSP algorithms, this increases
performance up to 30 % over the Thumb mode. For critical code size applications, thealternative 16-bit Thumb mode reduces code by more than 30 % with minimal
performance penalty.
Due to their tiny size and low power consumption, LPC2101/02/03 are ideal for
applications where miniaturization is a key requirement, such as access control andpoint-of-sale. A blend of serial communications interfaces, ranging from multiple UARTS,SPI, and SSP to two I2Cs, and on-chip SRAM of 2 kB/4 kB/8 kB make these devices very
well suited for communication gateways and protocol converters. The superior
performance also makes these devices suitable as math coprocessors. Various 32-bit and16-bit timers, an improved 10-bit ADC, PWM features through output match on all timers,and 32 fast GPIO lines with up to 13 edge or level sensitive external interrupt pins makethese microcontrollers particularly suitable for industrial control and medical systems.

2. Features• 16-bit/32-bit ARM7TDMI-S microcontroller in a tiny LQFP48 package.
• 2 kB/4 kB/8 kB of on-chip static RAM and 8 kB/16 kB/32 kB of on-chip flash program
memory. 128-bit wide interface/accelerator enables high-speed 70 MHz operation.

• In-System/In-Application Programming (ISP/IAP) via on-chip boot loader software.
Single flash sector or full chip erase in 100 ms and programming of 256 bytes in 1 ms.

• EmbeddedICE RT offers real-time debugging with the on-chip RealMonitor software.
• The 10-bit A/D converter provides eight analog inputs, with conversion times as low

as 2.44 μs per channel, and dedicated result registers to minimize interrupt overhead.

• Two 32-bit timers/external event counters with combined seven capture and sevencompare channels.

• Two 16-bit timers/external event counters with combined three capture and sevencompare channels.

• Low power Real-Time Clock (RTC) with independent power and dedicated 32 kHz
clock input.

• Multiple serial interfaces including two UARTs (16C550), two Fast I2C-buses(400 kbit/s), SPI and SSP with buffering and variable data length capabilities.

• Vectored interrupt controller with configurable priorities and vector addresses.
• Up to thirty-two 5 V tolerant fast general purpose I/O pins.
• Up to 13 edge or level sensitive external interrupt pins available.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

3 of 285

UM10161

NXP Semiconductors

Chapter 1: LPC2101/02/03 Introductory information• 70 MHz maximum CPU clock available from programmable on-chip PLL with apossible input frequency of 10 MHz to 25 MHz and a settling time of 100 μs.

• On-chip integrated oscillator operates with an external crystal in the range from
1 MHz to 25 MHz.

• Power saving modes include Idle mode, Power-down mode, and Power-down modewith RTC active.

• Individual enable/disable of peripheral functions as well as peripheral clock scaling foradditional power optimization.

• Processor wake-up from Power-down mode via external interrupt or RTC.

3. Applications• Industrial control• Medical systems• Access control• Point-of-sale• Communication gateway• Embedded soft modem• General purpose applications

4. Device information
Table 1.

LPC2101/02/03 device information

Type number

Flash memory

RAM

ADC

Temperature
range (°C)

LPC2101FBD48

8 kB

2 kB

8 inputs−40 to +85

LPC2102FBD48

16 kB

4 kB

8 inputs−40 to +85

LPC2103FBD48

32 kB

8 kB

8 inputs−40 to +85

LPC2102FHN48

16 kB

4 kB

8 inputs−40 to +85

LPC2103FHN48

32 kB

8 kB

8 inputs−40 to +85

5. Architectural overview
The LPC2101/02/03 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 LPC2101/02/03 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 spacewithin the AHB address space. LPC2101/02/03 peripheral functions (other than theinterrupt controller) are connected to the APB bus. The AHB to APB bridge interfaces theUM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

4 of 285

UM10161

NXP Semiconductors

Chapter 1: LPC2101/02/03 Introductory information

APB bus to the AHB bus. APB peripherals are also allocated a 2 megabyte range ofaddresses, beginning at the 3.5 gigabyte address point. Each APB peripheral is allocateda 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 7–4 on page 67). This must be configured by software to fit specificapplication requirements for the use of peripheral functions and pins.

6. ARM7TDMI-S processor
The ARM7TDMI-S is a general purpose 32-bit microprocessor, which offers highperformance 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 andimpressive 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 ARM7TDMI-S processor also employs a unique architectural strategy known as
THUMB, which makes it ideally suited to high-volume applications with memory
restrictions, or applications where code density is an issue.
The key idea behind THUMB is that of a super-reduced instruction set. Essentially, the
ARM7TDMI-S processor has two instruction sets:• The standard 32-bit ARM instruction set.
• A 16-bit THUMB instruction set.
The THUMB set’s 16-bit instruction length allows it to approach twice the density ofstandard ARM code while retaining most of the ARM’s performance advantage over a
traditional 16-bit processor using 16-bit registers. This is possible because THUMB code
operates on the same 32-bit register set as ARM code.
THUMB code is able to provide up to 65% of the code size of ARM, and 160% of theperformance 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 thatcan be found on official ARM website.

7. On-chip flash memory system
The LPC2101/02/03 incorporate a 8 kB, 16 kB, and 32 kB flash memory system
respectively. This memory may be used for both code and data storage. Programming of
the flash memory may be accomplished in several ways:• using the serial built-in JTAG interface• using In System Programming (ISP) and UART
• using In Application Programming (IAP) capabilities
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

5 of 285

UM10161

NXP Semiconductors

Chapter 1: LPC2101/02/03 Introductory information

The application program, using the IAP functions, may also erase and/or program theflash while the application is running, allowing a great degree of flexibility for data storage
field firmware upgrades, etc. The entire flash memory is available for user code because
the boot loader resides in a separate memory location.
The LPC2101/02/03 flash memory provides minimum of 100,000 erase/write cycles and20 years of data-retention.

8. On-chip Static RAM (SRAM)
On-chip Static RAM (SRAM) may be used for code and/or data storage. The on-chip
SRAM may be accessed as 8-bits, 16-bits, and 32-bits. The LPC2101/02/03 provide
2/4/8 kB of static RAM respectively.
The LPC2101/02/03 SRAM is designed to be accessed as a byte-addressed memory.
Word and halfword accesses to the memory ignore the alignment of the address andaccess the naturally-aligned value that is addressed (so a memory access ignores
address bits 0 and 1 for word accesses, and ignores bit 0 for halfword accesses).
Therefore valid reads and writes require data accessed as halfwords to originate fromaddresses with address line 0 being 0 (addresses ending with 0, 2, 4, 6, 8, A, C, and E in
hexadecimal notation) and data accessed as words to originate from addresses withaddress lines 0 and 1 being 0 (addresses ending with 0, 4, 8, and C in hexadecimal
notation).
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 bysoftware to the SRAM. This data is only written to the SRAM when another write isrequested by software (the data is only written to the SRAM when software does anotherwrite). 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.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

6 of 285

UM10161

NXP Semiconductors

Chapter 1: LPC2101/02/03 Introductory information

9. Block diagram
TMS
TRST

LPC2101/2102/2103

P0[31:0]

HIGH SPEED
GENERALPURPOSE I/O

8 kB
BOOT ROMTDI
TCK

XTAL2 VDD(3V3) VDD(1V8)
XTAL1

TDO

RST

VSS

TEST/DEBUG
INTERFACE
PLL

ARM7TDMI-S
AHB BRIDGE

systemclock

ARM7 local bus

SYSTEM
FUNCTIONSVECTORED
INTERRUPTCONTROLLER

AMBA AHB(Advanced High-performance Bus)INTERNAL
SRAM
CONTROLLERMEMORYACCELERATOR

2 kB/4 kB/
8 kB SRAM

8 kB/16 kB/
32 kB FLASHAHB TO APBBRIDGE
APB (ARM
peripheral bus)

EINT2 toEINT0(1)

EXTERNAL
INTERRUPTS

I2C-BUS SERIALINTERFACES 0 AND 1

3 × CAP0(1)4 × CAP1(1)3 × CAP2(1)3 × MAT0(1)4 × MAT1(1)
3 × MAT2(1)
4 × MAT3(1)CAPTURE/COMPARE
EXTERNAL COUNTERTIMER 0/TIMER 1/
TIMER 2/TIMER 3

SPI AND SSPSERIAL INTERFACES

AD0[7:0]ADC

UART0/UART1

GENERALPURPOSE I/O

REAL-TIME CLOCK

WATCHDOGTIMERSYSTEM CONTROL

P0[31:0]

SCL0, SCL1(1)SDA0, SDA1(1)SCK0, SCK1(1)
MOSI0, MOSI1(1)
MISO0, MISO1(1)SSEL0, SSEL1(1)TXD0, TXD1(1)RXD0, RXD1(1)DSR1, CTS1,
RTS1, DTR1
DCD1, RI1
RTCX1
RTCX2
VBAT

002aab814(1) Pins shared with GPIO.

Fig 1.

LPC2101/02/03 block diagram

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

7 of 285

UM10161
Chapter 2: LPC2101/02/03 Memory addressing
Rev. 3 — 2 October 2008

User manual

1. Memory maps
The LPC2101/02/03 incorporates 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.

0xFFFF FFFF

4.0 GBAHB PERIPHERALS

0xF000 0000

3.75 GBAPB PERIPHERALS
3.5 GB

0xE000 0000

3.0 GB

0xC000 0000
RESERVED ADDRESS SPACE

2.0 GB

0x8000 0000
BOOT BLOCK
0x7FFF E000
0x7FFF DFFFRESERVED ADDRESS SPACE

0x4000 2000
0x4000 1FFF
8 kB ON-CHIP STATIC RAM (LPC2103)
0x4000 1000
0x4000 0FFF
4 kB ON-CHIP STATIC RAM (LPC2102)
0x4000 0800
0x4000 07FF
1.0 GB

2 kB ON-CHIP STATIC RAM (LPC2101)
0x4000 0000

RESERVED ADDRESS SPACE
0x0000 8000
0x0000 7FFF
32 kB ON-CHIP NON-VOLATILE MEMORY
16 kB ON-CHIP NON-VOLATILE MEMORY

0x0000 4000
0x0000 3FFF
0x0000 2000
0x0000 1FFF

8 kB ON-CHIP NON-VOLATILE MEMORY
0.0 GBFig 2.

0x0000 0000

System memory map

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

8 of 285

UM10161

NXP Semiconductors

Chapter 2: LPC2101/02/03 Memory addressing

4.0 GB

0xFFFF FFFFAHB PERIPHERALS
0xFFE0 0000
0xFFDF FFFF

4.0 GB - 2 MB

RESERVED

0xF000 0000
0xEFFF FFFF

3.75 GBRESERVED

0xE020 0000
0xE01F FFFF

3.5 GB + 2 MB
APB PERIPHERALS

0xE000 0000

3.5 GBAHB section is 128 x 16 kB blocks (totaling 2 MB).
APB section is 128 x 16 kB blocks (totaling 2MB).

Fig 3. Peripheral memory map

Figure 2–3, Figure 2–4, and Table 2–2 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
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

9 of 285

UM10161

NXP Semiconductors

Chapter 2: LPC2101/02/03 Memory addressing

word aligned (to 32-bit boundaries) regardless of their size. This eliminates the need forbyte 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 andhalf-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.

VECTORED INTERRUPT CONTROLLER

0xFFFF F000 (4G - 4K)

0xFFFF C000

(AHB PERIPHERAL #126)
0xFFFF 8000

(AHB PERIPHERAL #125)
0xFFFF 4000

(AHB PERIPHERAL #124)
0xFFFF 0000

0xFFE1 0000

(AHB PERIPHERAL #3)
0xFFE0 C000

(AHB PERIPHERAL #2)
0xFFE0 8000

(AHB PERIPHERAL #1)
0xFFE0 4000

(AHB PERIPHERAL #0)
0xFFE0 0000

Fig 4.

AHB peripheral map

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

10 of 285

UM10161

NXP Semiconductors

Chapter 2: LPC2101/02/03 Memory addressing

Table 2.

APB peripheries and base addresses

APB peripheral

Base address

Peripheral name

00xE000 0000

Watchdog timer

1

0xE000 4000

Timer 02

0xE000 8000

Timer 1

30xE000 C000

UART0

4

0xE001 0000

UART1

5

0xE001 4000

Not used

60xE001 8000

Not used

7

0xE001 C000

I2C0

8

0xE002 0000

SPI0

9

0xE002 4000

RTC

10

0xE002 8000

GPIO

11

0xE002 C000

Pin connect block

120xE003 0000

Not used

13

0xE003 4000

ADC

14 - 220xE003 8000
0xE005 8000

Not used

23

0xE005 C000

I2C1

24

0xE006 0000

Not used25

0xE006 4000

Not used26

0xE006 8000

SSP

27

0xE006 C000

Not used

28

0xE007 0000

Timer 229

0xE007 4000

Timer 330 - 126

0xE007 8000
0xE01F 8000

Not used

127

0xE01F C000

System Control Block

2. LPC2101/02/03 memory re-mapping and boot block
2.1 Memory map concepts and operating modes
The basic concept on the LPC2101/02/03 is that each memory area has a "natural"
location in the memory map. This is the address range for which code residing in that area
is written. The bulk of each memory space remains permanently fixed in the same
location, eliminating the need to have portions of the code designed to run in different
address ranges.
Because of the location of the interrupt vectors on the ARM7 processor (at addresses
0x0000 0000 through 0x0000 001C, as shown in Table 2–3 below), a small portion of the
Boot Block and SRAM spaces need to be re-mapped in order to allow alternative uses ofinterrupts in the different operating modes described in Table 2–4. Re-mapping of theinterrupts is accomplished via the Memory Mapping Control feature (Section 5–7 “Memory
mapping control” on page 45).

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

11 of 285

UM10161

NXP Semiconductors

Chapter 2: LPC2101/02/03 Memory addressing

Table 3.

ARM exception vector locations

Address

Exception

0x0000 0000

Reset

0x0000 0004

Undefined Instruction

0x0000 0008

Software Interrupt

0x0000 000C

Prefetch Abort (instruction fetch memory fault)

0x0000 0010

Data Abort (data access memory fault)

0x0000 0014

Reserved
Note: Identified as reserved in ARM documentation, this location is usedby the Boot Loader as the Valid User Program key. This is described indetail in Section 19–4.2 “Criterion for valid user code”.

0x0000 0018

IRQ

0x0000 001C

FIQ

Table 4.

LPC2101/02/03 memory mapping modes

Mode

Activation

Usage

Boot
Loadermode

Hardwareactivation by
any Reset

The Boot Loader always executes after any reset. The Boot Blockinterrupt vectors are mapped to the bottom of memory to allow
handling exceptions and using interrupts during the Boot Loading
process.

User
Flash
mode

Softwareactivation by
Boot code

Activated by Boot Loader when a valid User Program Signature isrecognized in memory and Boot Loader operation is not forced.
Interrupt vectors are not re-mapped and are found in the bottom of theFlash memory.

User RAM Software
Activated by a User Program as desired. Interrupt vectors aremode
activation by re-mapped to the bottom of the Static RAM.
User program

2.2 Memory re-mapping
In order to allow for compatibility with future derivatives, the entire Boot Block is mapped
to the top of the on-chip memory space. In this manner, the use of larger or smaller flash
modules will not require changing the location of the Boot Block (which would requirechanging the Boot Loader code itself) or changing the mapping of the Boot Block interrupt
vectors. Memory spaces other than the interrupt vectors remain in fixed locations.
Figure 2–5 shows the on-chip memory mapping in the modes defined above.
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 through0x0000 003F. A typical user program in the Flash memory can place the entire FIQ
handler at address 0x0000 001C without any need to consider memory boundaries. The
vector contained in the SRAM, external memory, and Boot Block must contain branches tothe actual interrupt handlers, or to other instructions that accomplish the branch to theinterrupt handlers.
There are three reasons this configuration was chosen:
1. To give the FIQ handler in the Flash memory the advantage of not having to take amemory boundary caused by the remapping into account.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

12 of 285

UM10161

NXP Semiconductors

Chapter 2: LPC2101/02/03 Memory addressing

2. Minimize the need to for the SRAM and Boot Block vectors to deal with arbitrary
boundaries in the middle of code space.
3. To provide space to store constants for jumping beyond the range of single word
branch instructions.
Re-mapped memory areas, including the 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 5–7 “Memory mapping
control” on page 45.

0x7FFF FFFF

2.0 GB
8 kB BOOT BLOCK

2.0 GB - 8 kB

(BOOT BLOCK INTERRUPT VECTORS)

0x7FFF E000

RESERVED ADDRESS SPACE
ON-CHIP SRAM
LPC2103: 8 kB ( 0x4000 2000
LPC2102: 4 kB (0x4000 1000)
LPC2101: 2 kB (0x4000 0800)(SRAM INTERRUPT VECTORS)

1.0 GB

0x4000 0000

RESERVED ADDRESS SPACE

0x0000 7FFF
32 kB ON-CHIP FLASH MEMORYACTIVE INTERRUPT VECTORSFROM BOOT BLOCK

0.0 GBFig 5.

0x0000 0000

Map of lower memory is showing re-mapped and re-mappable areas (LPC2103
with 32 kB Flash)3. Prefetch abort and data abort exceptions
The LPC2101/02/03 generates the appropriate bus cycle abort exception if an access is
attempted for an address that is in a reserved or unassigned address region. The regionsare:• Areas of the memory map that are not implemented for a specific ARM derivative. For
the LPC2101/02/03, this is:– Address space between on-chip Non-Volatile Memory and on-chip SRAM, labelled"Reserved Address Space" in Figure 2–2. For 32 kB Flash device this is memory
address range from 0x0000 8000 to 0x3FFF FFFF, for 16 kB Flash device this ismemory address range from 0x0000 4000 to 0x3FFF FFFF, and for 8 kB Flashdevice this is memory address range from 0x0000 2000 to 0x3FFF FFFF.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

13 of 285

UM10161

NXP Semiconductors

Chapter 2: LPC2101/02/03 Memory addressing– Address space between on-chip Static RAM and the Boot Block. Labelled"Reserved Address Space" in Figure 2–2. For 8 kB SRAM device this is memory
address range from 0x4000 2000 to 0x7FFF DFFF, for 4 kB SRAM device this ismemory address range from 0x4000 1000 to 0x7FFF DFFF, and for 2 kB SRAM
device this range is from 0x4000 0800 to 0x7FFF DFFF.
– Address space between 0x8000 0000 and 0xDFFF FFFF, labelled "Reserved
Address Space".
– Reserved regions of the AHB and APB spaces. See Figure 2–3.

• Unassigned AHB peripheral spaces. See Figure 2–4.
• Unassigned APB peripheral spaces. See Table 2–2.
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 toan 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 withineach 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 definedin the LPC2101/02/03 documentation and are not a supported feature.
Note that the ARM core stores the Prefetch Abort flag along with the associatedinstruction (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 preventsaccidental aborts that could be caused by prefetches that occur when code is executed
very close to a memory boundary.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 200814 of 285

UM10161
Chapter 3: LPC2101/02/03 Memory Acceleration Module(MAM)
Rev. 3 — 2 October 2008

User manual

1. Introduction
The MAM block in the LPC2101/02/03 maximizes the performance of the ARM processor
when it is running code in flash memory using a single flash bank.

2. 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
LPC2101/02/03 uses one bank of Flash memory, compared to the two banks used on
predecessor devices. It includes three 128-bit buffers called the Prefetch Buffer, theBranch Trail Buffer and the Data Buffer. When an Instruction Fetch is not satisfied byeither the Prefetch or Branch Trail buffer, nor has a prefetch been initiated for that line, theARM is stalled while a fetch is initiated for the 128-bit line. If a prefetch has been initiatedbut not yet completed, the ARM is stalled for a shorter time. Unless aborted by a data
access, a prefetch is initiated as soon as the Flash has completed the previous access.
The prefetched line is latched by the Flash module, but the MAM does not capture the line
in its prefetch buffer until the ARM core presents the address from which the prefetch has
been made. If the core presents a different address from the one from which the prefetch
has been made, the prefetched line is discarded.
The Prefetch and Branch Trail Buffers each include four 32-bit ARM instructions or eight
16-bit Thumb instructions. During sequential code execution, typically the prefetch buffer
contains the current instruction and the entire Flash line that contains it.
The MAM uses the LPROT[0] line to differentiate between instruction and data accesses.
Code and data accesses use separate 128-bit buffers. 3 of every 4 sequential 32-bit codeor data accesses "hit" in the buffer without requiring a Flash access (7 of 8 sequential
16-bit accesses, 15 of every 16 sequential byte accesses). The fourth (eighth, 16th)
sequential data access must access Flash, aborting any prefetch in progress. When aFlash data access is concluded, any prefetch that had been in progress is re-initiated.
Timing of Flash read operations is programmable and is described later in this section.
In this manner, there is no code fetch penalty for sequential instruction execution when the
CPU clock period is greater than or equal to one fourth of the Flash access time. The
average amount of time spent doing program branches is relatively small (less than 25%)and may be minimized in ARM (rather than Thumb) code through the use of theconditional execution feature present in all ARM instructions. This conditional execution
may often be used to avoid small forward branches that would otherwise be necessary.
Branches and other program flow changes cause a break in the sequential flow of
instruction fetches described above. The Branch Trail Buffer captures the line to whichsuch a non-sequential break occurs. If the same branch is taken again, the next
instruction is taken from the Branch Trail Buffer. When a branch outside the contents of

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 200815 of 285

UM10161

NXP Semiconductors

Chapter 3: LPC2101/02/03 Memory Acceleration Module (MAM)

the Prefetch and Branch Trail Buffer is taken, a stall of several clocks is needed to load theBranch Trail Buffer. Subsequently, there will typically be no further instruction fetch delays
until a new and different branch occurs.

3. MAM blocks
The Memory Accelerator Module is divided into several functional blocks:• A Flash Address Latch and an incrementing function to form prefetch addresses• A 128-bit Prefetch Buffer and an associated Address latch and comparator• A 128-bit Branch Trail Buffer and an associated Address latch and comparator• A 128-bit Data Buffer and an associated Address latch and comparator• Control logic• 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 fromthe ARM. “Pre-fetch” is used to denote a Flash read of instructions beyond the current
processor fetch address.

3.1 Flash memory bank
There is one bank of flash memory on the LPC2101/02/03 MAM.
Flash programming operations are not controlled by the MAM but are handled as aseparate function. A separate boot block in ROM 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.

MEMORY ADDRESSFLASH MEMORY BANKARM LOCAL BUS

BUS
INTERFACE

BUFFERSFig 6.

Simplified block diagram of the Memory Accelerator Module (MAM)

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 200816 of 285

UM10161

NXP Semiconductors

Chapter 3: LPC2101/02/03 Memory Acceleration Module (MAM)

3.2 Instruction latches and data latches
Code and Data accesses are treated separately by the Memory Accelerator Module.
There is a 128-bit Latch, a 15-bit Address
Latch, and a 15-bit comparator associated with each buffer (prefetch, branch trail, anddata). Each 128-bit latch holds 4 words (4 ARM instructions, or 8 Thumb instructions).
Also associated with each buffer are 32 4:1 Multiplexers that select the requested wordfrom the 128-bit line.
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.

3.3 Flash programming issues
Since the flash memory does not allow accesses during programming and erase
operations, it is necessary for the MAM to force the CPU to wait if a memory access to aflash address is requested while the flash module is busy. Under some conditions, this
delay could result in a watchdog time-out. The user will need to be aware of this possibility
and take steps to insure that an unwanted watchdog reset does not cause a system failure
while programming or erasing the flash memory.
In order to preclude the possibility of stale data being read from the flash memory, theLPC2101/02/03 MAM holding latches are automatically invalidated at the beginning of any
flash programming or erase operation. Any subsequent read from a flash address willcause a new fetch to be initiated after the flash operation has completed.

4. MAM operating modes
Three modes of operation are defined for the MAM, trading off performance for ease ofpredictability:
Mode 0: MAM off. All memory requests result in a Flash read operation (see note 2
below). There are no instruction prefetches.
Mode 1: MAM partially enabled. Sequential instruction accesses are fulfilled from theholding latches if the data is present. Instruction prefetch is enabled. Non-sequential
instruction accesses initiate Flash read operations (see note 2 below). This means thatall 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 iscontained 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.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 200817 of 285

UM10161

NXP Semiconductors

Chapter 3: LPC2101/02/03 Memory Acceleration Module (MAM)

Table 5.

MAM Responses to program accesses of various types

Program Memory Request Type

MAM Mode0

12

Sequential access, data in latches

Initiate Fetch[2]Use Latched
Data[1]

Use Latched
Data[1]

Sequential access, data not in latches

Initiate Fetch

Initiate Fetch[1]Initiate Fetch[1]Non-sequential access, data in latches

Initiate Fetch[2]Initiate Fetch[1][2] Use Latched
Data[1]

Non-sequential access, data not in latches Initiate Fetch

Initiate Fetch[1]Initiate Fetch[1][1]Instruction prefetch is enabled in modes 1 and 2.

[2]

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 thefetch timing value in MAMTIM to one clock.

Table 6.

MAM responses to data accesses of various types

Data Memory Request Type

MAM Mode0

12

Sequential access, data in latches

Initiate Fetch[1]Initiate Fetch[1]Use Latched
Data

Sequential access, data not in latches

Initiate Fetch

Initiate Fetch

Initiate Fetch

Non-sequential access, data in latches

Initiate Fetch[1]Initiate Fetch[1]Use Latched
Data

Initiate Fetch

Initiate Fetch

Non-sequential access, data not in latches Initiate Fetch[1]

The MAM actually uses latched data if it is available, but it 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 thefetch timing value in MAMTIM to one clock.

5. MAM configuration
After reset the MAM defaults to the disabled state. Software can turn memory accessacceleration on or off at any time. This allows most of an application to be run at thehighest possible performance, while certain functions can be run at a somewhat slower
but more predictable rate if more precise timing is required.

6. Register description
All registers, regardless of size, are on word address boundaries. Details of the registers
appear in the description of each function.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 200818 of 285

UM10161

NXP Semiconductors

Chapter 3: LPC2101/02/03 Memory Acceleration Module (MAM)

Table 7.

Summary of MAM registers

Name

Description

Access Reset
Addressvalue[1]

MAMCR Memory Accelerator Module Control Register.
Determines the MAM functional mode, that is, towhat extent the MAM performance enhancements
are enabled. See Table 3–8.

R/W

0x0

0xE01F C000

MAMTIM Memory Accelerator Module Timing control.
Determines the number of clocks used for Flashmemory fetches (1 to 7 processor clocks).

R/W

0x07

0xE01F C004

[1]

Reset value reflects the data stored in used bits only. It does not include reserved bits content.

7. MAM Control register (MAMCR - 0xE01F C000)
Two configuration bits select the three MAM operating modes, as shown in Table 3–8.
Following Reset, MAM functions are disabled. Changing the MAM operating mode causes
the MAM to invalidate all of the holding latches, resulting in new reads of Flashinformation as required.
Table 8.

MAM Control Register (MAMCR - address 0xE01F C000) bit description

Bit

Symbol1:0

MAM_mode 00_control
01

7:2

-

Value

Description

Reset
value

MAM functions disabled

0

MAM functions partially enabled

10

MAM functions fully enabled

11

Reserved. Not to be used in the application.

-

Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.

8. MAM Timing register (MAMTIM - 0xE01F C004)
The MAM Timing register determines how many CCLK cycles are used to access theFlash memory. This allows tuning MAM timing to match the processor operating
frequency. Flash access times from 1 clock to 7 clocks are possible. Single clock Flashaccesses would essentially remove the MAM from timing calculations. In this case theMAM mode may be selected to optimize power usage.
Table 9.

MAM Timing register (MAMTIM - address 0xE01F C004) bit description

Bit

SymbolValue Description

Reset
value

2:0

MAM_fetch_
cycle_timing

000

0 - Reserved.

07

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

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 200819 of 285

UM10161

NXP Semiconductors

Chapter 3: LPC2101/02/03 Memory Acceleration Module (MAM)

Table 9.
Bit

MAM Timing register (MAMTIM - address 0xE01F C004) bit description

SymbolValue Description

Reset
value

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
bits. The value read from a reserved bit is not defined.

NA

9. MAM usage notes
When changing MAM timing, the MAM must first be turned off by writing a zero to
MAMCR. A new value may then be written to MAMTIM. Finally, the MAM may be turnedon again by writing a value (1 or 2) corresponding to the desired operating mode to
MAMCR.
For a system clock slower than 20 MHz, MAMTIM can be 001. For a system clock
between 20 MHz and 40 MHz, flash access time is suggested to be 2 CCLKs, while insystems with a system clock faster than 40 MHz, 3 CCLKs are proposed. For system
clocks of 60 MHz and above, 4CCLK’s are needed.
Table 10.

Suggestions for MAM timing selection

system clock

Number of MAM fetch cycles in MAMTIM< 20 MHz

1 CCLK

20 MHz to 40 MHz

2 CCLK

40 MHz to 60 MHz

3 CCLK>60 MHz

4 CCLK

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

20 of 285

UM10161
Chapter 4: Vectored Interrupt Controller (VIC)Rev. 3 — 2 October 2008

User manual

1. 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

2. Description
The Vectored Interrupt Controller (VIC) takes 32 interrupt request inputs andprogrammably assigns them into 3 categories, FIQ, vectored IRQ, and non-vectored IRQ.
The programmable assignment scheme means that priorities of interrupts from thevarious 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 isclassified as FIQ because then the FIQ service routine can simply start dealing with thatdevice. 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 aninterrupt.
Vectored IRQs have the middle priority, but only 16 of the 32 requests can be assigned tothis 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.
Non-vectored IRQs have the lowest priority.
The VIC ORs the requests from all the vectored and non-vectored IRQs to produce theIRQ signal to the ARM processor. The IRQ service routine can start by reading a registerfrom 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 notsupported.
Additional information on the Vectored Interrupt Controller is available in the ARM
PrimeCell Vectored Interrupt Controller (PL190) documentation.

3. Register description
The VIC implements the registers shown in Table 4–11. More detailed descriptions follow.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

21 of 285

UM10161

NXP Semiconductors

Chapter 4: Vectored Interrupt Controller (VIC)

Table 11.

VIC register map

Name

Description

AccessResetvalue[1]Address

VICIRQStatus

IRQ Status Register. This register reads out the state ofthose interrupt requests that are enabled and classified as
IRQ.

RO

0

0xFFFF F000

VICFIQStatus

FIQ Status Requests. This register reads out the state ofthose interrupt requests that are enabled and classified as
FIQ.

RO

0

0xFFFF F004

VICRawIntr

Raw Interrupt Status Register. This register reads out thestate of the 32 interrupt requests / software interrupts,
regardless of enabling or classification.

RO

0

0xFFFF F008

VICIntSelectInterrupt Select Register. This register classifies each of the R/W
32 interrupt requests as contributing to FIQ or IRQ.

00xFFFF F00C

VICIntEnable

Interrupt Enable Register. This register controls which of the R/W
32 interrupt requests and software interrupts are enabled tocontribute to FIQ or IRQ.

00xFFFF F010

VICIntEnClr

Interrupt Enable Clear Register. This register allows
software to clear one or more bits in the Interrupt Enableregister.

WO

00xFFFF F014

VICSoftInt

Software Interrupt Register. The contents of this register are R/W
ORed with the 32 interrupt requests from various peripheral
functions.

00xFFFF F018

VICSoftIntClear

Software Interrupt Clear Register. This register allows
software to clear one or more bits in the Software Interrupt
register.

WO

00xFFFF F01C

VICProtection

Protection enable register. This register allows limiting
R/W
access to the VIC registers by software running in privileged
mode.

0

0xFFFF F020

VICVectAddr

Vector Address Register. When an IRQ interrupt occurs, the R/W
IRQ service routine can read this register and jump to thevalue read.

0

0xFFFF F030

VICDefVectAddr Default Vector Address Register. This register holds theaddress of the Interrupt Service routine (ISR) for
non-vectored IRQs.

R/W

00xFFFF F034

VICVectAddr0

Vector address 0 register. Vector Address Registers 0-15
hold the addresses of the Interrupt Service routines (ISRs)
for the 16 vectored IRQ slots.

R/W

0

0xFFFF F100

VICVectAddr1

Vector address 1 register.

R/W

00xFFFF F104

VICVectAddr2

Vector address 2 register.

R/W

00xFFFF F108

VICVectAddr3

Vector address 3 register.

R/W

00xFFFF F10C

VICVectAddr4

Vector address 4 register.

R/W

00xFFFF F110

VICVectAddr5

Vector address 5 register.

R/W

00xFFFF F114

VICVectAddr6

Vector address 6 register.

R/W

00xFFFF F118

VICVectAddr7

Vector address 7 register.

R/W

00xFFFF F11C

VICVectAddr8

Vector address 8 register.

R/W

00xFFFF F120

VICVectAddr9

Vector address 9 register.

R/W

00xFFFF F124

VICVectAddr10

Vector address 10 register.

R/W

00xFFFF F128

VICVectAddr11

Vector address 11 register.

R/W

00xFFFF F12C

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

22 of 285

UM10161

NXP Semiconductors

Chapter 4: Vectored Interrupt Controller (VIC)

Table 11.

VIC register map

Name

Description

AccessResetvalue[1]Address

VICVectAddr12

Vector address 12 register.

R/W

00xFFFF F130

VICVectAddr13

Vector address 13 register.

R/W

00xFFFF F134

VICVectAddr14

Vector address 14 register.

R/W

00xFFFF F138

VICVectAddr15

Vector address 15 register.

R/W

00xFFFF F13C

VICVectCntl0

Vector control 0 register. Vector Control Registers 0-15 each R/Wcontrol one of the 16 vectored IRQ slots. Slot 0 has thehighest priority and slot 15 the lowest.

00xFFFF F200

VICVectCntl1

Vector control 1 register.

R/W

00xFFFF F204

VICVectCntl2

Vector control 2 register.

R/W

00xFFFF F208

VICVectCntl3

Vector control 3 register.

R/W

00xFFFF F20C

VICVectCntl4

Vector control 4 register.

R/W

00xFFFF F210

VICVectCntl5

Vector control 5 register.

R/W

00xFFFF F214

VICVectCntl6

Vector control 6 register.

R/W

00xFFFF F218

VICVectCntl7

Vector control 7 register.

R/W

00xFFFF F21C

VICVectCntl8

Vector control 8 register.

R/W

00xFFFF F220

VICVectCntl9

Vector control 9 register.

R/W

00xFFFF F224

VICVectCntl10

Vector control 10 register.

R/W

00xFFFF F228

VICVectCntl11

Vector control 11 register.

R/W

00xFFFF F22C

VICVectCntl12

Vector control 12 register.

R/W

00xFFFF F230

VICVectCntl13

Vector control 13 register.

R/W

00xFFFF F234

VICVectCntl14

Vector control 14 register.

R/W

00xFFFF F238

VICVectCntl15

Vector control 15 register.

R/W

00xFFFF F23C

[1]

Reset value reflects the data stored in used bits only. It does not include reserved bits content.

4. 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 foruse by software. For most people, this is also the best order to read about the registers
when learning the VIC.

4.1 Software Interrupt register (VICSoftInt - 0xFFFF F018)
The contents of this register are ORed with the 32 interrupt requests from the various
peripherals, before any other logic is applied.
Table 12. Software Interrupt register (VICSoftInt - address 0xFFFF F018) bit allocation
Reset value: 0x0000 0000
Bit

31

30

29

28

27

26

25

24

Symbol----TIMER3

TIMER2--

Access

R/W

R/W

R/W

R/W

R/W

R/W

R/W

R/W

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

23 of 285

UM10161

NXP Semiconductors

Chapter 4: Vectored Interrupt Controller (VIC)

Bit

23

22

21

20

19

18

17

16

Symbol

-

-

-

-

I2C1

AD0

-

EINT2

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

SSP/SPI1

SPI0

I2C0

-

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

TIMER1TIMER0

ARMCore1

ARMCore0-

WDT

Access

R/W

R/W

R/W

R/W

R/W

R/W

R/W

R/W

Table 13.

Software Interrupt register (VICSoftInt - address 0xFFFF F018) bit description

Bit

Symbol

Value

31:0

See VICSoftInt 0
bit allocationtable.
1

Description

Reset
value

Do not force the interrupt request with this bit number. Writing
zeroes to bits in VICSoftInt has no effect, see VICSoftIntClear(Section 4–4.2).

0Force the interrupt request with this bit number.

4.2 Software Interrupt Clear register (VICSoftIntClear - 0xFFFF F01C)
This register allows software to clear one or more bits in the Software Interrupt register,
without having to first read it.
Table 14. Software Interrupt Clear register (VICSoftIntClear - address 0xFFFF F01C) bit allocation
Reset value: 0x0000 0000
Bit

31

30

29

28

27

26

25

24

Symbol----TIMER3

TIMER2--

Access

WO

WO

WO

WO

WO

WO

WO

WO

Bit

23

22

21

20

19

18

17

16

Symbol

-

-

-

-

I2C1

AD0

-

EINT2

Access

WO

WO

WO

WO

WO

WO

WO

WO

15

14

13

12

11

10

9

8

Symbol

Bit

EINT1

EINT0

RTC

PLL

SSP/SPI1

SPI0

I2C0

-

Access

WO

WO

WO

WO

WO

WO

WO

WO

Bit

7

6

5

4

3

2

1

0

Symbol

UART1

UART0

TIMER1TIMER0

ARMCore1

ARMCore0-

WDT

Access

WO

WO

WO

WO

WO

WO

WO

WO

Table 15.

Software Interrupt Clear register (VICSoftIntClear - address 0xFFFF F01C) bit description

Bit

Symbol

Value

31:0

See
0
VICSoftIntClea 1
r bit allocationtable.

Description

Reset
value

Writing a 0 leaves the corresponding bit in VICSoftInt unchanged.

0

Writing a 1 clears the corresponding bit in the Software Interrupt
register, thus releasing the forcing of this request.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

24 of 285

UM10161

NXP Semiconductors

Chapter 4: Vectored Interrupt Controller (VIC)

4.3 Raw Interrupt status register (VICRawIntr - 0xFFFF F008)
This is a read only register. This register reads out the state of the 32 interrupt requests
and software interrupts, regardless of enabling or classification.
Table 16. Raw Interrupt status register (VICRawIntr - address 0xFFFF F008) bit allocation
Reset value: 0x0000 0000
Bit

31

30

29

28

27

26

25

24

Symbol----TIMER3

TIMER2--

Access

RO

RO

RO

RO

RO

RO

RO

RO

Bit

23

22

21

20

19

18

17

16

Symbol

-

-

-

-

I2C1

AD0

-

EINT2

Access

RO

RO

RO

RO

RO

RO

RO

RO

Bit

15

14

13

12

11

10

9

8

Symbol

EINT1

EINT0

RTC

PLL

SSP/SPI1

SPI0

I2C0

-

Access

RO

RO

RO

RO

RO

RO

RO

RO

Bit

7

6

5

4

3

2

1

0

Symbol

UART1

UART0

TIMER1TIMER0

ARMCore1

ARMCore0-

WDT

Access

RO

RO

RO

RO

RO

RO

RO

RO

Table 17.

Raw Interrupt status register (VICRawIntr - address 0xFFFF F008) bit description

Bit

SymbolValue

Description

Reset
value

31:0

See
VICRawIntr bit
allocationtable.

0

Neither the hardware nor software interrupt request with this bit
number are asserted.

01

The hardware or software interrupt request with this bit number isasserted.

4.4 Interrupt Enable register (VICIntEnable - 0xFFFF F010)
This is a read/write accessible register. This register controls which of the 32 interrupt
requests and software interrupts contribute to FIQ or IRQ.
Table 18. Interrupt Enable register (VICIntEnable - address 0xFFFF F010) bit allocation
Reset value: 0x0000 0000
Bit

31

30

29

28

27

26

25

24

Symbol----TIMER3

TIMER2--

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

-

-

-

-

I2C1

AD0

-

EINT2

Access

R/W

R/W

R/W

R/W

R/W

R/W

R/W

R/W

15

14

13

12

11

10

9

8

Symbol

Bit

EINT1

EINT0

RTC

PLL

SSP/SPI1

SPI0

I2C0

-

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

TIMER1TIMER0

ARMCore1

ARMCore0-

WDT

Access

R/W

R/W

R/W

R/W

R/W

R/W

R/W

R/W

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

25 of 285

UM10161

NXP Semiconductors

Chapter 4: Vectored Interrupt Controller (VIC)

Table 19.

Interrupt Enable register (VICIntEnable - address 0xFFFF F010) bit description

Bit

SymbolDescription

Reset
value

31:0

See
VICIntEnable
bit allocationtable.

When this register is read, 1s indicate interrupt requests or software interruptsthat are enabled to contribute to FIQ or IRQ.

0

When this register is written, ones enable interrupt requests or softwareinterrupts to contribute to FIQ or IRQ, zeroes have no effect. See Section 4–4.5“Interrupt Enable Clear register (VICIntEnClear - 0xFFFF F014)” on page 26
and Table 4–21 below for how to disable interrupts.

4.5 Interrupt Enable Clear register (VICIntEnClear - 0xFFFF F014)
This is a write only register. This register allows software to clear one or more bits in theInterrupt Enable register (see Section 4–4.4 “Interrupt Enable register (VICIntEnable 0xFFFF F010)” on page 25), without having to first read it.
Table 20. Software Interrupt Clear register (VICIntEnClear - address 0xFFFF F014) bit allocation
Reset value: 0x0000 0000
Bit

31

30

29

28

27

26

25

24

Symbol----TIMER3

TIMER2--

Access

WO

WO

WO

WO

WO

WO

WO

WO

Bit

23

22

21

20

19

18

17

16

Symbol

-

-

-

-

I2C1

AD0

-

EINT2

Access

WO

WO

WO

WO

WO

WO

WO

WO

Bit

15

14

13

12

11

10

9

8

Symbol

EINT1

EINT0

RTC

PLL

SSP/SPI1

SPI0

I2C0

-

Access

WO

WO

WO

WO

WO

WO

WO

WO

Bit

7

6

5

4

3

2

1

0

Symbol

UART1

UART0

TIMER1TIMER0

ARMCore1

ARMCore0-

WDT

Access

WO

WO

WO

WO

WO

WO

WO

WO

Table 21.

Software Interrupt Clear register (VICIntEnClear - address 0xFFFF F014) bit description

Bit

SymbolValue

Description

Reset
value

31:0

See
VICIntEnClear
bit allocationtable.

0

Writing a 0 leaves the corresponding bit in VICIntEnable
unchanged.

0

1

Writing a 1 clears the corresponding bit in the Interrupt Enableregister, thus disabling interrupts for this request.

4.6 Interrupt Select register (VICIntSelect - 0xFFFF F00C)
This is a read/write accessible register. This register classifies each of the 32 interrupt
requests as contributing to FIQ or IRQ.
Table 22. Interrupt Select register (VICIntSelect - address 0xFFFF F00C) bit allocation
Reset value: 0x0000 0000
Bit

31

30

29

28

27

26

25

24

Symbol----TIMER3

TIMER2--

Access

R/W

R/W

R/W

R/W

R/W

R/W

R/W

R/W

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

26 of 285

UM10161

NXP Semiconductors

Chapter 4: Vectored Interrupt Controller (VIC)

Bit

23

22

21

20

19

18

17

16

Symbol

-

-

-

-

I2C1

AD0

-

EINT2

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

SSP/SPI1

SPI0

I2C0

-

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

TIMER1TIMER0

ARMCore1

ARMCore0-

WDT

Access

R/W

R/W

R/W

R/W

R/W

R/W

R/W

R/W

Table 23.

Interrupt Select register (VICIntSelect - address 0xFFFF F00C) bit description

Bit

SymbolValue

Description

Reset
value

31:0

See
VICIntSelectbit allocationtable.

0

The interrupt request with this bit number is assigned to the IRQ
category.

01

The interrupt request with this bit number is assigned to the FIQ
category.

4.7 IRQ Status register (VICIRQStatus - 0xFFFF F000)
This is a read only register. This register reads out the state of those interrupt requests
that are enabled and classified as IRQ. It does not differentiate between vectored andnon-vectored IRQs.
Table 24. IRQ Status register (VICIRQStatus - address 0xFFFF F000) bit allocation
Reset value: 0x0000 0000
Bit

31

30

29

28

27

26

25

24

Symbol----TIMER3

TIMER2--

Access

RO

RO

RO

RO

RO

RO

RO

RO

Bit

23

22

21

20

19

18

17

16

Symbol

-

-

-

-

I2C1

AD0

-

EINT2

Access

RO

RO

RO

RO

RO

RO

RO

RO

Bit

15

14

13

12

11

10

9

8

Symbol

EINT1

EINT0

RTC

PLL

SSP/SPI1

SPI0

I2C0

-

Access

RO

RO

RO

RO

RO

RO

RO

RO

Bit

7

6

5

4

3

2

1

0

Symbol

UART1

UART0

TIMER1TIMER0

ARMCore1

ARMCore0-

WDT

Access

RO

RO

RO

RO

RO

RO

RO

RO

Table 25.

IRQ Status register (VICIRQStatus - address 0xFFFF F000) bit description

Bit

SymbolDescription

Reset
value

31:0

See
VICIRQStatus
bit allocationtable.

A bit read as 1 indicates a corresponding interrupt request being enabled,classified as IRQ, and asserted

0UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

27 of 285

UM10161

NXP Semiconductors

Chapter 4: Vectored Interrupt Controller (VIC)

4.8 FIQ Status register (VICFIQStatus - 0xFFFF F004)
This is a read only register. This register reads out the state of those interrupt requests
that are enabled and classified as FIQ. If more than one request is classified as FIQ, theFIQ service routine can read this register to see which request(s) is (are) active.
Table 26. FIQ Status register (VICFIQStatus - address 0xFFFF F004) bit allocation
Reset value: 0x0000 0000
Bit

31

30

29

28

27

26

25

24

Symbol----TIMER3

TIMER2--

Access

RO

RO

RO

RO

RO

RO

RO

RO

Bit

23

22

21

20

19

18

17

16

Symbol

-

-

-

-

I2C1

AD0

-

EINT2

Access

RO

RO

RO

RO

RO

RO

RO

RO

Bit

15

14

13

12

11

10

9

8

Symbol

EINT1

EINT0

RTC

PLL

SSP/SPI1

SPI0

I2C0

-0

Access

RO

RO

RO

RO

RO

RO

RO

RO

Bit

7

6

5

4

3

2

1

0

Symbol

UART1

UART0

TIMER1TIMER0

ARMCore1

ARMCore0-

WDT

Access

RO

RO

RO

RO

RO

RO

RO

RO

Table 27.

FIQ Status register (VICFIQStatus - address 0xFFFF F004) bit description

Bit

SymbolDescription

Reset
value

31:0

See
VICFIQStatus
bit allocationtable.

A bit read as 1 indicates a corresponding interrupt request being enabled,classified as FIQ, and asserted

0

4.9 Vector Control registers 0-15 (VICVectCntl0-15 - 0xFFFF F200-23C)
These are a read/write accessible registers. Each of these registers controls one of the 16
vectored IRQ slots. Slot 0 has the highest priority and slot 15 the lowest. Note that
disabling a vectored IRQ slot in one of the VICVectCntl registers does not disable theinterrupt itself, the interrupt is simply changed to the non-vectored form.
Table 28.

Vector Control registers 0-15 (VICVectCntl0-15 - 0xFFFF F200-23C) bit description

Bit

SymbolDescription

Reset
value

4:0

int_request/
sw_int_assig

The number of the interrupt request or software interrupt assigned to thisvectored 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 theinterrupt request or software interrupt is enabled, classified as IRQ, andasserted.

05

IRQslot_en

When 1, this vectored IRQ slot is enabled, and can produce a unique ISR
address when its assigned interrupt request or software interrupt is enabled,classified as IRQ, and asserted.

0

31:6

-

Reserved, user software should not write ones to reserved bits. The value read NA
from a reserved bit is not defined.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 200828 of 285

UM10161

NXP Semiconductors

Chapter 4: Vectored Interrupt Controller (VIC)4.10 Vector Address registers 0-15 (VICVectAddr0-15 - 0xFFFF F100-13C)
These are a read/write accessible registers. These registers hold the addresses of theInterrupt Service routines (ISRs) for the 16 vectored IRQ slots.
Table 29.

Vector Address registers (VICVectAddr0-15 - addresses 0xFFFF F100-13C) bit description

Bit

SymbolDescription

31:0

IRQ_vector

0x0000 0000
When one or more interrupt request or software interrupt is (are) 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 4–4.10).

Reset value

4.11 Default Vector Address register (VICDefVectAddr - 0xFFFF F034)
This is a read/write accessible register. This register holds the address of the Interrupt
Service routine (ISR) for non-vectored IRQs.
Table 30.

Default Vector Address register (VICDefVectAddr - address 0xFFFF F034) bit description

Bit

SymbolDescription

Reset value

31:0

IRQ_vector

When an IRQ service routine reads the Vector Address register
0x0000 0000
(VICVectAddr), and no IRQ slot responds as described above, this address isreturned.

4.12 Vector Address register (VICVectAddr - 0xFFFF F030)
This is a read/write accessible register. When an IRQ interrupt occurs, the IRQ service
routine can read this register and jump to the value read.
Table 31.

Vector Address register (VICVectAddr - address 0xFFFF F030) bit description

Bit

SymbolDescription

31:0

IRQ_vector

If any of the interrupt requests or software interrupts that are assigned to a
0x0000 0000
vectored IRQ slot is (are) enabled, classified as IRQ, and asserted, readingfrom this register returns the address in the Vector Address Register for thehighest-priority such slot (lowest-numbered) such slot. Otherwise it returns theaddress in the Default Vector Address Register.

Reset value

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.

4.13 Protection Enable register (VICProtection - 0xFFFF F020)
This is a read/write accessible register. It controls access to the VIC registers by software
running in User mode.
Table 32.

Protection Enable register (VICProtection - address 0xFFFF F020) bit description

Bit

SymbolValue

Description

Reset
value

0

VIC_access

0

VIC registers can be accessed in User or privileged mode.

0

1

The VIC registers can only be accessed in 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.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

29 of 285

UM10161

NXP Semiconductors

Chapter 4: Vectored Interrupt Controller (VIC)

5. Interrupt sources
Table 4–33 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.
Table 33.

Connection of interrupt sources to the Vectored Interrupt Controller (VIC)

Block

Flag(s)

VIC Channel # and Hex
Mask

WDT

Watchdog Interrupt (WDINT)

00x0000 0001-

Reserved for Software Interrupts only

1

0x0000 0002

ARM Core

Embedded ICE, DbgCommRx

20x0000 0004

ARM Core

Embedded ICE, DbgCommTX

30x0000 0008

TIMER0Match 0 - 2 (MR0, MR1, MR2)

40x0000 0010

50x0000 0020

60x0000 0040

70x0000 0080

Capture 0 - 2 (CR0, CR1, CR2)TIMER1

Match 0 - 3 (MR0, MR1, MR2, MR3)
Capture 0 - 3 (CR0, CR1, CR2, CR3)

UART0

Rx Line Status (RLS)
Transmit Holding Register Empty (THRE)
Rx Data Available (RDA)
Character Time-out Indicator (CTI)

UART1

Rx Line Status (RLS)
Transmit Holding Register Empty (THRE)
Rx Data Available (RDA)
Character Time-out Indicator (CTI)
Modem Status Interrupt (MSI)-

Reserved

80x0000 0100

I2C0

SI (state change)

90x0000 0200

SPI0

SPI0 Interrupt Flag (SPI0F)

10

0x0000 0400

110x0000 0800

Mode Fault (MODF)
SPI1 (SSP)

TX FIFO at least half empty (TXRIS)
Rx FIFO at least half full (RXRIS)
Receive Timeout condition (RTRIS)
Receive overrun (RORRIS)PLL

PLL Lock (PLOCK)

120x0000 1000

RTC

Counter Increment (RTCCIF)

130x0000 2000

System Control

External Interrupt 0 (EINT0)140x0000 4000

External Interrupt 1 (EINT1)

150x0000 8000

External Interrupt 2 (EINT2)

160x0001 0000

Alarm (RTCALF)

Reserved

170x0002 0000

ADC

A/D Converter 0 end of conversion

18

0x0004 0000

I2C1

SI (state change)

190x0008 0000

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

30 of 285

UM10161

NXP Semiconductors

Chapter 4: Vectored Interrupt Controller (VIC)

Table 33.

Connection of interrupt sources to the Vectored Interrupt Controller (VIC)

Block

Flag(s)

VIC Channel # and Hex
Mask-

Reserved2025

0x0010 0000
0x0200 0000

TIMER2

Match 0 - 2 (MR0, MR1, MR2)26

0x0400 0000

27

0x0800 0000

Capture 0 - 2 (CR0, CR1, CR2)TIMER3

Match 0 - 3 (MR0, MR1, MR2, MR3)

interrupt request, masking and selection
nVICFIQIN
SOFTINTCLEAR[31:0]INTENABLECLEAR[31:0]SOFTINT[31:0]INTENABLE[31:0]

VICINT
SOURCE[31:0]

non-vectored FIQ interrupt logic

FIQSTATUS[31:0]

FIQSTATUS[31:0]nVICFIQ

non-vectored IRQ interrupt logic
IRQSTATUS[31:0]
RAWINTERRUPT[31:0]

vector interrupt 0

IRQSTATUS[31:0]

INTSELECT[31:0]

IRQ

NonVectIRQ

priority 0interrupt priority logic

HARDWARE
PRIORITYLOGIC

VECTIRQ0

SOURCE ENABLE
VECTCNTL[5:0]vector interrupt 1

VECTADDR[31:0]

priority1

IRQ

nVICIRQ

address selectforhighest priority
interrupt

VECTADDR0[31:0]

VECTADDR[31:0]VECTIRQ1
VECTADDR1[31:0]

VICVECTADDROUT[31:0]

priority2
vector interrupt 15

priority15

VECTIRQ15
VECTADDR15[31:0]

DEFAULTVECTADDR[31:0]nVICIRQIN VICVECTADDRIN[31:0]

Fig 7.

Block diagram of the Vectored Interrupt Controller (VIC)

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

31 of 285

UM10161

NXP Semiconductors

Chapter 4: Vectored Interrupt Controller (VIC)

6. Spurious interrupts
Spurious interrupts are possible in the ARM7TDMI based microcontrollers such as the
LPC2101/02/03 due to asynchronous interrupt handling. The asynchronous character ofthe 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 coreactually processes an interrupt, problems may be generated.
Real-life applications may experience the following scenarios:
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 aresult the VIC will return the default interrupt VicDefVectAddr (0xFFFF F034).
This potentially disastrous chain of events can be prevented in two ways:
1. Application code should be set up in a way to prevent the spurious interrupts fromoccurring. Simple guarding of changes to the VIC may not be enough since, forexample, glitches on level sensitive interrupts can also cause spurious interrupts.
2. VIC default handler should be set up and tested properly.

6.1 Details and case studies on spurious interrupts
This chapter contains details that can be obtained from the official ARM website, FAQ
section.
What happens if an interrupt occurs as it is being disabled?
Applies to: ARM7TDMI
If an interrupt is received by the core during execution of an instruction that disables
interrupts, the ARM7 family will still take the interrupt. This occurs for both IRQ and FIQ
interrupts.
For example, consider the following instruction sequence:
MRS r0, cpsr
ORR r0, r0, #I_Bit:OR:F_Bit
MSR cpsr_c, r0;disable IRQ and FIQ interrupts

If an IRQ interrupt is received during execution of the MSR instruction, then the behavior
will be as follows:• The IRQ interrupt is latched.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

32 of 285

UM10161

NXP Semiconductors

Chapter 4: Vectored Interrupt Controller (VIC)• The MSR cpsr, r0 executes to completion setting both the I bit and the F bit in the
CPSR.

• The IRQ interrupt is taken because the core was committed to taking the interrupt
exception before the I bit was set in the CPSR.

• The CPSR (with the I bit and F bit set) is moved to the SPSR_IRQ.
This means that, on entry to the IRQ interrupt service routine, you can see the unusual
effect that an IRQ interrupt has just been taken while the I bit in the SPSR is set. In theexample above, the F bit will also be set in both the CPSR and SPSR. This means that
FIQs are disabled upon entry to the IRQ service routine, and will remain so until explicitly
re-enabled. FIQs will not be reenabled automatically by the IRQ return sequence.
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 notnormally 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:
SUBS pc, lr, #4
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 1: A particular routine maybe called as an IRQ handler, or as a regularsubroutine. In the latter case, the system guarantees that IRQs would have been disabledprior to the routine being called. The routine exploits this restriction to determine how it
was called (by examining the I bit of the SPSR), and returns using the appropriate
instruction. If the routine is entered due to an IRQ being received during execution of the
MSR instruction which disables IRQs, then the I bit in the SPSR will be set. The routine
would therefore assume that it could not have been entered via an IRQ.
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 bedisabled for more than a few cycles.

6.2 Workaround
There are 3 suggested workarounds. Which of these is most applicable will depend upon
the requirements of the particular system.

6.3 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.
SUB
STMFD
MRS
TST
LDMNEFDlr, lr, #4
sp!, {..., lr}
lr, SPSR
lr, #I_Bit
sp!, {..., pc}^

; Adjust LR to point to return; Get some free regs
; See if we got an interrupt while; interrupts were disabled.
; If so, just return immediately.
; The interrupt will remain pending since we haven’t; acknowledged it and will be reissued when interrupts

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

33 of 285

UM10161

NXP Semiconductors

Chapter 4: Vectored Interrupt Controller (VIC); are next enabled.
; Rest of interrupt routineThis 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.
This is the recommended workaround, as it overcomes both problems mentioned above.
However, in the case of problem two, it does add several cycles to the maximum length oftime FIQs will be disabled.

6.4 Solution 2: disable IRQs and FIQs using separate writes to the CPSR
MRS
ORR
MSR
ORR
MSR

r0, cpsr
r0, r0, #I_Bit
cpsr_c, r0
r0, r0, #F_Bit
cpsr_c, r0;disable IRQs
;disable FIQs

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, andrequires extra instructions at every point where IRQs and FIQs are disabled together.

6.5 Solution 3: re-enable FIQs at the beginning of the IRQ handler
As the required state of all bits in the c field of the CPSR are known, this can be mostefficiently be achieved by writing an immediate value to CPSR_C, for example:
MSR cpsr_c, #I_Bit:OR:irq_MODE;IRQ should be disabled;FIQ enabled;ARM state, IRQ modeThis 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 canguarantee that FIQs are never disabled while IRQs are enabled. It does not address
problem one.

7. VIC usage notes
If user code is running from an on-chip RAM and an application uses interrupts, interrupt
vectors must be re-mapped to on-chip address 0x0. This is necessary because all the
exception vectors are located at addresses 0x0 and above. This is easily achieved byconfiguring the MEMMAP register (see Section 5–7.1 “Memory Mapping control register(MEMMAP - 0xE01F C040)” on page 45) to User RAM mode. Application code should belinked such that at 0x4000 0000 the Interrupt Vector Table (IVT) will reside.
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

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

34 of 285

UM10161

NXP Semiconductors

Chapter 4: Vectored Interrupt Controller (VIC)

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 beserviced, it is necessary that write is performed into the VICVectAddr register before thereturn from interrupt is executed. This write will clear the respective interrupt flag in theinternal 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 therespective bits in VICSoftInt. For example, if VICSoftInt = 0x0000 0005 and bit 0 has to becleared, 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 thenthere is no way of clearing the interrupt. The only way you could perform return frominterrupt 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
VICIntEnable = 0x0000 06C0=>
VICDefVectAddr = 0x...
VICVectAddr0 = 0x...
VICVectAddr1 = 0x...
VICVectCntl0 = 0x0000 0026
VICVectCntl1 = 0x0000 002A

; SPI0, I2C0, UART1 and UART0 are IRQ =>; bit10, bit9, bit7 and bit6=0; SPI0, I2C0, UART1 and UART0 are enabled interrupts; bit10, bit9, bit 7 and bit6=1; holds address at what routine for servicing; non-vectored IRQs (i.e. UART1 and I2C) starts; holds address where UART0 IRQ service routine starts; holds address where SPI0 IRQ service routine starts; interrupt source with index 6 (UART0) is enabled as; the one with priority 0 (the highest); 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:
LDR pc, [pc,#-0xFF0]
This instruction loads PC with the address that is present in VICVectAddr register.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

35 of 285

UM10161

NXP Semiconductors

Chapter 4: Vectored Interrupt Controller (VIC)

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. Ifneither UART0 nor SPI0 have generated IRQ request but UART1 and/or I2C were thereason, content of VICVectAddr will be identical to VICDefVectAddr.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

36 of 285

UM10161
Chapter 5: LPC2101/02/03 System control blockRev. 3 — 2 October 2008

User manual

1. Summary of system control block functions
The System control block includes several system features and control registers for anumber of functions that are not related to specific peripheral devices. These include:• Crystal oscillator• External interrupt inputs• Miscellaneous system controls and status• Memory mapping control• PLL• Power control• Reset• APB divider• Wake-up timer
Each type of function has its own register(s) if any are required, and unneeded bits aredefined as reserved in order to allow future expansion. Unrelated functions never sharethe same register addresses

2. Pin description
Table 5–34 shows pins that are associated with System Control block functions.
Table 34.

Pin summary

Pin namePindirection

Pin description

XTAL1

Input

Crystal Oscillator Input - Input to the oscillator and internal clock
generator circuits

XTAL2

OutputCrystal Oscillator Output - Output from the oscillator amplifier

EINT0

Input

External Interrupt Input 0 - An active LOW/HIGH level orfalling/rising edge general purpose interrupt input. This pin may be
used to wake up the processor from Idle or Power-down modes.
Pin P0.16 can be selected to perform EINT0 function.

EINT1

Input

External Interrupt Input 1 - See the EINT0 description above.
Pin P0.14 can be selected to perform EINT1 function.
Important: LOW level on pin P0.14 immediately after reset isconsidered as an external hardware request to start the ISP
command handler. More details on ISP and Serial Boot Loader canbe found in Section 19–4 on page 234.

EINT2

Input

External Interrupt Input 2 - See the EINT0 description above.
Pin P0.15 can be selected to perform EINT2 function.

RESET

Input

External Reset input - A LOW on this pin resets the chip, causing
I/O ports and peripherals to take on their default states, and theprocessor to begin execution at address 0x0000 0000.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

37 of 285

UM10161

NXP Semiconductors

Chapter 5: LPC2101/02/03 System control block

3. Register description
All registers, regardless of size, are on word address boundaries. Details of the registers
appear in the description of each function.
Table 35.

Summary of system control registers

Name

Description

AccessResetvalue[1]Address

External Interrupts
EXTINT

External Interrupt Flag Register

R/W

00xE01F C140

INTWAKEInterrupt Wake-up Register

R/W

00xE01F C144

EXTMODE

External Interrupt Mode Register

R/W

00xE01F C148

EXTPOLAR

External Interrupt Polarity Register

R/W

00xE01F C14C

R/W

00xE01F C040

Memory Mapping Control
MEMMAP

Memory Mapping Control

Phase Locked Loop
PLLCONPLL Control Register

R/W

00xE01F C080

PLLCFGPLL Configuration Register

R/W

00xE01F C084

PLLSTATPLL Status RegisterRO

0

0xE01F C088

PLLFEED

PLL Feed Register

WO

NA

0xE01F C08C

PCON

Power Control Register

R/W

00xE01F C0C0PCONPPower Control for Peripherals

R/W

0x03BE0xE01F C0C4APB Divider Control

R/W

00xE01F C100

Reset Source Identification Register

R/W

00xE01F C180RO

00xE01F C184

R/W

00xE01F C1A0

Power Control

APB Divider
APBDIV
Reset
RSIR

Code Security/Debugging
CSPR

Code Security Protection Register

Syscon Miscellaneous Registers
SCS[1]

System Controls and Status

Reset value reflects the data stored in used bits only. It does not include reserved bits content.

4. Crystal oscillator
The LPC2101/02/03 onboard oscillator circuit supports external crystals in the range of
1 MHz to 25 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 isreferred 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 theSection 5–8 “Phase Locked Loop (PLL)” on page 46 for details and frequency limitations.
The onboard oscillator in the LPC2101/02/03 can operate in one of two modes: slave
mode and oscillation mode.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

38 of 285

UM10161

NXP Semiconductors

Chapter 5: LPC2101/02/03 System control block

In slave mode the input clock signal should be coupled by means of a capacitor of 100 pF(CC in Figure 5–8, drawing a), with an amplitude of at least 200 mVrms. The X2 pin in thisconfiguration 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 5–8,
drawings b and c, and in Table 5–36. Since the feedback resistance is integrated on chip,
only a crystal and the capacitances CX1 and CX2 need to be connected externally in caseof fundamental mode oscillation (the fundamental frequency is represented by L, CL and
RS). Capacitance CP in Figure 5–8, drawing c, represents the parallel package
capacitance and should not be larger than 7 pF. Parameters FC, CL, RS and CP aresupplied by the crystal manufacturer.
Choosing an oscillation mode as an on-board oscillator mode of operation limits FOSC
clock selection to 1 MHz to 30 MHz.

LPC2101/02/03

XTAL1

LPC2101/02/03

XTAL2

XTAL1

XTAL2

L

<=>

CC

CL

CP

Xtal
Clock

a)

Fig 8.

CX2

CX1

RS

b)

c)

Oscillator modes and models: a) slave mode of operation, b) oscillation mode of operation, c) external
crystal model used for CX1/X2 evaluation
Table 36.

Recommended values for CX1/X2 in oscillation mode (crystal and external
components parameters)

Fundamental
Crystal load
oscillation frequency capacitance CL
FOSC

Maximum crystal
series resistance RS

External load
capacitors CX1, CX2

1 MHz - 5 MHz

10 pF

NA

NA

20 pF

NA

NA

30 pF

< 300 Ω58 pF, 58 pF

10 pF< 300 Ω18 pF, 18 pF

20 pF< 300 Ω38 pF, 38 pF

30 pF< 300 Ω58 pF, 58 pF

5 MHz - 10 MHz

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

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

39 of 285

UM10161

NXP Semiconductors

Chapter 5: LPC2101/02/03 System control block

Table 36.

Recommended values for CX1/X2 in oscillation mode (crystal and external
components parameters)

Fundamental
Crystal load
oscillation frequency capacitance CL
FOSC

Maximum crystal
series resistance RS

External load
capacitors CX1, CX2

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

25 MHz - 30 MHz

10 pF< 160 Ω18 pF, 18 pF

20 pF< 90 Ω

38 pF, 38 pF

30 pF< 50 Ω

58 pF, 58 pF

10 pF< 130 Ω18 pF, 18 pF

20 pF< 50 Ω

38 pF, 38 pF

30 pF

NA

NA

f OSC selection

true

on-chip PLL used
in application?
false

true

ISP used for initialcode download?
false
external crystal
oscillator used?

true

false

Fig 9.

MIN fOSC = 10 MHz
MAX fOSC = 25 MHz

MIN fOSC = 1 MHz
MAX fOSC = 50 MHz

MIN fOSC = 1 MHz
MAX fOSC = 30 MHz

mode a and/or bmode amode bFOSC selection algorithm

5. External interrupt inputs
The LPC2101/02/03 includes up to three External Interrupt Inputs as selectable pinfunctions. When the pins are combined, external events can be processed as three
independent interrupt signals. The External Interrupt Inputs can optionally be used towake up the processor from Power-down mode.
Additionally, all 10 capture inputs can also be used as external interrupts without theoption to wake up the device from Power-down mode.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

40 of 285

UM10161

NXP Semiconductors

Chapter 5: LPC2101/02/03 System control block

5.1 Register description
The external interrupt function has four registers associated with it. The EXTINT registercontains the interrupt flags and the EXTWAKE register contains bits that enable individual
external interrupts to wake up the microcontroller from Power-down mode. The
EXTMODE and EXTPOLAR registers specify the level and edge sensitivity parameters.
Table 37.

External interrupt registers

Name

Description

Access Reset
Addressvalue[1]EXTINT

The External Interrupt Flag Register contains
interrupt flags for EINT0, EINT1, EINT2 andEINT3. See Table 5–38.

R/W

00xE01F C140

EXTWAKEThe Interrupt wake-up register contains four
enable bits that control whether each externalinterrupt will cause the processor to wake up
from Power-down mode. See Table 5–39.

R/W

00xE01F C144

EXTMODEThe External Interrupt Mode Register controls
whether each pin is edge- or level sensitive.

R/W

00xE01F C148

EXTPOLAR

The External Interrupt Polarity Register controls R/Wwhich level or edge on each pin will cause aninterrupt.

00xE01F C14C

[1]

Reset value reflects the data stored in used bits only. It does not include reserved bits content.

5.2 External Interrupt Flag register (EXTINT - 0xE01F C140)
When a pin is selected for its external interrupt function, the level or edge on that pin(selected by its bits in the EXTPOLAR and EXTMODE registers) will set its interrupt flag inthis register. This asserts the corresponding interrupt request to the VIC, which will cause
an interrupt if interrupts from the pin are enabled.
Writing ones to bits EINT0 through EINT2 in EXTINT register clears the corresponding
bits. In level-sensitive mode this action is efficacious only when the pin is in its inactive
state.
Once a bit from EINT0 to EINT2 is set and an appropriate code starts to execute (handlingwake-up 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.
Important: whenever a change of external interrupt operating mode (i.e. active
level/edge) is performed (including the initialization of an external interrupt), thecorresponding bit in the EXTINT register must be cleared! For details see Section
5–5.4 “External Interrupt Mode register (EXTMODE - 0xE01F C148)” and Section 5–5.5“External Interrupt Polarity register (EXTPOLAR - 0xE01F C14C)”.
For example, if a system wakes up from power-down using a LOW level on externalinterrupt 0 pin, its post-wake-up code must reset the EINT0 bit in order to allow futureentry 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 power-down mode will be discussed in the following chapters.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

41 of 285

UM10161

NXP Semiconductors

Chapter 5: LPC2101/02/03 System control block

Table 38.

External Interrupt Flag register (EXTINT - address 0xE01F C140) bit description

Bit

SymbolDescription

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.
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.
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.
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).

7:3-

Reserved, user software should not write ones to reserved bits. The value read from a reserved NA
bit is not defined.

5.3 Interrupt Wake-up register (INTWAKE - 0xE01F C144)
Enable bits in the INTWAKE register allow the external interrupts and other sources towake up the processor if it is in Power-down mode. The related EINTn function must be
mapped to the pin in order for the wake-up process to take place. It is not necessary forthe interrupt to be enabled in the Vectored Interrupt Controller for a wake-up to take place.
This arrangement allows additional capabilities, such as having an external interrupt input
wake up the processor from Power-down mode without causing an interrupt (simply
resuming operation), or allowing an interrupt to be enabled during Power-down without
waking the processor up if it is asserted (eliminating the need to disable the interrupt if thewake-up feature is not desirable in the application).
For an external interrupt pin to be a source that would wake up the microcontroller fromPower-down mode, it is also necessary to clear the corresponding bit in the ExternalInterrupt Flag register (see Section 5–5.2 on page 41).
Table 39.

Interrupt Wake-up register (INTWAKE - address 0xE01F C144) bit description

Bit

SymbolDescription

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.

UM10161_3

User manual

Reset
value

© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

42 of 285

UM10161

NXP Semiconductors

Chapter 5: LPC2101/02/03 System control block

Table 39.

Interrupt Wake-up register (INTWAKE - address 0xE01F C144) bit description

Bit

SymbolDescription

Reset
value

2

EXTWAKE2

When one, assertion of EINT2 will wake up the processor from 0
Power-down mode.

14:3

-

Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.

15

RTCWAKE

When one, assertion of an RTC interrupt will wake up theprocessor from Power-down mode.

0

5.4 External Interrupt Mode register (EXTMODE - 0xE01F C148)
The bits in this register select whether each EINT pin is level- or edge-sensitive. Only pinsthat are selected for the EINT function (see Section 7–4 on page 67) and enabled via the
VICIntEnable register (see Section 4–4.4 on page 25) can cause interrupts from theExternal Interrupt function (though of course pins selected for other functions may causeinterrupts from those functions).
Note: Software should only change a bit in this register when its interrupt isdisabled 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 40.

External Interrupt Mode register (EXTMODE - address 0xE01F C148) bit
description

Bit

SymbolValue

0

EXTMODE0 0

1

EXTMODE1 0

1
1
2
7:3

EXTMODE2 0-

Description

Reset
value

Level-sensitivity is selected for EINT0.

0

EINT0 is edge sensitive.
Level-sensitivity is selected for EINT1.

0

EINT1 is edge sensitive.
Level-sensitivity is selected for EINT2.

01

EINT2 is edge sensitive.

-

Reserved, user software should not write ones to reserved
bits. The value read from a reserved bit is not defined.

NA

5.5 External Interrupt Polarity register (EXTPOLAR - 0xE01F C14C)
In level-sensitive mode, the bits in this register select whether the corresponding pin is
high- or low-active. In edge-sensitive mode, they select whether the pin is rising- or
falling-edge sensitive. Only pins that are selected for the EINT function (see Section 7–4
on page 67) and enabled in the VICIntEnable register (see Section 4–4.4 on page 25) cancause interrupts from the External Interrupt function (though of course pins selected forother functions may cause interrupts from those functions).
Note: Software should only change a bit in this register when its interrupt isdisabled 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.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

43 of 285

UM10161

NXP Semiconductors

Chapter 5: LPC2101/02/03 System control block

Table 41.

External Interrupt Polarity register (EXTPOLAR - address 0xE01F C14C) bit
description

Bit

Symbol0

1

2

Description

Reset
value

EXTPOLAR0 0

EINT0 is low-active or falling-edge sensitive (depending on
EXTMODE0).

01

EINT0 is high-active or rising-edge sensitive (depending on
EXTMODE0).

EXTPOLAR1 0

EINT1 is low-active or falling-edge sensitive (depending on
EXTMODE1).

1

EINT1 is high-active or rising-edge sensitive (depending on
EXTMODE1).

EXTPOLAR2 0

EINT2 is low-active or falling-edge sensitive (depending on
EXTMODE2).

1

EINT2 is high-active or rising-edge sensitive (depending on
EXTMODE2).

-

Reserved, user software should not write ones to reserved
bits. The value read from a reserved bit is not defined.

7:3 -

Value

wakeup enable(one bit of EXTWAKE)

APB Bus Data

EINTi

GLITCHFILTER

D

0

0

NA

APB Readof EXTWAKE

EINTi to wakeup
timer1Q

PCLK

interrupt flag(one bit of EXTINT)

EXTPOLARi

1

D

S

S

S
Q

Q
R

EXTMODEiQ

to VIC

R

PCLK

PCLK

APB read of
EXTINTreset
write 1 to EXTINTi(1) See Figure 5–13 “Reset block diagram including the wake-up timer” on page 57

Fig 10. External interrupt logic

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

44 of 285

UM10161

NXP Semiconductors

Chapter 5: LPC2101/02/03 System control block

6. Other system controls
Some aspects of controlling LPC2101/02/03 operation that do not fit into peripheral orother registers are grouped here.

6.1 System Control and Status flags register (SCS - 0xE01F C1A0)
Table 42.

System Control and Status flags register (SCS - address 0xE01F C1A0) bit description

Bit

Symbol0

GPIO0M

31:1

Value

Description

Reset
value

GPIO port 0 mode selection.

00

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 the GPIO
chapter Section 8–4.2 “Fast GPIO port 0 Mask register (FIOMASK, Port 0:
FIO0MASK - 0x3FFF C010)” on page 75.

-

Reserved, user software should not write ones to reserved bits. The value read from NA
a reserved bit is not defined.

7. Memory mapping control
The Memory Mapping Control alters the mapping of the interrupt vectors that appear
beginning at address 0x0000 0000. This allows code running in different memory spaces
to have control of the interrupts.

7.1 Memory Mapping control register (MEMMAP - 0xE01F C040)
Whenever an exception handling is necessary, the microcontroller will fetch an instruction
residing on the exception corresponding address as described in Table 2–3 “ARM
exception vector locations” on page 12. The MEMMAP register determines the source ofdata that will fill this table.
Table 43.

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
Block.

00

01

User Flash Mode. Interrupt vectors are not re-mapped andreside in Flash.

10

User RAM Mode. Interrupt vectors are re-mapped to Static
RAM.

11

Reserved. Do not use this option.

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
bits. The value read from a reserved bit is not defined.

UM10161_3

User manual

NA© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

45 of 285

UM10161

NXP Semiconductors

Chapter 5: LPC2101/02/03 System control block

7.2 Memory mapping control usage notes
The Memory Mapping Control simply selects one out of three available sources of data
(sets of 64 bytes each) necessary for handling ARM exceptions (interrupts).
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–3 “ARM exception vector
locations” on page 12. 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).

8. Phase Locked Loop (PLL)The PLL accepts an input clock frequency in the range of 10 MHz to 25 MHz only. The
input frequency is multiplied up the range of 10 MHz to 60 MHz using a Current Controlled
Oscillators (CCO). The multiplier can be an integer value from 1 to 32 (in practice, themultiplier value cannot be higher than 6 on the LPC2101/02/03 due to the upper
frequency limit of the CPU). The CCO operates in the range of 156 MHz to 320 MHz, so
there is an additional divider in the loop to keep the CCO within its frequency range while
the PLL is providing the desired output frequency. The output divider may be set to divideby 2, 4, 8, or 16 to produce the output clock. Since the minimum output divider value is 2,
it is insured that the PLL output has a 50% duty cycle. A block diagram of the PLL isshown in Figure 5–11.
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 orderto prevent accidental alteration of PLL parameters or deactivation of the PLL. Since allchip operations, including the watchdog timer, are dependent on the PLL when it isproviding the chip clock, accidental changes to the PLL setup could result in unexpectedbehavior of the microcontroller. The protection is accomplished by a feed sequencesimilar 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.

8.1 Register description
The PLL is controlled by the registers shown in Table 5–44. More detailed descriptions
follow.
Warning: Improper setting of the PLL values may result in incorrect operation of thedevice!

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

46 of 285

UM10161

NXP Semiconductors

Chapter 5: LPC2101/02/03 System control block

Table 44.

PLL registers

GenericnameDescription

PLLCONPLL Control Register. Holding register for
R/W
updating PLL control bits. Values written to thisregister do not take effect until a valid PLL feed
sequence has taken place.

00xE01F C080

PLLCFGPLL Configuration Register. Holding register
R/W
for updating PLL configuration values. Values
written to this register do not take effect until avalid PLL feed sequence has taken place.

00xE01F C084

PLLSTATPLL Status Register. Read-back register forRO
PLL control and configuration information. If
PLLCON or PLLCFG have been written to, but
a PLL feed sequence has not yet occurred,
they will not reflect the current PLL state.
Reading this register provides the actual
values controlling the PLL, as well as thestatus of the PLL.

00xE01F C088

PLLFEED

PLL Feed Register. This register enablesloading of the PLL control and configuration
information from the PLLCON and PLLCFG
registers into the shadow registers that
actually affect PLL operation.

NA

0xE01F C08C

[1]

WO

Reset value reflects the data stored in used bits only. It does not include reserved bits content.

UM10161_3

User manual

Access Reset
Addressvalue[1]© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

47 of 285

UM10161

NXP Semiconductors

Chapter 5: LPC2101/02/03 System control block

PLLC
CLOCK
SYNCHRONIZATION0

directPSEL[1:0]
PD

PD

PLLE
0

bypass

FOSC

1
PHASEFREQUENCYDETECTOR

PLOCK

CCO

FCCO

CD

0
/2P

0
0

CCLK

1
1

PD
FOUT

CD
DIV-BY-M
MSEL<4:0>

MSEL[4:0]

Fig 11. PLL block diagram

8.2 PLL Control register (PLLCON - 0xE01F C080)
The PLLCON register contains the bits that enable and connect the PLL. Enabling the
PLL allows it to attempt to lock to the current settings of the multiplier and divider values.
Connecting the PLL causes the processor and all chip functions to run from the PLL
output clock. Changes to the PLLCON register do not take effect until a correct PLL feed
sequence has been given (see Section 5–8.7 “PLL Feed register (PLLFEED 0xE01F C08C)” and Section 5–8.3 “PLL Configuration register (PLLCFG - 0xE01F C084)”
on page 49).

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

48 of 285

UM10161

NXP Semiconductors

Chapter 5: LPC2101/02/03 System control block

Table 45.

PLL Control register (PLLCON - address 0xE01F C080) bit description

Bit

SymbolDescription

Reset
value

0

PLLE

0
PLL Enable. When one, and after a valid PLL feed, this bit will
activate the PLL and allow it to lock to the requested frequency. See
PLLSTAT register, Table 5–47.

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 5–47.

7:2-

Reserved, user software should not write ones to reserved bits. The
value read from a reserved bit is not defined.

NA

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 automaticallydisconnect the PLL if lock is lost during operation. In the event of loss of PLL lock, it islikely that the oscillator clock has become unstable and disconnecting the PLL will not
remedy the situation.

8.3 PLL Configuration register (PLLCFG - 0xE01F C084)
The PLLCFG register contains the PLL multiplier and divider values. Changes to the
PLLCFG register do not take effect until a correct PLL feed sequence has been given (seeSection 5–8.7 “PLL Feed register (PLLFEED - 0xE01F C08C)” on page 51). Calculations
for the PLL frequency, and multiplier and divider values are found in the PLL Frequency
Calculation in Section 5–8.9 “PLL frequency calculation” on page 51.
Table 46.

PLL Configuration register (PLLCFG - address 0xE01F C084) bit description

Bit

SymbolDescription

Reset
value

4:0

MSEL

PLL Multiplier value. Supplies the value "M" in the PLL frequency
calculations.

0Note: For details on selecting the right value for MSEL see Section
5–8.9 “PLL frequency calculation” on page 51.
6:5

PSEL

PLL Divider value. Supplies the value "P" in the PLL frequency
calculations.

0Note: For details on selecting the right value for PSEL see Section
5–8.9 “PLL frequency calculation” on page 51.
7-

Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.

8.4 PLL Status register (PLLSTAT - 0xE01F C088)
The read-only PLLSTAT register provides the actual PLL parameters that are in effect at
the time it is read, as well as the PLL status. PLLSTAT may disagree with values found in
PLLCON and PLLCFG because changes to those registers do not take effect until aproper PLL feed has occurred (see Section 5–8.7 “PLL Feed register (PLLFEED 0xE01F C08C)”).

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 200849 of 285

UM10161

NXP Semiconductors

Chapter 5: LPC2101/02/03 System control block

Table 47.

PLL Status register (PLLSTAT - address 0xE01F C088) bit description

Bit

SymbolDescription

Reset
value

4:0

MSEL

Read-back for the PLL Multiplier value. This is the value currently
used by the PLL.

0

6:5

PSEL

Read-back for the PLL Divider value. This is the value currently
used by the PLL.

0

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.
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.

0

8.5 PLL interrupt
The PLOCK bit in the PLLSTAT register is connected to the interrupt controller. This
allows for software to turn on the PLL and continue with other functions without having to
wait for the PLL to achieve lock. When the interrupt occurs (PLOCK = 1), the PLL may beconnected, and the interrupt disabled. For details on how to enable and disable the PLLinterrupt, see Section 4–4.4 “Interrupt Enable register (VICIntEnable - 0xFFFF F010)” on
page 25 and Section 4–4.5 “Interrupt Enable Clear register (VICIntEnClear 0xFFFF F014)” on page 26.

8.6 PLL modes
The combinations of PLLE and PLLC are shown in Table 5–48.
Table 48.

PLL Control bit combinations

PLLC

PLLE

PLL Function00

PLL is turned off and disconnected. The CCLK equals the unmodified clock
input.

0

1

The PLL is active, but not yet connected. The PLL can be connected after
PLOCK is asserted.

10

Same as 00 combination. This prevents the possibility of the PLL being
connected without also being enabled.

1

1

The PLL is active and has been connected. CCLK/system clock is sourced
from the PLL.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

50 of 285

UM10161

NXP Semiconductors

Chapter 5: LPC2101/02/03 System control block

8.7 PLL Feed register (PLLFEED - 0xE01F C08C)
A correct feed sequence must be written to the PLLFEED register in order for changes to
the PLLCON and PLLCFG registers to take effect. The feed sequence is:
1. Write the value 0xAA to PLLFEED.
2. Write the value 0x55 to PLLFEED.
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 49.

PLL Feed register (PLLFEED - address 0xE01F C08C) bit description

Bit

SymbolDescription

Reset
value

7:0

PLLFEED

The PLL feed sequence must be written to this register in order for
PLL configuration and control register changes to take effect.

0x00

8.8 PLL and Power-down mode
Power-down mode automatically turns off and disconnects activated PLL(s). Wake-up
from Power-down mode does not automatically restore the PLL settings. This must be
done in software. Typically, a routine to activate the PLL, wait for lock, and then connect
the PLL can be called at the beginning of any interrupt service routine that might be called
due to the wake-up. It is important not to attempt to restart the PLL by simply feeding it
when execution resumes after a wake-up from Power-down mode. This would enable andconnect the PLL at the same time, before PLL lock is established.

8.9 PLL frequency calculation
The PLL equations use the following parameters:
Table 50.

Elements determining PLL’s frequency

Element

Description

FOSC

the frequency from the crystal oscillator/external oscillator

FCCO

the frequency of the PLL current controlled oscillator

CCLK

the PLL output frequency (also the processor clock frequency)M

PLL Multiplier value from the MSEL bits in the PLLCFG registerP

PLL Divider value from the PSEL bits in the PLLCFG register

The PLL output frequency (when the PLL is both active and connected) is given by:
CCLK = M × FOSC or CCLK = FCCO / (2 × P)

The CCO frequency can be computed as:
FCCO = CCLK × 2 × P or FCCO = FOSC × M × 2 × P

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

51 of 285

UM10161

NXP Semiconductors

Chapter 5: LPC2101/02/03 System control block

The PLL inputs and settings must meet the following:• FOSC is in the range of 10 MHz to 25 MHz.
• CCLK is in the range of 10 MHz to Fmax (the maximum allowed frequency for the
microcontroller - determined by the system microcontroller is embedded in).

• FCCO is in the range of 156 MHz to 320 MHz.
8.10 Procedure for determining PLL settings
If a particular application uses the PLL, its configuration may be determined as follows:
1. Choose the desired processor operating frequency (CCLK). This may be based onprocessor throughput requirements, need to support a specific set of UART baudrates, etc. Bear in mind that peripheral devices may be running from a lower clock
than the processor (see Section 5–11 “APB divider” on page 58).
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 (seeTable 5–52.
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 oneof 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 5–51).
Table 51.

PLL Divider values

PSEL Bits (PLLCFG bits [6:5])

Value of P

00

1

01

2

10

4

11

8

Table 52.

PLL Multiplier values

MSEL Bits (PLLCFG bits [4:0])

Value of M

00000

1

00001

2

00010

3

00011

4

...

...

11110

31

11111

32

8.11 PLL configuring examples
Example: an application configuring the PLL
System design asks for FOSC= 10 MHz and requires CCLK = 60 MHz.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

52 of 285

UM10161

NXP Semiconductors

Chapter 5: LPC2101/02/03 System control block

Based on these specifications, M = CCLK / Fosc = 60 MHz / 10 MHz = 6. Consequently,
M - 1 = 5 will be written as PLLCFG[4:0].
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 islisted in Table 5–51 is P = 2. Therefore, PLLCFG[6:5] = 1 will be used.

9. Power control
The LPC2101/02/03 supports two reduced power modes: Idle mode and Power-down
mode. In Idle mode, execution of instructions is suspended until either a Reset or interrupt
occurs. Peripheral functions continue operation during Idle mode and may generateinterrupts to cause the processor to resume execution. Idle mode eliminates power usedby the processor itself, memory systems and related controllers, and internal buses.
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 arepreserved 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.
If the RTC is running with its external 32 kHz oscillator at the time of entry into
Power-down mode, operation can resume using an interrupt from the RTC (see Section
18–5.1 “RTC interrupts”).
Entry to Power-down and Idle modes must be coordinated with program execution.
Wake-up from Power-down or Idle modes via an interrupt resumes program execution insuch a way that no instructions are lost, incomplete, or repeated. Wake up fromPower-down mode is discussed further in Section 5–12 “Wake-up timer” on page 59.
A Power Control for Peripherals feature allows individual peripherals to be turned off ifthey are not needed in the application, resulting in additional power savings.

9.1 Register description
The Power Control function contains two registers, as shown in Table 5–53. More detailed
descriptions follow.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

53 of 285

UM10161

NXP Semiconductors

Chapter 5: LPC2101/02/03 System control block

Table 53.

Power control registers

Name

Description

Access Reset
value[1]PCONPower Control Register. This register contains R/Wcontrol bits that enable the two reduced power
operating modes of the microcontroller. See
Table 5–54.

PCONP Power Control for Peripherals Register. This R/Wregister contains control bits that enable anddisable individual peripheral functions,
Allowing elimination of power consumption by
peripherals that are not needed.
[1]

0x00

Address
0xE01F C0C0

0x0018 17BE 0xE01F C0C4

Reset value reflects the data stored in used bits only. It does not include reserved bits content.

9.2 Power Control register (PCON - 0xE01F COCO)
The PCON register contains two bits. Writing a one to the corresponding bit causes entry
to either the Power-down or Idle mode. If both bits are set, Power-down mode is entered.
Table 54.

Power Control register (PCON - address 0xE01F COCO) bit description

Bit

SymbolDescription

Reset
value

0

IDL

Idle mode - when 1, this bit causes the processor clock to be stopped,
while on-chip peripherals remain active. Any enabled interrupt from aperipheral or an external interrupt source will cause the processor toresume execution.

0

1

PD

Power-down mode - when 1, this bit causes the oscillator and all0
on-chip clocks to be stopped. A wake-up condition from an externalinterrupt can cause the oscillator to restart, the PD bit to be cleared, andthe processor to resume execution.

7:2-

Reserved, user software should not write ones to reserved bits. The
value read from a reserved bit is not defined.

NA

9.3 Power Control for Peripherals register (PCONP - 0xE01F COC4)The PCONP register allows turning off selected peripheral functions for the purpose ofsaving power. This is accomplished by gating off the clock source to the specified
peripheral blocks. A few peripheral functions cannot be turned off (i.e. the watchdog timer,
GPIO, the Pin Connect block, and the System Control block). Some peripherals,particularly those that include analog functions, may consume power that is not clock
dependent. These peripherals may contain a separate disable control that turns off
additional circuitry to reduce power. Each bit in PCONP controls one of the peripherals.
The bit numbers correspond to the related peripheral number as shown in the APB
peripheral map Table 2–2 “APB peripheries and base addresses” in Section 2–1 “Memorymaps” on page 8.
If a peripheral control bit is 1, that peripheral is enabled. If a peripheral bit is 0, thatperipheral is disabled to conserve power. For example if bit 19 is 1, the I2C1 interface isenabled. If bit 19 is 0, the I2C1 interface is disabled.
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!
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

54 of 285

UM10161

NXP Semiconductors

Chapter 5: LPC2101/02/03 System control block

Table 55.

Power Control for Peripherals register (PCONP - address 0xE01F C0C4) bit
description

Bit

SymbolDescription

Reset
value

0

-

Reserved, user software should not write ones to reserved bits. The
value read from a reserved bit is not defined.

NA

1

PCTIM0Timer/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

6:5

-

Reserved, user software should not write ones to reserved bits. The
value read from a reserved bit is not defined.

NA

7

PCI2C0The I2C0 interface power/clock control bit.

1

8

PCSPI

The SPI interface power/clock control bit.

1

9

PCRTC

The RTC power/clock control bit.

1

10

PCSPI

The SSP interface power/clock control bit.

1

11

-

Reserved, user software should not write ones to reserved bits. The
value read from a reserved bit is not defined.

NA

12

PCAD

A/D converter 0 (ADC0) power/clock control bit.

1

Note: Clear the PDN bit in the ADCR before clearing this bit, and set
this bit before setting PDN.
18:13

-

Reserved, user software should not write ones to reserved bits. The
value read from a reserved bit is not defined.

NA

19

PCI2C1The I2C1 interface power/clock control bit.

1

21:20

-

Reserved, user software should not write ones to reserved bits. The
value read from a reserved bit is not defined.

NA

22

PCTIM2The Timer/Counter 2 power/clock control bit.

1

23

PCTIM3

The Timer/Counter3 power/clock control bit.

1

31:24

-

Reserved, user software should not write ones to reserved bits. The
value read from a reserved bit is not defined.

NA

9.4 Power control usage notes
After every reset, the PCONP register contains the value that enables all interfaces andperipherals controlled by the PCONP to be enabled. Therefore, apart from proper
configuring via peripheral dedicated registers, the user’s application has no need toaccess the PCONP in order to start using any of the on-board peripherals.
Power saving oriented systems should have 1’s 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.

10. Reset
Reset has two sources on the LPC2101/02/03: 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 wake-up timer (see description in Section 5–12 “Wake-up
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

55 of 285

UM10161

NXP Semiconductors

Chapter 5: LPC2101/02/03 System control block

timer” in this chapter), causing reset to remain asserted until the external Reset isde-asserted, the oscillator is running, a fixed number of clocks have passed, and theon-chip circuitry has completed its initialization. The relationship between Reset, theoscillator, and the wake-up timer are shown in Figure 5–12 . The reset logic is shown in
Figure 5–13.
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 inorder 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 crystal oscillator is already running and stable signal is on the
XTAL1 pin, the RESET pin needs to be asserted for 300 ns only.

VDD(3V3), VDD(1V8) sequencing(no sequencing requirements)[2]oscillator starts
0.5 ms[4]valid clocks

oscillator

VDD(3V3)
3.0 V[3]GND
VDD(1V8)
1.65 V[3]

GND

reset

boot time
reset time[1]clock stability
time4096 clocks

1000
clocksPLL
lock time= 100 μs

SPI
boot
time

jump to user code

processor status002aad483(1) Reset time: The time reset needs to be held LOW. This time depends on system parameters such as VDD(1V8), VDD(3V3)risetime, and the oscillator startup time. There are no restrictions from the microcontroller except that VDD(1V8), VDD(3V3), and theoscillator must be within the specific operating range.
(2) There are no sequencing requirements for VDD(3V3) and VDD(1V8).
(3) When VDD(3V3) 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 12. Startup sequence diagram
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

56 of 285

UM10161

NXP Semiconductors

Chapter 5: LPC2101/02/03 System control block

When the internal Reset is removed, the processor begins executing at address 0, whichis 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.
External and internal Resets have some small differences. An external Reset causes thevalue 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. Pin 26 (RTCK) is examined
during an external Reset (see Section 6–2 on page 62 and Section 7–4 on page 67). Pin
P0.14 (see Section 19–4 on page 234) is examined by the on-chip bootloader when thiscode is executed after every Reset.
It is possible for a chip Reset to occur during a Flash programming or erase operation.
The Flash memory will interrupt the ongoing operation and hold off the completion of
Reset to the CPU until internal Flash high voltages have settled.

external
reset

reset to the
on-chip circuitry

C
Q

watchdog
reset

reset to
PCON.PDS

WAKE-UP TIMER
START

power
down

EINT0 wake-up
EINT1 wake-up
EINT2 wake-up

COUNT 2 nCQoscillator
output (FOSC)

S
write “1”from APBReset
ABP read of
PDBITin PCON

PLL

FOSC
to CPUFig 13. Reset block diagram including the wake-up timer

10.1 Reset Source Identification Register (RSIR - 0xE01F C180)
This register contains one bit for each source of Reset. Writing a 1 to any of these bits
clears the corresponding read-side bit to 0. The interactions among the four sources aredescribed below.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 200857 of 285

UM10161

NXP Semiconductors

Chapter 5: LPC2101/02/03 System control block

Table 56.

Reset Source identification Register (RSIR - address 0xE01F C180) bit description

Bit

Symbol Description

Reset
value

0

POR

Power-On Reset (POR) event sets this bit, and clears all of the other bits see text
in this register. But if another Reset signal (e.g., External Reset) remains
asserted after the POR signal is negated, then its bit is set. This bit is notaffected by any of the other sources of Reset.

1

EXTR

Assertion of the RESET signal sets this bit. This bit is cleared by POR,
but is not affected by WDT reset.

see text

2

WDTR

This bit is set when the watchdog timer times out and the WDTRESET
bit in the Watchdog Mode Register is 1. It is cleared by any of the othersources of Reset.

see text

7:3-

Reserved, user software should not write ones to reserved bits. The
value read from a reserved bit is not defined.

NA

11. APB divider
The APB Divider determines the relationship between the processor clock (CCLK) and theclock used by peripheral devices (PCLK). The APB Divider serves two purposes.
The first is to provides peripherals with desired PCLK via APB bus so that they canoperate 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 notwork since the APB divider control registers reside on the APB bus), the default conditionat reset is for the APB bus to run at one quarter speed.
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 isshown in Figure 5–14. Because the APB Divider is connected to the PLL output, the PLL
remains active (if it was running) during Idle mode.

11.1 Register description
Only one register is used to control the APB Divider.
Table 57.

APB divider register map

Name

Description

APBDIV

Controls the rate of the APB clock in relation to R/W
the processor clock.

[1]

Access Reset
Addressvalue[1]0x00

0xE01F C100

Reset value reflects the data stored in used bits only. It does not include reserved bits content.

11.2 APBDIV register (APBDIV - 0xE01F C100)
The APB Divider register contains two bits, allowing three divider values, as shown in
Table 5–58.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

58 of 285

UM10161

NXP Semiconductors

Chapter 5: LPC2101/02/03 System control block

Table 58.

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).

-

Reserved, user software should not write ones to reserved
bits. The value read from a reserved bit is not defined.

7:2-

crystal oscillator orexternal clock source(FOSC)

NA

processor clock(CCLK)PLL0

APB DIVIDERAPB clock(PCLK)

Fig 14. APB divider connections

12. Wake-up timer
The purpose of the wake-up 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 otherfunctions are turned off during Power-down mode, any wake-up of the processor fromPower-down mode makes use of the wake-up timer.
The wake-up timer monitors the crystal oscillator as the means of checking whether it issafe 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 wake-up timer counts 4096 clocks, then enables the on-chip
circuitry to initialize. When the onboard modules initialization is complete, the processor isreleased to execute instructions if the external Reset has been deasserted. In the casewhere an external clock source is used in the system (as opposed to a crystal connectedto the oscillator pins), the possibility that there could be little or no delay for oscillator
start-up must be considered. The wake-up timer design then ensures that any otherrequired chip functions will be operational prior to the beginning of program execution.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

59 of 285

UM10161

NXP Semiconductors

Chapter 5: LPC2101/02/03 System control block

Any of the various Resets can bring the microcontroller out of Power-down mode, as canthe external interrupts EINT2:0 and the RTC interrupt if the RTC is operating from its own
oscillator on the RTCX1-2 pins. When one of these interrupts is enabled for wake-up andits selected event occurs, an oscillator wake-up cycle is started. The actual interrupt (ifany) occurs after the wake-up timer expires, and is handled by the Vectored Interrupt
Controller.

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 ExternalInterrupt, select the appropriate mode and polarity for the interrupt, and then selectPower-down mode. Upon wake-up software should restore the pin multiplexing to theperipheral function.
To summarize: on the LPC2101/02/03, the wake-up timer enforces a minimum reset
duration based on the crystal oscillator, and is activated whenever there is a wake-up fromPower-down mode or any type of Reset.

13. Code security vs. debugging
Applications in development typically need the debugging and tracing facilities in the
LPC2101/02/03. Later in the life cycle of an application, it may be more important toprotect the application code from observation by hostile or competitive eyes. The CodeRead Protection feature on the LPC2101/02/03 allows an application to control whether it
can be debugged or protected from observation.
Details on the way Code Read Protection works can be found in Section 19–7 “CodeRead Protection (CRP)” on page 240.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

60 of 285

UM10161
Chapter 6: LPC2101/02/03 Pin configurationRev. 3 — 2 October 2008

User manual

37 P0.12/DSR1/MAT1.0/AD0.5

38 P0.25/AD0.6

39 P0.26/AD0.7

40 VDD(3V3)

41 P0.13/DTR1/MAT1.1

42 VDDA

43 VSS

44 P0.14/DCD1/SCK1/EINT1

45 P0.15/RI1/EINT2

46 P0.16/EINT0/MAT0.2

47 P0.17/CAP1.2/SCL1

48 P0.18/CAP1.3/SDA1

1. LPC2101/2102/2103 pinout

P0.19/MAT1.2/MISO1

1

36 P0.11/CTS1/CAP1.1/AD0.4

P0.20/MAT1.3/MOSI1

2

35 P0.10/RTS1/CAP1.0/AD0.3

P0.21/SSEL1/MAT3.0

334 P0.24/AD0.2

VBAT

4

33 P0.23/AD0.1

VDD(1V8)

5

32 P0.22/AD0.0

RST

6

VSS

7

P0.27/TRST/CAP2.0

8

29 P0.8/TXD1/MAT2.1

P0.28/TMS/CAP2.1

9

28 P0.7/SSEL0/MAT2.0

31 VSSA

LPC2101/2102/2103

30 P0.9/RXD1/MAT2.2

P0.29/TCK/CAP2.2 10

27 DBGSEL

P0.6/MOSI0/CAP0.2 24

P0.5/MISO0/MAT0.1 23

P0.4/SCK0/CAP0.1 22

P0.3/SDA0/MAT0.0 21

RTCX1 20

VSS 19P0.2/SCL0/CAP0.0 18

VDD(3V3) 17

P0.31/TDO 16

P0.30/TDI/MAT3.3 15

25 RTCX2
P0.0/TXD0/MAT3.1 13

26 RTCKXTAL2 12
P0.1/RXD0/MAT3.2 14

XTAL1 11002aab821

Fig 15. LQFP48 pin configuration

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

61 of 285

UM10161

NXP Semiconductors

37 P0.12/DSR1/MAT1.0/AD0.5

38 P0.25/AD0.6

39 P0.26/AD0.7

40 VDD(3V3)

41 P0.13/DTR1/MAT1.1

42 VDDA

43 VSS

44 P0.14/DCD1/SCK1/EINT1

45 P0.15/RI1/EINT2

46 P0.16/EINT0/MAT0.2

terminal 1
index area

47 P0.17/CAP1.2/SCL1

48 P0.18/CAP1.3/SDA1

Chapter 6: LPC2101/02/03 Pin configuration

P0.19/MAT1.2/MISO1

1

36 P0.11/CTS1/CAP1.1/AD0.4

P0.20/MAT1.3/MOSI1

2

35 P0.10/RTS1/CAP1.0/AD0.3

P0.21/SSEL1/MAT3.0

334 P0.24/AD0.2

VBAT

4

33 P0.23/AD0.1

VDD(1V8)

5

RST

6

VSS

7

P0.27/TRST/CAP2.0

8

29 P0.8/TXD1/MAT2.1

P0.28/TMS/CAP2.1

9

28 P0.7/SSEL0/MAT2.0

32 P0.22/AD0.0

LPC2102FHN48
LPC2103FHN48

31 VSSA
30 P0.9/RXD1/MAT2.2

P0.29/TCK/CAP2.2 10

27 DBGSEL

P0.6/MOSI0/CAP0.2 24

P0.5/MISO0/MAT0.1 23

P0.4/SCK0/CAP0.1 22

P0.3/SDA0/MAT0.0 21

RTCX1 20

VSS 19P0.2/SCL0/CAP0.0 18

VDD(3V3) 17

P0.31/TDO 16

P0.30/TDI/MAT3.3 15

25 RTCX2
P0.0/TXD0/MAT3.1 13

26 RTCKXTAL2 12
P0.1/RXD0/MAT3.2 14

XTAL1 11002aad918

Transparent top viewFig 16. Pin configuration (HVQFN48)

2. Pin description for LPC2101/02/03
Pin description for LPC2101/02/03 and a brief explanation of corresponding functions areshown in the following table.
Table 59.

Pin description

Symbol

Pin

P0.0 to P0.31

P0.0/TXD0/
MAT3.1

P0.1/RXD0/
MAT3.2

13[1]

14[1]

Type

Description

I/O

Port 0: Port 0 is a 32-bit I/O port with individual direction controls for each bit.
A total of 31 pins of the Port 0 can be used as general purpose bidirectional
digital I/Os while P0.31 is an output only pin. The operation of port 0 pins
depends upon the pin function selected via the pin connect block.

I/O

P0.0 — General purpose input/output digital pin.

O

TXD0 — Transmitter output for UART0.

O

MAT3.1 — PWM output 1 for Timer 3.

I/O

P0.1 — General purpose input/output digital pin.

I

RXD0 — Receiver input for UART0.

O

MAT3.2 — PWM output 2 for Timer 3.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

62 of 285

UM10161

NXP Semiconductors

Chapter 6: LPC2101/02/03 Pin configuration

Table 59.

Pin description …continued

SymbolPin

Type

Description

P0.2/SCL0/CAP0.018[2]I/O

P0.2 — General purpose input/output digital pin. Output is open-drain.

I/O

SCL0 — I2C0 clock Input/output. Open-drain output (for I2C-bus compliance).

P0.3/SDA0/
MAT0.021[2]P0.4/SCK0/CAP0.122[1]P0.5/MISO0/
MAT0.123[1]P0.6/MOSI0/
CAP0.224[1]P0.7/SSEL0/
MAT2.028[1]P0.8/TXD1/
MAT2.129[1]P0.9/RXD1/
MAT2.230[1]P0.10/RTS1/
CAP1.0/AD0.335[3]P0.11/CTS1/
CAP1.1/AD0.4

P0.12/DSR1/
MAT1.0/AD0.5

P0.13/DTR1/
MAT1.1

36[3]

37[3]

41[1]

I

CAP0.0 — Capture input for Timer 0, channel 0.

I/O

P0.3 — General purpose input/output digital pin. Output is open-drain.

I/O

SDA0 — I2C0 data input/output. Open-drain output (for I2C-bus compliance).

O

MAT0.0 — PWM output for Timer 0, channel 0. Output is open-drain.

I/O

P0.4 — General purpose input/output digital pin.

I/O

SCK0 — Serial clock for SPI0. SPI clock output from master or input to slave.

I

CAP0.1 — Capture input for Timer 0, channel 1.

I/O

P0.5 — General purpose input/output digital pin.

I/O

MISO0 — Master In Slave Out for SPI0. Data input to SPI master or data
output from SPI slave.

O

MAT0.1 — PWM output for Timer 0, channel 1.

I/O

P0.6 — General purpose input/output digital pin.

I/O

MOSI0 — Master Out Slave In for SPI0. Data output from SPI master or data
input to SPI slave.

I

CAP0.2 — Capture input for Timer 0, channel 2.

I/O

P0.7 — General purpose input/output digital pin.

I

SSEL0 — Slave Select for SPI0. Selects the SPI interface as a slave.

O

MAT2.0 — PWM output for Timer 2, channel 0.

I/O

P0.8 — General purpose input/output digital pin.

O

TXD1 — Transmitter output for UART1.

O

MAT2.1 — PWM output for Timer 2, channel 1.

I/O

P0.9 — General purpose input/output digital pin.

I

RXD1 — Receiver input for UART1.

O

MAT2.2 — PWM output for Timer 2, channel 2.

I/O

P0.10 — General purpose input/output digital pin.

O

RTS1 — Request to Send output for UART1.

I

CAP1.0 — Capture input for Timer 1, channel 0.

I

AD0.3 — ADC 0, input 3.

I/O

P0.11 — General purpose input/output digital pin.

I

CTS1 — Clear to Send input for UART1.

I

CAP1.1 — Capture input for Timer 1, channel 1.

I

AD0.4 — ADC 0, input 4.

I/O

P0.12 — General purpose input/output digital pin.

I

DSR1 — Data Set Ready input for UART1.

O

MAT1.0 — PWM output for Timer 1, channel 0.

I

AD0.5 — ADC 0, input 5.

I/O

P0.13 — General purpose input/output digital pin.

O

DTR1 — Data Terminal Ready output for UART1.

O

MAT1.1 — PWM output for Timer 1, channel 1.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

63 of 285

UM10161

NXP Semiconductors

Chapter 6: LPC2101/02/03 Pin configuration

Table 59.

Pin description …continued

SymbolPin

Type

Description

P0.14/DCD1/
SCK1/EINT1

44[4]

I/O

P0.14 — General purpose input/output digital pin.

I

DCD1 — Data Carrier Detect input for UART1.

P0.15/RI1/
EINT2

45[4]

P0.16/EINT0/
MAT0.246[4]P0.17/CAP1.2/
SCL1

47[5]

P0.18/CAP1.3/
SDA1

P0.19/MAT1.2/
MISO1

P0.20/MAT1.3/
MOSI1

48[5]

1[1]

2[1]

I/O

SCK1 — Serial Clock for SPI1. SPI clock output from master or input to slave.

I

EINT1 — External interrupt 1 input.

I/O

P0.15 — General purpose input/output digital pin.

I

RI1 — Ring Indicator input for UART1.

I

EINT2 — External interrupt 2 input.

I/O

P0.16 — General purpose input/output digital pin.

I

EINT0 — External interrupt 0 input.

O

MAT0.2 — PWM output for Timer 0, channel 2.

I/O

P0.17 — General purpose input/output digital pin. The output is notopen-drain.

I

CAP1.2 — Capture input for Timer 1, channel 2.

I/O

SCL1 — I2C1 clock Input/output. This pin is an open-drain output if I2C1
function is selected in the pin connect block.

I/O

P0.18 — General purpose input/output digital pin. The output is notopen-drain.

I

CAP1.3 — Capture input for Timer 1, channel 3.

I/O

SDA1 — I2C1 data Input/output. This pin is an open-drain output if I2C1
function is selected in the pin connect block.

I/O

P0.19 — General purpose input/output digital pin.

O

MAT1.2 — PWM output for Timer 1, channel 2.

I/O

MISO1 — Master In Slave Out for SSP. Data input to SSP master or data
output from SSP slave.

I/O

P0.20 — General purpose input/output digital pin.

O

MAT1.3 — PWM output for Timer 1, channel 3.

I/O

MOSI1 — Master Out Slave for SSP. Data output from SSP master or data
input to SSP slave.

I/O

P0.21 — General purpose input/output digital pin.

I

SSEL1 — Slave Select for SPI1. Selects the SPI interface as a slave.

P0.21/SSEL1/
MAT3.03[1]P0.22/AD0.032[3]P0.23/AD0.1

33[3]

I

AD0.1 — ADC 0, input 1.

P0.24/AD0.2

34[3]

I/O

P0.24 — General purpose input/output digital pin.

I

AD0.2 — ADC 0, input 2.

P0.25/AD0.6

38[3]

I/O

P0.25 — General purpose input/output digital pin.

I

AD0.6 — ADC 0, input 6.

P0.26/AD0.7

39[3]

I/O

P0.26 — General purpose input/output digital pin.

I

AD0.7 — ADC 0, input 7.

O

MAT3.0 — PWM output for Timer 3, channel 0.

I/O

P0.22 — General purpose input/output digital pin.

I

AD0.0 — ADC 0, input 0.

I/O

P0.23 — General purpose input/output digital pin.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

64 of 285

UM10161

NXP Semiconductors

Chapter 6: LPC2101/02/03 Pin configuration

Table 59.

Pin description …continued

SymbolPin

Type

Description

P0.27/TRST/
CAP2.08[1]I/O

P0.27 — General purpose input/output digital pin.

I

TRST — Test Reset for JTAG interface.

I

CAP2.0 — Capture input for Timer 2, channel 0.

P0.28/TMS/
CAP2.19[1]I/O

P0.28 — General purpose input/output digital pin.

I

TMS — Test Mode Select for JTAG interface.

I

CAP2.1 — Capture input for Timer 2, channel 1.

P0.29/TCK/
CAP2.210[1]I/O

P0.29 — General purpose input/output digital pin.

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.

I

CAP2.2 — Capture input for Timer 2, channel 2.

P0.30/TDI/
MAT3.315[1]I/O

P0.30 — General purpose input/output digital pin.

I

TDI — Test Data In for JTAG interface.

O

MAT3.3 — PWM output 3 for Timer 3.

P0.31/TDO

16[1]

O

P0.31 — General purpose output only digital pin.

O

TDO — Test Data Out for JTAG interface.

RTCX1

20[6]

I

Input to the RTC oscillator circuit.

RTCX2

25[6]

O

Output from the RTC oscillator circuit.

RTCK

26[6]

I/O

Returned test clock output: Extra signal added to the JTAG port. Assists
debugger synchronization when processor frequency varies. Bidirectional pin
with internal pull-up.

XTAL1

11

I

Input to the oscillator circuit and internal clock generator circuits.

XTAL2

12

O

Output from the oscillator amplifier.

DBGSEL

27

I

Debug select: When LOW, the part operates normally. When HIGH, debug
mode is entered. Input with internal pull-down.

RST

6

I

External reset input: A LOW on this pin resets the device, causing I/O ports
and peripherals to take on their default states and processor execution to
begin at address 0. TTL with hysteresis, 5 V tolerant.

VSS

7, 19, 43I

Ground: 0 V reference.

VSSA

31

I

Analog ground: 0 V reference. This should be nominally the same voltage
as VSS but should be isolated to minimize noise and error.

VDDA

42

I

Analog 3.3 V power supply: This should be nominally the same voltage as
VDD(3V3) but should be isolated to minimize noise and error. The level on thispin also provides a voltage reference level for the ADC.

VDD(1V8)5I

1.8 V core power supply: This is the power supply voltage for internal
circuitry and the on-chip PLL.

VDD(3V3)

17, 40I

3.3 V pad power supply: This is the power supply voltage for the I/O ports.

VBAT

4

I

RTC power supply: 3.3 V on this pin supplies the power to the RTC.

[1]

5 V tolerant pad providing digital I/O functions with TTL levels and hysteresis and 10 ns slew rate control.

[2]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 configuration applies to ALL functions on that pin.

[3]

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 an 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.

[4]

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.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

65 of 285

UM10161

NXP Semiconductors

Chapter 6: LPC2101/02/03 Pin configuration[5]

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 configuration applies only to I2C function on that pin.

[6]

Pad provides special analog functionality.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

66 of 285

UM10161
Chapter 7: Pin connect blockRev. 3 — 2 October 2008

User manual

1. Features
The Pin connect block allows individual pin configuration.

2. Applications
The purpose of the pin connect block is to configure the microcontroller pins to the desired
functions.

3. 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 thepin 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 partial exception from the above rule of exclusion is the case of inputs to the A/D
converter. Regardless of the function that is currently selected for the port pin hosting theA/D input, this A/D input can be read at any time and variations of the voltage level on thispin will be reflected in the A/D readings. However, valid analog reading(s) can be obtained
if and only if the function of an analog input is selected. Only in this case the properinterface circuit is active between the physical pin and the A/D module. In all other cases,a part of digital logic necessary for the digital function to be performed will be active andwill disrupt proper behavior of the A/D.

4. Register description
The Pin Control Module contains 2 registers as shown in Table 7–60 below.
Table 60.

Pin connect block register map
Reset value[1]Address

Pin function select Read/Writeregister 0.

0x0000 0000

0xE002 C000

Pin function select Read/Writeregister 1.

0x0000 0000

0xE002 C004

Name

Description

PINSEL0
PINSEL1[1]

AccessReset value reflects the data stored in used bits only. It does not include reserved bits content.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

67 of 285

UM10161

NXP Semiconductors

Chapter 7: Pin connect block

4.1 Pin function Select register 0 (PINSEL0 - 0xE002 C000)
The PINSEL0 register controls the functions of the pins as per the settings listed inTable 7–63. The direction control bit in the IO0DIR register is effective only when the
GPIO function is selected for a pin. For other functions, direction is controlled
automatically.
Table 61.

Pin function select register 0 (PINSEL0 - 0xE002 C000)

PINSEL0

Pin name

Value

1:0

P0.0

0

3:2

5:4

7:6

9:8

11:10

13:12

15:14

P0.1

P0.2

P0.3

P0.4

P0.5

P0.6

P0.7

Function

Value after
reset

0

GPIO Port 0.0

0

0

1

TXD0 (UART0)1

0

MAT3.1(Timer 3)

1

1

Reserved

00

GPIO Port 0.1

01

RXD0 (UART0)1

0

MAT3.2 (Timer 3)

1

1

Reserved

00

GPIO Port 0.201

SCL0 (I2C0)

1

0

CAP0.0 (Timer 0)

1

1

Reserved

00

GPIO Port 0.3

0

1

SDA0 (I2C0)1

0

MAT0.0 (Timer 0)

1

1

Reserved

00

GPIO Port 0.401

SCK0 (SPI0)

1

0

CAP0.1 (Timer 0)

1

1

Reserved

00

GPIO Port 0.5

01

MISO0 (SPI0)

10

MAT0.1 (Timer 0)

1

1

Reserved

00

GPIO Port 0.6

01

MOSI0 (SPI0)

1

0

CAP0.2 (Timer 0)

1

1

Reserved

00

GPIO Port 0.701

SSEL0 (SPI0)1

0

MAT2.0 (Timer 2)

1

1

Reserved

UM10161_3

User manual

0

0

0

0

0

0

0

© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

68 of 285

UM10161

NXP Semiconductors

Chapter 7: Pin connect block

Table 61.

Pin function select register 0 (PINSEL0 - 0xE002 C000) …continued

PINSEL0

Pin name

Value

17:16

P0.8

0

19:18

21:20

23:22

25:24

27:26

29:28

31:30

P0.9

P0.10

P0.11

P0.12

P0.13

P0.14

P0.15

Function

Value after
reset

0

GPIO Port 0.8

0

0

1

TXD1 (UART1)

1

0

MAT2.1 (Timer 2)

1

1

Reserved

00

GPIO Port 0.9

01

RXD1 (UART1)

1

0

MAT2.2 (Timer 2)

1

1

Reserved

00

GPIO Port 0.10

01

RTS1(UART1)

1

0

CAP1.0 (Timer 1)

1

1

AD0.3

0

0

GPIO Port 0.11

01

CTS1 (UART1)

1

0

CAP1.1 (Timer 1)

1

1

AD0.4

0

0

GPIO Port 0.12

01

DSR1 (UART1)

1

0

MAT1.0 (Timer 1)

1

1

AD0.5

0

0

GPIO Port 0.13

01

Reserved

10

MAT1.1 (Timer 1)

1

1

DTR1 (UART1)00

GPIO Port 0.14

0

1

EINT1

1

0

SCK1 (SSP1)

1

1

DCD1 (UART1)00

GPIO Port 0.15

0

1

EINT2

1

0

Reserved

1

1

RI1 (UART1)

0

0

0

0

0

0

0

4.2 Pin function Select register 1 (PINSEL1 - 0xE002 C004)
The PINSEL1 register controls the functions of the pins as per the settings listed infollowing tables. The direction control bit in the IO0DIR register is effective only when the
GPIO function is selected for a pin. For other functions direction is controlled
automatically.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

69 of 285

UM10161

NXP Semiconductors

Chapter 7: Pin connect block

Table 62.

Pin function select register 1 (PINSEL1 - 0xE002 C004)

PINSEL1

Pin Name

1:0

P0.16

3:2

5:4

7:6

9:8

11:10

13:12

15:14

17:16

19:18

P0.17

P0.18

P0.19

P0.20

P0.21

P0.22

P0.23

P0.24

P0.25

Value

Function

Value after reset
000GPIO Port 0.16

0

1

EINT0

1

0

MAT0.2 (Timer 0)

1

1

Reserved

00

GPIO Port 0.17

01

SCL1 (I2C1)

1

0

CAP1.2 (Timer 1)

1

1

Reserved

00

GPIO Port 0.18

01

SDA1 (I2C1)

1

0

CAP1.3 (Timer 1)

1

1

Reserved

00

GPIO Port 0.19

01

MISO1 (SPI1)

10

MAT1.2 (Timer 1)

1

1

Reserved

00

GPIO Port 0.20

01

MOSI1 (SPI1)

10

MAT1.3 (Timer 1)

1

1

Reserved

00

GPIO Port 0.21

01

SSEL1 (SPI1)

1

0

MAT3.0 (Timer 3)

1

1

Reserved

00

GPIO Port 0.22

01

Reserved

10

Reserved

1

1

AD0.0

0

0

GPIO Port 0.23

01

Reserved

10

Reserved

1

1

AD0.1

0

0

GPIO Port 0.24

01

Reserved

10

Reserved

1

1

AD0.2

0

0

GPIO Port 0.25

01

Reserved

10

Reserved

1

1

AD0.6

UM10161_3

User manual

0

0

0

0

0

0

0

0

0

© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

70 of 285

UM10161

NXP Semiconductors

Chapter 7: Pin connect block

Table 62.

Pin function select register 1 (PINSEL1 - 0xE002 C004) …continued

PINSEL1

Pin Name

Value

21:20

P0.26

0

23:22

25:24

27:26

29:28

31:30

P0.27

P0.28

P0.29

P0.30

P0.31

Function

Value after reset

0

GPIO Port 0.26

0

0

1

Reserved

10

Reserved

1

1

AD0.7

0

0

GPIO Port 0.27

01

TRST (JTAG)

1

0

CAP2.0 (Timer 2)

1

1

Reserved

00

GPIO Port 0.28

01

TMS (JTAG)

1

0

CAP2.1 (Timer 2)

1

1

Reserved

00

GPIO Port 0.29

01

TCK (JTAG)

1

0

CAP2.2 (Timer 2)

1

1

Reserved

00

GPIO Port 0.30

01

TDI (JTAG)

1

0

MAT3.3 (Timer 3)

1

1

Reserved

00

GPIO Port 0.31

01

TDO (JTAG)

1

0

Reserved

1

1

Reserved

0

0

0

0

0

4.3 Pin function select register values
The PINSEL registers control the functions of device pins as shown below. Pairs of bits inthese registers correspond to specific device pins.
Table 63.

Pin function select register bits

PINSEL0 and PINSEL1 Values Function

Value after Reset00

Primary (default) function, typically GPIO
port

00

01

First alternate function

10

Second alternate function

11

Third alternate function

The direction control bit in the IO0DIR register is effective only when the GPIO function is
selected for a pin. For other functions, direction is controlled automatically. Eachderivative 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.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

71 of 285

UM10161
Chapter 8: LPC2101/02/03 General Purpose Input/Output
ports (GPIO)
Rev. 3 — 2 October 2008

User manual

1. Features• Every physical GPIO port is accessible through two independent sets of registers.
One set provides enhanced features and higher speed port access. The other set ofregisters is the legacy group of registers to ensure backward compatibilty to older
NXP LPC2000 devices.

• Enhanced GPIO functions:– GPIO registers are relocated to the ARM local bus to achieve the fastest possible
I/O timing.
– Mask registers allow treating sets of port bits as a group, leaving other bits
unchanged.
– All registers are byte and half-word addressable.
– 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 ofbits in one port.

• Individual bits can be direction controlled.
• All I/O pins default to inputs after reset.
• Backward compatibility with other earlier devices is maintained with legacy registers
appearing at the original addresses on the APB bus.

2. Applications• General purpose I/O• Driving LEDs or other indicators• Controlling off-chip devices• Sensing digital inputs

3. Pin description
Table 64.

GPIO pin description

Pin

Type

Description

P0.0-P0.31

Input/
OutputGeneral purpose input/output. The number of GPIOs actually available depends on theuse of alternate functions.

4. Register description
LPC2101/02/03 has one 32-bit General Purpose I/O port. A total of 32 input/output pins
are available on PORT0. PORT0 is controlled by the registers shown in Table 8–65 andTable 8–66.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

72 of 285

UM10161

NXP Semiconductors

Chapter 8: LPC2101/02/03 General Purpose Input/Output ports (GPIO)

Legacy registers shown in Table 8–65 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 8–66 represent the enhanced GPIO features available on the
LPC2101/02/03. All of these registers are located directly on the local bus of the CPU for
the fastest possible read and write timing and are byte, half-word, and word accessible. A
mask register allows writing to individual pins of the GPIO port without the overhead ofsoftware masking.
The user must select in the System Control and Status flags register (SCS) whether a
GPIO will be accessed via registers that provide enhanced features or a legacy set ofregisters (see Section 5–6.1 “System Control and Status flags register (SCS 0xE01F C1A0)” on page 45). While both of a port’s fast and legacy GPIO registers arecontrolling the same physical pins, these two port control branches are mutually exclusive
and operate independently. For example, changing a pin’s output via a fast register will
not be observable via the corresponding legacy register.
The following text will refer to the legacy GPIO as "the slow" GPIO, while GPIO with theenhanced features selected will be referred to as "the fast" GPIO.
The "slow", legacy registers are word accessible only. The fast GPIO registers are byte,
half-word, and word accessible. In the following two tables, bit 0 corresponds to port0.0,
and bit 31 corresponds to port0.31.
Table 65.

GPIO register map (legacy APB accessible registers)

Generic
Name

Description

IOPIN

GPIO Port Pin value register. The current R/Wstate of the GPIO configured port pins canalways be read from this register,regardless of pin direction.

NA

0xE002 8000
IO0PINIOSETGPIO Port Output Set register. This
R/W
register controls the state of output pins inconjunction with the IOCLR register.
Writing ones produces HIGHs at thecorresponding port pins. Writing zeroes
has no effect.

0x0000 0000

0xE002 8004
IO0SET

IODIRGPIO Port Direction control register. This
register individually controls the directionof each port pin.

R/W

0x0000 0000

0xE002 8008
IO0DIRIOCLRGPIO Port Output Clear register. This
register controls the state of output pins.
Writing ones produces LOW at thecorresponding port pins and clears thecorresponding bits in the IOSET register.
Writing zeroes has no effect.

WO

0x0000 0000

0xE002 800C
IO0CLR[1]

Reset value[1] PORT0
Address &Name

Reset value reflects the data stored in used bits only. It does not include reserved bits content.

UM10161_3

User manual

Acces
s

© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

73 of 285

UM10161

NXP Semiconductors

Chapter 8: LPC2101/02/03 General Purpose Input/Output ports (GPIO)

Table 66.

GPIO register map (local bus accessible registers - enhanced GPIO features)

Generic
Name

Description

FIODIR

Fast GPIO Port Direction control register. R/WThis register individually controls the
direction of each port pin.

0x0000 0000

0x3FFF C000
FIO0DIRFIOMASK

Fast Mask register for port. Writes, sets,
clears, and reads to port (done via writes
to FIOPIN, FIOSET, and FIOCLR, andreads of FIOPIN). Only the bits enabled
by zeroes in this register are altered or
returned.

R/W

0x0000 0000

0x3FFF C010
FIO0MASKFIOPIN

Fast GPIO Port Pin value register using
R/W
FIOMASK. The current state of digital
port pins can be read from this register,regardless of pin direction or alternate
function selection (as long as pins is notconfigured as an input to ADC). The
value read is masked by ANDing withFIOMASK. Writing to this register places
corresponding values in all bits enabled
by zeroes in FIOMASK.

0x0000 0000

0x3FFF C014
FIO0PIN

FIOSET

Fast GPIO Port Output Set register using R/W
FIOMASK. This register controls the stateof output pins. Writing 1s produces HIGH
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 byzeroes in FIOMASK can be altered.

0x0000 0000

0x3FFF C018
FIO0SETFIOCLR

Fast GPIO Port Output Clear register
WO
using FIOMASK. This register controls
the state of output pins. Writing 1s
produces LOW at the corresponding port
pins. Writing 0s has no effect. Only bits
enabled by zeroes in FIOMASK can bealtered.

0x0000 0000

0x3FFF C01CFIO0CLR

Access Reset value[1] PORT0
Address &NameRemark: Bits in the FIOMASK registerare active LOW.

[1]

Reset value reflects the data stored in used bits only. It does not include reserved bits content.

4.1 GPIO port 0 Direction register (IODIR, Port 0: IO0DIR - 0xE002 8008;
FIODIR, Port 0: FIO0DIR - 0x3FFF C000)
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 pinfunctionality.
IO0DIR is the legacy register while the enhanced GPIO functions are supported via the
FIO0DIR register.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

74 of 285

UM10161

NXP Semiconductors

Chapter 8: LPC2101/02/03 General Purpose Input/Output ports (GPIO)

Table 67.

GPIO port 0 Direction register (IO0DIR - address 0xE002 8008) bit description

Bit

Symbol

31:0

P0xDIR

Table 68.

Value Description

Reset value

Slow GPIO Direction control bits. Bit 0 controls P0.0 ... bit 30 controls P0.30.
0Controlled pin is input.

1

Controlled pin is output.

0x0000 0000

Fast GPIO port 0 Direction register (FIO0DIR - address 0x3FFF C000) bit description

Bit

SymbolValue Description

31:0

FP0xDIR

Reset value

Fast GPIO Direction control bits. Bit 0 in FIO0DIR controls P0.0 ... Bit 30 in
FIO0DIR controls P0.30.
0Controlled pin is input.

1

Controlled pin is output.

0x0000 0000

Aside from 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 inTable 8–69. Next to providing the same functions as the FIODIR register, these additional
registers allow easier and faster access to the physical port pins.
Table 69.

Fast GPIO port 0 Direction control byte and half-word accessible register description

Register
nameRegister
Address
length (bits)& access

Description

Reset
value

FIO0DIR0

8 (byte)

0x3FFF C000

Fast GPIO Port 0 Direction control register 0. Bit 0 in FIO0DIR0register corresponds to P0.0 ... bit 7 to P0.7.

0x00

FIO0DIR1

8 (byte)

0x3FFF C001

Fast GPIO Port 0 Direction control register 1. Bit 0 in FIO0DIR1
register corresponds to P0.8 ... bit 7 to P0.15.

0x00

FIO0DIR2

8 (byte)

0x3FFF C002

Fast GPIO Port 0 Direction control register 2. Bit 0 in FIO0DIR2
register corresponds to P0.16 ... bit 7 to P0.23.

0x00

FIO0DIR3

8 (byte)

0x3FFF C003

Fast GPIO Port 0 Direction control register 3. Bit 0 in FIO0DIR3
register corresponds to P0.24 ... bit 7 to P0.31.

0x00

FIO0DIRL

16(half-word)

0x3FFF C000

Fast GPIO Port 0 Direction control Lower half-word register. Bit 0 in
FIO0DIRL register corresponds to P0.0 ... bit 15 to P0.15.

0x0000

FIO0DIRU

16(half-word)

0x3FFF C002

Fast GPIO Port 0 Direction control Upper half-word register. Bit 0 in
FIO0DIRU register corresponds to P0.16 ... bit 15 to P0.31.

0x00004.2 Fast GPIO port 0 Mask register (FIOMASK, Port 0: FIO0MASK 0x3FFF C010)
This register is available in the enhanced group of registers only. It is used to select the
port’s pins that will and will not be affected by a write accesses to the FIOPIN, FIOSET or
FIOCLR register. The mask register also filters out the port’s content when the FIOPIN
register is read.
A zero in this register’s bit enables an access to the corresponding physical pin via a reador 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 8–5 “GPIO usage notes” on page 79

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

75 of 285

UM10161

NXP Semiconductors

Chapter 8: LPC2101/02/03 General Purpose Input/Output ports (GPIO)

Table 70.

Fast GPIO port 0 Mask register (FIO0MASK - address 0x3FFF C010) bit description

Bit

SymbolValue Description

31:0

FP0xMASK

Reset value

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 withthe 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 inTable 8–71. Next to providing the same functions as the FIOMASK register, these
additional registers allow easier and faster access to the physical port pins.
Table 71.

Fast GPIO port 0 Mask byte and half-word accessible register description

Register
nameRegister
Address
length (bits)& access

Description

Reset
value

FIO0MASK0 8 (byte)

0x3FFF C010

Fast GPIO Port 0 Mask register 0. Bit 0 in FIO0MASK0 registercorresponds to P0.0 ... bit 7 to P0.7.

0x00

FIO0MASK1 8 (byte)

0x3FFF C011

Fast GPIO Port 0 Mask register 1. Bit 0 in FIO0MASK1 registercorresponds to P0.8 ... bit 7 to P0.15.

0x00

FIO0MASK2 8 (byte)

0x3FFF C012

Fast GPIO Port 0 Mask register 2. Bit 0 in FIO0MASK2 registercorresponds to P0.16 ... bit 7 to P0.23.

0x00

FIO0MASK3 8 (byte)

0x3FFF C013

Fast GPIO Port 0 Mask register 3. Bit 0 in FIO0MASK3 registercorresponds to P0.24 ... bit 7 to P0.31.

0x00

FIO0MASKL 16(half-word)

0x3FFF C001

Fast GPIO Port 0 Mask Lower half-word register. Bit 0 in
FIO0MASKL register corresponds to P0.0 ... bit 15 to P0.15.

0x0000

FIO0MASKU 16(half-word)

0x3FFF C012

Fast GPIO Port 0 Mask Upper half-word register. Bit 0 in
FIO0MASKU register corresponds to P0.16 ... bit 15 to P0.31.

0x00004.3 GPIO port 0 Pin value register (IOPIN, Port 0: IO0PIN - 0xE002 8000;
FIOPIN, Port 0: FIO0PIN - 0x3FFF C014)
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 or 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 IOPIN register.
If a pin has an analog function as one of its options, the pin state cannot be read if theanalog configuration is selected. Selecting the pin as an A/D input disconnects the digitalfeatures 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 theneed to use both the IOSET and IOCLR registers to obtain the entire written value. Thisfeature should be used carefully in an application since it affects the entire port.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

76 of 285

UM10161

NXP Semiconductors

Chapter 8: LPC2101/02/03 General Purpose Input/Output ports (GPIO)

The legacy register is the IO0PIN, while the enhanced GPIOs are supported via the
FIO0PIN register. Access to a port pins via the FIOPIN register is conditioned by thecorresponding FIOMASK register (see Section 8–4.2 “Fast GPIO port 0 Mask register(FIOMASK, Port 0: FIO0MASK - 0x3FFF C010)”).
Only pins masked with zeros in the Mask register (see Section 8–4.2 “Fast GPIO port 0
Mask register (FIOMASK, Port 0: FIO0MASK - 0x3FFF C010)”) will be correlated to thecurrent content of the Fast GPIO port pin value register.
Table 72.

GPIO port 0 Pin value register (IO0PIN - address 0xE002 8000) bit description

Bit

SymbolDescription

Reset value

31:0

P0xVAL

Slow GPIO pin value bits. Bit 0 in IO0PIN corresponds to P0.0 ... Bit 31 in IO0PIN
corresponds to P0.31.

NA

Table 73.

Fast GPIO port 0 Pin value register (FIO0PIN - address 0x3FFF C014) bit description

Bit

SymbolDescription

Reset value

31:0

FP0xVAL

Fast GPIO pin value bits. Bit 0 in FIO0PIN corresponds to P0.0 ... Bit 31 in FIO0PIN
corresponds to P0.31.

NA

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 inTable 8–74. Next to providing the same functions as the FIOPIN register, these additional
registers allow easier and faster access to the physical port pins.
Table 74.

Fast GPIO port 0 Pin value byte and half-word accessible register description

Register
nameRegister
Address
length (bits)& access

Description

Reset
value

FIO0PIN0

8 (byte)

0x3FFF C014

Fast GPIO Port 0 Pin value register 0. Bit 0 in FIO0PIN0 registercorresponds to P0.0 ... bit 7 to P0.7.

0x00

FIO0PIN1

8 (byte)

0x3FFF C015

Fast GPIO Port 0 Pin value register 1. Bit 0 in FIO0PIN1 registercorresponds to P0.8 ... bit 7 to P0.15.

0x00

FIO0PIN2

8 (byte)

0x3FFF C016

Fast GPIO Port 0 Pin value register 2. Bit 0 in FIO0PIN2 registercorresponds to P0.16 ... bit 7 to P0.23.

0x00

FIO0PIN3

8 (byte)

0x3FFF C017

Fast GPIO Port 0 Pin value register 3. Bit 0 in FIO0PIN3 registercorresponds to P0.24 ... bit 7 to P0.31.

0x00

FIO0PINL

16(half-word)

0x3FFF C014

Fast GPIO Port 0 Pin value Lower half-word register. Bit 0 in
FIO0PINL register corresponds to P0.0 ... bit 15 to P0.15.

0x0000

FIO0PINU

16(half-word)

0x3FFF C016

Fast GPIO Port 0 Pin value Upper half-word register. Bit 0 in
FIO0PINU register corresponds to P0.16 ... bit 15 to P0.31.

0x0000

4.4 GPIO port 0 output Set register (IOSET, Port 0: IO0SET - 0xE002 8004;
FIOSET, Port 0: FIO0SET - 0x3FFF C018)
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 theeffect of any outside world influence on the I/O pins.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

77 of 285

UM10161

NXP Semiconductors

Chapter 8: LPC2101/02/03 General Purpose Input/Output ports (GPIO)IO0SET is the legacy register while the enhanced GPIOs are supported via the FIO0SET
register. Access to a port pins via the FIOSET register is conditioned by the corresponding
FIOMASK register (see Section 8–4.2 “Fast GPIO port 0 Mask register (FIOMASK, Port 0:
FIO0MASK - 0x3FFF C010)”).
Table 75.

GPIO port 0 output Set register (IO0SET - address 0xE002 8004 bit description

Bit

SymbolDescription

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 76.

Reset value

Fast GPIO port 0 output Set register (FIO0SET - address 0x3FFF C018) bit description

Bit

SymbolDescription

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.

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 inTable 8–77. Next to providing the same functions as the FIOSET register, these additional
registers allow easier and faster access to the physical port pins.
Table 77.

Fast GPIO port 0 output Set byte and half-word accessible register description

Register
nameRegister
Address
length (bits)& access

Description

Reset
value

FIO0SET08 (byte)

0x3FFF C018

Fast GPIO Port 0 output Set register 0. Bit 0 in FIO0SET0 registercorresponds to P0.0 ... bit 7 to P0.7.

0x00

FIO0SET1

8 (byte)

0x3FFF C019

Fast GPIO Port 0 output Set register 1. Bit 0 in FIO0SET1 registercorresponds to P0.8 ... bit 7 to P0.15.

0x00

FIO0SET2

8 (byte)

0x3FFF C01A Fast GPIO Port 0 output Set register 2. Bit 0 in FIO0SET2 registercorresponds to P0.16 ... bit 7 to P0.23.

0x00

FIO0SET3

8 (byte)

0x3FFF C01B Fast GPIO Port 0 output Set register 3. Bit 0 in FIO0SET3 registercorresponds to P0.24 ... bit 7 to P0.31.

0x00

FIO0SETL

16(half-word)

0x3FFF C018

Fast GPIO Port 0 output Set Lower half-word register. Bit 0 in
FIO0SETL register corresponds to P0.0 ... bit 15 to P0.15.

0x0000

FIO0SETU

16(half-word)

0x3FFF C01A Fast GPIO Port 0 output Set Upper half-word register. Bit 0 in
FIO0SETU register corresponds to P0.16 ... bit 15 to P0.31.

0x0000

4.5 GPIO port 0 output Clear register (IOCLR, Port 0: IO0CLR 0xE002 800C; FIOCLR, Port 0: FIO0CLR - 0x3FFF C01C)
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.
IO0CLR is the legacy register while the enhanced GPIOs are supported via the FIO0CLR
register. Access to a port pins via the FIOCLR register is conditioned by the corresponding
FIOMASK register (see Section 8–4.2 “Fast GPIO port 0 Mask register (FIOMASK, Port 0:
FIO0MASK - 0x3FFF C010)”).

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

78 of 285

UM10161

NXP Semiconductors

Chapter 8: LPC2101/02/03 General Purpose Input/Output ports (GPIO)

Table 78.

GPIO port 0 output Clear register 0 (IO0CLR - address 0xE002 800C) bit description

Bit

SymbolDescription

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 79.

Reset value

Fast GPIO port 0 output Clear register 0 (FIO0CLR - address 0x3FFF C01C) bit description

Bit

SymbolDescription

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.

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 inTable 8–80. Next to providing the same functions as the FIOCLR register, these additional
registers allow easier and faster access to the physical port pins.
Table 80.

Fast GPIO port 0 output Clear byte and half-word accessible register description

Register
nameRegister
Address
length (bits)& access

Description

Reset
value

FIO0CLR08 (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.

FIO0CLR28 (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.

FIO0CLR38 (byte)

0x3FFF C01F

FIO0CLRL

16(half-word)

0x3FFF C01C Fast GPIO Port 0 output Clear Lower half-word register. Bit 0 in
FIO0CLRL register corresponds to P0.0 ... bit 15 to P0.15.

0x0000

FIO0CLRU

16(half-word)

0x3FFF C01E Fast GPIO Port 0 output Clear Upper half-word register. Bit 0 in
FIO0SETU register corresponds to P0.16 ... bit 15 to P0.31.

0x0000

Fast GPIO Port 0 output Clear register 3. Bit 0 in FIO0CLR3 register 0x00
corresponds to P0.24 ... bit 7 to P0.31.

5. GPIO usage notes
5.1 Example 1: sequential accesses to IOSET and IOCLR affecting thesame GPIO pin/bit
State of the output configured GPIO pin is determined by writes into the pin’s port IOSET
and IOCLR registers. Last of these accesses to the IOSET/IOCLR register will determine
the final output of a pin.
In case of a code:
IO0DIR = 0x0000 0080 ;pin P0.7 configured as output
IO0CLR = 0x0000 0080 ;P0.7 goes LOW
IO0SET = 0x0000 0080 ;P0.7 goes HIGH
IO0CLR = 0x0000 0080 ;P0.7 goes LOW
pin P0.7 is configured as an output (write to IO0DIR register). After this, P0.7 output is set
to LOW (first write to IO0CLR register). Short high pulse follows on P0.7 (write access to
IO0SET), and the final write to IO0CLR register sets pin P0.7 back to LOW level.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

79 of 285

UM10161

NXP Semiconductors

Chapter 8: LPC2101/02/03 General Purpose Input/Output ports (GPIO)

5.2 Example 2: an immediate output of 0s and 1s on a GPIO port
Write access to port’s IOSET followed by write to the IOCLR register results with pins
outputting 0s being slightly later then pins outputting 1s. There are systems that cantolerate this delay of a valid output, but for some applications simultaneous output of abinary 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]:
IO0PIN = (IO0PIN && 0xFFFF00FF) || 0x0000A500
The same outcome can be obtained using the fast port access.
Solution 1: using 32-bit (word) accessible fast GPIO registers
FIO0MASK = 0xFFFF00FF;
FIO0PIN = 0x0000A500;
Solution 2: using 16-bit (half-word) accessible fast GPIO registers
FIO0MASKL = 0x00FF;
FIO0PINL = 0xA500;
Solution 3: using 8-bit (byte) accessible fast GPIO registers
FIO0PIN1 = 0xA5;

5.3 Writing to IOSET/IOCLR vs. IOPIN
Write to the IOSET/IOCLR register allows easy change of the port’s selected output pin(s)to HIGH/LOW level at a time. Only pin/bit(s) in the IOSET/IOCLR written with 1 will be set
to HIGH/LOW level, while those written as 0 will remain unaffected. However, by justwriting to either IOSET or IOCLR register it is not possible to instantaneously output
arbitrary binary data containing mixture of 0s and 1s on a GPIO port.
Write to the IOPIN register enables instantaneous output of a desired content on theparallel 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, application must logically AND readout from the IOPIN with mask containing
0s in bits corresponding to pins that will be changed, and 1s for all others. Finally, thisresult 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
preserving all other PORT0 output pins as they were before.

5.4 Output signal frequency considerations when using the legacy andenhanced GPIO registers
The enhanced features of the fast GPIO ports available on this microcontroller make
GPIO pins more responsive to the code that has task of controlling them. In particular,software access to a GPIO pin is 3.5 times faster via the fast GPIO registers than it iswhen the legacy set of registers is used. As a result of the access speed increase, theUM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

80 of 285

UM10161

NXP Semiconductors

Chapter 8: LPC2101/02/03 General Purpose Input/Output ports (GPIO)

maximum output frequency of the digital pin is increased 3.5 times, too. This tremendous
increase of the output frequency is not always that visible when a plain C code is used. To
gain full benefit from the fast GPIO features, write the portion of the application handlingthe fast port output in assembly code and execute in the ARM mode.
The following example shows a code in which the pin control section is written inassembly language for ARM. First, port 0 is configured as slow port, and the program
generates two pulses on P0.20. Then port 0 is configured as fast port, and two pulses are
generated on P0.16. This illustrates the difference between the fast and slow GPIO port
output capabilities. Once this code is compiled in the ARM mode, its execution from theon-chip Flash will yield the best results when the MAM module is configured as describedin Section 3–9 “MAM usage notes” on page 20. Execution from the on-chip SRAM isindependent from the MAM setup.

ldr
mov
str
ldr
ldr
str
ldr
ldr
ldr
str
str
str
str
ldr
mov
str
ldr
ldr
str
ldr
ldr
ldr
str
str
str
str
loop: b/*set port 0 to slow GPIO */r0,=0xe01fc1a0 /*register address--SCS register*/
r1,#0x0/*set bit 0 to 0*/
r1,[r0]/*enable slow port*/
r1,=0xffffffff /* */r0,=0xe0028008 /*register address--IODIR*/r1,[r0]/*set port 0 to output*/r2,=0x00100000 /*select P0.20*/
r0,=0xe0028004 /*register address--IOSET*/
r1,=0xe002800C /*register address--IOCLR*//*generate 2 pulses using slow GPIO on P0.20*/
r2,[r0]/*HIGH*/r2,[r1]/*LOW*/
r2,[r0]/*HIGH*/r2,[r1]/*LOW*//*set port 0 to fast GPIO */r0,=0xe01fc1a0 /*register address--enable fast port*/
r1,#0x1
r1,[r0]/*enable fast port0*/
r1,=0xffffffff
r0,=0x3fffc000 /*direction of fast port0*/
r1,[r0]r0,=0x3fffc018 /*FIO0SET -- fast port0 register*/
r1,=0x3fffc01c /*FIO0CLR0 -- fast port0 register*/r2,=0x00010000 /*select fast port 0.16 for toggle*//*generate 2 pulses on the fast port*/
r2,[r0]r2,[r1]
r2,[r0]r2,[r1]loop

Figure 8–17 illustrates the code from above executed from the LPC2101/02/03 Flashmemory. The PLL generated FCCLK =60 MHz out of external FOSC = 12 MHz. The MAM
was fully enabled with MEMCR = 2 and MEMTIM = 3, and APBDIV = 1 (PCLK = CCLK).

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

81 of 285

UM10161

NXP Semiconductors

Chapter 8: LPC2101/02/03 General Purpose Input/Output ports (GPIO)

Fig 17. Illustration of the fast and slow GPIO access and output showing 3.5 x increase of the pin output
frequency

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

82 of 285

UM10161
Chapter 9: LPC2101/02/03 Universal Asynchronous
Receiver/Transmitter 0 (UART0)
Rev. 3 — 2 October 2008

User manual

1. 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

2. Pin description
Table 81:

UART0 pin description

Pin

Type

Description

RXD0

Input

Serial Input. Serial receive data.

TXD0

OutputSerial Output. Serial transmit data.

3. Register description
UART0 contains registers organized as shown in Table 9–82. The Divisor Latch AccessBit (DLAB) is contained in U0LCR[7] and enables access to the Divisor Latches.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

83 of 285

xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxx x x x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xx xx xxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx x xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx xxx
UART0 register map

Name

Description

Bit functions and addresses
MSB
BIT7

LSB
BIT6

BIT5

BIT4

BIT3

BIT2

BIT1

Access Reset
Addressvalue[1]BIT08-bit Read Data

RONA

0xE000 C000
(DLAB=0)U0THR

Transmit Holding
Register

8-bit Write Data

WO

NA

0xE000 C000
(DLAB=0)U0DLL

Divisor Latch LSB

8-bit Data

R/W

0x01

0xE000 C000
(DLAB=1)

U0DLM

Divisor Latch MSB

8-bit Data

R/W

0x00

0xE000 C004
(DLAB=1)

U0IER

Interrupt Enable
Register

-

-

-

-

-

En.ABTO En.ABEO R/W

0x00

-

-

-

-

-

0xE000 C004
(DLAB=0)Interrupt ID Reg.

-

-

-

-

-

-

0x01

0xE000 C008

FIFOs Enabled

-

-

IIR3

IIR2

IIR1

IIR0

RX Trigger

-

-

-

TX FIFOReset

RX FIFOReset

FIFO
EnableWO

0x00

0xE000 C008

Word Length Select R/W

0x00

0xE000 C00C

RO

0x60

0xE000 C014

R/W

0x00

0xE000 C01C

R/W

0x00

0xE000 C020

0x10

0xE000 C028

0x80

0xE000 C030

U0IIR

En.RX
EnableEn.RX
Lin.St.Int THRE Int Dat.Av.Int
ABTO Int ABEO Int RO

U0FCR

FIFO Control
Register

U0LCR

Line Control
Register

DLAB

Set
Break

Stick
ParityEven
Par.Selct.

ParityEnableNo. ofStop Bits

U0LSRLine Status
Register

RX FIFO
Error

TEMT

THRE

BI

FE

PE

U0SCR

Scratch Pad Reg.

U0ACR

Auto-baud Control
RegisterU0FDR

Fractional Divider
Register

U0TER

TX. Enable Reg.

84 of 285

© NXP B.V. 2008. All rights reserved.

[1]

OE

DR

8-bit Data
-

-

-

-

-

-

-

-

-

ABTO
Int.Clr

ABEO
Int.Clr--

Aut.Rstrt.

Mode

Start

Reserved[31:8]
MulValTXEN-

DivAddVal
-

-

-

-

-

Reset value reflects the data stored in used bits only. It does not include reserved bits content.

-

R/W

UM10161

Receiver Buffer
Register

Chapter 9: LPC2101/02/03 Universal Asynchronous

Rev. 3 — 2 October 2008

U0RBR

-

NXP Semiconductors

UM10161_3

User manual

Table 82:

UM10161

NXP Semiconductors

Chapter 9: LPC2101/02/03 Universal Asynchronous

3.1 UART0 Receiver Buffer register (U0RBR - 0xE000 C000, when
DLAB = 0, Read Only)
The U0RBR is the top byte of the UART0 Rx FIFO. The top byte of the Rx FIFO contains
the oldest character received and can be read via the bus interface. The LSB (bit 0)
represents the “oldest” received data bit. If the character received is less than 8 bits, theunused MSBs are padded with zeroes.
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 thevalid 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 83:

UART0 Receiver Buffer Register (U0RBR - address 0xE000 C000, when DLAB = 0,
Read Only) bit description

Bit

SymbolDescription

Reset value

7:0

RBR

The UART0 Receiver Buffer Register contains the oldest
received byte in the UART0 Rx FIFO.

undefined

3.2 UART0 Transmit Holding Register (U0THR - 0xE000 C000, when
DLAB = 0, Write Only)
The U0THR is the top byte of the UART0 TX FIFO. The top byte is the newest character in
the TX FIFO and can be written via the bus interface. The LSB represents the first bit totransmit.
The Divisor Latch Access Bit (DLAB) in U0LCR must be zero in order to access the
U0THR. The U0THR is always Write Only.
Table 84:

UART0 Transmit Holding Register (U0THR - address 0xE000 C000, when
DLAB = 0, Write Only) bit description

Bit

SymbolDescription

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 isavailable.

3.3 UART0 Divisor Latch registers (U0DLL - 0xE000 C000 and U0DLM 0xE000 C004, when DLAB = 1)
The UART0 Divisor Latch is part of the UART0 Fractional Baud Rate Generator and holds
the value used to divide the clock supplied by the fractional prescaler in order to produce
the baud rate clock, which must be 16x the desired baud rate (Equation 9–1). The U0DLL
and U0DLM registers together form a 16 bit divisor where U0DLL contains the lower 8 bitsof the divisor and U0DLM contains the higher 8 bits of the divisor. A 0x0000 value istreated 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.
Details on how to select the right value for U0DLL and U0DLM can be found later on inthis chapter.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

85 of 285

UM10161

NXP Semiconductors

Chapter 9: LPC2101/02/03 Universal Asynchronous

Table 85:

UART0 Divisor Latch LSB register (U0DLL - address 0xE000 C000, when
DLAB = 1) bit description

Bit

SymbolDescription

Reset value

7:0

DLL

The UART0 Divisor Latch LSB Register, along with the U0DLM
register, determines the baud rate of the UART0.

0x01

Table 86:

UART0 Divisor Latch MSB register (U0DLM - address 0xE000 C004, when
DLAB = 1) bit description

Bit

SymbolDescription

Reset value

7:0

DLM

The UART0 Divisor Latch MSB Register, along with the U0DLL
register, determines the baud rate of the UART0.

0x00

3.4 UART0 Fractional Divider Register (U0FDR - 0xE000 C028)
The UART0 Fractional Divider Register (U0FDR) controls the clock pre-scaler for thebaud rate generation and can be read and written at the user’s discretion. This pre-scaler
takes the APB clock and generates an output clock according to the specified fractional
requirements.
Important: If the fractional divider is active (DIVADDVAL > 0) and DLM = 0, the value of
the DLL register must be 3 or greater.
Table 87:

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 00, 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 isused 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 ofthe 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.
The UART0 baudrate can be calculated as (n = 0):
(1)

PCLK
UARTn baudrate = ---------------------------------------------------------------------------------------------------------------------------------DivAddVal
16 × ( 256 × UnDLM + UnDLL ) × ⎛⎝ 1 + -----------------------------⎞⎠
MulValWhere PCLK is the peripheral clock, U0DLM and U0DLL are the standard UART0 baudrate divider registers, and DIVADDVAL and MULVAL are UART0 fractional baudrate
generator specific parameters.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

86 of 285

UM10161

NXP Semiconductors

Chapter 9: LPC2101/02/03 Universal Asynchronous

The value of MULVAL and DIVADDVAL should comply to the following conditions:
1. 0 < MULVAL ≤ 15
2. 0 ≤ DIVADDVAL < 15
3. DIVADDVAL<MULVALThe 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.

3.4.1 Baudrate calculation
UART can operate with or without using the Fractional Divider. In real-life applications it islikely that the desired baudrate can be achieved using several different Fractional Divider
settings. The following algorithm illustrates one way of finding a set of DLM, DLL,MULVAL, and DIVADDVAL values. Such set of parameters yields a baudrate with arelative error of less than 1.1% from the desired one.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

87 of 285

UM10161

NXP Semiconductors

Chapter 9: LPC2101/02/03 Universal Asynchronous

Calculating UART
baudrate (BR)

PCLK,
BR

DL est = PCLK/(16 x BR)

DL est is an
integer?

True

False

DIVADDVAL = 0
MULVAL = 1

FR est = 1.5

Pick another FR est fromthe range [1.1, 1.9]

DL est = Int(PCLK/(16 x BR x FR est))

FR est = PCLK/(16 x BR x DL est)

False
1.1 < FR est < 1.9?

True

DIVADDVAL = table(FR est )MULVAL = table(FR est )DLM = DL est[15:8]
DLL = DL est [7:0]End

Fig 18. Algorithm for setting UART dividers

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

88 of 285

UM10161

NXP Semiconductors

Chapter 9: LPC2101/02/03 Universal Asynchronous

Table 88.

3.4.1.1

Fractional Divider setting look-up table

FR

DivAddVal/
MulValFR

DivAddVal/
MulValFR

DivAddVal/
MulValFR

DivAddVal/
MulVal

1.000

0/1

1.250

1/4

1.500

1/2

1.750

3/4

1.067

1/15

1.267

4/15

1.533

8/15

1.769

10/13

1.071

1/14

1.273

3/11

1.538

7/13

1.778

7/9

1.077

1/13

1.286

2/7

1.545

6/11

1.786

11/14

1.083

1/12

1.300

3/10

1.556

5/9

1.800

4/5

1.091

1/11

1.308

4/13

1.571

4/7

1.818

9/11

1.100

1/10

1.333

1/3

1.583

7/12

1.833

5/6

1.111

1/9

1.357

5/14

1.600

3/5

1.846

11/13

1.125

1/8

1.364

4/11

1.615

8/13

1.857

6/7

1.133

2/15

1.375

3/8

1.625

5/8

1.867

13/15

1.143

1/7

1.385

5/13

1.636

7/11

1.875

7/8

1.154

2/13

1.400

2/5

1.643

9/14

1.889

8/9

1.167

1/6

1.417

5/12

1.667

2/3

1.900

9/10

1.182

2/11

1.429

3/7

1.692

9/13

1.909

10/11

1.200

1/5

1.444

4/9

1.700

7/10

1.917

11/12

1.214

3/14

1.455

5/11

1.714

5/7

1.923

12/13

1.222

2/9

1.462

6/13

1.727

8/11

1.929

13/14

1.231

3/13

1.467

7/15

1.733

11/15

1.933

14/15

Example 1: PCLK = 14.7456 MHz, BR = 9600
According to the the provided algorithm DLest = PCLK/(16 x BR) = 14.7456 MHz / (16 x
9600) = 96. Since this DLest is an integer number, DIVADDVAL = 0, MULVAL = 1,
DLM = 0, and DLL = 96.

3.4.1.2

Example 2: PCLK = 12 MHz, BR = 115200
According to the the provided algorithm DLest = PCLK/(16 x BR) = 12 MHz / (16 x 115200)= 6.51. This DLest is not an integer number and the next step is to estimate the FR
parameter. Using an initial estimate of FRest = 1.5 a new DLest = 4 is calculated and FRest
is recalculated as FRest = 1.628. Since FRest = 1.628 is within the specified range of 1.1
and 1.9, DIVADDVAL and MULVAL values can be obtained from the attached look-up
table.
The closest value for FRest = 1.628 in the look-up Table 9–88 is FR = 1.625. It isequivalent 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 9–2 UART’s is 115384. Thisrate has a relative error of 0.16% from the originally specified 115200.

3.5 UART0 Interrupt Enable Register (U0IER - 0xE000 C004, when
DLAB = 0)
The U0IER is used to enable UART0 interrupt sources.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

89 of 285

UM10161

NXP Semiconductors

Chapter 9: LPC2101/02/03 Universal Asynchronous

Table 89.

UART0 Interrupt Enable Register (U0IER - address 0xE000 C004, when DLAB = 0)
bit description

Bit

Symbol0

RBRInterrupt
Enable1

2

THREInterrupt
EnableRX LineStatusInterrupt
Enable

7:3-

8

ABEOIntEn

9

31:10

Value

Reset
value

U0IER[0] enables the Receive Data Available interrupt
for UART0. It also controls the Character Receive
Time-out interrupt.

00Disable the RDA interrupts.

1

Enable the RDA interrupts.
U0IER[1] enables the THRE interrupt for UART0. The
status of this can be read from U0LSR[5].

0Disable the THRE interrupts.

1

Enable the THRE interrupts.

0

U0IER[2] enables the UART0 RX line status interrupts.
0
The status of this interrupt can be read from U0LSR[4:1].
0

Disable the RX line status interrupts.

1

Enable the RX line status interrupts.

-

Reserved, user software should not write ones toreserved bits. The value read from a reserved bit is notdefined.

NA

Enables the end of auto-baud interrupt.

00Disable End of Auto-baud Interrupt.

1

Enable End of Auto-baud Interrupt.

ABTOIntEn-

Description

Enables the auto-baud time-out interrupt.

00Disable Auto-baud Time-out Interrupt.

1

Enable Auto-baud Time-out Interrupt.

-

Reserved, user software should not write ones toreserved bits. The value read from a reserved bit is notdefined.

NA

3.6 UART0 Interrupt Identification Register (U0IIR - 0xE000 C008, Read
Only)
The U0IIR provides a status code that denotes the priority and source of a pending
interrupt. The interrupts are frozen during an U0IIR access. If an interrupt occurs during
an U0IIR access, the interrupt is recorded for the next U0IIR access.
Table 90:

UART0 Interrupt Identification Register (UOIIR - address 0xE000 C008, read only)
bit description

Bit

Symbol0Interrupt
Pending

Value Description

Note that U0IIR[0] is active LOW. The pending interrupt can 1
be determined by evaluating U0IIR[3:1].
0

At least one interrupt is pending.

1

No pending interrupts.

UM10161_3

User manual

Reset
value

© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

90 of 285

UM10161

NXP Semiconductors

Chapter 9: LPC2101/02/03 Universal Asynchronous

Table 90:

UART0 Interrupt Identification Register (UOIIR - address 0xE000 C008, read only)
bit description

Bit

Symbol3:1

Interrupt
Identification

Value Description

Reset
value

U0IER[3:1] identifies an interrupt corresponding to the
UART0 Rx FIFO. All other combinations of U0IER[3:1] notlisted above are reserved (000,100,101,111).
011

0

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
bits. The value read from a reserved bit is not defined.

NA

7:6

FIFO Enable

These bits are equivalent to U0FCR[0].

08ABEOInt

End of auto-baud interrupt. True if auto-baud has finishedsuccessfully and interrupt is enabled.

0

9

ABTOInt

Auto-baud time-out interrupt. True if auto-baud has timedout and interrupt is enabled.

0

Reserved, user software should not write ones to reserved
bits. The value read from a reserved bit is not defined.

NA

31:10 -

Interrupts are handled as described in Table 9–91. Given the status of U0IIR[3:0], aninterrupt handler routine can determine the cause of the interrupt and how to clear theactive interrupt. The U0IIR must be read in order to clear the interrupt prior to exiting theInterrupt 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 thetrigger 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 ofdata 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) willclear 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, theCPU 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.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

91 of 285

UM10161

NXP Semiconductors

Chapter 9: LPC2101/02/03 Universal Asynchronous

Table 91:

UART0 interrupt handling

U0IIR[3:0] Priority Interrupt Typevalue[1]Interrupt Source

Interrupt Reset

0001

None

None

U0LSR Read[2]

-

0110

HighestRX Line Status / Error

OE[2] or PE[2] or FE[2] or BI[2]0100

SecondRX Data Available

Rx data available or trigger level reached in FIFO U0RBR Read[3] or(U0FCR0=1)
UART0 FIFO drops
below trigger level

1100

SecondCharacter Time-out
indication

Minimum of one character in the Rx FIFO and no
character input or removed during a time perioddepending on how many characters are in FIFO
and what the trigger level is set at (3.5 to 4.5
character times).

U0RBR Read[3]The exact time will be:[(word length) × 7 − 2] × 8 + [(trigger level −number of characters) × 8 + 1] RCLKs
0010

Third

THRE[2]THRE

U0IIR Read (if source ofinterrupt) or THR write[4][1]

Values "0000", “0011”, “0101”, “0111”, “1000”, “1001”, “1010”, “1011”,”1101”,”1110”,”1111” are reserved.

[2]

For details see Section 9–3.9 “UART0 Line Status Register (U0LSR - 0xE000 C014, Read Only)”[3]

For details see Section 9–3.1 “UART0 Receiver Buffer register (U0RBR - 0xE000 C000, when DLAB = 0,
Read Only)”[4]

For details see Section 9–3.6 “UART0 Interrupt Identification Register (U0IIR - 0xE000 C008, Read Only)”and Section 9–3.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 activatedwhen 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 tofill 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 andcurrently, the U0THR is empty. The THRE interrupt is reset when a U0THR write occurs ora read of the U0IIR occurs and the THRE is the highest interrupt (U0IIR[3:1] = 001).

3.7 UART0 FIFO Control Register (U0FCR - 0xE000 C008)
The U0FCR controls the operation of the UART0 Rx and TX FIFOs.
Table 92:

UART0 FIFO Control Register (U0FCR - address 0xE000 C008) bit description

Bit

SymbolValue

0

FIFO Enable 0
1

Description

UART0 FIFOs are disabled. Must not be used in the 0
application.
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 thisbit will automatically clear the UART0 FIFOs.

UM10161_3

User manual

Reset value© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

92 of 285

UM10161

NXP Semiconductors

Chapter 9: LPC2101/02/03 Universal Asynchronous

Table 92:

UART0 FIFO Control Register (U0FCR - address 0xE000 C008) bit description

Bit

SymbolValue

Description

Reset value

1

RX FIFOReset

0

No impact on either of UART0 FIFOs.

0

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.

TX FIFOReset

0

No impact on either of UART0 FIFOs.

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 toreserved bits. The value read from a reserved bit is
not defined.

NA

7:6

RX Trigger
Level

These two bits determine how many receiver
UART0 FIFO characters must be written before aninterrupt is activated.

0

2

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).

0

3.8 UART0 Line Control Register (U0LCR - 0xE000 C00C)The U0LCR determines the format of the data character that is to be transmitted or
received.
Table 93:

UART0 Line Control Register (U0LCR - address 0xE000 C00C) bit description

Bit

SymbolValue

Description

Reset value

1:0

Word Length
Select00

5 bit character length

001

6 bit character length

10

7 bit character length11

8 bit character length

2
3
5:4

6

7

Stop Bit SelectParity Enable
Parity SelectBreak Control

0

1 stop bit.

1

2 stop bits (1.5 if U0LCR[1:0]=00).

0

Disable parity generation and checking.

1

Enable parity generation and checking.

00

Odd parity. Number of 1s in the transmitted character and theattached parity bit will be odd.

01

Even Parity. Number of 1s in the transmitted character and theattached parity bit will be even.

10

Forced "1" stick parity.

11

Forced "0" stick parity.

0

Disable break transmission.

1

Enable break transmission. Output pin UART0 TXD is forced
to logic 0 when U0LCR[6] is active HIGH.

Divisor Latch
0
Access Bit (DLAB) 1

Disable access to Divisor Latches.

0
0

0

0

Enable access to Divisor Latches.

UM10161_3

User manual

0© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

93 of 285

UM10161

NXP Semiconductors

Chapter 9: LPC2101/02/03 Universal Asynchronous

3.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 andRX blocks.
Table 94:

UART0 Line Status Register (U0LSR - address 0xE000 C014, read only) bit description

Bit Symbol
0Receiver Data
Ready
(RDR)

Value Description

0
1

1

2

Reset value

U0LSR0 is set when the U0RBR holds an unread character and is cleared
when the UART0 RBR FIFO is empty.

Overrun Error(OE)

0

U0RBR is empty.
U0RBR contains valid data.
The overrun error condition is set as soon as it occurs. An U0LSR read clears 0
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.

0Overrun error status is inactive.

1

Overrun error status is active.
When the parity bit of a received character is in the wrong state, a parity error 0
occurs. An U0LSR read clears U0LSR[2]. Time of parity error detection isdependent on U0FCR[0].

Parity Error(PE)

Note: A parity error is associated with the character at the top of the UART0RBR FIFO.

30

Parity error status is inactive.

1

Parity error status is active.
When the stop bit of a received character is a logic 0, a framing error occurs. 0
An U0LSR read clears U0LSR[3]. The time of the framing error detection isdependent 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 anearly start bit. However, it cannot be assumed that the next received byte will
be correct even if there is no Framing Error.

Framing Error(FE)

Note: A framing error is associated with the character at the top of the UART0RBR FIFO.

40

Framing error status is inactive.

1

Framing error status is active.

Break Interrupt(BI)

0
When RXD0 is held in the spacing state (all 0’s) for one full charactertransmission (start, data, parity, stop), a break interrupt occurs. Once thebreak condition has been detected, the receiver goes idle until RXD0 goes tomarking 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.

5

Transmitter
Holding
Register Empty(THRE))

0

Break interrupt status is inactive.

1

Break interrupt status is active.
THRE is set immediately upon detection of an empty UART0 THR and iscleared on a U0THR write.

0

U0THR contains valid data.

1

U0THR is empty.

UM10161_3

User manual

1© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

94 of 285

UM10161

NXP Semiconductors

Chapter 9: LPC2101/02/03 Universal Asynchronous

Table 94:

UART0 Line Status Register (U0LSR - address 0xE000 C014, read only) bit description

Bit Symbol
6

7

Value Description

Transmitter
Empty(TEMT)

Reset value

TEMT is set when both U0THR and U0TSR are empty; TEMT is cleared when 1
either the U0TSR or the U0THR contain valid data.
0

U0THR and/or the U0TSR contains valid data.

1

U0THR and the U0TSR are empty.

Error in RX
FIFO(RXFE)U0LSR[7] is set when a character with a Rx error such as framing error, parity 0
error or break interrupt, is loaded into the U0RBR. This bit is cleared when the
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.

3.10 UART0 Scratch Pad Register (U0SCR - 0xE000 C01C)The U0SCR has no effect on the UART0 operation. This register can be written and/or
read at user’s discretion. There is no provision in the interrupt interface that would indicate
to the host that a read or write of the U0SCR has occurred.
Table 95:

UART0 Scratch Pad Register (U0SCR - address 0xE000 C01C) bit description

Bit

SymbolDescription

Reset value

7:0

Pad

A readable, writable byte.

0x00

3.11 UART0 Auto-baud Control Register (U0ACR - 0xE000 C020)
The UART0 Auto-baud Control Register (U0ACR) controls the process of measuring theincoming clock/data rate for the baud rate generation and can be read and written at
user’s discretion.
Table 96:

Auto-baud Control Register (U0ACR - 0xE000 C020) bit description

Bit

Symbol

0

Start

1

2

7:3

Value Description
This bit is automatically cleared after auto-baudcompletion.
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-baudcompletion.
Auto-baud mode select bit.

0Mode 0.

1Mode 1.

AutoRestart 00

No restart0

1

Restart in case of time-out (counter restarts at next
UART0 Rx falling edge)

NA

Reserved, user software should not write ones to0reserved bits. The value read from a reserved bit is notdefined.

UM10161_3

User manual

0

0

Mode

-

Reset value© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

95 of 285

UM10161

NXP Semiconductors

Chapter 9: LPC2101/02/03 Universal Asynchronous

Table 96:

Auto-baud Control Register (U0ACR - 0xE000 C020) bit description

Bit

Symbol8

ABEOIntClr

End of auto-baud interrupt clear bit (write only
accessible). Writing a 1 will clear the corresponding
interrupt in the U0IIR. Writing a 0 has no impact.

09

ABTOIntClr

Auto-baud time-out interrupt clear bit (write only
accessible). Writing a 1 will clear the corresponding
interrupt in the U0IIR. Writing a 0 has no impact.

0

31:10 -

Value Description

NA

Reset value

Reserved, user software should not write ones to0reserved bits. The value read from a reserved bit is notdefined.

3.12 Auto-baud
The UART0 auto-baud function can be used to measure the incoming baud-rate based onthe ”AT" protocol (Hayes command). If enabled the auto-baud feature will measure the bittime 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 significantbit). In mode 1 the baud-rate is measured between the falling edge and the subsequentrising 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 ratemeasurement will restart at the next falling edge of the UART0 Rx pin.
The auto-baud function can generate two interrupts.

• 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).
The auto-baud interrupts have to be cleared by setting the corresponding U0ACRABTOIntClr and ABEOIntEn bits.
Typically the fractional baud-rate generator is disabled (DIVADDVAL = 0) during
auto-baud. However, if the fractional baud-rate generator is enabled (DIVADDVAL > 0), it
is going to impact the measuring of UART0 Rx pin baud-rate, but the value of the U0FDR
register is not going to be modified after rate measurement. Also, when auto-baud is used,
any write to U0DLM and U0DLL registers should be done before U0ACR register write.
The minimum and the maximum baudrates supported by UART0 are function of PCLK,
number of data bits, stop-bits and parity bits.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

96 of 285

UM10161

NXP Semiconductors

Chapter 9: LPC2101/02/03 Universal Asynchronous(2)
2 × P CLK
16 × 2 15

PCLK
16 × ( 2 + databits + paritybits + stopbits )ratemin = ------------------------- ≤ UART0 baudrate ≤ ------------------------------------------------------------------------------------------------------------ = ratemax

3.13 UART0 Transmit Enable Register (U0TER - 0xE000 C030)
LPC2101/02/03’s U0TER enables implementation of software flow control. When
TXEn=1, UART0 transmitter will keep sending data as long as they are available. As soon
as TXEn becomes 0, UART0 transmission will stop.
Table 9–97 describes how to use TXEn bit in order to achieve software flow control.
Table 97:

UART0 Transmit Enable Register (U0TER - address 0xE000 C030) bit description

Bit

SymbolDescription

Reset
value

6:0

-

Reserved, user software should not write ones to reserved bits. The
value read from a reserved bit is not defined.

NA

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 thatcharacter is completed, but no further characters are sent until this bit isset again. In other words, a 0 in this bit blocks the transfer of charactersfrom 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.

3.14 Auto-baud modes
When the software is expecting an ”AT" command, it configures the UART0 with the
expected character format and sets the U0ACR Start bit. The initial values in the divisor
latches U0DLM and U0DLM don‘t care. Because of the ”A" or ”a" ASCII coding(”A" = 0x41, ”a" = 0x61), the UART0 Rx pin sensed start bit and the LSB of the expectedcharacter are delimited by two falling edges. When the U0ACR Start bit is set, theauto-baud protocol will execute the following phases:
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 ratemeasuring counter will start counting PCLK cycles optionally pre-scaled by thefractional baud-rate generator.
3. During the receipt of the start bit, 16 pulses are generated on the RSR baud input withthe 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.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

97 of 285

UM10161

NXP Semiconductors

Chapter 9: LPC2101/02/03 Universal Asynchronous

6. The rate counter is loaded into U0DLM/U0DLL and the baud-rate will be switched tonormal 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 theremaining bits of the ”A/a" character.

'A' (0x41) or 'a' (0x61)
start

bit0

bit1

bit2

bit3

bit4

bit5

bit6

bit7

parity stop

UART0 RXstart bit

LSB of 'A' or 'a'

U0ACR start
rate counter
16xbaud_rate

16 cycles

16 cyclesa. Mode 0 (start bit and LSB are used for auto-baud)'A' (0x41) or 'a' (0x61)
start

bit0

bit1

bit2

bit3

bit4

bit5

bit6

bit7

parity stop

UART0 RXstart bit

LSB of 'A' or 'a'

U0ACR start
rate counter
16xbaud_rate

16 cyclesb. Mode 1 (only start bit is used for auto-baud)
Fig 19. Autobaud a) mode 0 and b) mode 1 waveform.

4. 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 validcharacter 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.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

98 of 285

UM10161

NXP Semiconductors

Chapter 9: LPC2101/02/03 Universal Asynchronous

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 theserial 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.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

99 of 285

UM10161

NXP Semiconductors

Chapter 9: LPC2101/02/03 Universal Asynchronous

U0TX

U0THR

NTXRDY
U0TSR

TXD0

U0BRG

U0DLL

NBAUDOUT

U0DLM

RCLK

U0RX

NRXRDYINTERRUPT
U0RBR
U0INTR

U0RSR

RXD0

U0IER

U0IIR

U0FCR

U0LSR
U0SCR
U0LCR

PA[2:0]PSEL
PSTB
PWRITEAPB
INTERFACE

PD[7:0]

DDIS

AR
MR
PCLK

Fig 20. UART0 block diagram

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

100 of 285

UM10161
Chapter 10: LPC2101/02/03 Universal Asynchronous
Receiver/Transmitter 1 (UART1)
Rev. 3 — 2 October 2008

User manual

1. 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.

2. Pin description
Table 98.

UART1 pin description

Pin

Type

Description

RXD1

Input

Serial Input. Serial receive data.

TXD1

OutputSerial 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), thecomplement 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 acommunication link with the UART1 and data may be exchanged. In normal operation of themodem interface (U1MCR[4]=0), the complement value of this signal is stored in U1MSR[7]. Statechange 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 acommunications 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).

DTR1

OutputData Terminal Ready. Active LOW signal indicates that the UART1 is ready to establish connection
with external modem. The complement value of this signal is stored in U1MCR[0].

RI1

Input

Ring Indicator. Active LOW signal indicates that a telephone ringing signal has been detected by
the modem. In normal operation of the modem interface (U1MCR[4] = 0), the complement value of
this signal is stored in U1MSR[6]. State change information is stored in U1MSR[2] and is a source
for a priority level 4 interrupt, if enabled (U1IER[3] = 1).

RTS1

OutputRequest To Send. Active LOW signal indicates that the UART1 would like to transmit data to theexternal modem. The complement value of this signal is stored in U1MCR[1].

3. Register description
UART1 contains registers organized as shown in Table 10–99. The Divisor Latch AccessBit (DLAB) is contained in U1LCR[7] and enables access to the Divisor Latches.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

101 of 285

xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxx x x x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xx xx xxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx x xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx xxx
UART1 register map

Name

Description

Bit functions and addresses
MSB
BIT7

LSB
BIT6

BIT5

BIT4

BIT3

BIT2

BIT1

Access Reset
value[1]Address

BIT0

Receiver Buffer
Register

8-bit Read Data

RONA

0xE001 0000
(DLAB=0)U1THR

Transmit Holding
Register

8-bit Write Data

WO

NA

0xE001 0000
(DLAB=0)U1DLL

Divisor Latch LSB

8-bit Data

R/W

0x01

0xE001 0000
(DLAB=1)U1DLM

Divisor Latch MSB

8-bit Data

R/W

0x00

0xE001 0004
(DLAB=1)U1IER

Interrupt Enable
Register

En.ABTO En.ABEO R/W

0x00

0xE001 0004
(DLAB=0)0x01

0xE001 0008

U1IIR

Interrupt ID Reg.

-

-

-

-

-

En.CTS
Int

-

-

-

-

-

-

-

-

-

FIFOs Enabled

-

-

IIR3

IIR2

IIR1

IIR0

RX Trigger

-

-

-

TX FIFOReset

RX FIFOReset

FIFO
EnableWO

0x00

0xE001 0008

Word Length Select R/W

0x00

0xE001 000C

E.Modem En. RX
EnableEn. RX
St.IntLin.St. Int THRE Int Dat.Av.Int
ABTO Int ABEO Int RO

FIFO Control
Register

U1LCRLine Control
Register

DLAB

Set BreakStick
ParityEven
Par.Selct.

ParityEnableNo. ofStop Bits

U1MCR

Modem Ctrl. Reg.

CTSen

RTSen

-

LoopBck.

-

-

RTS

DTR

R/W

0x00

0xE001 0010

U1LSRLine Status
Register

RX FIFO
Error

TEMT

THRE

BI

FE

PE

OE

DR

RO

0x60

0xE001 0014

U1MSR

Modem Status
Register

DCD

RI

DSR

CTS

Delta
DCD

Trailing
Edge RI

Delta
DSR

Delta
CTS

RO

0x00

0xE001 0018

U1SCR

Scratch Pad Reg.

R/W

0x00

0xE001 001C

U1ACR

Auto-baud Control
Register

-

-

-

-

-

-

ABTO
IntClr

ABEO
IntClrR/W

0x00

0xE001 0020

-

-

-

-

-

Aut.Rstrt.

Mode

Start
R/W

0x10

0xE001 0028

R/W

0x80

0xE001 0030

U1FDR
U1TER
[1]

8-bit Data

Fractional Divider
Register
TX. Enable Reg.

Reserved[31:8]
MulValTXEN-

DivAddVal---

Reset value reflects the data stored in used bits only. It does not include reserved bits content.

-

-

-

UM10161102 of 285© NXP B.V. 2008. All rights reserved.

U1FCR

Chapter 10: LPC2101/02/03 Universal Asynchronous

Rev. 3 — 2 October 2008

U1RBR

-

NXP Semiconductors

UM10161_3

User manual

Table 99.

UM10161

NXP Semiconductors

Chapter 10: LPC2101/02/03 Universal Asynchronous

3.1 UART1 Receiver Buffer Register (U1RBR - 0xE001 0000, when
DLAB = 0 Read Only)
The U1RBR is the top byte of the UART1 RX FIFO. The top byte of the RX FIFO contains
the oldest character received and can be read via the bus interface. The LSB (bit 0)
represents the “oldest” received data bit. If the character received is less than 8 bits, theunused MSBs are padded with zeroes.
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 thevalid 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 100. UART1 Receiver Buffer Register (U1RBR - address 0xE001 0000, when DLAB = 0
Read Only) bit description
Bit

SymbolDescription

Reset value

7:0

RBR

The UART1 Receiver Buffer Register contains the oldest
received byte in the UART1 RX FIFO.

undefined

3.2 UART1 Transmitter Holding Register (U1THR - 0xE001 0000, when
DLAB = 0 Write Only)
The U1THR is the top byte of the UART1 TX FIFO. The top byte is the newest character in
the TX FIFO and can be written via the bus interface. The LSB represents the first bit totransmit.
The Divisor Latch Access Bit (DLAB) in U1LCR must be zero in order to access the
U1THR. The U1THR is always Write Only.
Table 101. UART1 Transmitter Holding Register (U1THR - address 0xE001 0000, when
DLAB = 0 Write Only) bit description
Bit

SymbolDescription

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 isavailable.

3.3 UART1 Divisor Latch registers 0 and 1 (U1DLL - 0xE001 0000 and
U1DLM - 0xE001 0004, when DLAB = 1)
The UART1 Divisor Latch is part of the UART1 Fractional Baud Rate Generator and holds
the value used to divide the clock supplied by the fractional prescaler in order to produce
the baud rate clock, which must be 16x the desired baud rate (Equation 10–4). The
U1DLL and U1DLM registers together form a 16 bit divisor where U1DLL contains thelower 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.
Details on how to select the right value for U1DLL and U1DLM can be found later on inthis chapter.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

103 of 285

UM10161

NXP Semiconductors

Chapter 10: LPC2101/02/03 Universal Asynchronous

Table 102. UART1 Divisor Latch LSB register (U1DLL - address 0xE001 0000, when
DLAB = 1) bit description
Bit

SymbolDescription

Reset value

7:0

DLLSB

The UART1 Divisor Latch LSB Register, along with the U1DLM
register, determines the baud rate of the UART1.

0x01

Table 103. UART1 Divisor Latch MSB register (U1DLM - address 0xE001 0004, when
DLAB = 1) bit description
Bit

SymbolDescription

Reset value

7:0

DLMSB

The UART1 Divisor Latch MSB Register, along with the U1DLL
register, determines the baud rate of the UART1.

0x00

3.4 UART1 Fractional Divider Register (U1FDR - 0xE001 0028)
The UART1 Fractional Divider Register (U1FDR) controls the clock pre-scaler for thebaud rate generation and can be read and written at the user’s discretion. This pre-scaler
takes the APB clock and generates an output clock according to the specified fractional
requirements.
Important: If the fractional divider is active (DIVADDVAL > 0) and DLM = 0, the value of
the DLL register must be 3 or greater.
Table 104. 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 00, 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 isused 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 ofthe 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.
UART1 baudrate can be calculated as (n = 1):
(3)

PCLK
UARTn baudrate = ---------------------------------------------------------------------------------------------------------------------------------16 × ( 256 × UnDLM + UnDLL ) × ⎛ 1 + DivAddVal-----------------------------⎞⎠⎝
MulValWhere PCLK is the peripheral clock, U1DLM and U1DLL are the standard UART1 baudrate divider registers, and DIVADDVAL and MULVAL are UART1 fractional baudrate
generator specific parameters.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

104 of 285

UM10161

NXP Semiconductors

Chapter 10: LPC2101/02/03 Universal Asynchronous

The value of MULVAL and DIVADDVAL should comply to the following conditions:
1. 0 < MULVAL ≤ 15
2. 0 ≤ DIVADDVAL < 15
3. DIVADDVAL<MULVALThe 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.

3.4.1 Baudrate calculation
UART can operate with or without using the Fractional Divider. In real-life applications it islikely that the desired baudrate can be achieved using several different Fractional Divider
settings. The following algorithm illustrates one way of finding a set of DLM, DLL,MULVAL, and DIVADDVAL values. Such set of parameters yields a baudrate with arelative error of less than 1.1% from the desired one.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

105 of 285

UM10161

NXP Semiconductors

Chapter 10: LPC2101/02/03 Universal Asynchronous

Calculating UART
baudrate (BR)

PCLK,
BR

DL est = PCLK/(16 x BR)

DL est is an
integer?

True

False

DIVADDVAL = 0
MULVAL = 1

FR est = 1.5

Pick another FR est fromthe range [1.1, 1.9]

DL est = Int(PCLK/(16 x BR x FR est))

FR est = PCLK/(16 x BR x DL est)

False
1.1 < FR est < 1.9?

True

DIVADDVAL = table(FR est )MULVAL = table(FR est )DLM = DL est[15:8]
DLL = DL est [7:0]End

Fig 21. Algorithm for setting UART dividers

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

106 of 285

UM10161

NXP Semiconductors

Chapter 10: LPC2101/02/03 Universal Asynchronous

Table 105. Fractional Divider setting look-up table

3.4.1.1

FR

DivAddVal/
MulValFR

DivAddVal/
MulValFR

DivAddVal/
MulValFR

DivAddVal/
MulVal

1.000

0/1

1.250

1/4

1.500

1/2

1.750

3/4

1.067

1/15

1.267

4/15

1.533

8/15

1.769

10/13

1.071

1/14

1.273

3/11

1.538

7/13

1.778

7/9

1.077

1/13

1.286

2/7

1.545

6/11

1.786

11/14

1.083

1/12

1.300

3/10

1.556

5/9

1.800

4/5

1.091

1/11

1.308

4/13

1.571

4/7

1.818

9/11

1.100

1/10

1.333

1/3

1.583

7/12

1.833

5/6

1.111

1/9

1.357

5/14

1.600

3/5

1.846

11/13

1.125

1/8

1.364

4/11

1.615

8/13

1.857

6/7

1.133

2/15

1.375

3/8

1.625

5/8

1.867

13/15

1.143

1/7

1.385

5/13

1.636

7/11

1.875

7/8

1.154

2/13

1.400

2/5

1.643

9/14

1.889

8/9

1.167

1/6

1.417

5/12

1.667

2/3

1.900

9/10

1.182

2/11

1.429

3/7

1.692

9/13

1.909

10/11

1.200

1/5

1.444

4/9

1.700

7/10

1.917

11/12

1.214

3/14

1.455

5/11

1.714

5/7

1.923

12/13

1.222

2/9

1.462

6/13

1.727

8/11

1.929

13/14

1.231

3/13

1.467

7/15

1.733

11/15

1.933

14/15

Example 1: PCLK = 14.7456 MHz, BR = 9600 Bd
According to the the provided algorithm DLest = PCLK/(16 x BR) = 14.7456 MHz / (16 x
9600) = 96. Since this DLest is an integer number, DIVADDVAL = 0, MULVAL = 1,
DLM = 0, and DLL = 96.

3.4.1.2

Example 2: PCLK = 12 MHz, BR = 115200 Bd
According to the the provided algorithm DLest = PCLK/(16 x BR) = 12 MHz / (16 x 115200)= 6.51. This DLest is not an integer number and the next step is to estimate the FR
parameter. Using an initial estimate of FRest = 1.5 a new DLest = 4 is calculated and FRest
is recalculated as FRest = 1.628. Since FRest = 1.628 is within the specified range of 1.1
and 1.9, DIVADDVAL and MULVAL values can be obtained from the attached look-up
table.
The closest value for FRest = 1.628 in the look-up Table 10–105 is FR = 1.625. It isequivalent 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–3 the UART’s baud rate is115384 Bd. This rate has a relative error of 0.16% from the originally specified 115200 Bd.

3.5 UART1 Interrupt Enable Register (U1IER - 0xE001 0004, when
DLAB = 0)
The U1IER is used to enable UART1 interrupt sources.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

107 of 285

UM10161

NXP Semiconductors

Chapter 10: LPC2101/02/03 Universal Asynchronous

Table 106. UART1 Interrupt Enable Register (U1IER - address 0xE001 0004, when DLAB = 0)
bit description
Bit

Symbol0

RBRInterrupt
Enable

1

2

3

Value

Disable the RDA interrupts.

1

Enable the RDA interrupts.
U1IER[1] enables the THRE interrupt for UART1.
The status of this interrupt can be read fromU1LSR[5].

0Disable the THRE interrupts.

1

Enable the THRE interrupts.

RX LineInterrupt
Enable

6:4

-

7

CTS
Interrupt
EnableReset value
0

0
THRE
Interrupt
EnableModem
StatusInterrupt
EnableDescription
U1IER[0] enables the Receive Data Available
interrupt for UART1. It also controls the Character
Receive Time-out interrupt.

U1IER[2] enables the UART1 RX line statusinterrupts. The status of this interrupt can be readfrom U1LSR[4:1].
0

Disable the RX line status interrupts.

1

Enable the RX line status interrupts.
U1IER[3] enables the modem interrupt. The statusof this interrupt can be read from U1MSR[3:0].

0

Disable the modem interrupt.

1

Enable the modem interrupt.

-

Reserved, user software should not write ones toreserved bits. The value read from a reserved bit is
not defined.

0

0

0

NA

If auto-CTS mode is enabled this bit0enables/disables the modem status interrupt
generation on a CTS1 signal transition. If auto-CTS
mode is disabled a CTS1 transition will generate aninterrupt if Modem Status Interrupt Enable(U1IER[3]) is set.
In normal operation a CTS1 signal transition will
generate a Modem Status Interrupt unless theinterrupt 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 aninterrupt only if both the U1IER[3] and U1IER[7] bits
are set.

8

9

31:10

0

Disable the CTS interrupt.

1

Enable the CTS interrupt.

ABEOIntEn

Enables the end of auto-baud interrupt.
0

Disable End of Auto-baud Interrupt.

1

Enable End of Auto-baud Interrupt.

ABTOIntEn-

Enables the auto-baud time-out interrupt.

00Disable Auto-baud Time-out Interrupt.

1

Enable Auto-baud Time-out Interrupt.

-

Reserved, user software should not write ones toreserved bits. The value read from a reserved bit is
not defined.

UM10161_3

User manual

0NA© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

108 of 285

UM10161

NXP Semiconductors

Chapter 10: LPC2101/02/03 Universal Asynchronous

3.6 UART1 Interrupt Identification Register (U1IIR - 0xE001 0008, Read
Only)
The U1IIR provides a status code that denotes the priority and source of a pending
interrupt. The interrupts are frozen during an U1IIR access. If an interrupt occurs during
an U1IIR access, the interrupt is recorded for the next U1IIR access.
Table 107. UART1 Interrupt Identification Register (U1IIR - address 0xE001 0008, read only)
bit description
Bit

Symbol0Interrupt
Pending

3:1

Value

Description

Reset value

Note that U1IIR[0] is active LOW. The pending
interrupt can be determined by evaluating
U1IIR[3:1].

1

0

At least one interrupt is pending.

1

No interrupt is pending.

Interrupt
Identification

U1IER[3:1] identifies an interrupt corresponding to
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

0

4 - Modem Interrupt.

5:4-

Reserved, user software should not write ones toreserved bits. The value read from a reserved bit is
not defined.

NA

7:6

FIFO Enable

These bits are equivalent to U1FCR[0].

08ABEOInt

End of auto-baud interrupt. True if auto-baud has
finished successfully and interrupt is enabled.

0

9

ABTOInt

Auto-baud time-out interrupt. True if auto-baud has
timed out and interrupt is enabled.

0

Reserved, user software should not write ones toreserved bits. The value read from a reserved bit is
not defined.

NA

31:10 -

Interrupts are handled as described in Table 10–108. Given the status of U1IIR[3:0], aninterrupt handler routine can determine the cause of the interrupt and how to clear theactive interrupt. The U1IIR must be read in order to clear the interrupt prior to exiting theInterrupt 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.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

109 of 285

UM10161

NXP Semiconductors

Chapter 10: LPC2101/02/03 Universal Asynchronous

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 thetrigger 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) willclear 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, theCPU 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.
Table 108. UART1 interrupt handling
U1IIR[3:0] Priority
value[1]Interrupt TypeInterrupt Source

Interrupt Reset

0001

None

None

U1LSR Read[2]

-

0110

HighestRX Line Status / Error

OE[2] or PE[2] or FE[2] or BI[2]0100

SecondRX Data Available

Rx data available or trigger level reached in FIFO U1RBR Read[3] or(U1FCR0=1)
UART1 FIFO drops
below trigger level

1100

SecondCharacter Time-out
indication

Minimum of one character in the RX FIFO and no U1RBR Read[3]character input or removed during a time perioddepending on how many characters are in FIFO
and what the trigger level is set at (3.5 to 4.5
character times).
The exact time will be:[(word length) × 7 - 2] × 8 + [(trigger level number of characters) × 8 + 1] RCLKs

0010

Third

THRE

THRE[2]U1IIR Read[4] (if sourceof interrupt) or THR write

0000

FourthModem Status

CTS or DSR or RI or DCD

MSR Read[1]

Values "0000" (see Table note 10–2), “0011”, “0101”, “0111”, “1000”, “1001”, “1010”, “1011”,”1101”,”1110”,”1111” are reserved.

[2]

For details see Section 10–3.10 “UART1 Line Status Register (U1LSR - 0xE001 0014, Read Only)”[3]

For details see Section 10–3.1 “UART1 Receiver Buffer Register (U1RBR - 0xE001 0000, when DLAB = 0 Read Only)”[4]

For details see Section 10–3.6 “UART1 Interrupt Identification Register (U1IIR - 0xE001 0008, Read Only)” and Section 10–3.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 activatedwhen 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 tofill 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

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

110 of 285

UM10161

NXP Semiconductors

Chapter 10: LPC2101/02/03 Universal Asynchronous

immediately if the UART1 THR FIFO has held two or more characters at one time andcurrently, the U1THR is empty. The THRE interrupt is reset when a U1THR write occurs ora read of the U1IIR occurs and the THRE is the highest interrupt (U1IIR[3:1] = 001).
The modem interrupt (U1IIR[3:1] = 000) is available in LPC2101/02/03. It is the lowest
priority interrupt and is activated whenever there is any state change on modem inputs
pins, DCD, DSR or CTS. In addition, a LOW to high transition on modem input RI will
generate a modem interrupt. The source of the modem interrupt can be determined byexamining U1MSR[3:0]. A U1MSR read will clear the modem interrupt.

3.7 UART1 FIFO Control Register (U1FCR - 0xE001 0008)
The U1FCR controls the operation of the UART1 RX and TX FIFOs.
Table 109. UART1 FIFO Control Register (U1FCR - address 0xE001 0008) bit description
Bit

SymbolValue

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 andU1FCR[7:1] access. This bit must be set for proper UART1
operation. Any transition on this bit will automatically clear the
UART1 FIFOs.

0

No impact on either of UART1 FIFOs.

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.

0

No impact on either of UART1 FIFOs.

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.

1

2

RX FIFO Reset

TX FIFO Reset

0

0

5:3

-

Reserved, user software should not write ones to reserved bits.
The value read from a reserved bit is not defined.

NA

7:6

RX Trigger
Level

These two bits determine how many receiver UART1 FIFO
characters must be written before an interrupt is activated.

000

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).

3.8 UART1 Line Control Register (U1LCR - 0xE001 000C)
The U1LCR determines the format of the data character that is to be transmitted or
received.
Table 110. UART1 Line Control Register (U1LCR - address 0xE001 000C) bit description
Bit

SymbolValue

Description

Reset value

1:0

Word Length
Select00

5 bit character length.

001

6 bit character length.

2

Stop Bit Select10

7 bit character length.

11

8 bit character length.

0

1 stop bit.

1

2 stop bits (1.5 if U1LCR[1:0]=00).

UM10161_3

User manual

0© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

111 of 285

UM10161

NXP Semiconductors

Chapter 10: LPC2101/02/03 Universal Asynchronous

Table 110. UART1 Line Control Register (U1LCR - address 0xE001 000C) bit description
Bit

SymbolValue

Description

Reset value

3

Parity Enable0

Disable parity generation and checking.

0

1

Enable parity generation and checking.

00

Odd parity. Number of 1s in the transmitted character and theattached parity bit will be odd.

01

Even Parity. Number of 1s in the transmitted character and theattached parity bit will be even.

5:4

6

7

Parity SelectBreak Control

10Forced "1" stick parity.

11

Forced "0" stick parity.

0

Disable break transmission.

1

Enable break transmission. Output pin UART1 TXD is forced
to logic 0 when U1LCR[6] is active HIGH.

Divisor Latch
0
Access Bit (DLAB) 10

0

Disable access to Divisor Latches.

0

Enable access to Divisor Latches.

3.9 UART1 Modem Control Register (U1MCR - 0xE001 0010)
The U1MCR enables the modem loopback mode and controls the modem output signals.
Table 111. UART1 Modem Control Register (U1MCR - address 0xE001 0010) bit description
Bit

Symbol0

Description

Reset value

DTR Control

Source for modem output pin, DTR. This bit reads as 0 whenmodem loopback mode is active.

0

1

RTS Control

Source for modem output pin RTS. This bit reads as 0 whenmodem loopback mode is active.

0

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
Select

The modem loopback mode provides a mechanism to perform 0
diagnostic loopback testing. Serial data from the transmitter isconnected internally to serial input of the receiver. Input pin,
RXD1, has no effect on loopback and output pin, TXD1 is heldin 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 statusinterrupts to be generated in loopback mode by writing thelower four bits of U1MCR.

5:3

-

6

RTSen

Value

0

Disable modem loopback mode.

1

Enable modem loopback mode.
Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
Auto-RTS control bit.

0

Disable auto-RTS flow control.

1

Enable auto-RTS flow control.

UM10161_3

User manual

0© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

112 of 285

UM10161

NXP Semiconductors

Chapter 10: LPC2101/02/03 Universal Asynchronous

Table 111. UART1 Modem Control Register (U1MCR - address 0xE001 0010) bit description
Bit

Symbol

7

CTSen

Value

Description

Reset value

Auto-CTS control bit.

00

Disable auto-CTS flow control.

1

Enable auto-CTS flow control.

3.9.1 Auto-flow control
If auto-RTS mode is enabled the UART1‘s receiver FIFO hardware controls the RTS1
output of the UART1. If the auto-CTS mode is enabled the UART1‘s U1TSR hardware will
only start transmitting if the CTS1 input signal is asserted.
3.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 thetrigger 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 hasreached the previous trigger level. The reassertion of RTS1 signals to the sending UART
to continue transmitting data.
If Auto-RTS mode is disabled, the RTSen 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 thereceive FIFO contains 8 bytes (Table 10–109). The RTS1 output will be reasserted assoon as the receive FIFO hits the previous trigger level: 4 bytes.

~~

UART1 Rx
byte N

stop

start

bits0..7

stop

N

N-1

N-2

start

bits0..7

M

M-1

stop

~
~

start

RTS1 pin~~~~

UART1 Rx
FIFO read
UART1 Rx
FIFO level

N-1

N-2

M+2

M+1

~
~

N-1

Fig 22. Auto-RTS functional timing

3.9.1.2

Auto-CTS
The auto-CTS function is enabled by setting the CTSen bit. If auto-CTS is enabled thetransmitter circuitry in the U1TSR module checks CTS1 input before sending the next databyte. When CTS1 is active (LOW), the transmitter sends the next byte. To stop theUM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

113 of 285

UM10161

NXP Semiconductors

Chapter 10: LPC2101/02/03 Universal Asynchronoustransmitter from sending the following byte, CTS1 must be released before the middle ofthe 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 10–112 lists the conditions forgenerating a Modem Status interrupt.
Table 112. Modem status interrupt generation
Enable Modem CTSen
Status(U1MCR[7])Interrupt(U1IER[3])CTS Interrupt Delta CTS
Delta DCD or
Modem Status
Enable(U1MSR[0]) Trailing Edge RI orInterrupt(U1IER[7])Delta DSR
(U1MSR[3] or U1MSR[2] or (U1MSR[1]))

0

x

x

x

x

no

1

0

x

0

0

no

1

0

x

1

x

yes

1

0

x

x

1

yes

1

1

0

x

0

no

1

1

0

x

1

yes

1

1

1

0

0

no

1

1

1

1

x

yes

1

1

1

x

1

yes

~
~

UART1 TX
bits0..7

stop

start

bits0..7

stop

start

bits0..7

stop

~
~

start

~
~

The auto-CTS function reduces interrupts to the host system. When flow control isenabled, 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 10–23
illustrates the auto-CTS functional timing.

~~

CTS1 pin

Fig 23. Auto-CTS functional timing

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 willcontinue 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.

3.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 andRX blocks.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

114 of 285

UM10161

NXP Semiconductors

Chapter 10: LPC2101/02/03 Universal Asynchronous

Table 113. UART1 Line Status Register (U1LSR - address 0xE001 0014, read only) bit description
Bit Symbol
0Receiver Data
Ready
(RDR)

Value Description
U1LSR[0] is set when the U1RBR holds an unread character and is cleared when
the UART1 RBR FIFO is empty.
0
1

1

2

Reset
value

Overrun Error(OE)

0

U1RBR is empty.
U1RBR contains valid data.
The overrun error condition is set as soon as it occurs. An U1LSR read clears
0
U1LSR[1]. U1LSR[1] is set when UART1 RSR has a new character assembled andthe 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.

0Overrun error status is inactive.

1

Overrun error status is active.

Parity Error(PE)

When the parity bit of a received character is in the wrong state, a parity error
occurs. An U1LSR read clears U1LSR[2]. Time of parity error detection isdependent on U1FCR[0].

0Note: A parity error is associated with the character at the top of the UART1 RBR
FIFO.

3

0

Parity error status is inactive.

1

Parity error status is active.
When the stop bit of a received character is a logic 0, a framing error occurs. An
0
U1LSR read clears U1LSR[3]. The time of the framing error detection is dependenton 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, itcannot be assumed that the next received byte will be correct even if there is no
Framing Error.

Framing Error(FE)

Note: A framing error is associated with the character at the top of the UART1 RBR
FIFO.

4

0

Framing error status is inactive.

1

Framing error status is active.
When RXD1 is held in the spacing state (all 0’s) for one full character transmission 0(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].

Break Interrupt(BI)

Note: The break interrupt is associated with the character at the top of the UART1RBR FIFO.

5

6

Transmitter
Holding
Register Empty(THRE)
Transmitter
Empty(TEMT)

0

Break interrupt status is inactive.

1

Break interrupt status is active.
THRE is set immediately upon detection of an empty UART1 THR and is cleared on 1
a U1THR write.

0

U1THR contains valid data.

1

U1THR is empty.
TEMT is set when both U1THR and U1TSR are empty; TEMT is cleared wheneither the U1TSR or the U1THR contain valid data.

0

U1THR and/or the U1TSR contains valid data.

1

U1THR and the U1TSR are empty.

UM10161_3

User manual

1© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

115 of 285

UM10161

NXP Semiconductors

Chapter 10: LPC2101/02/03 Universal Asynchronous

Table 113. UART1 Line Status Register (U1LSR - address 0xE001 0014, read only) bit description
Bit Symbol
7

Value Description

Error in RX
FIFO(RXFE)

Reset
value

U1LSR[7] is set when a character with a RX error such as framing error, parity error 0
or break interrupt, is loaded into the U1RBR. This bit is cleared when the U1LSR
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.

3.11 UART1 Modem Status Register (U1MSR - 0xE001 0018)
The U1MSR is a read-only register that provides status information on the modem input
signals. U1MSR[3:0] is cleared on U1MSR read. Note that modem signals have no direct
affect on UART1 operation, they facilitate software implementation of modem signal
operations.
Table 114. UART1 Modem Status Register (U1MSR - address 0xE001 0018) bit description
Bit Symbol
0

1

2

3

Value Description

Delta CTS

Reset value

Set upon state change of input CTS. Cleared on an U1MSR read.
0

No change detected on modem input, CTS.

1State change detected on modem input, CTS.

Delta DSR0

Set upon state change of input DSR. Cleared on an U1MSR read.
0

No change detected on modem input, DSR.

1

State change detected on modem input, DSR.

Trailing Edge RI

0

Set upon LOW to HIGH transition of input RI. Cleared on an U1MSR read.
0

No change detected on modem input, RI.

1

LOW-to-HIGH transition detected on RI.

Delta DCD

Set upon state change of input DCD. Cleared on an U1MSR read.
0

No change detected on modem input, DCD.

1

State change detected on modem input, DCD.

0

0

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
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.

0

3.12 UART1 Scratch Pad Register (U1SCR - 0xE001 001C)
The U1SCR has no effect on the UART1 operation. This register can be written and/or
read at user’s discretion. There is no provision in the interrupt interface that would indicate
to the host that a read or write of the U1SCR has occurred.
Table 115. UART1 Scratch Pad Register (U1SCR - address 0xE001 0014) bit description
Bit

SymbolDescription

Reset value

7:0

Pad

A readable, writable byte.

0x00

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

116 of 285

UM10161

NXP Semiconductors

Chapter 10: LPC2101/02/03 Universal Asynchronous

3.13 UART1 Auto-baud Control Register (U1ACR - 0xE001 0020)
The UART1 Auto-baud Control Register (U1ACR) controls the process of measuring theincoming clock/data rate for the baud rate generation and can be read and written at
user’s discretion.
Table 116. Auto-baud Control Register (U1ACR - 0xE001 0020) bit description
Bit

Symbol

0

Start

1

2

Value Description

Reset value

This bit is automatically cleared after auto-baudcompletion.

00

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-baudcompletion.

Mode

Auto-baud mode select bit.
0Mode 0.

1Mode 1.

AutoRestart 00

No restart0

1

Restart in case of time-out (counter restarts at next
UART1 Rx falling edge)

NA

Reserved, user software should not write ones to0reserved bits. The value read from a reserved bit is notdefined.

7:3

-

8

ABEOIntClr

End of auto-baud interrupt clear bit (write only
accessible). Writing a 1 will clear the corresponding
interrupt in the U1IIR. Writing a 0 has no impact.

09

ABTOIntClr

Auto-baud time-out interrupt clear bit (write only
accessible). Writing a 1 will clear the corresponding
interrupt in the U1IIR. Writing a 0 has no impact.

0

31:10 -

NA

0
Reserved, user software should not write ones toreserved bits. The value read from a reserved bit is notdefined.

3.14 Auto-baud
The UART1 auto-baud function can be used to measure the incoming baud-rate based onthe ”AT" protocol (Hayes command). If enabled the auto-baud feature will measure the bittime 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 theUART1 Rx pin (the falling edge of the start bit and the falling edge of the least significantbit). In mode 1 the baud-rate is measured between the falling edge and the subsequentrising edge of the UART1 Rx pin (the length of the start bit).

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

117 of 285

UM10161

NXP Semiconductors

Chapter 10: LPC2101/02/03 Universal Asynchronous

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 ratemeasurement will restart at the next falling edge of the UART1 Rx pin.
The auto-baud function can generate two interrupts.

• 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).
The auto-baud interrupts have to be cleared by setting the corresponding U1ACRABTOIntClr and ABEOIntEn bits.
Typically the fractional baud-rate generator is disabled (DIVADDVAL = 0) during
auto-baud. However, if the fractional baud-rate generator is enabled (DIVADDVAL > 0), it
is going to impact the measuring of UART1 Rx pin baud-rate, but the value of the U1FDR
register is not going to be modified after rate measurement. Also, when auto-baud is used,
any write to U1DLM and U1DLL registers should be done before U1ACR register write.
The minimum and the maximum baudrates supported by UART1 are function of PCLK,
number of data bits, stop-bits and parity bits.
(4)
2 × P CLK
16 × 2 15

PCLK
16 × ( 2 + databits + paritybits + stopbits )ratemin = ------------------------- ≤ UART 1 baudrate ≤ ------------------------------------------------------------------------------------------------------------ = ratemax

3.15 Auto-baud modes
When the software is expecting an ”AT" command, it configures the UART1 with the
expected character format and sets the U1ACR Start bit. The initial values in the divisor
latches U1DLM and U1DLM don‘t care. Because of the ”A" or ”a" ASCII coding(”A" = 0x41, ”a" = 0x61), the UART1 Rx pin sensed start bit and the LSB of the expectedcharacter are delimited by two falling edges. When the U1ACR Start bit is set, theauto-baud protocol will execute the following phases:
1. On U1ACR Start bit setting, the baud-rate measurement counter is reset and theUART1 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 ratemeasuring counter will start counting PCLK cycles optionally pre-scaled by thefractional baud-rate generator.
3. During the receipt of the start bit, 16 pulses are generated on the RSR baud input withthe 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.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

118 of 285

UM10161

NXP Semiconductors

Chapter 10: LPC2101/02/03 Universal Asynchronous

6. The rate counter is loaded into U1DLM/U1DLL and the baud-rate will be switched tonormal 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 theremaining bits of the ”A/a" character.

'A' (0x41) or 'a' (0x61)
start

bit0

bit1

bit2

bit3

bit4

bit5

bit6

bit7

parity stop

UART1 RXstart bit

LSB of 'A' or 'a'

U1ACR start
rate counter
16xbaud_rate

16 cycles

16 cyclesa. Mode 0 (start bit and LSB are used for auto-baud)'A' (0x41) or 'a' (0x61)
start

bit0

bit1

bit2

bit3

bit4

bit5

bit6

bit7

parity stop

UART1 RXstart bit

LSB of 'A' or 'a'

U1ACR start
rate counter
16xbaud_rate

16 cyclesb. Mode 1 (only start bit is used for auto-baud)
Fig 24. Autobaud a) mode 0 and b) mode 1 waveform

3.16 UART1 Transmit Enable Register (U1TER - 0xE001 0030)
LPC2101/2102/2103’s U1TER enables implementation of software and hardware flow
control. When TXEn=1, UART1 transmitter will keep sending data as long as they areavailable. As soon as TXEn becomes 0, UART1 transmission will stop.
Table 10–117 describes how to use TXEn bit in order to achieve software flow control.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

119 of 285

UM10161

NXP Semiconductors

Chapter 10: LPC2101/02/03 Universal Asynchronous

Table 117. UART1 Transmit Enable Register (U1TER - address 0xE001 0030) bit description
Bit

SymbolDescription

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.

4. 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 theUART1.
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 validcharacter 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 theserial 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.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

120 of 285

UM10161

NXP Semiconductors

Chapter 10: LPC2101/02/03 Universal Asynchronous

MODEM

U1TX

U1THR

CTS
DSR

NTXRDY
U1TSR

TXD1

U1MSR

RI

U1BRG

DCD
DTR
RTS

U1DLL

NBAUDOUT

U1DLM

RCLK

U1MCR

U1RX

NRXRDYINTERRUPTU1RBR
U1INTR

U1RSR

RXD1

U1IER

U1IIR

U1FCR

U1LSR
U1SCR
U1LCR

PA[2:0]PSEL
PSTB
PWRITEAPB
INTERFACE

PD[7:0]

DDIS

AR
MR
PCLK

Fig 25. UART1 block diagram

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

121 of 285

UM10161
Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1
Rev. 3 — 2 October 2008

User manual

1. Features• Standard I2C compliant bus interfaces may be configured as Master, Slave, orMaster/Slave.

• Arbitration is handled between simultaneously transmitting masters without corruptionof serial data on the bus.

• Programmable clock allows adjustment of I2C transfer rates.
• Data transfer is bidirectional between masters and slaves.
• Serial clock synchronization allows devices with different bit rates to communicate via
one serial bus.

• Serial clock synchronization is used as a handshake mechanism to suspend andresume serial transfer.

• I2C-bus can be used for test and diagnostic purposes.

2. Applications
Interfaces to external I2C standard parts, such as serial RAMs, LCDs, tone generators,
etc.

3. Description
A typical I2C-bus configuration is shown in Figure 11–26. Depending on the state of thedirection 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 thelast received byte, a “not acknowledge” is returned. The master device generates allof 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 bereleased.
The LPC2101/02/03 I2C interfaces are byte oriented and have four operating modes:
master transmitter mode, master receiver mode, slave transmitter mode and slave
receiver mode.
The I2C interfaces comply with the entire I2C specification, supporting the ability to turnpower off to the LPC2101/02/03 without interfering with other devices on the same
I2C-bus.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

122 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

pull-upresistorpull-upresistor

SDA
I 2C bus
SCL

SDA

SCL

LPC2101/02/03

OTHER DEVICE WITH
I 2C INTERFACEOTHER DEVICE WITH
I 2C INTERFACE

Fig 26. I2C-bus configuration

4. Pin description
Table 118. I2C Pin Description
Pin

Type

Description

SDA0,1

Input/Output

I2C Serial Data.

SCL0,1

Input/Output

I2C Serial Clock.

5. I2C operating modes
In a given application, the I2C block may operate as a master, a slave, or both. In the slavemode, the I2C hardware looks for its own slave address and the general call address. If
one of these addresses is detected, an interrupt is requested. If the processor wishes tobecome the bus master, the hardware waits until the bus is free before the master mode isentered so that a possible slave operation is not interrupted. If bus arbitration is lost in themaster mode, the I2C block switches to the slave mode immediately and can detect its
own slave address in the same serial transfer.

5.1 Master Transmitter mode
In this mode data is transmitted from master to slave. Before the master transmitter modecan be entered, the I2CONSET register must be initialized as shown in Table 11–119.
I2EN must be set to 1 to enable the I2C function. If the AA bit is 0, the I2C interface will not
acknowledge any address when another device is master of the bus, so it can not enter
slave mode. The STA, STO and SI bits must be 0. The SI Bit is cleared by writing 1 to the
SIC bit in the I2CONCLR register.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

123 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

Table 119. I2C0CONSET and I2C1CONSET used to configure Master mode
Bit

7

6

5

4

3

2

1

0

Symbol

-

I2EN

STA

STO

SI

AA

-

-

Value

-

1

0

0

0

0

-

-

The first byte transmitted contains the slave address of the receiving device (7 bits) andthe 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 istransmitted 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 serialtransfer.
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 bywriting a 1 to the SIC bit in the I2CONCLR register.
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 11–134 to Table 11–137.

S

SLAVE ADDRESS

RW

A

DATA

“0” - Write“1” - Read

A

A/A

DATA

P

Data Transferred(n Bytes + Acknowledge)
A = Acknowledge (SDA low)

From Master to Slave

A = Not acknowledge (SDA high)From Slave to MasterS = START Condition
P = STOP ConditionFig 27. Format in the Master Transmitter mode

5.2 Master Receiver mode
In the master receiver mode, data is received from a slave transmitter. The transfer is
initiated in the same way as in the master transmitter mode. When the START condition
has been transmitted, the interrupt service routine must load the slave address and thedata direction bit to the I2C Data register (I2DAT), and then clear the SI bit. In this case,the data direction bit (R/W) should be 1 to indicate a read.
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 thestatus 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 toTable 11–135.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

124 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1SSLAVE ADDRESS

R

A

DATA

A

“0” - Write“1” - Read

A

DATA

P

Data Transferred(n Bytes + Acknowledge)
A = Acknowledge (SDA low)

From Master to Slave

A = Not acknowledge (SDA high)From Slave to MasterS = START Condition
P = STOP ConditionFig 28. Format of Master Receiver mode

After a repeated START condition, I2C may switch to the master transmitter mode.

S

SLA

R

A

DATA

A

DATA

A

RS

SLA

W

A

DATA

A

P

Data Transferred(n Bytes + Acknowledge)
A = Acknowledge (SDA low)
From Master to Slave

A = Not acknowledge (SDA high)From Slave to MasterS = START Condition
P = STOP Condition
SLA = Slave AddressFig 29. A Master Receiver switches to Master Transmitter after sending repeated START

5.3 Slave Receiver mode
In the slave receiver mode, data bytes are received from a master transmitter. To initialize
the slave receiver mode, user write the Slave Address register (I2ADR) and write the I2C
Control Set register (I2CONSET) as shown in Table 11–120.
Table 120. I2C0CONSET and I2C1CONSET used to configure Slave mode
Bit

7

6

5

4

3

2

1

0

Symbol

-

I2EN

STA

STO

SI

AA

-

-

Value

-

1

0

0

0

1

-

-

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 byits 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 transmittermode. 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 11–136 for the
status codes and actions.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

125 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1SSLAVE ADDRESS

W

A

DATA

“0” - Write“1” - Read

A

A/A

DATA

P/RS

Data Transferred(n Bytes + Acknowledge)
A = Acknowledge (SDA low)

From Master to Slave
From Slave to Master

A = Not acknowledge (SDA high)S = START Condition
P = STOP Condition
RS = Repeated START condition

Fig 30. Format of Slave Receiver mode

5.4 Slave Transmitter mode
The first byte is received and handled as in the slave receiver mode. However, in thismode, the direction bit will be 1, indicating a read operation. Serial data is transmitted via
SDA while the serial clock is input through SCL. START and STOP conditions arerecognized as the beginning and end of a serial transfer. In a given application, I2C may
operate as a master and as a slave. In the slave mode, the I2C hardware looks for its own
slave address and the general call address. If one of these addresses is detected, aninterrupt is requested. When the microcontrollers wishes to become the bus master, thehardware waits until the bus is free before the master mode is entered so that a possible
slave action is not interrupted. If bus arbitration is lost in the master mode, the I2C
interface switches to the slave mode immediately and can detect its own slave address inthe same serial transfer.

S

SLAVE ADDRESSR

A“0” - Write“1” - Read

DATA

A

A

DATA

P

Data Transferred(n Bytes + Acknowledge)
A = Acknowledge (SDA low)

From Master to Slave

A = Not acknowledge (SDA high)From Slave to MasterS = START Condition
P = STOP Condition

Fig 31. Format of Slave Transmitter mode

6. I2C implementation and operation
Figure 11–32 shows how the on-chip I2C-bus interface is implemented, and the following
text describes the individual blocks.

6.1 Input filters and output stages
Input signals are synchronized with the internal clock, and spikes shorter than threeclocks are filtered out.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

126 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

The output for I2C is a special pad designed to conform to the I2C specification.

8

I2ADR

ADDRESS REGISTERCOMPARATORINPUTFILTERSDA
OUTPUTSTAGE

SHIFT REGISTER

ACK
I2DAT

BIT COUNTER/
ARBITRATION &SYNC LOGICINPUTFILTERPCLK

APB BUS8

TIMING &CONTROLLOGICSCLOUTPUT
STAGE

I2CONSETI2CONCLR
I2SCLHI2SCLL

interrupt

SERIAL CLOCK
GENERATORCONTROL REGISTER & SCL DUTYCYCLE REGISTERS

16

statusbus

STATUSDECODERSTATUS REGISTERI2STAT8

Fig 32. I2C serial interface block diagram
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

127 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

6.2 Address Register, I2ADDRThis register may be loaded with the 7-bit slave address (7 most significant bits) to which
the I2C block will respond when programmed as a slave transmitter or receiver. The LSB(GC) is used to enable general call address (0x00) recognition.

6.3 Comparator
The comparator compares the received 7-bit slave address with its own slave address (7most significant bits in I2ADR). It also compares the first received 8-bit byte with thegeneral call address (0x00). If an equality is found, the appropriate status bits are set andan interrupt is requested.

6.4 Shift register, I2DATThis 8-bit register contains a byte of serial data to be transmitted or a byte which has justbeen received. Data in I2DAT is always shifted from right to left; the first bit to betransmitted is the MSB (bit 7) and, after a byte has been received, the first bit of received
data is located at the MSB of I2DAT. While data is being shifted out, data on the bus issimultaneously being shifted in; I2DAT always contains the last byte present on the bus.
Thus, in the event of lost arbitration, the transition from master transmitter to slave
receiver is made with the correct data in I2DAT.

6.5 Arbitration and synchronization logic
In the master transmitter mode, the arbitration logic checks that every transmitted logic 1
actually appears as a logic 1 on the I2C-bus. If another device on the bus overrules a logic
1 and pulls the SDA line low, arbitration is lost, and the I2C block immediately changes
from master transmitter to slave receiver. The I2C block will continue to output clock
pulses (on SCL) until transmission of the current serial byte is complete.
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 canoccur only at the end of a serial byte, the I2C block generates no further clock pulses.
Figure 11–33 shows the arbitration procedure.

(1)

(1)

(2)

1

2

3

(3)

SDA line

SCL line

4

8

9
ACK

(1) Another device transmits serial data.
(2) Another device overrules a logic (dotted line) transmitted this I2C master by pulling the SDA line
low. Arbitration is lost, and this I2C enters Slave Receiver mode.
(3) This I2C is in Slave Receiver mode but still generates clock pulses until the current byte has beentransmitted. This I2C will not generate clock pulses for the next byte. Data on SDA originates fromthe new master once it has won arbitration.

Fig 33. Arbitration procedure

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

128 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

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,” andthe “space” duration is determined by the device that generates the longest “spaces”.
Figure 11–34 shows the synchronization procedure.

SDA Line
(1)

(3)

(1)

SCL Line(2)
highperiodlow
period(1) Another device pulls the SCL line low before this I2C has timed a complete high time. The otherdevice effectively determines the (shorter) HIGH period.
(2) Another device continues to pull the SCL line low after this I2C has timed a complete low time andreleased SCL. The I2C clock generator is forced to wait until SCL goes HIGH. The other device
effectively determines the (longer) LOW period.
(3) The SCL line is released , and the clock generator begins timing the HIGH time.

Fig 34. Serial clock synchronization

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 serialinterrupt flag (SI) is set, and the stretching continues until the serial interrupt flag iscleared.

6.6 Serial clock generator
This programmable clock pulse generator provides the SCL clock pulses when the I2C
block is in the master transmitter or master receiver mode. It is switched off when the I2C
block is in a slave mode. The I2C output clock frequency and duty cycle is programmable
via the I2C Clock Control Registers. See the description of the I2CSCLL and I2CSCLH
registers for details. The output clock pulses have a duty cycle as programmed unless thebus is synchronizing with other SCL clock sources as described above.

6.7 Timing and control
The timing and control logic generates the timing and control signals for serial byte
handling. This logic block provides the shift pulses for I2DAT, enables the comparator,
generates and detects start and stop conditions, receives and transmits acknowledge bits,
controls the master and slave modes, contains interrupt request logic, and monitors the
I2C-bus status.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

129 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

6.8 Control register, I2CONSET and I2CONCLR
The I2C control register contains bits used to control the following I2C block functions: startand restart of a serial transfer, termination of a serial transfer, bit rate, address recognition,
and acknowledgment.
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 correspondto ones in the value written.

6.9 Status decoder and status register
The status decoder takes all of the internal status bits and compresses them into a 5-bit
code. This code is unique for each I2C-bus status. The 5-bit code may be used togenerate vector addresses for fast processing of the various service routines. Each
service routine processes a particular bus status. There are 26 possible bus states if all
four modes of the I2C block are used. The 5-bit status code is latched into the five mostsignificant bits of the status register when the serial interrupt flag is set (by hardware) andremains stable until the interrupt flag is cleared by software. The three least significant bitsof 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 issufficient for most of the service routines (see the software example in this section).

7. Register description
Each I2C interface contains 7 registers as shown in Table 11–121 below.
Table 121. I2C register map
Name

Access Reset
I2C0 Address I2C1 Address
value[1] and Name
and Name

Description

I2CONSET I2C Control Set Register. When a one is written to a bitof this register, the corresponding bit in the I2C control
register is set. Writing a zero has no effect on thecorresponding bit in the I2C control register.

R/W

0x00

0xE001 C000 0xE005 C000
I2C0CONSET I2C1CONSETI2STATI2C Status Register. During I2C operation, this register
provides detailed status codes that allow software to
determine the next action needed.

RO

0xF8

0xE001 C004
I2C0STAT

0xE005 C004
I2C1STATI2DATI2C Data Register. During master or slave transmit
R/Wmode, data to be transmitted is written to this register.
During master or slave receive mode, data that has been
received may be read from this register.

0x00

0xE001 C008
I2C0DAT

0xE005 C008
I2C1DATI2ADR

I2C Slave Address Register. Contains the 7-bit slave
address for operation of the I2C interface in slave mode,
and is not used in master mode. The least significant bit
determines whether a slave responds to the general calladdress.

0x00

0xE001 C00C
I2C0ADR

0xE005 C00CI2C1ADR

R/W

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

130 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

Table 121. I2C register map
Name

Description

Access Reset
I2C0 Address I2C1 Address
value[1] and Name
and Name

I2SCLHSCH Duty Cycle Register High Half Word. Determines
the high time of the I2C clock.

R/W

0x04

0xE001 C010
I2C0SCLH

0xE005 C010
I2C1SCLH

I2SCLLSCL Duty Cycle Register Low Half Word. Determines
the low time of the I2C clock. I2nSCLL and I2nSCLH
together determine the clock frequency generated by an
I2C master and certain times used in slave mode.

R/W

0x04

0xE001 C014
I2C0SCLL

0xE005 C014
I2C1SCLLNA

0xE001 C018 0xE005 C018
I2C0CONCLR I2C1CONCLR

I2CONCLR I2C Control Clear Register. When a one is written to a
WO
bit of this register, the corresponding bit in the I2C control
register is cleared. Writing a zero has no effect on thecorresponding bit in the I2C control register.
[1]

Reset value reflects the data stored in used bits only. It does not include reserved bits content.

7.1 I2C Control Set register (I2CONSET: I2C0, I2C0CONSET - 0xE001 C000
and I2C1, I2C1CONSET - 0xE005 C000)
The I2CONSET registers control setting of bits in the I2CON register that controls
operation of the I2C interface. Writing a one to a bit of this register causes thecorresponding bit in the I2C control register to be set. Writing a zero has no effect.
Table 122. I2C Control Set register (I2CONSET: I2C0, I2C0CONSET - address 0xE001 C000
and I2C1, I2C1CONSET - address 0xE005 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.

3SI

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 becleared 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 “notaddressed” 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, theI2C-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 andtransmit a START condition or transmit a repeated START condition if it is already inmaster mode.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

131 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

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 isalready 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 is0, 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 theinterface 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 iscleared 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 thatcase.
While SI is set, the low period of the serial clock on the SCL line is stretched, and theserial 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:
1. The address in the Slave Address Register has been received.
2. The general call address has been received while the general call bit (GC) in I2ADR is
set.
3. A data byte has been received while the I2C is in the master receiver mode.
4. A data byte has been received while the I2C is in the addressed slave receiver mode
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.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

132 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

7.2 I2C Control Clear register (I2CONCLR: I2C0, I2C0CONCLR 0xE001 C018 and I2C1, I2C1CONCLR - 0xE005 C018)
The I2CONCLR registers control clearing of bits in the I2CON register that controls
operation of the I2C interface. Writing a one to a bit of this register causes thecorresponding bit in the I2C control register to be cleared. Writing a zero has no effect.
Table 123. I2C Control Set register (I2CONCLR: I2C0, I2C0CONCLR - address 0xE001 C018
and I2C1, I2C1CONCLR - address 0xE005 C018) bit description
Bit Symbol

Description

Reset
value

1:0 -

Reserved. User software should not write ones to reserved bits. The
value read from a reserved bit is not defined.

NA

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
value read from a reserved bit is not defined.

NA

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
value read from a reserved bit is not defined.

NA

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.

7.3 I2C Status register (I2STAT: I2C0, I2C0STAT - 0xE001 C004 and I2C1,
I2C1STAT - 0xE005 C004)
Each I2C Status register reflects the condition of the corresponding I2C interface. The I2C
Status register is Read-Only.
Table 124. I2C Status register (I2STAT: I2C0, I2C0STAT - address 0xE001 C004 and I2C1,
I2C1STAT - address 0xE005 C004) 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 11–134 toTable 11–137.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

133 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

7.4 I2C Data register (I2DAT: I2C0, I2C0DAT - 0xE001 C008 and I2C1,
I2C1DAT - 0xE005 C008)
This register contains the data to be transmitted or the data just received. The CPU canread and write to this register only while it is not in the process of shifting a byte, when the
SI bit is set. Data in I2DAT remains stable as long as the SI bit is set. Data in I2DAT isalways shifted from right to left: the first bit to be transmitted is the MSB (bit 7), and after abyte has been received, the first bit of received data is located at the MSB of I2DAT.
Table 125. I2C Data register (I2DAT: I2C0, I2C0DAT - address 0xE001 C008 and I2C1, I2C1DAT- address 0xE005 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.

7.5 I2C Slave Address register (I2ADR: I2C0, I2C0ADR - 0xE001 C00C andI2C1, I2C1ADR - address 0xE005 C00C)
These registers are readable and writable, and is only used when an I2C interface is set toslave mode. In master mode, this register has no effect. The LSB of I2ADR is the generalcall bit. When this bit is set, the general call address (0x00) is recognized.
Table 126. I2C Slave Address register (I2ADR: I2C0, I2C0ADR - address 0xE001 C00C andI2C1, I2C1ADR - address 0xE005 C00C) bit description
Bit Symbol

Description

Reset value

0

General Call enable bit.

0

The I2C device address for slave mode.

0x00

GC

7:1 Address

7.6 I2C SCL HIGH duty cycle register (I2SCLH: I2C0, I2C0SCLH 0xE001 C010 and I2C1, I2C1SCLH - 0xE0015 C010)
Table 127. I2C SCL HIGH Duty Cycle register (I2SCLH: I2C0, I2C0SCLH - address
0xE001 C010 and I2C1, I2C1SCLH - address 0xE005 C010) bit description
Bit

SymbolDescription

Reset value

15:0

SCLH

Count for SCL HIGH time period selection.

0x0004

7.7 I2C SCL Low duty cycle register (I2SCLL: I2C0 - I2C0SCLL:
0xE001 C014; I2C1 - I2C1SCLL: 0xE0015 C014)
Table 128. I2C SCL Low Duty Cycle register (I2SCLL: I2C0, I2C0SCLL - address 0xE001 C014
and I2C1, I2C1SCLL - address 0xE005 C014) bit description
Bit

SymbolDescription

Reset value

15:0

SCLL

Count for SCL low time period selection.

0x0004

7.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 isdetermined by the following formula (PCLK is the frequency of the peripheral bus APB):

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

134 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

(5)

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 rangeof 0 through 400 kHz. Each register value must be greater than or equal to 4.
Table 11–129 gives some examples of I2C-bus rates based on PCLK frequency and
I2SCLL and I2SCLH values.
Table 129. Example I2C clock rates
I2C Bit Frequency (kHz) at PCLK (MHz)I2SCLL +I2SCLH

1

8

125

10

100

25

5

10

16

20

40

200

400

50

20

100

100

10

50

160

6.25

200

40

60

200

320

400

100

160

200

400

31.25

62.5

100

125

250

375

5

25

50

80

100

200

300

400

2.5

12.5

25

40

50

100

150

800

1.25

6.25

12.5

20

25

50

75

8. Details of I2C operating modes
The four operating modes are:• Master Transmitter• Master Receiver• Slave Receiver• Slave Transmitter
Data transfers in each mode of operation are shown in Figure 11–35, Figure 11–36,
Figure 11–37, Figure 11–38, and Figure 11–39. Table 11–130 lists abbreviations used inthese figures when describing the I2C operating modes.
Table 130. Abbreviations used to describe an I2C operation
Abbreviation

Explanation

S

Start Condition

SLA

7-bit slave address

R

Read bit (HIGH level at SDA)W

Write bit (LOW level at SDA)

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

135 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

Table 130. Abbreviations used to describe an I2C operation
Abbreviation

Explanation

A

Acknowledge bit (LOW level at SDA)A

Not acknowledge bit (HIGH level at SDA)

Data

8-bit data byte

P

Stop condition

In Figure 11–35 to Figure 11–39, circles are used to indicate when the serial interrupt flagis 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 serialtransfer. 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 tothe appropriate service routine. For each status code, the required software action anddetails of the following serial transfer are given in tables from Table 11–134 toTable 11–138.

8.1 Master Transmitter mode
In the master transmitter mode, a number of data bytes are transmitted to a slave receiver(see Figure 11–35). Before the master transmitter mode can be entered, I2CON must be
initialized as follows:
Table 131. I2CONSET used to initialize Master Transmitter mode
Bit

7

6

5

4

3

2

1

0

Symbol

-

I2EN

STA

STO

SI

AA

-

-

Value

-

1

0

0

0

x

-

-

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 anotherdevice 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 theslave 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 anumber 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 inTable 11–134. After a repeated start condition (state 0x10). The I2C block may switch tothe master receiver mode by loading I2DAT with SLA+R).

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

136 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

8.2 Master Receiver mode
In the master receiver mode, a number of data bytes are received from a slave transmitter(see Figure 11–36). The transfer is initialized as in the master transmitter mode. When thestart condition has been transmitted, the interrupt service routine must load I2DAT with the
7-bit slave address and the data direction bit (SLA+R). The SI bit in I2CON must then becleared before the serial transfer can continue.
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 anumber 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 11–135.
After a repeated start condition (state 0x10), the I2C block may switch to the mastertransmitter mode by loading I2DAT with SLA+W.

8.3 Slave Receiver mode
In the slave receiver mode, a number of data bytes are received from a master transmitter(see Figure 11–37). To initiate the slave receiver mode, I2ADR and I2CON must be
loaded as follows:
Table 132. I2C0ADR and I2C1ADR usage in Slave Receiver mode
Bit

7

6

5

Symbol4

32

1

own slave 7-bit address

0GC

The upper 7 bits are the address to which the I2C block will respond when addressed by amaster. If the LSB (GC) is set, the I2C block will respond to the general call address(0x00); otherwise it ignores the general call address.
Table 133. I2C0CONSET and I2C1CONSET used to initialize Slave Receiver mode
Bit

7

6

5

4

3

2

1

0

Symbol

-

I2EN

STA

STO

SI

AA

-

-

Value

-

1

0

0

0

1

-

-

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 byits 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 readfrom I2STAT. This status code is used to vector to a state service routine. The appropriate
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 mastermode (see status 0x68 and 0x78).

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

137 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

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 stillmonitored and address recognition may be resumed at any time by setting AA. Thismeans that the AA bit may be used to temporarily isolate the I2C block from the I2C-bus.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

138 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

MT
Successfultransmission
to a Slave
Receiver

S

SLA

W

A

DATA

A

18H

08H

P

28H

Next transfer
started with a
Repeated Start
condition

S

SLA

W

10H

Not
Acknowledge
received after
the Slave
Address

A

P

R

20H

Not
Acknowledge
received after a
Data byteAP

To Master
receive
mode,
entry
= MR

30H

Arbitration lostin Slave
Address orData byte

A OR A

Other Master
continues

A OR A

38H

Arbitration lostandaddressed as
Slave

A

Other Master
continues

38H

Other Master
continues

68H 78H B0H

To corresponding
states in Slave mode

From Master to Slave

From Slave to Master

DATA

n

Any number of data bytes and their associated Acknowledge bits

This number (contained in I2STA) corresponds to a defined state of the
I2C busFig 35. Format and states in the Master Transmitter mode

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

139 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

MR

Successfultransmission toa Slave
Transmitter

S

08H

SLA

R

A

DATA

40H

A

DATA

50H

A

P

58H

Next transfer
started with a
Repeated Start
condition

S

SLA

R

10H
Not Acknowledge
received after the
Slave Address

A

P

W

48H
To Mastertransmit
mode, entry= MT

Arbitration lost in
Slave Address or
Acknowledge bit

Other Master
continues

A OR A

38H

Arbitration lostand addressedas Slave

A

A

Other Master
continues

38H

Other Master
continues

68H 78H B0H

To
corresponding
states in Slave
mode

From Master to Slave

From Slave to Master

DATA

n

A

Any number of data bytes and their associatedAcknowledge bits
This number (contained in I2STA) corresponds to a defined state of
the I2C bus

Fig 36. Format and states in the Master Receiver mode

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

140 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

Reception of the own
Slave Address and one
or more Data bytes all
are acknowledged

S

SLA

R

A

DATA

60H

A

DATA

80H

Last data byte
received is Not
Acknowledged

A

P OR S

80H

A0H

A

P OR S

88H
Arbitration lost as
Master and addressedas SlaveA

68H

Reception of theGeneral Call address
and one or more Data
bytes

GENERAL CALL

A

DATA

70h

A

DATA

90h

Last data byte is Not
Acknowledged

A

P OR S

90h

A0H

A

P OR S

98h
Arbitration lost as
Master and addressedas Slave by General
Call

A

78h

From Master to Slave

From Slave to Master

DATA

n

A

Any number of data bytes and their associated Acknowledge bits

This number (contained in I2STA) corresponds to a defined state of the
I 2C bus

Fig 37. Format and states in the Slave Receiver mode

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

141 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

Reception of the own
Slave Address andone or more Data
bytes all are
Acknowledged

S

SLA

R

A

DATA

A8H

Arbitration lost as
Master andaddressed as Slave

A

B8H

DATA

A

P OR S

C0H

A

B0H

Last data byte
transmitted. Switchedto Not Addressed
Slave (AA bit in
I2CON = “0”)A

ALL ONES

P OR S

C8H

From Master to Slave

From Slave to Master

DATA

n

A

Any number of data bytes and their associatedAcknowledge bits

This number (contained in I2STA) corresponds to a defined state of
the I2C bus

Fig 38. Format and states in the Slave Transmitter mode

8.4 Slave Transmitter mode
In the slave transmitter mode, a number of data bytes are transmitted to a master receiver(see Figure 11–38). Data transfer is initialized as in the slave receiver mode. 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 “1” (R) for the I2C block tooperate in the slave transmitter mode. After its own slave address and the R bit have been
received, the serial interrupt flag (SI) is set and a valid status code can be read fromI2STAT. This status code is used to vector to a state service routine, and the appropriate
action to be taken for each of these status codes is detailed in Table 11–137. The slavetransmitter mode may also be entered if arbitration is lost while the I2C block is in themaster mode (see state 0xB0).
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 receiverreceives 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, andaddress 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.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

142 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

Table 134. Master Transmitter mode
StatusStatus of the I2C-bus Application software responseCodeand hardware
To/From I2DATTo I2CON(I2CSTAT)STA STO SI

AA

0x08

A START condition
Load SLA+W
has been transmitted.

X

0x10

A repeated START
condition has beentransmitted.

Load SLA+W or

X

0

0

X

As above.

Load SLA+R

X

0

0

X

SLA+W will be transmitted; the I2C block
will be switched to MST/REC mode.

SLA+W has beentransmitted; ACK has
been received.

Load data byte or

0

0

0

X

Data byte will be transmitted; ACK bit will
be received.

No I2DAT action
or

1

0

0

X

Repeated START will be transmitted.

No I2DAT action
or

0

1

0

X

STOP condition will be transmitted; STO
flag will be reset.

No I2DAT action

1

1

0

X

STOP condition followed by a START
condition will be transmitted; STO flag will
be reset.

Load data byte or
SLA+W has beentransmitted; NOT ACK
has been received.
No I2DAT action
or

0

0

0

X

Data byte will be transmitted; ACK bit will
be received.

1

0

0

X

Repeated START will be transmitted.

No I2DAT action
or

0

1

0

X

STOP condition will be transmitted; STO
flag will be reset.

No I2DAT action

1

1

0

X

STOP condition followed by a START
condition will be transmitted; STO flag will
be reset.

Load data byte or
Data byte in I2DAT
has been transmitted;
ACK has been
No I2DAT action
received.
or

0

0

0

X

Data byte will be transmitted; ACK bit will
be received.

1

0

0

X

Repeated START will be transmitted.

No I2DAT action
or

0

1

0

X

STOP condition will be transmitted; STO
flag will be reset.

No I2DAT action

1

1

0

X

STOP condition followed by a START
condition will be transmitted; STO flag will
be reset.

Load data byte or
Data byte in I2DAT
has been transmitted;
NOT ACK has been
No I2DAT action
received.
or

0

0

0

X

Data byte will be transmitted; ACK bit will
be received.

1

0

0

X

Repeated START will be transmitted.

No I2DAT action
or

0

1

0

X

STOP condition will be transmitted; STO
flag will be reset.

No I2DAT action

1

1

0

X

STOP condition followed by a START
condition will be transmitted; STO flag will
be reset.

No I2DAT action
or

0

0

0

X

I2C-bus will be released; not addressedslave will be entered.

No I2DAT action

1

0

0

X

A START condition will be transmitted
when the bus becomes free.

0x18

0x20

0x28

0x30

0x38

Arbitration lost in
SLA+R/W or Data
bytes.

X

0

0

UM10161_3

User manual

Next action taken by I2C hardware

SLA+W will be transmitted; ACK bit will
be received.

© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

143 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

Table 135. Master Receiver mode
StatusStatus of the I2C-bus Application software responseCodeand hardware
To/From I2DATTo I2CON(I2CSTAT)STA STO SI

AA

0x08

A START condition
Load SLA+R
has been transmitted.

X

0

0

X

SLA+R will be transmitted; ACK bit will bereceived.

0x10

A repeated START
condition has beentransmitted.

Load SLA+R or

X

0

0

X

As above.

Load SLA+W

X

0

0

X

SLA+W will be transmitted; the I2C block
will be switched to MST/TRX mode.

Arbitration lost in NOT No I2DAT action
ACK bit.
or

0

0

0

X

I2C-bus will be released; the I2C block willenter a slave mode.

No I2DAT action

1

0

0

X

A START condition will be transmitted
when the bus becomes free.

No I2DAT action
or

0

0

0

0

Data byte will be received; NOT ACK bit
will be returned.

No I2DAT action

0

0

0

1

Data byte will be received; ACK bit will be
returned.

SLA+R has been
No I2DAT action
transmitted; NOT ACK or
has been received.
No I2DAT action
or

1

0

0

X

Repeated START condition will betransmitted.

0

1

0

X

STOP condition will be transmitted; STO
flag will be reset.

No I2DAT action

1

1

0

X

STOP condition followed by a START
condition will be transmitted; STO flag will
be reset.

Data byte has been
received; ACK has
been returned.

Read data byte or 0

0

0

0

Data byte will be received; NOT ACK bit
will be returned.

Read data byte

0

0

0

1

Data byte will be received; ACK bit will be
returned.

Data byte has been
received; NOT ACK
has been returned.

Read data byte or 1

0

0

X

Repeated START condition will betransmitted.

Read data byte or 0

1

0

X

STOP condition will be transmitted; STO
flag will be reset.

Read data byte

1

0

X

STOP condition followed by a START
condition will be transmitted; STO flag will
be reset.

0x38

0x40

0x48

0x50

0x58

SLA+R has beentransmitted; ACK has
been received.

1

UM10161_3

User manual

Next action taken by I2C hardware© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

144 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

Table 136. Slave Receiver mode
StatusStatus of the I2C-bus Application software responseCodeand hardware
To/From I2DATTo I2CON(I2CSTAT)STA STO SI

AA

0x60

0x68

0x70

0x78

0x80

0x88

0x90

Own SLA+W has
been received; ACK
has been returned.

No I2DAT action
or

X

0

0

0

Data byte will be received and NOT ACK
will be returned.

No I2DAT action

X

0

0

1

Data byte will be received and ACK will
be returned.

Arbitration lost in
SLA+R/W as master;Own SLA+W has
been received, ACK
returned.

No I2DAT action
or

X

0

0

0

Data byte will be received and NOT ACK
will be returned.

No I2DAT action

X

0

0

1

Data byte will be received and ACK will
be returned.

General call address(0x00) has been
received; ACK has
been returned.

No I2DAT action
or

X

0

0

0

Data byte will be received and NOT ACK
will be returned.

No I2DAT action

X

0

0

1

Data byte will be received and ACK will
be returned.

Arbitration lost in
SLA+R/W as master;
General call address
has been received,
ACK has beenreturned.

No I2DAT action
or

X

0

0

0

Data byte will be received and NOT ACK
will be returned.

No I2DAT action

X

0

0

1

Data byte will be received and ACK will
be returned.

Previously addressedwith own SLV
address; DATA has
been received; ACK
has been returned.

Read data byte or X

0

0

0

Data byte will be received and NOT ACK
will be returned.

Read data byte

X

0

0

1

Data byte will be received and ACK will
be returned.

Previously addressedwith own SLA; DATA
byte has been
received; NOT ACK
has been returned.

Read data byte or 0

0

0

0

Switched to not addressed SLV mode; norecognition of own SLA or General calladdress.

Read data byte or 0

0

0

1

Switched to not addressed SLV mode;
Own SLA will be recognized; General calladdress will be recognized if
I2ADR[0] = logic 1.

Read data byte or 1

0

0

0

Switched to not addressed SLV mode; norecognition of own SLA or General calladdress. A START condition will betransmitted when the bus becomes free.

Read data byte

1

0

0

1

Switched to not addressed SLV mode;
Own SLA will be recognized; General calladdress will be recognized if
I2ADR[0] = logic 1. A START condition
will be transmitted when the bus becomes
free.

Read data byte or X

0

0

0

Data byte will be received and NOT ACK
will be returned.

Read data byte

0

0

1

Data byte will be received and ACK will
be returned.

Previously addressedwith General Call;
DATA byte has been
received; ACK has
been returned.

X

UM10161_3

User manual

Next action taken by I2C hardware© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

145 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

Table 136. Slave Receiver mode
StatusStatus of the I2C-bus Application software responseCodeand hardware
To/From I2DATTo I2CON(I2CSTAT)STA STO SI

AA

0x98

0xA0

Previously addressedwith General Call;
DATA byte has been
received; NOT ACK
has been returned.

A STOP condition or
repeated START
condition has been
received while still
addressed as
SLV/REC or
SLV/TRX.

Read data byte or 0

0

0

0

Switched to not addressed SLV mode; norecognition of own SLA or General calladdress.

Read data byte or 0

0

0

1

Switched to not addressed SLV mode;
Own SLA will be recognized; General calladdress will be recognized if
I2ADR[0] = logic 1.

Read data byte or 1

0

0

0

Switched to not addressed SLV mode; norecognition of own SLA or General calladdress. A START condition will betransmitted when the bus becomes free.

Read data byte

1

0

0

1

Switched to not addressed SLV mode;
Own SLA will be recognized; General calladdress will be recognized if
I2ADR[0] = logic 1. A START condition
will be transmitted when the bus becomesfree.

No STDAT action
or

0

0

0

0

Switched to not addressed SLV mode; norecognition of own SLA or General calladdress.

No STDAT action
or

0

0

0

1

Switched to not addressed SLV mode;
Own SLA will be recognized; General calladdress will be recognized if
I2ADR[0] = logic 1.

No STDAT action
or

1

0

0

0

Switched to not addressed SLV mode; norecognition of own SLA or General calladdress. A START condition will betransmitted when the bus becomes free.

No STDAT action

1

0

0

1

Switched to not addressed SLV mode;
Own SLA will be recognized; General calladdress will be recognized if
I2ADR[0] = logic 1. A START condition
will be transmitted when the bus becomes
free.

UM10161_3

User manual

Next action taken by I2C hardware© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

146 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

Table 137. Slave Transmitter mode
StatusStatus of the I2C-bus Application software responseCodeand hardware
To/From I2DATTo I2CON(I2CSTAT)STA STO SI

AA

0xA8

0xB0

0xB8

0xC0

0xC8

Own SLA+R has been Load data byte orreceived; ACK has
been returned.
Load data byte

X

0

0

0

Last data byte will be transmitted and
ACK bit will be received.

X

0

0

1

Data byte will be transmitted; ACK will bereceived.

X

0

0

0

Last data byte will be transmitted and
ACK bit will be received.

X

0

0

1

Data byte will be transmitted; ACK bit will
be received.

X

0

0

0

Last data byte will be transmitted and
ACK bit will be received.

X

0

0

1

Data byte will be transmitted; ACK bit will
be received.

No I2DAT action
Data byte in I2DAT
has been transmitted; or
NOT ACK has been
received.
No I2DAT action
or

0

0

0

0

Switched to not addressed SLV mode; norecognition of own SLA or General calladdress.

0

0

0

1

Switched to not addressed SLV mode;
Own SLA will be recognized; General calladdress will be recognized if
I2ADR[0] = logic 1.

No I2DAT action
or

1

0

0

0

Switched to not addressed SLV mode; norecognition of own SLA or General calladdress. A START condition will betransmitted when the bus becomes free.

No I2DAT action

1

0

0

1

Switched to not addressed SLV mode;
Own SLA will be recognized; General calladdress will be recognized if
I2ADR[0] = logic 1. A START condition
will be transmitted when the bus becomesfree.

No I2DAT action
or

0

0

0

0

Switched to not addressed SLV mode; norecognition of own SLA or General calladdress.

No I2DAT action
or

0

0

0

1

Switched to not addressed SLV mode;
Own SLA will be recognized; General calladdress will be recognized if
I2ADR[0] = logic 1.

No I2DAT action
or

1

0

0

0

Switched to not addressed SLV mode; norecognition of own SLA or General calladdress. A START condition will betransmitted when the bus becomes free.

No I2DAT action

1

0

0

01

Switched to not addressed SLV mode;
Own SLA will be recognized; General calladdress will be recognized if
I2ADR.0 = logic 1. A START condition willbe transmitted when the bus becomes
free.

Arbitration lost in
Load data byte or
SLA+R/W as master;Own SLA+R has been Load data byte
received, ACK has
been returned.
Data byte in I2DATLoad data byte or
has been transmitted;
ACK has been
Load data byte
received.

Last data byte in
I2DAT has beentransmitted (AA = 0);
ACK has been
received.

UM10161_3

User manual

Next action taken by I2C hardware© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

147 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

8.5 Miscellaneous states
There are two I2STAT codes that do not correspond to a defined I2C hardware state (seeTable 11–138). These are discussed below.

8.6 I2STAT = 0xF8
This status code indicates that no relevant information is available because the serialinterrupt flag, SI, is not yet set. This occurs between other states and when the I2C blockis not involved in a serial transfer.

8.7 I2STAT = 0x00
This status code indicates that a bus error has occurred during an I2C serial transfer. A
bus error is caused when a START or STOP condition occurs at an illegal position in theformat frame. Examples of such illegal positions are during the serial transfer of an
address byte, a data byte, or an acknowledge bit. A bus error may also be caused when
external interference disturbs the internal I2C block signals. When a bus error occurs, SI isset. To recover from a bus error, the STO flag must be set and SI must be cleared. This
causes the I2C block to enter the “not addressed” slave mode (a defined state) and toclear the STO flag (no other bits in I2CON are affected). The SDA and SCL lines are
released (a STOP condition is not transmitted).

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

148 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

Table 138. Miscellaneous States
StatusStatus of the I2C-bus Application software responseCodeand hardware
To/From I2DATTo I2CON(I2CSTAT)STA STO SI
0xF8

No relevant state
information available;
SI = 0.

No I2DAT action

0x00

Bus error during MST No I2DAT action
or selected slavemodes, due to an
illegal START or
STOP condition. State
0x00 can also occur
when interference
causes the I2C blockto enter an undefinedstate.

Next action taken by I2C hardware
AA

No I2CON action

0

1

0

X

Wait or proceed current transfer.

Only the internal hardware is affected in
the MST or addressed SLV modes. In allcases, the bus is released and the I2C
block is switched to the not addressed
SLV mode. STO is reset.

8.8 Some special cases
The I2C hardware has facilities to handle the following special cases that may occur
during a serial transfer:

8.9 Simultaneous repeated START conditions from two masters
A repeated START condition may be generated in the master transmitter or masterreceiver modes. A special case occurs if another master simultaneously generates arepeated START condition (see Figure 11–39). Until this occurs, arbitration is not lost byeither master since they were both transmitting the same data.
If the I2C hardware detects a repeated START condition on the I2C-bus before generatinga 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 datatransfer can commence.

8.10 Data transfer after loss of arbitration
Arbitration may be lost in the master transmitter and master receiver modes (seeFigure 11–33). Loss of arbitration is indicated by the following states in I2STAT; 0x38,
0x68, 0x78, and 0xB0 (see Figure 11–35 and Figure 11–36).
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 theCPU, and a retry of the total serial transfer can commence.

8.11 Forced access to the I2C-bus
In some applications, it may be possible for an uncontrolled source to cause a bus
hang-up. In such situations, the problem may be caused by interference, temporaryinterruption of the bus or a temporary short-circuit between SDA and SCL.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

149 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

If an uncontrolled source generates a superfluous START or masks a STOP condition,then the I2C-bus stays busy indefinitely. If the STA flag is set and bus access is not
obtained within a reasonable amount of time, then a forced access to the I2C-bus ispossible. This is achieved by setting the STO flag while the STA flag is still set. No STOP
condition is transmitted. The I2C hardware behaves as if a STOP condition was received
and is able to transmit a START condition. The STO flag is cleared by hardware (seeFigure 34).

8.12 I2C-bus obstructed by a LOW level on SCL or SDA
An I2C-bus hang-up occurs if SDA or SCL is pulled LOW by an uncontrolled source. If the
SCL line is obstructed (pulled LOW) by a device on the bus, no further serial transfer ispossible, and the I2C hardware cannot resolve this type of problem. When this occurs, theproblem must be resolved by the device that is pulling the SCL bus line LOW.
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 11–41). 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 isentered, and the serial transfer continues.
If a forced bus access occurs or a repeated START condition is transmitted while SDA isobstructed (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 andnormal serial transfer continues. Note that the CPU is not involved in solving these bus
hang-up problems.

8.13 Bus error
A bus error occurs when a START or STOP condition is present at an illegal position in theformat frame. Examples of illegal positions are during the serial transfer of an addressbyte, a data bit, or an acknowledge bit.
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 theinterrupt flag, and loads the status register with 0x00. This status code may be used tovector to a state service routine which either attempts the aborted serial transfer again or
simply recovers from the error condition as shown in Table 11–138.

S
08H

SLA

W

A
18H

DATA

A

S

OTHER MASTERCONTINUES

28H

other Master sends
repeated START earlier

P

S

SLA

08H

retry

Fig 39. Simultaneous repeated START conditions from two masters
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

150 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

time limit
STA flag

STO flag
SDA line

SCL line
start
condition

Fig 40. Forced access to a busy I2C-bus

STA flag(2)
SDA line

(1)

(3)

(1)

SCL line
start
condition(1) Unsuccessful attempt to send a start condition.
(2) SDA line is released.
(3) Successful attempt to send a start condition. State 08H is entered.

Fig 41. Recovering from a bus obstruction caused by a LOW level on SDA

8.14 I2C state service routines
This section provides examples of operations that must be performed by various I2C stateservice routines. This includes:• Initialization of the I2C block after a Reset.
• I2C Interrupt Service• The 26 state service routines providing support for all four I2C operating modes.
8.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.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

151 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1The I2C hardware now begins checking the I2C-bus for its own slave address and generalcall. If the general call or the own slave address is detected, an interrupt is requested and
I2STAT is loaded with the appropriate state information.

8.16 I2C interrupt service
When the I2C interrupt is entered, I2STAT contains a status code which identifies one of
the 26 state services to be executed.

8.17 The state service routines
Each state routine is part of the I2C interrupt routine and handles one of the 26 states.

8.18 Adapting state services to an application
The state service examples show the typical actions that must be performed in responseto the 26 I2C state codes. If one or more of the four I2C operating modes are not used, theassociated state services can be omitted, as long as care is taken that the those states
can never occur.
In an application, it may be desirable to implement some kind of timeout during I2C
operations, in order to trap an inoperative bus or a lost service routine.

9. Software example
9.1 Initialization routine
Example to initialize I2C Interface as a Slave and/or Master.
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.

9.2 Start Master Transmit function
Begin a Master Transmit operation by setting up the buffer, pointer, and data count, theninitiating a Start.
1. Initialize Master data counter.
2. Set up the Slave Address to which data will be transmitted, and add the Write bit.
3. Write 0x20 to I2CONSET to set the STA bit.
4. Set up data to be transmitted in Master Transmit buffer.
5. Initialize the Master data counter to match the length of the message being sent.
6. Exit

9.3 Start Master Receive function
Begin a Master Receive operation by setting up the buffer, pointer, and data count, theninitiating a Start.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

152 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

1. Initialize Master data counter.
2. Set up the Slave Address to which data will be transmitted, and add the Read bit.
3. Write 0x20 to I2CONSET to set the STA bit.
4. Set up the Master Receive buffer.
5. Initialize the Master data counter to match the length of the message to be received.
6. Exit

9.4 I2C interrupt routine
Determine the I2C state and which state routine will be used to handle it.
1. Read the I2C status from I2STA.
2. Use the status value to branch to one of 26 possible state routines.

9.5 Non mode specific states
9.5.1 State: 0x00
Bus Error. Enter not addressed Slave mode and release bus.
1. Write 0x14 to I2CONSET to set the STO and AA bits.
2. Write 0x08 to I2CONCLR to clear the SI flag.
3. Exit9.5.2 Master States
State 08 and State 10 are for both Master Transmit and Master Receive modes. The R/W
bit decides whether the next state is within Master Transmit mode or Master Receivemode.

9.5.3 State: 0x08
A Start condition has been transmitted. The Slave Address + R/W bit will be transmitted,
an ACK bit will be received.
1. Write Slave Address with R/W bit to I2DAT.
2. Write 0x04 to I2CONSET to set the AA bit.
3. Write 0x08 to I2CONCLR to clear the SI flag.
4. Set up Master Transmit mode data buffer.
5. Set up Master Receive mode data buffer.
6. Initialize Master data counter.
7. Exit9.5.4 State: 0x10
A repeated Start condition has been transmitted. The Slave Address + R/W bit will betransmitted, an ACK bit will be received.
1. Write Slave Address with R/W bit to I2DAT.
2. Write 0x04 to I2CONSET to set the AA bit.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

153 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

3. Write 0x08 to I2CONCLR to clear the SI flag.
4. Set up Master Transmit mode data buffer.
5. Set up Master Receive mode data buffer.
6. Initialize Master data counter.
7. Exit

9.6 Master Transmitter states
9.6.1 State: 0x18
Previous state was State 8 or State 10, Slave Address + Write has been transmitted, ACK
has been received. The first data byte will be transmitted, an ACK bit will be received.
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. Exit9.6.2 State: 0x20
Slave Address + Write has been transmitted, NOT ACK has been received. A Stopcondition will be transmitted.
1. Write 0x14 to I2CONSET to set the STO and AA bits.
2. Write 0x08 to I2CONCLR to clear the SI flag.
3. Exit9.6.3 State: 0x28
Data has been transmitted, ACK has been received. If the transmitted data was the last
data byte then transmit a Stop condition, otherwise transmit the next data byte.
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 pointer9. Exit9.6.4 State: 0x30
Data has been transmitted, NOT ACK received. A Stop condition will be transmitted.
1. Write 0x14 to I2CONSET to set the STO and AA bits.
2. Write 0x08 to I2CONCLR to clear the SI flag.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

154 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

3. Exit9.6.5 State: 0x38
Arbitration has been lost during Slave Address + Write or data. The bus has beenreleased and not addressed Slave mode is entered. A new Start condition will betransmitted when the bus is free again.
1. Write 0x24 to I2CONSET to set the STA and AA bits.
2. Write 0x08 to I2CONCLR to clear the SI flag.
3. Exit

9.7 Master Receive states
9.7.1 State: 0x40
Previous state was State 08 or State 10. Slave Address + Read has been transmitted,
ACK has been received. Data will be received and ACK returned.
1. Write 0x04 to I2CONSET to set the AA bit.
2. Write 0x08 to I2CONCLR to clear the SI flag.
3. Exit9.7.2 State: 0x48
Slave Address + Read has been transmitted, NOT ACK has been received. A Stopcondition will be transmitted.
1. Write 0x14 to I2CONSET to set the STO and AA bits.
2. Write 0x08 to I2CONCLR to clear the SI flag.
3. Exit9.7.3 State: 0x50
Data has been received, ACK has been returned. Data will be read from I2DAT. Additional
data will be received. If this is the last data byte then NOT ACK will be returned, otherwise
ACK will be returned.
1. Read data byte from I2DAT into Master Receive buffer.
2. Decrement the Master 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 Master Receive buffer pointer8. Exit9.7.4 State: 0x58
Data has been received, NOT ACK has been returned. Data will be read from I2DAT. A
Stop condition will be transmitted.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

155 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

1. Read data byte from I2DAT into Master Receive buffer.
2. Write 0x14 to I2CONSET to set the STO and AA bits.
3. Write 0x08 to I2CONCLR to clear the SI flag.
4. Exit

9.8 Slave Receiver states
9.8.1 State: 0x60
Own Slave Address + Write has been received, ACK has been returned. Data will bereceived and ACK returned.
1. Write 0x04 to I2CONSET to set the AA bit.
2. Write 0x08 to I2CONCLR to clear the SI flag.
3. Set up Slave Receive mode data buffer.
4. Initialize Slave data counter.
5. Exit9.8.2 State: 0x68
Arbitration has been lost in Slave Address and R/W bit as bus Master. Own Slave Address+ Write has been received, ACK has been returned. Data will be received and ACK will be
returned. STA is set to restart Master mode after the bus is free again.
1. Write 0x24 to I2CONSET to set the STA and AA bits.
2. Write 0x08 to I2CONCLR to clear the SI flag.
3. Set up Slave Receive mode data buffer.
4. Initialize Slave data counter.
5. Exit.

9.8.3 State: 0x70
General call has been received, ACK has been returned. Data will be received and ACK
returned.
1. Write 0x04 to I2CONSET to set the AA bit.
2. Write 0x08 to I2CONCLR to clear the SI flag.
3. Set up Slave Receive mode data buffer.
4. Initialize Slave data counter.
5. Exit9.8.4 State: 0x78
Arbitration has been lost in Slave Address + R/W bit as bus Master. General call has been
received and ACK has been returned. Data will be received and ACK returned. STA is set
to restart Master mode after the bus is free again.
1. Write 0x24 to I2CONSET to set the STA and AA bits.
2. Write 0x08 to I2CONCLR to clear the SI flag.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

156 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

3. Set up Slave Receive mode data buffer.
4. Initialize Slave data counter.
5. Exit9.8.5 State: 0x80
Previously addressed with own Slave Address. Data has been received and ACK has
been returned. Additional data will be read.
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. Exit9.8.6 State: 0x88
Previously addressed with own Slave Address. Data has been received and NOT ACK
has been returned. Received data will not be saved. Not addressed Slave mode isentered.
1. Write 0x04 to I2CONSET to set the AA bit.
2. Write 0x08 to I2CONCLR to clear the SI flag.
3. Exit9.8.7 State: 0x90
Previously addressed with general call. Data has been received, ACK has been returned.
Received data will be saved. Only the first data byte will be received with ACK. Additional
data will be received with NOT ACK.
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. Exit9.8.8 State: 0x98
Previously addressed with general call. Data has been received, NOT ACK has beenreturned. Received data will not be saved. Not addressed Slave mode is entered.
1. Write 0x04 to I2CONSET to set the AA bit.
2. Write 0x08 to I2CONCLR to clear the SI flag.
3. Exit9.8.9 State: 0xA0
A Stop condition or repeated Start has been received, while still addressed as a Slave.
Data will not be saved. Not addressed Slave mode is entered.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

157 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

1. Write 0x04 to I2CONSET to set the AA bit.
2. Write 0x08 to I2CONCLR to clear the SI flag.
3. Exit

9.9 Slave Transmitter states
9.9.1 State: 0xA8
Own Slave Address + Read has been received, ACK has been returned. Data will betransmitted, ACK bit will be received.
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. Exit9.9.2 State: 0xB0
Arbitration lost in Slave Address and R/W bit as bus Master. Own Slave Address + Readhas been received, ACK has been returned. Data will be transmitted, ACK bit will bereceived. STA is set to restart Master mode after the bus is free again.
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. Exit9.9.3 State: 0xB8
Data has been transmitted, ACK has been received. Data will be transmitted, ACK bit will
be received.
1. Load I2DAT from Slave Transmit buffer with data byte.
2. Write 0x04 to I2CONSET to set the AA bit.
3. Write 0x08 to I2CONCLR to clear the SI flag.
4. Increment Slave Transmit buffer pointer.
5. Exit9.9.4 State: 0xC0
Data has been transmitted, NOT ACK has been received. Not addressed Slave mode isentered.
1. Write 0x04 to I2CONSET to set the AA bit.
2. Write 0x08 to I2CONCLR to clear the SI flag.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

158 of 285

UM10161

NXP Semiconductors

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1

3. Exit.

9.9.5 State: 0xC8
The last data byte has been transmitted, ACK has been received. Not addressed Slave
mode is entered.
1. Write 0x04 to I2CONSET to set the AA bit.
2. Write 0x08 to I2CONCLR to clear the SI flag.
3. Exit

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

159 of 285

UM10161
Chapter 12: LPC2101/02/03 SPI interface SPI0
Rev. 3 — 2 October 2008

User manual

1. Features• Single complete and independent SPI controller• Compliant with Serial Peripheral Interface (SPI) specification• Synchronous, serial, full duplex communication• Combined SPI master and slave• Maximum data bit rate of one eighth of the input clock rate
• 8 to 16 bits per transfer

2. Description
2.1 SPI overview
SPI is a full duplex serial interface. It can handle multiple masters and slaves being
connected to a given bus. Only a single master and a single slave can communicate on
the interface during a given data transfer. During a data transfer the master always sends
8 to 16 bits of data to the slave, and the slave always sends a byte of data to the master.

2.2 SPI data transfers
Figure 12–42 is a timing diagram that illustrates the four different data transfer formats
that are available with the SPI. This timing diagram illustrates a single 8 bit data transfer.
The first thing you should notice in this timing diagram is that it is divided into threehorizontal parts. The first part describes the SCK and SSEL signals. The second partdescribes the MOSI and MISO signals when the CPHA variable is 0. The third partdescribes the MOSI and MISO signals when the CPHA variable is 1.
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 = 1, the SSEL signal will always go inactive between datatransfers. This is not guaranteed when CPHA = 0 (the signal can remain active).

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

160 of 285

UM10161

NXP Semiconductors

Chapter 12: LPC2101/02/03 SPI interface SPI0SCK (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

Fig 42. SPI data transfer format (CPHA = 0 and CPHA = 1)

The data and clock phase relationships are summarized in Table 12–139. This tablesummarizes the following for each setting of CPOL and CPHA.

• When the first data bit is driven• When all other data bits are driven• When data is sampled
Table 139. SPI data to clock phase relationship
CPOL and CPHA settings

First data driven

Other data driven

Data sampled

CPOL = 0, CPHA = 0

Prior to first SCK rising edge

SCK falling edge

SCK rising edge

CPOL = 0, CPHA = 1

First SCK rising edge

SCK rising edge

SCK falling edge

CPOL = 1, CPHA = 0

Prior to first SCK falling edge SCK rising edge

SCK falling edge

CPOL = 1, CPHA = 1

First SCK falling edge

SCK rising edge

SCK falling edge

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 byteof data that is ready to be transmitted. At this point, the master can activate the clock, andbegin the transfer. The transfer ends when the last clock cycle of the transfer is complete.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

161 of 285

UM10161

NXP Semiconductors

Chapter 12: LPC2101/02/03 SPI interface SPI0

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.

2.3 General information
There are four registers that control the SPI peripheral. They are described in detail in
Section 12–4 “Register description” on page 164.
The SPI control register contains a number of programmable bits used to control thefunction of the SPI block. The settings for this register must be set up prior to a given datatransfer 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 purposeof 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 theserial 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 registerwhen a transmit is not currently in progress. Read data is buffered. When a transfer iscomplete, 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 mastermode. This needs to be set prior to a transfer taking place, when the SPI block is amaster. 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.

2.4 Master operation
The following sequence describes how one should process a data transfer with the SPI
block when it is set up to be the master. This process assumes that any prior data transfer
has already completed.
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 datatransfer.
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.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

162 of 285

UM10161

NXP Semiconductors

Chapter 12: LPC2101/02/03 SPI interface SPI0

Note that 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, awrite to this register is required in order to clear the SPIF status bit.

2.5 Slave operation
The following sequence describes how one should process a data transfer with the SPI
block when it is set up to be a slave. This process assumes that any prior data transfer
has already completed. It is required that the system clock driving the SPI logic be at least
8X faster than the SPI.
1. Set the SPI control register to the desired settings.
2. Write the data to transmitted to the SPI data register (optional). Note that this can only
be done when a slave SPI transfer is not in progress.
3. Wait for the SPIF bit in the SPI status register to be set to 1. The SPIF bit will be set
after the last sampling clock edge of the SPI data transfer.
4. Read the SPI status register.
5. Read the received data from the SPI data register (optional).
6. Go to step 2 if more data is required to transmit.
Note that 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 registermust take place, in order to clear the SPIF status bit.

2.6 Exception conditions
2.7 Read overrun
A read overrun occurs when the SPI block internal read buffer contains data that has notbeen read by the processor, and a new transfer has completed. The read buffer
containing valid data is indicated by the SPIF bit in the status register being active. Whena transfer completes, the SPI block needs to move the received data to the read buffer. If
the SPIF bit is active (the read buffer is full), the new receive data will be lost, and the read
overrun (ROVR) bit in the status register will be activated.

2.8 Write collision
As stated previously, there is no write buffer between the SPI block bus interface, and theinternal shift register. As a result, data must not be written to the SPI data register when a
SPI data transfer is currently in progress. The time frame where data cannot be written to
the SPI data register is from when the transfer starts, until after the status register has
been read when the SPIF status is active. If the SPI data register is written in this timeframe, the write data will be lost, and the write collision (WCOL) bit in the status register
will be activated.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

163 of 285

UM10161

NXP Semiconductors

Chapter 12: LPC2101/02/03 SPI interface SPI0

2.9 Mode fault
The SSEL signal must always be inactive when the SPI block is a master. If the SSEL
signal goes active, when the SPI block is a master, this indicates another master has
selected the device to be a slave. This condition is known as a mode fault. When a mode
fault is detected, the mode fault (MODF) bit in the status register will be activated, the SPI
signal drivers will be de-activated, and the SPI mode will be changed to be a slave.

2.10 Slave abort
A slave transfer is considered to be aborted, if the SSEL signal goes inactive before thetransfer is complete. In the event of a slave abort, the transmit and receive data for thetransfer that was in progress are lost, and the slave abort (ABRT) bit in the status register
will be activated.

3. Pin description
Table 140. SPI pin description
Pin NameType

Pin Description

SCK0

Input/Output

Serial Clock. The SPI is a clock signal used to synchronize the transfer of data across the
SPI 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 datatransfer. 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 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 normallystays 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 toidle, and any data that was received is thrown away. There are no other indications of thisexception. This signal is not directly driven by the master. It could be driven by a simple
general purpose I/O under software control.
On the LPC2101/02/03 the SSEL0 pin can be used for a different function when the SPI0
interface is only used in Master mode. For example, the pin hosting the SSEL0 function canbe configured as an output digital GPIO pin or used to select one of the Match outputs.

MISO0

Input/Output

Master In Slave Out. The MISO signal is a unidirectional signal used to transfer serial datafrom the 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 notselected, the slave drives the signal high impedance.

MOSI0

Input/Output

Master Out Slave In. The MOSI signal is a unidirectional signal used to transfer serial datafrom the 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.

4. Register description
The SPI contains 5 registers as shown in Table 12–141. All registers are byte, half word
and word accessible.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

164 of 285

UM10161

NXP Semiconductors

Chapter 12: LPC2101/02/03 SPI interface SPI0

Table 141. SPI register map
Name

Description

AccessResetvalue[1]Address

S0SPCRSPI Control Register. This register controls theoperation of the SPI.

R/W

0x00

0xE002 0000

S0SPSRSPI Status Register. This register shows thestatus of the SPI.

RO

0x00

0xE002 0004

S0SPDRSPI Data Register. This bi-directional register
R/W
provides the transmit and receive data for the
SPI. Transmit data is provided to the SPI0 by
writing to this register. Data received by the SPI0
can be read from this register.

0x00

0xE002 0008

S0SPCCR SPI Clock Counter Register. This register
controls the frequency of a master’s SCK0.

R/W

0x00

0xE002 000CS0SPINT

R/W

0x00

0xE002 001C

[1]

SPI Interrupt Flag. This register contains theinterrupt flag for the SPI interface.

Reset value reflects the data stored in used bits only. It does not include reserved bits content.

4.1 SPI Control Register (S0SPCR - 0xE002 0000)
The S0SPCR register controls the operation of the SPI0 as per the configuration bits
setting.
Table 142: SPI Control Register (S0SPCR - address 0xE002 0000) bit description
Bit

Symbol

1:0-

2

BitEnable

3

CPHA

Value Description

0

1

5

6

Reserved, user software should not write ones toreserved bits. The value read from a reserved bit is notdefined.

NA

The SPI controller sends and receives 8 bits of data pertransfer.

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.
0

4

CPOL

Data is sampled on the first clock edge of SCK. A transfer
starts and ends with activation and deactivation of the
SSEL signal.
Data is sampled on the second clock edge of the SCK. A
transfer starts with the first clock edge, and ends with thelast sampling edge when the SSEL signal is active.
Clock polarity control.

0

SCK is active HIGH.

1

SCK is active LOW.

MSTR

0

Master mode select.
0

The SPI operates in Slave mode.

1

The SPI operates in Master mode.

LSBF

0

LSB First controls which direction each byte is shifted
when transferred.
0

SPI data is transferred MSB (bit 7) first.

1

SPI data is transferred LSB (bit 0) first.

UM10161_3

User manual

Reset
value

0

© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

165 of 285

UM10161

NXP Semiconductors

Chapter 12: LPC2101/02/03 SPI interface SPI0

Table 142: SPI Control Register (S0SPCR - address 0xE002 0000) bit description
Bit

Symbol

7

SPIE

11:8

Value Description
Serial peripheral interrupt enable.

-

0

0

SPI interrupts are inhibited.

1

A hardware interrupt is generated each time the SPIF or
MODF bits are activated.

BITS

15:12

Reset
value

When bit 2 of this register is 1, this field controls thenumber 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

0000

Reserved, user software should not write ones toreserved bits. The value read from a reserved bit is notdefined.

NA

4.2 SPI Status Register (S0SPSR - 0xE002 0004)
The S0SPSR register controls the operation of the SPI0 as per the configuration bits
setting.
Table 143: SPI Status Register (S0SPSR - address 0xE002 0004) bit description
Bit

SymbolDescription

Reset value

2:0-

Reserved, user software should not write ones to reserved bits.
The value read from a reserved bit is not defined.

NA

3

ABRT

Slave abort. When 1, this bit indicates that a slave abort has
occurred. This bit is cleared by reading this register.

0

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 SPI0 control register.

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, thenaccessing 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 theend 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 byfirst 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.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

166 of 285

UM10161

NXP Semiconductors

Chapter 12: LPC2101/02/03 SPI interface SPI0

4.3 SPI Data Register (S0SPDR - 0xE002 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 datatransfer. 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 144: SPI Data Register (S0SPDR - address 0xE002 0008) bit description
Bit

SymbolDescription

Reset value

7:0

DataLow

SPI Bi-directional data port.

0x00

15:8 DataHigh

If bit 2 of the SPCR is 1 and bits 11:8 are other than 1000, some 0x00
or all of these bits contain the additional transmit and receive
bits. When less than 16 bits are selected, the more significant
among these bits read as zeroes.

4.4 SPI Clock Counter Register (S0SPCCR - 0xE002 000C)
This register controls the frequency of a master’s SCK. The register indicates the numberof PCLK cycles that make up an SPI clock. The value of this register must always be aneven number. As a result, bit 0 must always be 0. The value of the register must also
always be greater than or equal to 8. Violations of this can result in unpredictablebehavior.
Table 145: SPI Clock Counter Register (S0SPCCR - address 0xE002 000C) bit description
Bit

SymbolDescription

Reset value

7:0Counter

SPI0 Clock counter setting.

0x00

The SPI0 rate may be calculated as: PCLK / SPCCR0 value. The PCLK rate is
CCLK /APB divider rate as determined by the APBDIV register contents.

4.5 SPI Interrupt register (S0SPINT - 0xE002 001C)
This register contains the interrupt flag for the SPI0 interface.
Table 146: SPI Interrupt register (S0SPINT - address 0xE002 001C) bit description
Bit

SymbolDescription

Reset value0

SPI Interrupt
Flag

SPI interrupt flag. Set by the SPI interface to generate an interrupt. Clearedby writing a 1 to this bit.

0

Note: this bit will be set once when SPIE = 1 and at least one of SPIF and
WCOL bits is 1. However, only when the SPI Interrupt bit is set and SPI0
Interrupt is enabled in the VIC, SPI based interrupt can be processed byinterrupt handling software.
7:1-

Reserved, user software should not write ones to reserved bits. The value
read from a reserved bit is not defined.

NA

5. Architecture
The block diagram of the SPI solution implemented in SPI0 interface is shown in the
Figure 12–43.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

167 of 285

UM10161

NXP Semiconductors

Chapter 12: LPC2101/02/03 SPI interface SPI0MOSI_INMOSI_OUTMISO_INMISO_OUTSPI SHIFT REGISTERSPI CLOCKSCK_INSCK_OUT
SS_IN

GENERATOR &DETECTORSPI Interrupt

APB Bus

SPI REGISTERINTERFACESPI STATE CONTROLOUTPUT
ENABLELOGIC

SCK_OUT_EN
MOSI_OUT_EN
MISO_OUT_EN

Fig 43. SPI block diagram

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

168 of 285

UM10161
Chapter 13: LPC2101/02/03 SPI/SSP interface SPI1
Rev. 3 — 2 October 2008

User manual

1. 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 bits frame

2. Description
The SSP is a Synchronous Serial Port (SSP) controller capable of operation on a 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 datatransfer. 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.
Table 147. SSP pin descriptions
Pin Name

Type

SCK1

I/O

Interface pin name/function
SPI

SSI

Microwire

SCK

CLK

SK

Pin Description
Serial Clock. SCK/CLK/SK is a clock signal used tosynchronize the transfer of data. It is driven by the masterand received by the slave. When SPI interface is used theclock is programmable to be active HIGH or active LOW,
otherwise it is always active HIGH. SCK1 only switches
during a data transfer. Any other time, the SSP either holds
it in its inactive state, or does not drive it (leaves it in HIGH
impedance state).

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

169 of 285

UM10161

NXP Semiconductors

Chapter 13: LPC2101/02/03 SPI/SSP interface SPI1

Table 147. SSP pin descriptions
Pin Name

Type

SSEL1

Interface pin name/function

Pin Description

SPI

SSI

Microwire

I/O

SSEL

FS

CS

Slave Select/Frame Sync/Chip Select. When the SSP is abus master, it drives this signal from shortly before the startof serial data, to shortly after the end of serial data, to signify
a data transfer as appropriate for the selected bus andmode. When the SSP is a bus slave, this signal qualifies thepresence of data from the Master, according to the protocol
in use. When there is just one bus master and one bus
slave, the Frame Sync or Slave Select signal from the
Master can be connected directly to the slave’s
corresponding input. When there is more than one slave on
the bus, further qualification of their Frame Select/Slave
Select inputs will typically be necessary to prevent morethan one slave from responding to a transfer.

MISO1

I/O

MISO

DR(M)
DX(S)

SI(M)
SO(S)

Master In Slave Out. The MISO signal transfers serial datafrom the slave to the master. When the SSP is a slave, serial
data is output on this signal. When the SSP is a master, it
clocks in serial data from this signal. When the SSP is aslave and is not selected by SSEL, it does not drive thissignal (leaves it in HIGH impedance state).

MOSI1

I/O

MOSI

DX(M)
DR(S)

SO(M)
SI(S)

Master Out Slave In. The MOSI signal transfers serial datafrom the master to the slave. When the SSP is a master, it
outputs serial data on this signal. When the SSP is a slave,it clocks in serial data from this signal.

3. Bus description
3.1 Texas Instruments Synchronous Serial (SSI) frame format
Figure 13–44 show the 4-wire Texas Instruments synchronous serial frame format
supported by the SSP module.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

170 of 285

UM10161

NXP Semiconductors

Chapter 13: LPC2101/02/03 SPI/SSP interface SPI1

CLK
FS
DX/DR

MSB

LSB
4 to 16 bitsa. Single frame transfer

CLK
FS
DX/DR

MSB

LSB

MSB

4 to 16 bits

LSB
4 to 16 bitsb. Continuous/back-to-back frames transfer
Fig 44. Texas Instruments synchronous serial frame format: a) single frame transfer and b)
continuous/back-to-back two frames.

For device configured as a master in this mode, CLK and FS are forced LOW, and thetransmit data line DX is tristated whenever the SSP is idle. Once the bottom entry of thetransmit FIFO contains data, FS is pulsed HIGH for one CLK period. The value to betransmitted is also transferred from the transmit FIFO to the serial shift register of thetransmit logic. On the next rising edge of CLK, the MSB of the 4 to 16-bit data frame isshifted 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.

3.2 SPI frame format
The SPI interface is a four-wire interface where the SSEL signal behaves as a slave
select. The main feature of the SPI format is that the inactive state and phase of the SCK
signal are programmable through the CPOL and CPHA bits within the SSPCR0 control
register.

3.3 Clock Polarity (CPOL) and Clock Phase (CPHA) control
When the CPOL clock polarity control bit is LOW, it produces a steady state LOW valueon the SCK pin. If the CPOL clock polarity control bit is HIGH, a steady state HIGH value
is placed on the CLK pin when data is not being transferred.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

171 of 285

UM10161

NXP Semiconductors

Chapter 13: LPC2101/02/03 SPI/SSP interface SPI1The 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 aclock 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.

3.4 SPI format with CPOL=0,CPHA=0
Single and continuous transmission signal sequences for SPI format with CPOL = 0,
CPHA = 0 are shown in Figure 13–45.

SCK
SSEL

MOSI
MISO

MSB

LSB

MSB

LSB

Q

4 to 16 bitsa. Single transfer with CPOL=0 and CPHA=0

SCK
SSEL

MOSI
MISO

MSB

LSB

MSB

LSB

MSB
Q

LSB

MSB

LSB

Q

4 to 16 bits

4 to 16 bitsb. Continuous transfer with CPOL=0 and CPHA=0
Fig 45. Motorola SPI frame format with CPOL=0 and CPHA=0 ( a) single transfer and b) continuous transfer)

In this configuration, during idle periods:• The CLK signal is forced LOW• SSEL is forced HIGH
• The transmit MOSI/MISO pad is in high impedance
If the SSP is enabled and there is valid data within the transmit FIFO, the start oftransmission is signified by the SSEL master signal being driven LOW. This causes slave
data to be enabled onto the MISO input line of the master. Master’s MOSI is enabled.
One half SCK period later, valid master data is transferred to the MOSI pin. Now that boththe 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.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

172 of 285

UM10161

NXP Semiconductors

Chapter 13: LPC2101/02/03 SPI/SSP interface SPI1

In the case of a single word transmission, after all bits of the data word have beentransferred, 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.

3.5 SPI format with CPOL=0,CPHA=1
The transfer signal sequence for SPI format with CPOL = 0, CPHA = 1 is shown in
Figure 13–46, which covers both single and continuous transfers.

SCK
SSEL

MOSI
MISO

Q

MSB

LSB

MSB

LSB

Q

4 to 16 bits

Fig 46. Motorola SPI frame format (single transfer) with CPOL=0 and CPHA=1

In this configuration, during idle periods:• The CLK signal is forced LOW• SSEL is forced HIGH
• The transmit MOSI/MISO pad is in high impedance
If the SSP is enabled and there is valid data within the transmit FIFO, the start oftransmission is signified by the SSEL master signal being driven LOW. Master’s MOSI pin
is enabled. After a further one half SCK period, both master and slave valid data isenabled onto their respective transmission lines. At the same time, the SCK is enabledwith a rising edge transition.
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 isreturned 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.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

173 of 285

UM10161

NXP Semiconductors

Chapter 13: LPC2101/02/03 SPI/SSP interface SPI1

3.6 SPI format with CPOL = 1,CPHA = 0
Single and continuous transmission signal sequences for SPI format with CPOL=1,
CPHA=0 are shown in Figure 13–47.

SCK
SSEL

MOSI
MISO

MSB

LSB

MSB

LSB

Q

4 to 16 bitsa. Single transfer with CPOL=1 and CPHA=0
SCK
SSEL

MOSI
MISO

MSB

LSB

MSB

LSB

MSB
Q

LSB

MSB

LSB

Q

4 to 16 bits

4 to 16 bitsb. Continuous transfer with CPOL=1 and CPHA=0
Fig 47. SPI frame format with CPOL = 1 and CPHA = 0 ( a) single and b) continuous transfer)

In this configuration, during idle periods:• The CLK signal is forced HIGH
• SSEL is forced HIGH
• The transmit MOSI/MISO pad is in high impedance
If the SSP is enabled and there is valid data within the transmit FIFO, the start oftransmission is signified by the SSEL master signal being driven LOW, which causesslave data to be immediately transferred onto the MISO line of the master. Master’s MOSI
pin is enabled.
One half period later, valid master data is transferred to the MOSI line. Now that both themaster 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, theSSEL 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 theUM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

174 of 285

UM10161

NXP Semiconductors

Chapter 13: LPC2101/02/03 SPI/SSP interface SPI1CPHA 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.

3.7 SPI format with CPOL = 1,CPHA = 1
The transfer signal sequence for SPI format with CPOL = 1, CPHA = 1 is shown in
Figure 13–48, which covers both single and continuous transfers.

SCK
SSEL

MOSI
MISO

Q

MSB

LSB

MSB

LSB

Q

4 to 16 bits

Fig 48. Motorola SPI frame format with CPOL = 1 and CPHA = 1 (single transfer)

In this configuration, during idle periods:• The CLK signal is forced HIGH
• SSEL is forced HIGH
• The transmit MOSI/MISO pad is in high impedance
If the SSP is enabled and there is valid data within the transmit FIFO, the start oftransmission is signified by the SSEL master signal being driven LOW. Master’s MOSI isenabled. After a further one half SCK period, both master and slave data are enabled onto
their respective transmission lines. At the same time, the SCK is enabled with a fallingedge transition. Data is then captured on the rising edges and propagated on the fallingedges of the SCK signal.
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 isheld LOW between successive data words and termination is the same as that of thesingle word transfer.

3.8 Semiconductor Microwire frame format
Figure 13–49 shows the Microwire frame format for a single frame. Figure 13–50 shows
the same format when back-to-back frames are transmitted.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

175 of 285

UM10161

NXP Semiconductors

Chapter 13: LPC2101/02/03 SPI/SSP interface SPI1

SK
CS

SO
SI

MSB

LSB

8 bit control
0 MSB

LSB

4 to 16 bits
output dataFig 49. Microwire frame format (single transfer)

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 serialtransmission begins with an 8-bit control word that is transmitted from the SSP to theoff-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 therequired data. The returned data is 4 to 16 bits in length, making the total frame length
anywhere from 13 to 25 bits.
In this configuration, during idle periods:• The SK signal is forced LOW• CS is forced HIGH
• The transmit data line SO is arbitrarily forced LOW
A transmission is triggered by writing a control byte to the transmit FIFO.The falling edgeof CS causes the value contained in the bottom entry of the transmit FIFO to betransferred to the serial shift register of the transmit logic, and the MSB of the 8-bit control
frame to be shifted out onto the SO pin. CS remains LOW for the duration of the frametransmission. The SI pin remains tristated during this transmission.
The off-chip serial slave device latches each control bit into its serial shifter on the risingedge 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 backto the SSP. Each bit is driven onto SI line on the falling edge of SK. The SSP in turnlatches each bit on the rising edge of SK. At the end of the frame, for single transfers, theCS 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 ofSK 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 asingle transfer. However, the CS line is continuously asserted (held LOW) andtransmission 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 theframe has been latched into the SSP.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

176 of 285

UM10161

NXP Semiconductors

Chapter 13: LPC2101/02/03 SPI/SSP interface SPI1

SK
CS
SO

LSB

MSB

LSB

8 bit control
SI

0 MSB

LSB

MSB

4 to 16 bits
output data

LSB

4 to 16 bits
output data

Fig 50. Microwire frame format (continuous transfers)

3.9 Setup and hold time requirements on CS with respect to SK in
Microwire mode
In the Microwire mode, the SSP slave samples the first bit of receive data on the risingedge of SK after CS has gone LOW. Masters that drive a free-running SK must ensurethat the CS signal has sufficient setup and hold margins with respect to the rising edge ofSK.
Figure 13–51 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.

t HOLD= tSKtSETUP=2*tSK

SK
CS

SI

Fig 51. Microwire frame format (continuous transfers) - details

4. Register description
The SSP contains 9 registers as shown in Table 13–148. All registers are byte, half word
and word accessible.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

177 of 285

UM10161

NXP Semiconductors

Chapter 13: LPC2101/02/03 SPI/SSP interface SPI1

Table 148. SSP register map
AccessReset value[1] Address

Name

Description

SSPCR0Control Register 0. Selects the serial clock R/Wrate, bus type, and data size.

0x00000xE006 8000

SSPCR1

Control Register 1. Selects master/slave
and other modes.

0x00

0xE006 8004

SSPDR

Data Register. Writes fill the transmit FIFO, R/W
and reads empty the receive FIFO.

0x00000xE006 8008

SSPSR

Status Register

RO

0x03

0xE006 800C

R/W

0x00

0xE006 8010

SSPCPSR Clock Prescale Register

R/W

SSPIMSCInterrupt Mask Set and Clear Register

R/W

0x00

0xE006 8014

SSPRIS

Raw Interrupt Status Register

R/W

0x04

0xE006 8018

SSPMIS

Masked Interrupt Status Register

RO

0x00

0xE006 801C

SSPICR

SSPICR Interrupt Clear Register

WO

NA

0xE006 8020

[1]

Reset value reflects the data stored in used bits only. It does not include reserved bits content.

4.1 SSP Control Register 0 (SSPCR0 - 0xE006 8000)
This register controls the basic operation of the SSP controller.
Table 149: SSP Control Register 0 (SSPCR0 - address 0xE006 8000) bit description
Bit

Symbol

3:0

DSS

5:4

Value

Description

Reset
value

Data Size Select. This field controls the number of bits
transferred in each frame. Values 0000-0010 are notsupported and should not be used.

0000

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

FRF

Frame Format.
00

SPI

01

SSI

10

Microwire

11

This combination is not supported and should not be used.

UM10161_3

User manual

00© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

178 of 285

UM10161

NXP Semiconductors

Chapter 13: LPC2101/02/03 SPI/SSP interface SPI1

Table 149: SSP Control Register 0 (SSPCR0 - address 0xE006 8000) bit description
Bit

Symbol

6

CPOL

7

15:8

Value

Description

Reset
value

Clock Out Polarity. 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.

CPHA

Clock Out Phase. This bit is only used in SPI mode.
0

SSP controller captures serial data on the first clock transitionof 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 clocktransition of the frame, that is, the transition back to theinter-frame state of the clock line.

0

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 APB clock PCLK clocks the prescaler, the bit
frequency is PCLK / (CPSDVSR × [SCR+1]).

SCR

4.2 SSP Control Register 1 (SSPCR1 - 0xE006 8004)
This register controls certain aspects of the operation of the SSP controller.
Table 150: SSP Control Register 1 (SSPCR1 - address 0xE006 8004) bit description
Bit

Symbol

0

LBM

1

2

Value

Description

Reset
value

Loop Back Mode.

00

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).
SSP Enable.

SSE

The SSP controller is disabled.

1

The SSP controller will interact with other devices on theserial bus. Software should write the appropriate control
information to the other SSP registers and interrupt
controller registers, before setting this bit.

MS

Master/Slave Mode.This bit can only be written when theSSE bit is 0.
010

The SSP controller acts as a master on the bus, driving the
SCLK, MOSI, and SSEL lines and receiving the MISO line.
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
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.

UM10161_3

User manual

0

0

0

© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

179 of 285

UM10161

NXP Semiconductors

Chapter 13: LPC2101/02/03 SPI/SSP interface SPI1

4.3 SSP Data Register (SSPDR - 0xE006 8008)
Software can write data to be transmitted to this register, and read data that has been
received.
Table 151: SSP Data Register (SSPDR - address 0xE006 8008) bit description
Bit

SymbolDescription

15:0

DATA

Write: software can write data to be sent in a future frame to this 0x0000
register whenever the TNF bit in the Status register is 1,
indicating that the Tx FIFO is not full. If the Tx FIFO waspreviously empty and the SSP controller is not busy on the bus,transmission of the data will begin immediately. Otherwise thedata 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.

Reset value

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 thedata length is less than 16 bits, the data is right-justified in thisfield with higher order bits filled with 0s.

4.4 SSP Status Register (SSPSR - 0xE006 800C)
This read-only register reflects the current status of the SSP controller.
Table 152: SSP Status Register (SSPDR - address 0xE006 800C) bit description
Bit

SymbolDescription

Reset value

0

TFE

Transmit FIFO Empty. This bit is 1 is the Transmit FIFO isempty, 0 if not.

1

1

TNF

Transmit FIFO Not Full. This bit is 0 if the Tx FIFO is full, 1 if not. 1

2

RNEReceive FIFO Not Empty. This bit is 0 if the Receive FIFO isempty, 1 if not.

0

3

RFF

Receive FIFO Full. This bit is 1 if the Receive FIFO is full, 0 if
not.

0

4

BSY

Busy. This bit is 0 if the SSP controller is idle, or 1 if it iscurrently sending/receiving a frame and/or the Tx FIFO is not
empty.

0

7:5-

Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.

4.5 SSP Clock Prescale Register (SSPCPSR - 0xE006 8010)
This register controls the factor by which the Prescaler divides the APB clock PCLK toyield the prescaler clock that is, in turn, divided by the SCR factor in SSPCR0, to
determine the bit clock.
Table 153: SSP Clock Prescale Register (SSPCPSR - address 0xE006 8010) bit description
Bit

SymbolDescription

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.

UM10161_3

User manual

Reset value© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

180 of 285

UM10161

NXP Semiconductors

Chapter 13: LPC2101/02/03 SPI/SSP interface SPI1

Important: the SSPCPSR value must be properly initialized or the SSP controller will not
be able to transmit data correctly. In case of an SSP operating in the master mode, the
CPSDVSRmin = 2, while in case of the slave mode CPSDVSRmin = 12.

4.6 SSP Interrupt Mask Set/Clear register (SSPIMSC - 0xE006 8014)
This register controls whether each of the four possible interrupt conditions in the SSP
controller are enabled. Note that ARM uses the word “masked” in the opposite sense fromclassic computer terminology, in which “masked” meant “disabled”. ARM uses the word
“masked” to mean “enabled”. To avoid confusion we will not use the word “masked”.
Table 154: SSP Interrupt Mask Set/Clear register (SSPIMSC - address 0xE006 8014) bit
description
Bit

SymbolDescription

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 anotherframe is completely received. The ARM spec implies that thepreceding frame data is overwritten by the new frame datawhen this occurs.

Reset value

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
FIFO is at least half full.

0

3

TXIM

Software should set this bit to enable interrupt when the Tx
FIFO is at least half empty.

0

7:4

-

Reserved, user software should not write ones to reserved
bits. The value read from a reserved bit is not defined.

NA

4.7 SSP Raw Interrupt Status register (SSPRIS - 0xE006 8018)
This read-only register contains a 1 for each interrupt condition that is asserted,
regardless of whether or not the interrupt is enabled in the SSPIMSC.
Table 155: SSP Raw Interrupt Status register (SSPRIS - address 0xE006 8018) bit description
Bit

SymbolDescription

0

RORRISThis 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 thisoccurs.

1

RTRIS

This bit is 1 if when there is a Receive Timeout condition. Note 0that a Receive Timeout can be negated if further data isreceived.

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
bits. The value read from a reserved bit is not defined.

NA

UM10161_3

User manual

Reset value© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

181 of 285

UM10161

NXP Semiconductors

Chapter 13: LPC2101/02/03 SPI/SSP interface SPI1

4.8 SSP Masked Interrupt register (SSPMIS - 0xE006 801C)
This read-only register contains a 1 for each interrupt condition that is asserted andenabled in the SSPIMSC. When an SSP interrupt occurs, the interrupt service routine
should read this register to determine the cause(s) of the interrupt.
Table 156: SSP Masked Interrupt Status register (SSPMIS -address 0xE006 801C) bit
description
Bit

SymbolDescription

0

RORMISThis bit is 1 if another frame was completely received while the 0
RxFIFO was full, and this interrupt is enabled.

Reset value

1

RTMIS

This bit is 1 when there is a Receive Timeout condition andthis interrupt is enabled. Note that 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 thisinterrupt is enabled.

0

7:5

-

Reserved, user software should not write ones to reserved
bits. The value read from a reserved bit is not defined.

NA0

4.9 SSP Interrupt Clear Register (SSPICR - 0xE006 8020)
Software can write one or more one(s) to this write-only register, to clear thecorresponding interrupt condition(s) in the SSP controller. Note that the other two interrupt
conditions can be cleared by writing or reading the appropriate FIFO, or disabled byclearing the corresponding bit in SSPIMSC.
Table 157: SSP interrupt Clear Register (SSPICR - address 0xE006 8020) bit description
Bit

SymbolDescription

Reset value

0

RORIC

Writing a 1 to this bit clears the “frame was received when
RxFIFO was full” interrupt.

NA

1

RTIC

Writing a 1 to this bit clears the Receive Timeout interrupt.

NA

7:2

-

Reserved, user software should not write ones to reserved
bits. The value read from a reserved bit is not defined.

NA

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

182 of 285

UM10161
Chapter 14: LPC2101/02/03 Analog-to-Digital Converter (ADC)
Rev. 3 — 2 October 2008

User manual

1. Features• 10 bit successive approximation analog to digital converter• Power-down mode
• Measurement range 0 V to VDD(3V3) (typically 3 V; not to exceed VDDA voltage level)• 10 bit conversion time ≥ 2.44 μs• Burst conversion mode for single or multiple inputs• Optional conversion on transition on input pin or timer Match signal• Dedicated result register for every analog input to reduce interrupt overhead

2. Description
Basic clocking for the A/D converters is provided by the APB clock. A programmabledivider is included in each converter to scale this clock to the 4.5 MHz (max) clock neededby the successive approximation process. A fully accurate conversion requires 11 of theseclocks.

3. Pin description
Table 14–158 gives a brief summary of each of ADC related pins.
Table 158. ADC pin description
Pin

Type

Description

AD0.7:0

Input

Analog Inputs. The ADC cell can measure the voltage on any of these input signals.
Note that these analog inputs are always connected to their pins, even if the Pinfunction Select register assigns them to port pins. A simple self-test of the ADC can bedone by driving these pins as port outputs.
If the ADC is used, signal levels on analog input pins must not be above the level of
V3A at any time. Otherwise, A/D converter readings will be invalid. If the A/D converter
is not used in an application then the pins associated with A/D inputs can be used as
5 V tolerant digital IO pins.
Warning: while the ADC pins are specified as 5 V tolerant (see Table 6–59), theanalog multiplexing in the ADC block is not. More than 3.3 V (VDDA) should not beapplied to any pin that is selected as an ADC input, or the ADC reading will beincorrect. If for example AD0.0 and AD0.1 are used as the ADC0 inputs and voltage
on AD0.0 = 4.5 V while AD0.1 = 2.5 V, an excessive voltage on the AD.0 can cause
an incorrect reading of the AD0.1, although the AD0.1 input voltage is within the right
range.

VDDA, VSSA

Power

Analog Power and Ground. These should be nominally the same voltages as VDD
and VSS but should be isolated to minimize noise and error. VDDA also provides thevoltage reference level (VRef) for the A/D converter.
Remark: If the ADC is not used, VDDA should still be tied to VDD(3V3), and VSSA should
be grounded. These pins must not be left floating.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

183 of 285

UM10161

NXP Semiconductors

Chapter 14: LPC2101/02/03 Analog-to-Digital Converter (ADC)

4. Register description
The A/D Converter registers are shown in Table 14–159.
Table 159. ADC registers
Generic
Name

Description

AccessReset value[1]AD0Address& NameADCR

A/D Control Register. The ADCR register must be written to
select the operating mode before A/D conversion can occur.

R/W

0x0000 0001

0xE003 4000
AD0CR

ADGDR

A/D Global Data Register. This register contains the ADC’s
DONE bit and the result of the most recent A/D conversion.

R/W

NA

0xE003 4004
AD0GDRADSTAT

A/D Status Register. This register contains DONE andOVERRUN flags for all of the A/D channels, as well as theA/D interrupt flag.

RO

0x0000 0000

0xE003 4030
AD0STATADINTENA/D Interrupt Enable Register. This register contains enable
R/W
bits that allow the DONE flag of each A/D channel to be
included or excluded from contributing to the generation of an
A/D interrupt.

0x0000 0100

0xE003 400C
AD0INTENADDR0

A/D Channel 0 Data Register. This register contains the result ROof the most recent conversion completed on channel 0.

NA0xE003 4010
AD0DR0ADDR1

A/D Channel 1 Data Register. This register contains the result ROof the most recent conversion completed on channel 1.

NA

0xE003 4014
AD0DR1ADDR2

A/D Channel 2 Data Register. This register contains the result ROof the most recent conversion completed on channel 2.

NA

0xE003 4018
AD0DR2ADDR3A/D Channel 3 Data Register. This register contains the result ROof the most recent conversion completed on channel 3.

NA

0xE003 401C
AD0DR3ADDR4A/D Channel 4 Data Register. This register contains the result ROof the most recent conversion completed on channel 4.

NA

0xE003 4020
AD0DR4ADDR5A/D Channel 5 Data Register. This register contains the result ROof the most recent conversion completed on channel 5.

NA

0xE003 4024
AD0DR5ADDR6A/D Channel 6 Data Register. This register contains the result ROof the most recent conversion completed on channel 6.

NA

0xE003 4028
AD0DR6ADDR7A/D Channel 7 Data Register. This register contains the result ROof the most recent conversion completed on channel 7.

NA

0xE003 402C
AD0DR7[1]

Reset value reflects the data stored in used bits only. It does not include reserved bits content.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

184 of 285

UM10161

NXP Semiconductors

Chapter 14: LPC2101/02/03 Analog-to-Digital Converter (ADC)

4.1 A/D Control Register (AD0CR - 0xE003 4000)
Table 160: A/D Control Register (AD0CR - address 0xE003 4000 ) bit description
Bit

SymbolValue Description

Reset
value

7:0

SEL

Selects which of the AD0.7:0 pins is (are) to be sampled and converted. For AD0, bit 0 0x01
selects Pin AD0.0, and bit 7 selects pin AD0.7. In software-controlled mode, only one ofthese bits should be 1. In hardware scan mode, any value containing 1 to 8 ones. All
zeroes is equivalent to 0x01.

15:8

CLKDIVThe APB clock (PCLK) is divided by (this value plus one) to produce the clock for the0
A/D converter, which should be less than or equal to 4.5 MHz. Typically, software should
program the smallest value in this field that yields a clock of 4.5 MHz or slightly less, but
in certain cases (such as a high-impedance analog source) a slower clock may bedesirable.

16

BURST

1

The AD converter does repeated conversions at the rate selected by the CLKS field,0scanning (if necessary) through the pins selected by 1s in the SEL field. The first
conversion after the start corresponds to the least-significant 1 in the SEL field, thenhigher numbered 1-bits (pins) if applicable. Repeated conversions can be terminated byclearing this bit, but the conversion that’s in progress when this bit is cleared will becompleted.

0

Conversions are software controlled and require 11 clocks.

Important: START bits must be 000 when BURST = 1 or conversions will not start.
19:17 CLKS

20

-

21

PDN

23:22 -

This field selects the number of clocks used for each conversion in Burst mode, and the 000
number of bits of accuracy of the result in the RESULT bits of ADDR, between 11 clocks(10 bits) and 4 clocks (3 bits).
000

11 clocks / 10 bits001

10 clocks / 9bits

010

9 clocks / 8 bits

011

8 clocks / 7 bits

100

7 clocks / 6 bits

101

6 clocks / 5 bits

110

5 clocks / 4 bits

111

4 clocks / 3 bits
Reserved, user software should not write ones to reserved bits. The value read from areserved bit is not defined.

NA

1

The A/D converter is operational.

00

The A/D converter is in power-down mode.
Reserved, user software should not write ones to reserved bits. The value read from areserved bit is not defined.

UM10161_3

User manual

NA© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

185 of 285

UM10161

NXP Semiconductors

Chapter 14: LPC2101/02/03 Analog-to-Digital Converter (ADC)

Table 160: A/D Control Register (AD0CR - address 0xE003 4000 ) bit description
Bit

SymbolValue Description

26:24 START

27

Reset
value

When the BURST bit is 0, these bits control whether and when an A/D conversion isstarted: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 pin.

011

Start conversion when the edge selected by bit 27 occurs on P0.22.

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.

EDGE

0

This bit is significant only when the START field contains 010-111. In these cases:
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 -

0Reserved, user software should not write ones to reserved bits. The value read from areserved bit is not defined.

NA

4.2 A/D Global Data Register (AD0GDR - 0xE003 4004)
Table 161: A/D Global Data Register (AD0GDR - address 0xE003 4004 ) bit description
Bit

SymbolDescription

Reset
value

5:0

-

Reserved, user software should not write ones to reserved bits. The value read from NA
a reserved bit is not defined.

15:6

RESULTNA
When DONE is 1, this field contains a binary fraction representing the voltage on
the Ain pin selected by the SEL field, divided by the voltage on the VDDA 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 wasclose to, equal to, or greater than that on VREF.

23:16

-

Reserved, user software should not write ones to reserved bits. The value read from NA
a reserved bit is not defined.

26:24

CHN

These bits contain the channel from which the RESULT bits were converted (e.g.
000 identifies channel 0, 001 channel 1...).

29:27

-

Reserved, user software should not write ones to reserved bits. The value read from NA
a reserved bit is not defined.

30

OVERUN

This bit is 1 in burst mode if the results of one or more conversions was (were) lostand overwritten before the conversion that produced the result in the RESULT bits.
This bit is cleared by reading this register.

0

31

DONE

This bit is set to 1 when an A/D conversion completes. It is cleared when thisregister is read and when the ADCR is written. If the ADCR is written while aconversion is still in progress, this bit is set and a new conversion is started.

0

UM10161_3

User manual

NA© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

186 of 285

UM10161

NXP Semiconductors

Chapter 14: LPC2101/02/03 Analog-to-Digital Converter (ADC)

4.3 A/D Status Register (AD0STAT - 0xE003 4030)
The A/D Status register allows checking the status of all A/D channels simultaneously.
The DONE and OVERRUN flags appearing in the ADDRn register for each A/D channel
are mirrored in ADSTAT. The interrupt flag (the logical OR of all DONE flags) is also foundin ADSTAT.
Table 162: A/D Status Register (AD0STAT - address 0xE003 4030) bit description
Bit

SymbolDescription

Reset
value

0

DONE0

This bit mirrors the DONE status flag from the result register for A/D channel 0.

0

1

DONE1

This bit mirrors the DONE status flag from the result register for A/D channel 1.

0

2

DONE2

This bit mirrors the DONE status flag from the result register for A/D channel 2.

0

3

DONE3

This bit mirrors the DONE status flag from the result register for A/D channel 3.

0

4

DONE4

This bit mirrors the DONE status flag from the result register for A/D channel 4.

0

5

DONE5

This bit mirrors the DONE status flag from the result register for A/D channel 5.

0

6

DONE6

This bit mirrors the DONE status flag from the result register for A/D channel 6.

0

7

DONE7

This bit mirrors the DONE status flag from the result register for A/D channel 7.

0

8

OVERRUN0

This bit mirrors the OVERRRUN status flag from the result register for A/D channel 0.

0

9

OVERRUN1

This bit mirrors the OVERRRUN status flag from the result register for A/D channel 1.

0

10

OVERRUN2

This bit mirrors the OVERRRUN status flag from the result register for A/D channel 2.

0

11

OVERRUN3

This bit mirrors the OVERRRUN status flag from the result register for A/D channel 3.

0

12

OVERRUN4

This bit mirrors the OVERRRUN status flag from the result register for A/D channel 4.

0

13

OVERRUN5

This bit mirrors the OVERRRUN status flag from the result register for A/D channel 5.

0

14

OVERRUN6

This bit mirrors the OVERRRUN status flag from the result register for A/D channel 6.

0

15

OVERRUN7

This bit mirrors the OVERRRUN status flag from the result register for A/D channel 7.

0

16

ADINT

This bit is the A/D interrupt flag. It is one when any of the individual A/D channel Done0
flags is asserted and enabled to contribute to the A/D interrupt via the ADINTEN register.

31:17

-

Reserved, user software should not write ones to reserved bits. The value read from areserved bit is not defined.

NA

4.4 A/D Interrupt Enable Register (AD0INTEN - 0xE003 400C)
This register allows control over which A/D channels generate an interrupt when aconversion is complete. For example, it may be desirable to use some A/D channels tomonitor sensors by continuously performing conversions on them. The most recent
results are read by the application program whenever they are needed. In this case, aninterrupt is not desirable at the end of each conversion for some A/D channels.
Table 163: A/D Status Register (AD0STAT - address 0xE003 400C ) bit description
Bit

SymbolValue

Description

Reset
value

0

ADINTEN00

Completion of a conversion on ADC channel 0 will not generate an interrupt.

01Completion of a conversion on ADC channel 0 will generate an interrupt.

1
2

ADINTEN1
ADINTEN20

Completion of a conversion on ADC channel 1 will not generate an interrupt.

1

Completion of a conversion on ADC channel 1 will generate an interrupt.

0Completion of a conversion on ADC channel 2 will not generate an interrupt.

1

Completion of a conversion on ADC channel 2 will generate an interrupt.

UM10161_3

User manual

00© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

187 of 285

UM10161

NXP Semiconductors

Chapter 14: LPC2101/02/03 Analog-to-Digital Converter (ADC)

Table 163: A/D Status Register (AD0STAT - address 0xE003 400C ) bit description
Bit

SymbolValue

Description

Reset
value

3

ADINTEN30

Completion of a conversion on ADC channel 3 will not generate an interrupt.

01Completion of a conversion on ADC channel 3 will generate an interrupt.

4

ADINTEN40Completion of a conversion on ADC channel 4 will not generate an interrupt.

1

Completion of a conversion on ADC channel 4 will generate an interrupt.

0Completion of a conversion on ADC channel 5 will not generate an interrupt.

1

Completion of a conversion on ADC channel 5 will generate an interrupt.

0Completion of a conversion on ADC channel 6 will not generate an interrupt.

1

Completion of a conversion on ADC channel 6 will generate an interrupt.
Completion of a conversion on ADC channel 7 will not generate an interrupt.

5ADINTEN5

6

ADINTEN6

7

ADINTEN10
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 generateinterrupts.

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 from a reserved bit is not defined.

0
0
0
0
1

NA

4.5 A/D Data Registers (AD0DR0 to AD0DR7 - 0xE003 4010 to
0xE003 402C)
The A/D Data Register hold the result when an A/D conversion is complete, and also
include the flags that indicate when a conversion has been completed and when aconversion overrun has occurred.
Table 164: A/D Data Registers (ADDR0 to ADDR7, ADC0: AD0DR0 to AD0DR7) bit description
Bit

SymbolDescription

Reset
value

5:0

-

Reserved, user software should not write ones to reserved bits. The value read from areserved bit is not defined.

NA

15:6

RESULT

When DONE is 1, this field contains a binary fraction representing the voltage on the AD0 pin, NA
divided by the voltage on the VREF pin (V/VREF). Zero in the field indicates that the voltage on
the AD0 pin was less than, equal to, or close to that on VSSA, while 0x3FF indicates that thevoltage on AD0 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 areserved bit is not defined.

30

OVERRUN This bit is 1 in burst mode if the results of one or more conversions was (were) lost andoverwritten before the conversion that produced the result in the RESULT bits.This bit iscleared by reading this register.

31

DONE

NA

This bit is set to 1 when an A/D conversion completes. It is cleared when this register is read. NA

5. Operation
5.1 Hardware-triggered conversion
If the BURST bit in the ADCR is 0 and the START field contains 010-111, the ADC will
start a conversion when a transition occurs on a selected pin or Timer Match signal. The
choices include conversion on a specified edge of any of 4 Match signals, or conversion
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

188 of 285

UM10161

NXP Semiconductors

Chapter 14: LPC2101/02/03 Analog-to-Digital Converter (ADC)

on a specified edge of either of 2 Capture/Match pins. The pin state from the selected pador the selected Match signal, XORed with ADCR bit 27, is used in the edge detection
logic.

5.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 A/D Converter in the VIC tocontrol whether this assertion results in an interrupt. DONE is negated when the ADDR is
read.

5.3 Accuracy vs. digital receiver
The AD0 function must be selected in corresponding Pin Select register (see "Pin
Connect Block" on Section 7–4 “Register description” on page 67) in order to get accurate
voltage readings on the monitored pin. For the pin hosting an ADC input it is not possible
to have a have a digital function selected and yet get valid ADC readings. An inside circuit
disconnects ADC hardware from the associated pin whenever a digital function is selectedon that pin.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

189 of 285

UM10161
Chapter 15: LPC2101/02/03 32-bit Timers Timer0/1
Rev. 3 — 2 October 2008

User manual

1. Features• 32-bit Timer/Counter with a programmable 32-bit Prescaler• Counter or Timer operation• Up to four (Timer1) and three (Timer0) 32-bit capture channels that can take asnapshot 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 (Timer1) and three (Timer0) external outputs corresponding to matchregisters with the following capabilities:– Set LOW on match.
– Set HIGH on match.
– Toggle on match.
– Do nothing on match.

• For each timer, up to four match registers can be configured as PWM allowing to use
up to three match outputs as single edge controlled PWM ouputs.
Remark: Timer/Counter0 and Timer/Counter1 are functionally identical except for the
peripheral base address.

2. Applications• Interval Timer for counting internal events• Pulse Width Demodulator via Capture inputs• Free running timer• Pulse Width Modulator via Match outputs

3. Description
The Timer/Counter is designed to count cycles of the peripheral clock (PCLK) or an
externally-supplied clock, and it can optionally generate interrupts or perform otheractions 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, optionallygenerating an interrupt.
Due to the limited number of pins on the LPC2101/02/03, only three of the Capture Inputs
and three of the Match Ouputs of Timer 0 are connected to device pins.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

190 of 285

UM10161

NXP Semiconductors

Chapter 15: LPC2101/02/03 32-bit Timers Timer0/1

Two match registers can be used to provide a single edge controlled PWM output on the
MATn.2.0 pins. Because the MAT0.3 register is not pinned out on Timer0, it isrecommended to use the MRn.3 registers to control the PWM cycle length. One othermatch register is needed to control the PWM edge position. The remaining two matchregisters can be used to create PWM output with the PWM cycle rate determined by
MRn.3.

4. Pin description
Table 15–165 gives a brief summary of each of the Timer/Counter related pins.
Table 165. Timer/Counter pin description
Pin

Type

Description

CAP0[2..0]
CAP1[3..0]

Input

Capture Signals- A transition on a capture pin can be configured toload one of the Capture Registers with the value in the Timer Counterand optionally generate an interrupt.
Here is the list of all CAPTURE signals, together with pins on where
they can be selected:• CAP0.0: P0.2
• CAP0.1: P0.4
• CAP0.2: P0.6
• CAP1.0: P0.10• CAP1.1: P0.11• CAP1.2: P0.17• CAP1.3: P0.18
Timer/Counter block can select a capture signal as a clock source
instead of the PCLK derived clock. For more details see Section
15–5.3 “Count Control Register (CTCR, TIMER0: T0CTCR 0xE000 4070 and TIMER1: T1TCR - 0xE000 8070)” on page 194.
MAT0[2..0]
MAT1[3..0]

OutputExternal Match Output 0/1- When a match register 0/1 (MR3:0) equals
the timer counter (TC), this output can either toggle, go LOW, go
HIGH, or do nothing. The External Match Register (EMR) and the
PWM Control register (PWMCON) control the functionality of this
output.
Here is the list of all MATCH signals together with pins on where they
can be selected:• MAT0.0: P0.3
• MAT0.1: P0.5
• MAT0.2: P0.16• MAT1.0: P0.12• MAT1.1: P0.13• MAT1.2: P0.19• MAT1.3: P0.20

5. Register description
Each Timer/Counter contains the registers shown in Table 15–166. More detailed
descriptions follow.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

191 of 285

UM10161

NXP Semiconductors

Chapter 15: LPC2101/02/03 32-bit Timers Timer0/1

Table 166. TIMER/COUNTER0 and TIMER/COUNTER1 register map
Generic
Name

Description

AccessReset
TIMER/
value[1] COUNTER0
Address &Name

TIMER/
COUNTER1
Address &Name

IRInterrupt Register. The IR can be written to clear
interrupts. The IR can be read to identify which ofeight possible interrupt sources are pending.

R/W

0

0xE000 4000
T0IR

0xE000 8000
T1IR

TCR

Timer Control Register. The TCR is used to control
R/W
the Timer Counter functions. The Timer Counter canbe disabled or reset through the TCR.

00xE000 4004
T0TCR

0xE000 8004
T1TCR

TC

Timer Counter. The 32-bit TC is incremented every
PR+1 cycles of PCLK. The TC is controlled throughthe TCR.

R/W

0

0xE000 4008
T0TC

0xE000 8008
T1TC

PR

Prescale Register. The Prescale Counter (below) is R/Wequal to this value. The next clock increments the TC
and clears the PC.

00xE000 400C
T0PR

0xE000 800C
T1PR

PC

Prescale Counter. The 32-bit PC is a counter whichis incremented to the value stored in PR. When thevalue in PR is reached, the TC is incremented andthe PC is cleared. The PC is observable andcontrollable through the bus interface.

R/W

0

0xE000 4010
T0PC

0xE000 8010
T1PC

MCR

Match Control Register. The MCR is used to control
if an interrupt is generated and if the TC is reset
when a Match occurs.

R/W

0

0xE000 4014
T0MCR

0xE000 8014
T1MCR

MR0

Match Register 0. MR0 can be enabled through the
MCR to reset the TC, stop both the TC and PC,
and/or generate an interrupt every time MR0matches the TC.

R/W

0

0xE000 4018
T0MR0

0xE000 8018
T1MR0

MR1

Match Register 1. See MR0 description.

R/W

0

0xE000 401C
T0MR1

0xE000 801C
T1MR1

MR2

Match Register 2. See MR0 description.

R/W

0

0xE000 4020
T0MR2

0xE000 8020
T1MR2

MR3

Match Register 3. See MR0 description.

R/W

0

0xE000 4024
T0MR3

0xE000 8024
T1MR3

CCR

Capture Control Register. The CCR controls whichedges of the capture inputs are used to load the
Capture Registers and whether or not an interrupt isgenerated when a capture takes place.

R/W

0

0xE000 4028
T0CCR

0xE000 8028
T1CCR

CR0

Capture Register 0. CR0 is loaded with the value of RO
TC when there is an event on the CAPn.0(CAP0.0 or
CAP1.0 respectively) input.

0

0xE000 402C
T0CR0

0xE000 802C
T1CR0

CR1

Capture Register 1. See CR0 description.

RO0

0xE000 4030
T0CR1

0xE000 8030
T1CR1

CR2

Capture Register 2. See CR0 description.

RO0

0xE000 4034
T0CR2

0xE000 8034
T1CR2

CR3

Capture Register 3. See CR0 description.
Note: CAP0.3 not available on Timer 0RO00xE000 4038
T0CR3
Not usable

0xE000 8038
T1CR3

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

192 of 285

UM10161

NXP Semiconductors

Chapter 15: LPC2101/02/03 32-bit Timers Timer0/1

Table 166. TIMER/COUNTER0 and TIMER/COUNTER1 register map
Generic
Name

Description

AccessReset
TIMER/
value[1] COUNTER0
Address &Name

TIMER/
COUNTER1
Address &
Name

EMR

External Match Register. The EMR controls thematch function and the external match pins
MAT0.2:0 and MAT1.3:0.

R/W

00xE000 403C
T0EMR

0xE000 803C
T1EMR

R/W

0

0xE000 4070
T0CTCR

0xE000 8070
T1CTCR

R/W

0

0xE000 4074
PWM0CON

0xE000 8074
PWM1CON

Remark: MAT0.3 is not connected to a pin on
LPC2101/02/03.
CTCR

Count Control Register. The CTCR selects between
Timer and Counter mode, and in Counter mode
selects the signal and edge(s) for counting.

PWMCON PWM Control Register. The PWMCON enables
PWM mode for the external match pins MAT0.3:0
and MAT1.3:0.
[1]

Reset value reflects the data stored in used bits only. It does not include reserved bits content.

5.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 thecapture 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 167: Interrupt Register (IR, TIMER0: T0IR - address 0xE000 4000 and TIMER1: T1IR - address 0xE000 8000) bit
description
Bit

SymbolDescription

Reset value0

MR0 Interrupt

Interrupt flag for match channel 0.

0

1

MR1 Interrupt

Interrupt flag for match channel 1.

02

MR2 Interrupt

Interrupt flag for match channel 2.

03

MR3 Interrupt

Interrupt flag for match channel 3.

0

4

CR0 Interrupt

Interrupt flag for capture channel 0 event.

05

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.
Note: CAP0.3 not usable on Timer 00

5.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.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

193 of 285

UM10161

NXP Semiconductors

Chapter 15: LPC2101/02/03 32-bit Timers Timer0/1

Table 168: Timer Control Register (TCR, TIMER0: T0TCR - address 0xE000 4004 and TIMER1:
T1TCR - address 0xE000 8004) bit description
Bit

Symbol0Counter Enable When one, the Timer Counter and Prescale Counter are 0
enabled for counting. When zero, the counters are
disabled.

Description

Reset value

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] isreturned to zero.

7:2-

Reserved, user software should not write ones toreserved bits. The value read from a reserved bit is notdefined.

NA

5.3 Count Control Register (CTCR, TIMER0: T0CTCR - 0xE000 4070 and
TIMER1: T1TCR - 0xE000 8070)
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/LOWLOW levels on the same CAP input
in this case can not be shorter than 1/PCLK.
Table 169: Count Control Register (CTCR, TIMER0: T0CTCR - address 0xE000 4070 and
TIMER1: T1TCR - address 0xE000 8070) bit description
Bit

Symbol1:0Counter/
Timer
Mode

Value

Description

Reset
value

This field selects which rising PCLK edges can increment
Timer’s Prescale Counter (PC), or clear PC and increment
Timer Counter (TC).

0000

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.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

194 of 285

UM10161

NXP Semiconductors

Chapter 15: LPC2101/02/03 32-bit Timers Timer0/1

Table 169: Count Control Register (CTCR, TIMER0: T0CTCR - address 0xE000 4070 and
TIMER1: T1TCR - address 0xE000 8070) bit description
Bit

Symbol

3:2

Count
Input
SelectValue

Description

Reset
value

When bits 1:0 in this register are not 00, these bits selectwhich CAP pin is sampled for clocking:

00

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

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 theother 3 CAPn inputs in the same timer.
Note: CAP0.3 not available on Timer 0.

7:4

-

-

Reserved, user software should not write ones to reserved
bits. The value read from a reserved bit is not defined.

NA

5.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 thevalue 0xFFFF FFFF and then wrap back to the value 0x0000 0000. This event does notcause an interrupt, but a Match register can be used to detect an overflow if needed.

5.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.

5.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 isapplied to the Timer Counter. This allows control of the relationship between the resolutionof the timer and the maximum time before the timer overflows. The Prescale Counter isincremented 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.

5.7 Match Registers (MR0 - MR3)
The Match register values are continuously compared to the Timer Counter value. Whenthe two values are equal, actions can be triggered automatically. The action possibilities
are to generate an interrupt, reset the Timer Counter, or stop the timer. Actions arecontrolled by the settings in the MCR register.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

195 of 285

UM10161

NXP Semiconductors

Chapter 15: LPC2101/02/03 32-bit Timers Timer0/1

5.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 shownin Table 15–170.
Table 170: Match Control Register (MCR, TIMER0: T0MCR - address 0xE000 4014 and TIMER1: T1MCR - address
0xE000 8014) bit description
Bit

Symbol

0

MR0I

1
2

MR0R
MR0S

3

MR1I

4

MR1R

5

6
7

MR1S

MR2I
MR2R

8

MR2S

9

MR3I

Value Description

Reset
value
0

1

Interrupt on MR0: an interrupt is generated when MR0 matches the value in the TC.

0This interrupt is disabled

1

Reset on MR0: the TC will be reset if MR0 matches it.

0

Feature disabled.

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.

1

Interrupt on MR1: an interrupt is generated when MR1 matches the value in the TC.

0This interrupt is disabled

1

Reset on MR1: the TC will be reset if MR1 matches it.

0

Feature disabled.

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.

1

Interrupt on MR2: an interrupt is generated when MR2 matches the value in the TC.

0This interrupt is disabled

0

0
0

0

1

Reset on MR2: the TC will be reset if MR2 matches it.

0

Feature disabled.

01

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.

1

Interrupt on MR3: an interrupt is generated when MR3 matches the value in the TC.

0This interrupt is disabled
Reset on MR3: the TC will be reset if MR3 matches it.

0

10

MR3R

1
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 areserved bit is not defined.

UM10161_3

User manual

0NA© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

196 of 285

UM10161

NXP Semiconductors

Chapter 15: LPC2101/02/03 32-bit Timers Timer0/1

5.9 Capture Registers (CR0 - CR3)
Each Capture register is associated with a device pin and may be loaded with the TimerCounter value when a specified event occurs on that pin. The settings in the Capture
Control Register register determine whether the capture function is enabled, and whether
a capture event happens on the rising edge of the associated pin, the falling edge, or on
both edges.

5.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 thesame time is a valid configuration, resulting in a capture event for both edges. In thedescription below, “n” represents the Timer number, 0 or 1.
Table 171: Capture Control Register (CCR, TIMER0: T0CCR - address 0xE000 4028 and TIMER1: T1CCR - address
0xE000 8028) bit description
Bit

SymbolValue Description

Reset
value

0

CAP0RE1

Capture on CAPn.0 rising edge: a sequence of 0 then 1 on CAPn.0 will cause CR0 to
be loaded with the contents of TC.

00

This feature is disabled.

1

Capture on CAPn.0 falling edge: a sequence of 1 then 0 on CAPn.0 will cause CR0 to
be loaded with the contents of TC.

0

This feature is disabled.

1

Interrupt on CAPn.0 event: a CR0 load due to a CAPn.0 event will generate aninterrupt.

0This feature is disabled.

1

Capture on CAPn.1 rising edge: a sequence of 0 then 1 on CAPn.1 will cause CR1 to
be loaded with the contents of TC.

0

This feature is disabled.

1

Capture on CAPn.1 falling edge: a sequence of 1 then 0 on CAPn.1 will cause CR1 to
be loaded with the contents of TC.

0

This feature is disabled.

1

Interrupt on CAPn.1 event: a CR1 load due to a CAPn.1 event will generate aninterrupt.

1

CAP0FE

2

CAP0I

3

4

5

6

7

8

CAP1RECAP1FE

CAP1I

CAP2RECAP2FECAP2I

0This feature is disabled.

1

Capture on CAPn.2 rising edge: A sequence of 0 then 1 on CAPn.2 will cause CR2 to
be loaded with the contents of TC.

0

This feature is disabled.

1

Capture on CAPn.2 falling edge: a sequence of 1 then 0 on CAPn.2 will cause CR2 to
be loaded with the contents of TC.

0

This feature is disabled.

1

Interrupt on CAPn.2 event: a CR2 load due to a CAPn.2 event will generate aninterrupt.

0This feature is disabled.

UM10161_3

User manual

0

0

0

0

0

0

0

0

© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

197 of 285

UM10161

NXP Semiconductors

Chapter 15: LPC2101/02/03 32-bit Timers Timer0/1

Table 171: Capture Control Register (CCR, TIMER0: T0CCR - address 0xE000 4028 and TIMER1: T1CCR - address
0xE000 8028) bit description
Bit

SymbolValue Description

Reset
value

9

CAP3RE1

Capture on CAPn.3 rising edge: A sequence of 0 then 1 on CAPn.3 will cause CR3 to
be loaded with the contents of TC[1].

00This feature is disabled.

1

Capture on CAPn.3 falling edge: a sequence of 1 then 0 on CAPn.3 will cause CR3 to
be loaded with the contents of TC[1].

0This feature is disabled.

1

Interrupt on CAPn.3 event: a CR3 load due to a CAPn.3 event will generate aninterrupt[1].

10

CAP3FE

11

CAP3I

0
15:12 -

[1]00This feature is disabled.
Reserved, user software should not write ones to reserved bits. The value read from areserved bit is not defined.

NA

On Timer0, CAP0.3 is disabled and values for CAP3RE, CAP3FE, and CAP3I are not defined.

5.11 External Match Register (EMR, TIMER0: T0EMR - 0xE000 403C; andTIMER1: T1EMR - 0xE000 803C)
The External Match Register provides both control and status of the external match pins
MAT(0-3).
If the match ouputs are configured as PWM output, the function of the external matchregisters is determined by the PWM rules (Section 15–5.13 “Rules for single edge
controlled PWM ouputs” on page 200).
Table 172: External Match Register (EMR, TIMER0: T0EMR - address 0xE000 403C and TIMER1: T1EMR address0xE000 803C) bit description
Bit

SymbolDescription

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 outputof the timer can either toggle, go LOW, go HIGH, or do nothing. Bits EMR[5:4] control thefunctionality 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 outputof the timer can either toggle, go LOW, go HIGH, or do nothing. Bits EMR[7:6] control thefunctionality 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 outputof the timer can either toggle, go LOW, go HIGH, or do nothing. Bits EMR[9:8] control thefunctionality 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 outputof 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–173
shows the encoding of these bits.

00

7:6

EMC1

External Match Control 1. Determines the functionality of External Match 1. Table 15–173
shows the encoding of these bits.

00

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

198 of 285

UM10161

NXP Semiconductors

Chapter 15: LPC2101/02/03 32-bit Timers Timer0/1

Table 172: External Match Register (EMR, TIMER0: T0EMR - address 0xE000 403C and TIMER1: T1EMR address0xE000 803C) bit description
Bit

SymbolDescription

Reset
value

9:8

EMC2

External Match Control 2. Determines the functionality of External Match 2. Table 15–173
shows the encoding of these bits.

00

11:10

EMC3

External Match Control 3. Determines the functionality of External Match 3. Table 15–173
shows the encoding of these bits.

00

15:12

-

Reserved, user software should not write ones to reserved bits. The value read from areserved bit is not defined.

NA

Table 173. External match control
EMR[11:10], EMR[9:8],
EMR[7:6], or EMR[5:4]

Function00

Do Nothing.

01

Clear the corresponding External Match bit/output to 0 (MATn.m pin is LOW if pinned out).

10

Set the corresponding External Match bit/output to 1 (MATn.m pin is HIGH if pinned out).

11

Toggle the corresponding External Match bit/output.

5.12 PWM Control Register (PWMCON, TIMER0: PWM0CON - 0xE000 4074
and TIMER1: PWM1CON - 0xE000 8074)
The PWM Control Register is used to configure the match ouputs as PWM outputs. Each
match output can be independently set to perform either as PWM output or as match
output whose function is controlled by the External Match Register (EMR).
For each timer, a maximum of three single edge controlled PWM ouputs can be selectedon the MATn.2:0 outputs. One additional match register determines the PWM cycle
length. When a match occurs in any of the other match registers, the PWM output is set to
HIGH. The timer is reset by the match register that is configured to set the PWM cycle
length. When the timer is reset to zero, all currently HIGH match outputs configured as
PWM ouputs are cleared.
Table 174: PWM Control Register (PWMCON, TIMER0: PWM0CON - 0xE000 4074 and
TIMER1: PWM1CON - 0xE000 8074) bit description
Bit

SymbolDescription

Reset value0

PWM enable

When one, PWM mode is enabled for MATn.0. Whenzero, MATn.0 is controlled by EM0.

01

PWM enable

When one, PWM mode is enabled for MATn.1. Whenzero, MATn.1 is controlled by EM1.

02

PWM enable

When one, PWM mode is enabled for MATn.2. Whenzero, MATn.2 is controlled by EM2.

03

PWM enable

When one, PWM mode is enabled for MATn.3. Whenzero, MATn.3 is controlled by EM3.

0

Note: It is recommended to use MATn.3 to set the PWM
cycle because MATn.3 is not pinned out on Timer0.
4:32-

Reserved, user software should not write ones toreserved bits. The value read from a reserved bit is notdefined.

UM10161_3

User manual

NA© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

199 of 285

UM10161

NXP Semiconductors

Chapter 15: LPC2101/02/03 32-bit Timers Timer0/1

5.13 Rules for single edge controlled PWM ouputs
1. All single edge controlled PWM outputs go LOW at the beginning of each PWM cycle(timer is set to zero) unless their match value is equal to zero.
2. Each PWM output will go HIGH when its match value is reached. If no match occurs(i.e. the match value is greater than the PWM cycle length), the PWM output remains
continuously LOW.
3. If a match value larger than the PWM cycle length is written to the match register, and
the PWM signal is HIGH already, then the PWM signal will be cleared with the start of
the next PWM cycle.
4. If a match register contains the same value as the timer reset value (the PWM cycle
length), then the PWM output will be reset to LOW on the next clock tick after thetimer reaches the match value. Therefore, the PWM output will always consist of aone clock tick wide positive pulse with a period determined by the PWM cycle length(i.e. the timer reload value).
5. If a match register is set to zero, then the PWM output will go to HIGH the first time thetimer goes back to zero and will stay HIGH continuously.
Note: When the match outputs are selected to perform as PWM outputs, the timer reset(MRnR) and timer stop (MRnS) bits in the Match Control Register MCR must be set tozero except for the match register setting the PWM cycle length. For this register, set the
MRnR bit to one to enable the timer reset when the timer value matches the value of thecorresponding match register.

PWM2/MAT2

MR2 = 100

PWM1/MAT1

MR1 = 41

PWM0/MAT0

MR0 = 65

0

41

65

100
(counter is reset)

Fig 52. Sample PWM waveforms with a PWM cycle length of 100 (selected by MR3) andMAT3:0 enabled as PWM outputs by the PWCON register.

6. Example timer operation
Figure 15–53 shows a timer configured to reset the count and generate an interrupt onmatch. The prescaler is set to 2 and the match register set to 6. At the end of the timer
cycle where the match occurs, the timer count is reset. This gives a full length cycle to thematch value. The interrupt indicating that a match occurred is generated in the next clock
after the timer reached the match value.
Figure 15–54 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.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

200 of 285

UM10161

NXP Semiconductors

Chapter 15: LPC2101/02/03 32-bit Timers Timer0/1

PCLK
prescalecounter2

timer
counter

4

0

1

2

0

1

5

2

6

0

1
0

2

0

1
1

timer counter
reset
interrupt

Fig 53. A timer cycle in which PR=2, MRx=6, and both interrupt and reset on match are enabled

PCLKprescale counter
timer counter
TCR[0](counter enable)

2
4

0

1
5
1

2

0
6
0

interrupt

Fig 54. A timer cycle in which PR=2, MRx=6, and both interrupt and stop on match are enabled

7. Architecture
The block diagram for TIMER/COUNTER0 and TIMER/COUNTER1 is shown in
Figure 15–55.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

201 of 285

UM10161

NXP Semiconductors

Chapter 15: LPC2101/02/03 32-bit Timers Timer0/1

MATCH REGISTER 0
MATCH REGISTER 1
MATCH REGISTER 2
MATCH REGISTER 3
MATCH CONTROL REGISTER
EXTERNAL MATCH REGISTERINTERRUPT REGISTERCONTROL=

MAT[3:0]
INTERRUPT=CAP[3:0]=

STOP ON MATCH
RESET ON MATCH
LOAD[3:0]=

CAPTURE CONTROL REGISTERCSNCAPTURE REGISTER 0

TIMER COUNTERCAPTURE REGISTER 1CE

CAPTURE REGISTER 2CAPTURE REGISTER 3(1)

TCI
PCLK
PRESCALE COUNTER
reset

enableTIMER CONTROL REGISTERMAXVALPRESCALE REGISTER(1) The capture register 3 (CAP0.3) is not available on TIMER0.

Fig 55. Timer0/1 block diagram

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

202 of 285

UM10161
Chapter 16: LPC2101/02/03 16-bit Timers Timer 2/3
Rev. 3 — 2 October 2008

User manual

1. Features• A 16-bit Timer/Counter with a programmable 16-bit Prescaler.
• Counter or Timer operation• Three (Timer 2) 16-bit capture channels that can take a snapshot of the timer value
when an input signal transitions. A capture event may also optionally generate aninterrupt.

• Four 16-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 (Timer3) and three (Timer2) external outputs corresponding to matchregisters with the following capabilities:– Set LOW on match.
– Set HIGH on match.
– Toggle on match.
– Do nothing on match.

• For each timer, up to four match registers can be configured as PWM allowing to use
up to three match outputs as single edge controlled PWM ouputs.
Remark: Timer/Counter2 and Timer/Counter3 are functionally identical except for the
peripheral base address.

2. Applications• Interval Timer for counting internal events• Pulse Width Demodulator via Capture inputs• Free running timer• Pulse Width Modulator via Match outputs

3. Description
The Timer/Counter is designed to count cycles of the peripheral clock (PCLK) or an
externally-supplied clock, and it can optionally generate interrupts or perform otheractions 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, optionallygenerating an interrupt.
Due to the limited number of pins on the LPC2101/02/03, none of the Capture Inputs ofTimer3, only three of the Capture Inputs of Timer2, three of the Match Ouputs of Timer2,
and four of the Match Outputs of Timer3 are connected to device pins.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

203 of 285

UM10161

NXP Semiconductors

Chapter 16: LPC2101/02/03 16-bit Timers Timer 2/3

Two match registers can be used to provide a single edge controlled PWM output on the
MATn.2..0 pins. Because the MAT2.3 register is not pinned out on Timer2, it isrecommended to use the MRn.3 registers to control the PWM cycle length. One othermatch register is needed to control the PWM edge position. The remaining two matchregisters can be used to create PWM output with the PWM cycle rate determined by
MRn.3.

4. Pin description
Table 16–175 gives a brief summary of each of the Timer/Counter related pins.
Table 175. Timer/Counter pin description
Pin

Type

Description

CAP2[2..0]

Input

Capture Signals- A transition on a capture pin can be configured toload one of the Capture Registers with the value in the Timer Counterand optionally generate an interrupt.
Here is the list of all CAPTURE signals together with pins on where
they can be selected:• CAP2.0: P0.27• CAP2.1: P0.28• CAP2.2: P0.29
Timer/Counter block can select a capture signal as a clock source
instead of the PCLK derived clock. For more details see Section
16–5.3 “Count Control Register (CTCR, TIMER2: T2CTCR 0xE007 0070 and TIMER3: T3TCR - 0xE007 4070)” on page 207.
MAT2[2..0]
MAT3[3..0]

OutputExternal Match Output 0/1- When a match register 0/1 (MR3:0) equals
the timer counter (TC), this output can either toggle, go LOW, go
HIGH, or do nothing. The External Match Register (EMR) and the
PWM Control Register (PWMCON) control the functionality of this
output.
Here is the list of all MATCH signals together with pins on where they
can be selected:• MAT2.0: P0.7
• MAT2.1: P0.8
• MAT2.2: P0.9
• MAT3.0: P0.21• MAT3.1: P0.0
• MAT3.2: P0.1
• MAT3.3: P0.30

5. Register description
Each Timer/Counter contains the registers shown in Table 16–176. More detailed
descriptions follow.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

204 of 285

UM10161

NXP Semiconductors

Chapter 16: LPC2101/02/03 16-bit Timers Timer 2/3

Table 176. TIMER/COUNTER2 and TIMER/CT3OUNTER3 register map
Generic
Name

Description

AccessReset
TIMER/
value[1] COUNTER2
Address &Name

TIMER/
COUNTER3
Address &Name

IRInterrupt Register. The IR can be written to clear
interrupts. The IR can be read to identify which ofeight possible interrupt sources are pending.

R/W

0

0xE007 0000
T2IR

0xE007 4000
T3IR

TCR

Timer Control Register. The TCR is used to control R/W
the Timer Counter functions. The Timer Counter canbe disabled or reset through the TCR.

00xE007 0004
T2TCR

0xE007 4004
T3TCR

TC

Timer Counter. The 16-bit TC is incremented every
PR+1 cycles of PCLK. The TC is controlled throughthe TCR.

R/W

0

0xE007 0008
T2TC

0xE007 4008
T3TC

PR

Prescale Register. The Prescale Counter (below) isequal to this value. The next clock increments the
TC and clears the PC.

R/W

0

0xE007 000C
T2PR

0xE007 400C
T3PR

PC

Prescale Counter. The 16-bit PC is a counter whichis incremented to the value stored in PR. When thevalue in PR is reached, the TC is incremented andthe PC is cleared. The PC is observable andcontrollable through the bus interface.

R/W

0

0xE007 0010
T2PC

0xE007 4010
T3PC

MCR

Match Control Register. The MCR is used to control
if an interrupt is generated and if the TC is reset
when a Match occurs.

R/W

0

0xE007 0014
T2MCR

0xE007 4014
T3MCR

MR0

Match Register 0. MR0 can be enabled through the
MCR to reset the TC, stop both the TC and PC,
and/or generate an interrupt every time MR0matches the TC.

R/W

0

0xE007 0018
T2MR0

0xE007 4018
T3MR0

MR1

Match Register 1. See MR0 description.

R/W

0

0xE007 001C
T2MR1

0xE007 401C
T3MR1

MR2

Match Register 2. See MR0 description.

R/W

0

0xE007 0020
T2MR2

0xE007 4020
T3MR2

MR3

Match Register 3. See MR0 description.

R/W

0

0xE007 0024
T2MR3

0xE007 4024
T3MR3

CCR

R/W
Capture Control Register. The CCR controls whichedges of the capture inputs are used to load the
Capture Registers and whether or not an interrupt isgenerated when a capture takes place.

00xE007 0028
T2CCR

0xE007 4028
T3CCR

CR0

Capture Register 0. CR0 is loaded with the value ofTC when there is an event on the CAP2.0 input.
Note: CAP3.0 not usable on Timer 3

RO0

0xE007 002C
T2CR0

0xE007 402C
T3CR0

CR1

Capture Register 1. See CR0 description.
Note: CAP3.1 not usable on Timer 3

RO0

0xE007 0030
T2CR1

0xE007 4030
T3CR1

CR2

Capture Register 2. See CR0 description.
Note: CAP3.2 not usable on Timer 3

RO0

0xE007 0034
T2CR2

0xE007 4034
T3CR2

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

205 of 285

UM10161

NXP Semiconductors

Chapter 16: LPC2101/02/03 16-bit Timers Timer 2/3

Table 176. TIMER/COUNTER2 and TIMER/CT3OUNTER3 register map
Generic
Name

Description

AccessReset
TIMER/
value[1] COUNTER2
Address &Name

TIMER/
COUNTER3
Address &
Name

EMR

External Match Register. The EMR controls thematch function and the external match pins
MAT0.2:0 and MAT1.3:0.

R/W

00xE007 003C
T2EMR

0xE007 403C
T3EMR

Count Control Register. The CTCR selects between R/W
Timer and Counter mode, and in Counter mode
selects the signal and edge(s) for counting.

0

0xE007 0070
T2CTCR

0xE007 4070
T3CTCR0

0xE007 0074
PWM2CON

0xE007 4074
PWM3CON

Remark: MAT0.3 is not connected to a pin on
LPC2101/02/03.
CTCR

PWMCON PWM Control Register. The PWMCON enables
PWM mode for the external match pins MAT2.3..0
and MAT3.3..0.
[1]

R/W

Reset value reflects the data stored in used bits00 only. It does not include reserved bits content.

5.1 Interrupt Register (IR TIMER2: T2IR - 0xE007 0000 and TIMER3: T3IR 0xE007 4000)
The Interrupt Register consists of four bits for the match interrupts and four bits for thecapture 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 177: Interrupt Register (IR, TIMER2T2: T2IR - address 0xE007 0000 and TIMER3: T3IR - address 0xE007 4000)
bit description
Bit

SymbolDescription

Reset value0

MR0 Interrupt

Interrupt flag for match channel 0.

0

1

MR1 Interrupt

Interrupt flag for match channel 1.

02

MR2 Interrupt

Interrupt flag for match channel 2.

03

MR3 Interrupt

Interrupt flag for match channel 3.

0

4

CR0 Interrupt

Interrupt flag for capture channel 0 event.

05

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.
Note: CAPn.3 not usable on Timer 2/Timer30

5.2 Timer Control Register (TCR, TIMER2: T2TCR - 0xE007 0004 and
TIMER3: T3TCR - 0xE007 4004)
The Timer Control Register (TCR) is used to control the operation of the Timer/Counter.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

206 of 285

UM10161

NXP Semiconductors

Chapter 16: LPC2101/02/03 16-bit Timers Timer 2/3

Table 178: Timer Control Register (TCR, TIMER2: T2TCR - address 0xE007 0004 and TIMER3:
T3TCR - address 0xE007 4004) bit description
Bit

Symbol0Counter Enable When one, the Timer Counter and Prescale Counter are 0
enabled for counting. When zero, the counters are
disabled.

Description

Reset value

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] isreturned to zero.

7:2-

Reserved, user software should not write ones toreserved bits. The value read from a reserved bit is notdefined.

NA

5.3 Count Control Register (CTCR, TIMER2: T2CTCR - 0xE007 0070 and
TIMER3: T3TCR - 0xE007 4070)
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 inthis case can not be shorter than 1/PCLK.
Table 179: Count Control Register (CTCR, TIMER2: T2CTCR - address 0xE007 0070 and
TIMER3: T3TCR - address 0xE007 4070) bit description
Bit

Symbol1:0Counter/
Timer
Mode

Value

Description

Reset
value

This field selects which rising PCLK edges can increment
Timer’s Prescale Counter (PC), or clear PC and increment
Timer Counter (TC).

0000

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.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

207 of 285

UM10161

NXP Semiconductors

Chapter 16: LPC2101/02/03 16-bit Timers Timer 2/3

Table 179: Count Control Register (CTCR, TIMER2: T2CTCR - address 0xE007 0070 and
TIMER3: T3TCR - address 0xE007 4070) bit description
Bit

Symbol

3:2

Count
Input
SelectValue

Description

Reset
value

When bits 1:0 in this register are not 00, these bits selectwhich CAP pin is sampled for clocking:

00

00

CAP2.001

CAP2.1

10

CAP2.2
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 theother 3 CAPn inputs in the same timer.

7:4

-

11

Reserved. CAPn.3 are not available on Timer2/3-

Reserved, user software should not write ones to reserved
bits. The value read from a reserved bit is not defined.

NA

5.4 Timer Counter (TC, TIMER2: T2TC - 0xE007 0008 and TIMER3:
T3TC - 0xE007 4008)
The 16-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 thevalue 0xFFFF FFFF and then wrap back to the value 0xE000 0000. This event does notcause an interrupt, but a Match register can be used to detect an overflow if needed.

5.5 Prescale Register (PR, TIMER2: T2PR - 0xE007 000C and TIMER3:
T3PR - 0xE007 400C)
The 16-bit Prescale Register specifies the maximum value for the Prescale Counter.

5.6 Prescale Counter register (PC, TIMER2: T2PC - 0xE007 0010 and
TIMER3: T3PC - 0xE007 4010)
The 16-bit Prescale Counter controls division of PCLK by some constant value before it isapplied to the Timer Counter. This allows control of the relationship between the resolutionof the timer and the maximum time before the timer overflows. The Prescale Counter isincremented 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.

5.7 Match Registers (MR0 - MR3)
The Match register values are continuously compared to the Timer Counter value. Whenthe two values are equal, actions can be triggered automatically. The action possibilities
are to generate an interrupt, reset the Timer Counter, or stop the timer. Actions arecontrolled by the settings in the MCR register.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

208 of 285

UM10161

NXP Semiconductors

Chapter 16: LPC2101/02/03 16-bit Timers Timer 2/3

5.8 Match Control Register (MCR, TIMER2: T2MCR - 0xE007 0014 and
TIMER3: T3MCR - 0xE007 4014)
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 shownin Table 16–180.
Table 180: Match Control Register (MCR, TIMER2: T2MCR - address 0xE007 0014 and TIMER3: T3MCR - address
0xE007 4014) bit description
Bit

Symbol

0

MR0I

1
2

MR0R
MR0S

3

MR1I

4

MR1R

5

6
7

MR1S

MR2I
MR2R

8

MR2S

9

MR3I

Value Description

Reset
value
0

1

Interrupt on MR0: an interrupt is generated when MR0 matches the value in the TC.

0This interrupt is disabled

1

Reset on MR0: the TC will be reset if MR0 matches it.

0

Feature disabled.

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.

1

Interrupt on MR1: an interrupt is generated when MR1 matches the value in the TC.

0This interrupt is disabled

1

Reset on MR1: the TC will be reset if MR1 matches it.

0

Feature disabled.

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.

1

Interrupt on MR2: an interrupt is generated when MR2 matches the value in the TC.

0This interrupt is disabled

0

0
0

0

1

Reset on MR2: the TC will be reset if MR2 matches it.

0

Feature disabled.

01

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.

1

Interrupt on MR3: an interrupt is generated when MR3 matches the value in the TC.

0This interrupt is disabled
Reset on MR3: the TC will be reset if MR3 matches it.

0

10

MR3R

1
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 areserved bit is not defined.

UM10161_3

User manual

0NA© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

209 of 285

UM10161

NXP Semiconductors

Chapter 16: LPC2101/02/03 16-bit Timers Timer 2/3

5.9 Capture Registers (CR0 - CR3)
Each Capture register is associated with a device pin and may be loaded with the TimerCounter value when a specified event occurs on that pin. The settings in the Capture
Control Register register determine whether the capture function is enabled, and whether
a capture event happens on the rising edge of the associated pin, the falling edge, or on
both edges.

5.10 Capture Control Register (CCR, TIMER2: T2CCR - 0xE007 0028 and
TIMER3: T3CCR - 0xE007 4028)
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 thesame time is a valid configuration, resulting in a capture event for both edges. In thedescription below, "n" represents the Timer number, 2 or 3.
Table 181: Capture Control Register (CCR, TIMER2: T2CCR - address 0xE007 0028 and TIMER3: T3CCR - address
0xE007 4028) bit description
Bit

SymbolValue Description

Reset
value

0

CAP0RE1

Capture on CAPn.0 rising edge: a sequence of 0 then 1 on CAPn.0 will cause CR0 to
be loaded with the contents of TC.

00

This feature is disabled.

1

Capture on CAPn.0 falling edge: a sequence of 1 then 0 on CAPn.0 will cause CR0 to
be loaded with the contents of TC.

0

This feature is disabled.

1

Interrupt on CAPn.0 event: a CR0 load due to a CAPn.0 event will generate aninterrupt.

0This feature is disabled.

1

Capture on CAPn.1 rising edge: a sequence of 0 then 1 on CAPn.1 will cause CR1 to
be loaded with the contents of TC.

0

This feature is disabled.

1

Capture on CAPn.1 falling edge: a sequence of 1 then 0 on CAPn.1 will cause CR1 to
be loaded with the contents of TC.

0

This feature is disabled.

1

Interrupt on CAPn.1 event: a CR1 load due to a CAPn.1 event will generate aninterrupt.

1

CAP0FE

2

CAP0I

3

4

5

6

7

CAP1RECAP1FE

CAP1I

CAP2RECAP2FE

8

CAP2I

15:9

-[1]

0

This feature is disabled.

1

Capture on CAPn.2 rising edge: A sequence of 0 then 1 on CAPn.2 will cause CR2 to
be loaded with the contents of TC.

0

This feature is disabled.

1

Capture on CAPn.2 falling edge: a sequence of 1 then 0 on CAPn.2 will cause CR2 to
be loaded with the contents of TC.

0

This feature is disabled.

1

Interrupt on CAPn.2 event: a CR2 load due to a CAPn.2 event will generate aninterrupt.

0This feature is disabled.
Reserved, user software should not write ones to reserved bits. The value read from areserved bit is not defined.

UM10161_3

User manual

0

0

0

0

0

0

0

0

NA

© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

210 of 285

UM10161

NXP Semiconductors

Chapter 16: LPC2101/02/03 16-bit Timers Timer 2/3[1]

On TIMER2/3, CAPn.3 is disabled and values for CAP3RE, CAP3FE, and CAP3I are not defined.

5.11 External Match Register (EMR, TIMER2: T2EMR - 0xE007 003C; andTIMER3: T3EMR - 0xE007 403C)
The External Match Register provides both control and status of the external match pins
MAT(0-3).
If the match ouputs are configured as PWM output, the function of the external matchregisters is determined by the PWM rules (Section 16–5.13 “Rules for single edge
controlled PWM ouputs” on page 212).
Table 182: External Match Register (EMR, TIMER2: T2EMR - address 0xE007 003C and TIMER3: T3EMR address0xE007 4016-bit3C) bit description
Bit

SymbolDescription

Reset
value

0

EM0

External Match 0. This bit reflects the state of output MAT2.0/MAT3.0, whether or not this 0
output is connected to its pin. When a match occurs between the TC and MR0, this outputof the timer can either toggle, go LOW, go HIGH, or do nothing. Bits EMR[5:4] control thefunctionality of this output.

1

EM1

External Match 1. This bit reflects the state of output MAT2.1/MAT3.1, whether or not this 0
output is connected to its pin. When a match occurs between the TC and MR1, this outputof the timer can either toggle, go LOW, go HIGH, or do nothing. Bits EMR[7:6] control thefunctionality of this output.

2

EM2

External Match 2. This bit reflects the state of output MAT2.2/MAT3.2, whether or not this 0
output is connected to its pin. When a match occurs between the TC and MR2, this outputof the timer can either toggle, go LOW, go HIGH, or do nothing. Bits EMR[9:8] control thefunctionality of this output.

3

EM3

External Match 3. This bit reflects the state of output MAT2.3/MAT3.3, whether or not this 0
output is connected to its pin. When a match occurs between the TC and MR3, this outputof 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 16–183
shows the encoding of these bits.

00

7:6

EMC1

External Match Control 1. Determines the functionality of External Match 1. Table 16–183
shows the encoding of these bits.

00

9:8

EMC2

External Match Control 2. Determines the functionality of External Match 2. Table 16–183
shows the encoding of these bits.

00

11:10

EMC3

External Match Control 3. Determines the functionality of External Match 3. Table 16–183
shows the encoding of these bits.

00

15:12

-

Reserved, user software should not write ones to reserved bits. The value read from areserved bit is not defined.

NA

Table 183. External match control
EMR[11:10], EMR[9:8],
EMR[7:6], or EMR[5:4]

Function00

Do Nothing.

01

Clear the corresponding External Match bit/output to 0 (MATn.m pin is LOW if pinned out).

10

Set the corresponding External Match bit/output to 1 (MATn.m pin is HIGH if pinned out).

11

Toggle the corresponding External Match bit/output.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

211 of 285

UM10161

NXP Semiconductors

Chapter 16: LPC2101/02/03 16-bit Timers Timer 2/3

5.12 PWM Control register (PWMCON, TIMER2: PWM2CON - 0xE007 0074
and TIMER3: PWM3CON - 0xE007 4074)
The PWM Control Register is used to configure the match outputs as PWM outputs. Each
match output can be independently set to perform either as PWM output or as match
output whose function is controlled by the External Match Register (EMR).
For each timer, a maximum of three single edge controlled PWM outputs can be selectedon the MATn.2:0 outputs. One additional match register determines the PWM cycle
length. When a match occurs in any of the other match registers, the PWM output is set to
HIGH. The timer is reset by the match register that is configured to set the PWM cycle
length. When the timer is reset to zero, all currently HIGH match outputs configured as
PWM outputs are cleared.
Table 184: PWM Control Register (PWMCON, TIMER2: PWM2CON - 0xE007 0074 and
TIMER3: PWM3CON - 0xE007 4074) bit description
Bit

SymbolDescription

Reset value0

PWM enable

When one, PWM mode is enabled for MATn.0. Whenzero, MATn.0 is controlled by EM0.

01

PWM enable

When one, PWM mode is enabled for MATn.1. Whenzero, MATn.1 is controlled by EM1.

02

PWM enable

When one, PWM mode is enabled for MATn.2. Whenzero, MATn.2 is controlled by EM2.

03

PWM enable

When one, PWM mode is enabled for MATn.3. Whenzero, MATn.3 is controlled by EM3.

0

Note: It is recommended to use MATn.3 to set the PWM
cycle because it is not pinned out on Timer2.
4:32-

Reserved, user software should not write ones toreserved bits. The value read from a reserved bit is notdefined.

NA

5.13 Rules for single edge controlled PWM ouputs
1. All single edge controlled PWM outputs go LOW at the beginning of each PWM cycle(timer is set to zero) unless their match value is equal to zero.
2. Each PWM output will go HIGH when its match value is reached. If no match occurs(i.e. the match value is greater than the PWM cycle length), the PWM output remains
continuously LOW.
3. If a match value larger than the PWM cycle length is written to the match register, and
the PWM signal is HIGH already, then the PWM signal will be cleared on the next startof the next PWM cycle.
4. If a match register contains the same value as the timer reset value (the PWM cycle
length), then the PWM output will be reset to LOW on the next clock tick. Therefore,
the PWM output will always consist of a one clock tick wide positive pulse with aperiod determined by the PWM cycle length (i.e. the timer reload value).
5. If a match register is set to zero, then the PWM output will go to HIGH the first time thetimer goes back to zero and will stay HIGH continuously.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

212 of 285

UM10161

NXP Semiconductors

Chapter 16: LPC2101/02/03 16-bit Timers Timer 2/3

Note: When the match outputs are selected to perform as PWM outputs, the timer reset(MRnR) and timer stop (MRnS) bits in the Match Control Register MCR must be set tozero except for the match register setting the PWM cycle length. For this register, set the
MRnR bit to one to enable the timer reset when the timer value matches the value of thecorresponding match register.

PWM2/MAT2

MR2 = 100

PWM1/MAT1

MR1 = 41

PWM0/MAT0

MR0 = 65

0

41

65

100
(counter is reset)

Fig 56. Sample PWM waveforms with a PWM cycle length of 100 (selected by MR3) andMAT3:0 enabled as PWM outputs by the PWCON register.

6. Example timer operation
Figure 16–57 shows a timer configured to reset the count and generate an interrupt onmatch. The prescaler is set to 2 and the match register set to 6. At the end of the timer
cycle where the match occurs, the timer count is reset. This gives a full length cycle to thematch value. The interrupt indicating that a match occurred is generated in the next clock
after the timer reached the match value.
Figure 16–58 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
prescalecounter2

timer
counter

4

0

1
5

2

0

1

2

6

0

1
0

2

0

1
1

timer counter
reset
interrupt

Fig 57. A timer cycle in which PR=2, MRx=6, and both interrupt and reset on match are enabled

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

213 of 285

UM10161

NXP Semiconductors

Chapter 16: LPC2101/02/03 16-bit Timers Timer 2/3

PCLK
prescale counter
timer counter
TCR[0](counter enable)

2
4

0

1
5
1

2

0
6
0

interrupt

Fig 58. A timer cycle in which PR=2, MRx=6, and both interrupt and stop on match are enabled

7. Architecture
The block diagram for TIMER/COUNTER2 and TIMER/COUNTER3 is shown in
Figure 16–59.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

214 of 285

UM10161

NXP Semiconductors

Chapter 16: LPC2101/02/03 16-bit Timers Timer 2/3

MATCH REGISTER 0
MATCH REGISTER 1
MATCH REGISTER 2
MATCH REGISTER 3
MATCH CONTROL REGISTER
EXTERNAL MATCH REGISTERINTERRUPT REGISTERCONTROL=

MATn[3:0]
INTERRUPT=CAP2[2:0]=

STOP ON MATCH
RESET ON MATCH
LOAD[3:0]=

CAPTURE CONTROL REGISTERCSNCAPTURE REGISTER 0(1)TIMER COUNTER(1)CAPTURE REGISTER 1CE

CAPTURE REGISTER 2(1)

TCI
PCLK
PRESCALE COUNTER
reset

enableTIMER CONTROL REGISTERMAXVALPRESCALE REGISTER(1) The capture registers are not available on TIMER3.

Fig 59. Timer2/3 block diagram

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

215 of 285

UM10161
Chapter 17: LPC2101/02/03 WatchDog Timer (WDT)
Rev. 3 — 2 October 2008

User manual

1. Features• Internally resets chip if not periodically reloaded.
• Supports Debug mode.
• Watchdog timer is 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 indicates watchdog reset.
• Includes programmable 32-bit timer with internal pre-scaler.
• Time period can be selected from (TPCLK x 256 x 4) to (TPCLK x 232 x 4) in multiples of
TPCLK x 4.

2. Applications
The purpose of the watchdog is to reset the microcontroller within a reasonable amount oftime 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 predeterminedamount of time.
For interaction of the on-chip watchdog and other peripherals, especially the reset andboot-up procedures, please read Section 5–10 “Reset” on page 55 of this document.

3. 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:• Set the watchdog timer constant reload value in WDTC register.
• Setup mode in WDMOD register.
• Start the watchdog by writing 0xAA followed by 0x55 to the WDFEED register.
• Watchdog should be fed again before the watchdog counter underflows to prevent
reset/interrupt.
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.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

216 of 285

UM10161

NXP Semiconductors

Chapter 17: LPC2101/02/03 WatchDog Timer (WDT)

4. Register description
The watchdog contains 4 registers as shown in Table 17–185 below.
Table 185. Watchdog register map
Name

Description

WDMOD

Watchdog Mode register. This register contains the R/Wbasic mode and status of the Watchdog Timer.

0

0xE000 0000

WDTC

Watchdog Timer Constant register. This register
determines the time-out value.

R/W

0xFF

0xE000 0004

WDFEED Watchdog Feed sequence register. Writing 0xAA
followed by 0x55 to this register reloads the
Watchdog timer to its preset value.

WO

NA

0xE000 0008

0xFF

0xE000 000C

WDTV
[1]

Access Reset
Addressvalue[1]

Watchdog Timer Value register. This register reads RO
out the current value of the Watchdog timer.

Reset value reflects the data stored in used bits only. It does not include reserved bits content.

4.1 Watchdog Mode register (WDMOD - 0xE000 0000)
The WDMOD register controls the operation of the watchdog as per the combination of
WDEN and RESET bits.
Table 186. Watchdog operating modes selection
WDEN

WDRESET

Mode of Operation0

X (0 or 1)

Debug/Operate without the watchdog running.

1

0

Watchdog Interrupt Mode: debug with the Watchdog interrupt but no
WDRESET enabled.
When this mode is selected, a watchdog counter underflow will set the
WDINT flag and the watchdog interrupt request will be generated.

1

1

Watchdog Reset Mode: operate with the watchdog interrupt and
WDRESET enabled.
When this mode is selected, a watchdog counter underflow will reset
the microcontroller. While the watchdog interrupt is also enabled inthis case (WDEN = 1) it will not be recognized since the watchdog
reset will clear the WDINT flag.

Once the WDEN and/or WDRESET bits are set they can not be cleared by software. Bothflags 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 iscleared by software.
WDINT The Watchdog Interrupt Flag is set when the watchdog times out. This flag iscleared when any reset occurs. Once the watchdog interrupt is serviced, it can bedisabled in the VIC or the watchdog interrupt request will be generated indefinitely.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

217 of 285

UM10161

NXP Semiconductors

Chapter 17: LPC2101/02/03 WatchDog Timer (WDT)

Table 187: Watchdog Mode register (WDMOD - address 0xE000 0000) bit description
Bit

SymbolDescription

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
bits. The value read from a reserved bit is not defined.

NA

4.2 Watchdog Timer Constant register (WDTC - 0xE000 0004)
The WDTC register determines the time-out value. Every time a feed sequence occurs
the WDTC content is reloaded in to the watchdog timer. It’s a 32-bit register with 8 LSB set
to 1 on reset. Writing values below 0xFF will cause 0xFF to be loaded to the WDTC. Thus
the minimum time-out interval is TPCLK × 256 × 4.
Table 188: Watchdog Timer Constant register (WDTC - address 0xE000 0004) bit description
Bit

SymbolDescription

Reset value

31:0

Count

Watchdog time-out interval.

0x0000 00FF

4.3 Watchdog Feed register (WDFEED - 0xE000 0008)
Writing 0xAA followed by 0x55 to this register will reload the watchdog timer to the WDTC
value. This operation will also start the watchdog if it is enabled via the WDMOD register.
Setting the WDEN bit in the WDMOD register is not sufficient to enable the watchdog. A
valid feed sequence must first be completed before the watchdog is capable of generating
an interrupt/reset. Until then, the watchdog will ignore feed errors. After writing 0xAA to
WFEED, access to any WatchDog register other than writing 0x55 to WFEED causes animmediate reset/interrupt when the WatchDog is enabled. The interrupt/reset will be
generated during the second PCLK following an incorrect access to a watchdog timer
register during a feed sequence.
Remark: Interrupts must be disabled during the feed sequence. An abort condition will
occur if an interrupt happens during the feed sequence.
Table 189: Watchdog Feed register (WDFEED - address 0xE000 0008) bit description
Bit

SymbolDescription

Reset value

7:0

Feed

Feed value should be 0xAA followed by 0x55.

NA

4.4 Watchdog Timer Value register (WDTV - 0xE000 000C)
The WDTV register is used to read the current value of watchdog timer.
Table 190: Watchdog Timer Value register (WDTV - address 0xE000 000C) bit description
Bit

SymbolDescription

Reset value

31:0

Count

Counter timer value.

0x0000 00FF

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

218 of 285

UM10161

NXP Semiconductors

Chapter 17: LPC2101/02/03 WatchDog Timer (WDT)

5. Block diagram
The block diagram of the Watchdog is shown below in the Figure 17–60.

WDTC

feed sequence
feed error

feed ok
WDFEED

32 BIT DOWNCOUNTER

PLCK/4

underflow

enablecount 1
WDTV
register

CURRENT WD
TIMER COUNTSHADOW BIT

WDMODregister

WDEN 2

WDTOF

WDINT

WDRESET 2

resetinterrupt(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 60. Watchdog block diagram

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

219 of 285

UM10161
Chapter 18: LPC2101/02/03 Real-time clock (RTC)
Rev. 3 — 2 October 2008

User manual

1. Features• Measures the passage of time to maintain a calendar and clock.
• Ultra Low Power design supports battery powered systems.
• Provides Seconds, Minutes, Hours, Day of Month, Month, Year, Day of Week, andDay of Year.

• Can be used with dedicated 32 kHz oscillator or programmable prescaler from APB
clock.

• Dedicated power supply pin can be connected to a battery or to the main 3.3 V.

2. Description
The Real Time Clock (RTC) is a set of counters for measuring time when system power ison and optionally when it is off. It uses little power in Power-down mode. On the
LPC2101/02/03, the RTC can be clocked by a separate 32.768 KHz oscillator or by aprogrammable prescale divider based on the APB clock.
The RTC is powered by its own power supply pin, VBAT, which must be connected to abattery or to the same 3.3 V supply used by the rest of the device. Note that the PLL isdisabled when waking up from power down. See Section 5–8.8 for the PLL start-up
procedure.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

220 of 285

UM10161

NXP Semiconductors

Chapter 18: LPC2101/02/03 Real-time clock (RTC)

3. Architecture

RTC OSCILLATOR
CLK32kMUXCLOCK GENERATORREFERENCE CLOCK DIVIDER(PRESCALER)
strobe

CLK1

CCLK

TIME COUNTERS

counterenables

ALARM
REGISTERSCOMPARATORSCOUNTER INCREMENTALARM MASKINTERRUPT ENABLE

REGISTERINTERRUPT GENERATOR

Fig 61. RTC block diagram

4. Pin description
Table 191. RTC pin description
Name

Type

Description

RTCX1

I

Input to the RTC oscillator circuit.

RTCX2

O

Output from the RTC oscillator circuit.
Remark: If the RTC is not used, the RTCX1/2 pins can be left
floating.

VBAT

I

RTC power supply: 3.3 V on this pin supplies the power to the
RTC.
Remark: VBAT must always be connected to either pin VDD(3V3) oran independent power supply (external battery).

5. Register description
The RTC includes a number of registers. The address space is split into four sections byfunctionality. 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.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

221 of 285

UM10161

NXP Semiconductors

Chapter 18: LPC2101/02/03 Real-time clock (RTC)

The Real Time Clock includes the register shown in Table 18–192. Detailed descriptionsof the registers follow. Most registers are not changed by a Reset, and the Reset value isnoted as NC (“Not Changed”).
Table 192. Real Time Clock (RTC) register map
Name

Size Description

AccessResetvalue[1]Address

ILR

2

Interrupt Location Register

R/W

NC

0xE002 4000

CTC

15

Clock Tick CounterRONC

0xE002 4004

CCR

4Clock Control Register

R/W

NC

0xE002 4008

CIIR

8

Counter Increment Interrupt Register

R/W

NC

0xE002 400C

AMR

8Alarm Mask Register

R/W

NC

0xE002 4010

CTIME032

Consolidated Time Register 0RONC

0xE002 4014

CTIME132

Consolidated Time Register 1

RONC

0xE002 4018

CTIME232

Consolidated Time Register 2RONC

0xE002 401C

SEC

6Seconds Counter

R/W

NC

0xE002 4020

MIN

6

Minutes Register

R/W

NC

0xE002 4024

HOUR

5

Hours Register

R/W

NC

0xE002 4028

DOM

5

Day of Month Register

R/W

NC

0xE002 402C

DOW

3

Day of Week Register

R/W

NC

0xE002 4030

DOY

9

Day of Year Register

R/W

NC

0xE002 4034

MONTH

4

Months Register

R/W

NC

0xE002 4038

YEAR

12

Years Register

R/W

NC

0xE002 403C

ALSEC

6

Alarm value for Seconds

R/W

NC

0xE002 4060

ALMIN

6

Alarm value for Minutes

R/W

NC

0xE002 4064

ALHOUR

5

Alarm value for Seconds

R/W

NC

0xE002 4068

ALDOM

5

Alarm value for Day of Month

R/W

NC

0xE002 406C

ALDOW

3

Alarm value for Day of Week

R/W

NC

0xE002 4070

ALDOY

9

Alarm value for Day of Year

R/W

NC

0xE002 4074

ALMON

4

Alarm value for Months

R/W

NC

0xE002 4078

ALYEAR

12

Alarm value for Year

R/W

NC

0xE002 407C

PREINT

13

PREFRAC 15[1]

Prescaler value, integer portion

R/W

0

0xE002 4080

Prescaler value, fractional portion

R/W

0

0xE002 4084

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.

5.1 RTC interrupts
Interrupt generation is controlled through the Interrupt Location Register (ILR), Counter
Increment Interrupt Register (CIIR), the alarm registers, and the Alarm Mask Register(AMR). Interrupts are generated only by the transition into the interrupt state. The ILR
separately enables CIIR and AMR interrupts. Each bit in CIIR corresponds to one of thetime counters. If CIIR is enabled for a particular counter, then every time the counter isincremented an interrupt is generated. The alarm registers allow the user to specify a date

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

222 of 285

UM10161

NXP Semiconductors

Chapter 18: LPC2101/02/03 Real-time clock (RTC)

and time for an interrupt to be generated. The AMR provides a mechanism to mask alarmcompares. If all nonmasked alarm registers match the value in their corresponding time
counter, then an interrupt is generated.
The RTC interrupt can bring the microcontroller out of power-down mode if the RTC is
operating from its own oscillator on the RTCX1-2 pins. When the RTC interrupt is enabled
for wake-up and its selected event occurs, X1/2 pins associated oscillator wake-up cycle
is started. For details on the RTC based wake-up process see Section 5–5.3 “Interrupt
Wake-up register (INTWAKE - 0xE01F C144)” on page 42 and Section 5–12 “Wake-up
timer” on page 59.

5.2 Miscellaneous register group
Table 18–193 summarizes the registers located from 0 to 7 of A[6:2]. More detailed
descriptions follow.
Table 193. Miscellaneous registers
Name

Size Description

ILR

2Interrupt Location. Reading this location
R/W
indicates the source of an interrupt. Writing a
one to the appropriate bit at this location clears
the associated interrupt.

Access0xE002 4000

Address

CTC

15

Clock Tick Counter. Value from the clock
divider.

RO

0xE002 4004

CCR

4Clock Control Register. Controls the function of R/W
the clock divider.

0xE002 4008

CIIR

8

Counter Increment Interrupt. Selects whichcounters will generate an interrupt when they
are incremented.

R/W

0xE002 400C

AMR

8Alarm Mask Register. Controls which of thealarm registers are masked.

R/W

0xE002 4010

CTIME032

Consolidated Time Register 0RO

0xE002 4014

CTIME132

Consolidated Time Register 1

RO

0xE002 4018

CTIME232

Consolidated Time Register 2RO

0xE002 401C

5.3 Interrupt Location Register (ILR - 0xE002 4000)
The Interrupt Location Register is a 2-bit register that specifies which blocks are
generating an interrupt (see Table 18–194). Writing a one to the appropriate bit clears thecorresponding interrupt. Writing a zero has no effect. This allows the programmer to readthis register and write back the same value to clear only the interrupt that is detected by
the read.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

223 of 285

UM10161

NXP Semiconductors

Chapter 18: LPC2101/02/03 Real-time clock (RTC)

Table 194: Interrupt Location Register (ILR - address 0xE002 4000) bit description
Bit

SymbolDescription

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 tothis bit location clears the alarm interrupt.

NA

7:2

-

Reserved, user software should not write ones to reserved bits. The
value read from a reserved bit is not defined.

NA

5.4 Clock Tick Counter Register (CTC - 0xE002 4004)
The Clock Tick Counter is read only. It can be reset to zero through the Clock Control
Register (CCR). The CTC consists of the bits of the clock divider counter.
Table 195: Clock Tick Counter Register (CTC - address 0xE002 4004) bit description
Bit

SymbolDescription

Reset
value

0

-

Reserved, user software should not write ones to reserved bits. The
value read from a reserved bit is not defined.

NA

15:1

NA
Clock Tick Prior to the Seconds counter, the CTC counts 32,768 clocks per
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 229 for details.

If the RTC is driven by the external 32.786 kHz oscillator, subsequent read operations of
the CTC may yield an incorrect result. The CTC is implemented as a 15-bit ripple counterso that not all 15 bits change simultaneously. The LSB changes first, then the next, and soforth. Since the 32.786 kHz oscillator is asynchronous to the CPU clock, it is possible for a
CTC read to occur during the time when the CTCR bits are changing, resulting in anincorrect large difference between back-to-back reads.
If the RTC is driven by the PCLK, the CPU and the RTC are synchronous because both oftheir clocks are driven from the PLL output. Therefore, incorrect consecutive reads can
not occur.

5.5 Clock Control Register (CCR - 0xE002 4008)
The clock register is a 5-bit register that controls the operation of the clock divide circuit.
Each bit of the clock register is described in Table 18–196.
Table 196: Clock Control Register (CCR - address 0xE002 4008) bit description
Bit

SymbolDescription

Reset
value

0

CLKEN

Clock Enable. When this bit is a one the time counters are enabled.
When it is a zero, they are disabled so that they may be initialized.

NA

1

CTCRST

CTC Reset. When one, the elements in the Clock Tick Counter are
reset. The elements remain reset until CCR[1] is changed to zero.

NA

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

224 of 285

UM10161

NXP Semiconductors

Chapter 18: LPC2101/02/03 Real-time clock (RTC)

Table 196: Clock Control Register (CCR - address 0xE002 4008) bit description
Bit

SymbolDescription

Reset
value

3:2

-

Reserved, user software should not write ones to reserved bits. The
value read from a reserved bit is not defined.

NA

4

CLKSRCIf this bit is 0, the Clock Tick Counter takes its clock from the Prescaler, NA
as on earlier devices in the Philips Embedded ARM family. If this bit is1, the CTC takes its clock from the 32 kHz oscillator that’s connected to
the RTCX1 and RTCX2 pins (see Section 18–8 “RTC external 32 kHz
oscillator component selection” for hardware details).

7:5-

Reserved, user software should not write ones to reserved bits. The
value read from a reserved bit is not defined.

NA

5.6 Counter Increment Interrupt Register (CIIR - 0xE002 400C)
The Counter Increment Interrupt Register (CIIR) gives the ability to generate an interrupt
every time a counter is incremented. This interrupt remains valid until cleared by writing a
one to bit zero of the Interrupt Location Register (ILR[0]).
Table 197: Counter Increment Interrupt Register (CIIR - address 0xE002 400C) bit description
Bit

SymbolDescription

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 aninterrupt.

NA

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

5.7 Alarm Mask Register (AMR - 0xE002 4010)
The Alarm Mask Register (AMR) allows the user to mask any of the alarm registers.
Table 18–198 shows the relationship between the bits in the AMR and the alarms. For thealarm function, every non-masked alarm register must match the corresponding time
counter for an interrupt to be generated. The interrupt is generated only when the countercomparison first changes from no match to match. The interrupt is removed when a one iswritten to the appropriate bit of the Interrupt Location Register (ILR). If all mask bits areset, then the alarm is disabled.
Table 198: Alarm Mask Register (AMR - address 0xE002 4010) bit description
Bit

SymbolDescription

Reset
value

0

AMRSECWhen 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

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

225 of 285

UM10161

NXP Semiconductors

Chapter 18: LPC2101/02/03 Real-time clock (RTC)

Table 198: Alarm Mask Register (AMR - address 0xE002 4010) bit description
Bit

SymbolDescription

Reset
value

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

5.8 Consolidated time registers
The values of the Time Counters can optionally be read in a consolidated format whichallows the programmer to read all time counters with only three read operations. The
various registers are packed into 32-bit values as shown in Table 18–199, Table 18–200,
and Table 18–201. The least significant bit of each register is read back at bit 0, 8, 16, or
24.
The Consolidated Time Registers are read only. To write new values to the TimeCounters, the Time Counter addresses should be used.

5.9 Consolidated Time register 0 (CTIME0 - 0xE002 4014)
The Consolidated Time Register 0 contains the low order time values: Seconds, Minutes,
Hours, and Day of Week.
Table 199: Consolidated Time register 0 (CTIME0 - address 0xE002 4014) bit description
Bit

SymbolDescription

Reset
value

5:0
7:6

Seconds

Seconds value in the range of 0 to 59

NA-

Reserved, user software should not write ones to reserved bits.
The value read from a reserved bit is not defined.

NA

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.
The value read from a reserved bit is not defined.

NA

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.
The value read from a reserved bit is not defined.

NA

26:24

Day Of Week Day of week value in the range of 0 to 6

NA

31:27

-

NA

Reserved, user software should not write ones to reserved bits.
The value read from a reserved bit is not defined.

5.10 Consolidated Time register 1 (CTIME1 - 0xE002 4018)
The Consolidate Time register 1 contains the Day of Month, Month, and Year values.
Table 200: Consolidated Time register 1 (CTIME1 - address 0xE002 4018) bit description
Bit

SymbolDescription

4:0

Day of Month Day of month value in the range of 1 to 28, 29, 30, or 31(depending on the month and whether it is a leap year).

NA

7:5

-

Reserved, user software should not write ones to reserved bits.
The value read from a reserved bit is not defined.

NA

11:8

Month

Month value in the range of 1 to 12.

NA

UM10161_3

User manual

Reset
value

© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

226 of 285

UM10161

NXP Semiconductors

Chapter 18: LPC2101/02/03 Real-time clock (RTC)

Table 200: Consolidated Time register 1 (CTIME1 - address 0xE002 4018) bit description
Bit

SymbolDescription

Reset
value

15:12

-

Reserved, user software should not write ones to reserved bits.
The value read from a reserved bit is not defined.

NA

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.
The value read from a reserved bit is not defined.

NA

5.11 Consolidated Time register 2 (CTIME2 - 0xE002 401C)
The Consolidate Time register 2 contains just the Day of Year value.
Table 201: Consolidated Time register 2 (CTIME2 - address 0xE002 401C) bit description
Bit

SymbolDescription

Reset
value

11:0

Day of YearDay 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.
The value read from a reserved bit is not defined.

NA

5.12 Time counter group
The time value consists of the eight counters shown in Table 18–202 and Table 18–203.
These counters can be read or written at the locations shown in Table 18–203.
Table 202. Time counter relationships and values
Counter

Size

Enabled by

Minimum value

Maximum value

Second6

Clk1 (seeFigure 18–61)

059

Minute6Second

0

59

Hour

5

Minute023

Day of Month

5

Hour

1

28, 29, 30 or 31

Day of Week

3

Hour

0

6

Day of Year

9

Hour

1

365 or 366 (for leap year)

Month

4

Day of Month

1

12

Year

12

Month or day of Year

0

4095

Table 203. Time counter registers
Name

Size Description

AccessAddress

SEC

6

Seconds value in the range of 0 to 59

R/W

0xE002 4020

MIN

6

Minutes value in the range of 0 to 59

R/W

0xE002 4024

HOUR

5

Hours value in the range of 0 to 23

R/W

0xE002 4028

DOM

5

Day of month value in the range of 1 to 28, 29, 30, R/W
or 31 (depending on the month and whether it is aleap year).[1]0xE002 402C

DOW

3

Day of week value in the range of 0 to 6[1]0xE002 4030

UM10161_3

User manual

R/W© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

227 of 285

UM10161

NXP Semiconductors

Chapter 18: LPC2101/02/03 Real-time clock (RTC)

Table 203. Time counter registers
Name

Size Description

DOY

9

Day of year value in the range of 1 to 365 (366 for R/Wleap years)[1]0xE002 4034

MONTH

4

Month value in the range of 1 to 12

R/W

0xE002 4038

YEAR

12

Year value in the range of 0 to 4095

R/W

0xE002 403C

[1]

AccessAddress

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.

5.13 Leap year calculation
The RTC does a simple bit comparison to see if the two lowest order bits of the year
counter are zero. If true, then the RTC considers that year a leap year. The RTC considers
all years evenly divisible by 4 as leap years. This algorithm is accurate from the year 1901
through the year 2099, but fails for the year 2100, which is not a leap year. The only effectof leap year on the RTC is to alter the length of the month of February for the month, dayof month, and year counters.

5.14 Alarm register group
The alarm registers are shown in Table 18–204. The values in these registers arecompared with the time counters. If all the unmasked (See Section 18–5.7 “Alarm Mask
Register (AMR - 0xE002 4010)” on page 225) alarm registers match their correspondingtime counters then an interrupt is generated. The interrupt is cleared when a one is written
to bit one of the Interrupt Location Register (ILR[1]).
Table 204. Alarm registers
Name

Size

Description

AccessAddress

ALSEC

6

Alarm value for Seconds

R/W

0xE002 4060

ALMIN

6

Alarm value for Minutes

R/W

0xE002 4064

ALHOUR

5

Alarm value for Hours

R/W

0xE002 4068

ALDOM

5

Alarm value for Day of Month

R/W

0xE002 406C

ALDOW

3

Alarm value for Day of Week

R/W

0xE002 4070

ALDOY

9

Alarm value for Day of Year

R/W

0xE002 4074

ALMON

4

Alarm value for Months

R/W

0xE002 4078

ALYEAR

12

Alarm value for Years

R/W

0xE002 407C

6. RTC usage notes
If the RTC is used, VBAT must always be connected to either pin VDD(3V3) or an
independent power supply (external battery). No provision is made in the LPC2101/02/03
to retain RTC status upon the VBAT power loss, or to maintain time incrementation if theclock source is lost, interrupted, or altered.
Since the RTC operates using one of two available clocks (the APB clock (PCLK) or the
32 kHz signal coming from the RTCX1-2 pins), any interruption of the selected clock willcause the time to drift away from the time value it would have provided otherwise. The
variance could be to actual clock time if the RTC was initialized to that, or simply an error
in elapsed time since the RTC was activated.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

228 of 285

UM10161

NXP Semiconductors

Chapter 18: LPC2101/02/03 Real-time clock (RTC)

While the signal from RTCX1-2 pins can be used to supply the RTC clock at anytime,
selecting the PCLK as the RTC clock and entering the Power-down mode will cause alapse in the time update. Also, feeding the RTC with the PCLK and altering this timebase
during system operation (by reconfiguring the PLL, the APB divider, or the RTC prescaler)
will result in some form of accumulated time error. Accumulated time errors may also
occur when the RTC clock source is switched between the PCLK and the RTCX pins.
Once the 32 kHz signal from RTCX1-2 pins is selected as a clock source, the RTC can
operate completely without the presence of the APB clock (PCLK). Therefore, power
sensitive applications (i.e. battery powered application) utilizing the RTC will reduce thepower consumption by using the signal from RTCX1-2 pins and writing a 0 into the
PCRTC bit in the PCONP power control register (see Section 5–9 “Power control” onpage 53).
Remark: Note that if the RTC is running from the 32 kHz signal and powered by VBAT, theinternal registers can be read. However, they cannot be written to unless the PCRTC bit in
the PCONP register is set to 1 (see Section 5–9.3).

7. Reference clock divider (prescaler)
The reference clock divider (hereafter referred to as the prescaler) allows generation of a
32.768 kHz reference clock from any peripheral clock frequency greater than or equal to65.536 kHz (2 × 32.768 kHz). This permits the RTC to always run at the proper rate
regardless of the peripheral clock rate. Basically, the Prescaler divides the peripheral
clock (PCLK) by a value which contains both an integer portion and a fractional portion.
The result is not a continuous output at a constant frequency, some clock periods will be
one PCLK longer than others. However, the overall result can always be 32,768 counts
per second.
The reference clock divider consists of a 13-bit integer counter and a 15-bit fractionalcounter. The reasons for these counter sizes are as follows:
1. For frequencies that are expected to be supported by the LPC2101/02/03, a 13-bit
integer counter is required. This can be calculated as 160 MHz divided by
32,768 minus 1 = 4881 with a remainder of 26,624. Thirteen bits are needed to holdthe value 4881, but actually supports frequencies up to 268.4 MHz (32,768 × 8192).
2. The remainder value could be as large as 32,767, which requires 15 bits.
Table 205. Reference clock divider registers
Name

Size

Description

AccessAddress

PREINT

13

Prescale Value, integer portion

R/W

0xE002 4080

Prescale Value, fractional portion

R/W

0xE002 4084

PREFRAC 15

7.1 Prescaler Integer register (PREINT - 0xE002 4080)
This is the integer portion of the prescale value, calculated as:
PREINT = int (PCLK / 32768) − 1. The value of PREINT must be greater than or equal to1.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

229 of 285

UM10161

NXP Semiconductors

Chapter 18: LPC2101/02/03 Real-time clock (RTC)

Table 206: Prescaler Integer register (PREINT - address 0xE002 4080) bit description
Bit

SymbolDescription

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
bits. The value read from a reserved bit is not defined.

NA

7.2 Prescaler Fraction register (PREFRAC - 0xE002 4084)
This is the fractional portion of the prescale value, and may be calculated as:
PREFRAC = PCLK − ((PREINT + 1) × 32768).
Table 207: Prescaler Integer register (PREFRAC - address 0xE002 4084) bit description
Bit

SymbolDescription

Reset
value

14:0

Prescaler
FractionContains the integer portion of the RTC prescaler value.

0

15

-

Reserved, user software should not write ones to reserved
bits. The value read from a reserved bit is not defined.

NA

7.3 Example of prescaler usage
In a simplistic case, the PCLK frequency is 65.537 kHz. So:
PREINT = int (PCLK / 32768) − 1 = 1 and
PREFRAC = PCLK - ([PREINT + 1] × 32768) = 1
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 a more realistic case, the PCLK frequency is 10 MHz. Then,
PREINT = int (PCLK / 32768) − 1 = 304 and
PREFRAC = PCLK − ([PREINT + 1] × 32768) = 5,760.
In this case, 5,760 of the prescaler output clocks will be 306 (305 + 1) PCLKs long, therest will be 305 PCLKs long.
In a similar manner, any PCLK rate greater than 65.536 kHz (as long as it is an evennumber 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 persecond clocks are of the same length. Some of the clocks are one PCLK longer thanothers. 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 (CTC - 0xE002 4004)” on page 224).

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

230 of 285

UM10161

NXP Semiconductors

Chapter 18: LPC2101/02/03 Real-time clock (RTC)

PCLK(APB clock)to clock tick counter

CLK
CLK

UNDERFLOW

15 BIT FRACTION COUNTER

13 BIT INTEGER COUNTER(DOWN COUNTER)RELOAD
15

COMBINATORIAL LOGIC

13

extendreload1513 BIT RELOAD INTEGERREGISTER(PREINT)

15 BIT FRACTION REGISTER(PREFRAC)

13

15
APB busFig 62. RTC prescaler block diagram

7.4 Prescaler operation
The Prescaler block labelled "Combination Logic" in Figure 18–62 determines when thedecrement of the 13-bit PREINT counter is extended by one PCLK. In order to both insert
the correct number of longer cycles, and to distribute them evenly, the combinatorial Logic
associates each bit in PREFRAC with a combination in the 15-bit Fraction Counter. These
associations are shown in the following Table 18–208.
For example, if PREFRAC bit 14 is a one (representing the fraction 1/2), then half of thecycles 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 counterto be longer.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

231 of 285

UM10161

NXP Semiconductors

Chapter 18: LPC2101/02/03 Real-time clock (RTC)

Table 208. 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

8. RTC external 32 kHz oscillator component selection
The RTC external oscillator circuit is shown in Figure 18–63. Since the feedback
resistance is integrated on chip, only a crystal, the capacitances CX1 and CX2 need to beconnected externally to the microcontroller.

LPC2101/02/03

RTCX1

CX1

RTCX2

32 kHzXtal

CX2

Fig 63. RTC 32 kHz crystal oscillator circuit

Table 18–209 gives the crystal parameters that should be used. CL is the typical load
capacitance of the crystal and is usually specified by the crystal manufacturer. The actual
CL influences oscillation frequency. When using a crystal that is manufactured for a
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

232 of 285

UM10161

NXP Semiconductors

Chapter 18: LPC2101/02/03 Real-time clock (RTC)

different load capacitance, the circuit will oscillate at a slightly different frequency(depending on the quality of the crystal) compared to the specified one. Therefore for an
accurate time reference it is advised to use the load capacitors as specified inTable 18–209 that belong to a specific CL. The value of external capacitances CX1 and
CX2 specified in this table are calculated from the internal parasitic capacitances and the
CL. Parasitics from PCB and package are not taken into account.
Table 209. Recommended values for the RTC external 32 kHz oscillator CX1/X2 components
Crystal load capacitance Maximum crystal seriesCLresistance RS

External load capacitors CX1, CX2

11 pF< 100 kΩ18 pF, 18 pF

13 pF< 100 kΩ22 pF, 22 pF

15 pF< 100 kΩ27 pF, 27 pF

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

233 of 285

UM10161
Chapter 19: LPC2101/02/03 Flash memory system andprogramming
Rev. 3 — 2 October 2008

User manual

1. Boot loader
The boot loader controls initial operation after reset and also provides the means toaccomplish programming of the flash memory. This could be initial programming of a
blank device, erasure and re-programming of a previously programmed device, or
programming of the flash memory by the application program in a running system.

2. Features• In-System Programming: In-System programming (ISP) is 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 is performing erase
and write operation on the on-chip flash memory, as directed by the end-user
application code.

3. Applications
The boot loader provides both In-System and In-Application programming interfaces for
programming the on-chip flash memory.

4. Description
The 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 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 proper signal is present on X1 pin when the rising edge
on RESET pin is generated, it may take up to 3 ms before P0.14 is sampled and thedecision on whether to continue with user code or ISP handler is made. If P0.14 issampled 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 avalid user program is not found, the auto-baud routine is invoked.
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.

4.1 Memory map after any reset
The boot block is 8 kB in size and resides in the top of the on-chip memory space (startingfrom 0x7FFF E000). Both the ISP and IAP software use parts of the on-chip RAM. The
RAM usage is described later in this chapter. The interrupt vectors residing in the bootUM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

234 of 285

UM10161

NXP Semiconductors

Chapter 19: LPC2101/02/03 Flash memory system and programming

block of the on-chip flash memory also become active after reset, i.e., the bottom 64 bytesof the boot block are also visible in the memory region starting from the address
0x0000 0000. The reset vector contains a jump instruction to the entry point of the flash
boot loader software.

0x7FFF FFFF

2.0 GB
8 kB BOOT BLOCK

2.0 GB - 8 kB

(BOOT BLOCK INTERRUPT VECTORS)

0x7FFF E000

0x0000 7FFF

ON-CHIP FLASH MEMORYACTIVE INTERRUPT VECTORSFROM BOOT BLOCK
0.0 GB

0x0000 0000

Remark: Memory regions are not drawn to scale.

Fig 64. Map of lower memory after reset for LPC2103 with 32 kB of Flash memory

4.2 Criterion for valid user code
Criterion for valid user code: The reserved ARM interrupt vector location (0x0000 0014)
should contain the 2’s complement of the check-sum of the remaining interrupt vectors.
This causes the checksum of all of the vectors together to be 0. The boot loader code
disables the overlaying of the interrupt vectors from the boot block, then checksums theinterrupt vectors in sector 0 of the flash. If the signatures match then the execution control
is transferred to the user code by loading the program counter with 0x0000 0000. Hencethe user flash reset vector should contain a jump instruction to the entry point of the user
application code.
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 interms 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 hostshould 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
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

235 of 285

UM10161

NXP Semiconductors

Chapter 19: LPC2101/02/03 Flash memory system and programming

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 issent to the host after receiving the crystal frequency. If synchronization is not verified thenthe 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 thecommands 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 isrequired to be executed once per ISP session. The Unlock command is explained in
Section 19–8 “ISP commands” on page 240.

4.3 Communication protocol
All ISP commands should be sent as single ASCII strings. Strings should be terminatedwith 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.

4.4 ISP command format"Command Parameter_0 Parameter_1 ... Parameter_n<CR><LF>" "Data" (Data only for
Write commands)

4.5 ISP response format"Return_Code<CR><LF>Response_0<CR><LF>Response_1<CR><LF> ...
Response_n<CR><LF>" "Data" (Data only for Read commands)

4.6 ISP data format
The data stream is in UU-encode format. The UU-encode algorithm converts 3 bytes ofbinary data in to 4 bytes of printable ASCII character set. It is more efficient than Hex
format which converts 1 byte of binary data in to 2 bytes of ASCII hex. The sender should
send the check-sum after transmitting 20 UU-encoded lines. The length of any
UU-encoded line should not exceed 61 characters(bytes) i.e. it can hold 45 data bytes.
The receiver should compare it with the check-sum of the received bytes. If thecheck-sum matches then the receiver should respond with "OK<CR><LF>" to continue
further transmission. If the check-sum does not match the receiver should respond with
"RESEND<CR><LF>". In response the sender should retransmit the bytes.

4.7 ISP flow control
A software XON/XOFF flow control scheme is used to prevent data loss due to buffer
overrun. When the data arrives rapidly, the ASCII control character DC3 (stop) is sent tostop the flow of data. Data flow is resumed by sending the ASCII control character DC1(start). The host should also support the same flow control scheme.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

236 of 285

UM10161

NXP Semiconductors

Chapter 19: LPC2101/02/03 Flash memory system and programming

4.8 ISP command abort
Commands can be aborted by sending the ASCII control character "ESC". This feature is
not documented as a command under "ISP Commands" section. Once the escape code isreceived the ISP command handler waits for a new command.

4.9 Interrupts during ISP
The boot block interrupt vectors located in the boot block of the flash are active after any
reset.

4.10 Interrupts during IAP
The on-chip flash memory is not accessible during erase/write operations. When the user
application code starts executing the interrupt vectors from the user flash area are active.
The user should either disable interrupts, or ensure that user interrupt vectors are active in
RAM and that the interrupt handlers reside in RAM, before making a flash erase/write IAP
call. The IAP code does not use or disable interrupts.

4.11 RAM used by ISP command handler
ISP commands use on-chip RAM from 0x4000 0120 to 0x4000 01FF. The user could use
this area, but the contents may be lost upon reset. Flash programming commands use the
top 32 bytes of on-chip RAM. The stack is located at RAM top − 32. The maximum stackusage is 256 bytes and it grows downwards.

4.12 RAM used by IAP command handler
Flash programming commands use the top 32 bytes of on-chip RAM. The maximum stackusage in the user allocated stack space is 128 bytes and it grows downwards.

4.13 RAM used by RealMonitor
The RealMonitor uses on-chip RAM from 0x4000 0040 to 0x4000 011F. The user could
use this area if RealMonitor based debug is not required. The Flash boot loader does notinitialize the stack for RealMonitor.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

237 of 285

UM10161

NXP Semiconductors

Chapter 19: LPC2101/02/03 Flash memory system and programming

4.14 Boot process flowchartRESETINITIALIZE

no

CRP 1
ENABLED?

ENABLE DEBUG

yes

yes

WATCHDOG
FLAG SET?

noEnter ISP
MODE?
(PO.14 LOW?)

USER CODE
VALID?

no

no
yes

yes

EXECUTE INTERNALUSER CODERUN AUTO-BAUDno

AUTO-BAUD
SUCCESSFUL?

yes
RECEIVE CRYSTALFREQUENCYRUN ISP COMMAND
HANDLER(1) Code Read Protection

Fig 65. Boot process flowchart

5. Sector numbers
Some IAP and ISP commands operate on "sectors" and specify sector numbers. The
following table indicate the correspondence between sector numbers and memory
addresses for LPC2101/02/03 devices containing 8, 16, and 32 kB of Flash respectively.
IAP, ISP, and RealMonitor routines are located in the boot block. The boot block is present
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

238 of 285

UM10161

NXP Semiconductors

Chapter 19: LPC2101/02/03 Flash memory system and programmingat addresses 0x7FFF E000 to 0x7FFF FFFF in all devices. ISP and IAP commands do notallow write/erase/go operation on the boot block. The entire 8/16/32 kB of Flash memoryon the LPC2101/02/03 microcontrollers are available for user’s application.

SectorNumber

SectorSize [kB]

Address Range

LPC2101(8 kB)

LPC2102(16 kB)

LPC2103(32 kB)

Table 210. Flash sectors in LPC2101, LPC2102, LPC2103

040x0000 0000 - 0x0000 0FFF

+

+

+

1

4

0x0000 1000 - 0x0000 1FFF

+

+

+

2

4

0x0000 2000 - 0x0000 2FFF

+

+

3

4

0x0000 3000 - 0x0000 3FFF

+

+

4

4

0x0000 4000 - 0x0000 4FFF

+

5

4

0x0000 5000 - 0x0000 5FFF

+

6

4

0x0000 6000 - 0x0000 6FFF

+

7

4

0x0000 7000 - 0x0000 7FFF+

6. Flash content protection mechanism
The LPC2101/02/03/8 is equipped with the Error Correction Code (ECC) capable Flashmemory. The purpose of an error correction module is twofold. Firstly, it decodes datawords read from the memory into output data words. Secondly, it encodes data words tobe written to the memory. The error correction capability consists of single bit error
correction with Hamming code.
The operation of ECC is transparent to the running application. The ECC content itself isstored 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 areprotected by the first ECC byte, Flash bytes from 0x0000 0010 to 0x0000 001F areprotected by the second ECC byte, etc.
Whenever the CPU requests a read from user’s Flash, both 128 bits of raw datacontaining 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 andstored 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 describedabove.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

239 of 285

UM10161

NXP Semiconductors

Chapter 19: LPC2101/02/03 Flash memory system and programming

7. Code Read Protection (CRP)
Code read protection is enabled by programming the flash address location 0x1FC (Userflash sector 0) with value 0x8765 4321 (2271560481 Decimal). Address 0x1FC is used toallow some room for the FIQ exception handler. When the code read protection is enabled
the JTAG debug port, external memory boot and the following ISP commands are
disabled:• Read Memory• Write to RAM• Go• Copy RAM to FlashThe ISP commands mentioned above terminate with return code
CODE_READ_PROTECTION_ENABLED. The ISP erase command only allows erasureof all user sectors when the code read protection is enabled. This limitation does not exist
if the code read protection is not enabled. IAP commands are not affected by the code
read protection.
Important: CRP is active/inactive once the device has gone through a power cycle.

8. 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 211. ISP command summary
ISP Command

Usage

Described in

UnlockU <Unlock Code>

Table 19–212

Set Baud Rate

B <Baud Rate> <stop bit>

Table 19–213

Echo

A <setting>

Table 19–215

Write to RAM

W <start address> <number of bytes>

Table 19–216

Read Memory

R <address> <number of bytes>

Table 19–217

Prepare sector(s) for
write operation

P <start sector number> <end sector number>Table 19–218

Copy RAM to FlashC <Flash address> <RAM address> <number of bytes> Table 19–219

Go

G <address> <Mode>

Table 19–220

Erase sector(s)E <start sector number> <end sector number>Table 19–221

Blank check sector(s)I <start sector number> <end sector number>Table 19–222

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

240 of 285

UM10161

NXP Semiconductors

Chapter 19: LPC2101/02/03 Flash memory system and programming

Table 211. ISP command summary
ISP Command

Usage

Described in

Read Part ID

J

Table 19–223

Read Boot code version

K

Table 19–225

CompareM <address1> <address2> <number of bytes>

Table 19–226

8.1 Unlock <unlock code>
Table 212. ISP Unlock command
CommandU

Input

Unlock code: 2313010

Return CodeCMD_SUCCESS |INVALID_CODE |PARAM_ERROR

Description

This command is used to unlock flash Write, Erase, and Go commands.

Example"U 23130<CR><LF>" unlocks the flash Write/Erase & Go commands.

8.2 Set Baud Rate <baud rate> <stop bit>
Table 213. ISP Set Baud Rate command
CommandB

Input

Baud Rate: 9600 | 19200 | 38400 | 57600 | 115200 | 230400
Stop bit: 1 | 2

Return CodeCMD_SUCCESS |INVALID_BAUD_RATE |INVALID_STOP_BIT |PARAM_ERROR

Description

This command is used to change the baud rate. The new baud rate is effective
after the command handler sends the CMD_SUCCESS return code.

Example"B 57600 1<CR><LF>" sets the serial port to baud rate 57600 bps and 1 stop bit.

Table 214. Correlation between possible ISP baudrates and external crystal frequency (inMHz)
ISP Baudrate vs.
External Crystal Frequency

9600

19200

38400

10.0000+++

11.0592++

12.2880+++

14.7456+++

15.3600+

18.4320++

19.6608+++

24.5760+++

25.0000+++

UM10161_3

User manual

57600

115200230400

+

+

+
+
+

© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

241 of 285

UM10161

NXP Semiconductors

Chapter 19: LPC2101/02/03 Flash memory system and programming

8.3 Echo <setting>
Table 215. ISP Echo command
CommandA

Input

Setting: ON = 1 | OFF = 0

Return CodeCMD_SUCCESS |PARAM_ERROR

Description

The default setting for echo command is ON. When ON the ISP command handler
sends the received serial data back to the host.

Example"A 0<CR><LF>" turns echo off.

8.4 Write to RAM <start address> <number of bytes>
The host should send the data only after receiving the CMD_SUCCESS return code. The
host should send the check-sum after transmitting 20 UU-encoded lines. The checksum isgenerated by adding raw data (before UU-encoding) bytes and is reset after transmitting
20 UU-encoded lines. The length of any UU-encoded line should not exceed 61
characters(bytes) i.e. it can hold 45 data bytes. When the data fits in less then 20
UU-encoded lines then the check-sum should be of the actual number of bytes sent. The
ISP command handler compares it with the check-sum of the received bytes. If thecheck-sum matches, the ISP command handler responds with "OK<CR><LF>" tocontinue further transmission. If the check-sum does not match, the ISP command
handler responds with "RESEND<CR><LF>". In response the host should retransmit thebytes.
Table 216. ISP Write to RAM command
Command

W

Input

Start Address: RAM address where data bytes are to be written. This address
should be a word boundary.

Return CodeCMD_SUCCESS |Number of Bytes: Number of bytes to be written. Count should be a multiple of 4
ADDR_ERROR (Address not on word boundary) |ADDR_NOT_MAPPED |COUNT_ERROR (Byte count is not multiple of 4) |PARAM_ERROR |CODE_READ_PROTECTION_ENABLED
Description

This command is used to download data to RAM. Data should be in UU-encoded
format. This command is blocked when code read protection is enabled.

Example"W 1073742336 4<CR><LF>" writes 4 bytes of data to address 0x4000 0200.

8.5 Read memory <address> <no. of bytes>
The data stream is followed by the command success return code. The check-sum is sent
after transmitting 20 UU-encoded lines. The checksum is generated by adding raw data
(before UU-encoding) bytes and is reset after transmitting 20 UU-encoded lines. The
length of any UU-encoded line should not exceed 61 characters(bytes) i.e. it can hold 45
data bytes. When the data fits in less then 20 UU-encoded lines then the check-sum is ofactual number of bytes sent. The host should compare it with the checksum of thereceived bytes. If the check-sum matches then the host should respond with
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

242 of 285

UM10161

NXP Semiconductors

Chapter 19: LPC2101/02/03 Flash memory system and programming"OK<CR><LF>" to continue further transmission. If the check-sum does not match thenthe host should respond with "RESEND<CR><LF>". In response the ISP command
handler sends the data again.
Table 217. ISP Read memory command
Command

R

Input

Start Address: Address from where data bytes are to be read. This address
should be a word boundary.
Number of Bytes: Number of bytes to be read. Count should be a multiple of 4.

Return CodeCMD_SUCCESS followed by <actual data (UU-encoded)> |ADDR_ERROR (Address not on word boundary) |ADDR_NOT_MAPPED |COUNT_ERROR (Byte count is not a multiple of 4) |PARAM_ERROR |CODE_READ_PROTECTION_ENABLED

Description

This command is used to read data from RAM or Flash memory. This command isblocked when code read protection is enabled.

Example"R 1073741824 4<CR><LF>" reads 4 bytes of data from address 0x4000 0000.

8.6 Prepare sector(s) for write operation <start sector number> <end
sector number>This command makes flash write/erase operation a two step process.
Table 218. ISP Prepare sector(s) for write operation command
CommandP

Input

Start Sector Number
End Sector Number: Should be greater than or equal to start sector number.

Return CodeCMD_SUCCESS |BUSY |INVALID_SECTOR |PARAM_ERROR

Description

This command must be executed before executing "Copy RAM to Flash" or"Erase Sector(s)" command. Successful execution of the "Copy RAM to Flash" or"Erase Sector(s)" command causes relevant sectors to be protected again. Theboot block can not be prepared by this command. To prepare a single sector use
the same "Start" and "End" sector numbers.

Example"P 0 0<CR><LF>" prepares the flash sector 0.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

243 of 285

UM10161

NXP Semiconductors

Chapter 19: LPC2101/02/03 Flash memory system and programming

8.7 Copy RAM to flash <Flash address> <RAM address> <no of bytes>
Table 219. ISP Copy command
CommandC

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 areautomatically protected again once the copy command is successfully executed.
The boot block cannot be written by this command. This command is blocked whencode 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.

8.8 Go <address> <mode>
Table 220. ISP Go command
CommandG

Input

Address: Flash or RAM address from which the code execution is to be started.
This address should be on a word boundary.
Mode: T (Execute program in Thumb Mode) | A (Execute program in ARM mode).

Return Code CMD_SUCCESS |ADDR_ERROR |ADDR_NOT_MAPPED |CMD_LOCKED |PARAM_ERROR |CODE_READ_PROTECTION_ENABLED
Description

This command is used to execute a program residing in RAM or Flash memory. It
may not be possible to return to the ISP command handler once this command is
successfully executed. This command is blocked when code read protection isenabled.

Example"G 0 A<CR><LF>" branches to address 0x0000 0000 in ARM mode.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

244 of 285

UM10161

NXP Semiconductors

Chapter 19: LPC2101/02/03 Flash memory system and programming

8.9 Erase sector(s) <start sector number> <end sector number>Table 221. ISP Erase sector command
Command

E

Input

Start Sector Number
End Sector Number: Should be greater than or equal to start sector number.

Return Code CMD_SUCCESS |BUSY |INVALID_SECTOR |SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION |CMD_LOCKED |PARAM_ERROR |CODE_READ_PROTECTION_ENABLED
Description

This command is used to erase one or more sector(s) of on-chip Flash memory.
The boot block can not be erased using this command. This command only allows
erasure of all user sectors when the code read protection is enabled.

Example"E 2 3<CR><LF>" erases the flash sectors 2 and 3.

8.10 Blank check sector(s) <sector number> <end sector number>Table 222. ISP Blank check sector command
Command

I

Input

Start Sector Number:
End Sector Number: Should be greater than or equal to start sector number.

Return Code CMD_SUCCESS |SECTOR_NOT_BLANK (followed by <Offset of the first non blank word location><Contents of non blank word location>) |INVALID_SECTOR |PARAM_ERROR |Description

This command is used to blank check one or more sectors of on-chip Flashmemory.
Blank check on sector 0 always fails as first 64 bytes are re-mapped to flash
boot block.

Example"I 2 3<CR><LF>" blank checks the flash sectors 2 and 3.

8.11 Read part identification number
Table 223. ISP Read part identification number command
Command

J

Input

None.

Return Code CMD_SUCCESS followed by part identification number in ASCII (seeTable 19–224).
Description

This command is used to read the part identification number.

Table 224. LPC2101/02/03 part identification numbers
DeviceASCII/dec coding

Hex coding

LPC21033274410x0004 FF11

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

245 of 285

UM10161

NXP Semiconductors

Chapter 19: LPC2101/02/03 Flash memory system and programming

8.12 Read boot code version number
Table 225. ISP Read Boot code version number command
Command

K

Input

None

Return Code CMD_SUCCESS followed by 2 bytes of boot code version number in ASCII format.
It is to be interpreted as <byte1(Major)>.<byte0(Minor)>.
Description

This command is used to read the boot code version number.

8.13 Compare <address1> <address2> <no of bytes>
Table 226. ISP Compare command
CommandM

Input

Address1 (DST): Starting Flash or RAM address of data bytes to be compared.
This address should be a word boundary.
Address2 (SRC): Starting Flash or RAM address of data bytes to be compared.
This address should be a word boundary.
Number of Bytes: Number of bytes to be compared; should be a multiple of 4.

Return Code CMD_SUCCESS | (Source and destination data are equal)
COMPARE_ERROR | (Followed by the offset of first mismatch)
COUNT_ERROR (Byte count is not a multiple of 4) |ADDR_ERROR |ADDR_NOT_MAPPED |PARAM_ERROR |Description

This command is used to compare the memory contents at two locations.
Compare result may not be correct when source or destination addresscontains any of the first 64 bytes starting from address zero. First 64 bytes
are re-mapped to flash boot sector

Example"M 8192 1073741824 4<CR><LF>" compares 4 bytes from the RAM address
0x4000 0000 to the 4 bytes from the flash address 0x2000.

8.14 ISP Return codes
Table 227. ISP Return codes Summary
Return Mnemonic
Code

Description0

CMD_SUCCESS

Command is executed successfully. Sent by ISP
handler only when command given by the host has
been completely and successfully executed.

1

INVALID_COMMAND

Invalid command.

2

SRC_ADDR_ERROR

Source address is not on word boundary.

3

DST_ADDR_ERROR

Destination address is not on a correct boundary.

4

SRC_ADDR_NOT_MAPPED

Source address is not mapped in the memory map.
Count value is taken in to consideration whereapplicable.

5

DST_ADDR_NOT_MAPPED

Destination address is not mapped in the memory
map. Count value is taken in to consideration
where applicable.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

246 of 285

UM10161

NXP Semiconductors

Chapter 19: LPC2101/02/03 Flash memory system and programming

Table 227. ISP Return codes Summary
Return Mnemonic
Code

Description

6

COUNT_ERROR

Byte count is not multiple of 4 or is not a permitted
value.

7

INVALID_SECTOR

Sector number is invalid or end sector number isgreater than start sector number.

8

SECTOR_NOT_BLANK

Sector is not blank.

9

SECTOR_NOT_PREPARED_FOR_ Command to prepare sector for write operation
WRITE_OPERATION
was not executed.

10

COMPARE_ERROR

Source and destination data not equal.

11

BUSY

Flash programming hardware interface is busy.

12

PARAM_ERROR

Insufficient number of parameters or invalid
parameter.

13

ADDR_ERROR

Address is not on word boundary.

14

ADDR_NOT_MAPPED

Address is not mapped in the memory map. Countvalue is taken in to consideration where applicable.

15

CMD_LOCKED

Command is locked.

16

INVALID_CODE

Unlock code is invalid.

17

INVALID_BAUD_RATE

Invalid baud rate setting.

18

INVALID_STOP_BIT

Invalid stop bit setting.

19

CODE_READ_PROTECTION_ENABLED

Code read protection enabled.

9. IAP commands
For in application programming the IAP routine should be called with a word pointer inregister r0 pointing to memory (RAM) containing command code and parameters. Resultof the IAP command is returned in the result table pointed to by register r1. The user canreuse the command table for result by passing the same pointer in registers r0 and r1. The
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 the
Figure 19–66. The number of parameters and results vary according to the IAP command.
The maximum number of parameters is 5, passed to the "Copy RAM to FLASH"
command. The maximum number of results is 2, returned by the "Blankcheck sector(s)"command. The command handler sends the status code INVALID_COMMAND when an
undefined command is received. The IAP routine resides at 0x7FFF FFF0 location and itis thumb code.
The IAP function could be called in the following way using C.
Define the IAP location entry point. Since the 0th bit of the IAP location is set there will bea change to Thumb instruction set when the program counter branches to this address.
#define IAP_LOCATION 0x7ffffff1
Define data structure or pointers to pass IAP command table and result table to the IAP
function:unsigned long command[5];UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

247 of 285

UM10161

NXP Semiconductors

Chapter 19: LPC2101/02/03 Flash memory system and programming

unsigned long result[2];orunsigned long * command;
unsigned long * result;command=(unsigned long *) 0x……
result= (unsigned long *) 0x……
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.
typedef void (*IAP)(unsigned int [],unsigned int[]);
IAP iap_entry;
Setting function pointer:
iap_entry=(IAP) IAP_LOCATION;
Whenever you wish to call IAP you could use the following statement.
iap_entry (command, result);
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 be use this space if IAP flash
programming is permitted in the application.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

248 of 285

UM10161

NXP Semiconductors

Chapter 19: LPC2101/02/03 Flash memory system and programming

Table 228. IAP command summary
IAP Command

Command CodeDescribed in

Prepare sector(s) for write operation

5010

Table 19–229

Copy RAM to Flash

5110

Table 19–230

Erase sector(s)5210

Table 19–231

Blank check sector(s)5310

Table 19–232

Read Part ID

5410

Table 19–233

Read Boot code version

5510

Table 19–234

Compare5610

Table 19–235

Reinvoke ISP

5710

Table 19–236

COMMAND CODE
PARAMETER 1

commandparameter table

PARAMETER 2
ARM REGISTER r0

PARAMETER n
ARM REGISTER r1

STATUS CODERESULT 1

commandresult table

RESULT 2

RESULT n

Fig 66. IAP Parameter passing

9.1 Prepare sector(s) for write operation
This command makes flash write/erase operation a two step process.
Table 229. IAP Prepare sector(s) for write operation command
Command

Prepare sector(s) for write operation

Input

Command code: 5010
Param0: Start Sector Number
Param1: End Sector Number (should be greater than or equal to start sector
number).

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

249 of 285

UM10161

NXP Semiconductors

Chapter 19: LPC2101/02/03 Flash memory system and programming

Table 229. IAP Prepare sector(s) for write operation command
Command

Prepare sector(s) for write operation

Return CodeCMD_SUCCESS |BUSY |INVALID_SECTOR

ResultNone

Description

This command must be executed before executing "Copy RAM to Flash" or"Erase Sector(s)" command. Successful execution of the "Copy RAM to Flash" or"Erase Sector(s)" command causes relevant sectors to be protected again. Theboot sector can not be prepared by this command. To prepare a single sector use
the same "Start" and "End" sector numbers.

9.2 Copy RAM to flash
Table 230. IAP Copy RAM to flash command
Command

Copy RAM to Flash

Input

Command code: 5110
Param0(DST): Destination Flash address where data bytes are to be written. Thisaddress should be a 256 byte boundary.
Param1(SRC): Source RAM address from which data bytes are to be read. Thisaddress should be a word boundary.
Param2: Number of bytes to be written. Should be 256 | 512 | 1024 | 4096.
Param3: System Clock Frequency (CCLK) in kHz.

Return CodeCMD_SUCCESS |SRC_ADDR_ERROR (Address not a 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 |

ResultNone

Description

This command is used to program the flash memory. The affected sectors should
be prepared first by calling "Prepare Sector for Write Operation" command. The
affected sectors are automatically protected again once the copy command is
successfully executed. The boot sector can not be written by this command.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

250 of 285

UM10161

NXP Semiconductors

Chapter 19: LPC2101/02/03 Flash memory system and programming

9.3 Erase sector(s)Table 231. IAP Erase sector(s) command
CommandErase Sector(s)InputCommand code: 5210
Param0: Start Sector Number
Param1: End Sector Number (should be greater than or equal to start sector
number).
Param2: System Clock Frequency (CCLK) in kHz.

Return CodeCMD_SUCCESS |BUSY |SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION |INVALID_SECTOR

ResultNone

Description

This command is used to erase a sector or multiple sectors of on-chip Flashmemory. The boot sector can not be erased by this command. To erase a single
sector use the same "Start" and "End" sector numbers.

9.4 Blank check sector(s)Table 232. IAP Blank check sector(s) command
Command

Blank check sector(s)InputCommand code: 5310
Param0: Start Sector Number
Param1: End Sector Number (should be greater than or equal to start sector
number).

Return CodeCMD_SUCCESS |BUSY |SECTOR_NOT_BLANK |INVALID_SECTOR

ResultResult0: Offset of the first non blank word location if the Status Code is
SECTOR_NOT_BLANK.
Result1: Contents of non blank word location.

Description

This command is used to blank check a sector or multiple sectors of on-chip Flashmemory. To blank check a single sector use the same "Start" and "End" sector
numbers.

9.5 Read part identification number
Table 233. IAP Read Part Identification command
Command

Read part identification number

Input

Command code: 5410

Return CodeCMD_SUCCESS |ResultResult0: Part Identification Number (see Table 19–224 “LPC2101/02/03 part
identification numbers” on page 245 for details)

Description

This command is used to read the part identification number.

Parameters: None

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

251 of 285

UM10161

NXP Semiconductors

Chapter 19: LPC2101/02/03 Flash memory system and programming

9.6 Read boot code version number
Table 234. IAP Read Boot code version number command
Command

Read boot code version number

Input

Command code: 5510
Parameters: None

Return CodeCMD_SUCCESS |ResultResult0: 2 bytes of boot code version number in ASCII format. It is to beinterpreted as <byte1(Major)>.<byte0(Minor)>

Description

This command is used to read the boot code version number.

9.7 Compare <address1> <address2> <no of bytes>
Table 235. IAP Compare command
CommandCompareInput

Command code: 5610
Param0(DST): Starting Flash or RAM address of data bytes to be compared. Thisaddress should be a word boundary.
Param1(SRC): Starting Flash or RAM address of data bytes to be compared. Thisaddress should be a word boundary.
Param2: Number of bytes to be compared; should be a multiple of 4.

Return CodeCMD_SUCCESS |COMPARE_ERROR |COUNT_ERROR (Byte count is not a multiple of 4) |ADDR_ERROR |ADDR_NOT_MAPPEDResultDescription

Result0: Offset of the first mismatch if the Status Code is COMPARE_ERROR.
This command is used to compare the memory contents at two locations.
The result may not be correct when the source or destination includes anyof the first 64 bytes starting from address zero. The first 64 bytes can be
re-mapped to RAM.

9.8 Reinvoke ISP
Table 236. Reinvoke ISP
CommandCompareInput

Command code: 5710

Return Code

None

ResultNone.

Description

This command is used to invoke the bootloader in ISP mode. This command
maps boot vectors, configures P0.1 as an input and sets the APB divider register
to 0 before entering the ISP mode. This command may be used when a valid user
program is present in the internal flash memory and the P0.14 pin is notaccessible to force the ISP mode. This command does not disable the PLL hence
it is possible to invoke the bootloader when the part is running off the PLL. In suchcase the ISP utility should pass the PLL frequency after autobaud handshake.
Another option is to disable the PLL before making this IAP call.
Important: TIMER1 registers must be programmed with reset values before"Reinvoke ISP" command is used.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

252 of 285

UM10161

NXP Semiconductors

Chapter 19: LPC2101/02/03 Flash memory system and programming

9.9 IAP status codes
Table 237. IAP status codes summary
Status Mnemonic
Code

Description0

CMD_SUCCESS

Command is executed successfully.

1

INVALID_COMMAND

Invalid command.

2

SRC_ADDR_ERROR

Source address is not on a word boundary.

3

DST_ADDR_ERROR

Destination address is not on a correct boundary.

4

SRC_ADDR_NOT_MAPPED

Source address is not mapped in the memory map.
Count value is taken in to consideration whereapplicable.

5

DST_ADDR_NOT_MAPPED

Destination address is not mapped in the memory
map. Count value is taken in to consideration whereapplicable.

6

COUNT_ERROR

Byte count is not multiple of 4 or is not a permitted
value.

7

INVALID_SECTOR

Sector number is invalid.

8

SECTOR_NOT_BLANK

Sector is not blank.

9

SECTOR_NOT_PREPARED_
FOR_WRITE_OPERATION

Command to prepare sector for write operation was
not executed.

10

COMPARE_ERROR

Source and destination data is not same.

11

BUSY

Flash programming hardware interface is busy.

10. JTAG flash programming interface
Debug tools can write parts of the flash image to the RAM and then execute the IAP call
"Copy RAM to Flash" repeatedly with proper offset.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

253 of 285

UM10161
Chapter 20: LPC2101/02/03 EmbeddedICE logic
Rev. 3 — 2 October 2008

User manual

1. Features• No target resources are required by the software debugger in order to start the
debugging session.

• The software debugger talks via a JTAG (Joint Test Action Group) port directly to thecore.

• Instructions are inserted 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.

• Instructions can be executed at a slow debug speed or at a fast system speed.

2. 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.

3. Description
The ARM7TDMI-S Debug Architecture uses the existing JTAG1 port as a method ofaccessing the core. The scan chains that are around the core for production test arereused in the debug state to capture information from the data bus 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 chainthat 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 theaddress bus, data bus and some control signals. Any bit can be masked so that its value
does not affect the comparison. Either watchpoint register can be configured as awatchpoint (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

1.

For more details refer to IEEE Standard 1149.1 - 1990 Standard Test Access Port and Boundary Scan Architecture.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

254 of 285

UM10161

NXP Semiconductors

Chapter 20: LPC2101/02/03 EmbeddedICE logic

trigger on an access to a peripheral and the second to trigger on the code segmentthat 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 forthe 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 oreven entering the debug state. The debug communication channel is accessed as aco-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 andcontrol registers are mapped in to addresses in the EmbeddedICE logic.

4. Pin description
Table 238. EmbeddedICE pin description
Pin Name

Type

Description

TMS

Input

Test Mode Select. The TMS pin selects the next state in the TAP statemachine.

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 thatdefine 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.

TRST

Input

Test Reset. The TRST pin can be used to reset the test logic within theEmbeddedICE logic.

DBGSEL

Input

Debug Select. When LOW at Reset, the P0.27 - P0.31 pins are
configured for alternate use via the Pin Connect Block. When HIGH at
Reset, the debug mode is entered.
For functionality provided by DBGSEL, see Section 20–8 “DEBUG mode”
on page 257

RTCK

OutputReturned Test Clock. Extra signal added to the JTAG port. Required fordesigns based on ARM7TDMI-S processor core. Multi-ICE (Development
system from ARM) uses this signal to maintain synchronization withtargets having slow or widely varying clock frequency. For details refer to"Multi-ICE System Design considerations Application Note 72 (ARM DAI
0072A)". Also used during entry into debug mode.

5. Reset state of multiplexed pins
On the LPC2101/02/03, the pins TMS, TCK, TDI, TDO, and TRST are multiplexed with
P0.27 - P0.31. To have them come up as a Debug port, DBGSEL needs to be held HIGH
during and after reset. Additionally, the RTCK pin needs to be HIGH when the reset is
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

255 of 285

UM10161

NXP Semiconductors

Chapter 20: LPC2101/02/03 EmbeddedICE logic

released. The RTCK pin can be driven HIGH externally or allowed to float HIGH via its
on-chip pull-up. To have them come up as GPIO pins, do not connect a bias resistor, andensure that any external driver connected to Pin 26 (RTCK) is either driving high or is in
high-impedance state during Reset.

6. Register description
The EmbeddedICE logic contains 16 registers as shown in Table 20–239 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.
Table 239. EmbeddedICE logic registers
Name

Width

Description

Address

Debug Control

6Force debug state, disable interrupts

00000

Debug Status

5

Status of debug

00001

Debug Comms Control Register32

Debug communication control register

00100

Debug Comms Data Register32

Debug communication data register

00101

Watchpoint 0 Address Value

32

Holds watchpoint 0 address value

01000

Watchpoint 0 Address Mask

32

Holds watchpoint 0 address mask

01001

Watchpoint 0 Data Value

32

Holds watchpoint 0 data value

01010

Watchpoint 0 Data Mask

32

Holds watchpoint 0 data mask

01011

Watchpoint 0 Control Value

9

Holds watchpoint 0 control value

01100

Watchpoint 0 Control Mask

8

Holds watchpoint 0 control mask

01101

Watchpoint 1 Address Value

32

Holds watchpoint 1 address value

10000

Watchpoint 1 Address Mask

32

Holds watchpoint 1 address mask

10001

Watchpoint 1 Data Value

32

Holds watchpoint 1 data value

10010

Watchpoint 1 Data Mask

32

Holds watchpoint 1 data mask

10011

Watchpoint 1 Control Value

9

Holds watchpoint 1 control value

10100

Watchpoint 1 Control Mask

8

Holds watchpoint 1 control mask

10101

7. Block diagram
The block diagram of the debug environment is shown below in Figure 20–67.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

256 of 285

UM10161

NXP Semiconductors

Chapter 20: LPC2101/02/03 EmbeddedICE logic

JTAG PORT
serialparallelinterface

EMBEDDED ICEINTERFACE
PROTOCOL
CONVERTER

5

EMBEDDED ICE

host running debugger
ARM7TDMI-STARGET BOARD

Fig 67. EmbeddedICE debug environment block diagram

8. DEBUG mode
The Debug mode connects the JTAG pins to the embedded ICE for program debugging
using an emulator or other development tool.

8.1 Enable Debug mode
The Debug mode is enabled through the use of the DBGSEL and RTCK pins.
To enable the debug mode, DBGSEL must be HIGH during and after the CPU is reset.
For normal (non-debug) operation, DBGSEL must be kept LOW at all times (seeFigure 20–68)

RST

DBGSEL1

RTCK 2(1) DBGSEL is tied or pulled LOW at all times. An internal pull-down will cause DBGSEL to be LOW if
it is not pulled HIGH externally.
(2) RTCK is not connected in the application and is pulled up internally.

Fig 68. Waveforms for normal operations (not in debug mode)

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

257 of 285

UM10161

NXP Semiconductors

Chapter 20: LPC2101/02/03 EmbeddedICE logic

For debugging with JTAG pins, RTCK must be HIGH as the RST pin is released (seeFigure 20–69). RTCK may be driven HIGH externally or allowed to float HIGH via its
on-chip pull-up. The RTCK output driver is disabled until the internal wake-up time has
expired, allowing an interval between the release of the external reset and the release of
the internal reset during which RTCK may be driven by an external signal if necessary.
This procedure establishes the P0.27 - P0.31 pins as the JTAG Test/Debug interface. Pinconnect block settings have no affect on P0.27 - P0.31 pins if they are initialized as JTAGpins.
For the effect of hardware override related to DBGSEL and RTCK see in Section 6–2.

RST

wake-up timer count timeinternal reset

DBGSEL1

RTCK 2,3(1) DBGSEL must be HIGH.
(2) RTCK must be HIGH as RST is released. An internal pull-up will cause RTCK to be HIGH if it is
not pulled LOW externally.
(3) The RTCK output driver will be turned on when the internal chip reset is released by the wake-up
timer.

Fig 69. Waveforms for debug mode using the primary JTAG pins.

8.2 JTAG pin selection
The Primary JTAG port can be selected for debugging only when DBGSEL and RTCK
pins are HIGH at reset (see Figure 20–69). If at least one of the DBGSEL or RTCK lines is
LOW at reset, JTAG will not be enabled and can not be used for later debugging.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

258 of 285

UM10161
Chapter 21: LPC2101/02/03 RealMonitor
Rev. 3 — 2 October 2008

User manual

1. 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.
Remark: RealMonitor is a configurable software module which enables real time debug.
RealMonitor is developed by ARM Inc. Information presented in this chapter is taken fromthe ARM document RealMonitor Target Integration Guide (ARM DUI 0142A). It applies toa specific configuration of RealMonitor software programmed in the on-chip ROM bootmemory of this device.
Refer to the white paper "Real Time Debug for System-on-chip", available at the official
ARM website, for background information.

2. Applications
Real time debugging

3. 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 (a target-based debug monitor)• Multi-ICE or other JTAG unit and EmbeddedICE logic (a hardware-based debug
solution).
Although both of these methods provide robust debugging environments, neither issuitable as a lightweight real-time monitor.
Angel is designed to load and debug independent applications that can run in a variety ofmodes, and communicate with the debug host using a variety of connections (such as aserial port or ethernet). Angel is required to save and restore full processor context, andthe occurrence of interrupts can be delayed as a result. Angel, as a fully functionaltarget-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 isbuilt 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 theprocessor is in this state, which can be millions of cycles, normal program execution issuspended, and interrupts cannot be serviced.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

259 of 285

UM10161

NXP Semiconductors

Chapter 21: LPC2101/02/03 RealMonitor

RealMonitor combines features and mechanisms from both Angel and Multi-ICE toprovide the services and functions that are required. In particular, it contains both theMulti-ICE communication mechanisms (the DCC using JTAG), and Angel-like support forprocessor 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 whileparts of application continue to run. Refer to Section 21–4 “How to enable Realmonitor” onpage 262 for details.

3.1 RealMonitor components
As shown in Figure 21–70, RealMonitor is split in to two functional components:

DEBUGGER
RDI 1.5.1

host
REALMONITOR.DLLRMHOST
RDI 1.5.1 RT

JTAG UNIT

RealMonitor
protocolDCC transmissions
over the JTAG linktargetTARGET BOARD AND
PROCESSORRMTARGETAPPLICATION

Fig 70. RealMonitor components

3.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 thedebugger 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).

3.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).
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

260 of 285

UM10161

NXP Semiconductors

Chapter 21: LPC2101/02/03 RealMonitor

3.4 How RealMonitor works
In general terms, the RealMonitor operates as a state machine, as shown in
Figure 21–71. RealMonitor switches between running and stopped states in response topackets received by the host or due to asynchronous events on the target. RMTarget
supports the triggering of only one breakpoint, watchpoint, stop, or semihosting SWI at atime. There is no provision to allow nested events to be saved and restored. So, forexample, if the user application has stopped at one breakpoint and another breakpoint
occurs in an IRQ handler, RealMonitor enters a panic state. No debugging can be
performed after RealMonitor enters this state.

SWI abort
undef
stop
SWI abort
undef
RUNNINGSTOPPEDPANIC

goFig 71. RealMonitor as a state machine

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 andreceive data. This communication between host and target is illustrated in Figure 21–70.
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 the user application is running, RMTarget typically uses IRQs generated by the
DCC. This means that if the user application also wants to use IRQs, it must pass any
DCC-generated interrupts to RealMonitor.
To allow nonstop debugging, the EmbeddedICE-RT logic in the processor generates a
Prefetch Abort exception when a breakpoint is reached, or a Data Abort exception when awatchpoint is hit. These exceptions are handled by the RealMonitor exception handlersthat inform the user, by way of the debugger, of the event. This allows user application tocontinue running without stopping the processor. RealMonitor considers user application
to consist of two parts:• a foreground application running continuously, typically in User, System, or SVC
mode• a background application containing interrupt and exception handlers that are
triggered by certain events in user system, including:– IRQs or FIQs
– Data and Prefetch aborts caused by user foreground application. This indicates anerror in the application being debugged. In both cases the host is notified and theuser application is stopped.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

261 of 285

UM10161

NXP Semiconductors

Chapter 21: LPC2101/02/03 RealMonitor– Undef exception caused by the undefined instructions in user foregroundapplication. This indicates an error in the application being debugged. RealMonitor
stops the user application until a "Go" packet is received from the host.
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 ispassed to rm_ReceiveData() (RealMonitor internal function). If the DCC write buffer isfree, control is passed to rm_TransmitData() (RealMonitor internal function). If there isnothing 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 thecommunications link.

• RealMonitor stops the foreground application. Both IRQs and FIQs continue to beserviced if they were enabled by the application at the time the foreground application
was stopped.

4. How to enable Realmonitor
The following steps must be performed to enable RealMonitor. A code example which
implements all the steps can be found at the end of this section.

4.1 Adding stacks
User must ensure that stacks are set up within application for each of the processor
modes used by RealMonitor. For each mode, RealMonitor requires a fixed number ofwords of stack space. User must therefore allow sufficient stack space for both
RealMonitor and application.
RealMonitor has the following stack requirements:
Table 240. RealMonitor stack requirement
Processor Mode

RealMonitor Stack Usage (Bytes)

Undef

48

Prefetch Abort

16

Data Abort

16

IRQ

8

4.2 IRQ mode
A stack for this mode is always required. RealMonitor uses two words on entry to its
interrupt handler. These are freed before nested interrupts are enabled.

4.3 Undef mode
A stack for this mode is always required. RealMonitor uses 12 words while processing an
undefined instruction exception.

4.4 SVC mode
RealMonitor makes no use of this stack.
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

262 of 285

UM10161

NXP Semiconductors

Chapter 21: LPC2101/02/03 RealMonitor

4.5 Prefetch Abort mode
RealMonitor uses four words on entry to its Prefetch abort interrupt handler.

4.6 Data Abort mode
RealMonitor uses four words on entry to its data abort interrupt handler.

4.7 User/System mode
RealMonitor makes no use of this stack.

4.8 FIQ mode
RealMonitor makes no use of this stack.

4.9 Handling exceptions
This section describes the importance of sharing exception handlers between
RealMonitor and user application.

4.10 RealMonitor exception handlingTo function properly, RealMonitor must be able to intercept certain interrupts andexceptions. Figure 21–72 illustrates how exceptions can be claimed by RealMonitor itself,or shared between RealMonitor and application. If user application requires the exception
sharing, they must provide function (such as app_IRQDispatch ()). Depending on thenature of the exception, this handler can either:• Pass control to the RealMonitor processing routine, such as rm_irqhandler2().
• Claim the exception for the application itself, such as app_IRQHandler ().
In a simple case where an application has no exception handlers of its own, theapplication can install the RealMonitor low-level exception handlers directly into the vector
table of the processor. Although the IRQ handler must get the address of the Vectored
Interrupt Controller. The easiest way to do this is to write a branch instruction (<address>)
into the vector table, where the target of the branch is the start address of the relevant
RealMonitor exception handler.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

263 of 285

UM10161

NXP Semiconductors

Chapter 21: LPC2101/02/03 RealMonitor

RealMonitor supplied exception vector handlers
RM_UNDEF_HANDLER()
RM_PREFETCHABORT_HANDLER()
RM_DATAABORT_HANDLER()
RM_IRQHANDLER()

RESET

UNDEF

SWI
sharing IRQs between RealMonitor and user IRQ handler
PREFETCH
ABORT

RM_IRQHANDLER2()DATA ABORTAPP_IRQDISPATCH

RESERVED

APP_IRQHANDLER2()
OR

IRQ

FIQ

Fig 72. Exception handlers

4.11 RMTarget initialization
While the processor is in a privileged mode, and IRQs are disabled, user must include aline of code within the start-up sequence of application to call rm_init_entry().

4.12 Code example
The following example shows how to setup stack, VIC, initialize RealMonitor and sharenon vectored interrupts:
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.
CODE32ENTRY;Define exception table. Instruct linker to place code at address 0x0000 0000
AREA exception_table, CODELDR pc, Reset_Address
LDR pc, Undefined_Address
LDR pc, SWI_Address
LDR pc, Prefetch_Address
LDR pc, Abort_Address
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

264 of 285

UM10161

NXP Semiconductors

Chapter 21: LPC2101/02/03 RealMonitor

NOP ; Insert User code valid signature here.
LDR pc, [pc, #-0xFF0] ;Load IRQ vector from VIC
LDR PC, FIQ_Address
Reset_Address
Undefined_Address
SWI_Address
Prefetch_Address
Abort_Address
FIQ_Address

DCD __init;Reset Entry point
DCD rm_undef_handler ;Provided by RealMonitor
DCD 0;User can put address of SWI handler here
DCD rm_prefetchabort_handler;Provided by RealMonitor
DCD rm_dataabort_handler;Provided by RealMonitor
DCD 0;User can put address of FIQ handler here

AREA init_code, CODE
ram_end EQU 0x4000xxxx ; Top of on-chip RAM.
__init; /*********************************************************************; * Set up the stack pointers for various processor modes. Stack grows; * downwards.
; *********************************************************************/LDR r2, =ram_end ;Get top of RAM
MRS r0, CPSR ;Save current processor mode
; Initialize the Undef mode stack for RealMonitor use
BIC r1, r0, #0x1f
ORR r1, r1, #0x1b
MSR CPSR_c, r1;Keep top 32 bytes for flash programming routines.
;Refer to Flash Memory System and Programming chapter
SUB sp,r2,#0x1F; Initialize the Abort mode stack for RealMonitor
BIC r1, r0, #0x1f
ORR r1, r1, #0x17
MSR CPSR_c, r1;Keep 64 bytes for Undef mode stack
SUB sp,r2,#0x5F; Initialize the IRQ mode stack for RealMonitor and User
BIC r1, r0, #0x1f
ORR r1, r1, #0x12
MSR CPSR_c, r1;Keep 32 bytes for Abort mode stack
SUB sp,r2,#0x7F; Return to the original mode.
MSR CPSR_c, r0; Initialize the stack for user application; Keep 256 bytes for IRQ mode stack
SUB sp,r2,#0x17F

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

265 of 285

UM10161

NXP Semiconductors

Chapter 21: LPC2101/02/03 RealMonitor; /*********************************************************************; * 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.
; *********************************************************************/
VICBaseAddr
EQU 0xFFFFF000 ; VIC Base address
VICDefVectAddrOffset EQU 0x34
LDR
LDR
STR

r0, =VICBaseAddr
r1, =app_irqDispatch
r1, [r0,#VICDefVectAddrOffset]BL
rm_init_entry;Initialize RealMonitor;enable FIQ and IRQ in ARM Processor
MRS r1, CPSR
; get the CPSR
BIC r1, r1, #0xC0; enable IRQs and FIQs
MSR CPSR_c, r1; update the CPSR
; /*********************************************************************; * Get the address of the User entry point.
; *********************************************************************/LDR lr, =User_Entry
MOV pc, lr; /*********************************************************************; * Non vectored irq handler (app_irqDispatch); *********************************************************************/
AREA app_irqDispatch, CODE
VICVectAddrOffset EQU 0x30
app_irqDispatch;enable interrupt nesting
STMFD sp!, {r12,r14}
MRS r12, spsr
MSR cpsr_c,0x1F;Save SPSR in to r12;Re-enable IRQ, go to system mode

;User should insert code here if non vectored Interrupt sharing is;required. Each non vectored shared irq handler must return to;the interrupted instruction by using the following code.
;
MSR cpsr_c, #0x52;Disable irq, move to IRQ mode;
MSR spsr, r12;Restore SPSR from r12;
STMFD sp!, {r0};
LDR r0, =VICBaseAddr;
STR r1, [r0,#VICVectAddrOffset];Acknowledge Non Vectored irq has finished;LDMFD sp!, {r12,r14,r0};Restore registers;
SUBS pc, r14, #4;Return to the interrupted instruction;user interrupt did not happen so call rm_irqhandler2. This handler;is not aware of the VIC interrupt priority hardware so trick;rm_irqhandler2 to return here
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

266 of 285

UM10161

NXP Semiconductors

Chapter 21: LPC2101/02/03 RealMonitor

STMFD sp!, {ip,pc}
LDR pc, rm_irqhandler2;rm_irqhandler2 returns here
MSR cpsr_c, #0x52
MSR spsr, r12
STMFD sp!, {r0}
LDR r0, =VICBaseAddr
STR r1, [r0,#VICVectAddrOffset]
LDMFD sp!, {r12,r14,r0}
SUBS pc, r14, #4
END;Disable irq, move to IRQ mode
;Restore SPSR from r12;Acknowledge Non Vectored irq has finished;Restore registers;Return to the interrupted instruction

5. RealMonitor build options
RealMonitor was built with the following options:
RM_OPT_DATALOGGING=FALSEThis 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
This option enables or disables support for software breakpoints.
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=FALSEThis 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
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

267 of 285

UM10161

NXP Semiconductors

Chapter 21: LPC2101/02/03 RealMonitor

RM_OPT_READHALFWORDS=TRUE
RM_OPT_WRITEHALFWORDS=TRUE
RM_OPT_READWORDS=TRUE
RM_OPT_WRITEWORDS=TRUE
Enables/Disables support for 8/16/32 bit read/write.
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 incode profiling when real monitor is used in interrupt mode.
RM_EXECUTECODE_SIZE=NA"execute code" buffer size. Also refer to RM_OPT_EXECUTECODE option.
RM_OPT_GATHER_STATISTICS=FALSEThis option enables or disables the code for gathering statistics about the internal
operation of RealMonitor.
RM_DEBUG=FALSEThis option enables or disables additional debugging and error-checking code in
RealMonitor.
RM_OPT_BUILDIDENTIFIER=FALSEThis 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=FALSEThis option determines whether a memory map of the board is built into the target andmade 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
UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

268 of 285

UM10161

NXP Semiconductors

Chapter 21: LPC2101/02/03 RealMonitor

This option allows RMTarget to support vector chaining through µHAL (ARM HWabstraction API).

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

269 of 285

UM10161
Chapter 22: Supplementary informationRev. 3 — 2 October 2008

User manual

1. Abbreviations
Table 241. Abbreviations
AcronymDescription

ADC

Analog-to-Digital Converter

APB

ARM Peripheral Bus

CPU

Central Processing Unit

DAC

Digital-to-Analog Converter

DCC

Debug Communications Channel

FIFO

First In, First Out

GPIO

General Purpose Input/Output

JTAG

Joint Test Action GroupNA

Not Applicable

PLL

Phase-Locked Loop

PWM

Pulse Width Modulator

RAM

Random Access Memory

SRAM

Static Random Access Memory

UART

Universal Asynchronous Receiver/Transmitter

VIC

Vector Interrupt Controller

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

270 of 285

UM10161

NXP Semiconductors

Chapter 22: Supplementary information

2. Legal information
2.1

Definitions

Draft — The document is a draft version only. The content is still underinternal review and subject to formal approval, which may result in
modifications or additions. NXP Semiconductors does not give any
representations or warranties as to the accuracy or completeness of
information included herein and shall have no liability for the consequences ofuse of such information.

2.2

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
malfunction of an NXP Semiconductors product can reasonably be expected
to result in personal injury, death or severe property or environmental
damage. NXP Semiconductors accepts no liability for inclusion and/or use of
NXP Semiconductors products in such equipment or applications andtherefore such inclusion and/or use is at the customer’s own risk.
Applications — Applications that are described herein for any of theseproducts are for illustrative purposes only. NXP Semiconductors makes norepresentation or warranty that such applications will be suitable for the
specified use without further testing or modification.

Disclaimers

General — Information in this document is believed to be accurate andreliable. However, NXP Semiconductors does not give any representations or
warranties, expressed or implied, as to the accuracy or completeness of suchinformation and shall have no liability for the consequences of use of suchinformation.
Right to make changes — NXP Semiconductors reserves the right to makechanges 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.

2.3

Trademarks

Notice: All referenced brands, product names, service names and trademarks
are the property of their respective owners.
I2C-bus — logo is a trademark of NXP B.V.

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

271 of 285

UM10161

NXP Semiconductors

Chapter 22: Supplementary information

Notes

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

272 of 285

UM10161

NXP Semiconductors

Chapter 22: Supplementary information

3. Tables
Table 1.
Table 2.
Table 3.
Table 4.
Table 5.

LPC2101/02/03 device information . . . . . . . . . .4
APB peripheries and base addresses . . . . . . . 11
ARM exception vector locations . . . . . . . . . . . .12
LPC2101/02/03 memory mapping modes . . . .12
MAM Responses to program accesses of various
types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18
Table 6. MAM responses to data accesses of various
types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18
Table 7. Summary of MAM registers . . . . . . . . . . . . . . .19
Table 8. MAM Control Register (MAMCR - address
0xE01F C000) bit description . . . . . . . . . . . . . .19
Table 9. MAM Timing register (MAMTIM - address
0xE01F C004) bit description . . . . . . . . . . . . . .19
Table 10. Suggestions for MAM timing selection . . . . . . .20
Table 11. VIC register map. . . . . . . . . . . . . . . . . . . . . . . .22
Table 12. Software Interrupt register (VICSoftInt - address
0xFFFF F018) bit allocation . . . . . . . . . . . . . . .23
Table 13. Software Interrupt register (VICSoftInt - address
0xFFFF F018) bit description . . . . . . . . . . . . . .24
Table 14. Software Interrupt Clear register (VICSoftIntClear- address 0xFFFF F01C) bit allocation . . . . . .24
Table 15. Software Interrupt Clear register (VICSoftIntClear- address 0xFFFF F01C) bit description . . . . . .24
Table 16. Raw Interrupt status register (VICRawIntr address 0xFFFF F008) bit allocation . . . . . . . .25
Table 17. Raw Interrupt status register (VICRawIntr address 0xFFFF F008) bit description . . . . . . .25
Table 18. Interrupt Enable register (VICIntEnable - address
0xFFFF F010) bit allocation . . . . . . . . . . . . . . .25
Table 19. Interrupt Enable register (VICIntEnable - address
0xFFFF F010) bit description . . . . . . . . . . . . . .26
Table 20. Software Interrupt Clear register (VICIntEnClear address 0xFFFF F014) bit allocation . . . . . . . .26
Table 21. Software Interrupt Clear register (VICIntEnClear address 0xFFFF F014) bit description . . . . . . .26
Table 22. Interrupt Select register (VICIntSelect - address
0xFFFF F00C) bit allocation . . . . . . . . . . . . . .26
Table 23. Interrupt Select register (VICIntSelect - address
0xFFFF F00C) bit description . . . . . . . . . . . . . .27
Table 24. IRQ Status register (VICIRQStatus - address
0xFFFF F000) bit allocation . . . . . . . . . . . . . . .27
Table 25. IRQ Status register (VICIRQStatus - address
0xFFFF F000) bit description . . . . . . . . . . . . . .27
Table 26. FIQ Status register (VICFIQStatus - address
0xFFFF F004) bit allocation . . . . . . . . . . . . . . .28
Table 27. FIQ Status register (VICFIQStatus - address
0xFFFF F004) bit description . . . . . . . . . . . . . .28
Table 28. Vector Control registers 0-15 (VICVectCntl0-15 0xFFFF F200-23C) bit description . . . . . . . . . .28
Table 29. Vector Address registers (VICVectAddr0-15 addresses 0xFFFF F100-13C) bit description .29
Table 30. Default Vector Address register (VICDefVectAddr- address 0xFFFF F034) bit description . . . . . .29
Table 31. Vector Address register (VICVectAddr - address
0xFFFF F030) bit description . . . . . . . . . . . . . .29
Table 32. Protection Enable register (VICProtection -address 0xFFFF F020) bit description . . . . . . . 29
Table 33. Connection of interrupt sources to the Vectored
Interrupt Controller (VIC) . . . . . . . . . . . . . . . . . 30
Table 34. Pin summary . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Table 35. Summary of system control registers. . . . . . . . 38
Table 36. Recommended values for CX1/X2 in oscillation
mode (crystal and external components
parameters) . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Table 37. External interrupt registers. . . . . . . . . . . . . . . . 41
Table 38. External Interrupt Flag register (EXTINT - address
0xE01F C140) bit description. . . . . . . . . . . . . . 42
Table 39. Interrupt Wake-up register (INTWAKE - address
0xE01F C144) bit description. . . . . . . . . . . . . . 42
Table 40. External Interrupt Mode register (EXTMODE address 0xE01F C148) bit description. . . . . . . 43
Table 41. External Interrupt Polarity register (EXTPOLAR address 0xE01F C14C) bit description . . . . . . 44
Table 42. System Control and Status flags register (SCS address 0xE01F C1A0) bit description . . . . . . 45
Table 43. Memory Mapping control register (MEMMAP address 0xE01F C040) bit description. . . . . . . 45
Table 44. PLL registers . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Table 45. PLL Control register (PLLCON - address
0xE01F C080) bit description. . . . . . . . . . . . . . 49
Table 46. PLL Configuration register (PLLCFG - address
0xE01F C084) bit description. . . . . . . . . . . . . . 49
Table 47. PLL Status register (PLLSTAT - address
0xE01F C088) bit description. . . . . . . . . . . . . . 50
Table 48. PLL Control bit combinations . . . . . . . . . . . . . . 50
Table 49. PLL Feed register (PLLFEED - address
0xE01F C08C) bit description . . . . . . . . . . . . . 51
Table 50. Elements determining PLL’s frequency . . . . . . 51
Table 51. PLL Divider values . . . . . . . . . . . . . . . . . . . . . . 52
Table 52. PLL Multiplier values . . . . . . . . . . . . . . . . . . . . 52
Table 53. Power control registers . . . . . . . . . . . . . . . . . . 54
Table 54. Power Control register (PCON - address
0xE01F COCO) bit description . . . . . . . . . . . . 54
Table 55. Power Control for Peripherals register (PCONP address 0xE01F C0C4) bit description . . . . . . 55
Table 56. Reset Source identification Register (RSIR address 0xE01F C180) bit description. . . . . . . 58
Table 57. APB divider register map . . . . . . . . . . . . . . . . . 58
Table 58. APB Divider register (APBDIV - address
0xE01F C100) bit description. . . . . . . . . . . . . . 59
Table 59. Pin description . . . . . . . . . . . . . . . . . . . . . . . . 62
Table 60. Pin connect block register map . . . . . . . . . . . . 67
Table 61. Pin function select register 0 (PINSEL0 0xE002 C000) . . . . . . . . . . . . . . . . . . . . . . . . . 68
Table 62. Pin function select register 1 (PINSEL1 0xE002 C004) . . . . . . . . . . . . . . . . . . . . . . . . . 70
Table 63. Pin function select register bits . . . . . . . . . . . . 71
Table 64. GPIO pin description . . . . . . . . . . . . . . . . . . . . 72
Table 65. GPIO register map (legacy APB accessible
registers) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Table 66. GPIO register map (local bus accessible registers- enhanced GPIO features) . . . . . . . . . . . . . . . 74

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

273 of 285

UM10161

NXP Semiconductors

Chapter 22: Supplementary information

Table 67. GPIO port 0 Direction register (IO0DIR - address
0xE002 8008) bit description . . . . . . . . . . . . . .75
Table 68. Fast GPIO port 0 Direction register (FIO0DIR address 0x3FFF C000) bit description . . . . . . .75
Table 69. Fast GPIO port 0 Direction control byte andhalf-word accessible register description . . . . .75
Table 70. Fast GPIO port 0 Mask register (FIO0MASK address 0x3FFF C010) bit description . . . . . . .76
Table 71. Fast GPIO port 0 Mask byte and half-wordaccessible register description . . . . . . . . . . . . .76
Table 72. GPIO port 0 Pin value register (IO0PIN - address
0xE002 8000) bit description . . . . . . . . . . . . . .77
Table 73. Fast GPIO port 0 Pin value register (FIO0PIN address 0x3FFF C014) bit description . . . . . . .77
Table 74. Fast GPIO port 0 Pin value byte and half-wordaccessible register description . . . . . . . . . . . . .77
Table 75. GPIO port 0 output Set register (IO0SET - address
0xE002 8004 bit description . . . . . . . . . . . . . . .78
Table 76. Fast GPIO port 0 output Set register (FIO0SET address 0x3FFF C018) bit description . . . . . . .78
Table 77. Fast GPIO port 0 output Set byte and half-wordaccessible register description . . . . . . . . . . . . .78
Table 78. GPIO port 0 output Clear register 0 (IO0CLR address 0xE002 800C) bit description . . . . . . .79
Table 79. Fast GPIO port 0 output Clear register 0(FIO0CLR - address 0x3FFF C01C) bit
description . . . . . . . . . . . . . . . . . . . . . . . . . . . .79
Table 80. Fast GPIO port 0 output Clear byte and half-wordaccessible register description . . . . . . . . . . . . .79
Table 81: UART0 pin description . . . . . . . . . . . . . . . . . . .83
Table 82: UART0 register map . . . . . . . . . . . . . . . . . . . .84
Table 83: UART0 Receiver Buffer Register (U0RBR address 0xE000 C000, when DLAB = 0, Read
Only) bit description . . . . . . . . . . . . . . . . . . . . .85
Table 84: UART0 Transmit Holding Register (U0THR address 0xE000 C000, when DLAB = 0, Write
Only) bit description . . . . . . . . . . . . . . . . . . . . .85
Table 85: UART0 Divisor Latch LSB register (U0DLL address 0xE000 C000, when DLAB = 1) bit
description . . . . . . . . . . . . . . . . . . . . . . . . . . . .86
Table 86: UART0 Divisor Latch MSB register (U0DLM address 0xE000 C004, when DLAB = 1) bit
description . . . . . . . . . . . . . . . . . . . . . . . . . . . .86
Table 87: UARTn Fractional Divider Register (U0FDR address 0xE000 C028, U2FDR - 0xE007 8028,
U3FDR - 0xE007 C028) bit description . . . . . .86
Table 88. Fractional Divider setting look-up table. . . . . . .89
Table 89. UART0 Interrupt Enable Register (U0IER address 0xE000 C004, when DLAB = 0) bit
description . . . . . . . . . . . . . . . . . . . . . . . . . . . .90
Table 90: UART0 Interrupt Identification Register (UOIIR address 0xE000 C008, read only)
bit description . . . . . . . . . . . . . . . . . . . . . . . . . .90
Table 91: UART0 interrupt handling . . . . . . . . . . . . . . . . .92
Table 92: UART0 FIFO Control Register (U0FCR - address
0xE000 C008) bit description . . . . . . . . . . . . . .92
Table 93: UART0 Line Control Register (U0LCR - address
0xE000 C00C) bit description . . . . . . . . . . . . . .93

Table 94: UART0 Line Status Register (U0LSR - address
0xE000 C014, read only) bit description . . . . . 94
Table 95: UART0 Scratch Pad Register (U0SCR - address
0xE000 C01C) bit description . . . . . . . . . . . . . 95
Table 96: Auto-baud Control Register (U0ACR 0xE000 C020) bit description. . . . . . . . . . . . . . 95
Table 97: UART0 Transmit Enable Register (U0TER address 0xE000 C030) bit description . . . . . . . 97
Table 98. UART1 pin description . . . . . . . . . . . . . . . . . . 101
Table 99. UART1 register map . . . . . . . . . . . . . . . . . . . 102
Table 100.UART1 Receiver Buffer Register (U1RBR address 0xE001 0000, when DLAB = 0 Read
Only) bit description . . . . . . . . . . . . . . . . . . . 103
Table 101.UART1 Transmitter Holding Register (U1THR address 0xE001 0000, when DLAB = 0 Write
Only) bit description . . . . . . . . . . . . . . . . . . . . 103
Table 102.UART1 Divisor Latch LSB register (U1DLL address 0xE001 0000, when DLAB = 1) bit
description . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Table 103.UART1 Divisor Latch MSB register (U1DLM address 0xE001 0004, when DLAB = 1) bit
description . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Table 104.UART1 Fractional Divider Register (U1FDR address 0xE001 0028) bit description . . . . . . 104
Table 105.Fractional Divider setting look-up table . . . . . 107
Table 106.UART1 Interrupt Enable Register (U1IER address 0xE001 0004, when DLAB = 0) bit
description . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Table 107.UART1 Interrupt Identification Register (U1IIR address 0xE001 0008, read only) bit description.
109
Table 108.UART1 interrupt handling . . . . . . . . . . . . . . . 110
Table 109.UART1 FIFO Control Register (U1FCR - address
0xE001 0008) bit description . . . . . . . . . . . . . 111
Table 110. UART1 Line Control Register (U1LCR - address
0xE001 000C) bit description. . . . . . . . . . . . . 111
Table 111. UART1 Modem Control Register (U1MCR address 0xE001 0010) bit description . . . . . . 112
Table 112. Modem status interrupt generation . . . . . . . . 114
Table 113. UART1 Line Status Register (U1LSR - address
0xE001 0014, read only) bit description. . . . . 115
Table 114. UART1 Modem Status Register (U1MSR address 0xE001 0018) bit description . . . . . . 116
Table 115. UART1 Scratch Pad Register (U1SCR - address
0xE001 0014) bit description . . . . . . . . . . . . . 116
Table 116. Auto-baud Control Register (U1ACR 0xE001 0020) bit description . . . . . . . . . . . . . 117
Table 117. UART1 Transmit Enable Register (U1TER address 0xE001 0030) bit description . . . . . . 120
Table 118. I2C Pin Description. . . . . . . . . . . . . . . . . . . . . 123
Table 119. I2C0CONSET and I2C1CONSET used toconfigure Master mode . . . . . . . . . . . . . . . . . 124
Table 120.I2C0CONSET and I2C1CONSET used toconfigure Slave mode . . . . . . . . . . . . . . . . . . 125
Table 121.I2C register map . . . . . . . . . . . . . . . . . . . . . . . 130
Table 122.I2C Control Set register (I2CONSET: I2C0,
I2C0CONSET - address 0xE001 C000 and I2C1,
I2C1CONSET - address 0xE005 C000) bit

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

274 of 285

UM10161

NXP Semiconductors

Chapter 22: Supplementary information

description . . . . . . . . . . . . . . . . . . . . . . . . . . .131
Table 123.I2C Control Set register (I2CONCLR: I2C0,
I2C0CONCLR - address 0xE001 C018 and I2C1,
I2C1CONCLR - address 0xE005 C018) bit
description . . . . . . . . . . . . . . . . . . . . . . . . . . .133
Table 124.I2C Status register (I2STAT: I2C0, I2C0STAT address 0xE001 C004 and I2C1, I2C1STAT address 0xE005 C004) bit description . . . . . .133
Table 125.I2C Data register (I2DAT: I2C0, I2C0DAT address 0xE001 C008 and I2C1, I2C1DAT address 0xE005 C008) bit description . . . . . .134
Table 126.I2C Slave Address register (I2ADR: I2C0,
I2C0ADR - address 0xE001 C00C and I2C1,
I2C1ADR - address 0xE005 C00C)
bit description . . . . . . . . . . . . . . . . . . . . . . . . .134
Table 127.I2C SCL HIGH Duty Cycle register (I2SCLH: I2C0,
I2C0SCLH - address 0xE001 C010 and I2C1,
I2C1SCLH - address 0xE005 C010) bit
description . . . . . . . . . . . . . . . . . . . . . . . . . . .134
Table 128.I2C SCL Low Duty Cycle register (I2SCLL: I2C0,
I2C0SCLL - address 0xE001 C014 and I2C1,
I2C1SCLL - address 0xE005 C014) bit
description . . . . . . . . . . . . . . . . . . . . . . . . . . .134
Table 129.Example I2C clock rates . . . . . . . . . . . . . . . . .135
Table 130.Abbreviations used to describe an I2C
operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . .135
Table 131.I2CONSET used to initialize Master Transmittermode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136
Table 132.I2C0ADR and I2C1ADR usage in Slave Receivermode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .137
Table 133.I2C0CONSET and I2C1CONSET used to initialize
Slave Receiver mode . . . . . . . . . . . . . . . . . . .137
Table 134.Master Transmitter mode . . . . . . . . . . . . . . . .143
Table 135.Master Receiver mode . . . . . . . . . . . . . . . . . .144
Table 136.Slave Receiver mode . . . . . . . . . . . . . . . . . . .145
Table 137.Slave Transmitter mode . . . . . . . . . . . . . . . . .147
Table 138.Miscellaneous States . . . . . . . . . . . . . . . . . . .149
Table 139.SPI data to clock phase relationship. . . . . . . .161
Table 140.SPI pin description . . . . . . . . . . . . . . . . . . . . .164
Table 141.SPI register map . . . . . . . . . . . . . . . . . . . . . . .165
Table 142:SPI Control Register (S0SPCR - address
0xE002 0000) bit description . . . . . . . . . . . . .165
Table 143:SPI Status Register (S0SPSR - address
0xE002 0004) bit description . . . . . . . . . . . . .166
Table 144:SPI Data Register (S0SPDR - address
0xE002 0008) bit description . . . . . . . . . . . . .167
Table 145:SPI Clock Counter Register (S0SPCCR - address
0xE002 000C) bit description . . . . . . . . . . . . .167
Table 146:SPI Interrupt register (S0SPINT - address
0xE002 001C) bit description . . . . . . . . . . . . .167
Table 147.SSP pin descriptions . . . . . . . . . . . . . . . . . . .169
Table 148.SSP register map . . . . . . . . . . . . . . . . . . . . . .178
Table 149:SSP Control Register 0 (SSPCR0 - address
0xE006 8000) bit description . . . . . . . . . . . . .178
Table 150:SSP Control Register 1 (SSPCR1 - address
0xE006 8004) bit description . . . . . . . . . . . . .179
Table 151:SSP Data Register (SSPDR - address
0xE006 8008) bit description . . . . . . . . . . . . .180

Table 152:SSP Status Register (SSPDR - address
0xE006 800C) bit description. . . . . . . . . . . . . 180
Table 153:SSP Clock Prescale Register (SSPCPSR address 0xE006 8010) bit description . . . . . . 180
Table 154:SSP Interrupt Mask Set/Clear register (SSPIMSC- address 0xE006 8014) bit description . . . . . 181
Table 155:SSP Raw Interrupt Status register (SSPRIS address 0xE006 8018) bit description . . . . . . 181
Table 156:SSP Masked Interrupt Status register (SSPMIS-address 0xE006 801C) bit description . . . . . 182
Table 157:SSP interrupt Clear Register (SSPICR - address
0xE006 8020) bit description . . . . . . . . . . . . . 182
Table 158.ADC pin description . . . . . . . . . . . . . . . . . . . . 183
Table 159.ADC registers. . . . . . . . . . . . . . . . . . . . . . . . . 184
Table 160:A/D Control Register (AD0CR - address
0xE003 4000 ) bit description . . . . . . . . . . . . 185
Table 161:A/D Global Data Register (AD0GDR - address
0xE003 4004 ) bit description . . . . . . . . . . . . 186
Table 162:A/D Status Register (AD0STAT - address
0xE003 4030) bit description . . . . . . . . . . . . . 187
Table 163:A/D Status Register (AD0STAT - address
0xE003 400C ) bit description . . . . . . . . . . . . 187
Table 164:A/D Data Registers (ADDR0 to ADDR7, ADC0:
AD0DR0 to AD0DR7) bit description . . . . . . . 188
Table 165.Timer/Counter pin description . . . . . . . . . . . . 191
Table 166.TIMER/COUNTER0 and TIMER/COUNTER1
register map . . . . . . . . . . . . . . . . . . . . . . . . . . 192
Table 167:Interrupt Register (IR, TIMER0: T0IR - address
0xE000 4000 and TIMER1: T1IR - address
0xE000 8000) bit description . . . . . . . . . . . . . 193
Table 168:Timer Control Register (TCR, TIMER0: T0TCR address 0xE000 4004 and TIMER1: T1TCR address 0xE000 8004) bit description . . . . . . 194
Table 169:Count Control Register (CTCR, TIMER0:
T0CTCR - address 0xE000 4070 and TIMER1:
T1TCR - address 0xE000 8070) bit
description . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
Table 170:Match Control Register (MCR, TIMER0: T0MCR address 0xE000 4014 and TIMER1: T1MCR address 0xE000 8014) bit description . . . . . . 196
Table 171:Capture Control Register (CCR, TIMER0: T0CCR- address 0xE000 4028 and TIMER1: T1CCR address 0xE000 8028) bit description . . . . . . 197
Table 172:External Match Register (EMR, TIMER0: T0EMR- address 0xE000 403C and TIMER1: T1EMR address0xE000 803C) bit description . . . . . . 198
Table 173.External match control . . . . . . . . . . . . . . . . . . 199
Table 174:PWM Control Register (PWMCON, TIMER0:PWM0CON - 0xE000 4074 and TIMER1:PWM1CON - 0xE000 8074) bit description . . 199
Table 175.Timer/Counter pin description . . . . . . . . . . . . 204
Table 176.TIMER/COUNTER2 and TIMER/CT3OUNTER3
register map . . . . . . . . . . . . . . . . . . . . . . . . . . 205
Table 177:Interrupt Register (IR, TIMER2T2: T2IR - address
0xE007 0000 and TIMER3: T3IR - address
0xE007 4000) bit description . . . . . . . . . . . . . 206
Table 178:Timer Control Register (TCR, TIMER2: T2TCR address 0xE007 0004 and TIMER3: T3TCR -UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

275 of 285

UM10161

NXP Semiconductors

Chapter 22: Supplementary information

address 0xE007 4004) bit description . . . . . .207
Table 179:Count Control Register (CTCR, TIMER2:
T2CTCR - address 0xE007 0070 and TIMER3:
T3TCR - address 0xE007 4070) bit
description . . . . . . . . . . . . . . . . . . . . . . . . . . .207
Table 180:Match Control Register (MCR, TIMER2: T2MCR address 0xE007 0014 and TIMER3: T3MCR address 0xE007 4014) bit description . . . . . .209
Table 181:Capture Control Register (CCR, TIMER2: T2CCR- address 0xE007 0028 and TIMER3: T3CCR address 0xE007 4028) bit description . . . . . .210
Table 182:External Match Register (EMR, TIMER2: T2EMR- address 0xE007 003C and TIMER3: T3EMR address0xE007 4016-bit3C) bit description . . 211
Table 183.External match control . . . . . . . . . . . . . . . . . . 211
Table 184:PWM Control Register (PWMCON, TIMER2:PWM2CON - 0xE007 0074 and TIMER3:PWM3CON - 0xE007 4074) bit description . .212
Table 185.Watchdog register map. . . . . . . . . . . . . . . . . .217
Table 186.Watchdog operating modes selection. . . . . . .217
Table 187:Watchdog Mode register (WDMOD - address
0xE000 0000) bit description . . . . . . . . . . . . .218
Table 188:Watchdog Timer Constant register (WDTC address 0xE000 0004) bit description . . . . . .218
Table 189:Watchdog Feed register (WDFEED - address
0xE000 0008) bit description . . . . . . . . . . . . .218
Table 190:Watchdog Timer Value register (WDTV - address
0xE000 000C) bit description . . . . . . . . . . . . .218
Table 191.RTC pin description . . . . . . . . . . . . . . . . . . . .221
Table 192.Real Time Clock (RTC) register map . . . . . . .222
Table 193.Miscellaneous registers . . . . . . . . . . . . . . . . .223
Table 194:Interrupt Location Register (ILR - address
0xE002 4000) bit description . . . . . . . . . . . . .224
Table 195:Clock Tick Counter Register (CTC - address
0xE002 4004) bit description . . . . . . . . . . . . .224
Table 196:Clock Control Register (CCR - address
0xE002 4008) bit description . . . . . . . . . . . . .224
Table 197:Counter Increment Interrupt Register (CIIR address 0xE002 400C) bit description . . . . . .225
Table 198:Alarm Mask Register (AMR - address
0xE002 4010) bit description . . . . . . . . . . . . .225
Table 199:Consolidated Time register 0 (CTIME0 - address
0xE002 4014) bit description . . . . . . . . . . . . .226
Table 200:Consolidated Time register 1 (CTIME1 - address
0xE002 4018) bit description . . . . . . . . . . . . .226
Table 201:Consolidated Time register 2 (CTIME2 - address
0xE002 401C) bit description . . . . . . . . . . . . .227
Table 202.Time counter relationships and values . . . . . .227
Table 203.Time counter registers . . . . . . . . . . . . . . . . . .227
Table 204.Alarm registers . . . . . . . . . . . . . . . . . . . . . . . .228
Table 205.Reference clock divider registers . . . . . . . . . .229
Table 206:Prescaler Integer register (PREINT - address
0xE002 4080) bit description . . . . . . . . . . . . .230
Table 207:Prescaler Integer register (PREFRAC - address
0xE002 4084) bit description . . . . . . . . . . . . .230
Table 208.Prescaler cases where the Integer Counter reload
value is incremented. . . . . . . . . . . . . . . . . . . .232
Table 209.Recommended values for the RTC external

32 kHz oscillator CX1/X2 components . . . . . . . 233
Table 210.Flash sectors in LPC2101, LPC2102,
LPC2103 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Table 211. ISP command summary. . . . . . . . . . . . . . . . . 240
Table 212.ISP Unlock command . . . . . . . . . . . . . . . . . . 241
Table 213.ISP Set Baud Rate command . . . . . . . . . . . . 241
Table 214.Correlation between possible ISP baudrates andexternal crystal frequency (in MHz) . . . . . . . . 241
Table 215.ISP Echo command . . . . . . . . . . . . . . . . . . . . 242
Table 216.ISP Write to RAM command . . . . . . . . . . . . . 242
Table 217.ISP Read memory command. . . . . . . . . . . . . 243
Table 218.ISP Prepare sector(s) for write operationcommand . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
Table 219.ISP Copy command . . . . . . . . . . . . . . . . . . . . 244
Table 220.ISP Go command. . . . . . . . . . . . . . . . . . . . . . 244
Table 221.ISP Erase sector command . . . . . . . . . . . . . . 245
Table 222.ISP Blank check sector command . . . . . . . . . 245
Table 223.ISP Read part identification number
command . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Table 224.LPC2101/02/03 part identification numbers. . 245
Table 225.ISP Read Boot code version number
command . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
Table 226.ISP Compare command. . . . . . . . . . . . . . . . . 246
Table 227.ISP Return codes Summary . . . . . . . . . . . . . 246
Table 228.IAP command summary. . . . . . . . . . . . . . . . . 249
Table 229.IAP Prepare sector(s) for write operationcommand . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
Table 230.IAP Copy RAM to flash command . . . . . . . . . 250
Table 231.IAP Erase sector(s) command . . . . . . . . . . . . 251
Table 232.IAP Blank check sector(s) command . . . . . . . 251
Table 233.IAP Read Part Identification command . . . . . 251
Table 234.IAP Read Boot code version number
command . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
Table 235.IAP Compare command. . . . . . . . . . . . . . . . . 252
Table 236.Reinvoke ISP . . . . . . . . . . . . . . . . . . . . . . . . . 252
Table 237.IAP status codes summary . . . . . . . . . . . . . . 253
Table 238.EmbeddedICE pin description . . . . . . . . . . . . 255
Table 239.EmbeddedICE logic registers . . . . . . . . . . . . 256
Table 240.RealMonitor stack requirement . . . . . . . . . . . 262
Table 241.Abbreviations . . . . . . . . . . . . . . . . . . . . . . . . 270

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

276 of 285

UM10161

NXP Semiconductors

Chapter 22: Supplementary information

4. Figures
Fig 1.
Fig 2.
Fig 3.
Fig 4.
Fig 5.
Fig 6.
Fig 7.
Fig 8.

Fig 9.
Fig 10.
Fig 11.
Fig 12.
Fig 13.
Fig 14.
Fig 15.
Fig 16.
Fig 17.

Fig 18.
Fig 19.
Fig 20.
Fig 21.
Fig 22.
Fig 23.
Fig 24.
Fig 25.
Fig 26.
Fig 27.
Fig 28.
Fig 29.
Fig 30.
Fig 31.
Fig 32.
Fig 33.
Fig 34.
Fig 35.
Fig 36.
Fig 37.
Fig 38.
Fig 39.
Fig 40.
Fig 41.
Fig 42.

LPC2101/02/03 block diagram . . . . . . . . . . . . . . .7
System memory map . . . . . . . . . . . . . . . . . . . . . . .8
Peripheral memory map. . . . . . . . . . . . . . . . . . . . .9
AHB peripheral map . . . . . . . . . . . . . . . . . . . . . .10
Map of lower memory is showing re-mapped andre-mappable areas (LPC2103 with 32 kB Flash) .13
Simplified block diagram of the Memory Accelerator
Module (MAM) . . . . . . . . . . . . . . . . . . . . . . . . . . .16
Block diagram of the Vectored Interrupt Controller(VIC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31
Oscillator modes and models: a) slave mode ofoperation, b) oscillation mode of operation, c)
external crystal model used for CX1/X2 evaluation39
FOSC selection algorithm . . . . . . . . . . . . . . . . . . .40
External interrupt logic . . . . . . . . . . . . . . . . . . . . .44
PLL block diagram . . . . . . . . . . . . . . . . . . . . . . . .48
Startup sequence diagram . . . . . . . . . . . . . . . . . .56
Reset block diagram including the wake-up timer57
APB divider connections . . . . . . . . . . . . . . . . . . .59
LQFP48 pin configuration . . . . . . . . . . . . . . . . . .61
Pin configuration (HVQFN48) . . . . . . . . . . . . . . .62
Illustration of the fast and slow GPIO access andoutput showing 3.5 x increase of the pin output
frequency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82
Algorithm for setting UART dividers. . . . . . . . . . .88
Autobaud a) mode 0 and b) mode 1 waveform.. .98
UART0 block diagram . . . . . . . . . . . . . . . . . . . .100
Algorithm for setting UART dividers. . . . . . . . . .106
Auto-RTS functional timing . . . . . . . . . . . . . . . . 113
Auto-CTS functional timing . . . . . . . . . . . . . . . . 114
Autobaud a) mode 0 and b) mode 1 waveform . 119
UART1 block diagram . . . . . . . . . . . . . . . . . . . .121
I2C-bus configuration . . . . . . . . . . . . . . . . . . . . .123
Format in the Master Transmitter mode. . . . . . .124
Format of Master Receiver mode . . . . . . . . . . .125
A Master Receiver switches to Master Transmitter
after sending repeated START . . . . . . . . . . . . .125
Format of Slave Receiver mode . . . . . . . . . . . .126
Format of Slave Transmitter mode . . . . . . . . . .126
I2C serial interface block diagram . . . . . . . . . . .127
Arbitration procedure . . . . . . . . . . . . . . . . . . . . .128
Serial clock synchronization. . . . . . . . . . . . . . . .129
Format and states in the Master Transmittermode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139
Format and states in the Master Receivermode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .140
Format and states in the Slave Receiver mode .141
Format and states in the Slave Transmittermode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .142
Simultaneous repeated START conditions from two
masters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .150
Forced access to a busy I2C-bus . . . . . . . . . . .151
Recovering from a bus obstruction caused by a
LOW level on SDA . . . . . . . . . . . . . . . . . . . . . . .151
SPI data transfer format (CPHA = 0 and
CPHA = 1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161

Fig 43. SPI block diagram . . . . . . . . . . . . . . . . . . . . . . . 168
Fig 44. Texas Instruments synchronous serial frame format:a) single frame transfer and b)
continuous/back-to-back two frames. . . . . . . . . 171
Fig 45. Motorola SPI frame format with CPOL=0 and
CPHA=0 ( a) single transfer and b) continuoustransfer). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
Fig 46. Motorola SPI frame format (single transfer) with
CPOL=0 and CPHA=1 . . . . . . . . . . . . . . . . . . . 173
Fig 47. SPI frame format with CPOL = 1 and CPHA = 0 ( a)single and b) continuous transfer). . . . . . . . . . . 174
Fig 48. Motorola SPI frame format with CPOL = 1 andCPHA = 1 (single transfer) . . . . . . . . . . . . . . . . 175
Fig 49. Microwire frame format (single transfer) . . . . . . 176
Fig 50. Microwire frame format (continuous transfers) . 177
Fig 51. Microwire frame format (continuous transfers) details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Fig 52. Sample PWM waveforms with a PWM cycle lengthof 100 (selected by MR3) and MAT3:0 enabled as
PWM outputs by the PWCON register. . . . . . . . 200
Fig 53. A timer cycle in which PR=2, MRx=6, and bothinterrupt and reset on match are enabled . . . . . 201
Fig 54. A timer cycle in which PR=2, MRx=6, and bothinterrupt and stop on match are enabled . . . . . 201
Fig 55. Timer0/1 block diagram. . . . . . . . . . . . . . . . . . . 202
Fig 56. Sample PWM waveforms with a PWM cycle lengthof 100 (selected by MR3) and MAT3:0 enabled as
PWM outputs by the PWCON register. . . . . . . . 213
Fig 57. A timer cycle in which PR=2, MRx=6, and bothinterrupt and reset on match are enabled . . . . . 213
Fig 58. A timer cycle in which PR=2, MRx=6, and bothinterrupt and stop on match are enabled . . . . . 214
Fig 59. Timer2/3 block diagram. . . . . . . . . . . . . . . . . . . 215
Fig 60. Watchdog block diagram. . . . . . . . . . . . . . . . . . 219
Fig 61. RTC block diagram . . . . . . . . . . . . . . . . . . . . . . 221
Fig 62. RTC prescaler block diagram . . . . . . . . . . . . . . 231
Fig 63. RTC 32 kHz crystal oscillator circuit . . . . . . . . . 232
Fig 64. Map of lower memory after reset for LPC2103 with
32 kB of Flash memory . . . . . . . . . . . . . . . . . . . 235
Fig 65. Boot process flowchart . . . . . . . . . . . . . . . . . . . 238
Fig 66. IAP Parameter passing . . . . . . . . . . . . . . . . . . . 249
Fig 67. EmbeddedICE debug environment block
diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
Fig 68. Waveforms for normal operations (not in debugmode) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
Fig 69. Waveforms for debug mode using the primary JTAG
pins.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
Fig 70. RealMonitor components . . . . . . . . . . . . . . . . . 260
Fig 71. RealMonitor as a state machine . . . . . . . . . . . . 261
Fig 72. Exception handlers . . . . . . . . . . . . . . . . . . . . . . 264

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

277 of 285

UM10161

NXP Semiconductors

Chapter 22: Supplementary information

Contents
Chapter 1: LPC2101/02/03 Introductory information
1
2
3
4
5

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Device information . . . . . . . . . . . . . . . . . . . . . . 4
Architectural overview . . . . . . . . . . . . . . . . . . . 4

6
7
8
9

ARM7TDMI-S processor . . . . . . . . . . . . . . . . . .
On-chip flash memory system. . . . . . . . . . . . .
On-chip Static RAM (SRAM). . . . . . . . . . . . . . .
Block diagram . . . . . . . . . . . . . . . . . . . . . . . . . .

5
5
6
7

2.1
2.2
3

Memory map concepts and operating modes . 11
Memory re-mapping. . . . . . . . . . . . . . . . . . . . 12
Prefetch abort and data abort exceptions . . 13

Chapter 2: LPC2101/02/03 Memory addressing
1
2

Memory maps. . . . . . . . . . . . . . . . . . . . . . . . . . . 8
LPC2101/02/03 memory re-mapping and bootblock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Chapter 3: LPC2101/02/03 Memory Acceleration Module (MAM)
1
2
3
3.1
3.2
3.3
4

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
MAM blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Flash memory bank . . . . . . . . . . . . . . . . . . . . 16
Instruction latches and data latches . . . . . . . . 17
Flash programming issues . . . . . . . . . . . . . . . 17
MAM operating modes . . . . . . . . . . . . . . . . . . 17

5
6
7
8
9

MAM configuration . . . . . . . . . . . . . . . . . . . . .
Register description . . . . . . . . . . . . . . . . . . . .
MAM Control register (MAMCR 0xE01F C000). . . . . . . . . . . . . . . . . . . . . . . . . .
MAM Timing register (MAMTIM 0xE01F C004). . . . . . . . . . . . . . . . . . . . . . . . . .
MAM usage notes . . . . . . . . . . . . . . . . . . . . . .

18
18
19
19
20

Chapter 4: Vectored Interrupt Controller (VIC)
1
2
3
4
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9

Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Register description . . . . . . . . . . . . . . . . . . . . 21
VIC registers. . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Software Interrupt register (VICSoftInt 0xFFFF F018). . . . . . . . . . . . . . . . . . . . . . . . . 23
Software Interrupt Clear register (VICSoftIntClear- 0xFFFF F01C) . . . . . . . . . . . . . . . . . . . . . . . 24
Raw Interrupt status register (VICRawIntr 0xFFFF F008). . . . . . . . . . . . . . . . . . . . . . . . . 25
Interrupt Enable register (VICIntEnable 0xFFFF F010). . . . . . . . . . . . . . . . . . . . . . . . . 25
Interrupt Enable Clear register (VICIntEnClear 0xFFFF F014). . . . . . . . . . . . . . . . . . . . . . . . . 26
Interrupt Select register (VICIntSelect 0xFFFF F00C) . . . . . . . . . . . . . . . . . . . . . . . . 26
IRQ Status register (VICIRQStatus 0xFFFF F000). . . . . . . . . . . . . . . . . . . . . . . . . 27
FIQ Status register (VICFIQStatus 0xFFFF F004). . . . . . . . . . . . . . . . . . . . . . . . . 28
Vector Control registers 0-15 (VICVectCntl0-15 0xFFFF F200-23C) . . . . . . . . . . . . . . . . . . . . . 28

4.10
4.11
4.12
4.13
5
6
6.1
6.2
6.3
6.4
6.5
7

Vector Address registers 0-15 (VICVectAddr0-15 0xFFFF F100-13C) . . . . . . . . . . . . . . . . . . . . 29
Default Vector Address register (VICDefVectAddr- 0xFFFF F034) . . . . . . . . . . . . . . . . . . . . . . . 29
Vector Address register (VICVectAddr 0xFFFF F030) . . . . . . . . . . . . . . . . . . . . . . . . 29
Protection Enable register (VICProtection 0xFFFF F020) . . . . . . . . . . . . . . . . . . . . . . . . 29
Interrupt sources. . . . . . . . . . . . . . . . . . . . . . . 30
Spurious interrupts . . . . . . . . . . . . . . . . . . . . . 32
Details and case studies on spurious
interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Workaround . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Solution 1: test for an IRQ received during a write
to disable IRQs . . . . . . . . . . . . . . . . . . . . . . . 33
Solution 2: disable IRQs and FIQs using separate
writes to the CPSR. . . . . . . . . . . . . . . . . . . . . 34
Solution 3: re-enable FIQs at the beginning of the
IRQ handler . . . . . . . . . . . . . . . . . . . . . . . . . . 34
VIC usage notes . . . . . . . . . . . . . . . . . . . . . . . 34

Chapter 5: LPC2101/02/03 System control block
1
2
3
4

Summary of system control block functions 37
Pin description . . . . . . . . . . . . . . . . . . . . . . . . . 37
Register description . . . . . . . . . . . . . . . . . . . . 38
Crystal oscillator . . . . . . . . . . . . . . . . . . . . . . . 38

5
5.1
5.2

External interrupt inputs. . . . . . . . . . . . . . . . . 40
Register description . . . . . . . . . . . . . . . . . . . . 41
External Interrupt Flag register (EXTINT 0xE01F C140) . . . . . . . . . . . . . . . . . . . . . . . . 41

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

278 of 285

UM10161

NXP Semiconductors

Chapter 22: Supplementary information

5.3
5.4
5.5
6
6.1
7
7.1
7.2
8
8.1
8.2
8.3
8.4
8.5

Interrupt Wake-up register (INTWAKE 0xE01F C144) . . . . . . . . . . . . . . . . . . . . . . . . 42
External Interrupt Mode register (EXTMODE 0xE01F C148) . . . . . . . . . . . . . . . . . . . . . . . . 43
External Interrupt Polarity register (EXTPOLAR 0xE01F C14C) . . . . . . . . . . . . . . . . . . . . . . . . 43
Other system controls. . . . . . . . . . . . . . . . . . . 45
System Control and Status flags register (SCS 0xE01F C1A0) . . . . . . . . . . . . . . . . . . . . . . . . 45
Memory mapping control . . . . . . . . . . . . . . . . 45
Memory Mapping control register (MEMMAP 0xE01F C040) . . . . . . . . . . . . . . . . . . . . . . . . 45
Memory mapping control usage notes . . . . . . 46
Phase Locked Loop (PLL). . . . . . . . . . . . . . . . 46
Register description . . . . . . . . . . . . . . . . . . . . 46
PLL Control register (PLLCON 0xE01F C080) . . . . . . . . . . . . . . . . . . . . . . . . 48
PLL Configuration register (PLLCFG 0xE01F C084) . . . . . . . . . . . . . . . . . . . . . . . . 49
PLL Status register (PLLSTAT 0xE01F C088) . . . . . . . . . . . . . . . . . . . . . . . . 49
PLL interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . 50

8.6
8.7
8.8
8.9
8.10
8.11
9
9.1
9.2

11
11.1
11.2
12
13

PLL modes. . . . . . . . . . . . . . . . . . . . . . . . . . . 50
PLL Feed register (PLLFEED - 0xE01F C08C) 51
PLL and Power-down mode. . . . . . . . . . . . . . 51
PLL frequency calculation . . . . . . . . . . . . . . . 51
Procedure for determining PLL settings. . . . . 52
PLL configuring examples . . . . . . . . . . . . . . . 52
Power control . . . . . . . . . . . . . . . . . . . . . . . . . 53
Register description . . . . . . . . . . . . . . . . . . . . 53
Power Control register (PCON 0xE01F COCO) . . . . . . . . . . . . . . . . . . . . . . . 54
Power Control for Peripherals register (PCONP 0xE01F COC4) . . . . . . . . . . . . . . . . . . . . . . . 54
Power control usage notes . . . . . . . . . . . . . . 55
Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Reset Source Identification Register (RSIR 0xE01F C180) . . . . . . . . . . . . . . . . . . . . . . . . 57
APB divider . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Register description . . . . . . . . . . . . . . . . . . . . 58
APBDIV register (APBDIV - 0xE01F C100) . . 58
Wake-up timer . . . . . . . . . . . . . . . . . . . . . . . . . 59
Code security vs. debugging . . . . . . . . . . . . . 60

2

Pin description for LPC2101/02/03 . . . . . . . . 62

4.1

Pin function Select register 0 (PINSEL0 0xE002 C000) . . . . . . . . . . . . . . . . . . . . . . . . 68
Pin function Select register 1 (PINSEL1 0xE002 C004) . . . . . . . . . . . . . . . . . . . . . . . . 69
Pin function select register values . . . . . . . . . 71

9.3
9.4
10
10.1

Chapter 6: LPC2101/02/03 Pin configuration
1

LPC2101/2102/2103 pinout . . . . . . . . . . . . . . . 61

Chapter 7: Pin connect block
1
2
3
4

Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Register description . . . . . . . . . . . . . . . . . . . . 67

4.2
4.3

Chapter 8: LPC2101/02/03 General Purpose Input/Output ports (GPIO)
1
2
3
4
4.1

4.2
4.3

Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Pin description . . . . . . . . . . . . . . . . . . . . . . . . . 72
Register description . . . . . . . . . . . . . . . . . . . . 72
GPIO port 0 Direction register (IODIR, Port 0:
IO0DIR - 0xE002 8008; FIODIR, Port 0: FIO0DIR- 0x3FFF C000) . . . . . . . . . . . . . . . . . . . . . . . 74
Fast GPIO port 0 Mask register (FIOMASK, Port
0: FIO0MASK - 0x3FFF C010) . . . . . . . . . . . . 75
GPIO port 0 Pin value register (IOPIN, Port 0:
IO0PIN - 0xE002 8000; FIOPIN, Port 0: FIO0PIN- 0x3FFF C014) . . . . . . . . . . . . . . . . . . . . . . . 76

4.4

4.5

5
5.1
5.2
5.3
5.4

GPIO port 0 output Set register (IOSET, Port 0:
IO0SET - 0xE002 8004; FIOSET, Port 0:
FIO0SET - 0x3FFF C018) . . . . . . . . . . . . . . . 77
GPIO port 0 output Clear register (IOCLR, Port 0:
IO0CLR - 0xE002 800C; FIOCLR, Port 0:
FIO0CLR - 0x3FFF C01C). . . . . . . . . . . . . . . 78
GPIO usage notes . . . . . . . . . . . . . . . . . . . . . . 79
Example 1: sequential accesses to IOSET and
IOCLR affecting the same GPIO pin/bit . . . . . 79
Example 2: an immediate output of 0s and 1s on
a GPIO port . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Writing to IOSET/IOCLR vs. IOPIN . . . . . . . . 80
Output signal frequency considerations whenusing the legacy and enhanced GPIO
registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80

Chapter 9: LPC2101/02/03 Universal Asynchronous Receiver/Transmitter 0 (UART0)1
2
3

Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Pin description . . . . . . . . . . . . . . . . . . . . . . . . . 83
Register description . . . . . . . . . . . . . . . . . . . . 83

3.1
3.2

UM10161_3

User manual

UART0 Receiver Buffer register (U0RBR 0xE000 C000, when DLAB = 0, Read Only) . 85
UART0 Transmit Holding Register (U0THR 0xE000 C000, when DLAB = 0, Write Only) . 85
© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

279 of 285

UM10161

NXP Semiconductors

Chapter 22: Supplementary information

3.3

3.4
3.4.1
3.4.1.1
3.4.1.2
3.5
3.6
3.7

UART0 Divisor Latch registers (U0DLL 0xE000 C000 and U0DLM - 0xE000 C004, when
DLAB = 1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
UART0 Fractional Divider Register (U0FDR 0xE000 C028). . . . . . . . . . . . . . . . . . . . . . . . . 86
Baudrate calculation . . . . . . . . . . . . . . . . . . . . 87
Example 1: PCLK = 14.7456 MHz, BR = 9600 89
Example 2: PCLK = 12 MHz, BR = 115200 . . 89
UART0 Interrupt Enable Register (U0IER 0xE000 C004, when DLAB = 0) . . . . . . . . . . . 89
UART0 Interrupt Identification Register (U0IIR 0xE000 C008, Read Only) . . . . . . . . . . . . . . . 90
UART0 FIFO Control Register (U0FCR 0xE000 C008). . . . . . . . . . . . . . . . . . . . . . . . . 92

3.8
3.9
3.10
3.11
3.12
3.13
3.14
4

UART0 Line Control Register (U0LCR 0xE000 C00C) . . . . . . . . . . . . . . . . . . . . . . . . 93
UART0 Line Status Register (U0LSR 0xE000 C014, Read Only) . . . . . . . . . . . . . . . 94
UART0 Scratch Pad Register (U0SCR 0xE000 C01C) . . . . . . . . . . . . . . . . . . . . . . . . 95
UART0 Auto-baud Control Register (U0ACR 0xE000 C020) . . . . . . . . . . . . . . . . . . . . . . . . 95
Auto-baud . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
UART0 Transmit Enable Register (U0TER 0xE000 C030) . . . . . . . . . . . . . . . . . . . . . . . . 97
Auto-baud modes. . . . . . . . . . . . . . . . . . . . . . 97
Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . 98

Chapter 10: LPC2101/02/03 Universal Asynchronous Receiver/Transmitter 1 (UART1)
1
2
3
3.1

Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Pin description . . . . . . . . . . . . . . . . . . . . . . . . 101
Register description . . . . . . . . . . . . . . . . . . . 101
UART1 Receiver Buffer Register (U1RBR 0xE001 0000, when DLAB = 0 Read Only) . 103
3.2
UART1 Transmitter Holding Register (U1THR 0xE001 0000, when DLAB = 0 Write Only) . 103
3.3
UART1 Divisor Latch registers 0 and 1 (U1DLL 0xE001 0000 and U1DLM - 0xE001 0004, when
DLAB = 1) . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
3.4
UART1 Fractional Divider Register (U1FDR 0xE001 0028) . . . . . . . . . . . . . . . . . . . . . . . . 104
3.4.1
Baudrate calculation . . . . . . . . . . . . . . . . . . . 105
3.4.1.1
Example 1: PCLK = 14.7456 MHz,
BR = 9600 Bd . . . . . . . . . . . . . . . . . . . . . . . . 107
3.4.1.2
Example 2: PCLK = 12 MHz,
BR = 115200 Bd . . . . . . . . . . . . . . . . . . . . . . 107
3.5
UART1 Interrupt Enable Register (U1IER 0xE001 0004, when DLAB = 0) . . . . . . . . . . 107
3.6
UART1 Interrupt Identification Register (U1IIR 0xE001 0008, Read Only) . . . . . . . . . . . . . . 109

3.7

UART1 FIFO Control Register (U1FCR 0xE001 0008). . . . . . . . . . . . . . . . . . . . . . . . . 111
3.8
UART1 Line Control Register (U1LCR 0xE001 000C) . . . . . . . . . . . . . . . . . . . . . . . . 111
3.9
UART1 Modem Control Register (U1MCR 0xE001 0010). . . . . . . . . . . . . . . . . . . . . . . . . 112
3.9.1
Auto-flow control . . . . . . . . . . . . . . . . . . . . . . 113
3.9.1.1
Auto-RTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
3.9.1.2
Auto-CTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
3.10
UART1 Line Status Register (U1LSR 0xE001 0014, Read Only) . . . . . . . . . . . . . . . 114
3.11
UART1 Modem Status Register (U1MSR 0xE001 0018). . . . . . . . . . . . . . . . . . . . . . . . . 116
3.12
UART1 Scratch Pad Register (U1SCR 0xE001 001C) . . . . . . . . . . . . . . . . . . . . . . . . 116
3.13
UART1 Auto-baud Control Register (U1ACR 0xE001 0020). . . . . . . . . . . . . . . . . . . . . . . . . 117
3.14
Auto-baud . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
3.15
Auto-baud modes. . . . . . . . . . . . . . . . . . . . . . 118
3.16
UART1 Transmit Enable Register (U1TER 0xE001 0030). . . . . . . . . . . . . . . . . . . . . . . . . 119
4
Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . 120

Chapter 11: LPC2101/02/03 I2C interfaces I2C0 and I2C1
1
2
3
4
5
5.1
5.2
5.3
5.4
6
6.1
6.2
6.3
6.4
6.5
6.6

Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
Applications . . . . . . . . . . . . . . . . . . . . . . . . . . 122
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
Pin description . . . . . . . . . . . . . . . . . . . . . . . . 123
I2C operating modes . . . . . . . . . . . . . . . . . . . 123
Master Transmitter mode . . . . . . . . . . . . . . . 123
Master Receiver mode . . . . . . . . . . . . . . . . . 124
Slave Receiver mode . . . . . . . . . . . . . . . . . . 125
Slave Transmitter mode . . . . . . . . . . . . . . . . 126
I2C implementation and operation . . . . . . . . 126
Input filters and output stages. . . . . . . . . . . . 126
Address Register, I2ADDR . . . . . . . . . . . . . . 128
Comparator. . . . . . . . . . . . . . . . . . . . . . . . . . 128
Shift register, I2DAT . . . . . . . . . . . . . . . . . . . 128
Arbitration and synchronization logic . . . . . . 128
Serial clock generator . . . . . . . . . . . . . . . . . . 129

6.7
6.8
6.9
7
7.1

7.2

7.3

7.4

Timing and control . . . . . . . . . . . . . . . . . . . . 129
Control register, I2CONSET and I2CONCLR 130
Status decoder and status register. . . . . . . . 130
Register description . . . . . . . . . . . . . . . . . . . 130
I2C Control Set register (I2CONSET: I2C0,
I2C0CONSET - 0xE001 C000 and I2C1,
I2C1CONSET - 0xE005 C000) . . . . . . . . . . 131
I2C Control Clear register (I2CONCLR: I2C0,
I2C0CONCLR - 0xE001 C018 and I2C1,
I2C1CONCLR - 0xE005 C018) . . . . . . . . . . 133
I2C Status register (I2STAT: I2C0, I2C0STAT 0xE001 C004 and I2C1, I2C1STAT 0xE005 C004) . . . . . . . . . . . . . . . . . . . . . . . 133
I2C Data register (I2DAT: I2C0, I2C0DAT 0xE001 C008 and I2C1, I2C1DAT 0xE005 C008) . . . . . . . . . . . . . . . . . . . . . . . 134

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

280 of 285

UM10161

NXP Semiconductors

Chapter 22: Supplementary information

7.5

7.6

7.7

7.8
8
8.1
8.2
8.3
8.4
8.5
8.6
8.7
8.8
8.9
8.10
8.11
8.12
8.13
8.14
8.15
8.16
8.17
8.18
9
9.1
9.2

I2C Slave Address register (I2ADR: I2C0,
I2C0ADR - 0xE001 C00C and I2C1, I2C1ADR address 0xE005 C00C) . . . . . . . . . . . . . . . . 134
I2C SCL HIGH duty cycle register (I2SCLH: I2C0,
I2C0SCLH - 0xE001 C010 and I2C1, I2C1SCLH 0xE0015 C010). . . . . . . . . . . . . . . . . . . . . . . 134
I2C SCL Low duty cycle register (I2SCLL: I2C0 I2C0SCLL: 0xE001 C014; I2C1 - I2C1SCLL:
0xE0015 C014). . . . . . . . . . . . . . . . . . . . . . . 134
Selecting the appropriate I2C data rate and duty
cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Details of I2C operating modes. . . . . . . . . . . 135
Master Transmitter mode . . . . . . . . . . . . . . . 136
Master Receiver mode . . . . . . . . . . . . . . . . . 137
Slave Receiver mode . . . . . . . . . . . . . . . . . . 137
Slave Transmitter mode . . . . . . . . . . . . . . . . 142
Miscellaneous states . . . . . . . . . . . . . . . . . . 148
I2STAT = 0xF8 . . . . . . . . . . . . . . . . . . . . . . . 148
I2STAT = 0x00 . . . . . . . . . . . . . . . . . . . . . . . 148
Some special cases . . . . . . . . . . . . . . . . . . . 149
Simultaneous repeated START conditions fromtwo masters . . . . . . . . . . . . . . . . . . . . . . . . . 149
Data transfer after loss of arbitration . . . . . . 149
Forced access to the I2C-bus . . . . . . . . . . . . 149
I2C-bus obstructed by a LOW level on SCL or
SDA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
Bus error . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
I2C state service routines . . . . . . . . . . . . . . . 151
Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . 151
I2C interrupt service . . . . . . . . . . . . . . . . . . . 152
The state service routines. . . . . . . . . . . . . . . 152
Adapting state services to an application . . . 152
Software example . . . . . . . . . . . . . . . . . . . . . 152
Initialization routine . . . . . . . . . . . . . . . . . . . . 152
Start Master Transmit function . . . . . . . . . . . 152

9.3
9.4
9.5
9.5.1
9.5.2
9.5.3
9.5.4
9.6
9.6.1
9.6.2
9.6.3
9.6.4
9.6.5
9.7
9.7.1
9.7.2
9.7.3
9.7.4
9.8
9.8.1
9.8.2
9.8.3
9.8.4
9.8.5
9.8.6
9.8.7
9.8.8
9.8.9
9.9
9.9.1
9.9.2
9.9.3
9.9.4
9.9.5

Start Master Receive function . . . . . . . . . . .
I2C interrupt routine . . . . . . . . . . . . . . . . . . .
Non mode specific states . . . . . . . . . . . . . . .
State: 0x00 . . . . . . . . . . . . . . . . . . . . . . . . . .
Master States . . . . . . . . . . . . . . . . . . . . . . . .
State: 0x08 . . . . . . . . . . . . . . . . . . . . . . . . . .
State: 0x10 . . . . . . . . . . . . . . . . . . . . . . . . . .
Master Transmitter states . . . . . . . . . . . . . .
State: 0x18 . . . . . . . . . . . . . . . . . . . . . . . . . .
State: 0x20 . . . . . . . . . . . . . . . . . . . . . . . . . .
State: 0x28 . . . . . . . . . . . . . . . . . . . . . . . . . .
State: 0x30 . . . . . . . . . . . . . . . . . . . . . . . . . .
State: 0x38 . . . . . . . . . . . . . . . . . . . . . . . . . .
Master Receive states . . . . . . . . . . . . . . . . .
State: 0x40 . . . . . . . . . . . . . . . . . . . . . . . . . .
State: 0x48 . . . . . . . . . . . . . . . . . . . . . . . . . .
State: 0x50 . . . . . . . . . . . . . . . . . . . . . . . . . .
State: 0x58 . . . . . . . . . . . . . . . . . . . . . . . . . .
Slave Receiver states . . . . . . . . . . . . . . . . .
State: 0x60 . . . . . . . . . . . . . . . . . . . . . . . . . .
State: 0x68 . . . . . . . . . . . . . . . . . . . . . . . . . .
State: 0x70 . . . . . . . . . . . . . . . . . . . . . . . . . .
State: 0x78 . . . . . . . . . . . . . . . . . . . . . . . . . .
State: 0x80 . . . . . . . . . . . . . . . . . . . . . . . . . .
State: 0x88 . . . . . . . . . . . . . . . . . . . . . . . . . .
State: 0x90 . . . . . . . . . . . . . . . . . . . . . . . . . .
State: 0x98 . . . . . . . . . . . . . . . . . . . . . . . . . .
State: 0xA0. . . . . . . . . . . . . . . . . . . . . . . . . .
Slave Transmitter states . . . . . . . . . . . . . . .
State: 0xA8. . . . . . . . . . . . . . . . . . . . . . . . . .
State: 0xB0. . . . . . . . . . . . . . . . . . . . . . . . . .
State: 0xB8. . . . . . . . . . . . . . . . . . . . . . . . . .
State: 0xC0 . . . . . . . . . . . . . . . . . . . . . . . . .
State: 0xC8 . . . . . . . . . . . . . . . . . . . . . . . . .

152
153
153
153
153
153
153
154
154
154
154
154
155
155
155
155
155
155
156
156
156
156
156
157
157
157
157
157
158
158
158
158
158
159

Chapter 12: LPC2101/02/03 SPI interface SPI0
1
2
2.1
2.2
2.3
2.4
2.5
2.6
2.7
2.8
2.9
2.10

Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
SPI overview. . . . . . . . . . . . . . . . . . . . . . . . . 160
SPI data transfers . . . . . . . . . . . . . . . . . . . . . 160
General information . . . . . . . . . . . . . . . . . . . 162
Master operation. . . . . . . . . . . . . . . . . . . . . . 162
Slave operation. . . . . . . . . . . . . . . . . . . . . . . 163
Exception conditions. . . . . . . . . . . . . . . . . . . 163
Read overrun . . . . . . . . . . . . . . . . . . . . . . . . 163
Write collision . . . . . . . . . . . . . . . . . . . . . . . . 163
Mode fault . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Slave abort . . . . . . . . . . . . . . . . . . . . . . . . . . 164

3
4
4.1
4.2
4.3
4.4
4.5
5

Pin description . . . . . . . . . . . . . . . . . . . . . . . 164
Register description . . . . . . . . . . . . . . . . . . . 164
SPI Control Register (S0SPCR 0xE002 0000). . . . . . . . . . . . . . . . . . . . . . . . 165
SPI Status Register (S0SPSR 0xE002 0004). . . . . . . . . . . . . . . . . . . . . . . . 166
SPI Data Register (S0SPDR - 0xE002 0008) 167
SPI Clock Counter Register (S0SPCCR 0xE002 000C) . . . . . . . . . . . . . . . . . . . . . . . 167
SPI Interrupt register (S0SPINT 0xE002 001C) . . . . . . . . . . . . . . . . . . . . . . . 167
Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . 167

Chapter 13: LPC2101/02/03 SPI/SSP interface SPI1
1
2
3
3.1

Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
Bus description . . . . . . . . . . . . . . . . . . . . . . . 170
Texas Instruments Synchronous Serial (SSI)
frame format . . . . . . . . . . . . . . . . . . . . . . . . . 170

3.2
3.3
3.4
3.5

UM10161_3

User manual

SPI frame format . . . . . . . . . . . . . . . . . . . . . 171
Clock Polarity (CPOL) and Clock Phase (CPHA)
control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
SPI format with CPOL=0,CPHA=0. . . . . . . . 172
SPI format with CPOL=0,CPHA=1. . . . . . . . 173© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

281 of 285

UM10161

NXP Semiconductors

Chapter 22: Supplementary information

3.6
3.7
3.8
3.9
4
4.1
4.2
4.3

SPI format with CPOL = 1,CPHA = 0 . . . . . . 174
SPI format with CPOL = 1,CPHA = 1 . . . . . . 175
Semiconductor Microwire frame format . . . . 175
Setup and hold time requirements on CS withrespect to SK in Microwire mode . . . . . . . . . 177
Register description . . . . . . . . . . . . . . . . . . . 177
SSP Control Register 0 (SSPCR0 0xE006 8000) . . . . . . . . . . . . . . . . . . . . . . . . 178
SSP Control Register 1 (SSPCR1 0xE006 8004) . . . . . . . . . . . . . . . . . . . . . . . . 179
SSP Data Register (SSPDR - 0xE006 8008) 180

4.4

SSP Status Register (SSPSR 0xE006 800C) . . . . . . . . . . . . . . . . . . . . . . . 180
SSP Clock Prescale Register (SSPCPSR 0xE006 8010). . . . . . . . . . . . . . . . . . . . . . . . 180
SSP Interrupt Mask Set/Clear register (SSPIMSC- 0xE006 8014) . . . . . . . . . . . . . . . . . . . . . . 181
SSP Raw Interrupt Status register (SSPRIS 0xE006 8018). . . . . . . . . . . . . . . . . . . . . . . . 181
SSP Masked Interrupt register (SSPMIS 0xE006 801C) . . . . . . . . . . . . . . . . . . . . . . . 182
SSP Interrupt Clear Register (SSPICR 0xE006 8020). . . . . . . . . . . . . . . . . . . . . . . . 182

4.5
4.6
4.7
4.8
4.9

Chapter 14: LPC2101/02/03 Analog-to-Digital Converter (ADC)
1
2
3
4
4.1
4.2

Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Pin description . . . . . . . . . . . . . . . . . . . . . . . . 183
Register description . . . . . . . . . . . . . . . . . . . 184
A/D Control Register (AD0CR - 0xE003 4000). . .
185
A/D Global Data Register (AD0GDR 0xE003 4004) . . . . . . . . . . . . . . . . . . . . . . . . 186

4.3
4.4
4.5
5
5.1
5.2
5.3

A/D Status Register (AD0STAT 0xE003 4030). . . . . . . . . . . . . . . . . . . . . . . .
A/D Interrupt Enable Register (AD0INTEN 0xE003 400C) . . . . . . . . . . . . . . . . . . . . . . .
A/D Data Registers (AD0DR0 to AD0DR7 0xE003 4010 to 0xE003 402C) . . . . . . . . . .
Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Hardware-triggered conversion . . . . . . . . . .
Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . .
Accuracy vs. digital receiver . . . . . . . . . . . .

187
187
188
188
188
189
189

Chapter 15: LPC2101/02/03 32-bit Timers Timer0/1
1
2
3
4
5
5.1

5.2

5.3

5.4

5.5

Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Applications . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Pin description . . . . . . . . . . . . . . . . . . . . . . . . 191
Register description . . . . . . . . . . . . . . . . . . . 191
Interrupt Register (IR, TIMER0: T0IR 0xE000 4000 and TIMER1: T1IR 0xE000 8000) . . . . . . . . . . . . . . . . . . . . . . . . 193
Timer Control Register (TCR, TIMER0: T0TCR 0xE000 4004 and TIMER1: T1TCR 0xE000 8004) . . . . . . . . . . . . . . . . . . . . . . . . 193
Count Control Register (CTCR, TIMER0:
T0CTCR - 0xE000 4070 and TIMER1: T1TCR 0xE000 8070) . . . . . . . . . . . . . . . . . . . . . . . . 194
Timer Counter (TC, TIMER0: T0TC 0xE000 4008 and TIMER1: T1TC 0xE000 8008) . . . . . . . . . . . . . . . . . . . . . . . . 195
Prescale Register (PR, TIMER0: T0PR 0xE000 400C and TIMER1:
T1PR - 0xE000 800C) . . . . . . . . . . . . . . . . . 195

5.6

5.7
5.8

5.9
5.10

5.11

5.12

5.13
6
7

Prescale Counter Register (PC, TIMER0: T0PC 0xE000 4010 and TIMER1: T1PC 0xE000 8010). . . . . . . . . . . . . . . . . . . . . . . . 195
Match Registers (MR0 - MR3) . . . . . . . . . . . 195
Match Control Register (MCR, TIMER0: T0MCR 0xE000 4014 and TIMER1: T1MCR 0xE000 8014). . . . . . . . . . . . . . . . . . . . . . . . 196
Capture Registers (CR0 - CR3) . . . . . . . . . . 197
Capture Control Register (CCR, TIMER0: T0CCR- 0xE000 4028 and TIMER1: T1CCR 0xE000 8028). . . . . . . . . . . . . . . . . . . . . . . . 197
External Match Register (EMR, TIMER0: T0EMR- 0xE000 403C; and TIMER1: T1EMR 0xE000 803C) . . . . . . . . . . . . . . . . . . . . . . . 198
PWM Control Register (PWMCON, TIMER0:PWM0CON - 0xE000 4074 and TIMER1:PWM1CON - 0xE000 8074). . . . . . . . . . . . . 199
Rules for single edge controlled PWM
ouputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
Example timer operation . . . . . . . . . . . . . . . 200
Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . 201

Chapter 16: LPC2101/02/03 16-bit Timers Timer 2/3
1
2
3
4
5

Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Applications . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Pin description . . . . . . . . . . . . . . . . . . . . . . . . 204
Register description . . . . . . . . . . . . . . . . . . . 204

5.1

5.2

UM10161_3

User manual

Interrupt Register (IR TIMER2: T2IR 0xE007 0000 and TIMER3: T3IR 0xE007 4000). . . . . . . . . . . . . . . . . . . . . . . . 206
Timer Control Register (TCR, TIMER2: T2TCR 0xE007 0004 and TIMER3: T3TCR 0xE007 4004). . . . . . . . . . . . . . . . . . . . . . . . 206© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

282 of 285

UM10161

NXP Semiconductors

Chapter 22: Supplementary information

5.3

5.4

5.5

5.6

5.7
5.8

Count Control Register (CTCR, TIMER2:
T2CTCR - 0xE007 0070 and TIMER3: T3TCR 0xE007 4070) . . . . . . . . . . . . . . . . . . . . . . . . 207
Timer Counter (TC, TIMER2: T2TC 0xE007 0008 and TIMER3: T3TC 0xE007 4008) . . . . . . . . . . . . . . . . . . . . . . . . 208
Prescale Register (PR, TIMER2: T2PR 0xE007 000C and TIMER3:
T3PR - 0xE007 400C) . . . . . . . . . . . . . . . . . 208
Prescale Counter register (PC, TIMER2: T2PC 0xE007 0010 and TIMER3: T3PC - 0xE007 4010)
208
Match Registers (MR0 - MR3) . . . . . . . . . . . 208
Match Control Register (MCR, TIMER2: T2MCR 0xE007 0014 and TIMER3: T3MCR 0xE007 4014) . . . . . . . . . . . . . . . . . . . . . . . . 209

5.9
5.10

5.11

5.12

5.13
6
7

Capture Registers (CR0 - CR3) . . . . . . . . . . 210
Capture Control Register (CCR, TIMER2: T2CCR- 0xE007 0028 and TIMER3: T3CCR 0xE007 4028). . . . . . . . . . . . . . . . . . . . . . . . 210
External Match Register (EMR, TIMER2: T2EMR- 0xE007 003C; and TIMER3: T3EMR 0xE007 403C) . . . . . . . . . . . . . . . . . . . . . . . . 211
PWM Control register (PWMCON, TIMER2:PWM2CON - 0xE007 0074 and TIMER3:PWM3CON - 0xE007 4074). . . . . . . . . . . . . 212
Rules for single edge controlled PWM
ouputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
Example timer operation . . . . . . . . . . . . . . . 213
Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . 214

Chapter 17: LPC2101/02/03 WatchDog Timer (WDT)
1
2
3
4
4.1

Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Applications . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Register description . . . . . . . . . . . . . . . . . . . 217
Watchdog Mode register (WDMOD 0xE000 0000) . . . . . . . . . . . . . . . . . . . . . . . . 217

4.2
4.3
4.4
5

Watchdog Timer Constant register (WDTC 0xE000 0004). . . . . . . . . . . . . . . . . . . . . . . .
Watchdog Feed register (WDFEED 0xE000 0008). . . . . . . . . . . . . . . . . . . . . . . .
Watchdog Timer Value register (WDTV 0xE000 000C) . . . . . . . . . . . . . . . . . . . . . . .
Block diagram . . . . . . . . . . . . . . . . . . . . . . . .

218
218
218
219

Chapter 18: LPC2101/02/03 Real-time clock (RTC)
1
2
3
4
5
5.1
5.2
5.3
5.4
5.5
5.6
5.7
5.8
5.9

Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . 221
Pin description . . . . . . . . . . . . . . . . . . . . . . . . 221
Register description . . . . . . . . . . . . . . . . . . . 221
RTC interrupts . . . . . . . . . . . . . . . . . . . . . . . 222
Miscellaneous register group . . . . . . . . . . . . 223
Interrupt Location Register (ILR 0xE002 4000) . . . . . . . . . . . . . . . . . . . . . . . . 223
Clock Tick Counter Register (CTC 0xE002 4004) . . . . . . . . . . . . . . . . . . . . . . . . 224
Clock Control Register (CCR - 0xE002 4008) 224
Counter Increment Interrupt Register (CIIR 0xE002 400C). . . . . . . . . . . . . . . . . . . . . . . . 225
Alarm Mask Register (AMR - 0xE002 4010). 225
Consolidated time registers . . . . . . . . . . . . . 226
Consolidated Time register 0 (CTIME0 0xE002 4014) . . . . . . . . . . . . . . . . . . . . . . . . 226

5.10
5.11
5.12
5.13
5.14
6
7
7.1
7.2
7.3
7.4
8

Consolidated Time register 1 (CTIME1 0xE002 4018). . . . . . . . . . . . . . . . . . . . . . . .
Consolidated Time register 2 (CTIME2 0xE002 401C) . . . . . . . . . . . . . . . . . . . . . . .
Time counter group . . . . . . . . . . . . . . . . . . .
Leap year calculation . . . . . . . . . . . . . . . . . .
Alarm register group . . . . . . . . . . . . . . . . . .
RTC usage notes. . . . . . . . . . . . . . . . . . . . . .
Reference clock divider (prescaler) . . . . . .
Prescaler Integer register (PREINT 0xE002 4080). . . . . . . . . . . . . . . . . . . . . . . .
Prescaler Fraction register (PREFRAC 0xE002 4084). . . . . . . . . . . . . . . . . . . . . . . .
Example of prescaler usage . . . . . . . . . . . .
Prescaler operation . . . . . . . . . . . . . . . . . . .
RTC external 32 kHz oscillator component
selection. . . . . . . . . . . . . . . . . . . . . . . . . . . . .

226
227
227
228
228
228
229
229
230
230
231
232

Chapter 19: LPC2101/02/03 Flash memory system and programming
1
2
3
4
4.1
4.2
4.3
4.4

Boot loader . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
Applications . . . . . . . . . . . . . . . . . . . . . . . . . . 234
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
Memory map after any reset. . . . . . . . . . . . . 234
Criterion for valid user code . . . . . . . . . . . . . 235
Communication protocol . . . . . . . . . . . . . . . . 236
ISP command format . . . . . . . . . . . . . . . . . . 236

4.5
4.6
4.7
4.8
4.9
4.10
4.11
4.12

UM10161_3

User manual

ISP response format . . . . . . . . . . . . . . . . . .
ISP data format . . . . . . . . . . . . . . . . . . . . . .
ISP flow control . . . . . . . . . . . . . . . . . . . . . .
ISP command abort . . . . . . . . . . . . . . . . . . .
Interrupts during ISP . . . . . . . . . . . . . . . . . .
Interrupts during IAP . . . . . . . . . . . . . . . . . .
RAM used by ISP command handler. . . . . .
RAM used by IAP command handler. . . . . .

236
236
236
237
237
237
237
237

© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

283 of 285

UM10161

NXP Semiconductors

Chapter 22: Supplementary information

4.13
4.14
5
6
7
8
8.1
8.2
8.3
8.4
8.5
8.6
8.7
8.8
8.9

RAM used by RealMonitor . . . . . . . . . . . . . . 237
Boot process flowchart . . . . . . . . . . . . . . . . . 238
Sector numbers . . . . . . . . . . . . . . . . . . . . . . . 238
Flash content protection mechanism . . . . . 239
Code Read Protection (CRP) . . . . . . . . . . . . 240
ISP commands . . . . . . . . . . . . . . . . . . . . . . . . 240
Unlock <unlock code> . . . . . . . . . . . . . . . . . 241
Set Baud Rate <baud rate> <stop bit> . . . . . 241
Echo <setting> . . . . . . . . . . . . . . . . . . . . . . . 242
Write to RAM <start address><number of bytes> . . . . . . . . . . . . . . . . . . . . 242
Read memory <address> <no. of bytes> . . . 242
Prepare sector(s) for write operation <start sector
number> <end sector number> . . . . . . . . . . 243
Copy RAM to flash <Flash address> <RAM
address> <no of bytes> . . . . . . . . . . . . . . . . 244
Go <address> <mode>. . . . . . . . . . . . . . . . . 244
Erase sector(s) <start sector number> <end
sector number>. . . . . . . . . . . . . . . . . . . . . . . 245

8.10

9.8
9.9
10

Blank check sector(s) <sector number> <end
sector number> . . . . . . . . . . . . . . . . . . . . . . 245
Read part identification number . . . . . . . . . . 245
Read boot code version number . . . . . . . . . 246
Compare <address1> <address2><no of bytes> . . . . . . . . . . . . . . . . . . . . . . . . 246
ISP Return codes. . . . . . . . . . . . . . . . . . . . . 246
IAP commands . . . . . . . . . . . . . . . . . . . . . . . 247
Prepare sector(s) for write operation . . . . . . 249
Copy RAM to flash . . . . . . . . . . . . . . . . . . . . 250
Erase sector(s). . . . . . . . . . . . . . . . . . . . . . . 251
Blank check sector(s). . . . . . . . . . . . . . . . . . 251
Read part identification number . . . . . . . . . . 251
Read boot code version number . . . . . . . . . 252
Compare <address1> <address2><no of bytes> . . . . . . . . . . . . . . . . . . . . . . . . 252
Reinvoke ISP . . . . . . . . . . . . . . . . . . . . . . . . 252
IAP status codes . . . . . . . . . . . . . . . . . . . . . 253
JTAG flash programming interface . . . . . . . 253

6
7
8
8.1
8.2

Register description . . . . . . . . . . . . . . . . . . .
Block diagram . . . . . . . . . . . . . . . . . . . . . . . .
DEBUG mode. . . . . . . . . . . . . . . . . . . . . . . . .
Enable Debug mode . . . . . . . . . . . . . . . . . .
JTAG pin selection . . . . . . . . . . . . . . . . . . . .

256
256
257
257
258

4.4
4.5
4.6
4.7
4.8
4.9
4.10
4.11
4.12
5

SVC mode . . . . . . . . . . . . . . . . . . . . . . . . . .
Prefetch Abort mode . . . . . . . . . . . . . . . . . .
Data Abort mode . . . . . . . . . . . . . . . . . . . . .
User/System mode . . . . . . . . . . . . . . . . . . .
FIQ mode . . . . . . . . . . . . . . . . . . . . . . . . . . .
Handling exceptions. . . . . . . . . . . . . . . . . . .
RealMonitor exception handling. . . . . . . . . .
RMTarget initialization . . . . . . . . . . . . . . . . .
Code example . . . . . . . . . . . . . . . . . . . . . . .
RealMonitor build options . . . . . . . . . . . . . .

262
263
263
263
263
263
263
264
264
267

3
4
4

Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
Contents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278

8.11
8.12
8.13
8.14
9
9.1
9.2
9.3
9.4
9.5
9.6
9.7

Chapter 20: LPC2101/02/03 EmbeddedICE logic
1
2
3
4
5

Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
Applications . . . . . . . . . . . . . . . . . . . . . . . . . . 254
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
Pin description . . . . . . . . . . . . . . . . . . . . . . . . 255
Reset state of multiplexed pins . . . . . . . . . . 255

Chapter 21: LPC2101/02/03 RealMonitor
1
2
3
3.1
3.2
3.3
3.4
4
4.1
4.2
4.3

Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
Applications . . . . . . . . . . . . . . . . . . . . . . . . . . 259
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
RealMonitor components . . . . . . . . . . . . . . . 260
RMHost. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
RMTarget . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
How RealMonitor works . . . . . . . . . . . . . . . . 261
How to enable Realmonitor. . . . . . . . . . . . . . 262
Adding stacks . . . . . . . . . . . . . . . . . . . . . . . . 262
IRQ mode . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
Undef mode . . . . . . . . . . . . . . . . . . . . . . . . . 262

Chapter 22: Supplementary information
1
2
2.1
2.2
2.3

Abbreviations . . . . . . . . . . . . . . . . . . . . . . . . . 270
Legal information. . . . . . . . . . . . . . . . . . . . . . 271
Definitions. . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Disclaimers . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Trademarks. . . . . . . . . . . . . . . . . . . . . . . . . . 271

UM10161_3

User manual© NXP B.V. 2008. All rights reserved.

Rev. 3 — 2 October 2008

284 of 285

UM10161

NXP Semiconductors

Chapter 22: Supplementary information

285

Please be aware that important notices concerning this document and the product(s)described herein, have been included in section ‘Legal information’.

© NXP B.V. 2008.

All rights reserved.

For more information, please visit: http://www.nxp.com
For sales office addresses, please send an email to: salesaddresses@nxp.com
Date of release: 2 October 2008
Document identifier: UM10161_3