LPC 2148 User
LPC 2148 User
Document information
Info Content
Keywords LPC2141, LPC2142, LPC2144, LPC2146, LPC2148, LPC2000, LPC214x,
ARM, ARM7, embedded, 32-bit, microcontroller, USB 2.0, USB device
Abstract An initial LPC214x User Manual revision
Philips Semiconductors UM10139
Volume 1 LPC2141/2/4/6/8 UM
Revision history
Rev Date Description
01 20050815 Initial version
Contact information
For additional information, please visit: http://www.semiconductors.philips.com
For sales office addresses, please send an email to: [email protected]
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
1.1 Introduction
The LPC2141/2/4/6/8 microcontrollers are based on a 32/16 bit ARM7TDMI-S CPU with
real-time emulation and embedded trace support, that combines the microcontroller with
embedded high speed flash memory ranging from 32 kB to 512 kB. A 128-bit wide
memory interface and a unique accelerator architecture enable 32-bit code execution at
the maximum clock rate. For critical code size applications, the alternative 16-bit Thumb
mode reduces code by more than 30 % with minimal performance penalty.
Due to their tiny size and low power consumption, LPC2141/2/4/6/8 are ideal for
applications where miniaturization is a key requirement, such as access control and
point-of-sale. A blend of serial communications interfaces ranging from a USB 2.0 Full
Speed device, multiple UARTS, SPI, SSP to I2Cs and on-chip SRAM of 8 kB up to 40 kB,
make these devices very well suited for communication gateways and protocol converters,
soft modems, voice recognition and low end imaging, providing both large buffer size and
high processing power. Various 32-bit timers, single or dual 10-bit ADC(s), 10-bit DAC,
PWM channels and 45 fast GPIO lines with up to nine edge or level sensitive external
interrupt pins make these microcontrollers particularly suitable for industrial control and
medical systems.
1.2 Features
• 16/32-bit ARM7TDMI-S microcontroller in a tiny LQFP64 package.
• 8 to 40 kB of on-chip static RAM and 32 to 512 kB of on-chip flash program memory.
128 bit wide interface/accelerator enables high speed 60 MHz operation.
• In-System/In-Application Programming (ISP/IAP) via on-chip boot-loader software.
Single flash sector or full chip erase in 400 ms and programming of 256 bytes in 1 ms.
• EmbeddedICE RT and Embedded Trace interfaces offer real-time debugging with the
on-chip RealMonitor software and high speed tracing of instruction execution.
• USB 2.0 Full Speed compliant Device Controller with 2 kB of endpoint RAM.
In addition, the LPC2146/8 provide 8 kB of on-chip RAM accessible to USB by DMA.
• One or two (LPC2141/2 vs. LPC2144/6/8) 10-bit A/D converters provide a total of 6/14
analog inputs, with conversion times as low as 2.44 µs per channel.
• Single 10-bit D/A converter provides variable analog output.
• Two 32-bit timers/external event counters (with four capture and four compare
channels each), PWM unit (six outputs) and watchdog.
• Low power real-time clock with independent power and dedicated 32 kHz clock input.
• Multiple serial interfaces including two UARTs (16C550), two Fast I2C-bus
(400 kbit/s), SPI and SSP with buffering and variable data length capabilities.
• Vectored interrupt controller with configurable priorities and vector addresses.
• Up to 45 of 5 V tolerant fast general purpose I/O pins in a tiny LQFP64 package.
• Up to nine edge or level sensitive external interrupt pins available.
• 60 MHz maximum CPU clock available from programmable on-chip PLL with settling
time of 100 µs.
• On-chip integrated oscillator operates with an external crystal in range from 1 MHz to
30 MHz and with an external oscillator up to 50 MHz.
• Power saving modes include Idle and Power-down.
• Individual enable/disable of peripheral functions as well as peripheral clock scaling for
additional power optimization.
• Processor wake-up from Power-down mode via external interrupt, USB, Brown-Out
Detect (BOD) or Real-Time Clock (RTC).
• Single power supply chip with Power-On Reset (POR) and BOD circuits:
– CPU operating voltage range of 3.0 V to 3.6 V (3.3 V ± 10 %) with 5 V tolerant I/O
pads.
1.3 Applications
• Industrial control
• Medical systems
• Access control
• Point-of-sale
• Communication gateway
• Embedded soft modem
• General purpose applications
[1] While the USB DMA is the primary user of the additional 8 kB RAM, this RAM is also accessible at any time
by the CPU as a general purpose RAM for data and code storage.
Peripheral Bus (VPB, a compatible superset of ARM’s AMBA Advanced Peripheral Bus)
for connection to on-chip peripheral functions. The LPC2141/24/6/8 configures the
ARM7TDMI-S processor in little-endian byte order.
AHB peripherals are allocated a 2 megabyte range of addresses at the very top of the
4 gigabyte ARM memory space. Each AHB peripheral is allocated a 16 kB address space
within the AHB address space. LPC2141/2/4/6/8 peripheral functions (other than the
interrupt controller) are connected to the VPB bus. The AHB to VPB bridge interfaces the
VPB bus to the AHB bus. VPB peripherals are also allocated a 2 megabyte range of
addresses, beginning at the 3.5 gigabyte address point. Each VPB peripheral is allocated
a 16 kB address space within the VPB address space.
The connection of on-chip peripherals to device pins is controlled by a Pin Connect Block
(see chapter "Pin Connect Block" on page 75). This must be configured by software to fit
specific application requirements for the use of peripheral functions and pins.
Pipeline techniques are employed so that all parts of the processing and memory systems
can operate continuously. Typically, while one instruction is being executed, its successor
is being decoded, and a third instruction is being fetched from memory.
The key idea behind THUMB is that of a super-reduced instruction set. Essentially, the
ARM7TDMI-S processor has two instruction sets:
THUMB code is able to provide up to 65% of the code size of ARM, and 160% of the
performance of an equivalent ARM processor connected to a 16-bit memory system.
The LPC2141/2/4/6/8 Flash memory provides minimum of 100,000 erase/write cycles and
20 years of data-retention.
The SRAM controller incorporates a write-back buffer in order to prevent CPU stalls during
back-to-back writes. The write-back buffer always holds the last data sent by software to
the SRAM. This data is only written to the SRAM when another write is requested by
software (the data is only written to the SRAM when software does another write). If a chip
reset occurs, actual SRAM contents will not reflect the most recent write request (i.e. after
a "warm" chip reset, the SRAM does not reflect the last write operation). Any software that
checks SRAM contents after reset must take this into account. Two identical writes to a
location guarantee that the data will be present after a Reset. Alternatively, a dummy write
operation before entering idle or power-down mode will similarly guarantee that the last
data written will be present in SRAM after a subsequent Reset.
LPC2141/42/44/46/48
EMULATION TRACE
TEST/DEBUG PLL0
INTERFACE
MODULE
P0[31:28] and system SYSTEM
P0[25:0] FAST GENERAL clock FUNCTIONS
PURPOSE I/O
ARM7TDMI-S
P1[31:16]
PLL1
AHB BRIDGE
VECTORED
USB
INTERRUPT
ARM7 local bus clock
CONTROLLER
AMBA AHB
(Advanced High-performance Bus)
INTERNAL INTERNAL
SRAM FLASH
CONTROLLER CONTROLLER
8 kB RAM AHB
8/16/32 kB 32/64/128/256/512 kB AHB TO VPB VPB SHARED WITH DECODER
SRAM FLASH BRIDGE DIVIDER USB DMA(3)
VPB (VLSI D+
peripheral bus) D−
USB 2.0 FULL-SPEED
EXTERNAL
EINT3 to EINT0 DEVICE CONTROLLER UP_LED
INTERRUPTS
WITH DMA(3) CONNECT
VBUS
TXD0, TXD1
RXD0, RXD1
AOUT(4) D/A CONVERTER UART0/UART1
DSR1(2),CTS1(2),
RTS1(2), DTR1(2)
DCD1(2),RI1(2)
P0[31:28] and
GENERAL RTXC1
P0[25:0] REAL-TIME CLOCK
PURPOSE I/O RTXC2
P1[31:16] VBAT
WATCHDOG
PWM6 to PWM0 PWM0
TIMER
SYSTEM
CONTROL
002aab560
0x0008 0000
TOTAL OF 512 kB ON-CHIP NON-VOLATILE MEMORY 0x0007 FFFF
(LPC2148) 0x0004 0000
TOTAL OF 256 kB ON-CHIP NON-VOLATILE MEMORY 0x0003 FFFF
(LPC2146) 0x0002 0000
TOTAL OF 128 kB ON-CHIP NON-VOLATILE MEMORY 0x0001 FFFF
(LPC2144) 0x0001 0000
TOTAL OF 64 kB ON-CHIP NON-VOLATILE MEMORY 0x0000 FFFF
(LPC2142) 0x0000 8000
TOTAL OF 32 kB ON-CHIP NON-VOLATILE MEMORY 0x0000 7FFF
0.0 GB (LPC2141) 0x0000 0000
Notes:
- AHB section is
128 x 16 kB blocks
(totaling 2 MB).
- VPB section is
128 x 16 kB blocks
(totaling 2 MB). RESERVED
0xF000 0000
3.75 GB
0xEFFF FFFF
RESERVED
0xE020 0000
3.5 GB + 2 MB
0xE01F FFFF
VPB PERIPHERALS
3.5 GB 0xE000 0000
Figures 3 through 4 and Table 2 show different views of the peripheral address space.
Both the AHB and VPB 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
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
address decoding for each peripheral. All peripheral register addresses are word aligned
(to 32-bit boundaries) regardless of their size. This eliminates the need for byte lane
mapping hardware that would be required to allow byte (8-bit) or half-word (16-bit)
accesses to occur at smaller boundaries. An implication of this is that word and half-word
registers must be accessed all at once. For example, it is not possible to read or write the
upper byte of a word register separately.
0xFFFF C000
0xFFE1 0000
Because of the location of the interrupt vectors on the ARM7 processor (at addresses
0x0000 0000 through 0x0000 001C, as shown in Table 3 below), a small portion of the
Boot Block and SRAM spaces need to be re-mapped in order to allow alternative uses of
interrupts in the different operating modes described in Table 4. Re-mapping of the
interrupts is accomplished via the Memory Mapping Control feature (Section 3.7 “Memory
mapping control” on page 26).
The portion of memory that is re-mapped to allow interrupt processing in different modes
includes the interrupt vector area (32 bytes) and an additional 32 bytes, for a total of
64 bytes. The re-mapped code locations overlay addresses 0x0000 0000 through
0x0000 003F. 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 to
the actual interrupt handlers, or to other instructions that accomplish the branch to the
interrupt handlers.
1. To give the FIQ handler in the Flash memory the advantage of not having to take a
memory boundary caused by the remapping into account.
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
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 Boot Block and interrupt vectors, continue to
appear in their original location in addition to the re-mapped address.
Details on re-mapping and examples can be found in Section 3.7 “Memory mapping
control” on page 26.
0x8000 0000
2.0 GB 12 kB BOOT BLOCK 0x7FFF FFFF
(RE-MAPPED FROM TOP OF FLASH MEMORY)
0x4000 8000
0x4000 7FFF
32 kB ON-CHIP SRAM
0x0008 0000
(12 kB BOOT BLOCK RE-MAPPED TO HIGHER ADDRESS RANGE) 0x0007 FFFF
Fig 5. Map of lower memory is showing re-mapped and re-mappable areas (LPC2148
with 512 kB Flash)
• Areas of the memory map that are not implemented for a specific ARM derivative. For
the LPC2141/2/4/6/8, this is:
– Address space between On-Chip Non-Volatile Memory and On-Chip SRAM,
labelled "Reserved Address Space" in Figure 2. For 32 kB Flash device this is
memory address range from 0x0000 8000 to 0x3FFF FFFF, for 64 kB Flash device
this is memory address range from 0x0001 0000 to 0x3FFF FFFF, for 128 kB Flash
device this is memory address range from 0x0002 0000 to 0x3FFF FFFF, for
256 kB Flash device this is memory address range from 0x0004 0000 to
0x3FFF FFFF while for 512 kB Flash device this range is from 0x0008 0000 to
0x3FFF FFFF.
– Address space between On-Chip Static RAM and the Boot Block. Labelled
"Reserved Address Space" in Figure 2. For 8 kB SRAM device this is memory
address range from 0x4000 2000 to 0x7FFF CFFF, for 16 kB SRAM device this is
memory address range from 0x4000 4000 to 0x7FFF CFFF. For 32 kB SRAM
device this range is from 0x4000 8000 to 0x7FCF FFFF where the 8 kB USB DMA
RAM starts, and from 0x7FD0 2000 to 0x7FFF CFFF.
– Address space between 0x8000 0000 and 0xDFFF FFFF, labelled "Reserved
Adress Space".
– Reserved regions of the AHB and VPB spaces. See Figure 3.
• Unassigned AHB peripheral spaces. See Figure 4.
• Unassigned VPB peripheral spaces. See Table 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 to
an AHB or VPB peripheral address.
Within the address space of an existing VPB peripheral, a data abort exception is not
generated in response to an access to an undefined address. Address decoding within
each peripheral is limited to that needed to distinguish defined registers within the
peripheral itself. For example, an access to address 0xE000 D000 (an undefined address
within the UART0 space) may result in an access to the register defined at address
0xE000 C000. Details of such address aliasing within a peripheral space are not defined
in the LPC2141/2/4/6/8 documentation and are not a supported feature.
Note that the ARM core stores the Prefetch Abort flag along with the associated
instruction (which will be meaningless) in the pipeline and processes the abort only if an
attempt is made to execute the instruction fetched from the illegal address. This prevents
accidental aborts that could be caused by prefetches that occur when code is executed
very near a memory boundary.
• Crystal Oscillator
• External Interrupt Inputs
• Miscellaneous System Controls and Status
• Memory Mapping Control
• PLL
• Power Control
• Reset
• VPB Divider
• Wakeup Timer
Each type of function has its own register(s) if any are required and unneeded bits are
defined as reserved in order to allow future expansion. Unrelated functions never share
the same register addresses
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
The oscillator output frequency is called FOSC and the ARM processor clock frequency is
referred to as CCLK for purposes of rate equations, etc. elsewhere in this document. FOSC
and CCLK are the same value unless the PLL is running and connected. Refer to the
Section 3.8 “Phase Locked Loop (PLL)” on page 27 for details and frequency limitations.
The onboard oscillator in the LPC2141/2/4/6/8 can operate in one of two modes: slave
mode and oscillation mode.
In slave mode the input clock signal should be coupled by means of a capacitor of 100 pF
(CC in Figure 6, drawing a), with an amplitude of at least 200 mVrms. The X2 pin in this
configuration can be left not connected. If slave mode is selected, the FOSC signal of 50-50
duty cycle can range from 1 MHz to 50 MHz.
External components and models used in oscillation mode are shown in Figure 6,
drawings b and c, and in Table 7. Since the feedback resistance is integrated on chip, only
a crystal and the capacitances CX1 and CX2 need to be connected externally in case of
fundamental mode oscillation (the fundamental frequency is represented by L, CL and
RS). Capacitance CP in Figure 6, drawing c, represents the parallel package capacitance
and should not be larger than 7 pF. Parameters FC, CL, RS and CP are supplied by the
crystal manufacturer.
LPC2141/2/4/6/8 LPC2141/2/4/6/8
X1 X2 X1 X2
CC <=>
CL CP
Xtal
Clock CX1 CX2
RS
a) b) c)
Fig 6. Oscillator modes and models: a) slave mode of operation, b) oscillation mode of
operation, c) external crystal model used for CX1/X2 evaluation
Table 7: Recommended values for CX1/X2 in oscillation mode (crystal and external
components parameters)
Fundamental Crystal load Maximum crystal External load
oscillation frequency capacitance CL series resistance RS capacitors CX1, CX2
FOSC
1 MHz - 5 MHz 10 pF NA NA
20 pF NA NA
30 pF < 300 Ω 58 pF, 58 pF
5 MHz - 10 MHz 10 pF < 300 Ω 18 pF, 18 pF
20 pF < 300 Ω 38 pF, 38 pF
30 pF < 300 Ω 58 pF, 58 pF
10 MHz - 15 MHz 10 pF < 300 Ω 18 pF, 18 pF
20 pF < 220 Ω 38 pF, 38 pF
30 pF < 140 Ω 58 pF, 58 pF
15 MHz - 20 MHz 10 pF < 220 Ω 18 pF, 18 pF
20 pF < 140 Ω 38 pF, 38 pF
30 pF < 80 Ω 58 pF, 58 pF
20 MHz - 25 MHz 10 pF < 160 Ω 18 pF, 18 pF
20 pF < 90 Ω 38 pF, 38 pF
30 pF < 50 Ω 58 pF, 58 pF
25 MHz - 30 MHz 10 pF < 130 Ω 18 pF, 18 pF
20 pF < 50 Ω 38 pF, 38 pF
30 pF NA NA
f OSC selection
False
False
False
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
Writing ones to bits EINT0 through EINT3 in EXTINT register clears the corresponding
bits. In level-sensitive mode this action is efficacious only when the pin is in its inactive
state.
Once a bit from EINT0 to EINT3 is set and an appropriate code starts to execute (handling
wakeup and/or external interrupt), this bit in EXTINT register must be cleared. Otherwise
the event that was just triggered by activity on the EINT pin will not be recognized in the
future.
For example, if a system wakes up from power-down using a low level on external
interrupt 0 pin, its post-wakeup code must reset the EINT0 bit in order to allow future entry
into the power-down mode. If the EINT0 bit is left set to 1, subsequent attempt(s) to invoke
power-down mode will fail. The same goes for external interrupt handling.
Table 9: External Interrupt Flag register (EXTINT - address 0xE01F C140) bit description
Bit Symbol Description Reset
value
0 EINT0 In level-sensitive mode, this bit is set if the EINT0 function is selected for its pin, and the pin is in 0
its active state. In edge-sensitive mode, this bit is set if the EINT0 function is selected for its pin,
and the selected edge occurs on the pin.
Up to two pins can be selected to perform the EINT0 function (see P0.1 and P0.16 description in
"Pin Configuration" chapter page 66.)
This bit is cleared by writing a one to it, except in level sensitive mode when the pin is in its active
state (e.g. if EINT0 is selected to be low level sensitive and a low level is present on the
corresponding pin, this bit can not be cleared; this bit can be cleared only when the signal on the
pin becomes high).
1 EINT1 In level-sensitive mode, this bit is set if the EINT1 function is selected for its pin, and the pin is in 0
its active state. In edge-sensitive mode, this bit is set if the EINT1 function is selected for its pin,
and the selected edge occurs on the pin.
Up to two pins can be selected to perform the EINT1 function (see P0.3 and P0.14 description in
"Pin Configuration" chapter on page 66.)
This bit is cleared by writing a one to it, except in level sensitive mode when the pin is in its active
state (e.g. if EINT1 is selected to be low level sensitive and a low level is present on the
corresponding pin, this bit can not be cleared; this bit can be cleared only when the signal on the
pin becomes high).
2 EINT2 In level-sensitive mode, this bit is set if the EINT2 function is selected for its pin, and the pin is in 0
its active state. In edge-sensitive mode, this bit is set if the EINT2 function is selected for its pin,
and the selected edge occurs on the pin.
Up to two pins can be selected to perform the EINT2 function (see P0.7 and P0.15 description in
"Pin Configuration" chapter on page 66.)
This bit is cleared by writing a one to it, except in level sensitive mode when the pin is in its active
state (e.g. if EINT2 is selected to be low level sensitive and a low level is present on the
corresponding pin, this bit can not be cleared; this bit can be cleared only when the signal on the
pin becomes high).
3 EINT3 In level-sensitive mode, this bit is set if the EINT3 function is selected for its pin, and the pin is in 0
its active state. In edge-sensitive mode, this bit is set if the EINT3 function is selected for its pin,
and the selected edge occurs on the pin.
Up to three pins can be selected to perform the EINT3 function (see P0.9, P0.20 and P0.30
description in "Pin Configuration" chapter on page 66.)
This bit is cleared by writing a one to it, except in level sensitive mode when the pin is in its active
state (e.g. if EINT3 is selected to be low level sensitive and a low level is present on the
corresponding pin, this bit can not be cleared; this bit can be cleared only when the signal on the
pin becomes high).
7:4 - Reserved, user software should not write ones to reserved bits. The value read from a reserved NA
bit is not defined.
For an external interrupt pin to be a source that would wake up the microcontroller from
Power-down mode, it is also necessary to clear the corresponding bit in the External
Interrupt Flag register (Section 3.5.2 on page 21).
Table 10: Interrupt Wakeup register (INTWAKE - address 0xE01F C144) bit description
Bit Symbol Description Reset
value
0 EXTWAKE0 When one, assertion of EINT0 will wake up the processor from 0
Power-down mode.
1 EXTWAKE1 When one, assertion of EINT1 will wake up the processor from 0
Power-down mode.
2 EXTWAKE2 When one, assertion of EINT2 will wake up the processor from 0
Power-down mode.
3 EXTWAKE3 When one, assertion of EINT3 will wake up the processor from 0
Power-down mode.
4 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
5 USBWAKE When one, activity of the USB bus (USB_need_clock = 1) will 0
wake up the processor from Power-down mode. Any change of
state on the USB data pins will cause a wakeup when this bit is
set. For details on the relationship of USB to Power-down mode
and wakeup, see Section 14.7.1 “USB Interrupt Status register
(USBIntSt - 0xE01F C1C0)” on page 200 and Section 3.8.8
“PLL and Power-down mode” on page 32.
13:4 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
14 BODWAKE When one, a BOD interrupt will wake up the processor from 0
Power-down mode.
15 RTCWAKE When one, assertion of an RTC interrupt will wake up the 0
processor from Power-down mode.
Note: Software should only change a bit in this register when its interrupt is
disabled in the VICIntEnable register, and should write the corresponding 1 to the
EXTINT register before enabling (initializing) or re-enabling the interrupt, to clear
the EXTINT bit that could be set by changing the mode.
Table 11: External Interrupt Mode register (EXTMODE - address 0xE01F C148) bit
description
Bit Symbol Value Description Reset
value
0 EXTMODE0 0 Level-sensitivity is selected for EINT0. 0
1 EINT0 is edge sensitive.
1 EXTMODE1 0 Level-sensitivity is selected for EINT1. 0
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Table 11: External Interrupt Mode register (EXTMODE - address 0xE01F C148) bit
description
Bit Symbol Value Description Reset
value
1 EINT1 is edge sensitive.
2 EXTMODE2 0 Level-sensitivity is selected for EINT2. 0
1 EINT2 is edge sensitive.
3 EXTMODE3 0 Level-sensitivity is selected for EINT3. 0
1 EINT3 is edge sensitive.
7:4 - - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Note: Software should only change a bit in this register when its interrupt is
disabled in the VICIntEnable register, and should write the corresponding 1 to the
EXTINT register before enabling (initializing) or re-enabling the interrupt, to clear
the EXTINT bit that could be set by changing the polarity.
Table 12: External Interrupt Polarity register (EXTPOLAR - address 0xE01F C14C) bit
description
Bit Symbol Value Description Reset
value
0 EXTPOLAR0 0 EINT0 is low-active or falling-edge sensitive (depending on 0
EXTMODE0).
1 EINT0 is high-active or rising-edge sensitive (depending on
EXTMODE0).
1 EXTPOLAR1 0 EINT1 is low-active or falling-edge sensitive (depending on 0
EXTMODE1).
1 EINT1 is high-active or rising-edge sensitive (depending on
EXTMODE1).
2 EXTPOLAR2 0 EINT2 is low-active or falling-edge sensitive (depending on 0
EXTMODE2).
1 EINT2 is high-active or rising-edge sensitive (depending on
EXTMODE2).
3 EXTPOLAR3 0 EINT3 is low-active or falling-edge sensitive (depending on 0
EXTMODE3).
1 EINT3 is high-active or rising-edge sensitive (depending on
EXTMODE3).
7:4 - - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
• In Low-Active Level Sensitive mode, the states of all pins selected for the same EINTx
functionality are digitally combined using a positive logic AND gate.
• In High-Active Level Sensitive mode, the states of all pins selected for the same
EINTx functionality are digitally combined using a positive logic OR gate.
• In Edge Sensitive mode, regardless of polarity, the pin with the lowest GPIO port
number is used. (Selecting multiple pins for an EINTx in edge-sensitive mode could
be considered a programming error.)
The signal derived by this logic processing multiple external interrupt pins is the EINTi
signal in the following logic schematic Figure 8.
For example, if the EINT3 function is selected in the PINSEL0 and PINSEL1 registers for
pins P0.9, P0.20 and P0.30, and EINT3 is configured to be low level sensitive, the inputs
from all three pins will be logically ANDed. When more than one EINT pin is logically
ORed, the interrupt service routine can read the states of the pins from the GPIO port
using the IO0PIN and IO1PIN registers, to determine which pin(s) caused the interrupt.
Wakeup enable
VPB Read
(one bit of EXTWAKE)
of EXTWAKE
EINTi to
VPB Bus Data D Q Wakeup Timer
(Figure 11)
GLITCH
EINTi PCLK
FILTER
1 D S S S
Q Q Q to VIC
R R R
EXTMODEi
VPB Read
PCLK of EXTINT
PCLK
Reset
Write 1 to EXTINTi
3.6.1 System Control and Status flags register (SCS - 0xE01F C1A0)
Table 13: System Control and Status flags register (SCS - address 0xE01F C1A0) bit description
Bit Symbol Value Description Reset
value
0 GPIO0M GPIO port 0 mode selection. 0
0 GPIO port 0 is accessed via VPB 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 on page page 81.
1 GPIO1M GPIO port 1 mode selection. 0
0 GPIO port 1 is accessed via VPB addresses in a fashion compatible with previous
LCP2000 devices.
1 High speed GPIO is enabled on GPIO port 1, accessed via addresses in the on-chip
memory range. This mode includes the port masking feature described in the GPIO
chapter on page page 81.
31:2 - Reserved, user software should not write ones to reserved bits. The value read from NA
a reserved bit is not defined.
Table 14: Memory Mapping control register (MEMMAP - address 0xE01F C040) bit
description
Bit Symbol Value Description Reset
value
1:0 MAP 00 Boot Loader Mode. Interrupt vectors are re-mapped to Boot 00
Block.
01 User Flash Mode. Interrupt vectors are not re-mapped and
reside 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 NA
bits. The value read from a reserved bit is not defined.
For example, whenever a Software Interrupt request is generated, the ARM core will
always fetch 32-bit data "residing" on 0x0000 0008 see Table 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).
The PLL0 and PLL1 accept 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 for the CCLK
and 48 MHz for the USB clock using a Current Controlled Oscillators (CCO). The
multiplier can be an integer value from 1 to 32 (in practice, the multiplier value cannot be
higher than 6 on the LPC2141/2/4/6/8 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 divide by 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 is shown in Figure 9.
PLL activation is controlled via the PLLCON register. The PLL multiplier and divider values
are controlled by the PLLCFG register. These two registers are protected in order to
prevent accidental alteration of PLL parameters or deactivation of the PLL. Since all chip
operations, including the Watchdog Timer, are dependent on the PLL0 when it is providing
the chip clock, accidental changes to the PLL setup could result in unexpected behavior of
the microcontroller. The same concern is present with the PLL1 and the USB. The
protection is accomplished by a feed sequence similar to that of the Watchdog Timer.
Details are provided in the description of the PLLFEED register.
Both PLLs are turned off and bypassed following a chip Reset and when by entering
Power-down mode. The PLL is enabled by software only. The program must configure and
activate the PLL, wait for the PLL to Lock, then connect to the PLL as a clock source.
Warning: Improper setting of the PLL0 and PLL1 values may result in incorrect
operation of the device and the USB module!
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
PLLC
CLOCK
SYNCHRONIZATION
0 Direct
PSEL[1:0]
PD PD
PLLE
0 Bypass
F OSC 1 CD
PHASE- F CCO
FREQUENCY CCO 0 0
PLOCK DETECTOR /2P
0 CCLK
1
PD 1
CD
F OUT
DIV-BY-M
MSEL<4:0>
MSEL[4:0]
Table 16: PLL Control register (PLL0CON - address 0xE01F C080, PLL1CON - address
0xE01F C0A0) bit description
Bit Symbol Description Reset
value
0 PLLE PLL Enable. When one, and after a valid PLL feed, this bit will 0
activate the PLL and allow it to lock to the requested frequency. See
PLLSTAT register, Table 18.
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 18.
7:2 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
The PLL must be set up, enabled, and Lock established before it may be used as a clock
source. When switching from the oscillator clock to the PLL output or vice versa, internal
circuitry synchronizes the operation in order to ensure that glitches are not generated.
Hardware does not insure that the PLL is locked before it is connected or automatically
disconnect the PLL if lock is lost during operation. In the event of loss of PLL lock, it is
likely that the oscillator clock has become unstable and disconnecting the PLL will not
remedy the situation.
Table 17: PLL Configuration register (PLL0CFG - address 0xE01F C084, PLL1CFG - address
0xE01F C0A4) bit description
Bit Symbol Description Reset
value
4:0 MSEL PLL Multiplier value. Supplies the value "M" in the PLL frequency 0
calculations.
Note: For details on selecting the right value for MSEL see Section
3.8.9 “PLL frequency calculation” on page 33.
6:5 PSEL PLL Divider value. Supplies the value "P" in the PLL frequency 0
calculations.
Note: For details on selecting the right value for PSEL see Section
3.8.9 “PLL frequency calculation” on page 33.
7 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
Table 18: PLL Status register (PLL0STAT - address 0xE01F C088, PLL1STAT - address
0xE01F C0A8) bit description
Bit Symbol Description Reset
value
4:0 MSEL Read-back for the PLL Multiplier value. This is the value currently 0
used by the PLL.
6:5 PSEL Read-back for the PLL Divider value. This is the value currently 0
used by the PLL.
7 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
8 PLLE Read-back for the PLL Enable bit. When one, the PLL is currently 0
activated. When zero, the PLL is turned off. This bit is automatically
cleared when Power-down mode is activated.
9 PLLC Read-back for the PLL Connect bit. When PLLC and PLLE are both 0
one, the PLL is connected as the clock source for the
microcontroller. When either PLLC or PLLE is zero, the PLL is
bypassed and the oscillator clock is used directly by the
microcontroller. This bit is automatically cleared when Power-down
mode is activated.
10 PLOCK Reflects the PLL Lock status. When zero, the PLL is not locked. 0
When one, the PLL is locked onto the requested frequency.
15:11 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
PLL interrupt is available only in PLL0, i.e. the PLL that generates the CCLK. USB
dedicated PLL1 does not have this capability.
The two writes must be in the correct sequence, and must be consecutive VPB 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 20: PLL Feed register (PLL0FEED - address 0xE01F C08C, PLL1FEED - address
0xE01F C0AC) bit description
Bit Symbol Description Reset
value
7:0 PLLFEED The PLL feed sequence must be written to this register in order for 0x00
PLL configuration and control register changes to take effect.
If activity on the USB data lines is not selected to wake up the microcontroller from
Power-down mode (see Section 3.5.3 “Interrupt Wakeup register (INTWAKE -
0xE01F C144)” on page 22), both the system and the USB PLL will be automatically be
turned off and disconnected when Power-down mode is invoked, as described above.
However, in case USBWAKE = 1 and USB_need_clock = 1 it is not possible to go into
Power-down mode and any attempt to set the PD bit will fail, leaving the PLLs in the
current state.
The PLL output frequency (when the PLL is both active and connected) is given by:
1. Choose the desired processor operating frequency (CCLK). This may be based on
processor throughput requirements, need to support a specific set of UART baud
rates, etc. Bear in mind that peripheral devices may be running from a lower clock
than the processor (see Section 3.11 “VPB divider” on page 40).
2. Choose an oscillator frequency (FOSC). CCLK must be the whole (non-fractional)
multiple of FOSC.
3. Calculate the value of M to configure the MSEL bits. M = CCLK / FOSC. M must be in
the range of 1 to 32. The value written to the MSEL bits in PLLCFG is M − 1 (see
Table 23.
4. Find a value for P to configure the PSEL bits, such that FCCO is within its defined
frequency limits. FCCO is calculated using the equation given above. P must have one
of the values 1, 2, 4, or 8. The value written to the PSEL bits in PLLCFG is 00 for
P = 1; 01 for P = 2; 10 for P = 4; 11 for P = 8 (see Table 22).
Important: if a particular application is using the USB peripheral, the PLL1 must be
configured since this is the only available source of the 48 MHz clock required by
the USB. This limits the selection of FOSC to either 12 MHz, 16 MHz or 24 MHz.
System design asks for FOSC= 10 MHz and requires CCLK = 60 MHz.
Value for P can be derived from P = FCCO / (CCLK x 2), using condition that FCCO must be
in range of 156 MHz to 320 MHz. Assuming the lowest allowed frequency for
FCCO = 156 MHz, P = 156 MHz / (2 x 60 MHz) = 1.3. The highest FCCO frequency criteria
produces P = 2.67. The only solution for P that satisfies both of these requirements and is
listed in Table 22 is P = 2. Therefore, PLLCFG[6:5] = 1 will be used.
System design asks for FOSC= 12 MHz and requires the USB clock of 48 MHz.
Value for P can be derived from P = FCCO / (48 MHz 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 48 MHz) = 1.625. The highest FCCO frequency
criteria produces P = 3.33. Solution for P that satisfy both of these requirements and are
listed in Table 22 are P = 2 and P = 3. Therefore, either of these two values can be used to
program PLLCFG[6:5] in the PLL1.
Example 2 has illustrated the way PLL1 should be configured. Since PLL0 and PLL1 are
independent, the PLL0 can be configured using the approach described in Example 1.
In Power-down mode, the oscillator is shut down and the chip receives no internal clocks.
The processor state and registers, peripheral registers, and internal SRAM values are
preserved throughout Power-down mode and the logic levels of chip pins remain static.
The Power-down mode can be terminated and normal operation resumed by either a
Reset or certain specific interrupts that are able to function without clocks. Since all
dynamic operation of the chip is suspended, Power-down mode reduces chip power
consumption to nearly zero.
Entry to Power-down and Idle modes must be coordinated with program execution.
Wakeup from Power-down or Idle modes via an interrupt resumes program execution in
such a way that no instructions are lost, incomplete, or repeated. Wake up from
Power-down mode is discussed further in Section 3.12 “Wakeup timer” on page 41.
A Power Control for Peripherals feature allows individual peripherals to be turned off if
they are not needed in the application, resulting in additional power savings.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
Table 25: Power Control register (PCON - address 0xE01F COCO) bit description
Bit Symbol Description Reset
value
0 IDL Idle mode - when 1, this bit causes the processor clock to be stopped, 0
while on-chip peripherals remain active. Any enabled interrupt from a
peripheral or an external interrupt source will cause the processor to
resume execution.
1 PD Power-down mode - when 1, this bit causes the oscillator and all 0
on-chip clocks to be stopped. A wakeup condition from an external
interrupt can cause the oscillator to restart, the PD bit to be cleared,
and the processor to resume execution.
IMPORTANT: PD bit can be set to 1 at any time if USBWAKE = 0. In
case of USBWAKE = 1, it is possible to set PD to 1 only if
USB_need_clock = 0. Having both USBWAKE and
USB_need_clock equal 1 prevents the microcontroller from
entering Power-down mode. (For additional details see Section 3.5.3
“Interrupt Wakeup register (INTWAKE - 0xE01F C144)” on page 22 and
Section 14.7.1 “USB Interrupt Status register (USBIntSt -
0xE01F C1C0)” on page 200)
2 PDBOD When PD is 1 and this bit is 0, Brown Out Detection (BOD) remains 0
operative during Power-down mode, such that its Reset can release the
microcontroller from Power-down mode[1]. When PD and this bit are
both 1, the BOD circuit is disabled during Power-down mode to
conserve power. When PD is 0, the state of this bit has no effect.
3 BODPDM When this bit is 1, the BOD circuitry will go into power down mode when 0
chip power down is asserted, resulting in a further reduction in power.
However, the possibility of using BOD as a wakeup source from Power
Down mode will be lost. When this bit is 0, BOD stays active during
Power Down mode.
4 BOGD Brown Out Global Disable. When this bit is 1, the BOD circuitry is fully 0
disabled at all times, and will not consume power. When 0, the BOD
circuitry is enabled.
5 BORD Brown Out Reset Disable. When this bit is 1, the second stage of low 0
voltage detection (2.6 V) will not cause a chip reset. When BORD is 0,
the reset is enabled. The first stage of low voltage detection (2.9 V)
Brown Out interrupt is not affected.
7:6 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
[1] Since execution is delayed until after the Wakeup Timer has allowed the main oscillator to resume stable
operation, there is no guarantee that execution will resume before VDD has fallen below the lower BOD
threshold, which prevents execution. If execution does resume, there is no guarantee of how long the
microcontroller will continue execution before the lower BOD threshold terminates execution. These issues
depend on the slope of the decline of VDD. High decoupling capacitance (between VDD and ground) in the
vicinity of the microcontroller will improve the likelihood that software will be able to do what needs to be
done when power is being lost.
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 VPB
peripheral map Table 2 “VPB peripheries and base addresses” in the "LPC2141/2/4/6/8
Memory Addressing" chapter.
Important: valid read from a peripheral register and valid write to a peripheral
register is possible only if that peripheral is enabled in the PCONP register!
Table 26: Power Control for Peripherals register (PCONP - address 0xE01F C0C4) bit
description
Bit Symbol Description Reset
value
0 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
1 PCTIM0 Timer/Counter 0 power/clock control bit. 1
2 PCTIM1 Timer/Counter 1 power/clock control bit. 1
3 PCUART0 UART0 power/clock control bit. 1
4 PCUART1 UART1 power/clock control bit. 1
5 PCPWM0 PWM0 power/clock control bit. 1
6 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
7 PCI2C0 The I2C0 interface power/clock control bit. 1
8 PCSPI0 The SPI0 interface power/clock control bit. 1
9 PCRTC The RTC power/clock control bit. 1
10 PCSPI1 The SSP interface power/clock control bit. 1
11 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
12 PCAD0 A/D converter 0 (ADC0) power/clock control bit. 1
Note: Clear the PDN bit in the AD0CR before clearing this bit, and set
this bit before setting PDN.
18:13 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
19 PCI2C1 The I2C1 interface power/clock control bit. 1
20 PCAD1 A/D converter 1 (ADC1) power/clock control bit. 1
Note: Clear the PDN bit in the AD1CR before clearing this bit, and set
this bit before setting PDN.
30:21 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
31 PUSB USB power/clock control bit. 0
Power saving oriented systems should have 1s in the PCONP register only in positions
that match peripherals really used in the application. All other bits, declared to be
"Reserved" or dedicated to the peripherals not used in the current application, must be
cleared to 0.
3.10 Reset
Reset has two sources on the LPC2141/2/4/6/8: the RESET pin and Watchdog Reset.
The RESET pin is a Schmitt trigger input pin with an additional glitch filter. Assertion of
chip Reset by any source starts the Wakeup Timer (see description in Section 3.12
“Wakeup timer” in this chapter), causing reset to remain asserted until the external Reset
is de-asserted, the oscillator is running, a fixed number of clocks have passed, and the
on-chip circuitry has completed its initialization. The relationship between Reset, the
oscillator, and the Wakeup Timer are shown in Figure 10.
The Reset glitch filter allows the processor to ignore external reset pulses that are very
short, and also determines the minimum duration of RESET that must be asserted in
order to guarantee a chip reset. Once asserted, RESET pin can be deasserted only when
crystal oscillator is fully running and an adequate signal is present on the X1 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 X1
pin, the RESET pin needs to be asserted for 300 ns only.
When the internal Reset is removed, the processor begins executing at address 0, which
is initially the Reset vector mapped from the Boot Block. At that point, all of the processor
and peripheral registers have been initialized to predetermined values.
External and internal Resets have some small differences. An external Reset causes the
value of certain pins to be latched to configure the part. External circuitry cannot
determine when an internal Reset occurs in order to allow setting up those special pins,
so those latches are not reloaded during an internal Reset. Pins that are examined during
an external Reset for various purposes are: P1.20/TRACESYNC, P1.26/RTCK (see
chapters "Pin Configuration" on page 66 and "Pin Connect Block" on page 75). Pin P0.14
(see "Flash Memory System and Programming" chapter on page 291) is examined by
on-chip bootloader when this code 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.
Reset to the
External on-chip
reset C
circuitry
Q
Watchdog S Reset to
reset PCON.PD
WAKEUP TIMER
START
Power
down COUNT 2n C
VBP Read
of PDBIT
in PCON
FOSC
to PLL
Table 27: 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 not
affected by any of the other sources of Reset.
1 EXTR Assertion of the RESET signal sets this bit. This bit is cleared by POR, see text
but is not affected by WDT or BOD reset.
Table 27: Reset Source identification Register (RSIR - address 0xE01F C180) bit description
Bit Symbol Description Reset
value
2 WDTR This bit is set when the Watchdog Timer times out and the WDTRESET see text
bit in the Watchdog Mode Register is 1. It is cleared by any of the other
sources of Reset.
3 BODR This bit is set when the 3.3 V power reaches a level below 2.6 V. If the see text
VDD voltage dips from 3.3 V to 2.5 V and backs up, the BODR bit will be
set to 1. Also, if the VDD voltage rises continuously from below 1 V to a
level above 2.6 V, the BODR will be set to 1, too. This bit is not affected
by External Reset nor Watchdog Reset.
Note: only in case a reset occurs and the bit POR = 0, the BODR bit
indicates if the VDD voltage was below 2.6 V or not.
7:4 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
The first is to provides peripherals with desired PCLK via VPB bus so that they can
operate at the speed chosen for the ARM processor. In order to achieve this, the VPB bus
may be slowed down to one half or one fourth of the processor clock rate. Because the
VPB bus must work properly at power up (and its timing cannot be altered if it does not
work since the VPB divider control registers reside on the VPB bus), the default condition
at reset is for the VPB bus to run at one quarter speed.
The second purpose of the VPB 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 VPB Divider relative to the oscillator and the processor clock is
shown in Figure 11. Because the VPB Divider is connected to the PLL output, the PLL
remains active (if it was running) during Idle mode.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
Table 29: VPB Divider register (VPBDIV - address 0xE01F C100) bit description
Bit Symbol Value Description Reset
value
1:0 VPBDIV 00 VPB bus clock is one fourth of the processor clock. 00
01 VPB bus clock is the same as the processor clock.
10 VPB bus clock is one half of the processor clock.
11 Reserved. If this value is written to the VPBDIV register, it
has no effect (the previous setting is retained).
7:2 - - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Crystal oscillator
or Processor clock
PLL0
external clock source (CCLK)
(F OSC )
The Wakeup Timer monitors the crystal oscillator as the means of checking whether it is
safe to begin code execution. When power is applied to the chip, or some event caused
the chip to exit Power-down mode, some time is required for the oscillator to produce a
signal of sufficient amplitude to drive the clock logic. The amount of time depends on
many factors, including the rate of VDD ramp (in the case of power on), the type of crystal
and its electrical characteristics (if a quartz crystal is used), as well as any other external
circuitry (e.g. capacitors), and the characteristics of the oscillator itself under the existing
ambient conditions.
Once a clock is detected, the Wakeup Timer counts 4096 clocks, then enables the on-chip
circuitry to initialize. When the onboard modules initialization is complete, the processor is
released to execute instructions if the external Reset has been deasserted. In the case
where an external clock source is used in the system (as opposed to a crystal connected
to the oscillator pins), the possibility that there could be little or no delay for oscillator
start-up must be considered. The Wakeup Timer design then ensures that any other
required chip functions will be operational prior to the beginning of program execution.
Any of the various Resets can bring the microcontroller out of power-down mode, as can
the external interrupts EINT3:0, plus 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 wakeup and
its selected event occurs, an oscillator wakeup cycle is started. The actual interrupt (if any)
occurs after the wakeup timer expires, and is handled by the Vectored Interrupt Controller.
However, the pin multiplexing on the LPC2141/2/4/6/8 (see chapters "Pin Configuration"
on page 66 and "Pin Connect Block" on page 75) was designed to allow other peripherals
to, in effect, bring the device out of Power-down mode. The following pin-function pairings
allow interrupts from events relating to UART0 or 1, SPI 0 or 1, or the I2C: RxD0 / EINT0,
SDA / EINT1, SSEL0 / EINT2, RxD1 / EINT3, DCD1 / EINT1, RI1 / EINT2, SSEL1 /
EINT3.
To put the device in Power-down mode and allow activity on one or more of these buses or
lines to power it back up, software should reprogram the pin function to External Interrupt,
select the appropriate mode and polarity for the Interrupt, and then select Power-down
mode. Upon wakeup software should restore the pin multiplexing to the peripheral
function.
All of the bus- or line-activity indications in the list above happen to be low-active. If
software wants the device to come out of power -down mode in response to activity on
more than one pin that share the same EINTi channel, it should program low-level
sensitivity for that channel, because only in level mode will the channel logically OR the
signals to wake the device.
The only flaw in this scheme is that the time to restart the oscillator prevents the
LPC2141/2/4/6/8 from capturing the bus or line activity that wakes it up. Idle mode is more
appropriate than power-down mode for devices that must capture and respond to external
activity in a timely manner.
Both the 2.9 V and 2.6 V thresholds include some hysteresis. In normal operation, this
hysteresis allows the 2.9 V detection to reliably interrupt, or a regularly-executed event
loop to sense the condition.
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Details on the way Code Read Protection works can be found in the "Flash Memory
System and Programming" chapter on page 291.
4.1 Introduction
The MAM block in the LPC2141/2/4/6/8 maximizes the performance of the ARM
processor when it is running code in Flash memory, but does so using a single Flash
bank.
4.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
LPC2141/2/4/6/8 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, the
Branch Trail Buffer and the Data Buffer. When an Instruction Fetch is not satisfied by
either the Prefetch or Branch Trail buffer, nor has a prefetch been initiated for that line, the
ARM is stalled while a fetch is initiated for the 128-bit line. If a prefetch has been initiated
but 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 code
or 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 a
Flash 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 the
conditional 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 which
such 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
the Prefetch and Branch Trail Buffer is taken, a stall of several clocks is needed to load the
Branch Trail Buffer. Subsequently, there will typically be no further instructionfetch delays
until a new and different branch occurs.
Figure 12 shows a simplified block diagram of the Memory Accelerator Module data paths.
In the following descriptions, the term “fetch” applies to an explicit Flash read request from
the ARM. “Pre-fetch” is used to denote a Flash read of instructions beyond the current
processor fetch address.
Flash programming operations are not controlled by the MAM, but are handled as a
separate function. A “boot block” sector contains Flash programming algorithms that may
be called as part of the application program, and a loader that may be run to allow serial
programming of the Flash memory.
Memory Address
Flash Memory
Bank
BUS
ARM Local Bus
INTERFACE
BUFFERS
Memory Data
Fig 12. Simplified block diagram of the Memory Accelerator Module (MAM)
Latch, and a 15-bit comparator associated with each buffer (prefetch, branch trail, and
data). 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 word
from 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.
In order to preclude the possibility of stale data being read from the Flash memory, the
LPC2141/2/4/6/8 MAM holding latches are automatically invalidated at the beginning of
any Flash programming or erase operation. Any subsequent read from a Flash address
will cause a new fetch to be initiated after the Flash operation has completed.
Mode 0: MAM off. All memory requests result in a Flash read operation (see note 2
below). There are no instruction prefetches.
Mode 1: MAM partially enabled. Sequential instruction accesses are fulfilled from the
holding latches if the data is present. Instruction prefetch is enabled. Non-sequential
instruction accesses initiate Flash read operations (see note 2 below). This means that
all branches cause memory fetches. All data operations cause a Flash read because
buffered data access timing is hard to predict and is very situation dependent.
Mode 2: MAM fully enabled. Any memory request (code or data) for a value that is
contained in one of the corresponding holding latches is fulfilled from the latch.
Instruction prefetch is enabled. Flash read operations are initiated for instruction
prefetch and code or data values not available in the corresponding holding latches.
Table 31: MAM responses to data and DMA accesses of various types
Data Memory Request Type MAM Mode
0 1 2
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
Non-sequential access, data not in latches Initiate Fetch Initiate Fetch Initiate Fetch
[1] The MAM actually uses latched data if it is available, but mimics the timing of a Flash read operation. This
saves power while resulting in the same execution timing. The MAM can truly be turned off by setting the
fetch timing value in MAMTIM to one clock.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
Table 33: MAM Control Register (MAMCR - address 0xE01F C000) bit description
Bit Symbol Value Description Reset
value
1:0 MAM_mode 00 MAM functions disabled 0
_control 01 MAM functions partially enabled
10 MAM functions fully enabled
11 Reserved. Not to be used in the application.
7:2 - - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Table 34: MAM Timing register (MAMTIM - address 0xE01F C004) bit description
Bit Symbol Value Description Reset
value
2:0 MAM_fetch_ 000 0 - Reserved. 07
cycle_timing
001 1 - MAM fetch cycles are 1 processor clock (CCLK) in
duration
010 2 - MAM fetch cycles are 2 CCLKs in duration
011 3 - MAM fetch cycles are 3 CCLKs in duration
100 4 - MAM fetch cycles are 4 CCLKs in duration
101 5 - MAM fetch cycles are 5 CCLKs in duration
Table 34: MAM Timing register (MAMTIM - address 0xE01F C004) bit description
Bit Symbol Value 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 NA
bits. The value read from a reserved bit is not defined.
For system clock slower than 20 MHz, MAMTIM can be 001. For system clock between
20 MHz and 40 MHz, Flash access time is suggested to be 2 CCLKs, while in systems
with system clock faster than 40 MHz, 3 CCLKs are proposed.
5.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
5.2 Description
The Vectored Interrupt Controller (VIC) takes 32 interrupt request inputs and
programmably assigns them into 3 categories, FIQ, vectored IRQ, and non-vectored IRQ.
The programmable assignment scheme means that priorities of interrupts from the
various peripherals can be dynamically assigned and adjusted.
Fast Interrupt reQuest (FIQ) requests have the highest priority. If more than one request is
assigned to FIQ, the VIC ORs the requests to produce the FIQ signal to the ARM
processor. The fastest possible FIQ latency is achieved when only one request is
classified as FIQ, because then the FIQ service routine can simply start dealing with that
device. But if more than one request is assigned to the FIQ class, the FIQ service routine
can read a word from the VIC that identifies which FIQ source(s) is (are) requesting an
interrupt.
Vectored IRQs have the middle priority, but only 16 of the 32 requests can be assigned to
this category. Any of the 32 requests can be assigned to any of the 16 vectored IRQ slots,
among which slot 0 has the highest priority and slot 15 has the lowest.
The VIC ORs the requests from all the vectored and non-vectored IRQs to produce the
IRQ signal to the ARM processor. The IRQ service routine can start by reading a register
from the VIC and jumping there. If any of the vectored IRQs are requesting, the VIC
provides the address of the highest-priority requesting IRQs service routine, otherwise it
provides the address of a default routine that is shared by all the non-vectored IRQs. The
default routine can read another VIC register to see what IRQs are active.
All registers in the VIC are word registers. Byte and halfword reads and write are not
supported.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
Table 36: Software Interrupt register (VICSoftInt - address 0xFFFF F018) bit allocation
Reset value: 0x0000 0000
Bit 31 30 29 28 27 26 25 24
Symbol - - - - - - - -
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 - USB AD1 BOD I2C1 AD0 EINT3 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 SPI1/SSP SPI0 I2C0 PWM0
Access R/W R/W R/W R/W R/W R/W R/W R/W
Bit 7 6 5 4 3 2 1 0
Symbol UART1 UART0 TIMER1 TIMER0 ARMCore1 ARMCore0 - WDT
Access R/W R/W R/W R/W R/W R/W R/W R/W
Table 37: Software Interrupt register (VICSoftInt - address 0xFFFF F018) bit description
Bit Symbol Value Description Reset value
31:0 See VICSoftInt 0 Do not force the interrupt request with this bit number. Writing 0
bit allocation zeroes to bits in VICSoftInt has no effect, see VICSoftIntClear
table. (Section 5.4.2).
1 Force the interrupt request with this bit number.
Table 38: Software Interrupt Clear register (VICSoftIntClear - address 0xFFFF F01C) bit allocation
Reset value: 0x0000 0000
Bit 31 30 29 28 27 26 25 24
Symbol - - - - - - - -
Access WO WO WO WO WO WO WO WO
Bit 23 22 21 20 19 18 17 16
Symbol - USB AD1 BOD I2C1 AD0 EINT3 EINT2
Access WO WO WO WO WO WO WO WO
Bit 15 14 13 12 11 10 9 8
Symbol EINT1 EINT0 RTC PLL SPI1/SSP SPI0 I2C0 PWM0
Access WO WO WO WO WO WO WO WO
Bit 7 6 5 4 3 2 1 0
Symbol UART1 UART0 TIMER1 TIMER0 ARMCore1 ARMCore0 - WDT
Access WO WO WO WO WO WO WO WO
Table 39: Software Interrupt Clear register (VICSoftIntClear - address 0xFFFF F01C) bit description
Bit Symbol Value Description Reset
value
31:0 See 0 Writing a 0 leaves the corresponding bit in VICSoftInt unchanged. 0
VICSoftIntClea 1 Writing a 1 clears the corresponding bit in the Software Interrupt
r bit allocation register, thus releasing the forcing of this request.
table.
Table 40: Raw Interrupt status register (VICRawIntr - address 0xFFFF F008) bit allocation
Reset value: 0x0000 0000
Bit 31 30 29 28 27 26 25 24
Symbol - - - - - - - -
Access RO RO RO RO RO RO RO RO
Bit 23 22 21 20 19 18 17 16
Symbol - USB AD1 BOD I2C1 AD0 EINT3 EINT2
Access RO RO RO RO RO RO RO RO
Bit 15 14 13 12 11 10 9 8
Symbol EINT1 EINT0 RTC PLL SPI1/SSP SPI0 I2C0 PWM0
Access RO RO RO RO RO RO RO RO
Bit 7 6 5 4 3 2 1 0
Symbol UART1 UART0 TIMER1 TIMER0 ARMCore1 ARMCore0 - WDT
Access RO RO RO RO RO RO RO RO
Table 41: Raw Interrupt status register (VICRawIntr - address 0xFFFF F008) bit description
Bit Symbol Value Description Reset
value
31:0 See 0 The interrupt request or software interrupt with this bit number is 0
VICRawIntr bit negated.
allocation 1 The interrupt request or software interrupt with this bit number is
table. negated.
Table 42: Interrupt Enable register (VICIntEnable - address 0xFFFF F010) bit allocation
Reset value: 0x0000 0000
Bit 31 30 29 28 27 26 25 24
Symbol - - - - - - - -
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 - USB AD1 BOD I2C1 AD0 EINT3 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 SPI1/SSP SPI0 I2C0 PWM0
Access R/W R/W R/W R/W R/W R/W R/W R/W
Bit 7 6 5 4 3 2 1 0
Symbol UART1 UART0 TIMER1 TIMER0 ARMCore1 ARMCore0 - WDT
Access R/W R/W R/W R/W R/W R/W R/W R/W
Table 43: Interrupt Enable register (VICIntEnable - address 0xFFFF F010) bit description
Bit Symbol Description Reset
value
31:0 See When this register is read, 1s indicate interrupt requests or software interrupts 0
VICIntEnable that are enabled to contribute to FIQ or IRQ.
bit allocation When this register is written, ones enable interrupt requests or software
table. interrupts to contribute to FIQ or IRQ, zeroes have no effect. See Section 5.4.5
“Interrupt Enable Clear register (VICIntEnClear - 0xFFFF F014)” on page 55
and Table 45 below for how to disable interrupts.
Table 44: Software Interrupt Clear register (VICIntEnClear - address 0xFFFF F014) bit allocation
Reset value: 0x0000 0000
Bit 31 30 29 28 27 26 25 24
Symbol - - - - - - - -
Access WO WO WO WO WO WO WO WO
Bit 23 22 21 20 19 18 17 16
Symbol - USB AD1 BOD I2C1 AD0 EINT3 EINT2
Access WO WO WO WO WO WO WO WO
Bit 15 14 13 12 11 10 9 8
Symbol EINT1 EINT0 RTC PLL SPI1/SSP SPI0 I2C0 PWM0
Access WO WO WO WO WO WO WO WO
Bit 7 6 5 4 3 2 1 0
Symbol UART1 UART0 TIMER1 TIMER0 ARMCore1 ARMCore0 - WDT
Access WO WO WO WO WO WO WO WO
Table 45: Software Interrupt Clear register (VICIntEnClear - address 0xFFFF F014) bit description
Bit Symbol Value Description Reset
value
31:0 See 0 Writing a 0 leaves the corresponding bit in VICIntEnable 0
VICIntEnClear unchanged.
bit allocation 1 Writing a 1 clears the corresponding bit in the Interrupt Enable
table. register, thus disabling interrupts for this request.
Table 46: Interrupt Select register (VICIntSelect - address 0xFFFF F00C) bit allocation
Reset value: 0x0000 0000
Bit 31 30 29 28 27 26 25 24
Symbol - - - - - - - -
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 - USB AD1 BOD I2C1 AD0 EINT3 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 SPI1/SSP SPI0 I2C0 PWM0
Access R/W R/W R/W R/W R/W R/W R/W R/W
Bit 7 6 5 4 3 2 1 0
Symbol UART1 UART0 TIMER1 TIMER0 ARMCore1 ARMCore0 - WDT
Access R/W R/W R/W R/W R/W R/W R/W R/W
Table 47: Interrupt Select register (VICIntSelect - address 0xFFFF F00C) bit description
Bit Symbol Value Description Reset
value
31:0 See 0 The interrupt request with this bit number is assigned to the IRQ 0
VICIntSelect category.
bit allocation 1 The interrupt request with this bit number is assigned to the FIQ
table. category.
Table 48: IRQ Status register (VICIRQStatus - address 0xFFFF F000) bit allocation
Reset value: 0x0000 0000
Bit 31 30 29 28 27 26 25 24
Symbol - - - - - - - -
Access RO RO RO RO RO RO RO RO
Bit 23 22 21 20 19 18 17 16
Symbol - USB AD1 BOD I2C1 AD0 EINT3 EINT2
Access RO RO RO RO RO RO RO RO
Bit 15 14 13 12 11 10 9 8
Symbol EINT1 EINT0 RTC PLL SPI1/SSP SPI0 I2C0 PWM0
Access RO RO RO RO RO RO RO RO
Bit 7 6 5 4 3 2 1 0
Symbol UART1 UART0 TIMER1 TIMER0 ARMCore1 ARMCore0 - WDT
Access RO RO RO RO RO RO RO RO
Table 49: IRQ Status register (VICIRQStatus - address 0xFFFF F000) bit description
Bit Symbol Description Reset
value
31:0 See A bit read as 1 indicates a corresponding interrupt request being enabled, 0
VICIRQStatus classified as IRQ, and asserted
bit allocation
table.
Table 50: FIQ Status register (VICFIQStatus - address 0xFFFF F004) bit allocation
Reset value: 0x0000 0000
Bit 31 30 29 28 27 26 25 24
Symbol - - - - - - - -
Access RO RO RO RO RO RO RO RO
Bit 23 22 21 20 19 18 17 16
Symbol - USB AD1 BOD I2C1 AD0 EINT3 EINT2
Access RO RO RO RO RO RO RO RO
Bit 15 14 13 12 11 10 9 8
Symbol EINT1 EINT0 RTC PLL SPI1/SSP SPI0 I2C0 PWM0
Access RO RO RO RO RO RO RO RO
Bit 7 6 5 4 3 2 1 0
Symbol UART1 UART0 TIMER1 TIMER0 ARMCore1 ARMCore0 - WDT
Access RO RO RO RO RO RO RO RO
Table 51: FIQ Status register (VICFIQStatus - address 0xFFFF F004) bit description
Bit Symbol Description Reset
value
31:0 See A bit read as 1 indicates a corresponding interrupt request being enabled, 0
VICFIQStatus classified as FIQ, and asserted
bit allocation
table.
Table 52: Vector Control registers 0-15 (VICVectCntl0-15 - 0xFFFF F200-23C) bit description
Bit Symbol Description Reset
value
4:0 int_request/ The number of the interrupt request or software interrupt assigned to this 0
sw_int_assig vectored IRQ slot. As a matter of good programming practice, software should
not assign the same interrupt number to more than one enabled vectored IRQ
slot. But if this does occur, the lower numbered slot will be used when the
interrupt request or software interrupt is enabled, classified as IRQ, and
asserted.
5 IRQslot_en When 1, this vectored IRQ slot is enabled, and can produce a unique ISR 0
address when its assigned interrupt request or software interrupt is enabled,
classified as IRQ, and asserted.
31:6 - Reserved, user software should not write ones to reserved bits. The value read NA
from a reserved bit is not defined.
Table 53: Vector Address registers (VICVectAddr0-15 - addresses 0xFFFF F100-13C) bit description
Bit Symbol Description Reset value
31:0 IRQ_vector When one or more interrupt request or software interrupt is (are) enabled, 0x0000 0000
classified as IRQ, asserted, and assigned to an enabled vectored IRQ slot,
the value from this register for the highest-priority such slot will be provided
when the IRQ service routine reads the Vector Address register -VICVectAddr
(Section 5.4.10).
Table 54: Default Vector Address register (VICDefVectAddr - address 0xFFFF F034) bit description
Bit Symbol Description 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 is
returned.
Table 55: Vector Address register (VICVectAddr - address 0xFFFF F030) bit description
Bit Symbol Description Reset value
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, reading
from this register returns the address in the Vector Address Register for the
highest-priority such slot (lowest-numbered) such slot. Otherwise it returns the
address in the Default Vector Address Register.
Writing to this register does not set the value for future reads from it. Rather,
this register should be written near the end of an ISR, to update the priority
hardware.
Table 56: Protection Enable register (VICProtection - address 0xFFFF F020) bit description
Bit Symbol Value 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.
Table 57: Connection of interrupt sources to the Vectored Interrupt Controller (VIC)
Block Flag(s) VIC Channel # and Hex
Mask
WDT Watchdog Interrupt (WDINT) 0 0x0000 0001
- Reserved for Software Interrupts only 1 0x0000 0002
ARM Core Embedded ICE, DbgCommRx 2 0x0000 0004
ARM Core Embedded ICE, DbgCommTX 3 0x0000 0008
TIMER0 Match 0 - 3 (MR0, MR1, MR2, MR3) 4 0x0000 0010
Capture 0 - 3 (CR0, CR1, CR2, CR3)
TIMER1 Match 0 - 3 (MR0, MR1, MR2, MR3) 5 0x0000 0020
Capture 0 - 3 (CR0, CR1, CR2, CR3)
UART0 Rx Line Status (RLS) 6 0x0000 0040
Transmit Holding Register Empty (THRE)
Rx Data Available (RDA)
Character Time-out Indicator (CTI)
UART1 Rx Line Status (RLS) 7 0x0000 0080
Transmit Holding Register Empty (THRE)
Rx Data Available (RDA)
Character Time-out Indicator (CTI)
Modem Status Interrupt (MSI)[1]
PWM0 Match 0 - 6 (MR0, MR1, MR2, MR3, MR4, MR5, MR6) 8 0x0000 0100
I2C0 SI (state change) 9 0x0000 0200
SPI0 SPI Interrupt Flag (SPIF) 10 0x0000 0400
Mode Fault (MODF)
SPI1 (SSP) TX FIFO at least half empty (TXRIS) 11 0x0000 0800
Rx FIFO at least half full (RXRIS)
Receive Timeout condition (RTRIS)
Receive overrun (RORRIS)
PLL PLL Lock (PLOCK) 12 0x0000 1000
RTC Counter Increment (RTCCIF) 13 0x0000 2000
Alarm (RTCALF)
System Control External Interrupt 0 (EINT0) 14 0x0000 4000
External Interrupt 1 (EINT1) 15 0x0000 8000
External Interrupt 2 (EINT2) 16 0x0001 0000
External Interrupt 3 (EINT3) 17 0x0002 0000
ADC0 A/D Converter 0 end of conversion 18 0x0004 0000
I2C1 SI (state change) 19 0x0008 0000
Table 57: Connection of interrupt sources to the Vectored Interrupt Controller (VIC)
Block Flag(s) VIC Channel # and Hex
Mask
BOD Brown Out detect 20 0x0010 0000
ADC1 A/D Converter 1 end of conversion[1] 21 0x0020 0000
USB USB interrupts, DMA interrupt[1] 22 0x0040 0000
FIQSTATUS[31:0] FIQSTATUS
SOFTINT INTENABLE
[31:0] [31:0] [31:0] nVICFIQ
VICINT
SOURCE
[31:0] Non-vectored IRQ interrupt logic
IRQSTATUS[31:0]
IRQ NonVectIRQ
IRQSTATUS
RAWINTERRUPT INTSELECT [31:0]
[31:0] [31:0]
Priority 0
Vector interrupt 0
Interrupt priority logic
VECTORCNTL[5:0] [31:0]
Priority2
Priority15
nVICIRQIN VICVECTADDRIN[31:0]
1. VIC decides there is an IRQ interrupt and sends the IRQ signal to the core.
2. Core latches the IRQ state.
3. Processing continues for a few cycles due to pipelining.
4. Core loads IRQ address from VIC.
Furthermore, It is possible that the VIC state has changed during step 3. For example, VIC
was modified so that the interrupt that triggered the sequence starting with step 1) is no
longer pending -interrupt got disabled in the executed code. In this case, the VIC will not
be able to clearly identify the interrupt that generated the interrupt request, and as a result
the VIC will return the default interrupt VicDefVectAddr (0xFFFF F034).
1. Application code should be set up in a way to prevent the spurious interrupts from
occurring. Simple guarding of changes to the VIC may not be enough since, for
example, glitches on level sensitive interrupts can also cause spurious interrupts.
2. VIC default handler should be set up and tested properly.
If an IRQ interrupt is received during execution of the MSR instruction, then the behavior
will be as follows:
• 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 the
example 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 not
normally cause a problem, since an interrupt arriving just one cycle earlier would be
expected to be taken. When the interrupt routine returns with an instruction like:
the SPSR_IRQ is restored to the CPSR. The CPSR will now have the I bit and F bit set,
and therefore execution will continue with all interrupts disabled. However, this can cause
problems in the following cases:
Problem 2: FIQs and IRQs are both disabled by the same write to the CPSR. In this case,
if an IRQ is received during the CPSR write, FIQs will be disabled for the execution time of
the IRQ handler. This may not be acceptable in a system where FIQs must not be
disabled for more than a few cycles.
5.6.2 Workaround
There are 3 suggested workarounds. Which of these is most applicable will depend upon
the requirements of the particular system.
5.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.
This code will test for the situation where the IRQ was received during a write to disable
IRQs. If this is the case, the code returns immediately - resulting in the IRQ not being
acknowledged (cleared), and further IRQs being disabled.
Similar code may also be applied to the FIQ handler, in order to resolve the first issue.
5.6.4 Solution 2: disable IRQs and FIQs using separate writes to the CPSR
MRS r0, cpsr
ORR r0, r0, #I_Bit ;disable IRQs
MSR cpsr_c, r0
ORR r0, r0, #F_Bit ;disable FIQs
MSR cpsr_c, r0
This is the best workaround where the maximum time for which FIQs are disabled is
critical (it does not increase this time at all). However, it does not solve problem one, and
requires extra instructions at every point where IRQs and FIQs are disabled together.
This requires only the IRQ handler to be modified, and FIQs may be re-enabled more
quickly than by using workaround 1. However, this should only be used if the system can
guarantee that FIQs are never disabled while IRQs are enabled. It does not address
problem one.
Although multiple sources can be selected (VICIntSelect) to generate FIQ request, only
one interrupt service routine should be dedicated to service all available/present FIQ
request(s). Therefore, if more than one interrupt sources are classified as FIQ the FIQ
interrupt service routine must read VICFIQStatus to decide based on this content what to
do and how to process the interrupt request. However, it is recommended that only one
interrupt source should be classified as FIQ. Classifying more than one interrupt sources
as FIQ will increase the interrupt latency.
Following the completion of the desired interrupt service routine, clearing of the interrupt
flag on the peripheral level will propagate to corresponding bits in VIC registers
(VICRawIntr, VICFIQStatus and VICIRQStatus). Also, before the next interrupt can be
serviced, it is necessary that write is performed into the VICVectAddr register before the
return from interrupt is executed. This write will clear the respective interrupt flag in the
internal interrupt priority hardware.
In order to disable the interrupt at the VIC you need to clear corresponding bit in the
VICIntEnClr register, which in turn clears the related bit in the VICIntEnable register. This
also applies to the VICSoftInt and VICSoftIntClear in which VICSoftIntClear will clear the
respective bits in VICSoftInt. For example, if VICSoftInt = 0x0000 0005 and bit 0 has to be
cleared, VICSoftIntClear = 0x0000 0001 will accomplish this. Before the new clear
operation on the same bit in VICSoftInt using writing into VICSoftIntClear is performed in
the future, VICSoftIntClear = 0x0000 0000 must be assigned. Therefore writing 1 to any
bit in Clear register will have one-time-effect in the destination register.
If the watchdog is enabled for interrupt on underflow or invalid feed sequence only then
there is no way of clearing the interrupt. The only way you could perform return from
interrupt is by disabling the interrupt at the VIC (using VICIntEnClr).
Example:
Assuming that UART0 and SPI0 are generating interrupt requests that are classified as
vectored IRQs (UART0 being on the higher level than SPI0), while UART1 and I2C are
generating non-vectored IRQs, the following could be one possibility for VIC setup:
VICIntSelect = 0x0000 0000 ; SPI0, I2C, UART1 and UART0 are IRQ =>
; bit10, bit9, bit7 and bit6=0
VICIntEnable = 0x0000 06C0 ; SPI0, I2C, UART1 and UART0 are enabled interrupts =>
; bit10, bit9, bit 7 and bit6=1
VICDefVectAddr = 0x... ; holds address at what routine for servicing
; non-vectored IRQs (i.e. UART1 and I2C) starts
VICVectAddr0 = 0x... ; holds address where UART0 IRQ service routine starts
VICVectAddr1 = 0x... ; holds address where SPI0 IRQ service routine starts
VICVectCntl0 = 0x0000 0026 ; interrupt source with index 6 (UART0) is enabled as
; the one with priority 0 (the highest)
VICVectCntl1 = 0x0000 002A ; interrupt source with index 10 (SPI0) is enabled
; as the one with priority 1
After any of IRQ requests (SPI0, I2C, UART0 or UART1) is made, microcontroller will
redirect code execution to the address specified at location 0x0000 0018. For vectored
and non-vectored IRQ’s the following instruction could be placed at 0x0000 0018:
This instruction loads PC with the address that is present in VICVectAddr register.
In case UART0 request has been made, VICVectAddr will be identical to VICVectAddr0,
while in case SPI0 request has been made value from VICVectAddr1 will be found here. If
neither UART0 nor SPI0 have generated IRQ request but UART1 and/or I2C were the
reason, content of VICVectAddr will be identical to VICDefVectAddr.
54 P0.19/MAT1.2/MOSI1/CAP1.2
53 P0.18/CAP1.3/MISO1/MAT1.3
55 P0.20/MAT1.3/SSEL1/EINT3
58 P0.23/VBUS
64 P1.27/TDO
52 P1.30/TMS
56 P1.29/TCK
60 P1.28/TDI
57 RESET
62 XTAL1
61 XTAL2
63 VREF
59 VSSA
49 VBAT
51 VDD
50 VSS
P0.21/PWM5/CAP1.3 1 48 P1.20/TRACESYNC
P0.22/CAP0.0/MAT0.0 2 47 P0.17/CAP1.2/SCK1/MAT1.2
RTXC1 3 46 P0.16/EINT0/MAT0.2/CAP0.2
P1.19/TRACEPKT3 4 45 P0.15/EINT2
RTXC2 5 44 P1.21/PIPESTAT0
VSS 6 43 VDD
VDDA 7 42 VSS
P1.18/TRACEPKT2 8 41 P0.14/EINT1/SDA1
LPC2141
P0.25/AD0.4 9 40 P1.22/PIPESTAT1
D+ 10 39 P0.13/MAT1.1
D− 11 38 P0.12/MAT1.0
P1.17/TRACEPKT1 12 37 P0.11/CAP1.1/SCL1
P0.28/AD0.1/CAP0.2/MAT0.2 13 36 P1.23/PIPESTAT2
P0.29/AD0.2/CAP0.3/MAT0.3 14 35 P0.10/CAP1.0
P0.30/AD0.3/EINT3/CAP0.0 15 34 P0.9/RXD1/PWM6/EINT3
P1.16/TRACEPKT0 16 33 P0.8/TXD1/PWM4
P0.31/UP_LED/CONNECT 17
VSS 18
P0.0/TXD0/PWM1 19
P1.31/TRST 20
P0.1/RXD0/PWM3/EINT0 21
P0.2/SCL0/CAP0.0 22
VDD 23
P1.26/RTCK 24
VSS 25
P0.3/SDA0/MAT0.0/EINT1 26
P0.4/SCK0/CAP0.1/AD0.6 27
P1.25/EXTIN0 28
P0.5/MISO0/MAT0.1/AD0.7 29
P0.6/MOSI0/CAP0.2 30
P0.7/SSEL0/PWM2/EINT2 31
P1.24/TRACECLK 32
002aab733
54 P0.19/MAT1.2/MOSI1/CAP1.2
53 P0.18/CAP1.3/MISO1/MAT1.3
55 P0.20/MAT1.3/SSEL1/EINT3
58 P0.23/VBUS
64 P1.27/TDO
52 P1.30/TMS
56 P1.29/TCK
60 P1.28/TDI
57 RESET
62 XTAL1
61 XTAL2
63 VREF
59 VSSA
49 VBAT
51 VDD
50 VSS
P0.21/PWM5/CAP1.3 1 48 P1.20/TRACESYNC
P0.22/CAP0.0/MAT0.0 2 47 P0.17/CAP1.2/SCK1/MAT1.2
RTXC1 3 46 P0.16/EINT0/MAT0.2/CAP0.2
P1.19/TRACEPKT3 4 45 P0.15/EINT2
RTXC2 5 44 P1.21/PIPESTAT0
VSS 6 43 VDD
VDDA 7 42 VSS
P1.18/TRACEPKT2 8 41 P0.14/EINT1/SDA1
LPC2142
P0.25/AD0.4/AOUT 9 40 P1.22/PIPESTAT1
D+ 10 39 P0.13/MAT1.1
D− 11 38 P0.12/MAT1.0
P1.17/TRACEPKT1 12 37 P0.11/CAP1.1/SCL1
P0.28/AD0.1/CAP0.2/MAT0.2 13 36 P1.23/PIPESTAT2
P0.29/AD0.2/CAP0.3/MAT0.3 14 35 P0.10/CAP1.0
P0.30/AD0.3/EINT3/CAP0.0 15 34 P0.9/RXD1/PWM6/EINT3
P1.16/TRACEPKT0 16 33 P0.8/TXD1/PWM4
P0.31/UP_LED/CONNECT 17
VSS 18
P0.0/TXD0/PWM1 19
P1.31/TRST 20
P0.1/RXD0/PWM3/EINT0 21
P0.2/SCL0/CAP0.0 22
VDD 23
P1.26/RTCK 24
VSS 25
P0.3/SDA0/MAT0.0/EINT1 26
P0.4/SCK0/CAP0.1/AD0.6 27
P1.25/EXTIN0 28
P0.5/MISO0/MAT0.1/AD0.7 29
P0.6/MOSI0/CAP0.2 30
P0.7/SSEL0/PWM2/EINT2 31
P1.24/TRACECLK 32
002aab734
54 P0.19/MAT1.2/MOSI1/CAP1.2
53 P0.18/CAP1.3/MISO1/MAT1.3
55 P0.20/MAT1.3/SSEL1/EINT3
58 P0.23/VBUS
64 P1.27/TDO
52 P1.30/TMS
56 P1.29/TCK
60 P1.28/TDI
57 RESET
62 XTAL1
61 XTAL2
63 VREF
59 VSSA
49 VBAT
51 VDD
50 VSS
P0.21/PWM5/AD1.6/CAP1.3 1 48 P1.20/TRACESYNC
P0.22/AD1.7/CAP0.0/MAT0.0 2 47 P0.17/CAP1.2/SCK1/MAT1.2
RTXC1 3 46 P0.16/EINT0/MAT0.2/CAP0.2
P1.19/TRACEPKT3 4 45 P0.15/RI1/EINT2/AD1.5
RTXC2 5 44 P1.21/PIPESTAT0
VSS 6 43 VDD
VDDA 7 42 VSS
P1.18/TRACEPKT2 8 41 P0.14/DCD1/EINT1/SDA1
LPC2144/2146/2148
P0.25/AD0.4/AOUT 9 40 P1.22/PIPESTAT1
D+ 10 39 P0.13/DTR1/MAT1.1/AD1.4
D− 11 38 P0.12/DSR1/MAT1.0/AD1.3
P1.17/TRACEPKT1 12 37 P0.11/CTS1/CAP1.1/SCL1
P0.28/AD0.1/CAP0.2/MAT0.2 13 36 P1.23/PIPESTAT2
P0.29/AD0.2/CAP0.3/MAT0.3 14 35 P0.10/RTS1/CAP1.0/AD1.2
P0.30/AD0.3/EINT3/CAP0.0 15 34 P0.9/RXD1/PWM6/EINT3
P1.16/TRACEPKT0 16 33 P0.8/TXD1/PWM4/AD1.1
P0.31/UP_LED/CONNECT 17
VSS 18
P0.0/TXD0/PWM1 19
P1.31/TRST 20
P0.1/RXD0/PWM3/EINT0 21
P0.2/SCL0/CAP0.0 22
VDD 23
P1.26/RTCK 24
VSS 25
P0.3/SDA0/MAT0.0/EINT1 26
P0.4/SCK0/CAP0.1/AD0.6 27
P1.25/EXTIN0 28
P0.5/MISO0/MAT0.1/AD0.7 29
P0.6/MOSI0/CAP0.2/AD1.0 30
P0.7/SSEL0/PWM2/EINT2 31
P1.24/TRACECLK 32
002aab735
[1] 5 V tolerant pad providing digital I/O functions with TTL levels and hysteresis and 10 ns slew rate control.
[2] 5 V tolerant pad providing digital I/O functions with TTL levels and hysteresis and 10 ns slew rate control. If
configured for an input function, this pad utilizes built-in glitch filter that blocks pulses shorter than 3 ns.
[3] Open-drain 5 V tolerant digital I/O I2C-bus 400 kHz specification compatible pad. It requires external pull-up
to provide an output functionality.
[4] 5 V tolerant pad providing digital I/O (with TTL levels and hysteresis and 10 ns slew rate control) and analog
input function. If configured for 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.
[5] 5 V tolerant pad providing digital I/O (with TTL levels and hysteresis and 10 ns slew rate control) and analog
output function. When configured as the DAC output, digital section of the pad is disabled.
[6] 5 V tolerant pad with built-in pull-up resistor providing digital I/O functions with TTL levels and hysteresis
and 10 ns slew rate control. The pull-up resistor’s value typically ranges from 60 kΩ to 300 kΩ.
[7] Pad is designed in accordance with the Universal Serial Bus (USB) specification, revision 2.0 (Full-speed
and Low-speed mode only).
[8] 5 V tolerant pad providing digital input (with TTL levels and hysteresis) function only.
[9] Pad provides special analog functionality.
7.1 Features
• Allows individual pin configuration.
7.2 Applications
The purpose of the Pin Connect Block is to configure the microcontroller pins to the
desired functions.
7.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 the
pin and the on chip peripherals.
Peripherals should be connected to the appropriate pins prior to being activated, and prior
to any related interrupt(s) being enabled. Activity of any enabled peripheral function that is
not mapped to a related pin should be considered undefined.
Selection of a single function on a port pin completely excludes all other functions
otherwise available on the same pin.
The only partial exception from the above rule of exclusion is the case of inputs to the A/D
converter. Regardless of the function that is selected for the port pin that also hosts the
A/D input, this A/D input can be read at any time and variations of the voltage level on this
pin will be reflected in the A/D readings. However, valid analog reading(s) can be obtained
if and only if the function of an analog input is selected. Only in this case proper interface
circuit is active in 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, and will
disrupt proper behavior of the A/D.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
Table 60: Pin function Select register 0 (PINSEL0 - address 0xE002 C000) bit description
Bit Symbol Value Function Reset value
1:0 P0.0 00 GPIO Port 0.0 0
01 TXD (UART0)
10 PWM1
11 Reserved
3:2 P0.1 00 GPIO Port 0.1 0
01 RxD (UART0)
10 PWM3
11 EINT0
5:4 P0.2 00 GPIO Port 0.2 0
01 SCL0 (I2C0)
10 Capture 0.0 (Timer 0)
11 Reserved
7:6 P0.3 00 GPIO Port 0.3 0
01 SDA0 (I2C0)
10 Match 0.0 (Timer 0)
11 EINT1
9:8 P0.4 00 GPIO Port 0.4 0
01 SCK0 (SPI0)
10 Capture 0.1 (Timer 0)
11 AD0.6
11:10 P0.5 00 GPIO Port 0.5 0
01 MISO0 (SPI0)
10 Match 0.1 (Timer 0)
11 AD0.7
13:12 P0.6 00 GPIO Port 0.6 0
01 MOSI0 (SPI0)
10 Capture 0.2 (Timer 0)
11 Reserved[1][2] or AD1.0[3]
15:14 P0.7 00 GPIO Port 0.7 0
01 SSEL0 (SPI0)
10 PWM2
11 EINT2
17:16 P0.8 00 GPIO Port 0.8 0
01 TXD UART1
10 PWM4
11 Reserved[1][2] or AD1.1[3]
Table 60: Pin function Select register 0 (PINSEL0 - address 0xE002 C000) bit description
Bit Symbol Value Function Reset value
19:18 P0.9 00 GPIO Port 0.9 0
01 RxD (UART1)
10 PWM6
11 EINT3
21:20 P0.10 00 GPIO Port 0.10 0
01 Reserved[1][2] or RTS (UART1)[3]
10 Capture 1.0 (Timer 1)
11 Reserved[1][2] or AD1.2[3]
23:22 P0.11 00 GPIO Port 0.11 0
01 Reserved[1][2] or CTS (UART1)[3]
10 Capture 1.1 (Timer 1)
11 SCL1 (I2C1)
25:24 P0.12 00 GPIO Port 0.12 0
01 Reserved[1][2] or DSR (UART1)[3]
10 Match 1.0 (Timer 1)
11 Reserved[1][2] or AD1.3[3]
27:26 P0.13 00 GPIO Port 0.13 0
01 Reserved[1][2] or DTR (UART1)[3]
10 Match 1.1 (Timer 1)
11 Reserved[1][2] or AD1.4[3]
29:28 P0.14 00 GPIO Port 0.14 0
01 Reserved[1][2] or DCD (UART1)[3]
10 EINT1
11 SDA1 (I2C1)
31:30 P0.15 00 GPIO Port 0.15 0
01 Reserved[1][2] or RI (UART1)[3]
10 EINT2
11 Reserved[1][2] or AD1.5[3]
Table 61: Pin function Select register 1 (PINSEL1 - address 0xE002 C004) bit description
Bit Symbol Value Function Reset value
1:0 P0.16 00 GPIO Port 0.16 0
01 EINT0
10 Match 0.2 (Timer 0)
11 Capture 0.2 (Timer 0)
3:2 P0.17 00 GPIO Port 0.17 0
01 Capture 1.2 (Timer 1)
10 SCK1 (SSP)
11 Match 1.2 (Timer 1)
5:4 P0.18 00 GPIO Port 0.18 0
01 Capture 1.3 (Timer 1)
10 MISO1 (SSP)
11 Match 1.3 (Timer 1)
7:6 P0.19 00 GPIO Port 0.19 0
01 Match 1.2 (Timer 1)
10 MOSI1 (SSP)
11 Capture 1.2 (Timer 1)
9:8 P0.20 00 GPIO Port 0.20 0
01 Match 1.3 (Timer 1)
10 SSEL1 (SSP)
11 EINT3
11:10 P0.21 00 GPIO Port 0.21 0
01 PWM5
10 Reserved[1][2] or AD1.6[3]
11 Capture 1.3 (Timer 1)
13:12 P0.22 00 GPIO Port 0.22 0
01 Reserved[1][2] or AD1.7[3]
10 Capture 0.0 (Timer 0)
11 Match 0.0 (Timer 0)
15:14 P0.23 00 GPIO Port 0.23 0
01 VBUS
10 Reserved
11 Reserved
17:16 P0.24 00 Reserved 0
01 Reserved
10 Reserved
11 Reserved
19:18 P0.25 00 GPIO Port 0.25 0
01 AD0.4
10 Reserved[1] or Aout(DAC)[2][3]
11 Reserved
Table 61: Pin function Select register 1 (PINSEL1 - address 0xE002 C004) bit description
Bit Symbol Value Function Reset value
21:20 P0.26 00 Reserved 0
01 Reserved
10 Reserved
11 Reserved
23:22 P0.27 00 Reserved 0
01 Reserved
10 Reserved
11 Reserved
25:24 P0.28 00 GPIO Port 0.28 0
01 AD0.1
10 Capture 0.2 (Timer 0)
11 Match 0.2 (Timer 0)
27:26 P0.29 00 GPIO Port 0.29 0
01 AD0.2
10 Capture 0.3 (Timer 0)
11 Match 0.3 (Timer 0)
29:28 P0.30 00 GPIO Port 0.30 0
01 AD0.3
10 EINT3
11 Capture 0.0 (Timer 0)
31:30 P0.31 00 GPO Port only 0
01 UP_LED
10 CONNECT
11 Reserved
Table 62: Pin function Select register 2 (PINSEL2 - 0xE002 C014) bit description
Bit Symbol Value Function Reset value
1:0 - - Reserved, user software should not write ones NA
to reserved bits. The value read from a reserved
bit is not defined.
2 GPIO/DEBUG 0 Pins P1.36-26 are used as GPIO pins. P1.26/RTCK
1 Pins P1.36-26 are used as a Debug port.
3 GPIO/TRACE 0 Pins P1.25-16 are used as GPIO pins. P1.20/
TRACESYNC
1 Pins P1.25-16 are used as a Trace port.
31:4 - - Reserved, user software should not write ones NA
to reserved bits. The value read from a reserved
bit is not defined.
The direction control bit in the IO0DIR/IO1DIR register is effective only when the GPIO
function is selected for a pin. For other functions, direction is controlled automatically.
Each derivative typically has a different pinout and therefore a different set of functions
possible for each pin. Details for a specific derivative may be found in the appropriate data
sheet.
8.1 Features
• Every physical GPIO port is accessible via either the group of registers providing an
enhanced features and accelerated port access or the legacy group of registers
• Accelerated GPIO functions:
– GPIO registers are relocated to the ARM local bus so that the fastest possible I/O
timing can be achieved
– Mask registers allow treating sets of port bits as a group, leaving other bits
unchanged
– All registers are byte 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 of
bits in one port
• Direction control of individual bits
• All I/O default to inputs after reset
• Backward compatibility with other earlier devices is maintained with legacy registers
appearing at the original addresses on the VPB bus
8.2 Applications
• General purpose I/O
• Driving LEDs, or other indicators
• Controlling off-chip devices
• Sensing digital inputs
Legacy registers shown in Table 65 allow backward compatibility with earlier family
devices, using existing code. The functions and relative timing of older GPIO
implementations is preserved.
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
The registers in Table 66 represent the enhanced GPIO features available on the
LPC2141/2/4/6/8. All of these registers are located directly on the local bus of the CPU for
the fastest possible read and write timing. An additional feature has been added that
provides byte addressability of all GPIO registers. A mask register allows treating groups
of bits in a single GPIO port separately from other bits on the same port.
User must select whether a GPIO will be accessed via registers that provide enhanced
features or a legacy set of registers (see Section 3.6.1 “System Control and Status flags
register (SCS - 0xE01F C1A0)” on page 26). While both of a port’s fast and legacy GPIO
registers are controlling the same physical pins, these two port control branches are
mutually exclusive and operate independently. For example, changing a pin’s output 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 equipped
with the enhanced features will be referred as "the fast" GPIO.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
Table 66: GPIO register map (local bus accessible registers - enhanced GPIO features)
Generic Description Access Reset PORT0 PORT1
Name value[1] Address & Name Address & Name
FIODIR Fast GPIO Port Direction control register. R/W 0x0000 0000 0x3FFF C000 0x3FFF C020
This register individually controls the FIO0DIR FIO1DIR
direction of each port pin.
FIOMASK Fast Mask register for port. Writes, sets, R/W 0x0000 0000 0x3FFF C010 0x3FFF C030
clears, and reads to port (done via writes to FIO0MASK FIO1MASK
FIOPIN, FIOSET, and FIOCLR, and reads of
FIOPIN) alter or return only the bits enabled
by zeros in this register.
FIOPIN Fast Port Pin value register using FIOMASK. R/W 0x0000 0000 0x3FFF C014 0x3FFF C034
The current state of digital port pins can be FIO0PIN FIO1PIN
read from this register, regardless of pin
direction or alternate function selection (as
long as pins is not configured as an input to
ADC). The value read is masked by ANDing
with FIOMASK. Writing to this register
places corresponding values in all bits
enabled by ones in FIOMASK.
FIOSET Fast Port Output Set register using R/W 0x0000 0000 0x3FFF C018 0x3FFF C038
FIOMASK. This register controls the state of FIO0SET FIO1SET
output pins. Writing 1s produces highs at the
corresponding port pins. Writing 0s has no
effect. Reading this register returns the
current contents of the port output register.
Only bits enabled by ones in FIOMASK can
be altered.
FIOCLR Fast Port Output Clear register using WO 0x0000 0000 0x3FFF C01C 0x3FFF C03C
FIOMASK0. This register controls the state FIO0CLR FIO1CLR
of output pins. Writing 1s produces lows at
the corresponding port pins. Writing 0s has
no effect. Only bits enabled by ones in
FIOMASK0 can be altered.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
8.4.1 GPIO port Direction register (IODIR, Port 0: IO0DIR - 0xE002 8008 and
Port 1: IO1DIR - 0xE002 8018; FIODIR, Port 0: FIO0DIR - 0x3FFF C000
and Port 1:FIO1DIR - 0x3FFF C020)
This word accessible register is used to control the direction of the pins when they are
configured as GPIO port pins. Direction bit for any pin must be set according to the pin
functionality.
Legacy registers are the IO0DIR and IO1DIR, while the enhanced GPIO functions are
supported via the FIO0DIR and FIO1DIR registers.
Table 67: GPIO port 0 Direction register (IO0DIR - address 0xE002 8008) bit description
Bit Symbol Value Description Reset value
31:0 P0xDIR Slow GPIO Direction control bits. Bit 0 controls P0.0 ... bit 30 controls P0.30. 0x0000 0000
0 Controlled pin is input.
1 Controlled pin is output.
Table 68: GPIO port 1 Direction register (IO1DIR - address 0xE002 8018) bit description
Bit Symbol Value Description Reset value
31:0 P1xDIR Slow GPIO Direction control bits. Bit 0 in IO1DIR controls P1.0 ... Bit 30 in 0x0000 0000
IO1DIR controls P1.30.
0 Controlled pin is input.
1 Controlled pin is output.
Table 69: Fast GPIO port 0 Direction register (FIO0DIR - address 0x3FFF C000) bit description
Bit Symbol Value Description Reset value
31:0 FP0xDIR Fast GPIO Direction control bits. Bit 0 in FIO0DIR controls P0.0 ... Bit 30 in 0x0000 0000
FIO0DIR controls P0.30.
0 Controlled pin is input.
1 Controlled pin is output.
Table 70: Fast GPIO port 1 Direction register (FIO1DIR - address 0x3FFF C020) bit description
Bit Symbol Value Description Reset value
31:0 FP1xDIR Fast GPIO Direction control bits. Bit 0 in FIO1DIR controls P1.0 ... Bit 30 in 0x0000 0000
FIO1DIR controls P1.30.
0 Controlled pin is input.
1 Controlled pin is output.
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 in
Table 71 and Table 72, too. Next to providing the same functions as the FIODIR register,
these additional registers allow easier and faster access to the physical port pins.
Table 71: Fast GPIO port 0 Direction control byte and half-word accessible register description
Register Register Address Description Reset
name length (bits) value
& access
FIO0DIR0 8 (byte) 0x3FFF C000 Fast GPIO Port 0 Direction control register 0. Bit 0 in FIO0DIR0 0x00
register corresponds to P0.0 ... bit 7 to P0.7.
FIO0DIR1 8 (byte) 0x3FFF C001 Fast GPIO Port 0 Direction control register 1. Bit 0 in FIO0DIR1 0x00
register corresponds to P0.8 ... bit 7 to P0.15.
FIO0DIR2 8 (byte) 0x3FFF C002 Fast GPIO Port 0 Direction control register 2. Bit 0 in FIO0DIR2 0x00
register corresponds to P0.16 ... bit 7 to P0.23.
FIO0DIR3 8 (byte) 0x3FFF C003 Fast GPIO Port 0 Direction control register 3. Bit 0 in FIO0DIR3 0x00
register corresponds to P0.24 ... bit 7 to P0.31.
FIO0DIRL 16 0x3FFF C000 Fast GPIO Port 0 Direction control Lower half-word register. Bit 0 in 0x0000
(half-word) FIO0DIRL register corresponds to P0.0 ... bit 15 to P0.15.
FIO0DIRU 16 0x3FFF C002 Fast GPIO Port 0 Direction control Upper half-word register. Bit 0 in 0x0000
(half-word) FIO0DIRU register corresponds to P0.16 ... bit 15 to P0.31.
Table 72: Fast GPIO port 1 Direction control byte and half-word accessible register description
Register Register Address Description Reset
name length (bits) value
& access
FIO1DIR0 8 (byte) 0x3FFF C020 Fast GPIO Port 1 Direction control register 0. Bit 0 in FIO1DIR0 0x00
register corresponds to P1.0 ... bit 7 to P1.7.
FIO1DIR1 8 (byte) 0x3FFF C021 Fast GPIO Port 1 Direction control register 1. Bit 0 in FIO1DIR1 0x00
register corresponds to P1.8 ... bit 7 to P1.15.
FIO1DIR2 8 (byte) 0x3FFF C022 Fast GPIO Port 1 Direction control register 2. Bit 0 in FIO1DIR2 0x00
register corresponds to P1.16 ... bit 7 to P1.23.
FIO1DIR3 8 (byte) 0x3FFF C023 Fast GPIO Port 1 Direction control register 3. Bit 0 in FIO1DIR3 0x00
register corresponds to P1.24 ... bit 7 to P1.31.
FIO1DIRL 16 0x3FFF C020 Fast GPIO Port 1 Direction control Lower half-word register. Bit 0 in 0x0000
(half-word) FIO1DIRL register corresponds to P1.0 ... bit 15 to P1.15.
FIO1DIRU 16 0x3FFF C022 Fast GPIO Port 1 Direction control Upper half-word register. Bit 0 in 0x0000
(half-word) FIO1DIRU register corresponds to P1.16 ... bit 15 to P1.31.
A zero in this register’s bit enables an access to the corresponding physical pin via a read
or write access. If a bit in this register is one, 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 92
Table 73: Fast GPIO port 0 Mask register (FIO0MASK - address 0x3FFF C010) bit description
Bit Symbol Value Description Reset value
31:0 FP0xMASK Fast GPIO physical pin access control. 0x0000 0000
0 Pin is affected by writes to the FIOSET, FIOCLR, and FIOPIN registers.
Current state of the pin will be observable in the FIOPIN register.
1 Physical pin is unaffected by writes into the FIOSET, FIOCLR and FIOPIN
registers. When the FIOPIN register is read, this bit will not be updated with
the state of the physical pin.
Table 74: Fast GPIO port 1 Mask register (FIO1MASK - address 0x3FFF C030) bit description
Bit Symbol Value Description Reset value
31:0 FP1xMASK Fast GPIO physical pin access control. 0x0000 0000
0 Pin is affected by writes to the FIOSET, FIOCLR, and FIOPIN registers.
Current state of the pin will be observable in the FIOPIN register.
1 Physical pin is unaffected by writes into the FIOSET, FIOCLR and FIOPIN
registers. When the FIOPIN register is read, this bit will not be updated with
the state of the physical pin.
Aside from the 32-bit long and word only accessible FIOMASK register, every fast GPIO
port can also be controlled via several byte and half-word accessible registers listed in
Table 75 and Table 76, too. Next to providing the same functions as the FIOMASK
register, these additional registers allow easier and faster access to the physical port pins.
Table 75: Fast GPIO port 0 Mask byte and half-word accessible register description
Register Register Address Description Reset
name length (bits) value
& access
FIO0MASK0 8 (byte) 0x3FFF C010 Fast GPIO Port 0 Mask register 0. Bit 0 in FIO0MASK0 register 0x00
corresponds to P0.0 ... bit 7 to P0.7.
FIO0MASK1 8 (byte) 0x3FFF C011 Fast GPIO Port 0 Mask register 1. Bit 0 in FIO0MASK1 register 0x00
corresponds to P0.8 ... bit 7 to P0.15.
FIO0MASK2 8 (byte) 0x3FFF C012 Fast GPIO Port 0 Mask register 2. Bit 0 in FIO0MASK2 register 0x00
corresponds to P0.16 ... bit 7 to P0.23.
FIO0MASK3 8 (byte) 0x3FFF C013 Fast GPIO Port 0 Mask register 3. Bit 0 in FIO0MASK3 register 0x00
corresponds to P0.24 ... bit 7 to P0.31.
FIO0MASKL 16 0x3FFF C001 Fast GPIO Port 0 Mask Lower half-word register. Bit 0 in 0x0000
(half-word) FIO0MASKL register corresponds to P0.0 ... bit 15 to P0.15.
FIO0MASKU 16 0x3FFF C012 Fast GPIO Port 0 Mask Upper half-word register. Bit 0 in 0x0000
(half-word) FIO0MASKU register corresponds to P0.16 ... bit 15 to P0.31.
Table 76: Fast GPIO port 1 Mask byte and half-word accessible register description
Register Register Address Description Reset
name length (bits) value
& access
FIO1MASK0 8 (byte) 0x3FFF C010 Fast GPIO Port 1 Mask register 0. Bit 0 in FIO1MASK0 register 0x00
corresponds to P1.0 ... bit 7 to P1.7.
FIO1MASK1 8 (byte) 0x3FFF C011 Fast GPIO Port 1 Mask register 1. Bit 0 in FIO1MASK1 register 0x00
corresponds to P1.8 ... bit 7 to P1.15.
FIO1MASK2 8 (byte) 0x3FFF C012 Fast GPIO Port 1 Mask register 2. Bit 0 in FIO1MASK2 register 0x00
corresponds to P1.16 ... bit 7 to P1.23.
FIO1MASK3 8 (byte) 0x3FFF C013 Fast GPIO Port 1 Mask register 3. Bit 0 in FIO1MASK3 register 0x00
corresponds to P1.24 ... bit 7 to P1.31.
FIO1MASKL 16 0x3FFF C001 Fast GPIO Port 1 Mask Lower half-word register. Bit 0 in 0x0000
(half-word) FIO1MASKL register corresponds to P1.0 ... bit 15 to P1.15.
FIO1MASKU 16 0x3FFF C012 Fast GPIO Port 1 Mask Upper half-word register. Bit 0 in 0x0000
(half-word) FIO1MASKU register corresponds to P1.16 ... bit 15 to P1.31.
8.4.3 GPIO port Pin value register (IOPIN, Port 0: IO0PIN - 0xE002 8000 and
Port 1: IO1PIN - 0xE002 8010; FIOPIN, Port 0: FIO0PIN - 0x3FFF C014
and Port 1: FIO1PIN - 0x3FFF C034)
This register provides the value of port pins that are configured to perform only digital
functions. The register will give the logic value of the pin regardless of whether the pin is
configured for input or output, or as GPIO or an alternate digital function. As an example,
a particular port pin may have GPIO input, GPIO output, UART receive, and PWM output
as selectable functions. Any configuration of that pin will allow its current logic state to be
read from the IOPIN register.
If a pin has an analog function as one of its options, the pin state cannot be read if the
analog configuration is selected. Selecting the pin as an A/D input disconnects the digital
features of the pin. In that case, the pin value read in the IOPIN register is not valid.
Writing to the IOPIN register stores the value in the port output register, bypassing the
need to use both the IOSET and IOCLR registers to obtain the entire written value. This
feature should be used carefully in an application since it affects the entire port.
Legacy registers are the IO0PIN and IO1PIN, while the enhanced GPIOs are supported
via the FIO0PIN and FIO1PIN registers. Access to a port pins via the FIOPIN register is
conditioned by the corresponding FIOMASK register (see Section 8.4.2 “Fast GPIO port
Mask register (FIOMASK, Port 0: FIO0MASK - 0x3FFF C010 and Port 1:FIO1MASK -
0x3FFF C030)”).
Only pins masked with zeros in the Mask register (see Section 8.4.2 “Fast GPIO port
Mask register (FIOMASK, Port 0: FIO0MASK - 0x3FFF C010 and Port 1:FIO1MASK -
0x3FFF C030)”) will be correlated to the current content of the Fast GPIO port pin value
register.
Table 77: GPIO port 0 Pin value register (IO0PIN - address 0xE002 8000) bit description
Bit Symbol Description Reset value
31:0 P0xVAL Slow GPIO pin value bits. Bit 0 in IO0PIN corresponds to P0.0 ... Bit 31 in IO0PIN NA
corresponds to P0.31.
Table 78: GPIO port 1 Pin value register (IO1PIN - address 0xE002 8010) bit description
Bit Symbol Description Reset value
31:0 P1xVAL Slow GPIO pin value bits. Bit 0 in IO1PIN corresponds to P1.0 ... Bit 31 in IO1PIN NA
corresponds to P1.31.
Table 79: Fast GPIO port 0 Pin value register (FIO0PIN - address 0x3FFF C014) bit description
Bit Symbol Description Reset value
31:0 FP0xVAL Fast GPIO pin value bits. Bit 0 in FIO0PIN corresponds to P0.0 ... Bit 31 in FIO0PIN NA
corresponds to P0.31.
Table 80: Fast GPIO port 1 Pin value register (FIO1PIN - address 0x3FFF C034) bit description
Bit Symbol Description Reset value
31:0 FP1xVAL Fast GPIO pin value bits. Bit 0 in FIO1PIN corresponds to P1.0 ... Bit 31 in FIO1PIN NA
corresponds to P1.31.
Aside from the 32-bit long and word only accessible FIOPIN register, every fast GPIO port
can also be controlled via several byte and half-word accessible registers listed in
Table 81 and Table 82, too. Next to providing the same functions as the FIOPIN register,
these additional registers allow easier and faster access to the physical port pins.
Table 81: Fast GPIO port 0 Pin value byte and half-word accessible register description
Register Register Address Description Reset
name length (bits) value
& access
FIO0PIN0 8 (byte) 0x3FFF C014 Fast GPIO Port 0 Pin value register 0. Bit 0 in FIO0PIN0 register 0x00
corresponds to P0.0 ... bit 7 to P0.7.
FIO0PIN1 8 (byte) 0x3FFF C015 Fast GPIO Port 0 Pin value register 1. Bit 0 in FIO0PIN1 register 0x00
corresponds to P0.8 ... bit 7 to P0.15.
FIO0PIN2 8 (byte) 0x3FFF C016 Fast GPIO Port 0 Pin value register 2. Bit 0 in FIO0PIN2 register 0x00
corresponds to P0.16 ... bit 7 to P0.23.
FIO0PIN3 8 (byte) 0x3FFF C017 Fast GPIO Port 0 Pin value register 3. Bit 0 in FIO0PIN3 register 0x00
corresponds to P0.24 ... bit 7 to P0.31.
FIO0PINL 16 0x3FFF C014 Fast GPIO Port 0 Pin value Lower half-word register. Bit 0 in 0x0000
(half-word) FIO0PINL register corresponds to P0.0 ... bit 15 to P0.15.
FIO0PINU 16 0x3FFF C016 Fast GPIO Port 0 Pin value Upper half-word register. Bit 0 in 0x0000
(half-word) FIO0PINU register corresponds to P0.16 ... bit 15 to P0.31.
Table 82: Fast GPIO port 1 Pin value byte and half-word accessible register description
Register Register Address Description Reset
name length (bits) value
& access
FIO1PIN0 8 (byte) 0x3FFF C034 Fast GPIO Port 1 Pin value register 0. Bit 0 in FIO1PIN0 register 0x00
corresponds to P1.0 ... bit 7 to P1.7.
FIO1PIN1 8 (byte) 0x3FFF C035 Fast GPIO Port 1 Pin value register 1. Bit 0 in FIO1PIN1 register 0x00
corresponds to P1.8 ... bit 7 to P1.15.
FIO1PIN2 8 (byte) 0x3FFF C036 Fast GPIO Port 1 Pin value register 2. Bit 0 in FIO1PIN2 register 0x00
corresponds to P1.16 ... bit 7 to P1.23.
FIO1PIN3 8 (byte) 0x3FFF C037 Fast GPIO Port 1 Pin value register 3. Bit 0 in FIO1PIN3 register 0x00
corresponds to P1.24 ... bit 7 to P1.31.
FIO1PINL 16 0x3FFF C034 Fast GPIO Port 1 Pin value Lower half-word register. Bit 0 in 0x0000
(half-word) FIO1PINL register corresponds to P1.0 ... bit 15 to P1.15.
FIO1PINU 16 0x3FFF C036 Fast GPIO Port 1 Pin value Upper half-word register. Bit 0 in 0x0000
(half-word) FIO1PINU register corresponds to P1.16 ... bit 15 to P1.31.
8.4.4 GPIO port output Set register (IOSET, Port 0: IO0SET - 0xE002 8004
and Port 1: IO1SET - 0xE002 8014; FIOSET, Port 0: FIO0SET -
0x3FFF C018 and Port 1: FIO1SET - 0x3FFF C038)
This register is used to produce a HIGH level output at the port pins configured as GPIO in
an OUTPUT mode. Writing 1 produces a HIGH level at the corresponding port pins.
Writing 0 has no effect. If any pin is configured as an input or a secondary function, writing
1 to the corresponding bit in the IOSET has no effect.
Reading the IOSET register returns the value of this register, as determined by previous
writes to IOSET and IOCLR (or IOPIN as noted above). This value does not reflect the
effect of any outside world influence on the I/O pins.
Legacy registers are the IO0SET and IO1SET, while the enhanced GPIOs are supported
via the FIO0SET and FIO1SET registers. Access to a port pins via the FIOSET register is
conditioned by the corresponding FIOMASK register (see Section 8.4.2 “Fast GPIO port
Mask register (FIOMASK, Port 0: FIO0MASK - 0x3FFF C010 and Port 1:FIO1MASK -
0x3FFF C030)”).
Table 83: GPIO port 0 output Set register (IO0SET - address 0xE002 8004 bit description
Bit Symbol Description Reset value
31:0 P0xSET Slow GPIO output value Set bits. Bit 0 in IO0SET corresponds to P0.0 ... Bit 31 0x0000 0000
in IO0SET corresponds to P0.31.
Table 84: GPIO port 1 output Set register (IO1SET - address 0xE002 8014) bit description
Bit Symbol Description Reset value
31:0 P1xSET Slow GPIO output value Set bits. Bit 0 in IO1SET corresponds to P1.0 ... Bit 31 0x0000 0000
in IO1SET corresponds to P1.31.
Table 85: Fast GPIO port 0 output Set register (FIO0SET - address 0x3FFF C018) bit description
Bit Symbol Description Reset value
31:0 FP0xSET Fast GPIO output value Set bits. Bit 0 in FIO0SET corresponds to P0.0 ... Bit 31 0x0000 0000
in FIO0SET corresponds to P0.31.
Table 86: Fast GPIO port 1 output Set register (FIO1SET - address 0x3FFF C038) bit description
Bit Symbol Description Reset value
31:0 FP1xSET Fast GPIO output value Set bits. Bit 0 Fin IO1SET corresponds to P1.0 ... Bit 31 0x0000 0000
in FIO1SET corresponds to P1.31.
Aside from the 32-bit long and word only accessible FIOSET register, every fast GPIO
port can also be controlled via several byte and half-word accessible registers listed in
Table 87 and Table 88, too. Next to providing the same functions as the FIOSET register,
these additional registers allow easier and faster access to the physical port pins.
Table 87: Fast GPIO port 0 output Set byte and half-word accessible register description
Register Register Address Description Reset
name length (bits) value
& access
FIO0SET0 8 (byte) 0x3FFF C018 Fast GPIO Port 0 output Set register 0. Bit 0 in FIO0SET0 register 0x00
corresponds to P0.0 ... bit 7 to P0.7.
FIO0SET1 8 (byte) 0x3FFF C019 Fast GPIO Port 0 output Set register 1. Bit 0 in FIO0SET1 register 0x00
corresponds to P0.8 ... bit 7 to P0.15.
FIO0SET2 8 (byte) 0x3FFF C01A Fast GPIO Port 0 output Set register 2. Bit 0 in FIO0SET2 register 0x00
corresponds to P0.16 ... bit 7 to P0.23.
FIO0SET3 8 (byte) 0x3FFF C01B Fast GPIO Port 0 output Set register 3. Bit 0 in FIO0SET3 register 0x00
corresponds to P0.24 ... bit 7 to P0.31.
FIO0SETL 16 0x3FFF C018 Fast GPIO Port 0 output Set Lower half-word register. Bit 0 in 0x0000
(half-word) FIO0SETL register corresponds to P0.0 ... bit 15 to P0.15.
FIO0SETU 16 0x3FFF C01A Fast GPIO Port 0 output Set Upper half-word register. Bit 0 in 0x0000
(half-word) FIO0SETU register corresponds to P0.16 ... bit 15 to P0.31.
Table 88: Fast GPIO port 1 output Set byte and half-word accessible register description
Register Register Address Description Reset
name length (bits) value
& access
FIO1SET0 8 (byte) 0x3FFF C038 Fast GPIO Port 1 output Set register 0. Bit 0 in FIO1SET0 register 0x00
corresponds to P1.0 ... bit 7 to P1.7.
FIO1SET1 8 (byte) 0x3FFF C039 Fast GPIO Port 1 output Set register 1. Bit 0 in FIO1SET1 register 0x00
corresponds to P1.8 ... bit 7 to P1.15.
FIO1SET2 8 (byte) 0x3FFF C03A Fast GPIO Port 1 output Set register 2. Bit 0 in FIO1SET2 register 0x00
corresponds to P1.16 ... bit 7 to P1.23.
FIO1SET3 8 (byte) 0x3FFF C03B Fast GPIO Port 1 output Set register 3. Bit 0 in FIO1SET3 register 0x00
corresponds to P1.24 ... bit 7 to P1.31.
FIO1SETL 16 0x3FFF C038 Fast GPIO Port 1 output Set Lower half-word register. Bit 0 in 0x0000
(half-word) FIO1SETL register corresponds to P1.0 ... bit 15 to P1.15.
FIO1SETU 16 0x3FFF C03A Fast GPIO Port 1 output Set Upper half-word register. Bit 0 in 0x0000
(half-word) FIO1SETU register corresponds to P1.16 ... bit 15 to P1.31.
Legacy registers are the IO0CLR and IO1CLR, while the enhanced GPIOs are supported
via the FIO0CLR and FIO1CLR registers. Access to a port pins via the FIOCLR register is
conditioned by the corresponding FIOMASK register (see Section 8.4.2 “Fast GPIO port
Mask register (FIOMASK, Port 0: FIO0MASK - 0x3FFF C010 and Port 1:FIO1MASK -
0x3FFF C030)”).
Table 89: GPIO port 0 output Clear register 0 (IO0CLR - address 0xE002 800C) bit description
Bit Symbol Description Reset value
31:0 P0xCLR Slow GPIO output value Clear bits. Bit 0 in IO0CLR corresponds to P0.0 ... Bit 0x0000 0000
31 in IO0CLR corresponds to P0.31.
Table 90: GPIO port 1 output Clear register 1 (IO1CLR - address 0xE002 801C) bit description
Bit Symbol Description Reset value
31:0 P1xCLR Slow GPIO output value Clear bits. Bit 0 in IO1CLR corresponds to P1.0 ... Bit 0x0000 0000
31 in IO1CLR corresponds to P1.31.
Table 91: Fast GPIO port 0 output Clear register 0 (FIO0CLR - address 0x3FFF C01C) bit description
Bit Symbol Description Reset value
31:0 FP0xCLR Fast GPIO output value Clear bits. Bit 0 in FIO0CLR corresponds to P0.0 ... Bit 0x0000 0000
31 in FIO0CLR corresponds to P0.31.
Table 92: Fast GPIO port 1 output Clear register 1 (FIO1CLR - address 0x3FFF C03C) bit description
Bit Symbol Description Reset value
31:0 FP1xCLR Fast GPIO output value Clear bits. Bit 0 in FIO1CLR corresponds to P1.0 ... Bit 0x0000 0000
31 in FIO1CLR corresponds to P1.31.
Aside from the 32-bit long and word only accessible FIOCLR register, every fast GPIO
port can also be controlled via several byte and half-word accessible registers listed in
Table 93 and Table 94, too. Next to providing the same functions as the FIOCLR register,
these additional registers allow easier and faster access to the physical port pins.
Table 93: Fast GPIO port 0 output Clear byte and half-word accessible register description
Register Register Address Description Reset
name length (bits) value
& access
FIO0CLR0 8 (byte) 0x3FFF C01C Fast GPIO Port 0 output Clear register 0. Bit 0 in FIO0CLR0 register 0x00
corresponds to P0.0 ... bit 7 to P0.7.
FIO0CLR1 8 (byte) 0x3FFF C01D Fast GPIO Port 0 output Clear register 1. Bit 0 in FIO0CLR1 register 0x00
corresponds to P0.8 ... bit 7 to P0.15.
FIO0CLR2 8 (byte) 0x3FFF C01E Fast GPIO Port 0 output Clear register 2. Bit 0 in FIO0CLR2 register 0x00
corresponds to P0.16 ... bit 7 to P0.23.
FIO0CLR3 8 (byte) 0x3FFF C01F Fast GPIO Port 0 output Clear register 3. Bit 0 in FIO0CLR3 register 0x00
corresponds to P0.24 ... bit 7 to P0.31.
FIO0CLRL 16 0x3FFF C01C Fast GPIO Port 0 output Clear Lower half-word register. Bit 0 in 0x0000
(half-word) FIO0CLRL register corresponds to P0.0 ... bit 15 to P0.15.
FIO0CLRU 16 0x3FFF C01E Fast GPIO Port 0 output Clear Upper half-word register. Bit 0 in 0x0000
(half-word) FIO0SETU register corresponds to P0.16 ... bit 15 to P0.31.
Table 94: Fast GPIO port 1 output Clear byte and half-word accessible register description
Register Register Address Description Reset
name length (bits) value
& access
FIO1CLR0 8 (byte) 0x3FFF C03C Fast GPIO Port 1 output Clear register 0. Bit 0 in FIO1CLR0 register 0x00
corresponds to P1.0 ... bit 7 to P1.7.
FIO1CLR1 8 (byte) 0x3FFF C03D Fast GPIO Port 1 output Clear register 1. Bit 0 in FIO1CLR1 register 0x00
corresponds to P1.8 ... bit 7 to P1.15.
FIO1CLR2 8 (byte) 0x3FFF C03E Fast GPIO Port 1 output Clear register 2. Bit 0 in FIO1CLR2 register 0x00
corresponds to P1.16 ... bit 7 to P1.23.
FIO1CLR3 8 (byte) 0x3FFF C03F Fast GPIO Port 1 output Clear register 3. Bit 0 in FIO1CLR3 register 0x00
corresponds to P1.24 ... bit 7 to P1.31.
FIO1CLRL 16 0x3FFF C03C Fast GPIO Port 1 output Clear Lower half-word register. Bit 0 in 0x0000
(half-word) FIO1CLRL register corresponds to P1.0 ... bit 15 to P1.15.
FIO1CLRU 16 0x3FFF C03E Fast GPIO Port 1 output Clear Upper half-word register. Bit 0 in 0x0000
(half-word) FIO1CLRU register corresponds to P1.16 ... bit 15 to P1.31.
In case of a code:
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.
Following code will preserve existing output on PORT0 pins P0.[31:16] and P0.[7:0] and at
the same time set P0.[15:8] to 0xA5, regardless of the previous value of pins P0.[15:8]:
The same outcome can be obtained using the fast port access.
FIO0MASK = 0xFFFF00FF;
FIO0PIN = 0x0000A500;
FIO0MASKL = 0x00FF;
FIO0PINL = 0xA500;
FIO0PIN1 = 0xA5;
Write to the IOPIN register enables instantaneous output of a desired content on the
parallel GPIO. Binary data written into the IOPIN register will affect all output configured
pins of that parallel port: 0s in the IOPIN will produce low level pin outputs and 1s in IOPIN
will produce high level pin outputs. In order to change output of only a group of port’s pins,
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, this result has to
be logically ORred with the desired content and stored back into the IOPIN register.
Example 2 from above illustrates output of 0xA5 on PORT0 pins 15 to 8 while preserving
all other PORT0 output pins as they were before.
8.5.4 Output signal frequency considerations when using the legacy and
enhanced 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 is
when the legacy set of registers is used. As a result of the access speed increase, the
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,
and a portion of an application handling the fast port output might have to be written in an
assembly code and executed in the ARM mode.
Here is a code where the pin control section is written in assembly language for ARM. It
illustrates the difference between the fast and slow GPIO port output capabilities. Once
this code is compiled in the ARM mode, its execution from the on-chip Flash will yield the
best results when the MAM module is configured as described in Section 4.9 “MAM usage
notes” on page 49. Execution from the on-chip SRAM is independent from the MAM
setup.
str r2,[r1]
str r2,[r0]
str r2,[r1]
/*Generate 2 pulses on the slow port*/
str r5,[r3]
str r5,[r4]
str r5,[r3]
str r5,[r4]
loop: b loop
Figure 17 illustrates the code from above executed from the LPC2148 Flash memory. The
PLL generated FCCLK =60 MHz out of external FOSC = 12 MHz. The MAM was fully
enabled with MEMCR = 2 and MEMTIM = 3, and VPBDIV = 1 (PCLK = CCLK).
Fig 17. Illustration of the fast and slow GPIO access and output showing 3.5 x increase of the pin output
frequency
9.1 Features
• 16 byte Receive and Transmit FIFOs
• Register locations conform 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.
Philips Semiconductors
Table 96: UART0 register map
Name Description Bit functions and addresses Access Reset Address
MSB LSB value[1]
Volume 1
BIT7 BIT6 BIT5 BIT4 BIT3 BIT2 BIT1 BIT0
U0RBR Receiver Buffer 8-bit Read Data RO NA 0xE000 C000
Register (DLAB=0)
U0THR Transmit Holding 8-bit Write Data WO NA 0xE000 C000
Register (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 - - - - - - En.ABTO En.ABEO R/W 0x00 0xE000 C004
Register - - - - - En.RX Enable En.RX (DLAB=0)
Lin.St.Int THRE Int Dat.Av.Int
Rev. 01 — 15 August 2005
U0IIR Interrupt ID Reg. - - - - - - ABTO Int ABEO Int RO 0x01 0xE000 C008
FIFOs Enabled - - IIR3 IIR2 IIR1 IIR0
U0FCR FIFO Control RX Trigger - - - TX FIFO RX FIFO FIFO WO 0x00 0xE000 C008
Register Reset Reset Enable
U0LCR Line Control DLAB Set Stick Even Parity No. of Word Length Select R/W 0x00 0xE000 C00C
Register Break Parity Par.Selct. Enable Stop Bits
U0LSR Line Status RX FIFO TEMT THRE BI FE PE OE DR RO 0x60 0xE000 C014
Register Error
U0SCR Scratch Pad Reg. 8-bit Data R/W 0x00 0xE000 C01C
U0ACR Auto-baud Control - - - - - - ABTO ABEO R/W 0x00 0xE000 C020
Register Int.Clr Int.Clr
- - - - - Aut.Rstrt. Mode Start
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
UM10139
Chapter 9: UART0
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
96
Philips Semiconductors UM10139
Volume 1 Chapter 9: UART0
The Divisor Latch Access Bit (DLAB) in U0LCR must be zero in order to access the
U0RBR. The U0RBR is always Read Only.
Since PE, FE and BI bits correspond to the byte sitting on the top of the RBR FIFO (i.e.
the one that will be read in the next read from the RBR), the right approach for fetching the
valid pair of received byte and its status bits is first to read the content of the U0LSR
register, and then to read a byte from the U0RBR.
Table 97: UART0 Receiver Buffer Register (U0RBR - address 0xE000 C000, when DLAB = 0,
Read Only) bit description
Bit Symbol Description Reset value
7:0 RBR The UART0 Receiver Buffer Register contains the oldest undefined
received byte in the UART0 Rx FIFO.
The Divisor Latch Access Bit (DLAB) in U0LCR must be zero in order to access the
U0THR. The U0THR is always Write Only.
Table 98: UART0 Transmit Holding Register (U0THR - address 0xE000 C000, when
DLAB = 0, Write Only) bit description
Bit Symbol Description Reset value
7:0 THR Writing to the UART0 Transmit Holding Register causes the data NA
to be stored in the UART0 transmit FIFO. The byte will be sent
when it reaches the bottom of the FIFO and the transmitter is
available.
9.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 1). The U0DLL
and U0DLM registers together form a 16 bit divisor where U0DLL contains the lower 8 bits
of the divisor and U0DLM contains the higher 8 bits of the divisor. A 0x0000 value is
treated like a 0x0001 value as division by zero is not allowed.The Divisor Latch Access Bit
(DLAB) in U0LCR must be one in order to access the UART0 Divisor Latches.
Details on how to select the right value for U0DLL and U0DLM can be found later on in
this chapter.
Table 99: UART0 Divisor Latch LSB register (U0DLL - address 0xE000 C000, when
DLAB = 1) bit description
Bit Symbol Description Reset value
7:0 DLL The UART0 Divisor Latch LSB Register, along with the U0DLM 0x01
register, determines the baud rate of the UART0.
Table 100: UART0 Divisor Latch MSB register (U0DLM - address 0xE000 C004, when
DLAB = 1) bit description
Bit Symbol Description Reset value
7:0 DLM The UART0 Divisor Latch MSB Register, along with the U0DLL 0x00
register, determines the baud rate of the UART0.
Table 101: UART0 Fractional Divider Register (U0FDR - address 0xE000 C028) bit description
Bit Function Description Reset value
3:0 DIVADDVAL Baudrate generation pre-scaler divisor value. If this field is 0, 0
fractional baudrate generator will not impact the UART0
baudrate.
7:4 MULVAL Baudrate pre-scaler multiplier value. This field must be greater 1
or equal 1 for UART0 to operate properly, regardless of
whether the fractional baudrate generator is used or not.
31:8 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
This register controls the clock pre-scaler for the baud rate generation. The reset value of
the register keeps the fractional capabilities of UART0 disabled making sure that UART0 is
fully software and hardware compatible with UARTs not equipped with this feature.
(1)
PCLK
UART0 baudrate = -------------------------------------------------------------------------------------------------------------------------------
16 × ( 16 × U0DLM + U0DLL ) × ⎛ 1 + -----------------------------⎞
DivAddVal
⎝ MulVal ⎠
Where PCLK is the peripheral clock, U0DLM and U0DLL are the standard UART0 baud
rate divider registers, and DIVADDVAL and MULVAL are UART0 fractional baudrate
generator specific parameters.
The value of MULVAL and DIVADDVAL should comply to the following conditions:
1. 0 < MULVAL ≤ 15
2. 0 ≤ DIVADDVAL ≤ 15
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.
The value of the U0FDR should not be modified while transmitting/receiving data or data
may be lost or corrupted.
Usage Note: For practical purposes, UART0 baudrate formula can be written in a way
that identifies the part of a UART baudrate generated without the fractional baudrate
generator, and the correction factor that this module adds:
(2)
PCLK MulVal
UART0 baudrate = ----------------------------------------------------------------------------- × ------------------------------------------------------------
16 × ( 16 × U0DLM + U0DLL ) ( MulVal + DivAddVal )
Example 2: Using UART0baudrate formula from above, it can be determined that system
with PCLK = 20 MHz, U0DL = 93 (U0DLM = 0x00 and U0DLL = 0x5D), DIVADDVAL = 2
and MULVAL = 5 will enable UART0 with UART0baudrate = 9600 bauds.
Table 102: Baudrates available when using 20 MHz peripheral clock (PCLK = 20 MHz)
Desired MULVAL = 0 DIVADDVAL = 0 Optimal MULVAL & DIVADDVAL
baudrate U0DLM:U0DLL % error[3] U0DLM:U0DLL Fractional % error[3]
hex[2] dec[1] dec[1] pre-scaler value
MULDIV
MULDIV + DIVADDVAL
Table 102: Baudrates available when using 20 MHz peripheral clock (PCLK = 20 MHz)
Desired MULVAL = 0 DIVADDVAL = 0 Optimal MULVAL & DIVADDVAL
baudrate U0DLM:U0DLL % error[3] U0DLM:U0DLL Fractional % error[3]
hex[2] dec[1] dec[1] pre-scaler value
MULDIV
MULDIV + DIVADDVAL
[1] Values in the row represent decimal equivalent of a 16 bit long content (DLM:DLL).
[2] Values in the row represent hex equivalent of a 16 bit long content (DLM:DLL).
[3] Refers to the percent error between desired and actual baudrate.
Table 103: UART0 Interrupt Enable Register (U0IER - address 0xE000 C004, when DLAB = 0)
bit description
Bit Symbol Value Description Reset
value
0 RBR U0IER[0] enables the Receive Data Available interrupt 0
Interrupt for UART0. It also controls the Character Receive
Enable Time-out interrupt.
0 Disable the RDA interrupts.
1 Enable the RDA interrupts.
1 THRE U0IER[1] enables the THRE interrupt for UART0. The 0
Interrupt status of this can be read from U0LSR[5].
Enable 0 Disable the THRE interrupts.
1 Enable the THRE interrupts.
2 RX Line U0IER[2] enables the UART0 RX line status interrupts. 0
Status The status of this interrupt can be read from U0LSR[4:1].
Interrupt 0 Disable the RX line status interrupts.
Enable
1 Enable the RX line status interrupts.
7:4 - - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is not
defined.
Table 103: UART0 Interrupt Enable Register (U0IER - address 0xE000 C004, when DLAB = 0)
bit description
Bit Symbol Value Description Reset
value
8 ABTOIntEn U1IER8 enables the auto-baud time-out interrupt. 0
0 Disable Auto-baud Time-out Interrupt.
1 Enable Auto-baud Time-out Interrupt.
9 ABEOIntEn U1IER9 enables the end of auto-baud interrupt. 0
0 Disable End of Auto-baud Interrupt.
1 Enable End of Auto-baud Interrupt.
31:10 - - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is not
defined.
Table 104: UART0 Interrupt Identification Register (UOIIR - address 0xE000 C008, read only)
bit description
Bit Symbol Value Description Reset
value
0 Interrupt Note that U0IIR[0] is active low. The pending interrupt can 1
Pending be determined by evaluating U0IIR[3:1].
0 At least one interrupt is pending.
1 No pending interrupts.
3:1 Interrupt U0IER[3:1] identifies an interrupt corresponding to the 0
Identification UART0 Rx FIFO. All other combinations of U0IER[3:1] not
listed above are reserved (000,100,101,111).
011 1 - Receive Line Status (RLS).
010 2a - Receive Data Available (RDA).
110 2b - Character Time-out Indicator (CTI).
001 3 - THRE Interrupt
5:4 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
7:6 FIFO Enable These bits are equivalent to U0FCR[0]. 0
8 ABEOInt End of auto-baud interrupt. True if auto-baud has finished 0
successfully and interrupt is enabled.
9 ABTOInt Auto-baud time-out interrupt. True if auto-baud has timed 0
out and interrupt is enabled.
31:10 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Interrupts are handled as described in Table 105. Given the status of U0IIR[3:0], an
interrupt handler routine can determine the cause of the interrupt and how to clear the
active interrupt. The U0IIR must be read in order to clear the interrupt prior to exiting the
Interrupt Service Routine.
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
The UART0 RLS interrupt (U0IIR[3:1] = 011) is the highest priority interrupt and is set
whenever any one of four error conditions occur on the UART0 Rx input: overrun error
(OE), parity error (PE), framing error (FE) and break interrupt (BI). The UART0 Rx error
condition that set the interrupt can be observed via U0LSR[4:1]. The interrupt is cleared
upon an U0LSR read.
The UART0 RDA interrupt (U0IIR[3:1] = 010) shares the second level priority with the CTI
interrupt (U0IIR[3:1] = 110). The RDA is activated when the UART0 Rx FIFO reaches the
trigger level defined in U0FCR[7:6] and is reset when the UART0 Rx FIFO depth falls
below the trigger level. When the RDA interrupt goes active, the CPU can read a block of
data defined by the trigger level.
The CTI interrupt (U0IIR[3:1] = 110) is a second level interrupt and is set when the UART0
Rx FIFO contains at least one character and no UART0 Rx FIFO activity has occurred in
3.5 to 4.5 character times. Any UART0 Rx FIFO activity (read or write of UART0 RSR) will
clear the interrupt. This interrupt is intended to flush the UART0 RBR after a message has
been received that is not a multiple of the trigger level size. For example, if a peripheral
wished to send a 105 character message and the trigger level was 10 characters, the CPU
would receive 10 RDA interrupts resulting in the transfer of 100 characters and 1 to 5 CTI
interrupts (depending on the service routine) resulting in the transfer of the remaining 5
characters.
[1] Values "0000", “0011”, “0101”, “0111”, “1000”, “1001”, “1010”, “1011”,”1101”,”1110”,”1111” are reserved.
[2] For details see Section 9.3.10 “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.7 “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 activated
when the UART0 THR FIFO is empty provided certain initialization conditions have been
met. These initialization conditions are intended to give the UART0 THR FIFO a chance to
fill up with data to eliminate many THRE interrupts from occurring at system start-up. The
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
initialization conditions implement a one character delay minus the stop bit whenever
THRE=1 and there have not been at least two characters in the U0THR at one time since
the last THRE = 1 event. This delay is provided to give the CPU time to write data to
U0THR without a THRE interrupt to decode and service. A THRE interrupt is set
immediately if the UART0 THR FIFO has held two or more characters at one time and
currently, the U0THR is empty. The THRE interrupt is reset when a U0THR write occurs or
a read of the U0IIR occurs and the THRE is the highest interrupt (U0IIR[3:1] = 001).
Table 106: UART0 FIFO Control Register (U0FCR - address 0xE000 C008) bit description
Bit Symbol Value Description Reset value
0 FIFO Enable 0 UART0 FIFOs are disabled. Must not be used in the 0
application.
1 Active high enable for both UART0 Rx and TX
FIFOs and U0FCR[7:1] access. This bit must be set
for proper UART0 operation. Any transition on this
bit will automatically clear the UART0 FIFOs.
1 RX FIFO 0 No impact on either of UART0 FIFOs. 0
Reset 1 Writing a logic 1 to U0FCR[1] will clear all bytes in
UART0 Rx FIFO and reset the pointer logic. This bit
is self-clearing.
2 TX FIFO 0 No impact on either of UART0 FIFOs. 0
Reset 1 Writing a logic 1 to U0FCR[2] will clear all bytes in
UART0 TX FIFO and reset the pointer logic. This bit
is self-clearing.
5:3 - 0 Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is
not defined.
7:6 RX Trigger These two bits determine how many receiver 0
Level UART0 FIFO characters must be written before an
00 interrupt is activated.
Trigger level 0 (1 character or 0x01)
01 Trigger level 1 (4 characters or 0x04)
10 Trigger level 2 (8 characters or 0x08)
11 Trigger level 3 (14 characters or 0x0E)
Table 107: UART0 Line Control Register (U0LCR - address 0xE000 C00C) bit description
Bit Symbol Value Description Reset value
1:0 Word Length 00 5 bit character length 0
Select 01 6 bit character length
10 7 bit character length
11 8 bit character length
Table 107: UART0 Line Control Register (U0LCR - address 0xE000 C00C) bit description
Bit Symbol Value Description Reset value
2 Stop Bit Select 0 1 stop bit. 0
1 2 stop bits (1.5 if U0LCR[1:0]=00).
3 Parity Enable 0 Disable parity generation and checking. 0
1 Enable parity generation and checking.
5:4 Parity Select 00 Odd parity. Number of 1s in the transmitted character and the 0
attached parity bit will be odd.
01 Even Parity. Number of 1s in the transmitted character and the
attached parity bit will be even.
10 Forced "1" stick parity.
11 Forced "0" stick parity.
6 Break Control 0 Disable break transmission. 0
1 Enable break transmission. Output pin UART0 TXD is forced to
logic 0 when U0LCR[6] is active high.
7 Divisor Latch 0 Disable access to Divisor Latches. 0
Access Bit (DLAB) 1 Enable access to Divisor Latches.
9.3.10 UART0 Line Status Register (U0LSR - 0xE000 C014, Read Only)
The U0LSR is a read-only register that provides status information on the UART0 TX and
RX blocks.
Table 108: UART0 Line Status Register (U0LSR - address 0xE000 C014, read only) bit description
Bit Symbol Value Description Reset value
0 Receiver Data U0LSR0 is set when the U0RBR holds an unread character and is cleared 0
Ready when the UART0 RBR FIFO is empty.
(RDR) 0 U0RBR is empty.
1 U0RBR contains valid data.
1 Overrun Error The overrun error condition is set as soon as it occurs. An U0LSR read clears 0
(OE) U0LSR1. U0LSR1 is set when UART0 RSR has a new character assembled
and the UART0 RBR FIFO is full. In this case, the UART0 RBR FIFO will not
be overwritten and the character in the UART0 RSR will be lost.
0 Overrun error status is inactive.
1 Overrun error status is active.
2 Parity Error When the parity bit of a received character is in the wrong state, a parity error 0
(PE) occurs. An U0LSR read clears U0LSR[2]. Time of parity error detection is
dependent on U0FCR[0].
Note: A parity error is associated with the character at the top of the UART0
RBR FIFO.
0 Parity error status is inactive.
1 Parity error status is active.
Table 108: UART0 Line Status Register (U0LSR - address 0xE000 C014, read only) bit description
Bit Symbol Value Description Reset value
3 Framing Error When the stop bit of a received character is a logic 0, a framing error occurs. 0
(FE) An U0LSR read clears U0LSR[3]. The time of the framing error detection is
dependent on U0FCR0. Upon detection of a framing error, the Rx will attempt
to resynchronize to the data and assume that the bad stop bit is actually an
early start bit. However, it cannot be assumed that the next received byte will
be correct even if there is no Framing Error.
Note: A framing error is associated with the character at the top of the UART0
RBR FIFO.
0 Framing error status is inactive.
1 Framing error status is active.
4 Break Interrupt When RXD0 is held in the spacing state (all 0’s) for one full character 0
(BI) transmission (start, data, parity, stop), a break interrupt occurs. Once the
break condition has been detected, the receiver goes idle until RXD0 goes to
marking state (all 1’s). An U0LSR read clears this status bit. The time of break
detection is dependent on U0FCR[0].
Note: The break interrupt is associated with the character at the top of the
UART0 RBR FIFO.
0 Break interrupt status is inactive.
1 Break interrupt status is active.
5 Transmitter THRE is set immediately upon detection of an empty UART0 THR and is 1
Holding cleared on a U0THR write.
Register Empty 0 U0THR contains valid data.
(THRE))
1 U0THR is empty.
6 Transmitter TEMT is set when both U0THR and U0TSR are empty; TEMT is cleared when 1
Empty either the U0TSR or the U0THR contain valid data.
(TEMT) 0 U0THR and/or the U0TSR contains valid data.
1 U0THR and the U0TSR are empty.
7 Error in RX U0LSR[7] is set when a character with a Rx error such as framing error, parity 0
FIFO error or break interrupt, is loaded into the U0RBR. This bit is cleared when the
(RXFE) U0LSR register is read and there are no subsequent errors in the UART0
FIFO.
0 U0RBR contains no UART0 RX errors or U0FCR[0]=0.
1 UART0 RBR contains at least one UART0 RX error.
Table 109: UART0 Scratch pad register (U0SCR - address 0xE000 C01C) bit description
Bit Symbol Description Reset value
7:0 Pad A readable, writable byte. 0x00
Table 110: Auto-baud Control Register (U0ACR - 0xE000 C020) bit description
Bit Symbol Value Description Reset value
0 Start This bit is automatically cleared after auto-baud 0
completion.
0 Auto-baud stop (auto-baud is not running).
1 Auto-baud start (auto-baud is running).Auto-baud run
bit. This bit is automatically cleared after auto-baud
completion.
1 Mode Auto-baud mode select bit. 0
0 Mode 0.
1 Mode 1.
2 AutoRestart 0 No restart 0
1 Restart in case of time-out (counter restarts at next
UART0 Rx falling edge)
7:3 - NA Reserved, user software should not write ones to 0
reserved bits. The value read from a reserved bit is not
defined.
8 ABEOIntClr End of auto-baud interrupt clear bit (write only 0
accessible). Writing a 1 will clear the corresponding
interrupt in the U0IIR. Writing a 0 has no impact.
9 ABTOIntClr Auto-baud time-out interrupt clear bit (write only 0
accessible). Writing a 1 will clear the corresponding
interrupt in the U0IIR. Writing a 0 has no impact.
31:10 - NA Reserved, user software should not write ones to 0
reserved bits. The value read from a reserved bit is not
defined.
9.3.13 Auto-baud
The UART0 auto-baud function can be used to measure the incoming baud-rate based on
the ”AT" protocol (Hayes command). If enabled the auto-baud feature will measure the bit
time of the receive data stream and set the divisor latch registers U0DLM and U0DLL
accordingly.
Auto-baud is started by setting the U0ACR Start bit. Auto-baud can be stopped by
clearing the U0ACR Start bit. The Start bit will clear once auto-baud has finished and
reading the bit will return the status of auto-baud (pending/finished).
Two auto-baud measuring modes are available which can be selected by the U0ACR
Mode bit. In mode 0 the baud-rate is measured on two subsequent falling edges of the
UART0 Rx pin (the falling edge of the start bit and the falling edge of the least significant
bit). In mode 1 the baud-rate is measured between the falling edge and the subsequent
rising edge of the UART0 Rx pin (the length of the start bit).
The U0ACR AutoRestart bit can be used to automatically restart baud-rate measurement
if a time-out occurs (the rate measurement counter overflows). If this bit is set the rate
measurement will restart at the next falling edge of the UART0 Rx pin.
• The U0IIR ABTOInt interrupt will get set if the interrupt is enabled (U0IER ABToIntEn
is set and the auto-baud rate measurement counter overflows).
• The U0IIR ABEOInt interrupt will get set if the interrupt is enabled (U0IER ABEOIntEn
is set and the auto-baud has completed successfully).
(3)
2 × P CLK PCLK
ratemin = ------------------------- ≤ UART0 baudrate ≤ ------------------------------------------------------------------------------------------------------------ = ratemax
16 × 2 15 16 × ( 2 + databits + paritybits + stopbits )
Table 111 describes how to use TXEn bit in order to achieve software flow control.
Table 111: UART0 Transmit Enable Register (U0TER - address 0xE000 C030) bit description
Bit Symbol Description Reset
value
6:0 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
7 TXEN When this bit is 1, as it is after a Reset, data written to the THR is output 1
on the TXD pin as soon as any preceding data has been sent. If this bit
is cleared to 0 while a character is being sent, the transmission of that
character is completed, but no further characters are sent until this bit is
set again. In other words, a 0 in this bit blocks the transfer of characters
from the THR or TX FIFO into the transmit shift register. Software
implementing software-handshaking can clear this bit when it receives
an XOFF character (DC3). Software can set this bit again when it
receives an XON (DC1) character.
1. On U0ACR Start bit setting, the baud-rate measurement counter is reset and the
UART0 U0RSR is reset. The U0RSR baud rate is switch to the highest rate.
2. A falling edge on UART0 Rx pin triggers the beginning of the start bit. The rate
measuring counter will start counting PCLK cycles optionally pre-scaled by the
fractional baud-rate generator.
3. During the receipt of the start bit, 16 pulses are generated on the RSR baud input with
the frequency of the (fractional baud-rate pre-scaled) UART0 input clock,
guaranteeing the start bit is stored in the U0RSR.
4. During the receipt of the start bit (and the character LSB for mode = 0) the rate
counter will continue incrementing with the pre-scaled UART0 input clock (PCLK).
5. If Mode = 0 then the rate counter will stop on next falling edge of the UART0 Rx pin. If
Mode = 1 then the rate counter will stop on the next rising edge of the UART0 Rx pin.
6. The rate counter is loaded into U0DLM/U0DLL and the baud-rate will be switched to
normal operation. After setting the U0DLM/U0DLL the end of auto-baud interrupt
U0IIR ABEOInt will be set, if enabled. The U0RSR will now continue receiving the
remaining bits of the ”A/a" character.
start bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 parity stop
U1ACR Start
rate counter
16xbaud_rate
16 cycles 16 cycles
a) Mode 0 (Start bit and LSB are used for auto-baud)
start bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 parity stop
U1ACR Start
rate counter
16xbaud_rate
16 cycles
b) Mode 1 (only Start bit is used for auto-baud)
9.4 Architecture
The architecture of the UART0 is shown below in the block diagram.
The VPB interface provides a communications link between the CPU or host and the
UART0.
The UART0 receiver block, U0RX, monitors the serial input line, RXD0, for valid input. The
UART0 RX Shift Register (U0RSR) accepts valid characters via RXD0. After a valid
character is assembled in the U0RSR, it is passed to the UART0 RX Buffer Register FIFO
to await access by the CPU or host via the generic host interface.
The UART0 transmitter block, U0TX, accepts data written by the CPU or host and buffers
the data in the UART0 TX Holding Register FIFO (U0THR). The UART0 TX Shift Register
(U0TSR) reads the data stored in the U0THR and assembles the data to transmit via the
serial output pin, TXD0.
The UART0 Baud Rate Generator block, U0BRG, generates the timing enables used by
the UART0 TX block. The U0BRG clock input source is the VPB clock (PCLK). The main
clock is divided down per the divisor specified in the U0DLL and U0DLM registers. This
divided down clock is a 16x oversample clock, NBAUDOUT.
The interrupt interface contains registers U0IER and U0IIR. The interrupt interface
receives several one clock wide enables from the U0TX and U0RX blocks.
Status information from the U0TX and U0RX is stored in the U0LSR. Control information
for the U0TX and U0RX is stored in the U0LCR.
U0TX NTXRDY
TXD0
U0THR U0TSR
U0BRG
U0DLL NBAUDOUT
U0DLM RCLK
U0RX
NRXRDY
INTERRUPT
RXD0
U0RBR U0RSR
U0INTR U0IER
U0IIR U0FCR
U0LSR
U0SCR
U0LCR
PA[2:0]
PSEL
PSTB
PWRITE
VPB
PD[7:0] DDIS
INTERFACE
AR
MR
PCLK
10.1 Features
• UART1 is identical to UART0, with the addition of a modem interface.
• 16 byte Receive and Transmit FIFOs.
• Register locations conform 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.
• Standard modem interface signals included with flow control (auto-CTS/RTS) fully
supported in hardware (LPC2144/6/8 only).
Philips Semiconductors
Table 113: UART1 register map
Name Description Bit functions and addresses Access Reset Address
MSB LSB value[1]
Volume 1
BIT7 BIT6 BIT5 BIT4 BIT3 BIT2 BIT1 BIT0
U1RBR Receiver Buffer 8-bit Read Data RO NA 0xE001 0000
Register (DLAB=0)
U1THR Transmit Holding 8-bit Write Data WO NA 0xE001 0000
Register (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 - - - - - - En.ABTO En.ABEO R/W 0x00 0xE001 0004
Register En.CTS - - - E.Modem En. RX Enable En. RX (DLAB=0)
Int[2] St.Int[2] Lin.St. Int THRE Int Dat.Av.Int
Rev. 01 — 15 August 2005
U1IIR Interrupt ID Reg. - - - - - - ABTO Int ABEO Int RO 0x01 0xE001 0008
FIFOs Enabled - - IIR3 IIR2 IIR1 IIR0
U1FCR FIFO Control RX Trigger - - - TX FIFO RX FIFO FIFO WO 0x00 0xE001 0008
Register Reset Reset Enable
U1LCR Line Control DLAB Set Stick Even Parity No. of Word Length Select R/W 0x00 0xE001 000C
Register Break Parity Par.Selct. Enable Stop Bits
U1MCR[2] Modem Ctrl. Reg. CTSen RTSen - LoopBck. - - RTS DTR R/W 0x00 0xE001 0010
U1LSR Line Status RX FIFO TEMT THRE BI FE PE OE DR RO 0x60 0xE001 0014
Register Error
U1MSR[2] Modem Status DCD RI DSR CTS Delta Trailing Delta Delta RO 0x00 0xE001 0018
Register DCD Edge RI DSR CTS
U1SCR Scratch Pad Reg. 8-bit Data R/W 0x00 0xE001 001C
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
[2] Modem specific features are available in LPC2144/6/8 only.
114
Philips Semiconductors UM10139
Volume 1 Chapter 10: UART1
The Divisor Latch Access Bit (DLAB) in U1LCR must be zero in order to access the
U1RBR. The U1RBR is always Read Only.
Since PE, FE and BI bits correspond to the byte sitting on the top of the RBR FIFO (i.e.
the one that will be read in the next read from the RBR), the right approach for fetching the
valid pair of received byte and its status bits is first to read the content of the U1LSR
register, and then to read a byte from the U1RBR.
Table 114: UART1 Receiver Buffer Register (U1RBR - address 0xE001 0000, when DLAB = 0
Read Only) bit description
Bit Symbol Description Reset value
7:0 RBR The UART1 Receiver Buffer Register contains the oldest undefined
received byte in the UART1 RX FIFO.
The Divisor Latch Access Bit (DLAB) in U1LCR must be zero in order to access the
U1THR. The U1THR is always Write Only.
Table 115: UART1 Transmitter Holding Register (U1THR - address 0xE001 0000, when
DLAB = 0 Write Only) bit description
Bit Symbol Description Reset value
7:0 THR Writing to the UART1 Transmit Holding Register causes the data NA
to be stored in the UART1 transmit FIFO. The byte will be sent
when it reaches the bottom of the FIFO and the transmitter is
available.
10.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 4). The U1DLL
and U1DLM registers together form a 16 bit divisor where U1DLL contains the lower 8 bits
of the divisor and U1DLM contains the higher 8 bits of the divisor. A 0x0000 value is
treated like a 0x0001 value as division by zero is not allowed.The Divisor Latch Access Bit
(DLAB) in U1LCR must be one in order to access the UART1 Divisor Latches.
Details on how to select the right value for U1DLL and U1DLM can be found later on in
this chapter.
Table 116: UART1 Divisor Latch LSB register (U1DLL - address 0xE001 0000, when
DLAB = 1) bit description
Bit Symbol Description Reset value
7:0 DLLSB The UART1 Divisor Latch LSB Register, along with the U1DLM 0x01
register, determines the baud rate of the UART1.
Table 117: UART1 Divisor Latch MSB register (U1DLM - address 0xE001 0004, when
DLAB = 1) bit description
Bit Symbol Description Reset value
7:0 DLMSB The UART1 Divisor Latch MSB Register, along with the U1DLL 0x00
register, determines the baud rate of the UART1.
Table 118: UART1 Fractional Divider Register (U1FDR - address 0xE001 0028) bit description
Bit Function Description Reset value
3:0 DIVADDVAL Baudrate generation pre-scaler divisor value. If this field is 0, 0
fractional baudrate generator will not impact the UART1
baudrate.
7:4 MULVAL Baudrate pre-scaler multiplier value. This field must be greater 1
or equal 1 for UART1 to operate properly, regardless of
whether the fractional baudrate generator is used or not.
31:8 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
This register controls the clock pre-scaler for the baud rate generation. The reset value of
the register keeps the fractional capabilities of UART1 disabled making sure that UART1 is
fully software and hardware compatible with UARTs not equipped with this feature.
(4)
PCLK
UART1 baudrate = -------------------------------------------------------------------------------------------------------------------------------
16 × ( 16 × U1DLM + U1DLL ) × ⎛ 1 + -----------------------------⎞
DivAddVal
⎝ MulVal ⎠
Where PCLK is the peripheral clock, U1DLM and U1DLL are the standard UART1 baud
rate divider registers, and DIVADDVAL and MULVAL are UART1 fractional baudrate
generator specific parameters.
The value of MULVAL and DIVADDVAL should comply to the following conditions:
1. 0 < MULVAL ≤ 15
2. 0 ≤ DIVADDVAL ≤ 15
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.
The value of the U1FDR should not be modified while transmitting/receiving data or data
may be lost or corrupted.
Usage Note: For practical purposes, UART1 baudrate formula can be written in a way
that identifies the part of a UART baudrate generated without the fractional baudrate
generator, and the correction factor that this module adds:
(5)
PCLK MulVal
UART1 baudrate = ----------------------------------------------------------------------------- × ------------------------------------------------------------
16 × ( 16 × U1DLM + U1DLL ) ( MulVal + DivAddVal )
Example 2: Using UART1baudrate formula from above, it can be determined that system
with PCLK = 20 MHz, U1DL = 93 (U1DLM = 0x00 and U1DLL = 0x5D), DIVADDVAL = 2
and MULVAL = 5 will enable UART1 with UART1baudrate = 9600 bauds.
Table 119: Baudrates available when using 20 MHz peripheral clock (PCLK = 20 MHz)
Desired MULVAL = 0 DIVADDVAL = 0 Optimal MULVAL & DIVADDVAL
baudrate U1DLM:U1DLL % error[3] U1DLM:U1DLL Fractional % error[3]
hex[2] dec[1] dec[1] pre-scaler value
MULDIV
MULDIV + DIVADDVAL
Table 119: Baudrates available when using 20 MHz peripheral clock (PCLK = 20 MHz)
Desired MULVAL = 0 DIVADDVAL = 0 Optimal MULVAL & DIVADDVAL
baudrate U1DLM:U1DLL % error[3] U1DLM:U1DLL Fractional % error[3]
hex[2] dec[1] dec[1] pre-scaler value
MULDIV
MULDIV + DIVADDVAL
[1] Values in the row represent decimal equivalent of a 16 bit long content (DLM:DLL).
[2] Values in the row represent hex equivalent of a 16 bit long content (DLM:DLL).
[3] Refers to the percent error between desired and actual baudrate.
Table 120: UART1 Interrupt Enable Register (U1IER - address 0xE001 0004, when DLAB = 0)
bit description
Bit Symbol Value Description Reset value
0 RBR U1IER[0] enables the Receive Data Available 0
Interrupt interrupt for UART1. It also controls the Character
Enable Receive Time-out interrupt.
0 Disable the RDA interrupts.
1 Enable the RDA interrupts.
1 THRE U1IER[1] enables the THRE interrupt for UART1. 0
Interrupt The status of this interrupt can be read from
Enable U1LSR[5].
0 Disable the THRE interrupts.
1 Enable the THRE interrupts.
2 RX Line U1IER[2] enables the UART1 RX line status 0
Interrupt interrupts. The status of this interrupt can be read
Enable from U1LSR[4:1].
0 Disable the RX line status interrupts.
1 Enable the RX line status interrupts.
3 Modem U1IER[3] enables the modem interrupt. The status 0
Status of this interrupt can be read from U1MSR[3:0].
Interrupt 0 Disable the modem interrupt.
Enable[1]
1 Enable the modem interrupt.
Table 120: UART1 Interrupt Enable Register (U1IER - address 0xE001 0004, when DLAB = 0)
bit description
Bit Symbol Value Description Reset value
6:4 - - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is
not defined.
7 CTS If auto-CTS mode is enabled this bit 0
Interrupt enables/disables the modem status interrupt
Enable[1] generation on a CTS1 signal transition. If auto-CTS
mode is disabled a CTS1 transition will generate an
interrupt if Modem Status Interrupt Enable
(U1IER[3]) is set.
In normal operation a CTS1 signal transition will
generate a Modem Status Interrupt unless the
interrupt has been disabled by clearing the
U1IER[3] bit in the U1IER register. In auto-CTS
mode a transition on the CTS1 bit will trigger an
interrupt only if both the U1IER[3] and U1IER[7] bits
are set.
0 Disable the CTS interrupt.
1 Enable the CTS interrupt.
8 ABTOIntEn U1IER8 enables the auto-baud time-out interrupt. 0
0 Disable Auto-baud Time-out Interrupt.
1 Enable Auto-baud Time-out Interrupt.
9 ABEOIntEn U1IER9 enables the end of auto-baud interrupt. 0
0 Disable End of Auto-baud Interrupt.
1 Enable End of Auto-baud Interrupt.
31:10 - - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is
not defined.
[1] Available in LPC2144/6/8 only. In all other LPC214x parts this bit is Reserved.
Table 121: UART1 Interrupt Identification Register (U1IIR - address 0xE001 0008, read only)
bit description
Bit Symbol Value Description Reset value
0 Interrupt Note that U1IIR[0] is active low. The pending 1
Pending interrupt can be determined by evaluating
U1IIR[3:1].
0 At least one interrupt is pending.
1 No interrupt is pending.
Table 121: UART1 Interrupt Identification Register (U1IIR - address 0xE001 0008, read only)
bit description
Bit Symbol Value Description Reset value
3:1 Interrupt U1IER[3:1] identifies an interrupt corresponding to 0
Identification the UART1 Rx FIFO. All other combinations of
U1IER[3:1] not listed above are reserved
(100,101,111).
011 1 - Receive Line Status (RLS).
010 2a - Receive Data Available (RDA).
110 2b - Character Time-out Indicator (CTI).
001 3 - THRE Interrupt.
000 4 - Modem Interrupt.[1]
5:4 - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is
not defined.
7:6 FIFO Enable These bits are equivalent to U1FCR[0]. 0
8 ABEOInt End of auto-baud interrupt. True if auto-baud has 0
finished successfully and interrupt is enabled.
9 ABTOInt Auto-baud time-out interrupt. True if auto-baud has 0
timed out and interrupt is enabled.
31:10 - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is
not defined.
[1] LPC2144/6/8 only. For all other LPC214x devices ’000’ combination is Reserved.
Interrupts are handled as described in Table 83. Given the status of U1IIR[3:0], an
interrupt handler routine can determine the cause of the interrupt and how to clear the
active interrupt. The U1IIR must be read in order to clear the interrupt prior to exiting the
Interrupt Service Routine.
The UART1 RLS interrupt (U1IIR[3:1] = 011) is the highest priority interrupt and is set
whenever any one of four error conditions occur on the UART1RX input: overrun error
(OE), parity error (PE), framing error (FE) and break interrupt (BI). The UART1 Rx error
condition that set the interrupt can be observed via U1LSR[4:1]. The interrupt is cleared
upon an U1LSR read.
The UART1 RDA interrupt (U1IIR[3:1] = 010) shares the second level priority with the CTI
interrupt (U1IIR[3:1] = 110). The RDA is activated when the UART1 Rx FIFO reaches the
trigger level defined in U1FCR7:6 and is reset when the UART1 Rx FIFO depth falls below
the trigger level. When the RDA interrupt goes active, the CPU can read a block of data
defined by the trigger level.
The CTI interrupt (U1IIR[3:1] = 110) is a second level interrupt and is set when the UART1
Rx FIFO contains at least one character and no UART1 Rx FIFO activity has occurred in
3.5 to 4.5 character times. Any UART1 Rx FIFO activity (read or write of UART1 RSR) will
clear the interrupt. This interrupt is intended to flush the UART1 RBR after a message has
been received that is not a multiple of the trigger level size. For example, if a peripheral
wished to send a 105 character message and the trigger level was 10 characters, the CPU
would receive 10 RDA interrupts resulting in the transfer of 100 characters and 1 to 5 CTI
interrupts (depending on the service routine) resulting in the transfer of the remaining 5
characters.
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
[1] Values "0000" (see Table note 2), “0011”, “0101”, “0111”, “1000”, “1001”, “1010”,
“1011”,”1101”,”1110”,”1111” are reserved.
[2] LPC2144/6/8 only.
[3] For details see Section 10.3.11 “UART1 Line Status Register (U1LSR - 0xE001 0014, Read Only)”
[4] For details see Section 10.3.1 “UART1 Receiver Buffer Register (U1RBR - 0xE001 0000, when DLAB = 0
Read Only)”
[5] For details see Section 10.3.7 “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 activated
when the UART1 THR FIFO is empty provided certain initialization conditions have been
met. These initialization conditions are intended to give the UART1 THR FIFO a chance to
fill up with data to eliminate many THRE interrupts from occurring at system start-up. The
initialization conditions implement a one character delay minus the stop bit whenever
THRE = 1 and there have not been at least two characters in the U1THR at one time since
the last THRE = 1 event. This delay is provided to give the CPU time to write data to
U1THR without a THRE interrupt to decode and service. A THRE interrupt is set
immediately if the UART1 THR FIFO has held two or more characters at one time and
currently, the U1THR is empty. The THRE interrupt is reset when a U1THR write occurs or
a read of the U1IIR occurs and the THRE is the highest interrupt (U1IIR[3:1] = 001).
The modem interrupt (U1IIR[3:1] = 000) is available in LPC2144/6/8 only. 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 by
examining U1MSR[3:0]. A U1MSR read will clear the modem interrupt.
Table 123: UART1 FIFO Control Register (U1FCR - address 0xE001 0008) bit description
Bit Symbol Value Description Reset value
0 FIFO Enable 0 UART1 FIFOs are disabled. Must not be used in the application. 0
1 Active high enable for both UART1 Rx and TX FIFOs and
U1FCR[7:1] access. This bit must be set for proper UART1
operation. Any transition on this bit will automatically clear the
UART1 FIFOs.
1 RX FIFO Reset 0 No impact on either of UART1 FIFOs. 0
1 Writing a logic 1 to U1FCR[1] will clear all bytes in UART1 Rx
FIFO and reset the pointer logic. This bit is self-clearing.
2 TX FIFO Reset 0 No impact on either of UART1 FIFOs. 0
1 Writing a logic 1 to U1FCR[2] will clear all bytes in UART1 TX
FIFO and reset the pointer logic. This bit is self-clearing.
5:3 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
7:6 RX Trigger Level These two bits determine how many receiver UART1 FIFO 0
characters must be written before an interrupt is activated.
00 trigger level 0 (1 character or 0x01).
01 trigger level 1 (4 characters or 0x04).
10 trigger level 2 (8 characters or 0x08).
11 trigger level 3 (14 characters or 0x0E).
Table 124: UART1 Line Control Register (U1LCR - address 0xE001 000C) bit description
Bit Symbol Value Description Reset value
1:0 Word Length 00 5 bit character length. 0
Select 01 6 bit character length.
10 7 bit character length.
11 8 bit character length.
2 Stop Bit Select 0 1 stop bit. 0
1 2 stop bits (1.5 if U1LCR[1:0]=00).
3 Parity Enable 0 Disable parity generation and checking. 0
1 Enable parity generation and checking.
5:4 Parity Select 00 Odd parity. Number of 1s in the transmitted character and the 0
attached parity bit will be odd.
01 Even Parity. Number of 1s in the transmitted character and the
attached parity bit will be even.
10 Forced "1" stick parity.
11 Forced "0" stick parity.
Table 124: UART1 Line Control Register (U1LCR - address 0xE001 000C) bit description
Bit Symbol Value Description Reset value
6 Break Control 0 Disable break transmission. 0
1 Enable break transmission. Output pin UART1 TXD is forced to
logic 0 when U1LCR[6] is active high.
7 Divisor Latch 0 Disable access to Divisor Latches. 0
Access Bit (DLAB) 1 Enable access to Divisor Latches.
Table 125: UART1 Modem Control Register (U1MCR - address 0xE001 0010), LPC2144/6/8 only bit description
Bit Symbol Value Description Reset value
0 DTR Control Source for modem output pin, DTR. This bit reads as 0 when 0
modem loopback mode is active.
1 RTS Control Source for modem output pin RTS. This bit reads as 0 when 0
modem loopback mode is active.
3:2 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
4 Loopback Mode The modem loopback mode provides a mechanism to perform 0
Select diagnostic loopback testing. Serial data from the transmitter is
connected internally to serial input of the receiver. Input pin,
RXD1, has no effect on loopback and output pin, TXD1 is held
in marking state. The four modem inputs (CTS, DSR, RI and
DCD) are disconnected externally. Externally, the modem
outputs (RTS, DTR) are set inactive. Internally, the four modem
outputs are connected to the four modem inputs. As a result of
these connections, the upper four bits of the U1MSR will be
driven by the lower four bits of the U1MCR rather than the four
modem inputs in normal mode. This permits modem status
interrupts to be generated in loopback mode by writing the
lower four bits of U1MCR.
0 Disable modem loopback mode.
1 Enable modem loopback mode.
5:3 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
6 RTSen Auto-RTS control bit. 0
0 Disable auto-RTS flow control.
1 Enable auto-RTS flow control.
7 CTSen Auto-CTS control bit. 0
0 Disable auto-CTS flow control.
1 Enable auto-CTS 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.
Auto-RTS
The auto-RTS function is enabled by setting the CTSen 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, when the receiver FIFO level reaches the programmed
trigger level RTS1 is deasserted (to a high value). The sending UART may send an
additional byte after the trigger level is reached (assuming the sending UART has another
byte to send) because it may not recognize the deassertion of RTS1 until after it has
begun sending the additional byte. RTS1 is automatically reasserted (to a low value) once
the receiver FIFO has reached the previous trigger level. The reassertion of RTS1 signals
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 RTSen bit of the UART1. As long as auto-RTS is enabled the
value if the RTSen bit is read-only for software.
Example: Suppose the UART1 operating in type 550 has trigger level in U1FCR set to 0x2
then if auto-RTS is enabled the UART1 will deassert the RTS1 output as soon as the
receive FIFO contains 8 bytes (Table 123 on page 122). The RTS1 output will be
reasserted as soon as the receive FIFO hits the previous trigger level: 4 bytes.
~
~
UART1 Rx start byte N stop start bits0..7 stop start bits0..7 stop
~
~
RTS1 pin
UART1 Rx
FIFO read
~~
~ ~
UART1 Rx
N-1 N N-1 N-2 N-1 N-2 M+2 M+1 M M-1
FIFO level
~
~
Auto-CTS
The auto-CTS function is enabled by setting the CTSen bit. If auto-CTS is enabled the
transmitter circuitry in the U1TSR module checks CTS1 input before sending the next data
byte. When CTS1 is active (low), the transmitter sends the next byte. To stop the
transmitter from sending the following byte, CTS1 must be released before the middle of
the last stop bit that is currently being sent. In auto-CTS mode a change of the CTS1
signal does not trigger a modem status interrupt unless the CTS Interrupt Enable bit is set,
Delta CTS bit in the U1MSR will be set though. Table 126 lists the conditions for
generating a Modem Status interrupt.
The auto-CTS function reduces interrupts to the host system. When flow control is
enabled, a CTS1 state change does not trigger host interrupts because the device
automatically controls its own transmitter. Without auto-CTS, the transmitter sends any
data present in the transmit FIFO and a receiver overrun error can result. Figure 21
illustrates the auto-CTS functional timing.
~
~
~
~
UART1 Tx start bits0..7 stop start bits0..7 stop start bits0..7 stop
~
~
CTS1 pin
~
~
While starting transmission of the initial character the CTS1 signal is asserted.
Transmission will stall as soon as the pending transmission has completed. The UART will
continue transmitting a 1 bit as long as CTS1 is deasserted (high). As soon as CTS1 gets
deasserted transmission resumes and a start bit is sent followed by the data bits of the
next character.
10.3.11 UART1 Line Status Register (U1LSR - 0xE001 0014, Read Only)
The U1LSR is a read-only register that provides status information on the UART1 TX and
RX blocks.
Table 127: UART1 Line Status Register (U1LSR - address 0xE001 0014, read only) bit description
Bit Symbol Value Description Reset
value
0 Receiver Data U1LSR[0] is set when the U1RBR holds an unread character and is cleared when 0
Ready the UART1 RBR FIFO is empty.
(RDR) 0 U1RBR is empty.
1 U1RBR contains valid data.
Table 127: UART1 Line Status Register (U1LSR - address 0xE001 0014, read only) bit description
Bit Symbol Value Description Reset
value
1 Overrun Error The overrun error condition is set as soon as it occurs. An U1LSR read clears 0
(OE) U1LSR[1]. U1LSR[1] is set when UART1 RSR has a new character assembled and
the UART1 RBR FIFO is full. In this case, the UART1 RBR FIFO will not be
overwritten and the character in the UART1 RSR will be lost.
0 Overrun error status is inactive.
1 Overrun error status is active.
2 Parity Error When the parity bit of a received character is in the wrong state, a parity error 0
(PE) occurs. An U1LSR read clears U1LSR[2]. Time of parity error detection is
dependent on U1FCR[0].
Note: A parity error is associated with the character at the top of the UART1 RBR
FIFO.
0 Parity error status is inactive.
1 Parity error status is active.
3 Framing Error When the stop bit of a received character is a logic 0, a framing error occurs. An 0
(FE) U1LSR read clears U1LSR[3]. The time of the framing error detection is dependent
on U1FCR0. Upon detection of a framing error, the RX will attempt to resynchronize
to the data and assume that the bad stop bit is actually an early start bit. However, it
cannot be assumed that the next received byte will be correct even if there is no
Framing Error.
Note: A framing error is associated with the character at the top of the UART1 RBR
FIFO.
0 Framing error status is inactive.
1 Framing error status is active.
4 Break Interrupt When RXD1 is held in the spacing state (all 0’s) for one full character transmission 0
(BI) (start, data, parity, stop), a break interrupt occurs. Once the break condition has
been detected, the receiver goes idle until RXD1 goes to marking state (all 1’s). An
U1LSR read clears this status bit. The time of break detection is dependent on
U1FCR[0].
Note: The break interrupt is associated with the character at the top of the UART1
RBR FIFO.
0 Break interrupt status is inactive.
1 Break interrupt status is active.
5 Transmitter THRE is set immediately upon detection of an empty UART1 THR and is cleared on 1
Holding a U1THR write.
Register Empty 0 U1THR contains valid data.
(THRE)
1 U1THR is empty.
6 Transmitter TEMT is set when both U1THR and U1TSR are empty; TEMT is cleared when 1
Empty either the U1TSR or the U1THR contain valid data.
(TEMT) 0 U1THR and/or the U1TSR contains valid data.
1 U1THR and the U1TSR are empty.
7 Error in RX U1LSR[7] is set when a character with a RX error such as framing error, parity error 0
FIFO or break interrupt, is loaded into the U1RBR. This bit is cleared when the U1LSR
(RXFE) register is read and there are no subsequent errors in the UART1 FIFO.
0 U1RBR contains no UART1 RX errors or U1FCR[0]=0.
1 UART1 RBR contains at least one UART1 RX error.
Table 128: UART1 Modem Status Register (U1MSR - address 0xE001 0018), LPC2144/6/8 only bit description
Bit Symbol Value Description Reset value
0 Delta CTS Set upon state change of input CTS. Cleared on an U1MSR read. 0
0 No change detected on modem input, CTS.
1 State change detected on modem input, CTS.
1 Delta DSR Set upon state change of input DSR. Cleared on an U1MSR read. 0
0 No change detected on modem input, DSR.
1 State change detected on modem input, DSR.
2 Trailing Edge RI Set upon low to high transition of input RI. Cleared on an U1MSR read. 0
0 No change detected on modem input, RI.
1 Low-to-high transition detected on RI.
3 Delta DCD Set upon state change of input DCD. Cleared on an U1MSR read. 0
0 No change detected on modem input, DCD.
1 State change detected on modem input, DCD.
4 CTS Clear To Send State. Complement of input signal CTS. This bit is connected 0
to U1MCR[1] in modem loopback mode.
5 DSR Data Set Ready State. Complement of input signal DSR. This bit is connected 0
to U1MCR[0] in modem loopback mode.
6 RI Ring Indicator State. Complement of input RI. This bit is connected to 0
U1MCR[2] in modem loopback mode.
7 DCD Data Carrier Detect State. Complement of input DCD. This bit is connected to 0
U1MCR[3] in modem loopback mode.
Table 129: UART1 Scratch pad register (U1SCR - address 0xE001 0014) bit description
Bit Symbol Description Reset value
7:0 Pad A readable, writable byte. 0x00
Table 130: Auto-baud Control Register (U1ACR - 0xE001 0020) bit description
Bit Symbol Value Description Reset value
0 Start This bit is automatically cleared after auto-baud 0
completion.
0 Auto-baud stop (auto-baud is not running).
1 Auto-baud start (auto-baud is running).Auto-baud run
bit. This bit is automatically cleared after auto-baud
completion.
1 Mode Auto-baud mode select bit. 0
0 Mode 0.
1 Mode 1.
2 AutoRestart 0 No restart 0
1 Restart in case of time-out (counter restarts at next
UART1 Rx falling edge)
7:3 - NA Reserved, user software should not write ones to 0
reserved bits. The value read from a reserved bit is not
defined.
8 ABEOIntClr End of auto-baud interrupt clear bit (write only 0
accessible). Writing a 1 will clear the corresponding
interrupt in the U1IIR. Writing a 0 has no impact.
9 ABTOIntClr Auto-baud time-out interrupt clear bit (write only 0
accessible). Writing a 1 will clear the corresponding
interrupt in the U1IIR. Writing a 0 has no impact.
31:10 - NA Reserved, user software should not write ones to 0
reserved bits. The value read from a reserved bit is not
defined.
10.3.15 Auto-baud
The UART1 auto-baud function can be used to measure the incoming baud-rate based on
the ”AT" protocol (Hayes command). If enabled the auto-baud feature will measure the bit
time of the receive data stream and set the divisor latch registers U1DLM and U1DLL
accordingly.
Auto-baud is started by setting the U1ACR Start bit. Auto-baud can be stopped by
clearing the U1ACR Start bit. The Start bit will clear once auto-baud has finished and
reading the bit will return the status of auto-baud (pending/finished).
Two auto-baud measuring modes are available which can be selected by the U1ACR
Mode bit. In mode 0 the baud-rate is measured on two subsequent falling edges of the
UART1 Rx pin (the falling edge of the start bit and the falling edge of the least significant
bit). In mode 1 the baud-rate is measured between the falling edge and the subsequent
rising edge of the UART1 Rx pin (the length of the start bit).
The U1ACR AutoRestart bit can be used to automatically restart baud-rate measurement
if a time-out occurs (the rate measurement counter overflows). If this bit is set the rate
measurement will restart at the next falling edge of the UART1 Rx pin.
• The U1IIR ABTOInt interrupt will get set if the interrupt is enabled (U1IER ABToIntEn
is set and the auto-baud rate measurement counter overflows).
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
• The U1IIR ABEOInt interrupt will get set if the interrupt is enabled (U1IER ABEOIntEn
is set and the auto-baud has completed successfully).
(6)
2 × P CLK PCLK
ratemin = ------------------------- ≤ UART 1 baudrate ≤ ------------------------------------------------------------------------------------------------------------ = ratemax
16 × 2 15 16 × ( 2 + databits + paritybits + stopbits )
1. On U1ACR Start bit setting, the baud-rate measurement counter is reset and the
UART1 U1RSR is reset. The U1RSR baud rate is switch to the highest rate.
2. A falling edge on UART1 Rx pin triggers the beginning of the start bit. The rate
measuring counter will start counting PCLK cycles optionally pre-scaled by the
fractional baud-rate generator.
3. During the receipt of the start bit, 16 pulses are generated on the RSR baud input with
the frequency of the (fractional baud-rate pre-scaled) UART1 input clock,
guaranteeing the start bit is stored in the U1RSR.
4. During the receipt of the start bit (and the character LSB for mode = 0) the rate
counter will continue incrementing with the pre-scaled UART1 input clock (PCLK).
5. If Mode = 0 then the rate counter will stop on next falling edge of the UART1 Rx pin. If
Mode = 1 then the rate counter will stop on the next rising edge of the UART1 Rx pin.
6. The rate counter is loaded into U1DLM/U1DLL and the baud-rate will be switched to
normal operation. After setting the U1DLM/U1DLL the end of auto-baud interrupt
U1IIR ABEOInt will be set, if enabled. The U1RSR will now continue receiving the
remaining bits of the ”A/a" character.
start bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 parity stop
U1ACR Start
rate counter
16xbaud_rate
16 cycles 16 cycles
a) Mode 0 (Start bit and LSB are used for auto-baud)
start bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 parity stop
U1ACR Start
rate counter
16xbaud_rate
16 cycles
b) Mode 1 (only Start bit is used for auto-baud)
Table 131 describes how to use TXEn bit in order to achieve software flow control.
Table 131: UART1 Transmit Enable Register (U1TER - address 0xE001 0030) bit description
Bit Symbol Description Reset value
6:0 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
7 TXEN When this bit is 1, as it is after a Reset, data written to the THR 1
is output on the TXD pin as soon as any preceding data has
been sent. If this bit cleared to 0 while a character is being sent,
the transmission of that character is completed, but no further
characters are sent until this bit is set again. In other words, a 0
in this bit blocks the transfer of characters from the THR or TX
FIFO into the transmit shift register. Software can clear this bit
when it detects that the a hardware-handshaking TX-permit
signal (LPC2144/6/8: CTS - otherwise any GPIO/external
interrupt line) has gone false, or 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.
10.4 Architecture
The architecture of the UART1 is shown below in the block diagram.
The VPB interface provides a communications link between the CPU or host and the
UART1.
The UART1 receiver block, U1RX, monitors the serial input line, RXD1, for valid input. The
UART1 RX Shift Register (U1RSR) accepts valid characters via RXD1. After a valid
character is assembled in the U1RSR, it is passed to the UART1 RX Buffer Register FIFO
to await access by the CPU or host via the generic host interface.
The UART1 transmitter block, U1TX, accepts data written by the CPU or host and buffers
the data in the UART1 TX Holding Register FIFO (U1THR). The UART1 TX Shift Register
(U1TSR) reads the data stored in the U1THR and assembles the data to transmit via the
serial output pin, TXD1.
The UART1 Baud Rate Generator block, U1BRG, generates the timing enables used by
the UART1 TX block. The U1BRG clock input source is the VPB clock (PCLK). The main
clock is divided down per the divisor specified in the U1DLL and U1DLM registers. This
divided down clock is a 16x oversample clock, NBAUDOUT.
The modem interface contains registers U1MCR and U1MSR. This interface is
responsible for handshaking between a modem peripheral and the UART1.
The interrupt interface contains registers U1IER and U1IIR. The interrupt interface
receives several one clock wide enables from the U1TX and U1RX blocks.
Status information from the U1TX and U1RX is stored in the U1LSR. Control information
for the U1TX and U1RX is stored in the U1LCR.
MODEM U1TX
NTXRDY
TXD1
U1THR U1TSR
CTS
DSR U1MSR
RI U1BRG
DCD
DTR
U1DLL NBAUDOUT
RTS
U1MCR
U1DLM RCLK
U1RX NRXRDY
INTERRUPT
RXD1
U1RBR U1RSR
U1INTR U1IER
U1IIR
U1FCR
U1LSR
U1SCR
U1LCR
PA[2:0]
PSEL
PSTB
PWRITE
VPB
PD[7:0] INTERFACE DDIS
AR
MR
PCLK
11.1 Features
• Standard I2C compliant bus interfaces that may be configured as Master, Slave, or
Master/Slave.
• Arbitration between simultaneously transmitting masters without corruption of serial
data on the bus.
• Programmable clock to allow adjustment of I2C transfer rates.
• Bidirectional data transfer between masters and slaves.
• Serial clock synchronization allows devices with different bit rates to communicate via
one serial bus.
• Serial clock synchronization can be used as a handshake mechanism to suspend and
resume serial transfer.
• The I2C-bus may be used for test and diagnostic purposes.
11.2 Applications
Interfaces to external I2C standard parts, such as serial RAMs, LCDs, tone generators,
etc.
11.3 Description
A typical I2C-bus configuration is shown in Figure 24. Depending on the state of the
direction bit (R/W), two types of data transfers are possible on the I2C-bus:
• Data transfer from a master transmitter to a slave receiver. The first byte transmitted
by the master is the slave address. Next follows a number of data bytes. The slave
returns an acknowledge bit after each received byte.
• Data transfer from a slave transmitter to a master receiver. The first byte (the slave
address) is transmitted by the master. The slave then returns an acknowledge bit.
Next follows the data bytes transmitted by the slave to the master. The master returns
an acknowledge bit after all received bytes other than the last byte. At the end of the
last received byte, a “not acknowledge” is returned. The master device generates all
of the serial clock pulses and the START and STOP conditions. A transfer is ended
with a STOP condition or with a repeated START condition. Since a repeated START
condition is also the beginning of the next serial transfer, the I2C-bus will not be
released.
The LPC2141/2/4/6/8 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 compile with entire I2C specification, supporting the ability to turn
power off to the LPC2141/2/4/6/8 without causing a problem with other devices on the
same I2C-bus (see "The I2C-bus specification" description under the heading
"Fast-Mode", and notes for the table titled "Characteristics of the SDA and SCL I/O stages
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Pull-up Pull-up
resisor resisor
SDA
I2 C BUS
SCL
SDA SCL
OTHER DEVICE OTHER DEVICE
LPC2141/2/4/6/8 WITH I 2C WITH I 2 C
INTERFACE INTERFACE
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.
The first byte transmitted contains the slave address of the receiving device (7 bits) and
the data direction bit. In this mode the data direction bit (R/W) should be 0 which means
Write. The first byte transmitted contains the slave address and Write bit. Data is
transmitted 8 bits at a time. After each byte is transmitted, an acknowledge bit is received.
START and STOP conditions are output to indicate the beginning and the end of a serial
transfer.
The I2C interface will enter master transmitter mode when software sets the STA bit. The
I2C logic will send the START condition as soon as the bus is free. After the START
condition is transmitted, the SI bit is set, and the status code in the I2STAT register is
0x08. This status code is used to vector to a state service routine which will load the slave
address and Write bit to the I2DAT register, and then clear the SI bit. SI is cleared by
writing a 1 to the SIC bit in the I2CONCLR register.
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 148 to Table 151.
“0” - Write
“1” - Read Data Transferred
(n Bytes + Acknowledge)
When the slave address and data direction bit have been transmitted and an acknowledge
bit has been received, the SI bit is set, and the Status Register will show the status code.
For master mode, the possible status codes are 0x40, 0x48, or 0x38. For slave mode, the
possible status codes are 0x68, 0x78, or 0xB0. For details, refer to Table 149.
“0” - Write
“1” - Read Data Transferred
(n Bytes + Acknowledge)
After a repeated START condition, I2C may switch to the master transmitter mode.
Data Transferred
(n Bytes + Acknowledge)
Fig 27. A Master Receiver switches to Master Transmitter after sending Repeated START
I2EN must be set to 1 to enable the I2C function. AA bit must be set to 1 to acknowledge
its own slave address or the general call address. The STA, STO and SI bits are set to 0.
After I2ADR and I2CONSET are initialized, the I2C interface waits until it is addressed by
its own address or general address followed by the data direction bit. If the direction bit is
0 (W), it enters slave receiver mode. If the direction bit is 1 (R), it enters slave transmitter
mode. After the address and direction bit have been received, the SI bit is set and a valid
status code can be read from the Status register (I2STAT). Refer to Table 150 for the
status codes and actions.
“0” - Write
“1” - Read Data Transferred
(n Bytes + Acknowledge)
“0” - Write
“1” - Read Data Transferred
(n Bytes + Acknowledge)
The output for I2C is a special pad designed to conform to the I2C specification.
INPUT COMPARATOR
FILTER
SDA
OUTPUT
SHIFT REGISTER ACK
STAGE
I2DAT
8
APB BUS
BIT COUNTER/
ARBITRATION &
SYNC LOGIC PCLK
INPUT
TIMING &
FILTER
CONTROL
SCL LOGIC
I2CONSET
I2CONCLR CONTROL REGISTER & SCL DUTY
I2SCLH CYCLE REGISTERS
I2SCLL
16
I2STAT
8
11.6.3 Comparator
The comparator compares the received 7-bit slave address with its own slave address (7
most significant bits in I2ADR). It also compares the first received 8-bit byte with the
general call address (0x00). If an equality is found, the appropriate status bits are set and
an interrupt is requested.
Arbitration may also be lost in the master receiver mode. Loss of arbitration in this mode
can only occur while the I2C block is returning a “not acknowledge: (logic 1) to the bus.
Arbitration is lost when another device on the bus pulls this signal LOW. Since this can
occur only at the end of a serial byte, the I2C block generates no further clock pulses.
Figure 31 shows the arbitration procedure.
SDA Line
SCL Line 1 2 3 4 8 9
ACK
The synchronization logic will synchronize the serial clock generator with the clock pulses
on the SCL line from another device. If two or more master devices generate clock pulses,
the “mark” duration is determined by the device that generates the shortest “marks,” and
the “space” duration is determined by the device that generates the longest “spaces”.
Figure 32 shows the synchronization procedure.
SDA Line
SCL Line
(2)
High Low
period period
A slave may stretch the space duration to slow down the bus master. The space duration
may also be stretched for handshaking purposes. This can be done after each bit or after
a complete byte transfer. the I2C block will stretch the SCL space duration after a byte has
been transmitted or received and the acknowledge bit has been transferred. The serial
interrupt flag (SI) is set, and the stretching continues until the serial interrupt flag is
cleared.
The contents of the I2C control register may be read as I2CONSET. Writing to I2CONSET
will set bits in the I2C control register that correspond to ones in the value written.
Conversely, writing to I2CONCLR will clear bits in the I2C control register that correspond
to ones in the value written.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
11.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 the
corresponding bit in the I2C control register to be set. Writing a zero has no effect.
Table 136: 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.
3 SI I2C interrupt flag. 0
4 STO STOP flag. See the text below. 0
5 STA START flag. See the text below. 0
6 I2EN I2C interface enable. See the text below. 0
7 - Reserved. User software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
I2EN I2C Interface Enable. When I2EN is 1, the I2C interface is enabled. I2EN can be
cleared by writing 1 to the I2ENC bit in the I2CONCLR register. When I2EN is 0, the I2C
interface is disabled.
When I2EN is “0”, the SDA and SCL input signals are ignored, the I2C block is in the “not
addressed” slave state, and the STO bit is forced to “0”.
I2EN should not be used to temporarily release the I2C-bus since, when I2EN is reset, the
I2C-bus status is lost. The AA flag should be used instead.
STA is the START flag. Setting this bit causes the I2C interface to enter master mode and
transmit a START condition or transmit a repeated START condition if it is already in
master mode.
When STA is 1 and the I2C interface is not already in master mode, it enters master mode,
checks the bus and generates a START condition if the bus is free. If the bus is not free, it
waits for a STOP condition (which will free the bus) and generates a START condition after
a delay of a half clock period of the internal clock generator. If the I2C interface is already
in master mode and data has been transmitted or received, it transmits a repeated START
condition. STA may be set at any time, including when the I2C interface is in an addressed
slave mode.
STA can be cleared by writing 1 to the STAC bit in the I2CONCLR register. When STA is 0,
no START condition or repeated START condition will be generated.
If STA and STO are both set, then a STOP condition is transmitted on the I2C-bus if it the
interface is in master mode, and transmits a START condition thereafter. If the I2C
interface is in slave mode, an internal STOP condition is generated, but is not transmitted
on the bus.
STO is the STOP flag. Setting this bit causes the I2C interface to transmit a STOP
condition in master mode, or recover from an error condition in slave mode. When STO is
1 in master mode, a STOP condition is transmitted on the I2C-bus. When the bus detects
the STOP condition, STO is cleared automatically.
In slave mode, setting this bit can recover from an error condition. In this case, no STOP
condition is transmitted to the bus. The hardware behaves as if a STOP condition has
been received and it switches to “not addressed” slave receiver mode. The STO flag is
cleared by hardware automatically.
SI is the I2C Interrupt Flag. This bit is set when the I2C state changes. However, entering
state F8 does not set SI since there is nothing for an interrupt service routine to do in that
case.
While SI is set, the low period of the serial clock on the SCL line is stretched, and the
serial transfer is suspended. When SCL is high, it is unaffected by the state of the SI flag.
SI must be reset by software, by writing a 1 to the SIC bit in I2CONCLR register.
AA is the Assert Acknowledge Flag. When set to 1, an acknowledge (low level to SDA) will
be returned during the acknowledge clock pulse on the SCL line on the following
situations:
The AA bit can be cleared by writing 1 to the AAC bit in the I2CONCLR register. When AA
is 0, a not acknowledge (high level to SDA) will be returned during the acknowledge clock
pulse on the SCL line on the following situations:
1. A data byte has been received while the I2C is in the master receiver mode.
2. A data byte has been received while the I2C is in the addressed slave receiver mode.
Table 137: 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 NA
value read from a reserved bit is not defined.
2 AAC Assert acknowledge Clear bit.
3 SIC I2C interrupt Clear bit. 0
4 - Reserved. User software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
Table 137: I2C Control Set register (I2CONCLR: I2C0, I2C0CONCLR - address 0xE001 C018
and I2C1, I2C1CONCLR - address 0xE005 C018) bit description
Bit Symbol Description Reset
value
5 STAC START flag Clear bit. 0
6 I2ENC I2C interface Disable bit. 0
7 - Reserved. User software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
AAC is the Assert Acknowledge Clear bit. Writing a 1 to this bit clears the AA bit in the
I2CONSET register. Writing 0 has no effect.
SIC is the I2C Interrupt Clear bit. Writing a 1 to this bit clears the SI bit in the I2CONSET
register. Writing 0 has no effect.
STAC is the Start flag Clear bit. Writing a 1 to this bit clears the STA bit in the I2CONSET
register. Writing 0 has no effect.
I2ENC is the I2C Interface Disable bit. Writing a 1 to this bit clears the I2EN bit in the
I2CONSET register. Writing 0 has no effect.
11.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 138: 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 148 to Table 151.
11.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 can
read 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 is
always shifted from right to left: the first bit to be transmitted 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.
Table 139: 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.
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
11.7.5 I2C Slave Address register (I2ADR: I2C0, I2C0ADR - 0xE001 C00C and
I2C1, I2C1ADR - address 0xE005 C00C)
These registers are readable and writable, and is only used when an I2C interface is set to
slave mode. In master mode, this register has no effect. The LSB of I2ADR is the general
call bit. When this bit is set, the general call address (0x00) is recognized.
Table 140: I2C Slave Address register (I2ADR: I2C0, I2C0ADR - address 0xE001 C00C and
I2C1, I2C1ADR - address 0xE005 C00C) bit description
Bit Symbol Description Reset value
0 GC General Call enable bit. 0
7:1 Address The I2C device address for slave mode. 0x00
11.7.6 I2C SCL High duty cycle register (I2SCLH: I2C0, I2C0SCLH -
0xE001 C010 and I2C1, I2C1SCLH - 0xE0015 C010)
Table 141: I2C SCL High Duty Cycle register (I2SCLH: I2C0, I2C0SCLH - address
0xE001 C010 and I2C1, I2C1SCLH - address 0xE005 C010) bit description
Bit Symbol Description Reset value
15:0 SCLH Count for SCL HIGH time period selection. 0x0004
11.7.7 I2C SCL Low duty cycle register (I2SCLL: I2C0 - I2C0SCLL:
0xE001 C014; I2C1 - I2C1SCLL: 0xE0015 C014)
Table 142: I2C SCL Low Duty Cycle register (I2SCLL: I2C0, I2C0SCLL - address 0xE001 C014
and I2C1, I2C1SCLL - address 0xE005 C014) bit description
Bit Symbol Description Reset value
15:0 SCLL Count for SCL LOW time period selection. 0x0004
11.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 is
determined by the following formula (PCLK is the frequency of the peripheral bus VPB):
(7)
PCLK
I 2 C bitfrequency = ---------------------------------------------------------
I2CSCLH + I2CSCLL
The values for I2SCLL and I2SCLH should not necessarily be the same. Software can set
different duty cycles on SCL by setting these two registers. For example, the I2C-bus
specification defines the SCL low time and high time at different values for a 400 kHz I2C
rate. The value of the register must ensure that the data rate is in the I2C data rate range
of 0 through 400 kHz. Each register value must be greater than or equal to 4. Table 143
gives some examples of I2C-bus rates based on PCLK frequency and I2SCLL and
I2SCLH values.
• Master Transmitter
• Master Receiver
• Slave Receiver
• Slave Transmitter
Data transfers in each mode of operation are shown in Figures 33 to 37. Table 144 lists
abbreviations used in these figures when describing the I2C operating modes.
In Figures 33 to 37, circles are used to indicate when the serial interrupt flag is set. The
numbers in the circles show the status code held in the I2STAT register. At these points, a
service routine must be executed to continue or complete the serial transfer. These
service routines are not critical since the serial transfer is suspended until the serial
interrupt flag is cleared by software.
When a serial interrupt routine is entered, the status code in I2STAT is used to branch to
the appropriate service routine. For each status code, the required software action and
details of the following serial transfer are given in tables from Table 148 to Table 152.
The I2C rate must also be configured in the I2SCLL and I2SCLH registers. I2EN must be
set to logic 1 to enable the I2C block. If the AA bit is reset, the I2C block will not
acknowledge its own slave address or the general call address in the event of another
device becoming master of the bus. In other words, if AA is reset, the I2C interface cannot
enter a slave mode. STA, STO, and SI must be reset.
The master transmitter mode may now be entered by setting the STA bit. The I2C logic will
now test the I2C-bus and generate a start condition as soon as the bus becomes free.
When a START condition is transmitted, the serial interrupt flag (SI) is set, and the status
code in the status register (I2STAT) will be 0x08. This status code is used by the interrupt
service routine to enter the appropriate state service routine that loads I2DAT with the
slave address and the data direction bit (SLA+W). The SI bit in I2CON must then be reset
before the serial transfer can continue.
When the slave address and the direction bit have been transmitted and an
acknowledgment bit has been received, the serial interrupt flag (SI) is set again, and a
number of status codes in I2STAT are possible. There are 0x18, 0x20, or 0x38 for the
master mode and also 0x68, 0x78, or 0xB0 if the slave mode was enabled (AA = logic 1).
The appropriate action to be taken for each of these status codes is detailed in Table 148.
After a repeated start condition (state 0x10). The I2C block may switch to the master
receiver mode by loading I2DAT with SLA+R).
When the slave address and the data direction bit have been transmitted and an
acknowledgment bit has been received, the serial interrupt flag (SI) is set again, and a
number of status codes in I2STAT are possible. These are 0x40, 0x48, or 0x38 for the
master mode and also 0x68, 0x78, or 0xB0 if the slave mode was enabled (AA = 1). The
appropriate action to be taken for each of these status codes is detailed in Table 149. After
a repeated start condition (state 0x10), the I2C block may switch to the master transmitter
mode by loading I2DAT with SLA+W.
The upper 7 bits are the address to which the I2C block will respond when addressed by a
master. If the LSB (GC) is set, the I2C block will respond to the general call address
(0x00); otherwise it ignores the general call address.
Table 147: 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 by
its own slave address followed by the data direction bit which must be “0” (W) for the I2C
block to operate in the slave receiver mode. After its own slave address and the W bit have
been received, the serial interrupt flag (SI) is set and a valid status code can be read from
I2STAT. This status code is used to vector to a state service routine. The appropriate
action to be taken for each of these status codes is detailed in Table 104. The slave
receiver mode may also be entered if arbitration is lost while the I2C block is in the master
mode (see status 0x68 and 0x78).
If the AA bit is reset during a transfer, the I2C block will return a not acknowledge (logic 1)
to SDA after the next received data byte. While AA is reset, the I2C block does not respond
to its own slave address or a general call address. However, the I2C-bus is still monitored
and address recognition may be resumed at any time by setting AA. This means that the
AA bit may be used to temporarily isolate the I2C block from the I2C-bus.
MT
Successful
transmission to
S SLA W A DATA A P
a Slave
Receiver
10H
Not Acknowledge
received after the A P R
Slave Address
20H
To Master
receive mode,
Not Acknowledge entry
received after a Data A P = MR
byte
30H
Arbitration lost in
Slave Address or A OR A Other Master A OR A Other Master
continues continues
Data byte
38H 38H
Arbitration lost
and addressed as A Other Master
continues
Slave
To corresponding states in
68H 78H B0H
Slave mode
DATA A Any number of data bytes and their associated Acknowledge bits
n 2C bus
This number (contained in I2STA) corresponds to a defined state of the I
MR
Successful
transmission to a S SLA R A DATA A DATA A P
Slave Transmitter
10H
Not Acknowledge
received after the Slave A P W
Address
48H
To Master
transmit mode,
entry = MT
38H 38H
To corresponding
states in Slave mode
68H 78H B0H
DATA A Any number of data bytes and their associated Acknowledge bits
n 2C bus
This number (contained in I2STA) corresponds to a defined state of the I
88H
68H
98h
78h
DATA A Any number of data bytes and their associated Acknowledge bits
2
n This number (contained in I2STA) corresponds to a defined state of theC Ibus
B0H
Last data byte transmitted.
Switched to Not Addressed
A ALL ONES P OR S
Slave (AA bit in I2CON =
“0”)
C8H
DATA A Any number of data bytes and their associated Acknowledge bits
n 2C
This number (contained in I2STA) corresponds to a defined state of the I bus
If the AA bit is reset during a transfer, the I2C block will transmit the last byte of the transfer
and enter state 0xC0 or 0xC8. The I2C block is switched to the not addressed slave mode
and will ignore the master receiver if it continues the transfer. Thus the master receiver
receives all 1s as serial data. While AA is reset, the I2C block does not respond to its own
slave address or a general call address. However, the I2C-bus is still monitored, and
address recognition may be resumed at any time by setting AA. This means that the AA
bit may be used to temporarily isolate the I2C block from the I2C-bus.
If the I2C hardware detects a repeated START condition on the I2C-bus before generating
a repeated START condition itself, it will release the bus, and no interrupt request is
generated. If another master frees the bus by generating a STOP condition, the I2C block
will transmit a normal START condition (state 0x08), and a retry of the total serial data
transfer can commence.
If the STA flag in I2CON is set by the routines which service these states, then, if the bus
is free again, a START condition (state 0x08) is transmitted without intervention by the
CPU, and a retry of the total serial transfer can commence.
If the SDA line is obstructed by another device on the bus (e.g., a slave device out of bit
synchronization), the problem can be solved by transmitting additional clock pulses on the
SCL line (see Figure 39). The I2C hardware transmits additional clock pulses when the
STA flag is set, but no START condition can be generated because the SDA line is pulled
LOW while the I2C-bus is considered free. The I2C hardware attempts to generate a
START condition after every two additional clock pulses on the SCL line. When the SDA
line is eventually released, a normal START condition is transmitted, state 0x08 is entered,
and the serial transfer continues.
If a forced bus access occurs or a repeated START condition is transmitted while SDA is
obstructed (pulled LOW), the I2C hardware performs the same action as described above.
In each case, state 0x08 is entered after a successful START condition is transmitted and
normal serial transfer continues. Note that the CPU is not involved in solving these bus
hang-up problems.
The I2C hardware only reacts to a bus error when it is involved in a serial transfer either as
a master or an addressed slave. When a bus error is detected, the I2C block immediately
switches to the not addressed slave mode, releases the SDA and SCL lines, sets the
interrupt flag, and loads the status register with 0x00. This status code may be used to
vector to a state service routine which either attempts the aborted serial transfer again or
simply recovers from the error condition as shown in Table 152.
Time limit
STA Flag
STO Flag
SDA Line
SCL Line
Start condition
STA Flag
(2) (3)
(1) (1)
SDA Line
SCL Line
Start condition
Fig 39. Recovering from a bus obstruction caused by a low level on SDA
• The 26 state service routines providing support for all four I2C operating modes.
11.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.
The I2C hardware now begins checking the I2C-bus for its own slave address and general
call. If the general call or the own slave address is detected, an interrupt is requested and
I2STAT is loaded with the appropriate state information.
1. Load I2ADR with own Slave Address, enable general call recognition if needed.
2. Enable I2C interrupt.
3. Write 0x44 to I2CONSET to set the I2EN and AA bits, enabling Slave functions. For
Master only functions, write 0x40 to I2CONSET.
1. Load I2DAT with first data byte from Master Transmit buffer.
2. Write 0x04 to I2CONSET to set the AA bit.
3. Write 0x08 to I2CONCLR to clear the SI flag.
4. Increment Master Transmit buffer pointer.
5. Exit
1. Decrement the Master data counter, skip to step 5 if not the last data byte.
2. Write 0x14 to I2CONSET to set the STO and AA bits.
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
5. Exit.
1. Read data byte from I2DAT into the Slave Receive buffer.
2. Decrement the Slave data counter, skip to step 5 if not the last data byte.
3. Write 0x0C to I2CONCLR to clear the SI flag and the AA bit.
4. Exit.
5. Write 0x04 to I2CONSET to set the AA bit.
6. Write 0x08 to I2CONCLR to clear the SI flag.
7. Increment Slave Receive buffer pointer.
8. Exit
1. Read data byte from I2DAT into the Slave Receive buffer.
2. Write 0x0C to I2CONCLR to clear the SI flag and the AA bit.
3. Exit
1. Load I2DAT from Slave Transmit buffer with first data byte.
2. Write 0x04 to I2CONSET to set the AA bit.
3. Write 0x08 to I2CONCLR to clear the SI flag.
4. Set up Slave Transmit mode data buffer.
5. Increment Slave Transmit buffer pointer.
6. Exit
1. Load I2DAT from Slave Transmit buffer with first data byte.
2. Write 0x24 to I2CONSET to set the STA and AA bits.
12.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
12.2 Description
In the first part of the timing diagram, note two points. First, the SPI is illustrated with
CPOL set to both 0 and 1. The second point to note is the activation and de-activation of
the SSEL signal. When CPHA = 1, the SSEL signal will always go inactive between data
transfers. This is not guaranteed when CPHA = 0 (the signal can remain active).
SCK (CPOL = 0)
SCK (CPOL = 1)
SSEL
CPHA = 0
Cycle # CPHA = 0 1 2 3 4 5 6 7 8
MOSI (CPHA = 0) BIT 1 BIT 2 BIT 3 BIT 4 BIT 5 BIT 6 BIT 7 BIT 8
MISO (CPHA = 0) BIT 1 BIT 2 BIT 3 BIT 4 BIT 5 BIT 6 BIT 7 BIT 8
CPHA = 1
Cycle # CPHA = 1 1 2 3 4 5 6 7 8
MOSI (CPHA = 1) BIT 1 BIT 2 BIT 3 BIT 4 BIT 5 BIT 6 BIT 7 BIT 8
MISO (CPHA = 1) BIT 1 BIT 2 BIT 3 BIT 4 BIT 5 BIT 6 BIT 7 BIT 8
The data and clock phase relationships are summarized in Table 153. This table
summarizes the following for each setting of CPOL and CPHA.
The definition of when an 8 bit transfer starts and stops is dependent on whether a device
is a master or a slave, and the setting of the CPHA variable.
When a device is a master, the start of a transfer is indicated by the master having a byte
of data that is ready to be transmitted. At this point, the master can activate the clock, and
begin the transfer. The transfer ends when the last clock cycle of the transfer is complete.
When a device is a slave, and CPHA is set to 0, the transfer starts when the SSEL signal
goes active, and ends when SSEL goes inactive. When a device is a slave, and CPHA is
set to 1, the transfer starts on the first clock edge when the slave is selected, and ends on
the last clock edge where data is sampled.
The SPI control register contains a number of programmable bits used to control the
function of the SPI block. The settings for this register must be set up prior to a given data
transfer taking place.
The SPI status register contains read only bits that are used to monitor the status of the
SPI interface, including normal functions, and exception conditions. The primary purpose
of this register is to detect completion of a data transfer. This is indicated by the SPIF bit.
The remaining bits in the register are exception condition indicators. These exceptions will
be described later in this section.
The SPI data register is used to provide the transmit and receive data bytes. An internal
shift register in the SPI block logic is used for the actual transmission and reception of the
serial data. Data is written to the SPI data register for the transmit case. There is no buffer
between the data register and the internal shift register. A write to the data register goes
directly into the internal shift register. Therefore, data should only be written to this register
when a transmit is not currently in progress. Read data is buffered. When a transfer is
complete, the receive data is transferred to a single byte data buffer, where it is later read.
A read of the SPI data register returns the value of the read data buffer.
The SPI clock counter register controls the clock rate when the SPI block is in master
mode. This needs to be set prior to a transfer taking place, when the SPI block is a master.
This register has no function when the SPI block is a slave.
The I/Os for this implementation of SPI are standard CMOS I/Os. The open drain SPI
option is not implemented in this design. When a device is set up to be a slave, its I/Os are
only active when it is selected by the SSEL signal being active.
1. Set the SPI clock counter register to the desired clock rate.
2. Set the SPI control register to the desired settings.
3. Write the data to transmitted to the SPI data register. This write starts the SPI data
transfer.
4. Wait for the SPIF bit in the SPI status register to be set to 1. The SPIF bit will be set
after the last cycle of the SPI data transfer.
5. Read the SPI status register.
6. Read the received data from the SPI data register (optional).
7. Go to step 3 if more data is required to transmit.
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
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, a
write to this register is required in order to clear the SPIF status bit.
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 register
must take place, in order to clear the SPIF status bit.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
Table 156: SPI Control Register (S0SPCR - address 0xE002 0000) bit description
Bit Symbol Value Description Reset
value
1:0 - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is not
defined.
2 BitEnable 0 The SPI controller sends and receives 8 bits of data per 0
transfer.
1 The SPI controller sends and receives the number of bits
selected by bits 11:8.
3 CPHA Clock phase control determines the relationship between 0
the data and the clock on SPI transfers, and controls
when a slave transfer is defined as starting and ending.
Data is sampled on the first clock edge of SCK. A transfer
0 starts and ends with activation and deactivation of the
SSEL signal.
1 Data is sampled on the second clock edge of the SCK. A
transfer starts with the first clock edge, and ends with the
last sampling edge when the SSEL signal is active.
4 CPOL Clock polarity control. 0
0 SCK is active high.
1 SCK is active low.
5 MSTR Master mode select. 0
0 The SPI operates in Slave mode.
1 The SPI operates in Master mode.
Table 156: SPI Control Register (S0SPCR - address 0xE002 0000) bit description
Bit Symbol Value Description Reset
value
6 LSBF LSB First controls which direction each byte is shifted 0
when transferred.
0 SPI data is transferred MSB (bit 7) first.
1 SPI data is transferred LSB (bit 0) first.
7 SPIE 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.
11:8 BITS When bit 2 of this register is 1, this field controls the 0000
number of bits per transfer:
1000 8 bits per transfer
1001 9 bits per transfer
1010 10 bits per transfer
1011 11 bits per transfer
1100 12 bits per transfer
1101 13 bits per transfer
1110 14 bits per transfer
1111 15 bits per transfer
0000 16 bits per transfer
15:12 - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is not
defined.
Table 157: SPI Status Register (S0SPSR - address 0xE002 0004) bit description
Bit Symbol Description Reset value
2:0 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
3 ABRT Slave abort. When 1, this bit indicates that a slave abort has 0
occurred. This bit is cleared by reading this register.
4 MODF Mode fault. when 1, this bit indicates that a Mode fault error has 0
occurred. This bit is cleared by reading this register, then writing
the SPI0 control register.
Table 157: SPI Status Register (S0SPSR - address 0xE002 0004) bit description
Bit Symbol Description Reset value
5 ROVR Read overrun. When 1, this bit indicates that a read overrun has 0
occurred. This bit is cleared by reading this register.
6 WCOL Write collision. When 1, this bit indicates that a write collision 0
has occurred. This bit is cleared by reading this register, then
accessing the SPI data register.
7 SPIF SPI transfer complete flag. When 1, this bit indicates when a SPI 0
data transfer is complete. When a master, this bit is set at the
end of the last cycle of the transfer. When a slave, this bit is set
on the last data sampling edge of the SCK. This bit is cleared by
first reading this register, then accessing the SPI data register.
Note: this is not the SPI interrupt flag. This flag is found in the
SPINT register.
Table 158: SPI Data Register (S0SPDR - address 0xE002 0008) bit description
Bit Symbol Description 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.
Table 159: SPI Clock Counter Register (S0SPCCR - address 0xE002 000C) bit description
Bit Symbol Description Reset value
7:0 Counter SPI0 Clock counter setting. 0x00
The SPI0 rate may be calculated as: PCLK / SPCCR0 value. The PCLK rate is
CCLK /VPB divider rate as determined by the VPBDIV register contents.
Table 160: SPI Interrupt register (S0SPINT - address 0xE002 001C) bit description
Bit Symbol Description Reset value
0 SPI Interrupt SPI interrupt flag. Set by the SPI interface to generate an interrupt. Cleared 0
Flag by writing a 1 to this bit.
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 by
interrupt handling software.
7:1 - Reserved, user software should not write ones to reserved bits. The value NA
read from a reserved bit is not defined.
12.5 Architecture
The block diagram of the SPI solution implemented in SPI0 interface is shown in the
Figure 41.
MOSI_IN
MOSI_OUT
MISO_IN
MISO_OUT
SPI SHIFT REGISTER
SCK_IN
SCK_OUT
SPI CLOCK SS_IN
GENERATOR &
SPI Interrupt DETECTOR
SPI REGISTER
VPB Bus INTERFACE
SCK_OUT_EN
MOSI_OUT_EN
OUTPUT MISO_OUT_EN
ENABLE
LOGIC
13.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
13.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 data
transfer. Data transfers are in principle full duplex, with frames of 4 to 16 bits of data
flowing from the master to the slave and from the slave to the master. In practice it is often
the case that only one of these data flows carries meaningful data.
CLK
FS
4 to 16 bits
CLK
FS
4 to 16 bits 4 to 16 bits
b) Continuous/back-to-back frames
transfer
Fig 42. Texas Instruments synchronous serial frame format: a) single and b) continuous/back-to-back two frames
transfer
For device configured as a master in this mode, CLK and FS are forced LOW, and the
transmit data line DX is tristated whenever the SSP is idle. Once the bottom entry of the
transmit FIFO contains data, FS is pulsed HIGH for one CLK period. The value to be
transmitted is also transferred from the transmit FIFO to the serial shift register of the
transmit logic. On the next rising edge of CLK, the MSB of the 4 to 16-bit data frame is
shifted out on the DX pin. Likewise, the MSB of the received data is shifted onto the DR
pin by the off-chip serial slave device.
Both the SSP and the off-chip serial slave device then clock each data bit into their serial
shifter on the falling edge of each CLK. The received data is transferred from the serial
shifter to the receive FIFO on the first rising edge of CLK after the LSB has been latched.
The CPHA control bit selects the clock edge that captures data and allows it to change
state. It has the most impact on the first bit transmitted by either allowing or not allowing a
clock transition before the first data capture edge. When the CPHA phase control bit is
LOW, data is captured on the first clock edge transition. If the CPHA clock phase control
bit is HIGH, data is captured on the second clock edge transition.
SCK
SSEL
4 to 16 bits
a) Motorola SPI frame format (single transfer) with CPOL=0 and CPHA=0
SCK
SSEL
4 to 16 bits 4 to 16 bits
b) Motorola SPI frame format (continuous transfer) with CPOL=0 and CPHA=0
Fig 43. SPI frame format with CPOL=0 and CPHA=0 (a) single and b) continuous transfer)
One half SCK period later, valid master data is transferred to the MOSI pin. Now that both
the master and slave data have been set, the SCK master clock pin goes HIGH after one
further half SCK period.
The data is now captured on the rising and propagated on the falling edges of the SCK
signal.
In the case of a single word transmission, after all bits of the data word have been
transferred, the SSEL line is returned to its idle HIGH state one SCK period after the last
bit has been captured.
However, in the case of continuous back-to-back transmissions, the SSEL signal must be
pulsed HIGH between each data word transfer. This is because the slave select pin
freezes the data in its serial peripheral register and does not allow it to be altered if the
CPHA bit is logic zero. Therefore the master device must raise the SSEL pin of the slave
device between each data transfer to enable the serial peripheral data write. On
completion of the continuous transfer, the SSEL pin is returned to its idle state one SCK
period after the last bit has been captured.
SCK
SSEL
4 to 16 bits
a) Motorola SPI frame format (single transfer) with CPOL=0 and CPHA=1
Data is then captured on the falling edges and propagated on the rising edges of the SCK
signal.
In the case of a single word transfer, after all bits have been transferred, the SSEL line is
returned to its idle HIGH state one SCK period after the last bit has been captured.
For continuous back-to-back transfers, the SSEL pin is held LOW between successive
data words and termination is the same as that of the single word transfer.
SCK
SSEL
4 to 16 bits
a) Motorola SPI frame format (single transfer) with CPOL=1 and CPHA=0
SCK
SSEL
4 to 16 bits 4 to 16 bits
b) Motorola SPI frame format (continuous transfer) with CPOL=1 and CPHA=0
Fig 45. SPI frame format with CPOL = 1 and CPHA = 0 (a) single and b) continuous transfer)
One half period later, valid master data is transferred to the MOSI line. Now that both the
master and slave data have been set, the SCK master clock pin becomes LOW after one
further half SCK period. This means that data is captured on the falling edges and be
propagated on the rising edges of the SCK signal.
In the case of a single word transmission, after all bits of the data word are transferred, the
SSEL line is returned to its idle HIGH state one SCK period after the last bit has been
captured.
However, in the case of continuous back-to-back transmissions, the SSEL signal must be
pulsed HIGH between each data word transfer. This is because the slave select pin
freezes the data in its serial peripheral register and does not allow it to be altered if the
CPHA bit is logic zero. Therefore the master device must raise the SSEL pin of the slave
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
device between each data transfer to enable the serial peripheral data write. On
completion of the continuous transfer, the SSEL pin is returned to its idle state one SCK
period after the last bit has been captured.
SCK
SSEL
4 to 16 bits
a) Motorola SPI frame format (single transfer) with CPOL=1 and CPHA=1
After all bits have been transferred, in the case of a single word transmission, the SSEL
line is returned to its idle HIGH state one SCK period after the last bit has been captured.
For continuous back-to-back transmissions, the SSEL pins remains in its active LOW
state, until the final bit of the last word has been captured, and then returns to its idle state
as described above. In general, for continuous back-to-back transfers the SSEL pin is held
LOW between successive data words and termination is the same as that of the single
word transfer.
SK
CS
SO MSB LSB
8 bit control
SI 0 MSB LSB
4 to 16 bits
output data
Microwire format is very similar to SPI format, except that transmission is half-duplex
instead of full-duplex, using a master-slave message passing technique. Each serial
transmission begins with an 8-bit control word that is transmitted from the SSP to the
off-chip slave device. During this transmission, no incoming data is received by the SSP.
After the message has been sent, the off-chip slave decodes it and, after waiting one
serial clock after the last bit of the 8-bit control message has been sent, responds with the
required data. The returned data is 4 to 16 bits in length, making the total frame length
anywhere from 13 to 25 bits.
The off-chip serial slave device latches each control bit into its serial shifter on the rising
edge of each SK. After the last bit is latched by the slave device, the control byte is
decoded during a one clock wait-state, and the slave responds by transmitting data back
to the SSP. Each bit is driven onto SI line on the falling edge of SK. The SSP in turn
latches each bit on the rising edge of SK. At the end of the frame, for single transfers, the
CS signal is pulled HIGH one clock period after the last bit has been latched in the receive
serial shifter, that causes the data to be transferred to the receive FIFO.
Note: The off-chip slave device can tristate the receive line either on the falling edge of SK
after the LSB has been latched by the receive shiftier, or when the CS pin goes HIGH.
For continuous transfers, data transmission begins and ends in the same manner as a
single transfer. However, the CS line is continuously asserted (held LOW) and
transmission of data occurs back to back. The control byte of the next frame follows
directly after the LSB of the received data from the current frame. Each of the received
values is transferred from the receive shifter on the falling edge SK, after the LSB of the
frame has been latched into the SSP.
SK
CS
8 bit control
SI 0 MSB LSB MSB LSB
4 to 16 bits 4 to 16 bits
output data output data
Figure 49 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 =2t
SETUP SK
t =t
HOLD SK
SK
CS
SI
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
Table 163: SSP Control Register 0 (SSPCR0 - address 0xE006 8000) bit description
Bit Symbol Value Description Reset
value
3:0 DSS Data Size Select. This field controls the number of bits 0000
transferred in each frame. Values 0000-0010 are not
supported and should not be used.
0011 4 bit transfer
0100 5 bit transfer
0101 6 bit transfer
0110 7 bit transfer
0111 8 bit transfer
1000 9 bit transfer
1001 10 bit transfer
1010 11 bit transfer
1011 12 bit transfer
1100 13 bit transfer
1101 14 bit transfer
1110 15 bit transfer
1111 16 bit transfer
5:4 FRF Frame Format. 00
00 SPI
01 SSI
10 Microwire
11 This combination is not supported and should not be used.
Table 163: SSP Control Register 0 (SSPCR0 - address 0xE006 8000) bit description
Bit Symbol Value Description Reset
value
6 CPOL Clock Out Polarity. This bit is only used in SPI mode. 0
SSP controller captures serial data on the first clock transition
0 of the frame, that is, the transition away from the inter-frame
state of the clock line.
1 SSP controller captures serial data on the second clock
transition of the frame, that is, the transition back to the
inter-frame state of the clock line.
7 CPHA Clock Out Phase. This bit is only used in SPI mode. 0
0 SSP controller maintains the bus clock low between frames.
1 SSP controller maintains the bus clock high between frames.
15:8 SCR Serial Clock Rate. The number of prescaler-output clocks per 0x00
bit on the bus, minus one. Given that CPSDVR is the prescale
divider, and the VPB clock PCLK clocks the prescaler, the bit
frequency is PCLK / (CPSDVSR * [SCR+1]).
Table 164: SSP Control Register 1 (SSPCR1 - address 0xE006 8004) bit description
Bit Symbol Value Description Reset
value
0 LBM Loop Back Mode. 0
0 During normal operation.
1 Serial input is taken from the serial output (MOSI or MISO)
rather than the serial input pin (MISO or MOSI
respectively).
1 SSE SSP Enable. 0
0 The SSP controller is disabled.
1 The SSP controller will interact with other devices on the
serial bus. Software should write the appropriate control
information to the other SSP registers and interrupt
controller registers, before setting this bit.
2 MS Master/Slave Mode.This bit can only be written when the 0
SSE bit is 0.
The SSP controller acts as a master on the bus, driving the
0 SCLK, MOSI, and SSEL lines and receiving the MISO line.
1 The SSP controller acts as a slave on the bus, driving
MISO line and receiving SCLK, MOSI, and SSEL lines.
3 SOD Slave Output Disable. This bit is relevant only in slave 0
mode (MS = 1). If it is 1, this blocks this SSP controller
from driving the transmit data line (MISO).
7:4 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Table 165: SSP Data Register (SSPDR - address 0xE006 8008) bit description
Bit Symbol Description Reset value
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 was
previously empty and the SSP controller is not busy on the bus,
transmission of the data will begin immediately. Otherwise the
data written to this register will be sent as soon as all previous
data has been sent (and received). If the data length is less than
16 bits, software must right-justify the data written to this register.
Read: software can read data from this register whenever the
RNE bit in the Status register is 1, indicating that the Rx FIFO is
not empty. When software reads this register, the SSP controller
returns data from the least recent frame in the Rx FIFO. If the
data length is less than 16 bits, the data is right-justified in this
field with higher order bits filled with 0s.
Table 166: SSP Status Register (SSPDR - address 0xE006 800C) bit description
Bit Symbol Description Reset value
0 TFE Transmit FIFO Empty. This bit is 1 is the Transmit FIFO is empty, 1
0 if not.
1 TNF Transmit FIFO Not Full. This bit is 0 if the Tx FIFO is full, 1 if not. 1
2 RNE Receive FIFO Not Empty. This bit is 0 if the Receive FIFO is 0
empty, 1 if not.
3 RFF Receive FIFO Full. This bit is 1 if the Receive FIFO is full, 0 if 0
not.
4 BSY Busy. This bit is 0 if the SSP controller is idle, or 1 if it is 0
currently sending/receiving a frame and/or the Tx FIFO is not
empty.
7:5 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
Table 167: SSP Clock Prescale Register (SSPCPSR - address 0xE006 8010) bit description
Bit Symbol Description Reset value
7:0 CPSDVSR This even value between 2 and 254, by which PCLK is divided 0
to yield the prescaler output clock. Bit 0 always reads as 0.
Important: the SSPCPSR value must be properly initialized or the SSP controller will not
be able to transmit data correctly. In case of an SSP operating in the master mode, the
CPSDVSRmin = 2, while in case of the slave mode CPSDVSRmin = 12.
Table 168: SSP Interrupt Mask Set/Clear register (SSPIMSC - address 0xE006 8014) bit
description
Bit Symbol Description Reset value
0 RORIM Software should set this bit to enable interrupt when a Receive 0
Overrun occurs, that is, when the Rx FIFO is full and another
frame is completely received. The ARM spec implies that the
preceding frame data is overwritten by the new frame data
when this occurs.
1 RTIM Software should set this bit to enable interrupt when a Receive 0
Timeout condition occurs. A Receive Timeout occurs when the
Rx FIFO is not empty, and no new data has been received, nor
has data been read from the FIFO, for 32 bit times.
2 RXIM Software should set this bit to enable interrupt when the Rx 0
FIFO is at least half full.
3 TXIM Software should set this bit to enable interrupt when the Tx 0
FIFO is at least half empty.
7:4 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Table 169: SSP Raw Interrupt Status register (SSPRIS - address 0xE006 8018) bit description
Bit Symbol Description Reset value
0 RORRIS This bit is 1 if another frame was completely received while the 0
RxFIFO was full. The ARM spec implies that the preceding
frame data is overwritten by the new frame data when this
occurs.
1 RTRIS This bit is 1 if when there is a Receive Timeout condition. Note 0
that a Receive Timeout can be negated if further data is
received.
2 RXRIS This bit is 1 if the Rx FIFO is at least half full. 0
3 TXRIS This bit is 1 if the Tx FIFO is at least half empty. 1
7:4 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Table 170: SSP Masked Interrupt Status register (SSPMIS -address 0xE006 801C) bit
description
Bit Symbol Description Reset value
0 RORMIS This bit is 1 if another frame was completely received while the 0
RxFIFO was full, and this interrupt is enabled.
1 RTMIS This bit is 1 when there is a Receive Timeout condition and 0
this interrupt is enabled. Note 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 this 0
interrupt is enabled.
7:5 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Table 171: SSP interrupt Clear Register (SSPICR - address 0xE006 8020) bit description
Bit Symbol Description Reset value
0 RORIC Writing a 1 to this bit clears the “frame was received when NA
RxFIFO was full” interrupt.
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 NA
bits. The value read from a reserved bit is not defined.
14.1 Introduction
The USB is a 4 wire bus that supports communication between a host and a number (127
max.) of peripherals. The host controller allocates the USB bandwidth to attached devices
through a token based protocol. The bus supports hot plugging, un-plugging and dynamic
configuration of the devices. All transactions are initiated by the host controller.
The host schedules transactions in 1 ms frames. Each frame contains SoF marker and
transactions that transfer data to/from device endpoints. Each device can have a
maximum of 16 logical or 32 physical endpoints. There are 4 types of transfers defined or
the endpoints. The control transfers are used to configure the device. The interrupt
transfers are used for periodic data transfer. The bulk transfers are used when rate of
transfer is not critical. The isochronous transfers have guaranteed delivery time but no
error correction.
The device controller enables 12 Mb/s data exchange with a USB host controller. It
consists of register interface, serial interface engine, endpoint buffer memory and DMA
controller. The serial interface engine decodes the USB data stream and writes data to the
appropriate end point buffer memory. The status of a completed USB transfer or error
condition is indicated via status registers. An interrupt is also generated if enabled. The
DMA controller when enabled transfers data between the endpoint buffer and the USB
RAM.
Table 172: USB related acronyms, abbreviations and definitions used in this chapter
Acronym/abbreviation Description
AHB Advanced High-performance bus
ATLE Auto Transfer Length Extraction
ATX Analog Transceiver
DD DMA Descriptor
DC Device Core
DDP DD Pointer
DMA Direct Memory Access
EoP End of Package
EP End Point
FS Full Speed
HREADY When HIGH the HREADY signal indicates that a transfer has finished on
the AHB bus. This signal may be driven LOW to extend a transfer.
LED Light Emitting Diode
LS Low Speed
MPS Maximum Packet Size
PLL Phase Locked Loop
RAM Random Access Memory
SoF Start of Frame
SIE Serial Interface Engine
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Table 172: USB related acronyms, abbreviations and definitions used in this chapter
Acronym/abbreviation Description
SRAM Synchronous RAM
UDCA USB Device Communication Area
USB Universal Serial Bus
14.2 Features
• Fully compliant with USB 2.0 Full Speed specification
• Supports 32 physical (16 logical) endpoints
• Supports Control, Bulk, Interrupt and Isochronous endpoints
• Scalable realization of endpoints at run time
• Endpoint Maximum packet size selection (up to USB maximum specification) by
software at run time
• RAM message buffer size based on endpoint realization and maximum packet size
• Supports Soft Connect™ feature and Good Link™ LED indicator
• Supports bus-powered capability with low suspend current
• Support DMA transfer with the DMA RAM of 8 kB on all non-control endpoints
(LPC2146/8 only)
• One Duplex DMA channel serves all endpoints (LPC2146/8 only)
• Allows dynamic switching between CPU controlled and DMA modes (available on
LPC2146/8 only)
• Double buffer implementation for Bulk & Isochronous endpoints
14.4 Architecture
The architecture of the USB device controller is shown below in the block diagram.
Bus
Master DMA
DMA Interface Engine
Interface
(AHB master)
USB Pins
AHB Bus
EP_RAM Serial
Register
Access Interface
Interface
Control Engine
Register
Interface EP_RAM
(AHB slave) USB Device (2K)
Block
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
For non-isochronous endpoints, when a full data packet is received without any errors, the
endpoint generates a request for data transfer from its FIFO by generating an interrupt to
the system.
Isochronous endpoint will have one packet of data to be transferred in every frame. So the
data transfer has to be synchronized to the USB frame rather than packet arrival. So, for
every 1 ms there will be an interrupt to the system.
The data transfer follows the little endian format. The first byte received from the USB bus
will be available in the least significant byte of the receive data register.
The data transfer follows the little endian format. The first byte sent on the USB bus will be
the least significant byte of the transmit data register.
Reception of valid (error-free) data packet in any of the OUT non-isochronous endpoint
buffer generates an interrupt. Upon receiving the interrupt, the software can read the data
using receive length and data registers. When there is no empty buffer (for a given OUT
non-isochronous endpoint), any data arrival generates an interrupt only if Interrupt on
NAK feature for that endpoint type is enabled and the existing interrupt is cleared. For
OUT isochronous endpoints, the data will always be written irrespective of the buffer
status. There will be no interrupt generated specific to OUT isochronous endpoints other
than the frame interrupt.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
The endpoint 0 of USB (default control endpoint) will receive the setup packet. It will not
be efficient to transfer this data to the USB RAM since the CPU has to decode this
command and respond back to the host. So, this transfer will happen in the slave mode
only.
For each Isochronous endpoint, one packet transfer happens every frame. Hence, the
DMA transfer has to be synchronized to the frame interrupt.
The DMA engine also support Auto Transfer Length Extraction (ATLE) mode for bulk
transfers. In this mode the DMA engine recovers the transfer size from the incoming
packet stream.
14.6 Interfaces
USB slave mode registers are located in the address region 0xE009 0000 to
0xE009 004C. All unused address in this region reads “DEADABBA”.
DMA related registers are located in the address region 0xE009 0050 to 0xE009 00FC. All
unused address in this region reads invalid data.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
The three interrupt output lines are ORed together to reduce the number of interrupt
channels required for the USB device in the vectored interrupt controller. This register
reflects the status of the each interrupt line. The USBIntSt is a read/write register.
Table 175: USB Interrupt Status register (USBIntSt - address 0xE01F C1C0) bit description
Bit Symbol Description Reset
value
0 USB_INT_REQ_LP Low priority interrupt line status. This bit is read only. 0
1 USB_INT_REQ_HP High priority interrupt line status. This bit is read only. 0
2 USB_INT_REQ_DMA DMA interrupt line status. This bit is read only. (LPC2146/8 only) 0
7:3 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Table 175: USB Interrupt Status register (USBIntSt - address 0xE01F C1C0) bit description
Bit Symbol Description Reset
value
8 USB_need_clock USB need clock indicator. This bit is set to 1 when a USB 0
activity/change of state on the USB data pins is detected, and it
indicates that a USB PLL supplied clock of 48 MHz is needed. Once the
USB_need_clock becomes one, it resets to zero 3 ms after the last
frame has been received/sent. A change of this bit from 0 to 1 can wake
up the microcontroller if an activity on the USB bus is selected to wake
up the part from the Power-down mode (see Section 3.5.3 “Interrupt
Wakeup register (INTWAKE - 0xE01F C144)” on page 22 for details).
Also see Section 3.8.8 “PLL and Power-down mode” on page 32 and
Section 3.9.2 “Power Control register (PCON - 0xE01F COCO)” on
page 35 for considerations about the USB PLL and invoking the Power
Down mode.
30:9 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
31 EN_USB_INTS Enable all USB interrupts. When this bit is cleared the ORed output of 1
the USB interrupt lines is not seen by the Vectored Interrupt Controller.
Table 176: USB Device Interrupt Status register (USBDevIntSt - address 0xE009 0000) bit allocation
Reset value: 0x0000 0000
Bit 31 30 29 28 27 26 25 24
Symbol - - - - - - - -
Bit 23 22 21 20 19 18 17 16
Symbol - - - - - - - -
Bit 15 14 13 12 11 10 9 8
Symbol - - - - - - EPR_INT EP_RLZED
Bit 7 6 5 4 3 2 1 0
Symbol TxENDPKT Rx CDFULL CCEMTY DEV_STAT EP_SLOW EP_FAST FRAME
ENDPKT
Table 177: USB Device Interrupt Status register (USBDevIntSt - address 0xE009 0000) bit description
Bit Symbol Description Reset value
0 FRAME The frame interrupt occurs every 1 ms. This is to be used in isochronous packet 0
transfer.
1 EP_FAST This is the fast interrupt transfer for the endpoint. If an Endpoint Interrupt Priority 0
register bit is set, the endpoint interrupt will be routed to this bit.
2 EP_SLOW This is the Slow interrupt transfer for the endpoint. If an Endpoint Interrupt Priority 0
Register bit is not set, the endpoint interrupt will be routed to this bit.
3 DEV_STAT Set when USB Bus reset, USB suspend change or Connect change event occurs. 0
Refer to Section 14.9.6 “Set Device Status (Command: 0xFE, Data: write 1 byte)” on
page 225.
4 CCEMTY The command code register is empty (New command can be written). 1
5 CDFULL Command data register is full (Data can be read now). 0
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Table 177: USB Device Interrupt Status register (USBDevIntSt - address 0xE009 0000) bit description
Bit Symbol Description Reset value
6 RxENDPKT The current packet in the FIFO is transferred to the CPU. 0
7 TxENDPKT The number of data bytes transferred to the FIFO equals the number of bytes 0
programmed in the TxPacket length register.
8 EP_RLZED Endpoints realized. Set when Realize endpoint register or Maxpacket size register is 0
updated.
9 ERR_INT Error Interrupt. Any bus error interrupt from the USB device. Refer to Section 14.9.9 0
“Read Error Status (Command: 0xFB, Data: read 1 byte)” on page 227
31:10 - Reserved, user software should not write ones to reserved bits. The value read from a NA
reserved bit is not defined.
Table 178: USB Device Interrupt Enable register (USBDevIntEn - address 0xE009 0004) bit allocation
Reset value: 0x0000 0000
Bit 31 30 29 28 27 26 25 24
Symbol - - - - - - - -
Bit 23 22 21 20 19 18 17 16
Symbol - - - - - - - -
Bit 15 14 13 12 11 10 9 8
Symbol - - - - - - EPR_INT EP_RLZED
Bit 7 6 5 4 3 2 1 0
Symbol TxENDPKT Rx CDFULL CCEMTY DEV_STAT EP_SLOW EP_FAST FRAME
ENDPKT
Table 179: USB Device Interrupt Enable register (USBDevIntEn - address 0xE009 0004) bit description
Bit Symbol Value Description Reset value
31:0 See 0 No external interrupt is generated. 0
USBDevIntEn 1 Enables an external interrupt to be generated (Fast or Slow) when the
bit allocation corresponding bit in the Device Interrupt Status register (Section 14.7.2) is
table above set.
Table 180: USB Device Interrupt Clear register (USBDevIntClr - address 0xE009 0008) bit allocation
Reset value: 0x0000 0000
Bit 31 30 29 28 27 26 25 24
Symbol - - - - - - - -
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Bit 23 22 21 20 19 18 17 16
Symbol - - - - - - - -
Bit 15 14 13 12 11 10 9 8
Symbol - - - - - - EPR_INT EP_RLZED
Bit 7 6 5 4 3 2 1 0
Symbol TxENDPKT Rx CDFULL CCEMTY DEV_STAT EP_SLOW EP_FAST FRAME
ENDPKT
Table 181: USB Device Interrupt Clear register (USBDevIntClr - address 0xE009 0008) bit description
Bit Symbol Value Description Reset value
31:0 See 0 No effect. 0
USBDevIntClr 1 The corresponding bit in the Device Interrupt Status register
bit allocation (Section 14.7.2) is cleared.
table above
Table 182: USB Device Interrupt Set register (USBDevIntSet - address 0xE009 000C) bit allocation
Reset value: 0x0000 0000
Bit 31 30 29 28 27 26 25 24
Symbol - - - - - - - -
Bit 23 22 21 20 19 18 17 16
Symbol - - - - - - - -
Bit 15 14 13 12 11 10 9 8
Symbol - - - - - - EPR_INT EP_RLZED
Bit 7 6 5 4 3 2 1 0
Symbol TxENDPKT Rx CDFULL CCEMTY DEV_STAT EP_SLOW EP_FAST FRAME
ENDPKT
Table 183: USB Device Interrupt Set register (USBDevIntSet - address 0xE009 000C) bit description
Bit Symbol Value Description Reset value
31:0 See 0 No effect. 0
USBDevIntSet 1 The corresponding bit in the Device Interrupt Status register
bit allocation (Section 14.7.2) is set.
table above
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
interrupts will be routed to the low priority interrupt line if the EP_FAST bit is set to 0,
irrespective of the Endpoint Interrupt Priority register (Section 14.7.11) setting. The
USBDevIntPri is a write only register.
Table 184: USB Device Interrupt Priority register (USBDevIntPri - address 0xE009 002C) bit description
Bit Symbol Value Description Reset value
0 FRAME 0 FRAME interrupt is routed to the low priority interrupt line. 0
1 FRAME interrupt is routed to the high priority interrupt line.
1 EP_FAST 0 EP_FAST interrupt is routed to the low priority interrupt line. 0
1 EP_FAST interrupt is routed to the high priority interrupt line.
7:2 - - Reserved, user software should not write ones to reserved bits. The value NA
read from a reserved bit is not defined.
Table 185: USB Endpoint Interrupt Status register (USBEpIntSt - address 0xE009 0030) bit allocation
Reset value: 0x0000 0000
Bit 31 30 29 28 27 26 25 24
Symbol EP15TX EP15RX EP14TX EP14RX EP13TX EP13RX EP12TX EP12RX
Bit 23 22 21 20 19 18 17 16
Symbol EP11TX EP11RX EP10TX EP10RX EP9TX EP9RX EP8TX EP8RX
Bit 15 14 13 12 11 10 9 8
Symbol EP7TX EP7RX EP6TX EP6RX EP5TX EP5RX EP4TX EP4RX
Bit 7 6 5 4 3 2 1 0
Symbol EP3TX EP3RX EP2TX EP2RX EP1TX EP1RX EP0TX EP0RX
Table 186: USB Endpoint Interrupt Status register (USBEpIntSt - address 0xE009 0030) bit description
Bit Symbol Description Reset value
0 EP0RX Endpoint 0, Data Received Interrupt bit. 0
1 EP0TX Endpoint 0, Data Transmitted Interrupt bit or sent a NAK. 0
2 EP1RX Endpoint 1, Data Received Interrupt bit. 0
3 EP1TX Endpoint 1, Data Transmitted Interrupt bit or sent a NAK. 0
4 EP2RX Endpoint 2, Data Received Interrupt bit. 0
5 EP2TX Endpoint 2, Data Transmitted Interrupt bit or sent a NAK. 0
6 EP3RX Endpoint 3, Isochronous endpoint. NA
7 EP3TX Endpoint 3, Isochronous endpoint. NA
8 EP4RX Endpoint 4, Data Received Interrupt bit. 0
9 EP4TX Endpoint 4, Data Transmitted Interrupt bit or sent a NAK. 0
10 EP5RX Endpoint 5, Data Received Interrupt bit. 0
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Table 186: USB Endpoint Interrupt Status register (USBEpIntSt - address 0xE009 0030) bit description
Bit Symbol Description Reset value
11 EP5TX Endpoint 5, Data Transmitted Interrupt bit or sent a NAK. 0
12 EP6RX Endpoint 6, Isochronous endpoint. NA
13 EP6TX Endpoint 6, Isochronous endpoint. NA
14 EP7RX Endpoint 7, Data Received Interrupt bit. 0
15 EP7TX Endpoint 7, Data Transmitted Interrupt bit or sent a NAK. 0
16 EP8RX Endpoint 8, Data Received Interrupt bit. 0
17 EP8TX Endpoint 8, Data Transmitted Interrupt bit or sent a NAK. 0
18 EP9RX Endpoint 9, Isochronous endpoint. NA
19 EP9TX Endpoint 9, Isochronous endpoint. NA
20 EP10RX Endpoint 10, Data Received Interrupt bit. 0
21 EP10TX Endpoint 10, Data Transmitted Interrupt bit or sent a NAK. 0
22 EP11RX Endpoint 11, Data Received Interrupt bit. 0
23 EP11TX Endpoint 11, Data Transmitted Interrupt bit or sent a NAK. 0
24 EP12RX Endpoint 12, Isochronous endpoint. NA
25 EP12TX Endpoint 12, Isochronous endpoint. NA
26 EP13RX Endpoint 13, Data Received Interrupt bit. 0
27 EP13TX Endpoint 13, Data Transmitted Interrupt bit or sent a NAK. 0
28 EP14RX Endpoint 14, Data Received Interrupt bit. 0
29 EP14TX Endpoint 14, Data Transmitted Interrupt bit or sent a NAK. 0
30 EP15RX Endpoint 15, Data Received Interrupt bit. 0
31 EP15TX Endpoint 15, Data Transmitted Interrupt bit or sent a NAK. 0
Table 187: USB Endpoint Interrupt Enable register (USBEpIntEn - address 0xE009 0034) bit allocation
Reset value: 0x0000 0000
Bit 31 30 29 28 27 26 25 24
Symbol EP15TX EP15RX EP14TX EP14RX EP13TX EP13RX EP12TX EP12RX
Bit 23 22 21 20 19 18 17 16
Symbol EP11TX EP11RX EP10TX EP10RX EP9TX EP9RX EP8TX EP8RX
Bit 15 14 13 12 11 10 9 8
Symbol EP7TX EP7RX EP6TX EP6RX EP5TX EP5RX EP4TX EP4RX
Bit 7 6 5 4 3 2 1 0
Symbol EP3TX EP3RX EP2TX EP2RX EP1TX EP1RX EP0TX EP0RX
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Table 188: USB Endpoint Interrupt Enable register (USBEpIntEn - address 0xE009 0034) bit description
Bit Symbol Value Description Reset value
31:0 See 0 No effect. 0
USBEpIntEn 1 The corresponding bit in the Endpoint Interrupt Status register
bit allocation (Section 14.7.7) transfers its status to the Device Interrupt Status register
table above (Section 14.7.2). Having a bit in the USBEpIntEn set to 1 implies operating
in the slave mode.
Table 189: USB Endpoint Interrupt Clear register (USBEpIntClr - address 0xE009 0038) bit allocation
Reset value: 0x0000 0000
Bit 31 30 29 28 27 26 25 24
Symbol EP15TX EP15RX EP14TX EP14RX EP13TX EP13RX EP12TX EP12RX
Bit 23 22 21 20 19 18 17 16
Symbol EP11TX EP11RX EP10TX EP10RX EP9TX EP9RX EP8TX EP8RX
Bit 15 14 13 12 11 10 9 8
Symbol EP7TX EP7RX EP6TX EP6RX EP5TX EP5RX EP4TX EP4RX
Bit 7 6 5 4 3 2 1 0
Symbol EP3TX EP3RX EP2TX EP2RX EP1TX EP1RX EP0TX EP0RX
Table 190: USB Endpoint Interrupt Clear register (USBEpIntClr - address 0xE009 0038) bit description
Bit Symbol Value Description Reset value
31:0 See 0 No effect. 0
USBEpIntClr 1 Clears the corresponding bit in the Endpoint Interrupt Status register.
bit allocation
table above
Software is allowed to issue clear operation on multiple endpoints as well. Let us take an
example:
Assume bits 5 and 10 of Endpoint Interrupt Status register are to be cleared. The software
can issue Clear operation by writing in Endpoint Interrupt Clear register (with
corresponding bit positions set to '1'). Then hardware will do the following:
Table 191: USB Endpoint Interrupt Set register (USBEpIntSet - address 0xE009 003C) bit allocation
Reset value: 0x0000 0000
Bit 31 30 29 28 27 26 25 24
Symbol EP15TX EP15RX EP14TX EP14RX EP13TX EP13RX EP12TX EP12RX
Bit 23 22 21 20 19 18 17 16
Symbol EP11TX EP11RX EP10TX EP10RX EP9TX EP9RX EP8TX EP8RX
Bit 15 14 13 12 11 10 9 8
Symbol EP7TX EP7RX EP6TX EP6RX EP5TX EP5RX EP4TX EP4RX
Bit 7 6 5 4 3 2 1 0
Symbol EP3TX EP3RX EP2TX EP2RX EP1TX EP1RX EP0TX EP0RX
Table 192: USB Endpoint Interrupt Set register (USBEpIntSet - address 0xE009 003C) bit description
Bit Symbol Value Description Reset value
31:0 See 0 No effect. 0
USBEpIntSet 1 Sets the corresponding bit in the Endpoint Interrupt Status register.
bit allocation
table above
Table 193: USB Endpoint Interrupt Priority register (USBEpIntPri - address 0xE009 0040) bit allocation
Reset value: 0x0000 0000
Bit 31 30 29 28 27 26 25 24
Symbol EP15TX EP15RX EP14TX E14RX EP13TX EP13RX EP12TX EP12RX
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Bit 23 22 21 20 19 18 17 16
Symbol EP11TX EP11RX EP10TX EP10RX EP9TX EP9RX EP8TX EP8RX
Bit 15 14 13 12 11 10 9 8
Symbol EP7TX EP7RX EP6TX EP6RX EP5TX EP5RX EP4TX EP4RX
Bit 7 6 5 4 3 2 1 0
Symbol EP3TX EP3RX EP2TX EP2RX EP1TX EP1RX EP0TX EP0RX
Table 194: USB Endpoint Interrupt Priority register (USBEpIntPri - address 0xE009 0040) bit description
Bit Symbol Value Description Reset value
31:0 See 0 The corresponding interrupt will be routed to the slow endpoint interrupt bit 0
USBEpIntPri in the Device Status register.
bit allocation 1 The corresponding interrupt will be routed to the fast endpoint interrupt bit
table above in the Device Status register.
Table 195: USB Realize Endpoint register (USBReEp - address 0xE009 0044) bit allocation
Reset value: 0x0000 0003
Bit 31 30 29 28 27 26 25 24
Symbol EP31 EP30 EP29 EP28 EP27 EP26 EP25 EP24
Bit 23 22 21 20 19 18 17 16
Symbol EP23 EP22 EP21 EP20 EP19 EP18 EP17 EP16
Bit 15 14 13 12 11 10 9 8
Symbol EP15 EP14 EP13 EP12 EP11 EP10 EP9 EP8
Bit 7 6 5 4 3 2 1 0
Symbol EP7 EP6 EP5 EP4 EP3 EP2 EP1 EP0
Table 196: USB Realize Endpoint register (USBReEp - address 0xE009 0044) bit description
Bit Symbol Value Description Reset value
0 EP0 0 Control endpoint EP0 is not realized. 1
1 Control endpoint EP0 is realized.
1 EP1 0 Control endpoint EP1 is not realized. 1
1 Control endpoint EP1 is realized.
31:2 EPxx 0 Endpoint EPxx is not realized. 0
1 Endpoint EPxx is realized.
At power on only default control endpoint is realized. Other endpoints if required have to
be realized by programming the corresponding bit in the Realize Endpoint register.
Realization of endpoints is a multi-cycle operation. The pseudo code of endpoint
realization is shown below.
{
/* OR with the existing value of the register */
RealizeEndpointRegister |= (UInt32) ((0x1 << endpt));
/* Load endpoint index Reg with physical endpoint no.*/
EndpointIndexRegister = (UInt32) endpointnumber;
Device will not respond to any tokens to the un-realized endpoint. ‘Configure Device’
command can only enable all realized and enabled endpoints. For details see Section
14.9.2 “Configure Device (Command: 0xD8, Data: write 1 byte)” on page 223.
EP_ RAM size (in words) required for the physical endpoint can be expressed as
where db_status = 1 for single buffered endpoint and 2 for double buffered endpoint.
Since all the realized endpoints occupy EP_RAM space, the total EP_RAM requirement is
TotalEPRAMsize = 32 + ∑ epramsize ( n )
n=0
where N is the number of realized endpoints. Total EP_RAM size should not exceed 2048
bytes (2 kB, 0.5 kwords).
EP_RAM can be accessed by 3 sources, which are SIE, DMA engine and CPU. Among
them, CPU has the highest priority followed by the SIE and DMA engine. The DMA engine
has got the lowest priority. Then again, under the above mentioned 3 request sources,
write request has got higher priority than read request. Typically, CPU does single word
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
read or write accesses, the DMA logic can do 32-byte burst access. The CPU and DMA
engine operates at a higher clock frequency as compared to the SIE engine. The CPU
cycles are valuable and so the CPU is given the highest priority. The CPU clock frequency
is higher than the SIE operating frequency (12 MHz). The SIE will take 32 clock cycles for
a word transfer. In general, this time translates to more than 32 clock cycles of the CPU in
which it can do easily several accesses to the memory.
The Endpoint Index register will hold the physical endpoint number. Writing into the
Maxpacket size register will set the array element pointed by the Endpoint Index register.
Table 197: USB Endpoint Index register (USBEpIn - address 0xE009 0048) bit description
Bit Symbol Description Reset value
4:0 Phy_endpoint Physical endpoint number (0-31) 0
31:5 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Table 198: USB MaxPacketSize register (USBMaxPSize - address 0xE009 004C) bit
description
Bit Symbol Description Reset value
9:0 MaxPacketSize The maximum packet size value. 0x008
31:10 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
MPS*_EP0
Endpoint index
MPS*_EP31
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Table 199: USB Receive Data register (USBRxData - address 0xE009 0018) bit description
Bit Symbol Description Reset value
31:0 ReceiveData Data received. 0x0000 0000
Table 200: USB Receive Packet Length register (USBRxPlen - address 0xE009 0020) bit
description
Bit Symbol Value Description Reset
value
9:0 PKT_LNGTH - The remaining amount of data in bytes still to be read from 0
the RAM.
10 DV Non-isochronous end point will not raise an interrupt when 0
an erroneous data packet is received. But invalid data
packet can be produced with bus reset. For isochronous
endpoint, data transfer will happen even if an erroneous
packet is received. In this case DV bit will not be set for the
packet.
0 Data is invalid.
1 Data is valid.
11 PKT_RDY - Packet length field in the register is valid and packet is ready 0
for reading.
31:12 - - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Table 201: USB Transmit Data register (USBTxData - address 0xE009 001C) bit description
Bit Symbol Description Reset value
31:0 TransmitData Transmit Data. 0x0000 0000
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
software can read this register to determine the number of bytes it has transferred to the
EP_RAM. After each write to the Transmit Data register the hardware will decrement the
contents of the Transmit Packet Length register. For lengths larger than the Maximum
Packet Size, the software should submit data in steps of Maximum Packet Size and the
remaining extra bytes in the last packet. For example, if the Maximum Packet Size is 64
bytes and the data buffer to be transferred is of length 130 bytes, then the software
submits 64 bytes packet twice followed by 2 bytes in the last packet. So, a total of 3
packets are sent on USB. The USBTxPLen is a write only register.
Table 202: USB Transmit Packet Length register (USBTxPLen - address 0xE009 0024) bit
description
Bit Symbol Value Description Reset
value
9:0 PKT_LNGTH - The remaining amount of data in bytes to be written to the 0x000
EP_RAM.
31:10 - - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Table 203: USB Control register (USBCtrl - address 0xE009 0028) bit description
Bit Symbol Value Description Reset
value
0 RD_EN Read mode control. 0
0 Read mode is disabled.
1 Read mode is enabled.
1 WR_EN Write mode control. 0
0 Write mode is disabled.
1 Write mode is enabled.
5:2 LOG_ENDPOINT - Logical Endpoint number. 0x0
31:6 - - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is not
defined.
The software can now start reading the Receive Data register (Section 14.8.3). When the
end of packet is reached the Read Enable bit (RD_EN in Table 203) will be disabled by the
control logic and RxENDPKT bit is set in the Device Interrupt Status register. The software
should issue a Clear Buffer (refer to Section 14.9.13 “Clear Buffer (Command: 0xF2, Data:
read 1 byte (optional))” on page 230) command. The endpoint is now ready to accept the
next packet.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
If the software makes the Read Enable bit low midway, the reading will be terminated. In
this case the data will remain in the EP_RAM. When the Read Enable signal is made high
again for this endpoint, data will be read from the beginning.
For writing data to an endpoint buffer, Write Enable bit (WR_EN in Table 203) should be
made high and software should write to the Transmit Packet Length register
(Section 14.8.6) the number of bytes it is going to send in the packet. It can then write data
continuously in the Transmit Data register.
When the control logic receives the number of bytes programmed in the Transmit Packet
Length register, it will reset the Write Enable bit. The TxENDPKT bit is set in the Device
Interrupt Status register. The software should issue a Validate Buffer (refer to Section
14.9.14 “Validate Buffer (Command: 0xFA, Data: none)” on page 230) command. The
endpoint is now ready to send the packet. If the software resets this bit midway, writing will
start again from the beginning.
A synchronization mechanism is used to transfer data between the two clock domains i.e.
AHB slave clock and the USB bit clock at 12 MHz. This synchronization process takes up
to 5 clock cycles of the slow clock (i.e. 12 MHz) for reading/writing from/to a register
before the next read/write can happen. The AHB HREADY output from the USB device is
driven appropriately to take care of the timing.
Both Read Enable and Write Enable bits can be high at the same time for the same logical
endpoint. The interleaved read and write operation is possible.
Table 204: USB Command Code register (USBCmdCode - address 0xE009 0010) bit
description
Bit Symbol Description Reset value
7:0 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
15:8 CMD_PHASE The command phase. 0x00
23:16 CMD_CODE The code for the command. 0x00
31:24 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Table 205: USB Command Data register (USBCmdData - address 0xE009 0014) bit
description
Bit Symbol Description Reset value
7:0 CommandData Command Data. 0x00
31:8 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Table 206: USB DMA Request Status register (USBDMARSt - address 0xE009 0050) bit allocation
Reset value: 0x0000 0000
Bit 31 30 29 28 27 26 25 24
Symbol EP31 EP30 EP29 EP28 EP27 EP26 EP25 EP24
Bit 23 22 21 20 19 18 17 16
Symbol EP23 EP22 EP21 EP20 EP19 EP18 EP17 EP16
Bit 15 14 13 12 11 10 9 8
Symbol EP15 EP14 EP13 EP12 EP11 EP10 EP9 EP8
Bit 7 6 5 4 3 2 1 0
Symbol EP7 EP6 EP5 EP4 EP3 EP2 EP1 EP0
Table 207: USB DMA Request Status register (USBDMARSt - address 0xE009 0050) bit description
Bit Symbol Value Description Reset value
0 EP0 0 Control endpoint OUT (DMA cannot be enabled for this endpoint and EP0 0
bit must be 0).
1 EP1 0 Control endpoint IN (DMA cannot be enabled for this endpoint and EP1 bit 0
must be 0).
31:2 EPxx Endpoint xx (2 ≤ xx ≤ 31) DMA request. 0
0 DMA not requested by endpoint xx.
1 DMA requested by endpoint xx.
[1] DMA can not be enabled for this endpoint and the corresponding bit in the USBDMARSt must be 0.
The USBDMARClr bit allocation is identical to the USBDMARSt register (Table 206).
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Table 208: USB DMA Request Clear register (USBDMARClr - address 0xE009 0054) bit description
Bit Symbol Value Description Reset value
0 EP0 0 Control endpoint OUT (DMA cannot be enabled for this endpoint and the 0
EP0 bit must be 0).
1 EP1 0 Control endpoint IN (DMA cannot be enabled for this endpoint and the EP1 0
bit must be 0).
31:2 EPxx Clear the endpoint xx (2 ≤ xx ≤ 31) DMA request. 0
0 No effect.
1 Clear the corresponding interrupt from the DMA request register.
The software should not clear the DMA request clear bit while the DMA operation is in
progress. But if at all the clearing happens, the behavior of DMA engine will depend on at
what time the clearing is done. There can be more than one DMA requests pending at any
given time. The DMA engine processes these requests serially (i.e starting from EP2 to
EP31). If the DMA request for a particular endpoint is cleared before DMA operation has
started for that request, then the DMA engine will never know about the request and no
DMA operation on that endpoint will be done (till the next request appears). On the other
hand, if the DMA request for a particular endpoint is cleared after the DMA operation
corresponding to that request has begun, it does not matter even if the request is cleared,
since the DMA engine has registered the endpoint number internally and will not sample
the same request before finishing the current DMA operation.
The USBDMARSet bit allocation is identical to the USBDMARSt register (Table 206).
Table 209: USB DMA Request Set register (USBDMARSet - address 0xE009 0058) bit
description
Bit Symbol Value Description Reset
value
0 EP0 0 Control endpoint OUT (DMA cannot be enabled for this endpoint 0
and the EP0 bit must be 0).
1 EP1 0 Control endpoint IN (DMA cannot be enabled for this endpoint and 0
the EP1 bit must be 0).
31:2 EPxx Set the endpoint xx (2 ≤ xx ≤ 31) DMA request interrupt. 0
0 No effect.
1 Set the corresponding interrupt from the DMA request register.
The DMA Request Set register is normally used for the test purpose. It is also useful in the
normal operation mode to avoid a "lock" situation if the DMA is programmed after that the
USB packets are already received. Normally the arrival of a packet generates an interrupt
when it is completely received. This interrupt is used by the DMA to start working. This
works fine as long as the DMA is programmed before the arrival of the packet (2 packets -
if double buffered). If the DMA is programmed "too late", the interrupts were already
generated in slave mode (but not handled because the intention was to use the DMA) and
when the DMA is programmed no interrupts are generated to "activate" it. In this case the
usage of the DMA Request Set register is useful to manually start the DMA transfer.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Table 210: USB UDCA Head register (USBUDCAH - address 0xE009 0080) bit description
Bit Symbol Description Reset value
6:0 - UDCA header is aligned in 128-byte boundaries. 0x00
31:7 UDCA_Header Start address of the UDCA Header. 0
The DMA Request Set register is normally used for the test purpose. It is also useful in the
normal operation mode to avoid a "lock" situation if the DMA is programmed after that the
USB packets are already received. Normally the arrival of a packet generates an interrupt
when it is completely received. This interrupt is used by the DMA to start working. This
works fine as long as the DMA is programmed before the arrival of the packet (2 packets -
if double buffered). If the DMA is programmed "too late", the interrupts were already
generated in slave mode (but not handled because the intention was to use the DMA) and
when the DMA is programmed no interrupts are generated to "activate" it. In this case the
usage of the DMA Request Set register is useful to manually start the DMA transfer.
UDCA NULL
0
NULL NULL
1
NULL
16
DDP-EP16 Next_DD_pointer Next_DD_pointer
DD-EP16-a DD-EP16-b
31
DDP-EP31
Table 211: USB EP DMA Status register (USBEpDMASt - address 0xE009 0084) bit
description
Bit Symbol Value Description Reset
value
0 EP0_DMA_ENABLE 0 Control endpoint OUT (DMA cannot be enabled for 0
this endpoint and the EP0_DMA_ENABLE bit must
be 0).
1 EP1_DMA_ENABLE 0 Control endpoint IN (DMA cannot be enabled for this 0
endpoint and the EP1_DMA_ENABLE bit must be
0).
31:2 EPxx_DMA_ENABLE endpoint xx (2 ≤ xx ≤ 31) DMA enabled bit. 0
0 The DMA for endpoint EPxx is disabled.
1 The DMA for endpoint EPxx is enabled.
Software does not have direct write permission to this register. It has to set the bit through
EP DMA Enable register. Resetting of the bit is done through EP DMA Disable register.
Table 212: USB EP DMA Enable register (USBEpDMAEn - address 0xE009 0088) bit
description
Bit Symbol Value Description Reset
value
0 EP0_DMA_ENABLE 0 Control endpoint OUT (DMA cannot be enabled for 0
this endpoint and the EP0_DMA_ENABLE bit value
must be 0).
1 EP1_DMA_ENABLE 0 Control endpoint IN (DMA cannot be enabled for this 0
endpoint and the EP1_DMA_ENABLE bit must be 0).
31:2 EPxx_DMA_ENABLE Endpoint xx (2 ≤ xx ≤ 31) DMA enable control bit. 0
0 No effect.
1 Enable the DMA operation for endpoint EPxx.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Table 213: USB EP DMA Disable register (USBEpDMADis - address 0xE009 008C) bit
description
Bit Symbol Value Description Reset
value
0 EP0_DMA_DISABLE 0 Control endpoint OUT (DMA cannot be enabled for 0
this endpoint and the EP0_DMA_DISABLE bit value
must be 0).
1 EP1_DMA_DISABLE 0 Control endpoint IN (DMA cannot be enabled for 0
this endpoint and the EP1_DMA_DISABLE bit value
must be 0).
31:2 EPxx_DMA_DISABLE Endpoint xx (2 ≤ xx ≤ 31) DMA disable control bit. 0
0 No effect.
1 Disable the DMA operation for endpoint EPxx.
Table 214: USB DMA Interrupt Status register (USBDMAIntSt - address 0xE009 0090) bit
description
Bit Symbol Value Description Reset
value
0 End_of_Transfer_Interrupt End of Transfer Interrupt bit. 0
0 All bits in the USBEoTIntSt register are 0.
1 At least one bit in the USBEoTIntSt is set.
1 New_DD_Request_Interrupt New DD Request Interrupt bit. 0
0 All bits in the USBNDDRIntSt register are 0.
1 At least one bit in the USBNDDRIntSt is set.
2 System_Error_Interrupt System Error Interrupt bit. 0
0 All bits in the USBSysErrIntSt register are 0.
1 At least one bit in the USBSysErrIntSt is set.
31:3 - - Reserved, user software should not write NA
ones to reserved bits. The value read from a
reserved bit is not defined.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Table 215: USB DMA Interrupt Enable register (USBDMAIntEn - address 0xE009 0094) bit
description
Bit Symbol Value Description Reset
value
0 End_of_Transfer_Interrupt_En End of Transfer Interrupt enable bit. 0
0 The End of Transfer Interrupt is disabled.
1 The End of Transfer Interrupt is enabled.
1 New_DD_Request_Interrupt_En New DD Request Interrupt enable bit. 0
0 The New DD Request Interrupt is
disabled.
1 The New DD Request Interrupt is
enabled.
2 System_Error_Interrupt_En System Error Interrupt enable bit. 0
0 The System Error Interrupt is disabled.
1 The System Error Interrupt is enabled.
31:3 - - Reserved, user software should not write NA
ones to reserved bits. The value read from
a reserved bit is not defined.
Table 216: USB End of Transfer Interrupt Status register (USBEoTIntSt - address
0xE009 00A0s) bit description
Bit Symbol Value Description Reset
value
31:0 EPxx Endpoint xx (0 ≤ xx ≤ 31) End of Transfer Interrupt request. 0
0 There is no End of Transfer interrupt request for endpoint xx.
1 There is an End of Transfer Interrupt request for endpoint xx.
Table 217: USB End of Transfer Interrupt Clear register (USBEoTIntClr - address
0xE009 00A4) bit description
Bit Symbol Value Description Reset
value
31:0 EPxx Clear endpoint xx (0 ≤ xx ≤ 31) End of Transfer Interrupt request. 0
0 Ne effect.
1 Clear the EPxx End of Transfer Interrupt request in the
USBEoTIntSt register.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Table 218: USB End of Transfer Interrupt Set register (USBEoTIntSet - address 0xE009 00A8)
bit description
Bit Symbol Value Description Reset
value
31:0 EPxx Set endpoint xx (0 ≤ xx ≤ 31) End of Transfer Interrupt request. 0
0 Ne effect.
1 Set the EPxx End of Transfer Interrupt request in the
USBEoTIntSt register.
Table 219: USB New DD Request Interrupt Status register (USBNDDRIntSt - address
0xE009 00AC) bit description
Bit Symbol Value Description Reset value
31:0 EPxx Endpoint xx (0 ≤ xx ≤ 31) new DD interrupt request. 0
0 There is no new DD interrupt request for endpoint xx.
1 There is a new DD interrupt request for endpoint xx.
Table 220: USB New DD Request Interrupt Clear register (USBNDDRIntClr - address
0xE009 00B0) bit description
Bit Symbol Value Description Reset value
31:0 EPxx Clear endpoint xx (0 ≤ xx ≤ 31) new DD interrupt request. 0
0 Ne effect.
1 Clear the EPxx new DD interrupt request in the
USBNDDRIntSt register.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Table 221: USB New DD Request Interrupt Set register (USBNDDRIntSet - address
0xE009 00B4) bit description
Bit Symbol Value Description Reset value
31:0 EPxx Set endpoint xx (0 ≤ xx ≤ 31) new DD interrupt request. 0
0 Ne effect.
1 Set the EPxx new DD interrupt request in the
USBNDDRIntSt register.
Table 222: USB System Error Interrupt Status register (USBSysErrIntSt - address
0xE009 00B8) bit description
Bit Symbol Value Description Reset
value
31:0 EPxx Endpoint xx (0 ≤ xx ≤ 31) System Error Interrupt request. 0
0 There is no System Error Interrupt request for endpoint xx.
1 There is a System Error Interrupt request for endpoint xx.
Table 223: USB System Error Interrupt Clear register (USBSysErrIntClr - address
0xE009 00BC) bit description
Bit Symbol Value Description Reset
value
31:0 EPxx Clear endpoint xx (0 ≤ xx ≤ 31) System Error Interrupt request. 0
0 Ne effect.
1 Clear the EPxx System Error Interrupt request in the
USBSysErrIntSt register.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Table 224: USB System Error Interrupt Set register (USBSysErrIntSet - address 0xE009 00C0) bit description
Bit Symbol Value Description Reset
value
31:0 EPxx Set endpoint xx (0 ≤ xx ≤ 31) System Error Interrupt request. 0
0 Ne effect.
1 Set the EPxx System Error Interrupt request in the USBSysErrIntSt register.
These commands have to be written into the Command Code register (Section 14.8.9).
The read data when present will be available in the Command Data register
(Section 14.8.10) after the successful execution of the command. Table 225 lists all
protocol engine commands.
Here is an example of the Read Current Frame Number command (reading 2 bytes):
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
[1] This bit should be reset to 0 if the DMA is enabled for any of the Interrupt OUT endpoints.
[2] This bit should be reset to 0 if the DMA is enabled for any of the Bulk OUT endpoints.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
• In case no SOF was received by the device at the beginning of a frame, the frame
number returned is that of the last successfully received SOF.
• In case the SOF frame number contained a CRC error, the frame number returned will
be the corrupted frame number as received by the device.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
14.9.10 Select Endpoint (Command: 0x00 - 0x1F, Data: read 1 byte (optional))
The Select Endpoint command initializes an internal pointer to the start of the selected
buffer in EP_RAM. Optionally, this command can be followed by a data read, which
returns some additional information on the packet in the buffer. The command code of
‘select endpoint’ is equal to the physical endpoint number. In the case of single buffer,
B_2_FULL bit is not valid.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
• They clear the associated interrupt in the USB clock domain only.
• In case of a control out endpoint, they clear the setup and over-written bits
• Reading one byte is obligatory.
14.9.12 Set Endpoint Status (Command: 0x40 - 0x55, Data: write 1 byte
(optional))
The Set Endpoint Status command sets status bits ‘7:5’ and 0 of the endpoint. The
Command Code of Set Endpoint Status is equal to the sum of 0x40 and the physical
endpoint number in hex value. Not all bits can be set for all types of endpoints.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
When bit 0 of the optional data byte is 1, the previously received packet was over-written
by a SETUP packet. The Packet overwritten bit is used only in control transfers. According
to the USB specification, SETUP packet should be accepted irrespective of the buffer
status. The software should always check the status of the PO bit after reading the
SETUP data. If it is set then it should discard the previously read data, clear the PO bit by
issuing a Select Endpoint/Clear Interrupt command, read the new SETUP data and again
check the status of the PO bit.
A control IN buffer cannot be validated when the Packet Over-written bit of its
corresponding OUT buffer is set or when the Set up packet is pending in the buffer. For the
control endpoint the validated buffer will be invalidated when a Setup packet is received.
The DMA descriptors are placed in the USB RAM. These descriptors can be located
anywhere in the USB RAM in the wordaligned boundaries. USB RAM is part of the system
memory which is used for the USB purposes. It is located at address 0x7FD0 0000 and is
8192 bytes (8 kB) in size.
DD for non-isochronous endpoints are four-word long and isochronous endpoints are
five-word long.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
There are certain parameters associated with a DMA transfer. These are:
14.10.1 Next_DD_pointer
Pointer to the memory location from where the next DMA descriptor has to be fetched.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
14.10.2 DMA_mode
Defines in which mode the DMA has to operate. Two modes have been defined, Normal
and ATLE. In the normal mode the DMA engine will not split a packet into two different
DMA buffers. In the ATLE mode splitting of the packet into two buffers can happen. This is
because two transfers can be concatenated in the packet to improve the bandwidth. See
Section 14.13 “Concatenated transfer (ATLE) mode operation” on page 236 for more
details.
14.10.3 Next_DD_valid
This bit indicates whether the software has prepared the next DMA descriptor. If it is valid,
the DMA engine once finished with the current descriptor will load the new descriptor.
14.10.4 Isochronous_endpoint
The descriptor belongs to an isochronous endpoint. Hence, 5 words have to be read.
14.10.5 Max_packet_size
The maximum packet size of the endpoint. This parameter has to be used while
transferring the data for IN endpoints from the memory. It is used for OUT endpoints to
detect the short packet. This is applicable to non-isochronous endpoints only. The
max_packet_size field should be the same as the value set in the MaxPacketSize register
for the endpoint.
14.10.6 DMA_buffer_length
This indicates the depth of the DMA buffer allocated for transferring the data. The DMA
engine will stop using this descriptor when this limit is reached and will look for the next
descriptor. This will be set by the software in the normal mode operation for both IN and
OUT endpoints.In the ATLE mode operation the buffer_length is set by software for IN
endpoints. For OUT endpoints this is set by the hardware from the extracted length of the
data stream. In case of the Isochronous endpoints the DMA_buffer_length is specified in
terms of number of packets.
14.10.7 DMA_buffer_start_addr
The address from where the data has to be picked up or to be stored. This field is updated
packet-wise by DMA engine.
14.10.8 DD_retired
This bit is set when the DMA engine finishes the current descriptor. This will happen when
the end of the buffer is reached or a short packet is transferred (no isochronous endpoints)
or an error condition is detected.
14.10.9 DD_status
The status of the DMA transfer is encoded in this field. The following status are defined:
• Not serviced - No packet has been transferred yet. DD is in the initial position itself.
• Being serviced - This status indicates that at least one packet is transferred.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
• Normal completion - The DD is retired because the end of the buffer is reached and
there were no errors. DD_retired bit also is set.
• Data under run - Before reaching the end of the buffer, transfer is terminated
because a short packet is received. DD_retired bit also is set.
• Data over run - End of the DMA buffer is reached in the middle of a packet transfer.
This is an error situation. DD_retired bit will be set. The DMA count will show the value
of DMA buffer length. The packet has to be re-transmitted from the FIFO.
DMA_ENABLE bit is reset.
• System error - Transfer is terminated because of an error in the system bus.
DD_retired bit is not set in this case. DMA_ENABLE bit is reset. Since system error
can happen while updating the DD, the DD fields in the USB RAM may not be very
reliable.
14.10.10 Packet_valid
This bit indicates whether the last packet transferred to the memory is received with errors
or not. This bit will be set if the packet is valid, i.e., it was received without errors. Since
non-isochronous endpoint will not generate DMA request for packet with errors, this field
will not make much sense to them as it will be set for all packets transferred. But for
isochronous endpoints this information is useful. See Section 14.14 “Isochronous
Endpoint Operation” on page 240 for isochronous endpoint operation.
14.10.11 LS_byte_extracted
Applicable only in the ATLE mode. This bit set indicates that the Least Significant Byte
(LSB) of the transfer length has been already extracted. The extracted size will be
reflected in the ‘dma_buffer_length’ field in the bits 23:16.
14.10.12 MS_byte_extracted
Applicable only in the ATLE mode. This bit set indicates that the Most Significant Byte
(MSB) of the transfer size has been already extracted. The size extracted will be reflected
in the ‘dma_buffer_length’ field at 31:24. Extraction stops when ‘LS_Byte_extracted’ and
‘MS_byte_extracted’ fields are set.
14.10.13 Present_DMA_count
The number of bytes transferred by the DMA engine at any point of time. This is updated
packet-wise by the DMA engine when it updates the descriptor. In case of the Isochronous
endpoints the Present_DMA_count is specified in terms of number of packets transferred.
14.10.14 Message_length_position
This applies only in the ATLE mode. This field gives the offset of the message length
position embedded in the packet. This is applicable only for OUT endpoints. Offset 0
indicates that the message length starts from the first byte of the packet onwards.
14.10.15 Isochronous_packetsize_memory_address
The memory buffer address where the packet size information along with the frame
number has to be transferred or fetched. See Figure 55. This is applicable to isochronous
endpoints only.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
The DMA transfer for an OUT endpoint is triggered when it receives a packet without any
errors (i.e., the buffer is full) and the DMA_ENABLE (Section 14.8.15 “USB EP DMA
Status register (USBEpDMASt - 0xE009 0084)”) bit is set for this endpoint.
Transfer for an IN endpoint is triggered when the host requests for a packet of data and
the DMA_ENABLE bit is set for this endpoint.
In DMA mode, the bits corresponding to Interrupt on NAK for Bulk OUT and Interrupt OUT
endpoints (bit INAK_BO and INAK_IO) in Set Mode register (Section 14.9.3 “Set Mode
(Command: 0xF3, Data: write 1 byte)”) should be reset to 0.
If a new descriptor has to be read, the DMA engine will calculate the location of the DDP
for this endpoint and will fetch the start address of DD from this location. A DD start
address at location zero is considered invalid. In this case a ‘new_dd_request’ interrupt is
raised. All other word boundaries are valid.
At any point of time if the DD is to be fetched, the status of DD (word 3) is read first and
the status of the ‘DD_retired’ bit is checked. If this is not set, DDP points to a valid DD. If
the ‘DD_retired’ bit is set, the DMA engine will read the ‘control’ field (word 1) of the DD.
If the bit ‘next_DD_valid’ bit’ is set, the DMA engine will fetch the ‘next_dd_pointer’ field
(word 0) of the DD and load it to the DDP. The new DDP is written to the UDCA area.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
The full DMA descriptor (4 words) will in turn be fetched from this address pointed by DDP.
The DD will give the details of the transfer to be done. The DMA engine will load its
hardware resources with the information fetched from the DD (start address, DMA count
etc.).
If the ‘next_dd_valid’ is not set and the DD_retired bit is set the DMA engine will raise the
‘NEW_DD_REQUEST’ interrupt for this endpoint. It also disables the DMA_ENABLE bit.
USB RAM
0
UDCA Head
Register 1 DD-EP2
2
DDP-EP2
USB
Device 31 DD-EP31
Controller DDP-EP31
This flag will be reset after the required number of bytes specified in the
‘dma_buffer_length’ field is transferred. It is also reset when the software writes into the
EP DMA Disable register. This will give the software control over the reading of DD by the
hardware. Hardware will be forced to read the DD for the next packet. Writing data 0x0
into the EP DMA Disable register will cause only resetting of the DMA_PROCEED flag
without disabling DMA for any endpoint.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Normal completion - If the current packet is fully transferred and the ‘dma_count’ field
equals the ‘dma_buffer_length’ defined in the descriptor, the DD has a normal
completion. The DD will be written back to memory with ‘DD_retired’ bit set.
END_OF_TRANSFER interrupt is raised for this endpoint. DD_Status bits are updated
for ‘normal_completion’ code.
Transfer end completion - If the current packet is fully transferred and its size is less
than the ‘max_packet_size’ defined in the descriptor, and the end of the buffer is still not
reached the transfer end completion occurs. The DD will be written back to the memory
with ‘DD_retired’ bit set and DD_Status bits showing ‘data under run’ completion code.
Also, the ‘END_OF_TRANSFER’ interrupt for this endpoint is raised.
Error completion - If the current packet is partially transferred i.e. end of the DMA
buffer is reached in the middle of the packet transfer, an error situation occurs. The DD
is written back with DD_status ‘data over run’ and ‘DD_retired’ bit is set. The DMA
engine will raise the end of transfer interrupt and resets the corresponding bit for this
endpoint in the ‘DMA_ENABLE’ register. This packet will be retransmitted to the
memory fully when DMA_ENABLE bit is set again.
14.12.6 No_Packet DD
For IN transfers, it can happen that for a request, the system does not have any data to
send for a long time. The system can suppress this request by programming a no_packet
DD. This is done by setting the ‘Maxpacketsize’ and ‘dma_buffer_length’ in the DD control
field to 0. No packets will be sent to the host in response to the no_packet DD.
In ATLE mode, the Host driver can concatenate various transfer lengths, which
correspond to different DMA descriptors on Device side. And these transfers have to be
done on USB without breaking the packet. This is the primary difference between the
Normal Mode of DMA operation and ATLE mode, wherein one DMA transfer length ends
with either a full USB packet or a short packet and next DMA transfer length starts with a
new USB packet in Normal mode, but these two transfers may be concatenated in the last
USB packet of the first DMA transfer in ATLE mode.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
64 bytes
32 bytes
32 bytes
100 bytes
100 bytes
64 bytes DMA_buffer_start_
address of DD2
4 bytes
Figure 54 shows a typical OUT transfer, where the host concatenates two DMA transfer
lengths of 160 bytes and 100 bytes respectively. As seen on USB, there would be four
packets of 64 bytes (MPS = 64) and a short packet of 4 bytes in ATLE mode unlike Normal
mode with five packets of 64, 64, 32, 64, 36 bytes in the given order.
It is now responsibility of the DMA engine to separate these two transfers and put them in
proper memory locations as pointed by the "DMA_buffer_start_address" field of DMA
Descriptor 1 (DD1) and DMA Descriptor 2 (DD2).
There are two things in OUT transfer of ATLE mode, which differentiate it from the OUT
transfer in Normal mode of DMA operation. The first one is that the Device software does
not know the "DMA_buffer_length" of the incoming transfer and hence this field in DD is
programmed to 0. But by the NDIS protocol, device driver does know at which location in
the incoming data transfer, will the transfer length be stored. This value is programmed in
the field "Message_length_position" of the DD.
It is responsibility of the hardware to read the two byte wide "DMA_buffer_length" at the
offset (from start of transfer) specified by "Message_length_position", from incoming data
and write it in "DMA_buffer_length" field of the DD. Once this information is extracted from
the incoming data and updated in the DD, the transfer continues as in Normal mode of
operation.
It may happen that the message length position points to the last byte in the USB packet,
which means that out of two bytes of buffer length, first (LS) byte is available in the current
packet, and the second (MS) byte would follow in the next packet. To deal with such
situations, the flags "LS_byte_extracted" and "MS_byte_extracted" are used by hardware.
When the hardware reads the LS byte (which is the last byte of USB packet), it writes the
contents of LS byte in position (23:16) of "DMA_buffer_length" field, sets the flag
"LS_byte_extracted" to 1 and updates the DD in System memory (since the packet
transfer is over).
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
The second thing, which differentiates the ATLE mode OUT transfer from Normal mode
OUT transfer, is the behavior in case when DD is retired in between a USB packet
transfer.
As can be seen in the figure earlier, the first 32 bytes of the 3rd packet correspond to DD1
and the remaining 32 bytes correspond to DD2. In such a situation, on reception of first 32
bytes, the first DD (i.e. DD1) is retired and updated in the system memory, the new DD
(pointed by "next_DD_pointer") is fetched and the remaining 32 bytes are transferred to
the location in system memory pointed by "DMA_buffer_start_address" of new DD (i.e.
DD2).
It should be noted that in ATLE mode, the software will always program the
"LS_byte_extracted" and "MS_byte_extracted" fields to 0 while preparing a DD, and hence
on fetching the DD2 in above situation, the Buffer Length Extraction process will start
again as described earlier.
In case if the first DD is retired in between the packet transfer and the next DD is not
programmed, i.e. "next_DD_valid" field in DD1 is 0, then the first DD is retired with the
status "data over run" (DD_status = 1000), which has to be treated as an err or condition
and the DMA channel for that particular endpoint is disabled by the hardware. Otherwise
the first DD is retired with status "normal completion" (DD_status = 0010).
Please note that in this mode the last buffer length to be transferred would always end with
a short packet or empty packet indicating that no more concatenated data is coming on
the way. If the concatenated transfer lengths are such that the last transfer ends on a
packet boundary, the (NDIS) host will send an empty packet to mark the End Of Transfer.
The operation in IN transfers is relatively simple than the OUT transfer in ATLE mode
since device software knows the buffer length to be transferred and it is programmed in
"DMA_buffer_length" field while preparing the DD, thus avoiding any transfer length
extraction mechanism.
The only difference for IN transfers between ATLE mode and Normal mode of DMA
operation is that the DDs can get retired in the middle of the USB packet transfer. In such
a case, the hardware will update the first DD in system memory, fetch the new DD pointed
by "next_DD_pointer" field of the first DD and fetch the remaining bytes from system
memory pointed by "DMA_buffer_start_address" of second DD to complete the packet
before sending it on USB.
In the above situation, if the next DD is not programmed, i.e. "next_DD_valid" field in DD is
0, and the buffer length for current DD has completed before the packet boundary, then
the available bytes from current DD are sent as a short packet on USB, which marks the
End Of Transfer for the Host.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
In cases, where the intended buffer lengths are already transferred and the last buffer
length has completed on the USB packet boundary, it is responsibility of Device software
to program the next DD with "DMA_buffer_length" field 0, after which an empty packet is
sent on USB by the hardware to mark the End Of Transfer for the Host.
For IN endpoints, descriptors are to be set in the same way as the normal mode operation.
Since a single packet can have two transfers which has to be transferred or collected from
different DMA buffers, the software should keep two buffers ready always, except for the
last delta transfer which ends with a short packet.
For IN endpoints transfer proceeds like the normal mode and continues till the number of
bytes transferred equals the ‘dma_buffer_length’.
For an OUT endpoint if the linked DD is not valid and the packet is partially transferred to
memory, the DD ends with data_over_run status set and DMA will be disabled for this
endpoint. Otherwise DD_status will be updated with ‘normal completion’.
For an IN endpoint if the linked DD is not valid and the packet is partially transferred to
USB, DD ends with ‘normal completion’ and the packet will be sent as a short packet
(since this situation is the end of transfer). Also, when the linked DD is valid and buffer
length is 0, a short packet will be sent.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
DMA descriptor has a bit field in the word 1 (isochronous_endpoint) to indicate that the
descriptor belongs to an isochronous endpoint. Also, isochronous DD has a fifth word
showing where the packet length for the frame has to be put (for OUT endpoint) or from
where it has to be read.
DMA request will be placed for DMA enabled isochronous endpoints on every frame
interrupt. For a DMA request the DMA engine will fetch the descriptor and if it identifies
that the descriptor belongs to an Isochronous endpoint, it will fetch the fifth word of the DD
which will give the location from where the packet length has to be placed or fetched.
For an OUT transfer a word is formed by combining the frame number and the packet
length such that the packet length appears at the least significant 2 bytes (15 to 0). Bit 16
shows whether the packet is valid or not (set when packet is valid i.e. it was received
without any errors). The frame number appears in the most significant 2 bytes (bit 31 to
17). The frame number is available from the USB device. This word is then transferred to
the address location pointed by the variable Isochronous_packet_size_memory_address.
The Isochronous_packet_size_memory_address is incremented by 4 after receiving or
transmitting an Isochronous data packet. The Isochronous_packet_size memory buffer
should be big enough to hold information of all packets sent by the host.
For an IN endpoint only the bits from 15 to 0 are applicable. An Isochronous data packet of
size specified by this field is transferred from the USB device to the Host in each frame. If
the size programmed in this location is zero an empty packet will be sent by the USB
device.
The Isochronous endpoint works only in the normal mode DMA operation.
An Isochronous endpoint can have only ‘normal completion’ since there is no short packet
on Isochronous endpoint and the transfer continues infinitely till a system error occurs.
Also, there is no data_over_run detection.
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
The sixteenth bit for all the words in the packet length memory will be set to 1.
Next_DD_Pointer
W0
NULL
DMA_buffer_length Max_packet_size Isochronous_endpoint Next_DD_Valid DMA_mode
W1
0x000A 0x0 1 0 0
DMA_buffer_start_addr
W2
0x80000000
Present_DMA_Count ATLE settings Packet_Valid DD_Status DD_Retired
W3
0x0 NA NA 0x0 0
Isocronous_packetsize_memory_address
W4
0x60000000
After 4 packets
W0 0x0 Full
W1 0x000A0010
W2 0x80000035
Empty
W3 0x4 - - 0x1 0
Frame Number Packet_Valid PacketLength
W4 0x60000010 31 16 15 0
21 1 10
22 1 15 Data memory
23 1 8
24 1 20
9397 750 XXXXX © Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Timer/Counter0 and Timer/Counter1 are functionally identical except for the peripheral
base address.
15.1 Features
• A 32-bit Timer/Counter with a programmable 32-bit Prescaler.
• Counter or Timer operation
• Up to four 32-bit capture channels per timer, that can take a snapshot of the timer
value when an input signal transitions. A capture event may also optionally generate
an interrupt.
• Four 32-bit match registers that allow:
– Continuous operation with optional interrupt generation on match.
– Stop timer on match with optional interrupt generation.
– Reset timer on match with optional interrupt generation.
• Up to four external outputs corresponding to match registers, with the following
capabilities:
– Set low on match.
– Set high on match.
– Toggle on match.
– Do nothing on match.
15.2 Applications
• Interval Timer for counting internal events.
• Pulse Width Demodulator via Capture inputs.
• Free running timer.
15.3 Description
The Timer/Counter is designed to count cycles of the peripheral clock (PCLK) or an
externally-supplied clock, and can optionally generate interrupts or perform other actions
at specified timer values, based on four match registers. It also includes four capture
inputs to trap the timer value when an input signal transitions, optionally generating an
interrupt.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
15.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 the
capture interrupts. If an interrupt is generated then the corresponding bit in the IR will be
high. Otherwise, the bit will be low. Writing a logic one to the corresponding IR bit will reset
the interrupt. Writing a zero has no effect.
Table 238: Interrupt Register (IR, TIMER0: T0IR - address 0xE000 4000 and TIMER1: T1IR - address 0xE000 8000) bit
description
Bit Symbol Description Reset value
0 MR0 Interrupt Interrupt flag for match channel 0. 0
1 MR1 Interrupt Interrupt flag for match channel 1. 0
2 MR2 Interrupt Interrupt flag for match channel 2. 0
3 MR3 Interrupt Interrupt flag for match channel 3. 0
4 CR0 Interrupt Interrupt flag for capture channel 0 event. 0
5 CR1 Interrupt Interrupt flag for capture channel 1 event. 0
6 CR2 Interrupt Interrupt flag for capture channel 2 event. 0
7 CR3 Interrupt Interrupt flag for capture channel 3 event. 0
15.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.
Table 239: Timer Control Register (TCR, TIMER0: T0TCR - address 0xE000 4004 and TIMER1:
T1TCR - address 0xE000 8004) bit description
Bit Symbol Description Reset value
0 Counter Enable When one, the Timer Counter and Prescale Counter are 0
enabled for counting. When zero, the counters are
disabled.
1 Counter Reset When one, the Timer Counter and the Prescale Counter 0
are synchronously reset on the next positive edge of
PCLK. The counters remain reset until TCR[1] is
returned to zero.
7:2 - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is not
defined.
15.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/low levels on the same CAP input in this
case can not be shorter than 1/PCLK.
Table 240: Count Control Register (CTCR, TIMER0: T0CTCR - address 0xE000 4070 and
TIMER1: T1TCR - address 0xE000 8070) bit description
Bit Symbol Value Description Reset
value
1:0 Counter/ This field selects which rising PCLK edges can increment 00
Timer Timer’s Prescale Counter (PC), or clear PC and increment
Mode Timer Counter (TC).
00 Timer Mode: every rising PCLK edge
01 Counter Mode: TC is incremented on rising edges on the
CAP input selected by bits 3:2.
10 Counter Mode: TC is incremented on falling edges on the
CAP input selected by bits 3:2.
11 Counter Mode: TC is incremented on both edges on the CAP
input selected by bits 3:2.
Table 240: Count Control Register (CTCR, TIMER0: T0CTCR - address 0xE000 4070 and
TIMER1: T1TCR - address 0xE000 8070) bit description
Bit Symbol Value Description Reset
value
3:2 Count When bits 1:0 in this register are not 00, these bits select 00
Input which CAP pin is sampled for clocking:
Select 00 CAPn.0 (CAP0.0 for TIMER0 and CAP1.0 for TIMER1)
01 CAPn.1 (CAP0.1 for TIMER0 and CAP1.1 for TIMER1)
10 CAPn.2 (CAP0.2 for TIMER0 and CAP1.2 for TIMER1)
11 CAPn.3 (CAP0.3 for TIMER0 and CAP1.3 for TIMER1)
Note: If Counter mode is selected for a particular CAPn input
in the TnCTCR, the 3 bits for that input in the Capture Control
Register (TnCCR) must be programmed as 000. However,
capture and/or interrupt can be selected for the other 3 CAPn
inputs in the same timer.
7:4 - - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
15.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 the
value 0xFFFF FFFF and then wrap back to the value 0x0000 0000. This event does not
cause an interrupt, but a Match register can be used to detect an overflow if needed.
15.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.
15.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 is
applied to the Timer Counter. This allows control of the relationship of the resolution of the
timer versus the maximum time before the timer overflows. The Prescale Counter is
incremented on every PCLK. When it reaches the value stored in the Prescale Register,
the Timer Counter is incremented and the Prescale Counter is reset on the next PCLK.
This causes the TC to increment on every PCLK when PR = 0, every 2 PCLKs when
PR = 1, etc.
15.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 shown
in Table 241.
Table 241: Match Control Register (MCR, TIMER0: T0MCR - address 0xE000 4014 and TIMER1: T1MCR - address
0xE000 8014) bit description
Bit Symbol Value Description Reset
value
0 MR0I 1 Interrupt on MR0: an interrupt is generated when MR0 matches the value in the TC. 0
0 This interrupt is disabled
1 MR0R 1 Reset on MR0: the TC will be reset if MR0 matches it. 0
0 Feature disabled.
2 MR0S 1 Stop on MR0: the TC and PC will be stopped and TCR[0] will be set to 0 if MR0 matches 0
the TC.
0 Feature disabled.
3 MR1I 1 Interrupt on MR1: an interrupt is generated when MR1 matches the value in the TC. 0
0 This interrupt is disabled
4 MR1R 1 Reset on MR1: the TC will be reset if MR1 matches it. 0
0 Feature disabled.
5 MR1S 1 Stop on MR1: the TC and PC will be stopped and TCR[0] will be set to 0 if MR1 matches 0
the TC.
0 Feature disabled.
6 MR2I 1 Interrupt on MR2: an interrupt is generated when MR2 matches the value in the TC. 0
0 This interrupt is disabled
7 MR2R 1 Reset on MR2: the TC will be reset if MR2 matches it. 0
0 Feature disabled.
8 MR2S 1 Stop on MR2: the TC and PC will be stopped and TCR[0] will be set to 0 if MR2 matches 0
the TC.
0 Feature disabled.
9 MR3I 1 Interrupt on MR3: an interrupt is generated when MR3 matches the value in the TC. 0
0 This interrupt is disabled
10 MR3R 1 Reset on MR3: the TC will be reset if MR3 matches it. 0
0 Feature disabled.
11 MR3S 1 Stop on MR3: the TC and PC will be stopped and TCR[0] will be set to 0 if MR3 matches 0
the TC.
0 Feature disabled.
15:12 - Reserved, user software should not write ones to reserved bits. The value read from a NA
reserved bit is not defined.
15.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 the
same time is a valid configuration, resulting in a capture event for both edges. In the
description below, "n" represents the Timer number, 0 or 1.
Table 242: Capture Control Register (CCR, TIMER0: T0CCR - address 0xE000 4028 and TIMER1: T1CCR - address
0xE000 8028) bit description
Bit Symbol Value Description Reset
value
0 CAP0RE 1 Capture on CAPn.0 rising edge: a sequence of 0 then 1 on CAPn.0 will cause CR0 to 0
be loaded with the contents of TC.
0 This feature is disabled.
1 CAP0FE 1 Capture on CAPn.0 falling edge: a sequence of 1 then 0 on CAPn.0 will cause CR0 to 0
be loaded with the contents of TC.
0 This feature is disabled.
2 CAP0I 1 Interrupt on CAPn.0 event: a CR0 load due to a CAPn.0 event will generate an interrupt. 0
0 This feature is disabled.
3 CAP1RE 1 Capture on CAPn.1 rising edge: a sequence of 0 then 1 on CAPn.1 will cause CR1 to 0
be loaded with the contents of TC.
0 This feature is disabled.
4 CAP1FE 1 Capture on CAPn.1 falling edge: a sequence of 1 then 0 on CAPn.1 will cause CR1 to 0
be loaded with the contents of TC.
0 This feature is disabled.
5 CAP1I 1 Interrupt on CAPn.1 event: a CR1 load due to a CAPn.1 event will generate an interrupt. 0
0 This feature is disabled.
6 CAP2RE 1 Capture on CAPn.2 rising edge: A sequence of 0 then 1 on CAPn.2 will cause CR2 to 0
be loaded with the contents of TC.
0 This feature is disabled.
7 CAP2FE 1 Capture on CAPn.2 falling edge: a sequence of 1 then 0 on CAPn.2 will cause CR2 to 0
be loaded with the contents of TC.
0 This feature is disabled.
8 CAP2I 1 Interrupt on CAPn.2 event: a CR2 load due to a CAPn.2 event will generate an interrupt. 0
0 This feature is disabled.
9 CAP3RE 1 Capture on CAPn.3 rising edge: a sequence of 0 then 1 on CAPn.3 will cause CR3 to 0
be loaded with the contents of TC.
0 This feature is disabled.
Table 242: Capture Control Register (CCR, TIMER0: T0CCR - address 0xE000 4028 and TIMER1: T1CCR - address
0xE000 8028) bit description
Bit Symbol Value Description Reset
value
10 CAP3FE 1 Capture on CAPn.3 falling edge: a sequence of 1 then 0 on CAPn.3 will cause CR3 to 0
be loaded with the contents of TC
0 This feature is disabled.
11 CAP3I 1 Interrupt on CAPn.3 event: a CR3 load due to a CAPn.3 event will generate an interrupt. 0
0 This feature is disabled.
15:12 - Reserved, user software should not write ones to reserved bits. The value read from a NA
reserved bit is not defined.
15.5.11 External Match Register (EMR, TIMER0: T0EMR - 0xE000 403C; and
TIMER1: T1EMR - 0xE000 803C)
The External Match Register provides both control and status of the external match pins
MAT(0-3).
Table 243: External Match Register (EMR, TIMER0: T0EMR - address 0xE000 403C and TIMER1: T1EMR -
address0xE000 803C) bit description
Bit Symbol Description Reset
value
0 EM0 External Match 0. This bit reflects the state of output MAT0.0/MAT1.0, whether or not this 0
output is connected to its pin. When a match occurs between the TC and MR0, this output
of the timer can either toggle, go low, go high, or do nothing. Bits EMR[5:4] control the
functionality of this output.
1 EM1 External Match 1. This bit reflects the state of output MAT0.1/MAT1.1, whether or not this 0
output is connected to its pin. When a match occurs between the TC and MR1, this output
of the timer can either toggle, go low, go high, or do nothing. Bits EMR[7:6] control the
functionality of this output.
2 EM2 External Match 2. This bit reflects the state of output MAT0.2/MAT1.2, whether or not this 0
output is connected to its pin. When a match occurs between the TC and MR2, this output
of the timer can either toggle, go low, go high, or do nothing. Bits EMR[9:8] control the
functionality of this output.
3 EM3 External Match 3. This bit reflects the state of output MAT0.3/MAT1.3, whether or not this 0
output is connected to its pin. When a match occurs between the TC and MR3, this output
of the timer can either toggle, go low, go high, or do nothing. Bits EMR[11:10] control the
functionality of this output.
5:4 EMC0 External Match Control 0. Determines the functionality of External Match 0. Table 244 00
shows the encoding of these bits.
7:6 EMC1 External Match Control 1. Determines the functionality of External Match 1. Table 244 00
shows the encoding of these bits.
9:8 EMC2 External Match Control 2. Determines the functionality of External Match 2. Table 244 00
shows the encoding of these bits.
11:10 EMC3 External Match Control 3. Determines the functionality of External Match 3. Table 244 00
shows the encoding of these bits.
15:12 - Reserved, user software should not write ones to reserved bits. The value read from a NA
reserved bit is not defined.
Figure 57 shows a timer configured to stop and generate an interrupt on match. The
prescaler is again set to 2 and the match register set to 6. In the next clock after the timer
reaches the match value, the timer enable bit in TCR is cleared, and the interrupt
indicating that a match occurred is generated.
PCLK
Prescale
2 0 1 2 0 1 2 0 1 2 0 1
counter
Timer
4 5 6 0 1
counter
Timer counter
reset
Iterrupt
Fig 56. A timer cycle in which PR=2, MRx=6, and both interrupt and reset on match are enabled
PCLK
Prescale
2 0 1 2 0
counter
Timer
4 5 6
counter
TCR[0]
1 0
(counter enable)
Iterrupt
Fig 57. A timer cycle in which PR=2, MRx=6, and both interrupt and stop on match are enabled
15.7 Architecture
The block diagram for TIMER/COUNTER0 and TIMER/COUNTER1 is shown in
Figure 58.
MATCH REGISTER 0
MATCH REGISTER 1
MATCH REGISTER 2
MATCH REGISTER 3
INTRRUPT REGISTER
CONTROL
=
MAT[3:0]
INTERRUPT
=
CAP[3:0]
STOP ON MATCH =
RESET ON MATCH
=
LOAD[3:0]
CSN
CAPTURE REGISTER 0 TIMER COUNTER
CAPTURE REGISTER 1 CE
CAPTURE REGISTER 2
CAPTURE REGISTER 3*
TCI
PCLK
PRESCALE COUNTER
16.1 Features
• Seven match registers allow up to 6 single edge controlled or 3 double edge
controlled PWM outputs, or a mix of both types. The match registers also allow:
– Continuous operation with optional interrupt generation on match.
– Stop timer on match with optional interrupt generation.
– Reset timer on match with optional interrupt generation.
• An external output for each match register with the following capabilities:
– Set low on match.
– Set high on match.
– Toggle on match.
– Do nothing on match.
• Supports single edge controlled and/or double edge controlled PWM outputs. Single
edge controlled PWM outputs all go high at the beginning of each cycle unless the
output is a constant low. Double edge controlled PWM outputs can have either edge
occur at any position within a cycle. This allows for both positive going and negative
going pulses.
• Pulse period and width can be any number of timer counts. This allows complete
flexibility in the trade-off between resolution and repetition rate. All PWM outputs will
occur at the same repetition rate.
• Double edge controlled PWM outputs can be programmed to be either positive going
or negative going pulses.
• Match register updates are synchronized with pulse outputs to prevent generation of
erroneous pulses. Software must "release" new match values before they can
become effective.
• May be used as a standard timer if the PWM mode is not enabled.
• A 32-bit Timer/Counter with a programmable 32-bit Prescaler.
• Four 32-bit capture channels take a snapshot of the timer value when an input signal
transitions. A capture event may also optionally generate an interrupt.
16.2 Description
The PWM is based on the standard Timer block and inherits all of its features, although
only the PWM function is pinned out on the LPC2141/2/4/6/8. The Timer is designed to
count cycles of the peripheral clock (PCLK) and optionally generate interrupts or perform
other actions when specified timer values occur, based on seven match registers. It also
includes four capture inputs to save the timer value when an input signal transitions, and
optionally generate an interrupt when those events occur. The PWM function is in addition
to these features, and is based on match register events.
The ability to separately control rising and falling edge locations allows the PWM to be
used for more applications. For instance, multi-phase motor control typically requires three
non-overlapping PWM outputs with individual control of all three pulse widths and
positions.
Two match registers can be used to provide a single edge controlled PWM output. One
match register (PWMMR0) controls the PWM cycle rate, by resetting the count upon
match. The other match register controls the PWM edge position. Additional single edge
controlled PWM outputs require only one match register each, since the repetition rate is
the same for all PWM outputs. Multiple single edge controlled PWM outputs will all have a
rising edge at the beginning of each PWM cycle, when an PWMMR0 match occurs.
Three match registers can be used to provide a PWM output with both edges controlled.
Again, the PWMMR0 match register controls the PWM cycle rate. The other match
registers control the two PWM edge positions. Additional double edge controlled PWM
outputs require only two match registers each, since the repetition rate is the same for all
PWM outputs.
With double edge controlled PWM outputs, specific match registers control the rising and
falling edge of the output. This allows both positive going PWM pulses (when the rising
edge occurs prior to the falling edge), and negative going PWM pulses (when the falling
edge occurs prior to the rising edge).
Figure 59 shows the block diagram of the PWM. The portions that have been added to the
standard timer block are on the right hand side and at the top of the diagram.
Match 1 PWMENA1
R EN
MATCH 0
PWMSEL2
PWM2
LATCH ENABLE REGISTER CLEAR MUX S Q
= PWM3
CONTROL MUX S Q
= Match 3 PWMENA3
M[6.0]
R EN
INTERRUPT
=
PWMSEL4
STOP ON MATCH
RESET ON MATCH PWM4
= MUX S Q
= Match 4 PWMENA4
R EN
CSN =
PWMSEL5
PWM5
MUX S Q
Match 5 PWMENA5
R EN
CE PWM6
MUX S Q
TCI
Match 6 PWMENA6
PRESCALE COUNTER R EN
PWMENA1..6 PWMSEL2..6
ENABLE
MAXVAL
RESET
PRESCALE REGISTER PWM CONTROL REGISTER
TIMER CONTROL REGISTER
Note: this diagram is intended to clarify the function of the PWM rather than to suggest a specific design implementation.
A sample of how PWM values relate to waveform outputs is shown in Figure 60. PWM
output logic is shown in Figure 59 that allows selection of either single or double edge
controlled PWM outputs via the muxes controlled by the PWMSELn bits. The match
register selections for various PWM outputs is shown in Table 245. This implementation
supports up to N-1 single edge PWM outputs or (N-1)/2 double edge PWM outputs, where
N is the number of match registers that are implemented. PWM types can be mixed if
desired.
The waveforms below show a single PWM cycle and demonstrate PWM outputs under the
following conditions:
The timer is configured for PWM mode. The match register values are as follows:
Match 0 is configured to reset the timer/counter MRO = 100 (PWM rate)
when a match event occurs. MR1 = 41, MR2 = 78 (PWM2 output)
Control bits PWMSEL2 and PWMSEL4 are set. MR3 = 53, MR4 = 27 (PWM4 output)
MR5 = 65 (PWM5 output)
PWM2
PWM4
PWM5
0 27 41 53 65 78 100
(counter is reset)
[1] Identical to single edge mode in this case since Match 0 is the neighboring match register. Essentially,
PWM1 cannot be a double edged output.
[2] It is generally not advantageous to use PWM channels 3 and 5 for double edge PWM outputs because it
would reduce the number of double edge PWM outputs that are possible. Using PWM 2, PWM4, and
PWM6 for double edge PWM outputs provides the most pairings.
2. Each PWM output will go low when its match value is reached. If no match occurs (i.e.
the match value is greater than the PWM rate), the PWM output remains continuously
high.
1. The match values for the next PWM cycle are used at the end of a PWM cycle (a time
point which is coincident with the beginning of the next PWM cycle), except as noted
in rule 3.
2. A match value equal to 0 or the current PWM rate (the same as the Match channel 0
value) have the same effect, except as noted in rule 3. For example, a request for a
falling edge at the beginning of the PWM cycle has the same effect as a request for a
falling edge at the end of a PWM cycle.
3. When match values are changing, if one of the "old" match values is equal to the
PWM rate, it is used again once if the neither of the new match values are equal to 0
or the PWM rate, and there was no old match value equal to 0.
4. If both a set and a clear of a PWM output are requested at the same time, clear takes
precedence. This can occur when the set and clear match values are the same as in,
or when the set or clear value equals 0 and the other value equals the PWM rate.
5. If a match value is out of range (i.e. greater than the PWM rate value), no match event
occurs and that match channel has no effect on the output. This means that the PWM
output will remain always in one state, allowing always low, always high, or
"no change" outputs.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
Table 248: PWM Interrupt Register (PWMIR - address 0xE001 4000) bit description
Bit Symbol Description Reset value
0 PWMMR0 Interrupt Interrupt flag for PWM match channel 0. 0
1 PWMMR1 Interrupt Interrupt flag for PWM match channel 1. 0
2 PWMMR2 Interrupt Interrupt flag for PWM match channel 2. 0
3 PWMMR3 Interrupt Interrupt flag for PWM match channel 3. 0
7:4 - Reserved, user software should not write ones to reserved bits. 0000
The value read from a reserved bit is not defined.
8 PWMMR4 Interrupt Interrupt flag for PWM match channel 4. 0
9 PWMMR5 Interrupt Interrupt flag for PWM match channel 5. 0
10 PWMMR6 Interrupt Interrupt flag for PWM match channel 6. 0
15:11 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
Table 249: PWM Timer Control Register (PWMTCR - address 0xE001 4004) bit description
Bit Symbol Description Reset value
0 Counter Enable When one, the PWM Timer Counter and PWM Prescale 0
Counter are enabled for counting. When zero, the
counters are disabled.
1 Counter Reset When one, the PWM Timer Counter and the PWM 0
Prescale Counter are synchronously reset on the next
positive edge of PCLK. The counters remain reset until
TCR[1] is returned to zero.
2 - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is not
defined.
3 PWM Enable When one, PWM mode is enabled. PWM mode causes 0
shadow registers to operate in connection with the
Match registers. A program write to a Match register will
not have an effect on the Match result until the
corresponding bit in PWMLER has been set, followed by
the occurrence of a PWM Match 0 event. Note that the
PWM Match register that determines the PWM rate
(PWM Match 0) must be set up prior to the PWM being
enabled. Otherwise a Match event will not occur to
cause shadow register contents to become effective.
7:4 - Reserved, user software should not write ones to NA
reserved bits. The value read from a reserved bit is not
defined.
Table 250: Match Control Register (MCR, TIMER0: T0MCR - address 0xE000 4014 and TIMER1: T1MCR - address
0xE000 8014) bit description
Bit Symbol Value Description Reset
value
0 PWMMR0I 1 Interrupt on PWMMR0: an interrupt is generated when PWMMR0 matches the value 0
in the PWMTC.
0 This interrupt is disabled.
1 PWMMR0R 1 Reset on PWMMR0: the PWMTC will be reset if PWMMR0 matches it. 0
0 This feature is disabled.
2 PWMMR0S 1 Stop on PWMMR0: the PWMTC and PWMPC will be stopped and PWMTCR[0] will 0
be set to 0 if PWMMR0 matches the PWMTC.
0 This feature is disabled
3 PWMMR1I 1 Interrupt on PWMMR1: an interrupt is generated when PWMMR1 matches the value 0
in the PWMTC.
0 This interrupt is disabled.
1 PWMMR1R 1 Reset on PWMMR1: the PWMTC will be reset if PWMMR1 matches it. 0
0 This feature is disabled.
5 PWMMR1S 1 Stop on PWMMR1: the PWMTC and PWMPC will be stopped and PWMTCR[0] will 0
be set to 0 if PWMMR1 matches the PWMTC.
0 This feature is disabled.
6 PWMMR2I 1 Interrupt on PWMMR2: an interrupt is generated when PWMMR2 matches the value 0
in the PWMTC.
0 This interrupt is disabled.
7 PWMMR2R 1 Reset on PWMMR2: the PWMTC will be reset if PWMMR2 matches it. 0
0 This feature is disabled.
8 PWMMR2S 1 Stop on PWMMR2: the PWMTC and PWMPC will be stopped and PWMTCR[0] will 0
be set to 0 if PWMMR2 matches the PWMTC.
0 This feature is disabled
9 PWMMR3I 1 Interrupt on PWMMR3: an interrupt is generated when PWMMR3 matches the value 0
in the PWMTC.
0 This interrupt is disabled.
10 PWMMR3R 1 Reset on PWMMR3: the PWMTC will be reset if PWMMR3 matches it. 0
0 This feature is disabled
Table 250: Match Control Register (MCR, TIMER0: T0MCR - address 0xE000 4014 and TIMER1: T1MCR - address
0xE000 8014) bit description
Bit Symbol Value Description Reset
value
11 PWMMR3S 1 Stop on PWMMR3: The PWMTC and PWMPC will be stopped and PWMTCR[0] will 0
be set to 0 if PWMMR3 matches the PWMTC.
0 This feature is disabled
12 PWMMR4I 1 Interrupt on PWMMR4: An interrupt is generated when PWMMR4 matches the value 0
in the PWMTC.
0 This interrupt is disabled.
13 PWMMR4R 1 Reset on PWMMR4: the PWMTC will be reset if PWMMR4 matches it. 0
0 This feature is disabled.
14 PWMMR4S 1 Stop on PWMMR4: the PWMTC and PWMPC will be stopped and PWMTCR[0] will 0
be set to 0 if PWMMR4 matches the PWMTC.
0 This feature is disabled
15 PWMMR5I 1 Interrupt on PWMMR5: An interrupt is generated when PWMMR5 matches the value 0
in the PWMTC.
0 This interrupt is disabled.
16 PWMMR5R 1 Reset on PWMMR5: the PWMTC will be reset if PWMMR5 matches it. 0
0 This feature is disabled.
17 PWMMR5S 1 Stop on PWMMR5: the PWMTC and PWMPC will be stopped and PWMTCR[0] will 0
be set to 0 if PWMMR5 matches the PWMTC.
0 This feature is disabled
18 PWMMR6I 1 Interrupt on PWMMR6: an interrupt is generated when PWMMR6 matches the value 0
in the PWMTC.
0 This interrupt is disabled.
19 PWMMR6R 1 Reset on PWMMR6: the PWMTC will be reset if PWMMR6 matches it. 0
0 This feature is disabled.
20 PWMMR6S 1 Stop on PWMMR6: the PWMTC and PWMPC will be stopped and PWMTCR[0] will 0
be set to 0 if PWMMR6 matches the PWMTC.
0 This feature is disabled
31:21 - Reserved, user software should not write ones to reserved bits. The value read from NA
a reserved bit is not defined.
Table 251: PWM Control Register (PWMPCR - address 0xE001 404C) bit description
Bit Symbol Value Description Reset
value
1:0 - Reserved, user software should not write ones to reserved bits. The value read from NA
a reserved bit is not defined.
2 PWMSEL2 1 Selects double edge controlled mode for the PWM2 output. 0
0 Selects single edge controlled mode for PWM2.
3 PWMSEL3 1 Selects double edge controlled mode for the PWM3 output. 0
0 Selects single edge controlled mode for PWM3.
Table 251: PWM Control Register (PWMPCR - address 0xE001 404C) bit description
Bit Symbol Value Description Reset
value
4 PWMSEL4 1 Selects double edge controlled mode for the PWM4 output. 0
0 Selects single edge controlled mode for PWM4.
5 PWMSEL5 1 Selects double edge controlled mode for the PWM5 output. 0
0 Selects single edge controlled mode for PWM5.
6 PWMSEL6 1 Selects double edge controlled mode for the PWM6 output. 0
0 Selects single edge controlled mode for PWM6.
8:7 - Reserved, user software should not write ones to reserved bits. The value read from NA
a reserved bit is not defined.
9 PWMENA1 1 The PWM1 output enabled. 0
0 The PWM1 output disabled.
10 PWMENA2 1 The PWM2 output enabled. 0
0 The PWM2 output disabled.
11 PWMENA3 1 The PWM3 output enabled. 0
0 The PWM3 output disabled.
12 PWMENA4 1 The PWM4 output enabled. 0
0 The PWM4 output disabled.
13 PWMENA5 1 The PWM5 output enabled. 0
0 The PWM5 output disabled.
14 PWMENA6 1 The PWM6 output enabled. 0
0 The PWM6 output disabled.
15 - Reserved, user software should not write ones to reserved bits. The value read from NA
a reserved bit is not defined.
For example, if PWM2 is configured for double edge operation and is currently running, a
typical sequence of events for changing the timing would be:
The order of writing the two PWM Match registers is not important, since neither value will
be used until after the write to PWMLER. This insures that both values go into effect at the
same time, if that is required. A single value may be altered in the same way if needed.
The function of each of the bits in the PWMLER is shown in Table 252.
Table 252: PWM Latch Enable Register (PWMLER - address 0xE001 4050) bit description
Bit Symbol Description Reset
value
0 Enable PWM Writing a one to this bit allows the last value written to the PWM 0
Match 0 Latch Match 0 register to be become effective when the timer is next
reset by a PWM Match event. See Section 16.4.7 “PWM Match
Control Register (PWMMCR - 0xE001 4014)”.
1 Enable PWM Writing a one to this bit allows the last value written to the PWM 0
Match 1 Latch Match 1 register to be become effective when the timer is next
reset by a PWM Match event. See Section 16.4.7 “PWM Match
Control Register (PWMMCR - 0xE001 4014)”.
2 Enable PWM Writing a one to this bit allows the last value written to the PWM 0
Match 2 Latch Match 2 register to be become effective when the timer is next
reset by a PWM Match event. See Section 16.4.7 “PWM Match
Control Register (PWMMCR - 0xE001 4014)”.
3 Enable PWM Writing a one to this bit allows the last value written to the PWM 0
Match 3 Latch Match 3 register to be become effective when the timer is next
reset by a PWM Match event. See Section 16.4.7 “PWM Match
Control Register (PWMMCR - 0xE001 4014)”.
4 Enable PWM Writing a one to this bit allows the last value written to the PWM 0
Match 4 Latch Match 4 register to be become effective when the timer is next
reset by a PWM Match event. See Section 16.4.7 “PWM Match
Control Register (PWMMCR - 0xE001 4014)”.
5 Enable PWM Writing a one to this bit allows the last value written to the PWM 0
Match 5 Latch Match 5 register to be become effective when the timer is next
reset by a PWM Match event. See Section 16.4.7 “PWM Match
Control Register (PWMMCR - 0xE001 4014)”.
6 Enable PWM Writing a one to this bit allows the last value written to the PWM 0
Match 6 Latch Match 6 register to be become effective when the timer is next
reset by a PWM Match event. See Section 16.4.7 “PWM Match
Control Register (PWMMCR - 0xE001 4014)”.
7 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
17.1 Features
• 10 bit successive approximation analog to digital converter (one in LPC2141/2 and
two in LPC2144/6/8).
• Input multiplexing among 6 or 8 pins (ADC0 and ADC1).
• Power-down mode.
• Measurement range 0 V to VREF (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.
• Global Start command for both converters (LPC2144/6/8 only).
17.2 Description
Basic clocking for the A/D converters is provided by the VPB clock. A programmable
divider is included in each converter, to scale this clock to the 4.5 MHz (max) clock
needed by the successive approximation process. A fully accurate conversion requires 11
of these clocks.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
Table 255: A/D Control Register (AD0CR - address 0xE003 4000 and AD1CR - address 0xE006 0000) bit description
Bit Symbol Value Description Reset
value
26:24 START When the BURST bit is 0, these bits control whether and when an A/D conversion is 0
started:
000 No start (this value should be used when clearing PDN to 0).
001 Start conversion now.
010 Start conversion when the edge selected by bit 27 occurs on
P0.16/EINT0/MAT0.2/CAP0.2 pin.
011 Start conversion when the edge selected by bit 27 occurs on
P0.22/TD3/CAP0.0/MAT0.0 pin.
100 Start conversion when the edge selected by bit 27 occurs on MAT0.1.
101 Start conversion when the edge selected by bit 27 occurs on MAT0.3.
110 Start conversion when the edge selected by bit 27 occurs on MAT1.0.
111 Start conversion when the edge selected by bit 27 occurs on MAT1.1.
27 EDGE This bit is significant only when the START field contains 010-111. In these cases: 0
1 Start conversion on a falling edge on the selected CAP/MAT signal.
0 Start conversion on a rising edge on the selected CAP/MAT signal.
31:28 - Reserved, user software should not write ones to reserved bits. The value read from a NA
reserved bit is not defined.
17.4.2 A/D Global Data Register (AD0GDR - 0xE003 4004 and AD1GDR -
0xE006 0004)
Table 256: A/D Global Data Register (AD0GDR - address 0xE003 4004 and AD1GDR - address 0xE006 0004) bit
description
Bit Symbol Description 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 RESULT When DONE is 1, this field contains a binary fraction representing the voltage on NA
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 was
close 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. NA
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) lost 0
and overwritten before the conversion that produced the result in the RESULT bits.
This bit is cleared by reading this register.
31 DONE This bit is set to 1 when an A/D conversion completes. It is cleared when this 0
register is read and when the ADCR is written. If the ADCR is written while a
conversion is still in progress, this bit is set and a new conversion is started.
Table 257: A/D Global Start Register (ADGSR - address 0xE003 4008) bit description
Bit Symbol Value Description Reset
value
15:0 - Reserved, user software should not write ones to reserved bits. The value read from a NA
reserved bit is not defined.
16 BURST 1 The AD converters do repeated conversions at the rate selected by their CLKS fields, 0
scanning (if necessary) through the pins selected by 1s in their SEL field. The first
conversion after the start corresponds to the least-significant 1 in the SEL field, then
higher numbered 1-bits (pins) if applicable. Repeated conversions can be terminated by
clearing this bit, but the conversion that’s in progress when this bit is cleared will be
completed.
Important: START bits must be 000 when BURST = 1 or conversions will not start.
0 Conversions are software controlled and require 11 clocks.
23:17 - Reserved, user software should not write ones to reserved bits. The value read from a NA
reserved bit is not defined.
26:24 START When the BURST bit is 0, these bits control whether and when an A/D conversion is 0
started:
000 No start (this value should be used when clearing PDN to 0).
001 Start conversion now.
010 Start conversion when the edge selected by bit 27 occurs on
P0.16/EINT0/MAT0.2/CAP0.2 pin.
011 Start conversion when the edge selected by bit 27 occurs on
P0.22/TD3/CAP0.0/MAT0.0 pin.
100 Start conversion when the edge selected by bit 27 occurs on MAT0.1.
101 Start conversion when the edge selected by bit 27 occurs on MAT0.3.
110 Start conversion when the edge selected by bit 27 occurs on MAT1.0.
111 Start conversion when the edge selected by bit 27 occurs on MAT1.1.
27 EDGE This bit is significant only when the START field contains 010-111. In these cases: 0
1 Start conversion on a falling edge on the selected CAP/MAT signal.
0 Start conversion on a rising edge on the selected CAP/MAT signal.
31:28 - Reserved, user software should not write ones to reserved bits. The value read from a NA
reserved bit is not defined.
17.4.4 A/D Status Register (ADSTAT, ADC0: AD0CR - 0xE003 4004 and
ADC1: AD1CR - 0xE006 0004)
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 found
in ADSTAT.
Table 258: A/D Status Register (ADSTAT, ADC0: AD0STAT - address 0xE003 4004 and ADC1: AD1STAT - address
0xE006 0004) bit description
Bit Symbol Description 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 Done 0
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 a NA
reserved bit is not defined.
Table 259: A/D Status Register (ADSTAT, ADC0: AD0STAT - address 0xE003 4004 and ADC1: AD1STAT - address
0xE006 0004) bit description
Bit Symbol Value Description Reset
value
0 ADINTEN0 0 Completion of a conversion on ADC channel 0 will not generate an interrupt. 0
1 Completion of a conversion on ADC channel 0 will generate an interrupt.
1 ADINTEN1 0 Completion of a conversion on ADC channel 1 will not generate an interrupt. 0
1 Completion of a conversion on ADC channel 1 will generate an interrupt.
2 ADINTEN2 0 Completion of a conversion on ADC channel 2 will not generate an interrupt. 0
1 Completion of a conversion on ADC channel 2 will generate an interrupt.
3 ADINTEN3 0 Completion of a conversion on ADC channel 3 will not generate an interrupt. 0
1 Completion of a conversion on ADC channel 3 will generate an interrupt.
Table 259: A/D Status Register (ADSTAT, ADC0: AD0STAT - address 0xE003 4004 and ADC1: AD1STAT - address
0xE006 0004) bit description
Bit Symbol Value Description Reset
value
4 ADINTEN4 0 Completion of a conversion on ADC channel 4 will not generate an interrupt. 0
1 Completion of a conversion on ADC channel 4 will generate an interrupt.
5 ADINTEN5 0 Completion of a conversion on ADC channel 5 will not generate an interrupt. 0
1 Completion of a conversion on ADC channel 5 will generate an interrupt.
6 ADINTEN6 0 Completion of a conversion on ADC channel 6 will not generate an interrupt. 0
1 Completion of a conversion on ADC channel 6 will generate an interrupt.
7 ADINTEN1 0 Completion of a conversion on ADC channel 7 will not generate an interrupt. 0
1 Completion of a conversion on ADC channel 7 will generate an interrupt.
8 ADGINTEN 0 Only the individual ADC channels enabled by ADINTEN7:0 will generate 1
interrupts.
1 Only the global DONE flag in ADDR is enabled to generate an interrupt.
31:17 - Reserved, user software should not write ones to reserved bits. The value NA
read from a reserved bit is not defined.
Table 260: A/D Data Registers (ADDR0 to ADDR7, ADC0: AD0DR0 to AD0DR7 - 0xE003 4010 to 0xE003 402C and
ADC1: AD1DR0 to AD1DR7- 0xE006 0010 to 0xE006 402C) bit description
Bit Symbol Description Reset
value
5:0 - Reserved, user software should not write ones to reserved bits. The value read from a NA
reserved bit is not defined.
15:6 RESULT When DONE is 1, this field contains a binary fraction representing the voltage on the AIN pin, NA
divided by the voltage on the VREF pin (V/VREF). Zero in the field indicates that the voltage on
the AIN pin was less than, equal to, or close to that on VSSA, while 0x3FF indicates that the
voltage on AIN was close to, equal to, or greater than that on VREF.
29:16 - Reserved, user software should not write ones to reserved bits. The value read from a NA
reserved bit is not defined.
30 OVERRUN This bit is 1 in burst mode if the results of one or more conversions was (were) lost and
overwritten before the conversion that produced the result in the RESULT bits.This bit is
cleared by reading this register.
31 DONE This bit is set to 1 when an A/D conversion completes. It is cleared when this register is read. NA
17.5 Operation
17.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 to
control whether this assertion results in an interrupt. DONE is negated when the ADDR is
read.
18.1 Features
• 10 bit digital to analog converter
• Resistor string architecture
• Buffered output
• Power-down mode
• Selectable speed vs. power
Table 262: DAC Register (DACR - address 0xE006 C000) bit description
Bit Symbol Value Description Reset
value
5:0 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
15:6 VALUE After the selected settling time after this field is written with a 0
new VALUE, the voltage on the AOUT pin (with respect to VSSA)
is VALUE/1024 * VREF.
16 BIAS 0 The settling time of the DAC is 1 µs max, and the maximum 0
current is 700 υA.
1 The settling time of the DAC is 2.5 µs and the maximum
current is 350 µA.
31:17 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
18.4 Operation
Bits 19:18 of the PINSEL1 register (Section 7.4.2 “Pin function Select register 1 (PINSEL1
- 0xE002 C004)” on page 77) control whether the DAC is enabled and controlling the state
of pin P0.25/AD0.4/AOUT. When these bits are 10, the DAC is powered on and active.
The settling times noted in the description of the BIAS bit are valid for a capacitance load
on the AOUT pin not exceeding 100 pF. A load impedance value greater than that value will
cause settling time longer than the specified time.
19.1 Features
• Measures the passage of time to maintain a calendar and clock.
• Ultra Low Power design to support battery powered systems.
• Provides Seconds, Minutes, Hours, Day of Month, Month, Year, Day of Week, and Day
of Year.
• Dedicated 32 kHz oscillator or programmable prescaler from VPB clock.
• Dedicated power supply pin can be connected to a battery or to the main 3.3 V.
19.2 Description
The Real Time Clock (RTC) is a set of counters for measuring time when system power is
on, and optionally when it is off. It uses little power in Power-down mode. On the
LPC2141/2/4/6/8, the RTC can be clocked by a separate 32.768 KHz oscillator, or by a
programmable prescale divider based on the VPB clock. Also, the RTC is powered by its
own power supply pin, VBAT, which can be connected to a battery or to the same 3.3 V
supply used by the rest of the device.
19.3 Architecture
RTC OSCILLATOR
CLK32k
MUX
CLOCK GENERATOR REFERENCE CLOCK
DIVIDER (PRESCALER)
Strobe
CLK1 CCLK
TIME ALARM
COMPARATORS
COUNTERS REGISTERS
COUNTER INCREMENT
Counter ALARM MASK
INTERRUPT ENABLE
enables REGISTER
INTERRUPT GENERATOR
The Real Time Clock includes the register shown in Table 263. Detailed descriptions of
the registers follow.
[1] Registers in the RTC other than those that are part of the Prescaler are not affected by chip Reset. These
registers must be initialized by software if the RTC is enabled. Reset value reflects the data stored in used
bits only. It does not include reserved bits content.
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 wakeup and its selected event occurs, XTAL1/2 pins associated oscillator wakeup
cycle is started. For details on the RTC based wakeup process see Section 3.5.3
“Interrupt Wakeup register (INTWAKE - 0xE01F C144)” on page 22 and Section 3.12
“Wakeup timer” on page 41.
Table 265: Interrupt Location Register (ILR - address 0xE002 4000) bit description
Bit Symbol Description Reset
value
0 RTCCIF When one, the Counter Increment Interrupt block generated an interrupt. NA
Writing a one to this bit location clears the counter increment interrupt.
1 RTCALF When one, the alarm registers generated an interrupt. Writing a one to NA
this bit location clears the alarm interrupt.
7:2 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
Table 266: Clock Tick Counter Register (CTCR - address 0xE002 4004) bit description
Bit Symbol Description Reset
value
14:0 Clock Tick Prior to the Seconds counter, the CTC counts 32,768 clocks per NA
Counter second. Due to the RTC Prescaler, these 32,768 time increments may
not all be of the same duration. Refer to the Section 19.6 “Reference
clock divider (prescaler)” on page 282 for details.
15 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
Table 267: Clock Control Register (CCR - address 0xE002 4008) bit description
Bit Symbol Description Reset
value
0 CLKEN Clock Enable. When this bit is a one the time counters are enabled. NA
When it is a zero, they are disabled so that they may be initialized.
1 CTCRST CTC Reset. When one, the elements in the Clock Tick Counter are NA
reset. The elements remain reset until CCR[1] is changed to zero.
3:2 CTTEST Test Enable. These bits should always be zero during normal NA
operation.
4 CLKSRC If 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 is
1, the CTC takes its clock from the 32 kHz oscillator that’s connected to
the RTCX1 and RTCX2 pins (see Section 19.7 “RTC external 32 kHz
oscillator component selection” for hardware details).
7:5 - Reserved, user software should not write ones to reserved bits. The NA
value read from a reserved bit is not defined.
Table 268: Counter Increment Interrupt Register (CIIR - address 0xE002 400C) bit description
Bit Symbol Description Reset
value
0 IMSEC When 1, an increment of the Second value generates an interrupt. NA
1 IMMIN When 1, an increment of the Minute value generates an interrupt. NA
2 IMHOUR When 1, an increment of the Hour value generates an interrupt. NA
3 IMDOM When 1, an increment of the Day of Month value generates an interrupt. 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
Table 269: Alarm Mask Register (AMR - address 0xE002 4010) bit description
Bit Symbol Description Reset
value
0 AMRSEC When 1, the Second value is not compared for the alarm. NA
1 AMRMIN When 1, the Minutes value is not compared for the alarm. NA
2 AMRHOUR When 1, the Hour value is not compared for the alarm. NA
3 AMRDOM When 1, the Day of Month value is not compared for the alarm. NA
4 AMRDOW When 1, the Day of Week value is not compared for the alarm. NA
5 AMRDOY When 1, the Day of Year value is not compared for the alarm. NA
6 AMRMON When 1, the Month value is not compared for the alarm. NA
7 AMRYEAR When 1, the Year value is not compared for the alarm. NA
The Consolidated Time Registers are read only. To write new values to the Time
Counters, the Time Counter addresses should be used.
Table 270: Consolidated Time register 0 (CTIME0 - address 0xE002 4014) bit description
Bit Symbol Description Reset
value
5:0 Seconds Seconds value in the range of 0 to 59 NA
7:6 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
13:8 Minutes Minutes value in the range of 0 to 59 NA
15:14 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
20:16 Hours Hours value in the range of 0 to 23 NA
23:21 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
26:24 Day Of Week Day of week value in the range of 0 to 6 NA
31:27 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
Table 271: Consolidated Time register 1 (CTIME1 - address 0xE002 4018) bit description
Bit Symbol Description Reset
value
4:0 Day of Month Day of month value in the range of 1 to 28, 29, 30, or 31 NA
(depending on the month and whether it is a leap year).
7:5 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
11:8 Month Month value in the range of 1 to 12. NA
15:12 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
27:16 Year Year value in the range of 0 to 4095. NA
31:28 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
Table 272: Consolidated Time register 2 (CTIME2 - address 0xE002 401C) bit description
Bit Symbol Description Reset
value
11:0 Day of Year Day of year value in the range of 1 to 365 (366 for leap years). NA
31:12 - Reserved, user software should not write ones to reserved bits. NA
The value read from a reserved bit is not defined.
[1] These values are simply incremented at the appropriate intervals and reset at the defined overflow point.
They are not calculated and must be correctly initialized in order to be meaningful.
Since the RTC operates using one of two available clocks (the VPB clock (PCLK) or the
32 kHz signal coming from the RTCX1-2pins), any interruption of the selected clock will
cause 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.
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 a
lapse in the time update. Also, feeding the RTC with the PCLK and altering this timebase
during system operation (by reconfiguring the PLL, the VPB divider, or the RTC prescaler)
will result in some form of accumulated time error. Accumulated time errors may occur in
case RTC clock source is switched between the PCLK to the RTCX pins, too.
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 VPB clock (PCLK). Therefore, power
sensitive applications (i.e. battery powered application) utilizing the RTC will reduce the
power 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 3.9 “Power control” on page
35).
The reference clock divider consists of a 13-bit integer counter and a 15-bit fractional
counter. The reasons for these counter sizes are as follows:
PREINT = int (PCLK / 32768) − 1. The value of PREINT must be greater than or equal to
1.
Table 277: Prescaler Integer register (PREINT - address 0xE002 4080) bit description
Bit Symbol Description Reset
value
12:0 Prescaler Integer Contains the integer portion of the RTC prescaler value. 0
15:13 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Table 278: Prescaler Integer register (PREFRAC - address 0xE002 4084) bit description
Bit Symbol Description Reset
value
14:0 Prescaler Fraction Contains the integer portion of the RTC prescaler value. 0
15 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
With this prescaler setting, exactly 32,768 clocks per second will be provided to the RTC
by counting 2 PCLKs 32,767 times, and 3 PCLKs once.
In this case, 5,760 of the prescaler output clocks will be 306 (305 + 1) PCLKs long, the
rest will be 305 PCLKs long.
In a similar manner, any PCLK rate greater than 65.536 kHz (as long as it is an even
number of cycles per second) may be turned into a 32 kHz reference clock for the RTC.
The only caveat is that if PREFRAC does not contain a zero, then not all of the 32,768 per
second clocks are of the same length. Some of the clocks are one PCLK longer than
others. While the longer pulses are distributed as evenly as possible among the remaining
pulses, this "jitter" could possibly be of concern in an application that wishes to observe
the contents of the Clock Tick Counter (CTC) directly(Section 19.4.4 “Clock Tick Counter
Register (CTCR - 0xE002 4004)” on page 278).
CLK
CLK UNDERFLOW 15 BIT FRACTION COUNTER
13 BIT INTEGER COUNTER
(DOWN COUNTER)
RELOAD
15
COMBINATORIAL LOGIC
13 Extend
reload
15
13 15
VPB Bus
For example, if PREFRAC bit 14 is a one (representing the fraction 1/2), then half of the
cycles counted by the 13-bit counter need to be longer. When there is a 1 in the LSB of
the Fraction Counter, the logic causes every alternate count (whenever the LSB of the
Fraction Counter=1) to be extended by one PCLK, evenly distributing the pulse widths.
Similarly, a one in PREFRAC bit 13 (representing the fraction 1/4) will cause every fourth
cycle (whenever the two LSBs of the Fraction Counter=10) counted by the 13-bit counter
to be longer.
Table 279: 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
LPC2141/2/4/6/8
RTXC1 RTXC2
32 kHz Xtal
CX1 C X2
Table 280 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
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 in Table 280
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 280: Recommended values for the RTC external 32 kHz oscillator CX1/X2 components
Crystal load capacitance Maximum crystal series External load capacitors CX1, CX2
CL resistance RS
11 pF < 100 kΩ 18 pF, 18 pF
13 pF < 100 kΩ 22 pF, 22 pF
15 pF < 100 kΩ 27 pF, 27 pF
20.1 Features
• Internally resets chip if not periodically reloaded.
• Debug mode.
• Enabled by software but requires a hardware reset or a watchdog reset/interrupt to be
disabled.
• Incorrect/Incomplete feed sequence causes reset/interrupt if enabled.
• Flag to indicate Watchdog reset.
• Programmable 32-bit timer with internal pre-scaler.
• Selectable time period from (TPCLK x 256 x 4) to (TPCLK x 232 x 4) in multiples of
TPCLK x 4.
20.2 Applications
The purpose of the watchdog is to reset the microcontroller within a reasonable amount of
time if it enters an erroneous state. When enabled, the watchdog will generate a system
reset if the user program fails to "feed" (or reload) the watchdog within a predetermined
amount of time.
For interaction of the on-chip watchdog and other peripherals, especially the reset and
boot-up procedures, please read Section 3.10 “Reset” on page 38 of this document.
20.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:
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.
[1] Reset value reflects the data stored in used bits only. It does not include reserved bits content.
Once the WDEN and/or WDRESET bits are set they can not be cleared by software. Both
flags are cleared by an external reset or a watchdog timer underflow.
WDTOF The Watchdog Time-Out Flag is set when the watchdog times out. This flag is
cleared by software.
WDINT The Watchdog Interrupt Flag is set when the watchdog times out. This flag is
cleared when any reset occurs. Once the watchdog interrupt is serviced, it can be
disabled in the VIC or the watchdog interrupt request will be generated indefinitely.
Table 283: Watchdog Mode register (WDMOD - address 0xE000 0000) bit description
Bit Symbol Description Reset value
0 WDEN WDEN Watchdog interrupt Enable bit (Set Only). 0
1 WDRESET WDRESET Watchdog Reset Enable bit (Set Only). 0
2 WDTOF WDTOF Watchdog Time-Out Flag. 0 (Only after
external reset)
3 WDINT WDINT Watchdog interrupt Flag (Read Only). 0
7:4 - Reserved, user software should not write ones to reserved NA
bits. The value read from a reserved bit is not defined.
Table 284: Watchdog Timer Constant register (WDTC - address 0xE000 0004) bit description
Bit Symbol Description Reset value
31:0 Count Watchdog time-out interval. 0x0000 00FF
Table 285: Watchdog Feed register (WDFEED - address 0xE000 0008) bit description
Bit Symbol Description Reset value
7:0 Feed Feed value should be 0xAA followed by 0x55. NA
Table 286: Watchdog Timer Value register (WDTV - address 0xE000 000C) bit description
Bit Symbol Description Reset value
31:0 Count Counter timer value. 0x0000 00FF
Feed OK
WDFEED
Under
PLCK 32 BIT DOWN flow
/4
COUNTER
Enable
count 1
WDTV CURRENT WD
register TIMER COUNT
SHADOW BIT
WDMOD 2 2
WDEN WDTOF WDINT WDRESET
Register
21.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.
21.3 Applications
The flash boot loader provides both In-System and In-Application programming interfaces
for programming the on-chip flash memory.
21.4 Description
The flash boot loader code is executed every time the part is powered on or reset. The
loader can execute the ISP command handler or the user application code. A 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 the
decision on whether to continue with user code or ISP handler is made. If P0.14 is
sampled low and the watchdog overflow flag is set, the external hardware request to start
the ISP command handler is ignored. If there is no request for the ISP command handler
execution (P0.14 is sampled HIGH after reset), a search is made for a valid user program.
If a valid user program is found then the execution control is transferred to it. If a valid user
program is not found, the auto-baud routine is invoked.
Pin P0.14 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.
memory area but 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 boot block of
the on-chip flash memory also become active after reset, i.e., the bottom 64 bytes of 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.
0x0007 FFFF
12 kB BOOT BLOCK RE-MAPPED TO
HIGHER ADDRESS RANGE
0x0007 D000
If the signature is not valid, the auto-baud routine synchronizes with the host via serial port
0. The host should send a ’?’ (0x3F) as a synchronization character and wait for a
response. The host side serial port settings should be 8 data bits, 1 stop bit and no parity.
The auto-baud routine measures the bit time of the received synchronization character in
terms of its own frequency and programs the baud rate generator of the serial port. It also
sends an ASCII string ("Synchronized<CR><LF>") to the Host. In response to this host
should send the same string ("Synchronized<CR><LF>"). The auto-baud routine looks at
Once the crystal frequency is received the part is initialized and the ISP command handler
is invoked. For safety reasons an "Unlock" command is required before executing the
commands resulting in flash erase/write operations and the "Go" command. The rest of
the commands can be executed without the unlock command. The Unlock command is
required to be executed once per ISP session. The Unlock command is explained in
Section 21.8 “ISP commands” on page 297.
RESET
INITIALIZE
CRP * No
ENABLED?
ENABLE DEBUG
Yes
WATCHDOG Yes
FLAG SET?
No
Yes No
EXECUTE INTERNAL
USER CODE
RUN AUTO-BAUD
No AUTO-BAUD
SUCCESSFUL?
Yes
RECEIVE CRYSTAL
FREQUENCY
boot block is present at addresses 0x0007 D000 to 0x0007 FFFF in all devices. ISP and
IAP commands do not allow write/erase/go operation on the boot block. Because of the
boot block, the amount of Flash available for user code and data is 500 K bytes in "512K"
devices. On the other hand, in case of the LPC2141/2/4/6 microcontroller all
32/64/128/256 K of Flash are available for user’s application.
Table 287: Flash sectors in LPC2141, LPC2142, LPC2144, LPC2146 and LPC2148
Sector Sector Address Range
LPC2141
LPC2142
LPC2144
LPC2146
LPC2148
(128kB)
(256kB)
(512kB)
Number Size [kB]
(32kB)
(64kB)
0 4 0X0000 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 + + + + +
8 32 0x0000 8000 - 0X0000 FFFF + + + +
9 32 0x0001 0000 - 0X0001 7FFF + + +
10 (0x0A) 32 0x0001 8000 - 0X0001 FFFF + + +
11 (0x0B) 32 0x0002 0000 - 0X0002 7FFF + +
12 (0x0C) 32 0x0002 8000 - 0X0002 FFFF + +
13 (0x0D) 32 0x0003 0000 - 0X0003 7FFF + +
14 (0X0E) 32 0x0003 8000 - 0X0003 FFFF + +
15 (0x0F) 32 0x0004 0000 - 0X0004 7FFF +
16 (0x10) 32 0x0004 8000 - 0X0004 FFFF +
17 (0x11) 32 0x0005 0000 - 0X0005 7FFF +
18 (0x12) 32 0x0005 8000 - 0X0005 FFFF +
19 (0x13) 32 0x0006 0000 - 0X0006 7FFF +
20 (0x14) 32 0x0006 8000 - 0X0006 FFFF +
21 (0x15) 32 0x0007 0000 - 0X0007 7FFF +
22 (0x16) 4 0x0007 8000 - 0X0007 8FFF +
23 (0x17) 4 0x0007 9000 - 0X0007 9FFF +
24 (0x18) 4 0x0007 A000 - 0X0007 AFFF +
25 (0x19) 4 0x0007 B000 - 0X0007 BFFF +
26 (0x1A) 4 0x0007 C000 - 0X0007 CFFF +
The operation of ECC is transparent to the running application. The ECC content itself is
stored in a flash memory not accessible by user’s code to either read from it or write into it
on its own. A byte of ECC corresponds to every consecutive 128 bits of the user
accessible Flash. Consequently, Flash bytes from 0x0000 0000 to 0x0000 0003 are
protected by the first ECC byte, Flash bytes from 0x0000 0004 to 0x0000 0007 are
protected by the second ECC byte, etc.
Whenever the CPU requests a read from user’s Flash, both 128 bits of raw data
containing the specified memory location and the matching ECC byte are evaluated. If the
ECC mechanism detects a single error in the fetched data, a correction will be applied
before data are provided to the CPU. When a write request into the user’s Flash is made,
write of user specified content is accompanied by a matching ECC value calculated and
stored in the ECC memory.
When a sector of user’s Flash memory is erased, corresponding ECC bytes are also
erased. Once an ECC byte is written, it can not be updated unless it is erased first.
Therefore, for the implemented ECC mechanism to perform properly, data must be written
into the Flash memory in groups of 4 bytes (or multiples of 4), aligned as described above.
• Read Memory
• Write to RAM
• Go
• Copy RAM to Flash
Important: CRP is active/inactive once the device has gone through a power cycle.
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.
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Table 291: Correlation between possible ISP baudrates and external crystal frequency (in
MHz)
ISP Baudrate .vs. 9600 19200 38400 57600 115200 230400
External Crystal Frequency
10.0000 + + +
11.0592 + + +
12.2880 + + +
14.7456 + + + + + +
15.3600 +
18.4320 + + +
19.6608 + + +
24.5760 + + +
25.0000 + + +
21.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.
21.8.7 Copy RAM to Flash <Flash address> <RAM address> <no of bytes>
Table 296: ISP Copy command
Command C
Input Flash Address(DST): Destination Flash address where data bytes are to be
written. The destination address should be a 256 byte boundary.
RAM Address(SRC): Source RAM address from where data bytes are to be read.
Number of Bytes: Number of bytes to be written. Should be 256 | 512 | 1024 |
4096.
Return Code CMD_SUCCESS |
SRC_ADDR_ERROR (Address not on word boundary) |
DST_ADDR_ERROR (Address not on correct boundary) |
SRC_ADDR_NOT_MAPPED |
DST_ADDR_NOT_MAPPED |
COUNT_ERROR (Byte count is not 256 | 512 | 1024 | 4096) |
SECTOR_NOT_PREPARED_FOR WRITE_OPERATION |
BUSY |
CMD_LOCKED |
PARAM_ERROR |
CODE_READ_PROTECTION_ENABLED
Description This command is used to program the flash memory. The "Prepare Sector(s) for
Write Operation" command should precede this command. The affected sectors
are automatically protected again once the copy command is successfully
executed. The boot block cannot be written by this command. This command is
blocked when code read protection is enabled.
Example "C 0 1073774592 512<CR><LF>" copies 512 bytes from the RAM address
0x4000 8000 to the flash address 0.
Define the IAP location entry point. Since the 0th bit of the IAP location is set there will be
a change to Thumb instruction set when the program counter branches to this address.
Define data structure or pointers to pass IAP command table and result table to the IAP
function:
or
Define pointer to function type, which takes two parameters and returns void. Note the IAP
returns the result with the base address of the table residing in R1.
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
iap_entry=(IAP) IAP_LOCATION;
Whenever you wish to call IAP you could use the following statement.
The IAP call could be simplified further by using the symbol definition file feature
supported by ARM Linker in ADS (ARM Developer Suite). You could also call the IAP
routine using assembly code.
The following symbol definitions can be used to link IAP routine and user application:
#<SYMDEFS># ARM Linker, ADS1.2 [Build 826]: Last Updated: Wed May 08 16:12:23 2002
0x7fffff90 T rm_init_entry
0x7fffffa0 A rm_undef_handler
0x7fffffb0 A rm_prefetchabort_handler
0x7fffffc0 A rm_dataabort_handler
0x7fffffd0 A rm_irqhandler
0x7fffffe0 A rm_irqhandler2
0x7ffffff0 T iap_entry
As per the ARM specification (The ARM Thumb Procedure Call Standard SWS ESPC
0002 A-05) up to 4 parameters can be passed in the r0, r1, r2 and r3 registers
respectively. Additional parameters are passed on the stack. Up to 4 parameters can be
returned in the r0, r1, r2 and r3 registers respectively. Additional parameters are returned
indirectly via memory. Some of the IAP calls require more than 4 parameters. If the ARM
suggested scheme is used for the parameter passing/returning then it might create
problems due to difference in the C compiler implementation from different vendors. The
suggested parameter passing scheme reduces such risk.
The flash memory is not accessible during a write or erase operation. IAP commands,
which results in a flash write/erase operation, use 32 bytes of space in the top portion of
the on-chip RAM for execution. The user program should not be use this space if IAP flash
programming is permitted in the application.
PARAMETER n
ARM REGISTER r1
STATUS CODE
RESULT 1 Command
result table
RESULT 2
RESULT n
22.1 Features
• No target resources are required by the software debugger in order to start the
debugging session.
• Allows the software debugger to talk via a JTAG (Joint Test Action Group) port directly
to the core.
• Inserts instructions directly in to the ARM7TDMI-S core.
• The ARM7TDMI-S core or the System state can be examined, saved or changed
depending on the type of instruction inserted.
• Allows instructions to execute at a slow debug speed or at a fast system speed.
22.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.
22.3 Description
The ARM7TDMI-S Debug Architecture uses the existing JTAG1 port as a method of
accessing the core. The scan chains that are around the core for production test are
reused in the debug state to capture information from the 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 chain
that is used to insert watchpoints and breakpoints for the ARM7TDMI-S core. The
EmbeddedICE logic consists of two real time watchpoint registers, together with a control
and status register. One or both of the watchpoint registers can be programmed to halt the
ARM7TDMI-S core. Execution is halted when a match occurs between the values
programmed into the EmbeddedICE logic and the values currently appearing on the
address bus, 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 a
watchpoint (i.e. on a data access) or a break point (i.e. on an instruction fetch). The
watchpoints and breakpoints can be combined such that:
• The conditions on both watchpoints must be satisfied before the ARM7TDMI core is
stopped. The CHAIN functionality requires two consecutive conditions to be satisfied
before the core is halted. An example of this would be to set the first breakpoint to
1.For more details refer to IEEE Standard 1149.1 - 1990 Standard Test Access Port and Boundary Scan Architecture.
trigger on an access to a peripheral and the second to trigger on the code segment
that performs the task switching. Therefore when the breakpoints trigger the
information regarding which task has switched out will be ready for examination.
• The watchpoints can be configured such that a range of addresses are enabled for
the watchpoints to be active. The RANGE function allows the breakpoints to be
combined such that a breakpoint is to occur if an access occurs in the bottom 256
bytes of memory but not in the bottom 32 bytes.
The ARM7TDMI-S core has a Debug Communication Channel function in-built. The
debug communication channel allows a program running on the target to communicate
with the host debugger or another separate host without stopping the program flow or
even entering the debug state. The debug communication channel is accessed as a
co-processor 14 by the program running on the ARM7TDMI-S core. The debug
communication channel allows the JTAG port to be used for sending and receiving data
without affecting the normal program flow. The debug communication channel data and
control registers are mapped in to addresses in the EmbeddedICE logic.
JTAG PORT
Serial
parallel EMBEDDEDICE
interface INTERFACE 5 EMBEDDED
PROTOCOL ICE
CONVERTER
Host
running
ARM7TDMI-S
debugger
TARGET BOARD
23.1 Features
• Closely track the instructions that the ARM core is executing.
• 1 External trigger input
• 10 pin interface
• All registers are programmed through JTAG interface.
• Does not consume power when trace is not being used.
• THUMB instruction set support
23.2 Applications
As the microcontroller has significant amounts of on-chip memories, it is not possible to
determine how the processor core is operating simply by observing the external pins. The
ETM provides real-time trace capability for deeply embedded processor cores. It outputs
information about processor execution to a trace port. A software debugger allows
configuration of the ETM using a JTAG interface and displays the trace information that
has been captured, in a format that a user can easily understand.
23.3 Description
The ETM is connected directly to the ARM core and not to the main AMBA system bus. It
compresses the trace information and exports it through a narrow trace port. An external
Trace Port Analyzer captures the trace information under software debugger control. Trace
port can broadcast the Instruction trace information. Instruction trace (or PC trace) shows
the flow of execution of the processor and provides a list of all the instructions that were
executed. Instruction trace is significantly compressed by only broadcasting branch
addresses as well as a set of status signals that indicate the pipeline status on a cycle by
cycle basis. Trace information generation can be controlled by selecting the trigger
resource. Trigger resources include address comparators, counters and sequencers.
Since trace information is compressed the software debugger requires a static image of
the code being executed. Self-modifying code can not be traced because of this
restriction.
[1] For details refer to ARM documentation "Embedded Trace Macrocell Specification (ARM IHI 0014E)".
APPLICATION PCB
CONNECTOR
TRACE TRACE
10
PORT
ANALYZER ETM
TRIGGER PERIPHERAL
PERIPHERAL
CONNECTOR
Host RAM
running ARM
JTAG
debugger 5
INTERFACE
UNIT ROM
EMBEDDEDICE
LAN
Refer to the white paper "Real Time Debug for System-on-Chip" available at
http://www.arm.com/support/White_Papers?OpenDocument for background information.
24.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.
24.2 Applications
Real time debugging.
24.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 is designed to load and debug independent applications that can run in a variety of
modes, and communicate with the debug host using a variety of connections (such as a
serial port or ethernet). Angel is required to save and restore full processor context, and
the occurrence of interrupts can be delayed as a result. Angel, as a fully functional
target-based debugger, is therefore too heavyweight to perform as a real-time monitor.
Multi-ICE is a hardware debug solution that operates using the EmbeddedICE unit that is
built into most ARM processors. To perform debug tasks such as accessing memory or
the processor registers, Multi-ICE must place the core into a debug state. While the
processor is in this state, which can be millions of cycles, normal program execution is
suspended, and interrupts cannot be serviced.
RealMonitor combines features and mechanisms from both Angel and Multi-ICE to
provide the services and functions that are required. In particular, it contains both the
Multi-ICE communication mechanisms (the DCC using JTAG), and Angel-like support for
processor context saving and restoring. RealMonitor is pre-programmed in the on-chip
ROM memory (boot sector). When enabled It allows user to observe and debug while
parts of application continue to run. Refer to Section 24.4 “How to enable Realmonitor” on
page 322 for details.
DEBUGGER
REALMONITOR.DLL RMHOST
RDI 1.5.1 RT
RealMonitor
JTAG Unit
protocol
DCC transmissions
over the JTAG link
24.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 the
debugger into DCC-only RDI messages for the JTAG unit. For complete details on
debugging a RealMonitor-integrated application from the host, see the ARM RMHost User
Guide (ARM DUI 0137A).
24.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).
SWI
Abort
undef
Stop
SWI
Abort
undef
RUNNING STOPPED PANIC
Go
A debugger such as the ARM eXtended Debugger (AXD) or other RealMonitor aware
debugger, that runs on a host computer, can connect to the target to send commands and
receive data. This communication between host and target is illustrated in Figure 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 user application is running, RMTarget typically uses IRQs generated by the DCC.
This means that if user application also wants to use IRQs, it must pass any
DCC-generated interrupts to RealMonitor.
When one of these exceptions occur that is not handled by user application, the following
happens:
• RealMonitor enters a loop, polling the DCC. If the DCC read buffer is full, control is
passed to rm_ReceiveData() (RealMonitor internal function). If the DCC write buffer is
free, control is passed to rm_TransmitData() (RealMonitor internal function). If there is
nothing else to do, the function returns to the caller. The ordering of the above
comparisons gives reads from the DCC a higher priority than writes to the
communications link.
• RealMonitor stops the foreground application. Both IRQs and FIQs continue to be
serviced if they were enabled by the application at the time the foreground application
was stopped.
RM_UNDEF_HANDLER()
RESET
RM_PREFETCHABORT_HANDLER()
RM_DATAABORT_HANDLER()
UNDEF RM_IRQHANDLER()
SWI
Sharing IRQs between ReaMonitor and User IRQ handler
PREFETCH
ABORT RM_IRQHANDLER2()
DATA ABORT
APP_IRQDISPATCH
RESERVED
APP_IRQHANDLER2()
OR
IRQ
FIQ
IMPORT rm_init_entry
IMPORT rm_prefetchabort_handler
IMPORT rm_dataabort_handler
IMPORT rm_irqhandler2
IMPORT rm_undef_handler
IMPORT User_Entry ;Entry point of user application.
CODE32
ENTRY
;Define exception table. Instruct linker to place code at address 0x0000 0000
; /*********************************************************************
RM_OPT_DATALOGGING=FALSE
This option enables or disables support for any target-to-host packets sent on a non
RealMonitor (third-party) channel.
RM_OPT_STOPSTART=TRUE
This option enables or disables support for all stop and start debugging features.
RM_OPT_SOFTBREAKPOINT=TRUE
RM_OPT_HARDBREAKPOINT=TRUE
Enabled for cores with EmbeddedICE-RT. This device uses ARM-7TDMI-S Rev 4 with
EmbeddedICE-RT.
RM_OPT_HARDWATCHPOINT=TRUE
Enabled for cores with EmbeddedICE-RT. This device uses ARM-7TDMI-S Rev 4 with
EmbeddedICE-RT.
RM_OPT_SEMIHOSTING=FALSE
This option enables or disables support for SWI semi-hosting. Semi-hosting provides
code running on an ARM target use of facilities on a host computer that is running an
ARM debugger. Examples of such facilities include the keyboard input, screen output,
and disk I/O.
RM_OPT_SAVE_FIQ_REGISTERS=TRUE
This option determines whether the FIQ-mode registers are saved into the registers
block when RealMonitor stops.
RM_OPT_READBYTES=TRUE
RM_OPT_WRITEBYTES=TRUE
RM_OPT_READHALFWORDS=TRUE
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
RM_OPT_WRITEHALFWORDS=TRUE
RM_OPT_READWORDS=TRUE
RM_OPT_WRITEWORDS=TRUE
RM_OPT_EXECUTECODE=FALSE
Enables/Disables support for executing code from "execute code" buffer. The code must
be downloaded first.
RM_OPT_GETPC=TRUE
This option enables or disables support for the RealMonitor GetPC packet. Useful in
code profiling when real monitor is used in interrupt mode.
RM_EXECUTECODE_SIZE=NA
RM_OPT_GATHER_STATISTICS=FALSE
This option enables or disables the code for gathering statistics about the internal
operation of RealMonitor.
RM_DEBUG=FALSE
RM_OPT_BUILDIDENTIFIER=FALSE
This option determines whether a build identifier is built into the capabilities table of
RMTarget. Capabilities table is stored in ROM.
RM_OPT_SDM_INFO=FALSE
SDM gives additional information about application board and processor to debug tools.
RM_OPT_MEMORYMAP=FALSE
This option determines whether a memory map of the board is built into the target and
made available through the capabilities table
RM_OPT_USE_INTERRUPTS=TRUE
This option specifies whether RMTarget is built for interrupt-driven mode or polled mode.
RM_FIFOSIZE=NA
This option specifies the size, in words, of the data logging FIFO buffer.
CHAIN_VECTORS=FALSE
This option allows RMTarget to support vector chaining through µHAL (ARM HW
abstraction API).
25.1Abbreviations
Table 321: Abbreviations
Acronym Description
ADC Analog-to-Digital Converter
BOD Brown-Out Detection
CPU Central Processing Unit
DAC Digital-to-Analog Converter
DCC Debug Communications Channel
FIFO First In, First Out
GPIO General Purpose Input/Output
NA Not Applicable
PLL Phase-Locked Loop
POR Power-On Reset
PWM Pulse Width Modulator
RAM Random Access Memory
SRAM Static Random Access Memory
UART Universal Asynchronous Receiver/Transmitter
USB Universal Serial Bus
VIC Vector Interrupt Controller
VPB VLSI Peripheral Bus
25.2Disclaimers products, and makes no representations or warranties that these products are
free from patent, copyright, or mask work right infringement, unless otherwise
specified.
Life support — These products are not designed for use in life support Application information — Applications that are described herein for any
appliances, devices, or systems where malfunction of these products can of these products are for illustrative purposes only. Philips Semiconductors
reasonably be expected to result in personal injury. Philips Semiconductors make no representation or warranty that such applications will be suitable for
customers using or selling these products for use in such applications do so the specified use without further testing or modification.
at their own risk and agree to fully indemnify Philips Semiconductors for any
damages resulting from such application.
Right to make changes — Philips Semiconductors reserves the right to 25.3Trademarks
make changes in the products - including circuits, standard cells, and/or
software - described or contained herein in order to improve design and/or
performance. When the product is in full production (status ‘Production’), Notice — All referenced brands, product names, service names and
relevant changes will be communicated via a Customer Product/Process trademarks are the property of their respective owners.
Change Notification (CPCN). Philips Semiconductors assumes no I2C-bus — wordmark and logo are trademarks of Koninklijke Philips
responsibility or liability for the use of any of these products, conveys no Electronics N.V.
licence or title under any patent, copyright, or mask work right to these SoftConnect — is a trademark of Koninklijke Philips Electronics N.V.
GoodLink — is a trademark of Koninklijke Philips Electronics N.V.
25.4 Tables
Table 1: LPC2141/2/4/6/8 device information. . . . . . . . . .4 0xE01F C100) bit description. . . . . . . . . . . . . . 41
Table 2: VPB peripheries and base addresses . . . . . . .10 Table 30: MAM Responses to program accesses of various
Table 3: ARM exception vector locations . . . . . . . . . . . .12 types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Table 4: LPC2141/2/4/6/8 memory mapping modes . . .12 Table 31: MAM responses to data and DMA accesses of
Table 5: Pin summary. . . . . . . . . . . . . . . . . . . . . . . . . . .16 various types . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Table 6: Summary of system control registers . . . . . . . .17 Table 32: Summary of MAM registers . . . . . . . . . . . . . . . 48
Table 7: Recommended values for CX1/X2 in oscillation Table 33: MAM Control Register (MAMCR - address
mode (crystal and external components 0xE01F C000) bit description. . . . . . . . . . . . . . 48
parameters) . . . . . . . . . . . . . . . . . . . . . . . . . . .19 Table 34: MAM Timing register (MAMTIM - address
Table 8: External interrupt registers . . . . . . . . . . . . . . . .20 0xE01F C004) bit description. . . . . . . . . . . . . . 48
Table 9: External Interrupt Flag register (EXTINT - address Table 35: VIC register map . . . . . . . . . . . . . . . . . . . . . . . 51
0xE01F C140) bit description . . . . . . . . . . . . . .22 Table 36: Software Interrupt register (VICSoftInt - address
Table 10: Interrupt Wakeup register (INTWAKE - address 0xFFFF F018) bit allocation . . . . . . . . . . . . . . 52
0xE01F C144) bit description . . . . . . . . . . . . . .23 Table 37: Software Interrupt register (VICSoftInt - address
Table 11: External Interrupt Mode register (EXTMODE - 0xFFFF F018) bit description. . . . . . . . . . . . . . 53
address 0xE01F C148) bit description . . . . . . .23 Table 38: Software Interrupt Clear register (VICSoftIntClear
Table 12: External Interrupt Polarity register (EXTPOLAR - - address 0xFFFF F01C) bit allocation . . . . . . 53
address 0xE01F C14C) bit description. . . . . . .24 Table 39: Software Interrupt Clear register (VICSoftIntClear
Table 13: System Control and Status flags register (SCS - - address 0xFFFF F01C) bit description . . . . . 53
address 0xE01F C1A0) bit description . . . . . . .26 Table 40: Raw Interrupt status register (VICRawIntr -
Table 14: Memory Mapping control register (MEMMAP - address 0xFFFF F008) bit allocation . . . . . . . 54
address 0xE01F C040) bit description . . . . . . .27 Table 41: Raw Interrupt status register (VICRawIntr -
Table 15: PLL registers . . . . . . . . . . . . . . . . . . . . . . . . . .28 address 0xFFFF F008) bit description . . . . . . . 54
Table 16: PLL Control register (PLL0CON - address Table 42: Interrupt Enable register (VICIntEnable - address
0xE01F C080, PLL1CON - address 0xFFFF F010) bit allocation . . . . . . . . . . . . . . 54
0xE01F C0A0) bit description. . . . . . . . . . . . . .30 Table 43: Interrupt Enable register (VICIntEnable - address
Table 17: PLL Configuration register (PLL0CFG - address 0xFFFF F010) bit description. . . . . . . . . . . . . . 55
0xE01F C084, PLL1CFG - address Table 44: Software Interrupt Clear register (VICIntEnClear -
0xE01F C0A4) bit description. . . . . . . . . . . . . .30 address 0xFFFF F014) bit allocation . . . . . . . 55
Table 18: PLL Status register (PLL0STAT - address Table 45: Software Interrupt Clear register (VICIntEnClear -
0xE01F C088, PLL1STAT - address address 0xFFFF F014) bit description . . . . . . . 55
0xE01F C0A8) bit description. . . . . . . . . . . . . .31 Table 46: Interrupt Select register (VICIntSelect - address
Table 19: PLL Control bit combinations . . . . . . . . . . . . . .32 0xFFFF F00C) bit allocation . . . . . . . . . . . . . . 55
Table 20: PLL Feed register (PLL0FEED - address Table 47: Interrupt Select register (VICIntSelect - address
0xE01F C08C, PLL1FEED - address 0xFFFF F00C) bit description . . . . . . . . . . . . . 56
0xE01F C0AC) bit description . . . . . . . . . . . . .32 Table 48: IRQ Status register (VICIRQStatus - address
Table 21: Elements determining PLL’s frequency. . . . . . .33 0xFFFF F000) bit allocation . . . . . . . . . . . . . . 56
Table 22: PLL Divider values . . . . . . . . . . . . . . . . . . . . . .34 Table 49: IRQ Status register (VICIRQStatus - address
Table 23: PLL Multiplier values. . . . . . . . . . . . . . . . . . . . .34 0xFFFF F000) bit description. . . . . . . . . . . . . . 56
Table 24: Power control registers . . . . . . . . . . . . . . . . . . .35 Table 50: FIQ Status register (VICFIQStatus - address
Table 25: Power Control register (PCON - address 0xFFFF F004) bit allocation . . . . . . . . . . . . . . 57
0xE01F COCO) bit description . . . . . . . . . . . . .36 Table 51: FIQ Status register (VICFIQStatus - address
Table 26: Power Control for Peripherals register (PCONP - 0xFFFF F004) bit description. . . . . . . . . . . . . . 57
address 0xE01F C0C4) bit description. . . . . . .37 Table 52: Vector Control registers 0-15 (VICVectCntl0-15 -
Table 27: Reset Source identification Register (RSIR - 0xFFFF F200-23C) bit description . . . . . . . . . . 57
address 0xE01F C180) bit description . . . . . . .39 Table 53: Vector Address registers (VICVectAddr0-15 -
Table 28: VPB divider register map . . . . . . . . . . . . . . . . .40 addresses 0xFFFF F100-13C) bit description . 58
Table 29: VPB Divider register (VPBDIV - address Table 54: Default Vector Address register (VICDefVectAddr
continued >>
- address 0xFFFF F034) bit description . . . . . .58 Table 82: Fast GPIO port 1 Pin value byte and half-word
Table 55: Vector Address register (VICVectAddr - address accessible register description. . . . . . . . . . . . . 88
0xFFFF F030) bit description . . . . . . . . . . . . . .58 Table 83: GPIO port 0 output Set register (IO0SET -
Table 56: Protection Enable register (VICProtection - address 0xE002 8004 bit description. . . . . . . . 89
address 0xFFFF F020) bit description . . . . . . .58 Table 84: GPIO port 1 output Set register (IO1SET -
Table 57: Connection of interrupt sources to the Vectored address 0xE002 8014) bit description . . . . . . . 89
Interrupt Controller (VIC) . . . . . . . . . . . . . . . . .59 Table 85: Fast GPIO port 0 output Set register (FIO0SET -
Table 58: Pin description . . . . . . . . . . . . . . . . . . . . . . . . .69 address 0x3FFF C018) bit description. . . . . . . 89
Table 59: Pin connect block register map. . . . . . . . . . . . .75 Table 86: Fast GPIO port 1 output Set register (FIO1SET -
Table 60: Pin function Select register 0 (PINSEL0 - address address 0x3FFF C038) bit description. . . . . . . 89
0xE002 C000) bit description . . . . . . . . . . . . .76 Table 87: Fast GPIO port 0 output Set byte and half-word
Table 61: Pin function Select register 1 (PINSEL1 - address accessible register description. . . . . . . . . . . . . 89
0xE002 C004) bit description . . . . . . . . . . . . .78 Table 88: Fast GPIO port 1 output Set byte and half-word
Table 62: Pin function Select register 2 (PINSEL2 - accessible register description. . . . . . . . . . . . . 90
0xE002 C014) bit description . . . . . . . . . . . . .80 Table 89: GPIO port 0 output Clear register 0 (IO0CLR -
Table 63: Pin function select register bits . . . . . . . . . . . . .80 address 0xE002 800C) bit description . . . . . . . 90
Table 64: GPIO pin description . . . . . . . . . . . . . . . . . . . .81 Table 90: GPIO port 1 output Clear register 1 (IO1CLR -
Table 65: GPIO register map (legacy VPB accessible address 0xE002 801C) bit description . . . . . . . 90
registers). . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82 Table 91: Fast GPIO port 0 output Clear register 0
Table 66: GPIO register map (local bus accessible registers (FIO0CLR - address 0x3FFF C01C) bit
- enhanced GPIO features). . . . . . . . . . . . . . . .83 description . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Table 67: GPIO port 0 Direction register (IO0DIR - address Table 92: Fast GPIO port 1 output Clear register 1
0xE002 8008) bit description . . . . . . . . . . . . . .83 (FIO1CLR - address 0x3FFF C03C) bit
Table 68: GPIO port 1 Direction register (IO1DIR - address description . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
0xE002 8018) bit description . . . . . . . . . . . . . .84 Table 93: Fast GPIO port 0 output Clear byte and half-word
Table 69: Fast GPIO port 0 Direction register (FIO0DIR - accessible register description. . . . . . . . . . . . . 91
address 0x3FFF C000) bit description . . . . . . .84 Table 94: Fast GPIO port 1 output Clear byte and half-word
Table 70: Fast GPIO port 1 Direction register (FIO1DIR - accessible register description. . . . . . . . . . . . . 91
address 0x3FFF C020) bit description . . . . . . .84 Table 95: UART0 pin description . . . . . . . . . . . . . . . . . . . 95
Table 71: Fast GPIO port 0 Direction control byte and Table 96: UART0 register map . . . . . . . . . . . . . . . . . . . . 96
half-word accessible register description . . . . .84 Table 97: UART0 Receiver Buffer Register (U0RBR -
Table 72: Fast GPIO port 1 Direction control byte and address 0xE000 C000, when DLAB = 0, Read
half-word accessible register description . . . . .85 Only) bit description . . . . . . . . . . . . . . . . . . . . 97
Table 73: Fast GPIO port 0 Mask register (FIO0MASK - Table 98: UART0 Transmit Holding Register (U0THR -
address 0x3FFF C010) bit description . . . . . . .85 address 0xE000 C000, when DLAB = 0, Write
Table 74: Fast GPIO port 1 Mask register (FIO1MASK - Only) bit description . . . . . . . . . . . . . . . . . . . . . 97
address 0x3FFF C030) bit description . . . . . . .85 Table 99: UART0 Divisor Latch LSB register (U0DLL -
Table 75: Fast GPIO port 0 Mask byte and half-word address 0xE000 C000, when DLAB = 1) bit
accessible register description . . . . . . . . . . . . .86 description . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Table 76: Fast GPIO port 1 Mask byte and half-word Table 100:UART0 Divisor Latch MSB register (U0DLM -
accessible register description . . . . . . . . . . . . .86 address 0xE000 C004, when DLAB = 1) bit
Table 77: GPIO port 0 Pin value register (IO0PIN - address description . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
0xE002 8000) bit description . . . . . . . . . . . . . .87 Table 101:UART0 Fractional Divider Register (U0FDR -
Table 78: GPIO port 1 Pin value register (IO1PIN - address address 0xE000 C028) bit description . . . . . . . 98
0xE002 8010) bit description . . . . . . . . . . . . . .87 Table 102:Baudrates available when using 20 MHz
Table 79: Fast GPIO port 0 Pin value register (FIO0PIN - peripheral clock (PCLK = 20 MHz). . . . . . . . . . 99
address 0x3FFF C014) bit description . . . . . . .87 Table 103:UART0 Interrupt Enable Register (U0IER -
Table 80: Fast GPIO port 1 Pin value register (FIO1PIN - address 0xE000 C004, when DLAB = 0) bit
address 0x3FFF C034) bit description . . . . . . .87 description . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Table 81: Fast GPIO port 0 Pin value byte and half-word Table 104:UART0 Interrupt Identification Register
accessible register description . . . . . . . . . . . . .88 (UOIIR - address 0xE000 C008, read only)
continued >>
continued >>
Table 151:Slave Transmitter mode . . . . . . . . . . . . . . . . .158 (USBDevIntEn - address 0xE009 0004) bit
Table 152:Miscellaneous States . . . . . . . . . . . . . . . . . . .160 description . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
Table 153:SPI data to clock phase relationship. . . . . . . .172 Table 180:USB Device Interrupt Clear register
Table 154:SPI pin description . . . . . . . . . . . . . . . . . . . . .175 (USBDevIntClr - address 0xE009 0008) bit
Table 155:SPI register map . . . . . . . . . . . . . . . . . . . . . . .176 allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
Table 156:SPI Control Register (S0SPCR - address Table 181:USB Device Interrupt Clear register
0xE002 0000) bit description . . . . . . . . . . . . .176 (USBDevIntClr - address 0xE009 0008) bit
Table 157:SPI Status Register (S0SPSR - address description . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
0xE002 0004) bit description . . . . . . . . . . . . .177 Table 182:USB Device Interrupt Set register (USBDevIntSet
Table 158:SPI Data Register (S0SPDR - address - address 0xE009 000C) bit allocation . . . . . 203
0xE002 0008) bit description . . . . . . . . . . . . .178 Table 183:USB Device Interrupt Set register (USBDevIntSet
Table 159:SPI Clock Counter Register (S0SPCCR - address - address 0xE009 000C) bit description. . . . . 203
0xE002 000C) bit description . . . . . . . . . . . . .178 Table 184:USB Device Interrupt Priority register
Table 160:SPI Interrupt register (S0SPINT - address (USBDevIntPri - address 0xE009 002C) bit
0xE002 001C) bit description . . . . . . . . . . . . .179 description . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
Table 161:SSP pin descriptions . . . . . . . . . . . . . . . . . . .180 Table 185:USB Endpoint Interrupt Status register
Table 162:SSP register map . . . . . . . . . . . . . . . . . . . . . .189 (USBEpIntSt - address 0xE009 0030) bit
Table 163:SSP Control Register 0 (SSPCR0 - address allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
0xE006 8000) bit description . . . . . . . . . . . . .189 Table 186:USB Endpoint Interrupt Status register
Table 164:SSP Control Register 1 (SSPCR1 - address (USBEpIntSt - address 0xE009 0030) bit
0xE006 8004) bit description . . . . . . . . . . . . .190 description . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
Table 165:SSP Data Register (SSPDR - address Table 187:USB Endpoint Interrupt Enable register
0xE006 8008) bit description . . . . . . . . . . . . .191 (USBEpIntEn - address 0xE009 0034) bit
Table 166:SSP Status Register (SSPDR - address allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
0xE006 800C) bit description . . . . . . . . . . . . .191 Table 188:USB Endpoint Interrupt Enable register
Table 167:SSP Clock Prescale Register (SSPCPSR - (USBEpIntEn - address 0xE009 0034) bit
address 0xE006 8010) bit description . . . . . .191 description . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
Table 168:SSP Interrupt Mask Set/Clear register (SSPIMSC Table 189:USB Endpoint Interrupt Clear register
- address 0xE006 8014) bit description . . . . .192 (USBEpIntClr - address 0xE009 0038) bit
Table 169:SSP Raw Interrupt Status register (SSPRIS - allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
address 0xE006 8018) bit description . . . . . .192 Table 190:USB Endpoint Interrupt Clear register
Table 170:SSP Masked Interrupt Status register (SSPMIS (USBEpIntClr - address 0xE009 0038) bit
-address 0xE006 801C) bit description . . . . .193 description . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
Table 171:SSP interrupt Clear Register (SSPICR - address Table 191:USB Endpoint Interrupt Set register (USBEpIntSet
0xE006 8020) bit description . . . . . . . . . . . . .193 - address 0xE009 003C) bit allocation . . . . . 207
Table 172:USB related acronyms, abbreviations and Table 192:USB Endpoint Interrupt Set register (USBEpIntSet
definitions used in this chapter . . . . . . . . . . . .194 - address 0xE009 003C) bit description. . . . . 207
Table 173:Pre-Fixed Endpoint Configuration. . . . . . . . . .195 Table 193:USB Endpoint Interrupt Priority register
Table 174:USB device register map . . . . . . . . . . . . . . . .199 (USBEpIntPri - address 0xE009 0040) bit
Table 175:USB Interrupt Status register (USBIntSt - address allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
0xE01F C1C0) bit description. . . . . . . . . . . . .200 Table 194:USB Endpoint Interrupt Priority register
Table 176:USB Device Interrupt Status register (USBEpIntPri - address 0xE009 0040) bit
(USBDevIntSt - address 0xE009 0000) bit description . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . .201 Table 195:USB Realize Endpoint register (USBReEp -
Table 177:USB Device Interrupt Status register address 0xE009 0044) bit allocation . . . . . . . 208
(USBDevIntSt - address 0xE009 0000) bit Table 196:USB Realize Endpoint register (USBReEp -
description . . . . . . . . . . . . . . . . . . . . . . . . . . .201 address 0xE009 0044) bit description . . . . . . 208
Table 178:USB Device Interrupt Enable register Table 197:USB Endpoint Index register (USBEpIn - address
(USBDevIntEn - address 0xE009 0004) bit 0xE009 0048) bit description . . . . . . . . . . . . . 210
allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . .202 Table 198:USB MaxPacketSize register (USBMaxPSize -
Table 179:USB Device Interrupt Enable register address 0xE009 004C) bit description . . . . . . 210
continued >>
continued >>
0xE001 4000) bit description . . . . . . . . . . . . .259 Table 273:Time counter relationships and values. . . . . . 281
Table 249:PWM Timer Control Register (PWMTCR - Table 274:Time counter registers . . . . . . . . . . . . . . . . . . 281
address 0xE001 4004) bit description . . . . . .260 Table 275:Alarm registers. . . . . . . . . . . . . . . . . . . . . . . . 282
Table 250:Match Control Register (MCR, TIMER0: T0MCR - Table 276:Reference clock divider registers . . . . . . . . . . 283
address 0xE000 4014 and TIMER1: T1MCR - Table 277:Prescaler Integer register (PREINT - address
address 0xE000 8014) bit description . . . . . .261 0xE002 4080) bit description . . . . . . . . . . . . . 283
Table 251:PWM Control Register (PWMPCR - address Table 278:Prescaler Integer register (PREFRAC - address
0xE001 404C) bit description . . . . . . . . . . . . .262 0xE002 4084) bit description . . . . . . . . . . . . . 283
Table 252:PWM Latch Enable Register (PWMLER - address Table 279:Prescaler cases where the Integer Counter reload
0xE001 4050) bit description . . . . . . . . . . . . .264 value is incremented . . . . . . . . . . . . . . . . . . . 285
Table 253:ADC pin description . . . . . . . . . . . . . . . . . . . .265 Table 280:Recommended values for the RTC external
Table 254:ADC registers . . . . . . . . . . . . . . . . . . . . . . . . .266 32 kHz oscillator CX1/X2 components . . . . . . . 286
Table 255:A/D Control Register (AD0CR - address Table 281:Watchdog register map . . . . . . . . . . . . . . . . . 288
0xE003 4000 and AD1CR - address Table 282:Watchdog operating modes selection . . . . . . 288
0xE006 0000) bit description . . . . . . . . . . . . .267 Table 283:Watchdog Mode register (WDMOD - address
Table 256:A/D Global Data Register (AD0GDR - address 0xE000 0000) bit description . . . . . . . . . . . . . 289
0xE003 4004 and AD1GDR - address Table 284:Watchdog Timer Constant register (WDTC -
0xE006 0004) bit description . . . . . . . . . . . . .268 address 0xE000 0004) bit description . . . . . . 289
Table 257:A/D Global Start Register (ADGSR - address Table 285:Watchdog Feed register (WDFEED - address
0xE003 4008) bit description . . . . . . . . . . . . .269 0xE000 0008) bit description . . . . . . . . . . . . . 289
Table 258:A/D Status Register (ADSTAT, ADC0: AD0STAT - Table 286:Watchdog Timer Value register (WDTV - address
address 0xE003 4004 and ADC1: AD1STAT - 0xE000 000C) bit description. . . . . . . . . . . . . 289
address 0xE006 0004) bit description . . . . . .270 Table 287:Flash sectors in LPC2141, LPC2142, LPC2144,
Table 259:A/D Status Register (ADSTAT, ADC0: AD0STAT - LPC2146 and LPC2148 . . . . . . . . . . . . . . . . . 296
address 0xE003 4004 and ADC1: AD1STAT - Table 288:ISP command summary. . . . . . . . . . . . . . . . . 298
address 0xE006 0004) bit description . . . . . .270 Table 289:ISP Unlock command. . . . . . . . . . . . . . . . . . . 298
Table 260:A/D Data Registers (ADDR0 to ADDR7, ADC0: Table 290:ISP Set Baud Rate command . . . . . . . . . . . . 298
AD0DR0 to AD0DR7 - 0xE003 4010 to 0xE003 Table 291:Correlation between possible ISP baudrates and
402C and ADC1: AD1DR0 to AD1DR7- 0xE006 external crystal frequency (in MHz) . . . . . . . . 299
0010 to 0xE006 402C) bit description . . . . . .271 Table 292:ISP Echo command . . . . . . . . . . . . . . . . . . . . 299
Table 261:DAC pin description . . . . . . . . . . . . . . . . . . . .273 Table 293:ISP Write to RAM command . . . . . . . . . . . . . 300
Table 262:DAC Register (DACR - address 0xE006 C000) bit Table 294:ISP Read memory command. . . . . . . . . . . . . 300
description . . . . . . . . . . . . . . . . . . . . . . . . . . .273 Table 295:ISP Prepare sector(s) for write operation
Table 263:Real Time Clock (RTC) register map . . . . . . .276 command . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
Table 264:Miscellaneous registers . . . . . . . . . . . . . . . . .277 Table 296:ISP Copy command . . . . . . . . . . . . . . . . . . . . 301
Table 265:Interrupt Location Register (ILR - address Table 297:ISP Go command. . . . . . . . . . . . . . . . . . . . . . 302
0xE002 4000) bit description . . . . . . . . . . . . .278 Table 298:ISP Erase sector command . . . . . . . . . . . . . . 302
Table 266:Clock Tick Counter Register (CTCR - address Table 299:ISP Blank check sector command . . . . . . . . . 303
0xE002 4004) bit description . . . . . . . . . . . . .278 Table 300:ISP Read Part Identification number
Table 267:Clock Control Register (CCR - address command . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
0xE002 4008) bit description . . . . . . . . . . . . .278 Table 301:LPC214x Part Identification numbers . . . . . . 303
Table 268:Counter Increment Interrupt Register (CIIR - Table 302:ISP Read Boot code version number
address 0xE002 400C) bit description . . . . . .279 command . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
Table 269:Alarm Mask Register (AMR - address Table 303:ISP Compare command. . . . . . . . . . . . . . . . . 304
0xE002 4010) bit description . . . . . . . . . . . . .279 Table 304:ISP Return codes Summary . . . . . . . . . . . . . 304
Table 270:Consolidated Time register 0 (CTIME0 - address Table 305:IAP Command Summary . . . . . . . . . . . . . . . . 306
0xE002 4014) bit description . . . . . . . . . . . . .280 Table 306:IAP Prepare sector(s) for write operation
Table 271:Consolidated Time register 1 (CTIME1 - address command . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
0xE002 4018) bit description . . . . . . . . . . . . .280 Table 307:IAP Copy RAM to Flash command . . . . . . . . 308
Table 272:Consolidated Time register 2 (CTIME2 - address Table 308:IAP Erase sector(s) command . . . . . . . . . . . . 308
0xE002 401C) bit description . . . . . . . . . . . . .280 Table 309:IAP Blank check sector(s) command . . . . . . . 309
continued >>
continued >>
25.5 Figures
Fig 1. LPC2141/2/4/6/8 block diagram. . . . . . . . . . . . . . .7 Fig 37. Simultaneous repeated START conditions from two
Fig 2. System memory map. . . . . . . . . . . . . . . . . . . . . . .8 masters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
Fig 3. Peripheral memory map. . . . . . . . . . . . . . . . . . . . .9 Fig 38. Forced access to a busy I2C-bus . . . . . . . . . . . 162
Fig 4. AHB peripheral map . . . . . . . . . . . . . . . . . . . . . .10 Fig 39. Recovering from a bus obstruction caused by a low
Fig 5. Map of lower memory is showing level on SDA . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
re-mapped and re-mappable areas Fig 40. SPI data transfer format
(LPC2148 with 512 kB Flash) . . . . . . . . . . . . . . .14 (CPHA = 0 and CPHA = 1) . . . . . . . . . . . . . . . . 172
Fig 6. Oscillator modes and models: a) slave mode of Fig 41. SPI block diagram . . . . . . . . . . . . . . . . . . . . . . . 179
operation, b) oscillation mode of operation, c) Fig 42. Texas Instruments synchronous serial frame format:
external crystal model used for CX1/X2 evaluation19 a) single and b) continuous/back-to-back two frames
Fig 7. FOSC selection algorithm . . . . . . . . . . . . . . . . . . .20 transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
Fig 8. External interrupt logic . . . . . . . . . . . . . . . . . . . . .25 Fig 43. SPI frame format with CPOL=0 and CPHA=0 (a)
Fig 9. PLL block diagram . . . . . . . . . . . . . . . . . . . . . . . .29 single and b) continuous transfer) . . . . . . . . . . . 183
Fig 10. Reset block diagram including the wakeup timer .39 Fig 44. SPI frame format with CPOL=0 and CPHA=1. . 184
Fig 11. VPB divider connections . . . . . . . . . . . . . . . . . . .41 Fig 45. SPI frame format with CPOL = 1 and CPHA = 0 (a)
Fig 12. Simplified block diagram of the Memory Accelerator single and b) continuous transfer) . . . . . . . . . . . 185
Module (MAM) . . . . . . . . . . . . . . . . . . . . . . . . . . .45 Fig 46. SPI frame format with CPOL = 1 and CPHA = 1186
Fig 13. Block diagram of the Vectored Interrupt Controller Fig 47. Microwire frame format (single transfer) . . . . . . 187
(VIC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60 Fig 48. Microwire frame format (continuos transfers) . . 188
Fig 14. LPC2141 64-pin package . . . . . . . . . . . . . . . . . .66 Fig 49. Microwire frame format (continuos transfers) -
Fig 15. LPC2142 64-pin package . . . . . . . . . . . . . . . . . .67 details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Fig 16. LPC2144/6/8 64-pin package . . . . . . . . . . . . . . .68 Fig 50. USB Device Controller Block Diagram . . . . . . . 196
Fig 17. Illustration of the fast and slow GPIO access and Fig 51. USB MaxPacket register array indexing . . . . . . 210
output showing 3.5 x increase of the pin output Fig 52. UDCA Head register and DMA descriptors. . . . 216
frequency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .94 Fig 53. Finding the DMA descriptor. . . . . . . . . . . . . . . . 235
Fig 18. Autobaud Mode 0 and Mode 1 waveform . . . . .109 Fig 54. Data transfer in ATLE mode . . . . . . . . . . . . . . . 237
Fig 19. UART0 block diagram . . . . . . . . . . . . . . . . . . . .111 Fig 55. Isochronous OUT Endpoint operation example 241
Fig 20. Auto-RTS functional timing . . . . . . . . . . . . . . . .124 Fig 56. A timer cycle in which PR=2, MRx=6, and both
Fig 21. Auto-CTS functional timing . . . . . . . . . . . . . . . .125 interrupt and reset on match are enabled . . . . . 251
Fig 22. Autobaud Mode 0 and Mode 1 waveform . . . . .130 Fig 57. A timer cycle in which PR=2, MRx=6, and both
Fig 23. UART1 block diagram . . . . . . . . . . . . . . . . . . . .132 interrupt and stop on match are enabled . . . . . 251
Fig 24. I2C-bus Configuration. . . . . . . . . . . . . . . . . . . . .134 Fig 58. Timer block diagram . . . . . . . . . . . . . . . . . . . . . 252
Fig 25. Format in the Master Transmitter mode . . . . . . .135 Fig 59. PWM block diagram . . . . . . . . . . . . . . . . . . . . . 255
Fig 26. Format of Master Receive mode . . . . . . . . . . . .136 Fig 60. Sample PWM waveforms . . . . . . . . . . . . . . . . . 256
Fig 27. A Master Receiver switches to Master Transmitter Fig 61. RTC block diagram . . . . . . . . . . . . . . . . . . . . . . 275
after sending Repeated START . . . . . . . . . . . . .136 Fig 62. RTC prescaler block diagram . . . . . . . . . . . . . . 284
Fig 28. Format of Slave Receiver mode. . . . . . . . . . . . .137 Fig 63. RTC 32kHz crystal oscillator circuit. . . . . . . . . . 286
Fig 29. Format of Slave Transmitter mode . . . . . . . . . . .137 Fig 64. Watchdog block diagram . . . . . . . . . . . . . . . . . . 290
Fig 30. I2C serial interface block diagram . . . . . . . . . . .139 Fig 65. Map of lower memory after reset . . . . . . . . . . . 292
Fig 31. Arbitration procedure . . . . . . . . . . . . . . . . . . . . .140 Fig 66. Boot process flowchart . . . . . . . . . . . . . . . . . . . 295
Fig 32. Serial clock synchronization. . . . . . . . . . . . . . . .141 Fig 67. IAP Parameter passing . . . . . . . . . . . . . . . . . . . 307
Fig 33. Format and States in the Master Transmitter Fig 68. EmbeddedICE debug environment block
mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .150 diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
Fig 34. Format and States in the Master Receiver Fig 69. ETM debug environment block diagram . . . . . . 318
mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .151 Fig 70. RealMonitor components . . . . . . . . . . . . . . . . . 320
Fig 35. Format and States in the Slave Receiver mode.152 Fig 71. RealMonitor as a state machine . . . . . . . . . . . . 321
Fig 36. Format and States in the Slave Transmitter Fig 72. Exception handlers . . . . . . . . . . . . . . . . . . . . . . 324
mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .153
continued >>
25.6 Contents
Chapter 1: General information
2.1 Memory maps. . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.2.1 Memory map concepts and operating modes 11
2.2 LPC2141/2142/2144/2146/2148 memory 2.2.2 Memory re-mapping. . . . . . . . . . . . . . . . . . . . 12
re-mapping and boot block. . . . . . . . . . . . . . . 11 2.3 Prefetch abort and data abort exceptions . . 15
continued >>
continued >>
8.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 8.4.4 GPIO port output Set register (IOSET, Port 0:
8.2 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 IO0SET - 0xE002 8004 and Port 1: IO1SET -
8.3 Pin description . . . . . . . . . . . . . . . . . . . . . . . . . 81 0xE002 8014; FIOSET, Port 0: FIO0SET -
0x3FFF C018 and Port 1: FIO1SET -
8.4 Register description . . . . . . . . . . . . . . . . . . . . 81
0x3FFF C038) . . . . . . . . . . . . . . . . . . . . . . . . 88
8.4.1 GPIO port Direction register (IODIR, Port 0: 8.4.5 GPIO port output Clear register (IOCLR, Port 0:
IO0DIR - 0xE002 8008 and Port 1: IO1DIR - IO0CLR - 0xE002 800C and Port 1: IO1CLR -
0xE002 8018; FIODIR, Port 0: FIO0DIR - 0xE002 801C; FIOCLR, Port 0: FIO0CLR -
0x3FFF C000 and Port 1:FIO1DIR - 0x3FFF C01C and Port 1: FIO1CLR -
0x3FFF C020) . . . . . . . . . . . . . . . . . . . . . . . . 83 0x3FFF C03C) . . . . . . . . . . . . . . . . . . . . . . . . 90
8.4.2 Fast GPIO port Mask register (FIOMASK, Port 0:
8.5 GPIO usage notes . . . . . . . . . . . . . . . . . . . . . . 92
FIO0MASK - 0x3FFF C010 and Port
1:FIO1MASK - 0x3FFF C030) . . . . . . . . . . . . 85 8.5.1 Example 1: sequential accesses to IOSET and
8.4.3 GPIO port Pin value register (IOPIN, Port 0: IOCLR affecting the same GPIO pin/bit . . . . . 92
IO0PIN - 0xE002 8000 and Port 1: IO1PIN - 8.5.2 Example 2: an immediate output of 0s and 1s on
0xE002 8010; FIOPIN, Port 0: FIO0PIN - a GPIO port . . . . . . . . . . . . . . . . . . . . . . . . . . 92
0x3FFF C014 and Port 1: FIO1PIN - 8.5.3 Writing to IOSET/IOCLR .vs. IOPIN. . . . . . . . 93
0x3FFF C034) . . . . . . . . . . . . . . . . . . . . . . . . 86 8.5.4 Output signal frequency considerations when
using the legacy and enhanced GPIO registers .
93
continued >>
10.3.4 UART1 Fractional Divider Register (U1FDR - 10.3.11 UART1 Line Status Register (U1LSR -
0xE001 0028) . . . . . . . . . . . . . . . . . . . . . . . . 116 0xE001 0014, Read Only) . . . . . . . . . . . . . . 125
10.3.5 UART1 baudrate calculation . . . . . . . . . . . . . 117 10.3.12 UART1 Modem Status Register (U1MSR -
10.3.6 UART1 Interrupt Enable Register (U1IER - 0xE001 0018), LPC2144/6/8 only . . . . . . . . 127
0xE001 0004, when DLAB = 0) . . . . . . . . . . 118 10.3.13 UART1 Scratch pad register (U1SCR -
10.3.7 UART1 Interrupt Identification Register (U1IIR - 0xE001 001C) . . . . . . . . . . . . . . . . . . . . . . . 127
0xE001 0008, Read Only) . . . . . . . . . . . . . . 119 10.3.14 UART1 Auto-baud Control Register (U1ACR -
10.3.8 UART1 FIFO Control Register (U1FCR - 0xE001 0020). . . . . . . . . . . . . . . . . . . . . . . . 127
0xE001 0008) . . . . . . . . . . . . . . . . . . . . . . . . 121 10.3.15 Auto-baud. . . . . . . . . . . . . . . . . . . . . . . . . . . 128
10.3.9 UART1 Line Control Register (U1LCR - 10.3.16 Auto-baud Modes. . . . . . . . . . . . . . . . . . . . . 129
0xE001 000C). . . . . . . . . . . . . . . . . . . . . . . . 122 10.3.17 UART1 Transmit Enable Register (U1TER -
10.3.10 UART1 Modem Control Register (U1MCR - 0xE001 0030). . . . . . . . . . . . . . . . . . . . . . . . 130
0xE001 0010), LPC2144/6/8 only . . . . . . . . 123 10.4 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . 131
11.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 11.7.5 I2C Slave Address register (I2ADR: I2C0,
11.2 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . 133 I2C0ADR - 0xE001 C00C and I2C1, I2C1ADR -
11.3 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 address 0xE005 C00C) . . . . . . . . . . . . . . . . 146
11.7.6 I2C SCL High duty cycle register (I2SCLH: I2C0,
11.4 Pin description . . . . . . . . . . . . . . . . . . . . . . . . 134
I2C0SCLH - 0xE001 C010 and I2C1, I2C1SCLH -
11.5 I2C operating modes . . . . . . . . . . . . . . . . . . . 134 0xE0015 C010) . . . . . . . . . . . . . . . . . . . . . . 146
11.5.1 Master Transmitter mode . . . . . . . . . . . . . . . 134 11.7.7 I2C SCL Low duty cycle register (I2SCLL: I2C0 -
11.5.2 Master Receiver mode . . . . . . . . . . . . . . . . . 135 I2C0SCLL: 0xE001 C014; I2C1 - I2C1SCLL:
11.5.3 Slave Receiver mode . . . . . . . . . . . . . . . . . . 136 0xE0015 C014) . . . . . . . . . . . . . . . . . . . . . . 146
11.5.4 Slave Transmitter mode . . . . . . . . . . . . . . . . 137 11.7.8 Selecting the appropriate I2C data rate and duty
11.6 I2C Implementation and operation . . . . . . . . 138 cycle. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
11.6.1 Input filters and output stages . . . . . . . . . . . 138 11.8 Details of I2C operating modes . . . . . . . . . . 147
11.6.2 Address Register, I2ADDR . . . . . . . . . . . . . . 140 11.8.1 Master Transmitter mode . . . . . . . . . . . . . . . 148
11.6.3 Comparator. . . . . . . . . . . . . . . . . . . . . . . . . . 140 11.8.2 Master Receiver mode . . . . . . . . . . . . . . . . . 148
11.6.4 Shift register, I2DAT . . . . . . . . . . . . . . . . . . . 140 11.8.3 Slave Receiver mode . . . . . . . . . . . . . . . . . . 149
11.6.5 Arbitration and synchronization logic . . . . . . 140 11.8.4 Slave Transmitter mode . . . . . . . . . . . . . . . . 153
11.6.6 Serial clock generator . . . . . . . . . . . . . . . . . . 141 11.8.5 Miscellaneous States . . . . . . . . . . . . . . . . . . 159
11.6.7 Timing and control . . . . . . . . . . . . . . . . . . . . 141 11.8.6 I2STAT = 0xF8 . . . . . . . . . . . . . . . . . . . . . . . 159
11.6.8 Control register, I2CONSET and I2CONCLR 141 11.8.7 I2STAT = 0x00 . . . . . . . . . . . . . . . . . . . . . . . 159
11.6.9 Status decoder and Status register . . . . . . . 142 11.8.8 Some special cases . . . . . . . . . . . . . . . . . . . 160
11.7 Register description . . . . . . . . . . . . . . . . . . . 142 11.8.9 Simultaneous repeated START conditions from
11.7.1 I2C Control Set register (I2CONSET: I2C0, two masters . . . . . . . . . . . . . . . . . . . . . . . . . 160
I2C0CONSET - 0xE001 C000 and I2C1, 11.8.10 Data transfer after loss of arbitration . . . . . . 160
I2C1CONSET - 0xE005 C000) . . . . . . . . . . . 143 11.8.11 Forced access to the I2C-bus. . . . . . . . . . . . 160
11.7.2 I2C Control Clear register (I2CONCLR: I2C0, 11.8.12 I2C-bus obstructed by a low level on
I2C0CONCLR - 0xE001 C018 and I2C1, SCL or SDA . . . . . . . . . . . . . . . . . . . . . . . . . 161
I2C1CONCLR - 0xE005 C018). . . . . . . . . . . 144 11.8.13 Bus error . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
11.7.3 I2C Status register (I2STAT: I2C0, I2C0STAT - 11.8.14 I2C State service routines . . . . . . . . . . . . . . 162
0xE001 C004 and I2C1, I2C1STAT - 11.8.15 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . 163
0xE005 C004). . . . . . . . . . . . . . . . . . . . . . . . 145 11.8.16 I2C interrupt service . . . . . . . . . . . . . . . . . . . 163
11.7.4 I2C Data register (I2DAT: 11.8.17 The State service routines . . . . . . . . . . . . . . 163
I2C0, I2C0DAT - 0xE001 C008 and 11.8.18 Adapting State services to an application . . 163
I2C1, I2C1DAT - 0xE005 C008) . . . . . . . . . . 145 11.9 Software example . . . . . . . . . . . . . . . . . . . . . 163
11.9.1 Initialization routine . . . . . . . . . . . . . . . . . . . 163
continued >>
11.9.2 Start Master Transmit function . . . . . . . . . . . 163 11.9.20 State: 0x58. . . . . . . . . . . . . . . . . . . . . . . . . . 167
11.9.3 Start Master Receive function . . . . . . . . . . . 164 11.9.21 Slave Receiver States . . . . . . . . . . . . . . . . . 167
11.9.4 I2C interrupt routine . . . . . . . . . . . . . . . . . . . 164 11.9.22 State: 0x60. . . . . . . . . . . . . . . . . . . . . . . . . . 167
11.9.5 Non mode specific States . . . . . . . . . . . . . . . 164 11.9.23 State: 0x68. . . . . . . . . . . . . . . . . . . . . . . . . . 167
11.9.6 State: 0x00 . . . . . . . . . . . . . . . . . . . . . . . . . . 164 11.9.24 State: 0x70. . . . . . . . . . . . . . . . . . . . . . . . . . 168
11.9.7 Master States . . . . . . . . . . . . . . . . . . . . . . . . 164 11.9.25 State: 0x78. . . . . . . . . . . . . . . . . . . . . . . . . . 168
11.9.8 State: 0x08 . . . . . . . . . . . . . . . . . . . . . . . . . . 164 11.9.26 State: 0x80. . . . . . . . . . . . . . . . . . . . . . . . . . 168
11.9.9 State: 0x10 . . . . . . . . . . . . . . . . . . . . . . . . . . 165 11.9.27 State: 0x88. . . . . . . . . . . . . . . . . . . . . . . . . . 168
11.9.10 Master Transmitter States. . . . . . . . . . . . . . . 165 11.9.28 State: 0x90. . . . . . . . . . . . . . . . . . . . . . . . . . 169
11.9.11 State: 0x18 . . . . . . . . . . . . . . . . . . . . . . . . . . 165 11.9.29 State: 0x98. . . . . . . . . . . . . . . . . . . . . . . . . . 169
11.9.12 State: 0x20 . . . . . . . . . . . . . . . . . . . . . . . . . . 165 11.9.30 State: 0xA0 . . . . . . . . . . . . . . . . . . . . . . . . . 169
11.9.13 State: 0x28 . . . . . . . . . . . . . . . . . . . . . . . . . . 165 11.9.31 Slave Transmitter States . . . . . . . . . . . . . . . 169
11.9.14 State: 0x30 . . . . . . . . . . . . . . . . . . . . . . . . . . 166 11.9.32 State: 0xA8 . . . . . . . . . . . . . . . . . . . . . . . . . 169
11.9.15 State: 0x38 . . . . . . . . . . . . . . . . . . . . . . . . . . 166 11.9.33 State: 0xB0 . . . . . . . . . . . . . . . . . . . . . . . . . 169
11.9.16 Master Receive States . . . . . . . . . . . . . . . . . 166 11.9.34 State: 0xB8 . . . . . . . . . . . . . . . . . . . . . . . . . 170
11.9.17 State: 0x40 . . . . . . . . . . . . . . . . . . . . . . . . . . 166 11.9.35 State: 0xC0 . . . . . . . . . . . . . . . . . . . . . . . . . 170
11.9.18 State: 0x48 . . . . . . . . . . . . . . . . . . . . . . . . . . 166 11.9.36 State: 0xC8 . . . . . . . . . . . . . . . . . . . . . . . . . 170
11.9.19 State: 0x50 . . . . . . . . . . . . . . . . . . . . . . . . . . 167
13.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 13.3.9 Setup and hold time requirements on CS with
13.2 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 respect to SK in Microwire mode . . . . . . . . . 188
13.3 Bus description . . . . . . . . . . . . . . . . . . . . . . . 181 13.4 Register description . . . . . . . . . . . . . . . . . . . 188
13.3.1 Texas Instruments Synchronous Serial (SSI) 13.4.1 SSP Control Register 0
frame format . . . . . . . . . . . . . . . . . . . . . . . . . 181 (SSPCR0 - 0xE006 8000) . . . . . . . . . . . . . . 189
13.3.2 SPI frame format. . . . . . . . . . . . . . . . . . . . . . 182 13.4.2 SSP Control Register 1
13.3.3 Clock Polarity (CPOL) and Clock Phase (CPHA) (SSPCR1 - 0xE006 8004) . . . . . . . . . . . . . . 190
control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 13.4.3 SSP Data Register (SSPDR - 0xE006 8008) 191
13.3.4 SPI format with CPOL=0,CPHA=0 . . . . . . . . 183 13.4.4 SSP Status Register
13.3.5 SPI format with CPOL=0,CPHA=1 . . . . . . . . 184 (SSPSR - 0xE006 800C) . . . . . . . . . . . . . . . 191
13.3.6 SPI format with CPOL = 1,CPHA = 0 . . . . . . 185 13.4.5 SSP Clock Prescale Register (SSPCPSR -
13.3.7 SPI format with CPOL = 1,CPHA = 1 . . . . . . 186 0xE006 8010). . . . . . . . . . . . . . . . . . . . . . . . 191
13.3.8 Semiconductor Microwire frame format . . . . 186 13.4.6 SSP Interrupt Mask Set/Clear register (SSPIMSC
- 0xE006 8014) . . . . . . . . . . . . . . . . . . . . . . 192
continued >>
13.4.7 SSP Raw Interrupt Status register (SSPRIS - 13.4.9 SSP Interrupt Clear Register (SSPICR -
0xE006 8018) . . . . . . . . . . . . . . . . . . . . . . . . 192 0xE006 8020). . . . . . . . . . . . . . . . . . . . . . . . 193
13.4.8 SSP Masked Interrupt register (SSPMIS -
0xE006 801C). . . . . . . . . . . . . . . . . . . . . . . . 193
continued >>
14.8.25 USB New DD Request Interrupt Set register 14.10.1 Next_DD_pointer . . . . . . . . . . . . . . . . . . . . . 231
(USBNDDRIntSet - 0xE009 00B4) . . . . . . . . 220 14.10.2 DMA_mode . . . . . . . . . . . . . . . . . . . . . . . . . 232
14.8.26 USB System Error Interrupt Status register 14.10.3 Next_DD_valid . . . . . . . . . . . . . . . . . . . . . . . 232
(USBSysErrIntSt - 0xE009 00B8) . . . . . . . . . 221 14.10.4 Isochronous_endpoint . . . . . . . . . . . . . . . . . 232
14.8.27 USB System Error Interrupt Clear register 14.10.5 Max_packet_size . . . . . . . . . . . . . . . . . . . . . 232
(USBSysErrIntClr - 0xE009 00BC) . . . . . . . . 221 14.10.6 DMA_buffer_length . . . . . . . . . . . . . . . . . . . 232
14.8.28 USB System Error Interrupt Set register 14.10.7 DMA_buffer_start_addr . . . . . . . . . . . . . . . . 232
(USBSysErrIntSet - 0xE009 00C0). . . . . . . . 221 14.10.8 DD_retired . . . . . . . . . . . . . . . . . . . . . . . . . . 232
14.9 Protocol engine command description . . . . 222 14.10.9 DD_status . . . . . . . . . . . . . . . . . . . . . . . . . . 232
14.9.1 Set Address 14.10.10 Packet_valid . . . . . . . . . . . . . . . . . . . . . . . . . 233
(Command: 0xD0, Data: write 1 byte) . . . . . 223 14.10.11 LS_byte_extracted . . . . . . . . . . . . . . . . . . . . 233
14.9.2 Configure Device (Command: 0xD8, Data: write 1 14.10.12 MS_byte_extracted . . . . . . . . . . . . . . . . . . . 233
byte) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 14.10.13 Present_DMA_count . . . . . . . . . . . . . . . . . . 233
14.9.3 Set Mode 14.10.14 Message_length_position . . . . . . . . . . . . . . 233
(Command: 0xF3, Data: write 1 byte). . . . . . 224 14.10.15 Isochronous_packetsize_memory_address. 233
14.9.4 Read Current Frame Number (Command: 0xF5, 14.11 DMA operation. . . . . . . . . . . . . . . . . . . . . . . . 234
Data: read 1 or 2 bytes) . . . . . . . . . . . . . . . . 225 14.11.1 Triggering the DMA engine . . . . . . . . . . . . . 234
14.9.5 Read Test Register (Command: 0xFD, Data: read 14.11.2 Arbitration between endpoints . . . . . . . . . . . 234
2 bytes) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 14.12 Non Isochronous Endpoints - Normal Mode
14.9.6 Set Device Status (Command: 0xFE, Data: write 1 operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
byte) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 14.12.1 Setting up DMA transfer. . . . . . . . . . . . . . . . 234
14.9.7 Get Device Status (Command: 0xFE, Data: read 1 14.12.2 Finding DMA Descriptor. . . . . . . . . . . . . . . . 234
byte) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 14.12.3 Transferring the Data . . . . . . . . . . . . . . . . . . 235
14.9.8 Get Error Code (Command: 0xFF, Data: read 1 14.12.4 Optimizing Descriptor Fetch. . . . . . . . . . . . . 235
byte) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 14.12.5 Ending the packet transfer . . . . . . . . . . . . . . 236
14.9.9 Read Error Status (Command: 0xFB, Data: read 1 14.12.6 No_Packet DD . . . . . . . . . . . . . . . . . . . . . . . 236
byte) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
14.13 Concatenated transfer (ATLE) mode
14.9.10 Select Endpoint (Command: 0x00 - 0x1F, Data:
operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
read 1 byte (optional)). . . . . . . . . . . . . . . . . . 228
14.13.1 Setting up the DMA transfer. . . . . . . . . . . . . 239
14.9.11 Select Endpoint/Clear Interrupt (Command:
14.13.2 Finding the DMA Descriptor. . . . . . . . . . . . . 239
0x40 - 0x5F, Data: read 1 byte). . . . . . . . . . . 229
14.13.3 Transferring the Data . . . . . . . . . . . . . . . . . . 239
14.9.12 Set Endpoint Status (Command: 0x40 - 0x55,
14.13.4 Ending the packet transfer . . . . . . . . . . . . . . 239
Data: write 1 byte (optional)). . . . . . . . . . . . . 229
14.9.13 Clear Buffer (Command: 0xF2, Data: read 1 byte 14.14 Isochronous Endpoint Operation . . . . . . . . 240
(optional)) . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 14.14.1 Setting up of DMA transfer. . . . . . . . . . . . . . 240
14.9.14 Validate Buffer 14.14.2 Finding the DMA Descriptor. . . . . . . . . . . . . 240
(Command: 0xFA, Data: none) . . . . . . . . . . . 230 14.14.3 Transferring the Data . . . . . . . . . . . . . . . . . . 240
14.10 DMA descriptor . . . . . . . . . . . . . . . . . . . . . . . 230 14.14.4 Isochronous OUT Endpoint Operation
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
15.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 15.5.2 Timer Control Register (TCR, TIMER0: T0TCR -
15.2 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . 242 0xE000 4004 and TIMER1: T1TCR -
15.3 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 0xE000 8004). . . . . . . . . . . . . . . . . . . . . . . . 245
15.5.3 Count Control Register (CTCR,
15.4 Pin description . . . . . . . . . . . . . . . . . . . . . . . . 242
TIMER0: T0CTCR - 0xE000 4070 and
15.5 Register description . . . . . . . . . . . . . . . . . . . 243 TIMER1: T1TCR - 0xE000 8070). . . . . . . . . 246
15.5.1 Interrupt Register (IR, 15.5.4 Timer Counter (TC,
TIMER0: T0IR - 0xE000 4000 and TIMER0: T0TC - 0xE000 4008 and
TIMER1: T1IR - 0xE000 8000) . . . . . . . . . . . 245 TIMER1: T1TC - 0xE000 8008) . . . . . . . . . . 247
continued >>
15.5.5 Prescale Register (PR, TIMER0: T0PR - 15.5.9 Capture Registers (CR0 - CR3) . . . . . . . . . . 249
0xE000 400C and TIMER1: 15.5.10 Capture Control Register (CCR, TIMER0: T0CCR
T1PR - 0xE000 800C) . . . . . . . . . . . . . . . . . 247 - 0xE000 4028 and TIMER1: T1CCR -
15.5.6 Prescale Counter Register (PC, 0xE000 8028). . . . . . . . . . . . . . . . . . . . . . . . 249
TIMER0: T0PC - 0xE000 4010 and 15.5.11 External Match Register (EMR, TIMER0: T0EMR
TIMER1: T1PC - 0xE000 8010) . . . . . . . . . . 247 - 0xE000 403C; and TIMER1: T1EMR -
15.5.7 Match Registers (MR0 - MR3) . . . . . . . . . . . 247 0xE000 803C) . . . . . . . . . . . . . . . . . . . . . . . 250
15.5.8 Match Control Register (MCR, TIMER0: T0MCR - 15.6 Example timer operation . . . . . . . . . . . . . . . 251
0xE000 4014 and TIMER1: T1MCR - 15.7 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . 252
0xE000 8014) . . . . . . . . . . . . . . . . . . . . . . . . 248
17.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 17.4.5 A/D Interrupt Enable Register (ADINTEN, ADC0:
17.2 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 AD0INTEN - 0xE003 400C and ADC1:
17.3 Pin description . . . . . . . . . . . . . . . . . . . . . . . . 265 AD1INTEN - 0xE006 000C) . . . . . . . . . . . . . 270
17.4.6 A/D Data Registers (ADDR0 to ADDR7, ADC0:
17.4 Register description . . . . . . . . . . . . . . . . . . . 266
AD0DR0 to AD0DR7 - 0xE003 4010 to
17.4.1 A/D Control Register (AD0CR - 0xE003 4000 and 0xE003 402C and ADC1: AD1DR0 to AD1DR7-
AD1CR - 0xE006 0000) . . . . . . . . . . . . . . . . 267 0xE006 0010 to 0xE006 402C) . . . . . . . . . . 271
17.4.2 A/D Global Data Register (AD0GDR -
17.5 Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
0xE003 4004 and AD1GDR - 0xE006 0004) 268
17.4.3 A/D Global Start Register (ADGSR - 17.5.1 Hardware-triggered conversion . . . . . . . . . . 272
0xE003 4008) . . . . . . . . . . . . . . . . . . . . . . . . 269 17.5.2 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
17.4.4 A/D Status Register (ADSTAT, 17.5.3 Accuracy vs. digital receiver. . . . . . . . . . . . . 272
ADC0: AD0CR - 0xE003 4004 and
ADC1: AD1CR - 0xE006 0004) . . . . . . . . . . 269
18.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 18.3 DAC Register (DACR - 0xE006 C000). . . . . . 273
18.2 Pin description . . . . . . . . . . . . . . . . . . . . . . . . 273 18.4 Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
continued >>
21.1 Flash Boot Loader . . . . . . . . . . . . . . . . . . . . . 291 21.6 Flash content protection mechanism . . . . . 296
21.2 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 21.7 Code Read Protection (CRP) . . . . . . . . . . . . 297
21.3 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . 291 21.8 ISP commands . . . . . . . . . . . . . . . . . . . . . . . 297
21.4 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 21.8.1 Unlock <unlock code> . . . . . . . . . . . . . . . . . 298
21.4.1 Memory map after any reset. . . . . . . . . . . . . 291 21.8.2 Set Baud Rate <baud rate> <stop bit> . . . . 298
21.4.2 Criterion for valid user code . . . . . . . . . . . . . 292 21.8.3 Echo <setting> . . . . . . . . . . . . . . . . . . . . . . . 299
21.4.3 Communication protocol . . . . . . . . . . . . . . . . 293 21.8.4 Write to RAM <start address>
21.4.4 ISP command format . . . . . . . . . . . . . . . . . . 293 <number of bytes> . . . . . . . . . . . . . . . . . . . . 299
21.4.5 ISP response format . . . . . . . . . . . . . . . . . . . 293 21.8.5 Read memory <address> <no. of bytes>. . . 300
21.4.6 ISP data format. . . . . . . . . . . . . . . . . . . . . . . 293 21.8.6 Prepare sector(s) for write operation <start sector
21.4.7 ISP flow control. . . . . . . . . . . . . . . . . . . . . . . 293 number> <end sector number> . . . . . . . . . . 300
21.4.8 ISP command abort . . . . . . . . . . . . . . . . . . . 294 21.8.7 Copy RAM to Flash <Flash address> <RAM
21.4.9 Interrupts during ISP. . . . . . . . . . . . . . . . . . . 294 address> <no of bytes> . . . . . . . . . . . . . . . . 301
21.4.10 Interrupts during IAP. . . . . . . . . . . . . . . . . . . 294 21.8.8 Go <address> <mode> . . . . . . . . . . . . . . . . 302
21.4.11 RAM used by ISP command handler . . . . . . 294 21.8.9 Erase sector(s) <start sector number> <end
21.4.12 RAM used by IAP command handler . . . . . . 294 sector number> . . . . . . . . . . . . . . . . . . . . . . 302
21.4.13 RAM used by RealMonitor . . . . . . . . . . . . . . 294 21.8.10 Blank check sector(s) <sector number> <end
21.4.14 Boot process flowchart . . . . . . . . . . . . . . . . . 295 sector number> . . . . . . . . . . . . . . . . . . . . . . 303
21.5 Sector numbers . . . . . . . . . . . . . . . . . . . . . . . 295 21.8.11 Read Part Identification number . . . . . . . . . 303
21.8.12 Read Boot code version number . . . . . . . . . 303
continued >>
21.8.13 Compare <address1> <address2> 21.9.5 Read Part Identification number . . . . . . . . . 309
<no of bytes> . . . . . . . . . . . . . . . . . . . . . . . . 304 21.9.6 Read Boot code version number . . . . . . . . . 309
21.8.14 ISP Return codes . . . . . . . . . . . . . . . . . . . . . 304 21.9.7 Compare <address1> <address2>
21.9 IAP Commands . . . . . . . . . . . . . . . . . . . . . . . 305 <no of bytes> . . . . . . . . . . . . . . . . . . . . . . . . 310
21.9.1 Prepare sector(s) for write operation . . . . . . 307 21.9.8 Reinvoke ISP . . . . . . . . . . . . . . . . . . . . . . . . 310
21.9.2 Copy RAM to Flash. . . . . . . . . . . . . . . . . . . . 308 21.9.9 IAP Status codes . . . . . . . . . . . . . . . . . . . . . 310
21.9.3 Erase sector(s) . . . . . . . . . . . . . . . . . . . . . . . 308 21.10 JTAG Flash programming interface. . . . . . . 311
21.9.4 Blank check sector(s) . . . . . . . . . . . . . . . . . . 309