The LPC1102 is an ARM Cortex-M0 based, low-cost 32-bit MCU, designed for 8/16-bit
microcontroller applications, offering performance, low power, simple instruction set and
memory addressing together with reduced code size compared to existing 8/16-bit
architectures.
The LPC1102 operates at CPU frequencies of up to 50 MHz.
The peripheral complement of the LPC1102 includes 32 kB of flash memory, 8 kB of data
memory, one RS-485/EIA-485 UART, one SPI interface with SSP features, four general
purpose counter/timers, a 10-bit ADC, and 11 general purpose I/O pins.
• System:
– ARM Cortex-M0 processor, running at frequencies of up to 50 MHz.
– ARM Cortex -M 0 bu ilt- in Ne ste d Vectored Interrupt Controller (NVIC).
– Serial Wire Debug.
– System tick timer.
• Memory:
– 32 kB on-chip flash programming memory.
– 8 kB SRAM.
– In-Application Programming (IAP) and In-System Programming (ISP) support via
on-chip bootloader software.
• Digital peripherals:
– 11 General Purpose I/O (GPIO) pins with configurable pull-up/pull-down resistors.
– GPIO pins can be used as edge and level sensitive interrupt sources.
– Four general purpose counter/timers with a total of one capture input and nine
match outputs.
– Programmable WatchDog Timer (WDT).
• Analog peripherals:
– 10-bit ADC with input multiplexing among five pins.
– UART with fractional baud rate generation, internal FIFO, and RS-485 support.
– One SPI controller with SSP features and with FIFO and multi-protocol capabilities.
– 12 MHz internal RC oscillator trimmed to 1% accuracy that can optionally be used
as a system clock.
– Programmable watchdog oscillator with a frequency range of 7.8 kHz to 1.8 MHz.
– PLL allows CPU operation up to the maximum CPU rate without the need for a
high-frequency crystal. May be run from an external clock or the internal RC
oscillator.
– Clock output function with divider that can reflect the external clock, IRC clo ck,
CPU clock, and the Watchdog clock.
– Integrated PMU (Power Management Unit) to minimize power consumption dur ing
Sleep and Deep-sleep modes.
– Power profiles residing in boot ROM allowing to optimize performance and
minimize power consumption for any give n application th rough one simple fu nction
call.
– Two reduced power modes: Sleep and Deep-sleep modes.
– Processor wake-up from Deep-sleep mode via a dedicated start logic using up to
six of the functional pins.
– Power-On Reset (POR).
– Brownout detect with four separate thresholds for interrupt and forced reset.
Table 3 shows the memory configuration for the LPC1102 part.
Table 3.LPC1102 memory configuration
PartFlashSRAM
Suffix
LPC110232 kB8 kB
2.2 Memory map
Figure 2 shows the memory and peripheral address space of the LPC1102.
The AHB peripheral area is 2 MB in size and is divided to allow for up to 128 peripherals.
On the LPC1102, the GPIO ports are the only AHB peripherals. The APB peripheral area
is 512 kB in size and is divided to allow for up to 32 peripherals. Each peripheral of either
type is allocated 16 kB of space. This allows simplifying the address decoding for each
peripheral.
All peripheral register addresses are 32-bit word aligned regardless of their size. 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.
The system configuration block controls oscillators, start logic, and clock generation of the
LPC1102. Also included in this block are registers for setting the priority for AHB access
and a register for remapping flash, SRAM, and ROM memory areas.
3.3 Pin description
Table 4 shows pins that are associated with system con tr o l bloc k func tio ns .
Table 4.Pin summary
Pin namePin directionPin description
PIO0_0; PIO0_8 to PIO0_11IStart logic wake-up pins port 0
PIO1_0 IStart logic wake-up pin port 1
3.4 Clocking and power control
See Figure 3 for an overview of the LPC1102 Clock Generation Unit (CGU).
The LPC1102 include three independent oscillators. These are the system oscillator, the
Internal RC oscillator (IRC), and the watchdog oscillator. Each oscillator can be used for
more than one purpose as required in a particular application.
Following reset, the LPC1102 will operate from the Internal RC oscillator until switched by
software. This allows systems to operate without any external crystal and the bootloader
code to operate at a known frequency.
The SYSAHBCLKCTRL register gates the system clock to the various peripherals and
memories. UART, the WDT, and SPI0 have individual clock dividers to derive peripheral
clocks from the main clock.
The system memory remap register selects whether the ARM interrupt vectors are read
from the boot ROM, the flash, or the SRAM.
Table 6.System memory remap register (SYSMEMREMAP, address 0x4004 8000) bit
description
BitSymbolValueDescriptionReset
1:0MAPSystem memory remap10
0x0Boot Loader Mode. Interrupt vectors are re-mapped to Boot
ROM.
0x1User RAM Mode. Interrupt vectors are re-mapped to Static
RAM.
0x2User Flash Mode. Interrupt vectors are not re-mapped and
reside in Flash.
0x3User Flash Mode. Interrupt vectors are not re-mapped and
reside in Flash.
31:2--Reserved0x00
Reference
Table 35
Table 36
value
3.5.2Peripheral reset control register
This register allows software to reset the SPI peripheral. Writing a 0 to the SSP0_RST_N
bit resets the SPI0 peripheral. Writing a 1 de-asserts the reset.
Remark: Before accessing the SPI peripheral, write a 1 to this register to ensure that the
reset signal to the SPI is de-asserted.
Table 7.Peripher al reset control register (PRESETCTRL, address 0x4004 8004) bit
description
BitSymbolValueDescriptionReset
value
0SSP0_RST_NSPI0 reset control0
0Resets the SPI0 periphe ral.
1SPI0 reset de-asserted.
This register connects and enables the system PLL a nd configur es the PLL multiplie r and
divider values. The PLL accepts an input frequency from 10 MHz to 25 MHz from various
clock sources. The input frequency is multiplied up to a high frequency, then divided down
to provide the actual clock used by the CPU, peripherals, and memories. The PLL can
produce a clock up to the maximum allowed for the CPU.
Table 8.Syste m PLL control register (SYSPLLCTRL, address 0x4004 8008) bit description
BitSymbolValueDescriptionReset
4:0MSELFeedback divider value. The division value M is the
6:5PSELPost divider ratio P. The division ratio is 2 × P.0x00
31:7--Reserved. Do not write ones to reserved bits.0x0
UM10429
Chapter 3: LPC1102 System configuration
value
0x000
programmed MSEL value + 1.
00000: Division ratio M = 1
to
11111: Division ration M = 32
0x0P = 1
0x1P = 2
0x2P = 4
0x3P = 8
3.5.4System PLL status register
This register is a Read-only register and supplies the PLL lock status (see
Section 3.10.1
Table 9.Syste m PLL status register (SYSPLLSTAT, address 0x4004 800C) bit description
BitSymbolValueDescriptionReset
0LOCKPLL lock status0x0
31:1--Reserved0x00
).
0PLL not locked
1PLL locked
3.5.5System oscillator control register
This register configures the frequency range for the system oscillator.
Table 10.System oscillator control register (SYSOSCCTRL, address 0x4004 8020) bit
description
BitSymbolValueDescriptionReset
0BYPASSBypass system oscillator0x0
0Oscillator is not bypassed.
1Bypass enabled. PLL input (sys_osc_clk) is fed
Table 10.System oscillator control register (SYSOSCCTRL, address 0x4004 8020) bit
BitSymbolValueDescriptionReset
1FREQRANGEDetermines frequency range for Low-power
31:2--Reserved0x00
3.5.6Watchdog oscillator control register
This register configures the watchdog oscillator. The oscillator consists of an analog and a
digital part. The analog part contains the oscillator function and generates an analog clock
(Fclkana). With the digital part, the analog output clock (Fclkana) can be divided to the
required output clock frequency wdt_osc_clk. The analog output frequency (Fclkan a) can
be adjusted with the FREQSEL bits between 500 kHz and 3.4 MHz. With the digital part
Fclkana will be divided (divider ratios = 2, 4,...,64) to wdt_osc_clk using the DIVSEL bits.
The output clock frequency of the watchdog oscillator can be calculated as
wdt_osc_clk =
⁄
(2 × (1 + DIVSEL))
= 7.8 kHz to 1.7 MHz (nominal values).
Fclkana
Remark: Any setting of the FREQSEL bits will yield a Fclkana value within ±40% of the
listed frequency value. The watchdog oscillator is the clock source with the lowest power
consumption. If accurate timing is required, use the IRC or system oscillator.
Remark: The frequency of the watchdog oscillator is undefined after reset. The watchdog
oscillator frequency must be programmed by writing to the WDTOSCCTRL register before
using the watchdog oscillator.
Table 11.Watchdog oscillator control register (WDTOSCCTRL, address 0x4004 8024) bit
This register updates the clock source of the system PLL with the new input clock after the
SYSPLLCLKSEL register has been written to. In order for the update to take effect, first
write a zero to the SYSPLLUEN register and then write a one to SYSPLLUEN.
Remark: When switching clock sources, both clocks must be running before the clock
source is updated.
This register selects the main system clock which can be either any input to the system
PLL, the output from the system PLL (sys_pllclkout), or the watchdog or IRC oscillators
directly. The main system clock clocks the core, the peripherals, and the memories.
UM10429
Chapter 3: LPC1102 System configuration
8044) bit description
0No change
1Update clock source
The MAINCLKUEN register (see Section 3.5.12
) must be toggled from LOW to HIGH for
the update to take effect.
Remark: When switching clock sources, both clocks must be running before the clock
source is updated.
Remark: When using the C_CAN controller with baudrates above 100 kbit/s, the system
0x0IRC oscillator
0x1Input clock to system PLL
0x2WDT oscillator
0x3System PLL clock out
31:2--Reserved0x00
3.5.12Main clock source update enable register
This register updates the clock source of the main clock with the new input clock after the
MAINCLKSEL register has been written to. In order for the update to take effect, first write
a zero to the MAINCLKUEN register and then write a one to MAINCLKUEN.
Remark: When switching clock sources, both clocks must be running before the clock
source is updated.
This register divides the main clock to provide the system clock to the core, memories,
and the peripherals. The system clock can be shut down completely by setting the DIV
bits to 0x0.
0x01
0: System clock disabled.
1: Divide by 1.
to
255: Divide by 255.
3.5.14System AHB clock control register
The AHBCLKCTRL register enables the clocks to individual system and peripheral blocks.
The system clock (sys_ahb_clk[0], bit 0 in the AHBCLKCTRL register) provides the clock
for the AHB to APB bridge, the AHB matrix, the ARM Cortex- M 0, the Syscon block, and
the PMU. This clock cannot be disabled.
Table 19.System AHB clock control register (SYSAHBCLKCTRL , ad dress 0x4004 8080) bit
description
BitSymbolValueDescriptionReset
0SYSEnables clock for AHB to APB bridge, to the AHB
matrix, to the Cortex-M0 FCLK and HCLK, to the
SysCon, and to the PMU. This bit is read only.
0Reserved
1Enable
This register updates the clock source of the watchdog timer with the new input clock a fter
the WDTCLKSEL register has been written to. In order for the update to take effect at the
input of the watchdog timer, first write a zero to the WDTCLKUEN register and then write
a one to WDTCLKUEN.
0: Disable WDT_PCLK.
1: Divide by 1.
to
255: Divide by 255.
31:8-Reserved0x00
value
0x00
3.5.20POR captured PIO status register 0
The PIOPORCAP0 register captures the state (HIGH or LOW) of the PIO pins of ports 0,1,
and 2 (pins PIO2_0 to PIO2_7) at power-on-reset. Each bit represents the reset state of
one GPIO pin. This register is a read-only status register.
Table 25.POR captured PIO status registers 0 (PIOPORCAP0, address 0x4004 8100) bit
BitSymbolDescriptionReset value
0CAPPIO0_0Raw reset status input PIO0_0User implementation dependent
7:1-Reserved.8CAPPIO0_8Raw reset status input PIO0_8User implementation dependent
9CAPPIO0_9Raw reset status input PIO0_9User implementation dependent
10CAPPIO0_10Raw reset status input PIO0_10User implementation dependent
1 1CAPPIO0_11Raw reset status input PIO0_11User implementation dependent
12CAPPIO1_0Raw reset status input PIO1_0User implementation dependent
13CAPPIO1_1Raw reset status input PIO1_1User implementation dependent
14CAPPIO1_2Raw reset status input PIO1_2User implementation dependent
15CAPPIO1_3Raw reset status input PIO1_3User implementation dependent
17:16-Reserved.18CAPPIO1_6Raw reset status input PIO1_6User implementation dependent
19CAPPIO1_7Raw reset status input PIO1_7User implementation dependent
31:20-Reserved.-
UM10429
Chapter 3: LPC1102 System configuration
description
3.5.21BOD control register
The BOD control register selects four separate threshold values for sending a BOD
interrupt to the NVIC and for forced reset. Reset and interrupt threshold values listed in
Table 26
Table 26.BOD control register (BODCTRL, address 0x400 4 8150) bit description
BitSymbolValue DescriptionReset
1:0BODRSTLEVBOD reset level00
3:2BODINTVALBOD interrupt level00
are typical values.
0x0Level 0: The reset assertion threshold voltage is 1.46 V; the
0x1Level 1: The reset assertion threshold voltage is 2.06 V; the
0x2Level 2: The reset assertion threshold voltage is 2.35 V; the
0x3Level 3: The reset assertion threshold voltage is 2.63 V; the
0x0Level 0: The interrupt assertion threshold voltage is 1.65 V;
0x1Level 1:The interrupt assertion threshold voltage is 2.22 V;
0x2Level 2: The interrupt assertion threshold voltage is 2.52 V;
0x3Level 3: The interrupt assertion threshold voltage is 2.80 V;
value
reset de-assertion threshold voltage is 1.63 V.
reset de-assertion threshold voltage is 2.15 V.
reset de-assertion threshold voltage is 2.43 V.
reset de-assertion threshold voltage is 2.71 V.
the interrupt de-assertion threshold voltage is 1.80 V.
the interrupt de-assertion threshold voltage is 2.35 V.
the interrupt de-assertion threshold voltage is 2.66 V.
the interrupt de-assertion threshold voltage is 2.90 V.
The STARTAPRP0 register controls the start logic input s of ports 0 (PIO0_0 to PIO0_11)
and 1 (PIO1_0). This register selects a falling or rising edge on the corresponding PIO
input to produce a falling or rising clock edge, respectively, for the start logic (see
Section 3.9.2
Every bit in the STARTAPRP0 register controls one port input and is connected to one
wake-up interrupt in the NVIC. Bit 0 in the STARTAPRP0 register corresponds to interrupt
0, bit 1 to interrupt 1, etc. (see Table 44
Remark: Each interrupt connected to a start log ic input must be enabled in the NVIC if the
corresponding PIO pin is used to wake up the chip from Deep-sleep mode.
Table 28.Start logic edge control register 0 (STARTAPRP0, address 0x4004 8200) bit
BitSymbolValueDescriptionReset
0 APRPIO0_0Edge select for start logic input PIO0_00x0
7:1--Reserved0x0
8APRPIO0_8Edge select for start logic input PIO0_80x0
9APRPIO0_9Edge select for start logic input PIO0_90x0
Writing a one to a bit in the STARTRSRP0CLR register resets the start logic state. The bit
assignment is identical to Table 28
clock edge for registering a start signal. This clock edge (falling or rising) sets the interrupt
for waking up from Deep-sleep mode. Therefore, the sta rt-up logic st ates must be cleared
before being used.
0RSRPIO0_0Start signal reset for start logic input PIO0_0n/a
7:1--Reservedn/a
8RSRPIO0_8Start signal reset for start logic input PIO0_8n/a
9RSRPIO0_9Start signal reset for start logic input PIO0_9n/a
10RSRPIO0_10Start signal reset for start logic input PIO0_10n/a
11RSRPIO0_11 Start signal reset for start logic input PIO0_11n/a
12RSRPIO1_0Start signal reset for start logic input PIO1_0n/a
31:13--Reservedn/a
UM10429
Chapter 3: LPC1102 System configuration
. The start-up logic uses the input signals to generate a
description
value
01Write: reset start signal
01Write: reset start signal
01Write: reset start signal
01Write: reset start signal
01Write: reset start signal
01Write: reset start signal
3.5.26Start logic status register 0
This register reflects the status of the enabled start signal bits. The bit assignment is
identical to Table 28
or not a wake-up signal has been received for a given pin.
Table 31.Start logic status register 0 (START SRP0, add ress 0x4004 820C) bit description
BitSymbolValueDescriptionReset
0SRPIO0_0Start signal status for start logic input 0PIO0_0n/a
. Each bit (if enabled) reflects the state of the start logic, i.e. whether
value
0No start signal received
1Start signal pending
Page 26
NXP Semiconductors
UM10429
Chapter 3: LPC1102 System configuration
Table 31.Start logic status register 0 (START SRP0, add ress 0x4004 820C) bit description
BitSymbolValueDescriptionReset
value
8SRPIO0_8Start signal status for start logic input PIO0_8n/a
0No start signal received
1Start signal pending
9SRPIO0_9Start signal status for start logic input PIO0_9n/a
0No start signal received
1Start signal pending
10SRPIO0_10Start signal status for start logic input PIO0_10n/a
0No start signal received
1Start signal pending
11SRPIO0_11Start signal status for start logic input PIO0_11n/a
0No start signal received
1Start signal pending
12SRPIO1_0Start signal status for start logic input PIO1_0n/a
0No start signal received
1Start signal pending
31:13--Reservedn/a
3.5.27Deep-sleep mode configuration register
This register controls the behavior of the WatchDog (WD) oscillator and the BOD circuit
when the device enters Deep-sleep mode.
This register must be initialized at least once before entering Deep-sleep mode with
one of the four values shown in Table 32
Table 32.Allowed values for PDSLEEPCFG register
ConfigurationWD oscillator onWD oscillator off
BOD onPDSLEEPCFG = 0x0000 18B7 PDSLEEPCFG = 0x0000 18F7
BOD offPDSLEEPCFG = 0x0000 18BF PDSLEEPCFG = 0x0000 18FF
:
Remark: Failure to initialize and program this register correctly may result in undefined
behavior of the microcontroller. The values listed in Table 32
for PDSLEEPCFG register.
To select the appropriate power configuration for Deep-sleep mode, consider the
following:
• BOD: Leaving the BOD circuit enabled will protect the part from a low voltage event
occurring while the part is in Deep-sleep mode. However, the BOD circuit causes an
additional current drain in Deep-sleep mode.
• WD oscillator: The watchdog oscillator can be left running in Deep-sleep mode to
provide a clock for the watchdog timer or a general purpose timer if they are needed
for timing a wake-up event (see Section 3.9.3
oscillator analog output frequency must be set to its lowest value (bits FREQSEL in
Remark: Reserved bits in this register must always be written as indicated. This register
must be initialized correctly before entering Deep-sleep mode.
Table 33.Deep-sleep configuration register (PDSLEEPCFG, address 0x4004 8230) bit
BitSymbolValueDescriptionReset
2:0-Reserved. Always write these bits as 111.0
3BOD_PDBOD power-down control in Deep-sleep mode, see
5:4-Reserved. Always write these bits as 11.0
6WDTOSC_PDWatchdog oscillator power control in Deep-sleep
7-Reserved. Always write this bit as 1.0
10:8-Reserved. Always write these bits as 000.0
12:11-Reserved. Always write these bits as 11.0
31:13-Reserved0
UM10429
Chapter 3: LPC1102 System configuration
the WDTOSCCTRL = 0001, see Table 11) and all peripheral clocks other than the
timer clock must be disabled in the SYSAHBCLKCTRL register (see Table 19
entering Deep-sleep mode.
The watchdog oscillator, if running, contributes an additional current drain in
Deep-sleep mode.
description
Table 32
0Powered
1Powered down
mode, see Table 32
0Powered
1Powered down
.
.
) before
value
0
0
3.5.28Wake-up configuration register
The bits in this register determine the state the chip enters when it is waking up from
Deep-sleep mode.
By default, the IRC and flash memory are powered and running and the BOD circuit is
enabled when the chip wakes up from Deep-sleep mode.
Remark: Reserved bits must be always written as indicated.
Table 34.Wake-up configuration register (PDAWAKECFG, address 0x4004 8234) bit
8-Reserved. Always write this bit as 1.1
9-Reserved. Always write this bit as 0. 0
10-Reserved. Always write this bit as 1.1
1 1-Reserved. Always write this bit as 1. 1
12-Reserved. Always write this bit as 0. 0
15:13-Reserved. Always write these bits as 111.111
31:16--Reserved-
description
UM10429
Chapter 3: LPC1102 System configuration
…continued
value
0Powered
1Pow ered down
0Powered
1Pow ered down
0Powered
1Pow ered down
0Powered
1Pow ered down
0Powered
1Pow ered down
0Powered
1Pow ered down
3.5.29Power-down configuration register
The bits in the PDRUNCFG register control the power to the various analog blocks. This
register can be written to at any time while the chip is running, and a write will take effect
immediately with the exception of the power-down signal to the IRC.
To avoid glitches when powering down the IRC, the IRC clock is automatically switched off
at a clean point. Therefore, for the IRC a delay is possible before the power-down state
takes effect.
By default, the IRC and flash memory are powered and running and the BOD circuit is
enabled.
Remark: Reserved bits must be always written as indicated.
Table 35.Power-down configuration register (PDRUNCFG, address 0x4004 8238) bit
BitSymbolValueDescriptionReset
0IRCOUT_PDIRC oscillator output power-down0
1IRC_PDIRC oscillator power-down0
2FLASH_PDFlash power-down0
3BOD_PDBOD power-down0
4ADC_PDADC power-down1
5SYSOSC_PDSystem oscillator power-down1
6WDTOSC_PDWatchdog oscillator power-down 1
7SYSPLL_PDSystem PLL power-down1
8-Reserved. Always write this bit as 1.1
9-Reserved. Always write this bit as 0. 0
10-Reserved. Always write this bit as 1.1
11-Reserved. Always write this bit as 1. 1
12-Reserved. Always write this bit as 0. 0
15:13-Reserved. Always write these bits as 111.111
31:16--Reserved-
UM10429
Chapter 3: LPC1102 System configuration
description
value
0Powered
1Powered down
0Powered
1Powered down
0Powered
1Powered down
0Powered
1Powered down
0Powered
1Powered down
0Powered
1Powered down
0Powered
1Powered down
0Powered
1Powered down
3.5.30Device ID register
This device ID register is a read-only register and contains the part ID for each LPC1102
part. This register is also read by the ISP/IAP commands (Section 19.5.11
Table 36.Device ID register (DEVICE_ID, address 0x4004 83F4) bit d escription
Reset has four sources on the LPC1102: the RESET pin, Watchdog Reset, Power-On
Reset (POR), and Brown Out Detect (BOD). In addition, there is a software reset.
UM10429
Chapter 3: LPC1102 System configuration
The RESET
the operating voltage attains a usable level, starts the IRC causing reset to remain
asserted until the external Reset is de-asserted, the oscillator is running, and the flash
controller has completed its initialization.
On the assertion of a reset source external to the Cortex-M0 CPU (POR, BOD reset,
External reset, and Watchdog reset), the following processes are initiated:
1. The IRC starts up. After the IRC-start-up time (maximum of 6 μs on power-up), the
IRC provides a stable clock output.
2. The boot code in the ROM starts. The boot code per forms the boot tasks and may
jump to the flash.
3. The flash is powered up. This takes approximately 100 μs. Then the flash initialization
sequence is started, which takes about 250 cycles.
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.
3.7 Brown-out detection
The LPC1 10 2 includes four levels for m onitoring th e volta ge on the VDD pin. If this voltage
falls below one of the four selected levels, the BOD asserts an interrupt signal to the
NVIC. This signal can be enabled for interrupt in the Interr upt Enable Register in the NVIC
in order to cause a CPU interrupt; if not, software can monitor the signal by reading the
NVIC status register (see Table 44
cause a forced reset of the chip (see Table 26
pin is a Schmitt trigger input pin. Assertion of chip Reset by any source, once
). An additional four threshold levels can be selected to
).
3.8 Power management
The LPC1102 support a variety of power control features. In Active mode, when the chip
is running, power and clocks to selected peripherals can be optimized for power
consumption. In addition, there are three special modes of processor power reduction:
Sleep mode and Deep-sleep mode mode.
Remark: The Debug mode is not supported in Sleep or Deep-sleep mode.
3.8.1Active mode
In Active mode, the ARM Cortex-M0 core and memories are clocked by the syste m clock,
and peripherals are clocked by the system clock or a dedicated peripheral clock.
The chip is in Active mode after reset and the default power configuration is determined
by the reset values of the PDRUNCFG and SYSAHBCLKCTRL registers. The power
configuration can be changed during run time.
Power consumption in Active mode is determined by the following configuration choices:
• The SYSAHBCLKCTRL register controls which memories and peripherals are
• The power to various analog blocks (PLL, oscillators, the ADC, the BOD circuit, and
• The clock source for the system clock can be selected from the IRC (default), the
• The system clock frequency can be selected by the SYSPLLCTRL (Table 8) and the
• Selected peripherals (UART, SPI0, WDT) use individual peripheral clocks with their
3.8.2Sleep mode
UM10429
Chapter 3: LPC1102 System configuration
running (Table 19
the flash block) can be controlled at any time individually through the PDRUNCFG
register (Table 35
system oscillator, or the watchdog oscillator (see Figure 3
SYSAHBCLKDIV register (Table 18
own clock dividers. The peripheral clocks can be shut down through the
corresponding clock divider registers.
).
).
and related registers).
).
In Sleep mode, the system clock to the ARM Cortex-M0 core is stopped, an d execution o f
instructions is suspended until either a reset or an enabled interrupt occurs.
Peripheral functions, if selected to be clocked in the SYSAHBCLKCTRL regi ster, continue
operation during Sleep mode and may generate interrupts to cause the processor to
resume execution. Sleep mode eliminates dynamic power used by the processor itself,
memory systems and their related controllers, and internal buses. The processor sta te
and registers, peripheral registers, and int er na l SRAM va lue s ar e ma in tained, and th e
logic levels of the pins remain static.
3.8.2.1Power configuration in Sleep mode
Power consumption in Sleep mode is configured by the same settings as in Active mode:
• The clock remains running.
• The system clock frequency remains the same as in Active mode, but the processor is
not clocked.
• Analog and digital peripherals are selected as in Active mode.
3.8.2.2Programming Sleep mode
The following steps must be performed to enter Sleep mode:
1. The DPDEN bit in the PCON register must be set to zero (Table 41
2. The SLEEPDEEP bit in the ARM Cortex-M0 SCR register must be set to zero, see
(Table 225
3. Use the ARM Cortex-M0 Wait-For-Interrupt (WFI) instruction.
Sleep mode is exited automatically when an interrupt enabled by the NVIC arrives at the
processor or a reset occurs. After wake-up due to an in te rr upt, the micr ocontr olle r returns
to its original power configuration defined by the contents of the PDRUNCFG and the
SYSAHBCLKDIV registers. If a reset occurs, the microcontroller enters the default
configuration in Active mode.
3.8.3Deep-sleep mode
In Deep-sleep mode, the system clock to the processor is disabled as in Sleep mode. All
analog blocks are powered down, except for the BOD circuit and the watchdog oscillator,
which must be selected or deselected during Deep-sleep mode in the PDSLEEPCFG
register.
Deep-sleep mode eliminates all power used by the flash and analog peripherals and all
dynamic power used by the processor itself, memory systems and their related
controllers, and internal buses. The processor state and registers, peripheral registers,
and internal SRAM values are maintained, and the logic levels of the pins remain static.
UM10429
Chapter 3: LPC1102 System configuration
3.8.3.1Power configuration in Deep-sleep mode
Power consumption in Deep-sleep mode is determined by the Deep-sleep power
configuration setting in the PDSLEEPCFG (Table 33
• The only clock source available in Deep-sleep mode is the watchdog oscillator. The
watchdog oscillator can be left running in Deep-sleep mode if required for
timer-controlled wake-up (see Section 3.9.3
system oscillator) and the system PLL are shut down. The watchdog oscillator analog
output frequency must be set to the lowest value of its analog clock output (bits
FREQSEL in the WDTOSCCTRL = 0001, see Table 11
• The BOD circuit can be left running in Deep-slee p mode if r equir ed b y th e a pplication .
• If the watchdog oscillator is running in Deep-sleep mode, only the watchdog timer or
one of the general-purpose timers should be enabled in SYSAHBCLKCTRL register
to minimize power consumption.
3.8.3.2Programming Deep-sleep mode
The following steps must be performed to enter Deep-sleep mode:
1. The DPDEN bit in the PCON register must be set to zero (Table 41
2. Select the power configuration in Deep-sleep mode in the PDSLEEPCFG (Table 33
register.
a. If a timer-controlled wake-up is needed, ensure that the watchdog oscillator is
powered in the PDRUNCFG register and switch the clock source to WD oscillator
in the MAINCLKSEL register (Table 16
b. If no timer-controlled wake-up is needed and the watchdog oscillator is shut down,
ensure that the IRC is powered in the PDRUNCFG register and switch the clock
source to IRC in the MAINCLKSEL register (Table 16
system clock is shut down glitch-free.
3. Select the power configuration after wake-up in the PDAWAKECFG (Table 34
register.
4. If an external pin is used for wake-up, enable and clear the wake-up pin in the start
5. In the SYSAHBCLKCTRL register (Table 19
6. Write one to the SLEEPDEEP bit in the ARM Cortex-M0 SCR register (Table 225
7. Use the ARM WFI instruction.
3.8.3.3Wake-up from Deep-sleep mode
The microcontroller can wake up from Deep-sleep mode in the following ways:
• Signal on an external pin. For this purpose, pins PIO0_0, PIO0_8 to PIO0_11, and
• Input signal to the start logic created by a match event on one of the g ene ral pur po se
• Reset from the BOD circuit. In this case, the BOD circuit must be enabled in the
• Reset from the watchdog timer. In this case, the watchdog oscillator must be running
• A reset signal from the external RESET pin.
UM10429
Chapter 3: LPC1102 System configuration
logic registers (Table 28
counter/timer or WDT if needed.
PIO1_0 can be enabled as inputs to the start logic. The start logic does not require
any clocks and generates the interrupt if enabled in the NVIC to wake up from
Deep-sleep mode.
timer external match outputs. The pin holding the timer match function must be
enabled as start logic input in the NVIC, the corresponding timer must be enabled in
the SYSAHBCLKCTRL register, and the watchdog oscillator must be running in
Deep-sleep mode (for details see Section 3.9.3
PDSLEEPCFG register, and the BOD reset must be enabled in the BODCTRL
register (Table 26
in Deep-sleep mode (see PDSLEEPCFG register), and the WDT must be enabled in
the SYSAHBCLKCTRL register.
to Table 31), and enable the start logic interrupt in the NVIC.
), disable all peripherals except
).
).
).
Remark: If the watchdog oscillator is running in Deep-sleep mode, its frequency
determines the wake-up time causing the wake-up time to be longer than waking up with
the IRC.
3.9 Deep-sleep mode details
3.9.1IRC oscillator
The IRC is the only oscillator on the LPC1102 that can always shut down glitch-free.
Therefore it is recommended that the user switches the clock source to IRC before the
chip enters Deep-sleep mode.
3.9.2Start logic
The Deep-sleep mode is exited when the start logic indicates an interrupt to the ARM
core. The port pins PIO0_0 to PIO0_11 and PIO1_1 are connected to the start logic and
serve as wake-up pins. The user must program the start logic registers for each input to
set the appropriate edge polarity for the corresponding wake-up event. Furthermore, the
interrupts corresponding to each input must be enabled in the NVIC (see Section 3.5.23
The start logic does not require a clock to run because it uses the input signals on the
enabled pins to generate a clock edge when enabled. Therefore, the start logic signals
should be cleared (see Table 30
The start logic can also be used in Active mode to provide a vectored interrupt using the
LPC1102’s input pins.
3.9.3Using the general purpose counter/timers to create a self-wake-up
event
If enabled in Deep-sleep mode through the SYSAHBCLKCFG register, the counter/timers
can count clock cycles of the watchdog oscillator and create a match event when the
number of cycles equals a preset match value. The match event causes the
corresponding match output pin to go HIGH, LOW, or toggle. The state of the match
output pin is also monitored by the start logic and can trigger a wake- up interrupt if that pin
is enabled in the NVIC and the start logic trigger is configured accordingly in the start lo gic
edge control register (see Table 28
The following steps must be performed to configure the counter/timer and create a timed
Deep-sleep self-wake-up event:
UM10429
Chapter 3: LPC1102 System configuration
) before use.
).
1. Configure the port pin as match output in the IOCONFIG block. Select from pins
PIO0_8 to PIO0_11, which are inputs to the start logic and also hold a match output
function.
2. In the corresponding counter/timer, set the match value, and configure the match
output for the selected pin.
3. Select the watchdog oscillator to run in Deep-sleep mode in the PDSLEEPCFG
register.
4. Switch the clock source to the watchdog oscillator in the MAINCLKSEL register
(Table 16
5. Enable the pin, configure its edge detect function, and reset the start logic in the start
logic registers (Table 28
6. Disable all other peripherals in the SYSAHBCLKCTRL register.
7. Ensure that the DPDEN bit in the PCON register is set to zero (Table 41
8. Write one to the SLEEPDEEP bit in the ARM Cortex-M0 SCR register (Table 225
9. Start the counter/timer.
10. Use the ARM WFI instruction to enter Deep-sleep mode.
) and ensure the watchdog oscillator is powered in the PDRUNCFG register.
to Table 31), and enable the interrupt in the NVIC.
3.10 System PLL functional description
The LPC1102 uses the system PLL to create the clocks for the core and peripherals.
The block diagram of this PLL is shown in Figure 4. The input frequency range is 10 MHz
to 25 MHz. The input clock is fed directly to the Phase-Fr eque n cy Det ector (PFD). This
block compares the phase and frequency of its inputs, and generates a control signal
when phase and/ or frequency do not match. The loop filter filters these control signals
and drives the current controlled oscillator (CCO), which generates the main clock and
optionally two additional phases. The CCO frequency range is 156 MHz to
320 MHz.These clocks are either divided by 2×P by the programmable post divider to
create the output clock(s), or are sent directly to the output(s). The main output clock is
then divided by M by the programmable feedback divider to generate the feedback clock.
The output signal of the phase-frequency detector is a lso monitored by the lock detector,
to signal when the PLL has locked on to the input clock.
Remark: The divider values for P and M must be selected so that the PLL output clock
frequency FCLKOUT is lower than 100 MHz.
3.10.1Lock detector
The lock detector measures the phase difference between the rising edges of the input
and feedback clocks. Only when this difference is smaller than the so called “lock
criterion” for more than eight consecutive input clock periods, the lock output switches
from low to high. A single too large phase difference immediately resets the counter and
causes the lock signal to drop (if it was high). Requiring eig h t phas e measurements in a
row to be below a certain figure ensures that the lock detector will not indicate lock until
both the phase and frequency of the input and feedback clocks are very well aligned. This
effectively prevents false lock indications, and thus ensures a glitch free lock signal.
3.10.2Power-down control
To reduce the power consumption when the PLL clock is not needed, a Power-down
mode has been incorporated. This mode is enabled by setting the SYSPLL_PD bits to one
in the Power-down configuration register (Table 35
reference will be turned off, the oscillator and the phase-frequency detector will be
stopped and the dividers will enter a reset state. While in Power-down mode, the lock
output will be low to indicate that the PLL is not in lock. When the Power-down mode is
terminated by setting the SYSPLL_PD bits to zero, the PLL will resume its normal
operation and will make the lock signal high once it has regained lock on the input clock.
3.10.3Divider ratio programming
Post divider
The division ratio of the post divider is controlled by the PSEL bits. The division ratio is two
times the value of P selected by PSEL bits as shown in Table 8
output clock with a 50% duty cycle.
Feedback divider
The feedback divider’s division ratio is controlled by the MSEL bits. The division ratio
between the PLL ’s outp ut clock and the input clock is the decim al value on MSEL bits p lus
one, as specified in Table 8
Changing the divider values
Changing the divider ratio while the PLL is running is not recommended. As there is no
way to synchronize the change of the MSEL and PSEL values with the dividers, the risk
exists that the counter will read in an undefined value, which could lead to unwanted
spikes or drops in the frequency of the output clock. The recommended way of changing
between divider settings is to power down the PLL, ad just the divider settings and then le t
the PLL start up again.
UM10429
Chapter 3: LPC1102 System configuration
. This guarantees an
.
3.10.4Frequency selection
The PLL frequency equations use the following parameters (also see Figure 3):
Table 37.PLL frequency parameters
ParameterSystem PLL
FCLKINFrequency of sys_pllclkin (input clock to the system PLL) from the
SYSPLLCLKSEL multiplexer (see Section 3.5.9
FCCOFrequency of the Current Controlled Osci llator (CCO); 156 to 320 MHz.
FCLKOUTFrequency of sys_pllclkout
PSystem PLL post divider ratio; PSEL bits in SYSPLLCTRL (see Section 3.5.3
MSystem PLL feedback divider register; MSEL bits in SYSPLLCTRL (see
Section 3.5.3
3.10.4.1Normal mode
In normal mode the post divider is enabled, giving a 50% duty cycle clock with the
following frequency relations:
To select the appropriate values for M and P, it is recommended to follow these steps:
2. Calculate M to obtain the desired output frequency FCLKOUT with
3. Find a value so that FCCO = 2 × P × FCLKOUT.
4. Verify that all fr equencies and divider values conform to the limits specified in Table 8
5. Ensure that FCLKOUT < 100 MHz.
UM10429
Chapter 3: LPC1102 System configuration
M = FCLKOUT / FCLKIN.
.
Table 38
shows how to configure the PLL for a 12 MHz crystal oscillator using the
SYSPLLCTRL register (Table 8
system clock divider SYSAHBCLKDIV is set to one (see Table 18
In this mode, the internal current reference will be turned off, the oscillator and the
phase-frequency detector will be stopped and the dividers will enter a reset state. While in
Power-down mode, the lock output will be low, to indicate that the PLL is not in lock. When
the Power-down mode is terminated by setting the SYSPLL_PD bit to zero in the
Power-down configuration register (Table 35
and will make the lock signal HIGH once it has regained lock on the input clock.
3.11 Flash memory access
Main clock
(FCLKOUT)
). The main clock is equivalent to the system clock if the
).
MSEL bits
Table 8
M divider
value
PSEL bits
Table 8
P divider
value
FCCO
frequency
), the PLL will resume its normal operation
Depending on the system clock frequency, access to the flash memory can be configured
with various access times by writing to the FLASHCFG register at address 0x4003 C010.
This register is part of the flash configuration block (see Figure 2
).
Remark: Improper setting of this register may result in incorrect operation of th e LPC1102
flash memory.
The power control register provides the flags for active or Sleep/Deep- sleep modes.
Table 41.Power control register (PCON, address 0x4003 8000) bit description
BitSymbolValueDescriptionReset
0-Reserved. This bit must always be written as 0.0x0
1-Reserved. This bit must always be written as 0.0
7:2-Reserved. These bits must always be written as 0.0x0
8SLEEPFLAGSleep mode flag0
11:9-Reserved. These bits must always be written as 0.0x0
1 1-Reserved. This bit must always be written as 0.0x0
31:12-Reserved. Do not write ones to this bit.0x0
This chapter describes calls that applications can make to code that is included in on-chip
ROM to facilitate power management and clocking setup.
The following elements have to be defined in an application that uses the power profiles:
typedef struct _PWRD {
void (*set_pll)(unsigned int cmd[], unsigned int resp[]);
void (*set_power)(unsigned int cmd[], unsigned int resp[]);
} PWRD;
typedef struct _ROM {
const PWRD * pWRD;
} ROM;
ROM ** rom = (ROM **) 0x1FFF1FF8;
unsigned int command[4], result[2];
5.4 Clocking routine
5.4.1set_pll
This routine sets up the system PLL according to the calling arguments. If the expected
clock can be obtained by simply dividing the system PLL input, set_pll bypasses the PLL
to lower system power consumption.
IMPORTANT: Before this routine is invoked, the PLL clock source (IRC/system oscillator)
must be selected (Table 15
system PLL (Table 17
), the main clock source must be set to the input clock to the
) and the system/AHB clock divider must be set to 1 (Table 19).
set_pll attempts to find a PLL setup that matches the calling parameters. Once a
combination of a feedback divider value (SYSPLLCTRL, M), a post divider ratio
(SYSPLLCTRL, P) and the system/AHB clock divider (SYSAHBCLKDIV) is found, set_pll
applies the selected values and switches the main clock source selection to the system
PLL clock out (if necessary).
The routine returns a result code that indicates if the system PLL was successfully set
(PLL_CMD_SUCCESS) or not (in which case the result code identifies what went wrong).
The current system frequency value is also returned. The application should use this
information to adjust other clocks in the device (the SSP, UART, and WDT clocks, and/or
clockout).
5.4.1.1System PLL input frequency and expected system clock
set_pll looks for a setup in which the system PLL clock does not exceed 50 MHz. It easily
finds a solution when the ratio between the expected system clock and the system PLL
input frequency is an integer value, but it can also find solutions in other cases.
The system PLL input frequency (Param0) must be between 10000 to 25000 kHz (10
MHz to 25 MHz) inclusive. The expected system clock (Param1) must be between 1 and
50000 kHz inclusive. If either of these requirements is not met, set_pll returns
PLL_INV ALID_FREQ an d returns Param0 as Result1 since the PLL setting is unchanged.
5.4.1.2Mode
The first priority of set_pll is to find a setup that generates the system clock at exactly the
rate specified in Param1. If it is unlikely that an exact match can be found, input parameter
mode (Param2) should be used to specify if the actual system clock can be less than or
equal, greater than or equal or approximately the value specified as the expected system
clock (Param1).
A call specifying CPU_FREQ_EQU will only succeed if the PLL can output exactly the
frequency requested in Param1.
CPU_FREQ_LTE can be used if the requested frequency should not be exceeded (such
as overall current consumption and/or power budget reasons).
CPU_FREQ_GTE helps applications that need a minimum level of CPU processing
capabilities.
CPU_FREQ_APPROX results in a system clock that is as close as possible to the
requested value (it may be greater than or less than the requested value).
If an illegal mode is specified, set_pll returns PLL_INVALID_MODE. If the expected
system clock is out of the range supported by this routine, set_pll returns
PLL_FREQ_NOT_FOUND. In these cases the current PLL setting is not changed and
Param0 is returned as Result1.
5.4.1.3System PLL lock timeout
It should take no more than 100 μs for the system PLL to lock if a valid configuration is
selected. If Param3 is zero, set_pll will wait indefinitely for the PLL to lock. If a non-zero
value is provided, that is how many times the code will check for a successful PLL lock
event before it returns PLL_NOT_LOCKED. In this case the PLL settings are unchanged
and Param0 is returned as Result1.
UM10429
Chapter 5: LPC1102 Power profiles
Hint: setting Param3 equal to the system PLL frequency [Hz] divided by 10000 will
provide more than enough PLL lock-polling cycles.
5.4.1.4Code examples
The following examples illustrate some of the features of set_pll discussed above.
5.4.1.4.1Invalid frequency (device maximum clock rate exceeded)
The above code specifies a 12 MHz PLL input clock and a system clock of exactly
60 MHz. The application was ready to infinitely wait for the PLL to lock. But the expected
system clock of 60 MHz exceed s th e ma xim um of 50 MHz. Therefore set_pll returns
PLL_INV ALID_FREQ in result[0] an d 12000 in result[1] without changing the PLL settin gs.
5.4.1.4.2Invalid frequency selection (system clock divider restrictions)
The above code specifies a 12 MHz PLL input clock, a system clock of no more than 40
kHz and no timeout while waiting for the PLL to lock. Since the maximum divider value for
the system clock is 255 and running at 40 kHz would need a divide by value of 300, set_pll
returns PLL_INVALID_FREQ in result[0] and 12000 in result[1] without changing the PLL
settings.
The above code specifies a 12 MHz PLL input clock and a system clock of exactly
25 MHz. The application was ready to infinitely wait for the PLL to lock. Since there is no
valid PLL setup within earlier mentioned restrictions, set_pll returns
PLL_FREQ_NOT_FOUND in result[0] and 12000 in result[1] without changing the PLL
settings.
5.4.1.4.4System clock less than or equal to the expected value
The above code specifies a 12 MHz PLL input clock, a system clock of no more than
25 MHz and no locking timeout. set_pll returns PLL_CMD_SUCCESS in result[0] and
24000 in result[1]. The new system clock is 24 MHz.
5.4.1.4.5System clock greater than or equal to the expected value
The above code specifies a 12 MHz PLL input clock, a system clock of at least 25 MHz
and no locking timeout. set_pll returns PLL_CMD_SUCCESS in result[0] and 36000 in
result[1]. The new system clock is 36 MHz.
5.4.1.4.6System clock approximately equal to the expected value
This routine configures the device’s internal power control settings according to the calling
arguments. The goal is to reduce active power consumption while maint aining the feature
of interest to the application close to its optimum.
set_power returns a result code that reports if the power setting was successfully changed
or not.
EFFICIENCY, PWR_LOW_CURRENT)
Param2: current system clock (in MHz)
PWR_INVALID_MODE
5.5.1.1New system clock
The new system clock is the clock rate at which the microcontroller will be running after
either a successful execution of a clocking routine call or a similar code provided by the
user. This operan d must be an integer between 1 to 50 MHz inclusive. If a value out of this
range is supplied, set_power returns PWR_INVALID_FREQ and does not change the
power control system.
5.5.1.2Mode
The input parameter mode (Param1) specifies one of four available power settings. If an
illegal selection is provided, set_power returns PWR_INVALID_MODE and does not
change the power control system.
PWR_DEFAULT keeps the device in a baseline power setting similar to its reset state.
PWR_CPU_PERFORMANCE configures the microcontroller so that it can provide more
processing capability to the application. CPU performance is 30% better than the default
option.
PWR_EFFICIENCY setting was designed to find a balance between active current and
the CPU’s ability to execute code and process data. In this mode the device outperforms
the default mode both in terms of providing higher CPU performance and lowering active
current.
PWR_LOW_CURRENT is intended for those solutions that focus on lowering power
consumption rather than CPU performance.
5.5.1.3Current system clock
The current system clock is the clock rate at which the microcontroller is running when
set_power is called. This parameter is an integer between from 1 and 50 MHz inclusive.
The above setup would be used in a system running at 12 MHz attempting to switch to
55 MHz system clock, with a need for maximum CPU processing power. Since the
specified 55 MHz clock is above the 50 MHz maximum, set_power returns
PWR_INVALID_FREQ in result[0] without changing anything in the existing power setup.
The above code specifies that an application running at a system clock of 12 MHz will
switch to 24 MHz with emphasis on efficiency . set_power returns PWR_CMD_SUCCESS
in result[0] after configuring the microcontroller’s internal power control featur es.
The Nested Vectored Interrupt Controller (NVIC) is an integral part of the Cortex-M0. The
tight coupling to the CPU allows for low interrupt latency and efficient processing of late
arriving interrupts.
6.3 Features
• Nested Vectored Interrupt Controller that is an integral part of the ARM Cortex-M0
Table 44 lists the interrupt sources for each peripheral function. Each peripheral device
may have one or more interrupt lines to the Vectored Interrupt Controller. Each line may
represent more than one interrupt source. There is no significance or priority about what
line is connected where, except for certain standards from ARM.
See Section 19.5.2
Interrupts 0 to 12 are connected to a PIO input pin serving as wake-up pin from
Deep-sleep mode; Interrupt 0 to 11 correspond to PIO0_0 to PIO0_11 and interrupt 12
corresponds to PIO1_0; see Section 3.5.28
Table 44.Connection of interrupt sources to the Vectored Interrupt Controller
Table 44.Connection of interrupt sources to the Vectored Interrupt Controller
Exception
Number
15-Reserved
16CT16B0 Match 0 - 2
17CT16B1 Match 0 - 1
18CT32B0 Match 0 - 3
19CT32B1 Match 0 - 3
20SPI/SSP0Tx FIFO half empty
21UARTRx Line Status (RLS)
22-Reserved
23-Reserved
24ADCA/D Converter end of conversion
25WDTWatchdog interrupt (WDINT)
26BODBrown-out detect
27-Reserved
28-Reserved
29-Reserved
30PIO_1GPIO interrupt status of port 1
31PIO_0GPIO interrupt status of port 0
Vector
Offset
UM10429
Chapter 6: LPC1102 Interrupt controller
FunctionFlag(s)
Capture 0
Rx FIFO half full
Rx Timeout
Rx Overrun
Transmit Holding Register Empty (THRE)
Rx Data Available (RDA)
Character Time-out Indicator (CTI)
End of Auto-Baud (ABEO)
Auto-Baud Time-Out (ABTO)
The I/O configuration registers control the el ectrical characteristics of the pads. The
following features are programmable:
• pin function
• internal pull-up/pull-down resistor or bus keeper function
• hysteresis
• analog input or digital mode for pads hosting the ADC inputs
7.3 General description
The IOCON registers control the function (GPIO or peripheral function), the input mode,
and the hysteresis of all PIOn_m pins. If a pin is used as input pin for the ADC, an analog
input mode can be selected.
The FUNC bits in the IOCON registers can be set to GPIO (FUNC = 000) or to a
peripheral function. If the pins are GPIO pins, the GPIOnDIR registers determine whether
the pin is configured as an input or output (see Section 9.3.2
the pin direction is controlled automatically depending on the pin’s functionality. The
GPIOnDIR registers have no effect for peripheral functions.
). For any peripheral function,
The MODE bits in the IOCON register allow the selection of on-chip pull-up or pull-down
resistors for each pin or select the repeater mode.
The possible on-chip resistor configurations are pull-up ena bled, pull-down enable d, or no
pull-up/pull-down. The default value is pull-up enabled.
The repeater mode enables the pull-up resistor if the pin is at a logic HIGH and enables
the pull-down resistor if the pin is at a logic LOW. This causes the pin to retain its last
known state if it is configured as an input and is not driven externally. Repeater mode may
typically be used to prevent a pin from floating (and potentially using significant power if it
floats to an indeterminate state) if it is temporarily not driven.
The input buffer for digital functions can be configured with hysteresis or as pla i n bu ffer
through the IOCON registers (see the LPC1102 data sheet for details).
UM10429
Chapter 7: LPC1102 I/O Configuration
If the external pad supply voltage V
can be enabled or disabled. If V
is between 2.5 V and 3.6 V, the hysteresis buffer
DD
is below 2.5 V, the hysteresis buffer must be disabled
DD
to use the pin in input mode.
7.3.4A/D-mode
In A/D-mode, the digital receiver is disconnected to obtain an accurate input voltage for
analog-to-digital conversions. This mode can be selected in those IOCON registers that
control pins with an analog function. If A/D mode is selected, Hysteresis and Pin mode
settings have no effect.
For pins without analog functions, the A/D-mode setting has no effect.
7.4 Register description
The I/O configuration registers control the PIO port pins, the inputs and outputs of all
peripherals and functional blocks and the ADC input pins.
Each port pin PIOn_m has one IOCON register assigned to control the pin’s function and
electrical characteristics.
noI/OI; PUSWDIO — Serial wire debug input/output.
CT32B1_MAT2
[3]
PIO1_6/RXD/
C2
noI/OI; PUPIO1_6 — General purpose digital input/output pin.
CT32B0_MAT0
[3]
PIO1_7/TXD/
D1
noI/OI; PUPIO1_7 — General purpose digital input/output pin.
CT32B0_MAT1
V
DD
XTALINB2
V
SS
D2; A1 -I-3.3 V supply voltage to the internal regulator, the external rail,
[5]
-I-External clock input and input to internal clock generator circuits.
D3; B1 -I-Ground.
TypeReset
state
Description
[1]
I/O-PIO0_11 — General purpose digital input/output pin.
I-AD0 — A/D converter, input 0.
I-CT32B0_MAT3 — Match output 3 for 32-bit timer 0.
I/O-PIO1_0 — General purpose digital input/output pin.
I-AD1 — A/D converter, input 1.
I-CT32B1_CAP0 — Capture input 0 for 32-bit timer 1.
I/O-PIO1_1 — General purpose digital input/output pin.
I-AD2 — A/D converter, input 2.
O- CT32B1_MAT0 — Match output 0 for 32-bit timer 1.
I/O-PIO1_2 — General purpose digital input/output pin.
I-AD3 — A/D converter, input 3.
O- CT32B1_MAT1 — Match output 1 for 32-bit timer 1.
I/O-PIO1_3 — General purpose digital input/output pin.
I-AD4 — A/D converter, input 4.
O- CT32B1_MAT2 — Match output 2 for 32-bit timer 1.
I-RXD — Receiver input for UART.
O- CT32B0_MAT0 — Match output 0 for 32-bit timer 0.
O- TXD — Transmitter output for UART.
O- CT32B0_MAT1 — Match output 1 for 32-bit timer 0.
and the ADC. Also used as the ADC reference voltage.
Input voltage must not exceed 1.8 V.
[1] Pin state at reset for default function: I = Input; PU = internal pull-up enabled.
[2] This pin includes a 20 ns glitch filter. The pulse-width must be at least 50 ns to reset or wake up the chip.
[3] 5 V tolerant pad providing digital I/O functions with configurable pull-up/pull-down resistors and configurable hysteresis (see Figure 6
[4] 5 V tolerant pad providing digital I/O functions with configurable pull-up/pull-down resistors, configurable hysteresis, and analog input.
When configured as a ADC input, digital section of the pad is disabled and the pin is not 5 V tolerant (see Figure 6
[5] When the external clock is not used, connect XTALIN as follows: XTALIN can be left floating or can be grounded (grounding is preferred
LPC1102WLCSP16 PIO0_0; PIO0_8 to PIO0_11PIO1_0 to PIO1_3; PIO1_6 to
9.2 Introduction
port 2
--11
PIO1_7
Register bits corresponding to PIOn_m pins which are not available are reserved.
GPIO
port 3
To tal GPIO
pins
9.2.1Features
• GPIO pins can be configured as input or output by software.
• Each individual port pin can serve as an edge or level-sensitive interrupt request.
• Interrupts can be configured on single falling or rising edges and on both edges.
• Level-sensitive interrupt pins can be HIGH or LOW-active.
• All GPIO pins are inputs by default.
• Reading and writing of data registers are masked by address bits 13:2.
9.3 Register description
Each GPIO register can be up to 12 bits wide and can be read or written using word or
half-word operations at word addresses.
Table 60. Register overview: GPIO (base address port 0: 0x5000 0000; port 1: 0x5001 0000)
NameAccessAddress offsetDescriptionReset
GPIOnDATAR/W0x0000 to 0x3FF8Port n data address masking register
GPIOnDATAR/W0x3FFCPort n data register for pins PIOn_0 to
-- 0x4000 to 0x7FFCreservedGPIOnDIRR/W0x8000Data direction register for port n0x00
GPIOnISR/W0x8004Interrupt sense register for port n0x00
GPIOnIBER/W0x8008Interrupt both edges register for port n0x00
GPIOnIEVR/W0x800CInterrupt event register for port n0x00
GPIOnIER/W0x8010Interrupt mask register for port n0x00
GPIOnRISR0x8014Raw interrupt status register for port n0x00
Table 60. Register overview: GPIO (base address port 0: 0x5000 0000; port 1: 0x5001 0000)
NameAccessAddress offsetDescriptionReset
value
GPIOnMISR0x8018Masked interrupt status register for port n0x00
GPIOnICW0x801CInterrupt clear register for port n0x00
--0x8020 - 0xFFFFreserved0x00
9.3.1GPIO data register
The GPIOnDATA register holds the current logic state of the pin (HIGH or LOW),
independently of whether the pin is configured as an GPIO input or output or as another
digital function. If the pin is configured as GPIO output, the current value of the
GPIOnDATA register is driven to the pin.
Table 61.GPIOnDATA register (GPIO0DATA, address 0x5000 0000 to 0x5000 3FFC;
GPIO1DATA, address 0x5001 0000 to 0x5001 3FFC; GPIO2DATA, address 0x5002
0000 to 0x5002 3FFC; GPIO3DATA, address 0x5003 0000 to 0x5003 3FFC) bit
description
BitSymbolDescriptionReset
value
11:0DATALogic levels for pins PIOn_0 to PIOn_11. HIGH = 1, LOW = 0.n/aR/W
Access
31:12-Reserved--
A read of the GPIOnDATA register always returns the current logic level (state) of the pin
independently of its configuration. Because there is a single data r egister for both the
value of the output driver and the state of the pin’s input, write operations have different
effects depending on the pin’s configuration:
• If a pin is configured as GPIO input, a write to the GPIOnDATA register has no effect
on the pin level. A read returns the current state of the pin.
• If a pin is configured as GPIO output, the current value of GPIOnDATA register is
driven to the pin. This value can be a result of writing to the GPIOnDATA register, or it
can reflect the previous state of the pin if the pin is switched to GPIO output from
GPIO input or another digital function. A read returns the current state of the pin.
• If a pin is configured as another digital function (input or output), a write to the
GPIOnDA TA register has no effect on the pin level. A rea d returns the cu rrent st ate o f
the pin even if it is configured as an output. This means that by reading the
GPIOnDA TA register, the digital output or input value of a function other than GPIO on
that pin can be observed.
The following rules apply when the pins are switched from input to output:
• Pin is configured as input with a HIGH level applied:
– Change pin to output: pin drives HIGH level.
• Pin is configured as input with a LOW level applied:
– Change pin to output: pin drives LOW level.
The rules show that the pins mirror the current logic level. Therefore floating pins may
drive an unpredictable level when switched from input to output.
Bits set to HIGH in the GPIOnIE register allow the corresponding pins to trigger their
individual interrupts and the combined GPIOnINTR line. Clearing a bit disables interrupt
triggering on that pin.
T able 66. GPIOnIE register (GPIO0IE, address 0x5000 8010 to GPIO3IE, address 0x5003
BitSymbol DescriptionReset
11:0MASKSelects interrupt on pin x to be masked (x = 0 to 11).
31:12-Reserved--
9.3.7GPIO raw interrupt status register
Bits read HIGH in the GPIOnIRS register reflect the raw (prior to masking) interrupt status
of the corresponding pins indicating that all the requirements have been met before they
are allowed to trigger the GPIOIE. Bits read as zero indicate that the corresponding input
pins have not initiated an interrupt. The register is read-only.
T able 67.GPIOnIRS register (GPIO0IRS, address 0x5000 8014 to GPIO3IRS, address 0x5003
BitSymbol DescriptionReset
11:0RAWST Raw interrupt status (x = 0 to 11).
31:12-Reserved--
UM10429
Chapter 9: LPC1102 General Purpose I/O (GPIO)
8010) bit description
Access
value
0x00R/W
0 = Interrupt on pin PIOn_x is masked.
1 = Interrupt on pin PIOn_x is not masked.
8014) bit description
Access
value
0x00R
0 = No interrupt on pin PIOn_x.
1 = Interrupt requirements met on PIOn_x.
9.3.8GPIO masked interrupt status register
Bits read HIGH in the GPIOnMIS register reflect the status of the input lines triggering an
interrupt. Bits read as LOW indicate that either no interrupt on the corresponding input
pins has been generated or that the interrupt is masked. GPIOMIS is the state of the
interrupt after masking. The register is read-only.
Table 68.GPIOnMIS register (GPIO0MIS, address 0x5000 8018 to GPIO3MIS, address
0x5003 8018) bit description
BitSymbol DescriptionReset
value
11:0MASKSelects interrupt on pin x to be masked (x = 0 to 11).
0 = No interrupt or interrupt masked on pin PIOn_x.
1 = Interrupt on PIOn_x.
31:12-Reserved--
0x00R
Access
9.3.9GPIO interrupt clear register
This register allows software to clear edge detection for port bits that are identified as
edge-sensitive in the Interrupt Sense register. This register has no effect on port bits
identified as level-sensitive.
11:0CLRSelects interrupt on pin x to be cleared (x = 0 to 11). Clears
31:12-Reserved--
9.4 Functional description
9.4.1Write/read data operation
UM10429
Chapter 9: LPC1102 General Purpose I/O (GPIO)
Access
value
0x00W
the interrupt edge detection logic. This register is write-only.
Remark: The synchronizer between the GPIO and the
NVIC blocks causes a delay of 2 clocks. It is recommended
to add two NOPs after the clear of the interrupt edge
detection logic before the exit of the interrupt service
routine.
0 = No effect.
1 = Clears edge detection logic for pin PIOn_x.
In order for software to be able to set GPIO bits without affecting any other pins in a single
write operation, bits [13:2] of a 14-bit wide address bus are used to create a 12-bit wide
mask for write and read operations on the 12 GPIO pins for each port. Only GPIOnDATA
bits masked by 1 are affected by read and write operations. The masked GP IO nDATA
register can be located anywhere between address offsets 0x0000 to 0x3FFC in the
GPIOn address space. Reading and writing to the GPIOnDATA register at address
0x3FFC sets all masking bits to 1.
Write operation
If the address bit (i+2) associated with the GPIO port bit i (i = 0 to 11) to be written is
HIGH, the value of the GPIODA TA register bit i is updated. If the address bit (i+2) is LOW,
the corresponding GPIODATA register bit i is left unchanged.
Fig 8.Masked write operation to the GPIODATA register
Page 68
NXP Semiconductors
000000110001
111111100100
000000100000
1312111098765432
00
ADDRESS[13:2]
address 0x0C4
port pin settings
data read
Read operation
If the address bit associated with the GPIO data bit is HIGH, the valu e is read. If the
address bit is LOW, the GPIO data bit is read as 0. Reading a port DATA register yields
the state of port pins 11:0 ANDed with address bits 13:2.
The UART block is implemented on the LPC1101 without modem control.
10.2 Basic configuration
The UART is configured using the following registers:
1. Pins: The UART pins must be configured in the IOCONFIG register block
(Section 7.4.1
2. Power: In the SYSAHBCLKCTRL register, set bit 12 (Table 19
3. Peripheral clock: Enable the UART peripheral clock by writing to the UARTCLKDIV
register (Table 21
) before the UART clocks can be enabled.
).
).
10.3 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 baud rate generator.
• UART allows for implementation of either software or h ardware flow control.
• RS-485/EIA-485 9-bit mode support with output enable.
10.4 Pin description
Table 70.UART pin description
PinTypeDescription
RXDInputSerial Input. Serial receive data.
TXDOutput Serial Output. Serial transmit data.
10.5 Register description
The UART contains registers organized as shown in Table 71. The Divisor Latc h Acce ss
Bit (DLAB) is contained in U0LCR[7] and enables access to the Diviso r Latches.
U0RBRRO0x000 Receiver Buffer Register. Contains the next received character to be read.
U0THRWO0x000 Transmit Holding Register. The next character to be transmitted is written
U0DLLR/W0x000Divisor Latch LSB. Least significant byte of the baud rate divisor value. The
U0DLMR/W0x004 Divisor Latch MSB. Most significant byte of the baud rate divisor value. The
U0IERR/W0x004 In terrupt Enable Register. Contains individual interrupt enable bits for the 7
U0IIRRO0x008Interrupt ID Register. Identifies which interrupt(s) are pending.0x01
U0FCRWO0x008FIFO Control Register. Controls UART FIFO usage and modes.0x00
U0LCRR/W0x00CLine Control Register. Contains controls for frame formatting and break
--0x010Reserved U0LSRRO0x014Line Status Register. Contains flags for transmit and receive status,
--0x018Reserved U0SCRR/W0x01CScratch Pad Register. Eight-bit temporary storage for software.0x00
U0ACRR/W0x020Auto-baud Control Register. Contains controls for the auto-baud feature.0x00
--0x024Reserved U0FDRR/W0x028Fractional Divider Register. Generates a clock input for the baud rate
--0x02CReservedU0TERR/W0x030T ransmit Enable Register. Turns off UART transmitter for use with software
--0x034 -
U0RS485CTRL R/W0x04CRS-485/EIA-485 Control. Contains controls to configure various aspects of
U0ADRMATCH R/W0x050RS-485/EIA-485 address match. Contains the address match value for
offset
0x048
DescriptionReset
value
NA
(DLAB=0)
NA
here. (DLAB=0)
0x01
full divisor is used to generate a baud rate from the fractional rate divider.
(DLAB=1)
0x00
full divisor is used to generate a baud rate from the fractional rate divider.
(DLAB=1)
0x00
potential UART interrupts. (DLAB=0)
0x00
generation.
0x60
including line errors.
0x10
divider.
0x80
flow control.
Reserved-
0x00
RS-485/EIA-485 modes.
0x00
RS-485/EIA-485 mode.
[1] Reset Value reflects the data stored in used bits only. It does not include reserved bits content.
The U0RBR is the top byte of the UART RX FIFO. The top byte of the RX FIFO contai ns
the oldest character received and can be read via the bus interface. The LSB (bit 0)
represents the “oldest” received data bit. If the character received is less than 8 bits, the
unused MSBs are padded with zeroes.
The Divisor Latch Access Bit (DLAB) in U0LCR must be zero in order to access the
U0RBR. The U0RBR is always Read Only.
) 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 the n to read a byte from the U0RBR.
The U0THR is the top byte of the UART TX FIFO. The top byte is the newest character in
the TX FIFO and can be written via the bus interface. The LSB represents the first bit to
transmit.
The Divisor Latch Access Bit (DLAB) in U0LCR must be zero in order to access the
U0THR. The U0THR is always Write Only.
7:0THRWriting to the UART Transmit Holding Register causes the data
to be stored in the UART transmit FIFO. The byte will be sent
when it reaches the bottom of the FIFO and the transmitter is
available.
31:8 -Reserved-
undefined
NA
10.5.3UART Divisor Latch LSB and MSB Registers (DLAB = 1)
The UART Divisor Latch is part of the UART Baud Rate Generator and holds the value
used, along with the Fractional Divider, to divide the UART_PCLK clock in order to
produce the baud rate clock, which must be 16x the desired baud rate. 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 UART Divisor Latches. Details on
how to select the right value for U0DLL and U0DLM can be found in Section 10.5.13
U0IIR provides a status code that denotes the priority and source of a pending interrupt.
The interrupts are frozen during a U0IIR access. If an interrupt occurs during a U0IIR
access, the interrupt is recorded for the next U0IIR access.
0At least one interrupt is pending.
1No interrupt is pending.
0x31 - Receive Line Status (RLS).
0x22a - Receive Data Available (RDA).
0x62b - Character Time-out Indicator (CTI).
0x13 - THRE Interrupt.
UM10429
value
NA
bits. The value read from a reserved bit is not defined.
value
1
pending interrupt can be determined by evaluating
U0IIR[3:1].
0
corresponding to the UART Rx FIFO. All other combinations
of U0IER[3:1] not listed below are reserved (000,
100,101,111).
NA
bits. The value read from a reserved bit is not defined.
0
successfully and interrupt is enabled.
0
out and interrupt is enabled.
NA
bits. The value read from a reserved bit is not defined.
Bits U0IIR[9:8] are set by the auto-baud function and signal a time- out or end of auto-baud
condition. The auto-baud interrupt conditions are cleared by settin g the corresponding
Clear bits in the Auto-baud Control Register.
If the IntStatus bit is one and no interrupt is pending and the IntId bits will be zero. If the
IntStatus is 0, a non auto- baud inte rrupt is pending in which case the IntId bits iden tify the
type of interrupt and handling as described in Table 78
interrupt handler routine can determine the cause of the interrupt and how to clear the
active interrupt. The U0IIR must be read in order to clear the interrupt prior to exiting the
Interrupt Service Routine.
The UART RLS interrupt (U0IIR[3:1] = 011) is the highest priority interrupt and is set
whenever any one of four error conditions occur on the UART RX input: overrun error
(OE), parity error (PE), framing error (FE) and break interrupt (BI). The UART Rx error
condition that set the interrupt can be observed via U0LSR[4:1]. The interrupt is cleared
upon a U0LSR read.
The UART 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 UART Rx FIFO reaches the
trigger level defined in U0FCR7:6 and is reset when the UART Rx FIFO depth falls be low
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 UART
Rx FIFO contains at least one character and no UART Rx FIFO activity has occurred in
3.5 to 4.5 character times. Any UART Rx FIFO activity (read or write of UART RSR) will
clear the interrupt. This interrupt is intended to flush the UART 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 r emaining
5 characters.
Rx data available or trigger level reached in FIFO
(U0FCR0=1)
Minimum of one character in the RX FIFO and no
character input or removed during a time period
depending on how many characters are in FIFO
and what the trigger level is set at (3.5 to 4.5
character times).
The exact time will be:
[(word length) × 7 - 2] × 8 + [(trigger level - numb er
of characters) × 8 + 1] RCLKs
[2]
reset
U0RBR
[3]
or
Read
UART FIFO
drops below
trigger level
U0RBR
[3]
Read
U0IIR
[4]
Read
(if
source of
interrupt) or
THR write
[1] Values “0000”, “0011”, “0101”, “0111”, “1000”, “1001”, “1010”, “1011”,”1101”,”1110”,”1111” are reserved.
[2] For details see Section 10.5.8 “
[3] For details see Section 10.5.1 “UART Receiver Buffer Register ( DLAB = 0, Read Only)”
[4] For details see Section 10.5.5 “UART Interrupt Identification Register (U0IIR - 0x4004 8008, Read Only)”
The UART THRE interrupt (U0IIR[3:1] = 001) is a third level interrupt and is activated
when the UART THR FIFO is empty provided certain initialization conditions have been
met. These initialization conditions are intended to give the UART THR FIFO a chance to
fill up with data to eliminate many THRE interrupts from occurring at system start-up. The
initialization conditions implement a one character delay minus the stop bit whenever
THRE = 1 and there have not been at least two characters in the U0THR at one time
since the last THRE = 1 event. This delay is provided to give the CPU time to write data to
U0THR without a THRE interrupt to decode and service. A THRE interrupt is set
immediately if the UART 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).
10.5.6UART FIFO Control Register (Write Only)
The U0FCR controls the operation of the UART RX and TX FIFOs.
0Parity error status is inactive.
1Parity error status is active.
0F raming error status is inactive.
1F raming error status is active.
0Break interrupt status is inactive.
1Break interrupt status is active.
0U0THR contains valid data.
1U0THR is empty.
0U0THR and/or the U0TSR contains valid data.
1U0THR and the U0TSR are empty.
UM10429
…continued
Value
0
When the parity bit of a received character is in the wrong state,
a parity error occurs. A 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 UART RBR FIFO.
0
When the stop bit of a received character is a logic 0, a framing
error occurs. A 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
re-synchronize 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 UART RBR FIFO.
0
When RXD1 is held in the spacing state (all zeros) for one full
character transmission (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
ones). A 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 UART RBR FIFO.
1
THRE is set immediately upon detection of an empty UART
THR and is cleared on a U0THR write.
1
TEMT is set when both U0THR and U0TSR are empty; TEMT is
cleared when either the U0TSR or the U0THR contain valid
data.
Table 81.UART Line Status Register (U0LSR - address 0x4000 8014, Read Only) bit
Bit SymbolValue DescriptionReset
7RXFEError in RX FIFO
31:8--Reserved-
10.5.9UART Scratch Pad Register
The U0SCR has no effect on the UART operation . This register can be written and/or read
at user’s discretion. There is no provision in the interrupt interface that would indicate to
the host that a read or write of the U0SCR has occurred.
Table 82.UART Scratch Pad Register (U0SCR - address 0x4000 8014) bit description
Bit Symbol DescriptionReset Value
7:0 PadA readable, writable byte.0x00
31:8-Reserved-
0
U0LSR[7] is set when a character with a RX error such as
framing error, parity error or break interrupt, is loaded into the
U0RBR. This bit is cleared when the U0LSR register is read
and there are no subsequent errors in the UART FIFO.
0U0RBR contains no UART RX errors or U0FCR[0]=0.
1UART RBR contains at least one UART RX error.
10.5.10UART Auto-baud Control Register
The UART Auto-baud Control Register (U0ACR) controls the process of measuring the
incoming clock/data rate for the baud rate generation and can be read and written at
user’s discretion.
Table 83.Auto-baud Control Register (U0ACR - address 0x4000 8020) bit description
BitSymbolValue DescriptionReset value
0StartThis bit is automatically cleared after auto-baud
completion.
0Auto-baud stop (auto-baud is not running).
1Auto-baud start (auto-baud is running). Auto-baud run
bit. This bit is automatically cleared after auto-baud
completion.
1ModeAuto-baud mode select bit.0
0Mode 0.
1Mode 1.
2AutoRestartRestart select.0
0No restart
1Restart in case of time-out (counter restarts at next
UART Rx falling edge)
7:3-NAReserved, user software should not write ones to
reserved bits. The value read from a reserved bit is not
Table 83.Auto-baud Control Register (U0ACR - address 0x4000 8020) bit description
BitSymbolValue DescriptionReset value
8ABEOIntClrEnd of auto-baud interrupt clear bit (write only
9ABTOIntClrAuto-baud time-out interrupt clear bit (write only
31:10 -NAReserved, user software should not write ones to
10.5.11Auto-baud
The UART auto-baud function can be used to meas ure the incoming baud rate based on
the ”A T" 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.
accessible).
0Writing a 0 has no impact.
1Writing a 1 will clear the corresponding interrupt in the
U0IIR.
0
accessible).
0Writing a 0 has no impact.
1Writing a 1 will clear the corresponding interrupt in the
U0IIR.
0
reserved bits. The value read from a reserved bit is not
defined.
Auto-baud is started by setting the U0ACR S tart bit. Auto-bau d 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 subse quent falling edges of the
UART 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 UART 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 UART Rx pin.
The auto-baud function can generate two interrupts.
• The U0IIR ABTOInt interrupt will get set if the interrupt is enabled (U0IER ABToIntEn
is set and the auto-baud rate measurement counter overflow s).
• The U0IIR ABEOInt interrupt will get set if the interrupt is enabled (U0IER ABEOIntEn
is set and the auto-baud has completed successfully).
The auto-baud interrupts have to be cleared by setting the corresponding U0ACR
ABTOIntClr and ABEOIntEn bits.
The fractional baud rate generator must be disabled (DIVADDVAL = 0) during auto-baud.
Also, when auto-baud is used, any write to U0DLM and U0DLL registers should be done
before U0ACR register write. The minimum and the maximum baud rates supported by
UART are function of UART_PCLK, number of data bits, stop bits and parity bits.
When the software is expecting an ”AT" command, it configures the UART with the
expected character format and sets the U0ACR Start bit. The initial values in the divisor
latches U0DLM and U0DLM don‘t care. Because of the ”A" or ”a" ASCII coding
(”A" = 0x41, ”a" = 0x61), the UART Rx pin sensed start bit and the LSB of the expected
character are delimited by two falling edges. When the U0ACR Start bit is set, the
auto-baud protocol will execute the following phases:
1. On U0ACR Start bit setting, the baud rate measurement counter is reset and the
2. A falling edge on UART Rx pin triggers the beginning of the start bit. The rate
3. During the receipt of the start bit, 16 pulses are generated on the RSR baud input with
4. During the receipt of the start bit (and the character LSB for Mode = 0), the rate
5. If Mode = 0, the rate counter will stop on next falling edge of the UART Rx pin. If
6. The rate counter is loaded into U0DLM/U0DLL and the baud rate will be switched to
UART U0RSR is reset. The U0RSR baud rate is switched to the highest rate.
measuring counter will start counting UART_PCLK cycles.
the frequency of the UART input clock, guaranteeing the start bit is stored in the
U0RSR.
counter will continue incrementing with the pre-scaled UART input clock
(UART_PCLK).
Mode = 1, the rate counter will stop on the next rising edge of the UART Rx pin.
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.
The UART Fractional Divider Register (U0FDR) controls the clock pre-scaler for th e baud
rate generation and can be read and written at the user’s discretion. This pre-scaler takes
the APB clock and generates an output clock according to the specified fractional
requirements.
Important: If the fractional divider is active (DIVADDVAL > 0) and DLM = 0, the value of
the DLL register must be 3 or greater.
3:0DIVADDVAL Baud rate ge neration pre-scaler divisor value. If this field is 0,
7:4MUL VALBaud rate pre-scaler multiplier value. This field must be greater or
31:8 -Reserved, user software should not write ones to reserved bits.
This register controls the clock pre-scaler for the baud rate generation. The r eset va lue of
the register keeps the fractional capabilities of UART disabled making sure that UART is
fully software and hardware compatible with UARTs not equipped with this feature.
fractional baud rate generator will not impact the UART baud rate.
1
equal 1 for UART to operate properly, regardless of whether the
fractional baud rate generator is used or not.
0
The value read from a reserved bit is not defined.
(3)
Where UART_PCLK is the peripheral clock, U0DLM and U0DLL are the s tandard UART
baud rate divider registers, and DIVADDVAL and MULVAL are UART fractional baud rate
generator specific parameters.
The value of MULVAL and DIVADDVAL should comply to the following conditions:
1. 1 ≤ MULVAL ≤ 15
2. 0 ≤ DIVADDVAL ≤ 14
3. DIVADDVAL< MULVAL
The value of the U0FDR should not be modified while transmitting/receiving data or data
may be lost or corrupted.
If the U0FDR register value does not comply to these two requests, then the fractional
divider output is undefined. If DIV ADDVAL is zero then the fractional divider is disabled,
and the clock will not be divided.
10.5.13.1Baud rate calculation
UART can operate with or without using the Fractional Divider. In real-life applications it is
likely that the desired baud rate can be ach ieved using sever al dif ferent Fraction al Divider
settings. The following algorithm illustrates one way of finding a set of DLM, DLL,
MULVAL, and DIVADDVAL values. Such set of parameters yields a baud rate with a
relative error of less than 1.1% from the desired one.
is not an integer number and the next step is to estimate the FR
est
parameter. Using an initial estimate of FR
is recalculated as FR
= 1.628. Since FRest = 1.628 is within the specified range of 1.1
est
= PCLK/(16 x BR) = 12 MHz / (16 x 115200) =
est
= 1.5 a new DL
est
and 1.9, DIVADDVAL and MULVAL values can be obtained from the attached look-up
table.
The closest value for FRest = 1.628 in the look-up Table 85
to DIVADDVAL = 5 and MULVAL = 8.
Based on these findings, the suggested UART setup would be: DLM = 0, DLL = 4,
DIVADDVAL = 5, and MULVAL = 8. According to Equation 3
115384. This rate has a relative error of 0.16% from the originally specified 115200.
10.5.14UART Transmit Enable Register
In addition to being equipped with full hardware flow control (auto-cts and auto-rts
mechanisms described above), U0TER enables implementation of software flow control.
When TxEn = 1, UART transmitter will keep sending data as long as they are available. As
soon as TxEn becomes 0, UART transmission will stop.
Although Table 86 describes how to use TxEn bit in order to ach ieve hardware flow
control, it is strongly suggested to let UART hardware implemented auto flow control
features take care of this, and limit the scope of TxEn to software flow control.
6:0-Reserved, user software should not write ones to reserved bits.
7TXENWhen this bit is 1, as it is after a Reset, data written to the THR
31:8 -Reserved-
describes how to use TXEn bit in order to achieve software flow control.
The value read from a reserved bit is not defined.
is output on the TXD pin as soon as any preceding data has
been sent. If this bit cleared to 0 while a character is being sent,
the transmission of that character is completed, but no further
characters are sent until this bit is set again. In other words, a 0
in this bit blocks the transfer of characters from the THR or TX
FIFO into the transmit shift register. Software can clear this bit
when it detects that the a hardware-handshaking TX-permit
signal (CTS
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.
) has gone false, or with software handshaking,
10.5.15UART RS485 Control register
The U0RS485CTRL register controls the config u ratio n of the UART in RS-485/EIA-485
mode.
Table 87.UART RS485 Control register (U0RS485CTRL - address 0x4000 804C) bit
description
BitSymbolValueDescriptionReset
0NMMENRS-485/EIA-485 mode0
0RS-485/EIA-485 Normal Multidrop Mode (NMM)
is disabled.
1RS-485/EIA-485 Normal Multidrop Mode (NMM)
is enabled. In this mode, an address is detected
when a received byte causes the UART to set the
parity error and generate an interrupt.
1RXDISReceiver enable/disable0
0The receiver is enabled.
1The receiver is disabled.
2AADENAuto Address Detect (AAD) enable/disab le0
0Auto Address Detect (AAD) is disabled.
1Auto Address Detect (AAD) is enabled.
31:3 --Reserved, user software should not write ones to
reserved bits. The value read from a reserved bit
is not defined.
10.5.16UART RS-485 Address Match register (U0RS485ADRMATCH - 0x4000
8050)
The U0RS485ADRMA TCH register cont ains the address match value for RS-485/EIA-485
mode.
Table 88.UART RS-485 Address Match register (U0RS485ADRMATCH - address
BitSymbolDescriptionR eset value
7:0ADRMATCH C ontains the address match value.0x 00
31:8-Reserved-
10.5.17RS-485/EIA-485 modes of operation
The RS-485/EIA-485 feature allows the UART to be config ured as an addressable slave.
The addressable slave is one of multiple slaves controlled by a single master.
The UART master transmitter will identify an address character by setting the parity (9th)
bit to ‘1’. For data characters, the parity bit is set to ‘0’.
Each UART slave receiver can be assigned a unique address. The slave can be
programmed to either manually or automatically reject data following an address which is
not theirs.
RS-485/EIA-485 Normal Multidrop Mode (NMM)
Setting the RS485CTRL bit 0 enables this mode. In this mode, an address is detected
when a received byte causes the UART to set the parity error and generate an interrupt.
If the receiver is disabled (RS485CTRL bit 1 = ‘1’), any received data bytes will be ignored
and will not be stored in the RXFIFO. When an address byte is detected (parity bit = ‘1’) it
will be placed into the RXFIFO and an Rx Data Ready Interrupt will be generated. The
processor can then read the address byte and decide whether or not to enable the
receiver to accept the following data.
While the receiver is enabled (RS485CTRL bit 1 =’0’), all received bytes will be accepted
and stored in the RXFIFO regardless of whether they are data or address. When an
address character is received a parity error interrupt will be generated and the processor
can decide whether or not to disable the receiver.
RS-485/EIA-485 Auto Address Detection (AAD) mode
When both RS485CTRL register bits 0 (9-bit mode enable) and 2 (AAD mo de enable) are
set, the UART is in auto address detect mode.
In this mode, the receiver will compare any address byte received (parity = ‘1’) to the 8-bit
value programmed into the RS485ADRMATCH register.
If the receiver is disabled (RS485CTRL bit 1 = ‘1’), any received byte will be discarded if it
is either a data byte OR an address byte which fails to match the RS485ADRMATCH
value.
When a matching address character is detected it will be pushed onto the RXFIFO along
with the parity bit, and the receiver will be automatically enabled (RS485CTRL bit 1 will be
cleared by hardware). The receiver will also generate an Rx Data Ready Interrupt.
While the receiver is enabled (RS485CTRL bit 1 = ‘0’), all bytes received will be accepted
and stored in the RXFIFO until an address byte which does not match the
RS485ADRMA TCH value is received. When this occurs, the receiver will be automatically
disabled in hardware (RS485CTRL bit 1 will be set), The received non-matching address
character will not be stored in the RXFIFO.
10.6 Architecture
The architecture of the UART is shown below in the block diagram.
The APB interface provides a communications link between the CPU or host and the
UART.
The UART receiver block, U0RX, monitors the serial input line, RXD, for valid input. The
UART RX Shift Register (U0RSR) accepts valid characters via RXD. After a valid
character is assembled in the U0RSR, it is passed to the UART RX Buffer Register FIFO
to await access by the CPU or host via the generic host interface.
The UART transmitter block, U0TX, accepts data written by the CPU or host and buffers
the data in the UART TX Holding Register FIFO (U0THR). The UART TX Shift Register
(U0TSR) reads the data stored in the U0THR and assembles the data to transmit via the
serial output pin, TXD1.
The UART Baud Rate Generator block, U0BRG, generates the timing enables used by the
UART TX block. The U0BRG clock input source is UART_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 interrup t 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.
The LPC1102 includes one SPI interface.
Remark: The SPI block includes the full SSP feature set, and all register names use the
SSP prefix.
11.2 Basic configuration
The SPI0 is configured using the following registers:
1. Pins: The SPI pins must be configured in the IOCONFIG register block.
2. Power: In the SYSAHBCLKCTRL register, set bit 11 (Table 19
3. Peripheral clock: Enable the SPI0 peripheral clock by writing to the SSP0CLKDIV
register (Section 3.5.15
4. Reset: Before accessing the SPI block, ensure that the SSP_RST_N bits (bit 0) in the
PRESETCTRL register (Table 7
blocks.
).
).
) is set to 1. This de-asserts the reset signal to the SPI
Remark: Care must be taken when using the SPI because the SPI clock SCK and the
serial wire debug clock SWCLK share the same pin on the WLCSP16 package. Once the
SPI is enabled, the serial wire debugger is no longer available.
11.3 Features
• Compatible with Motorola SPI, 4-wire TI SSI, and National Semiconductor Microwire
buses.
• Synchronous Serial Communication.
• Supports master or slave operation.
• Eight-frame FIFOs for both transmit and receive.
• 4-bit to 16-bit frame.
11.4 General description
The SPI/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 bits 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.
SCK0/1I/OSCKCLKSKSerial Clock. SCK/CLK/SK is a clock signal used
SSEL0I/OSSEL FSCSFrame Sync/Slave Select. When the SPI/SSP
MISO0I/OMISO DR(M)
MOSI0I/OMOSI DX(M)
Interface pin
name/function
Type
SPISSIMicrowire
DX(S)
DR(S)
SI(M)
SO(S)
SO(M)
SI(S)
UM10429
Chapter 11: LPC1102 SPI0 with SSP
Pin description
to synchronize the transfer of data. It is driven by
the master and received by the slave. When
SPI/SSP interface is used, the clock is
programmable to be active-high or acti ve-low,
otherwise it is always active-high. SCK only
switches during a data transfer. Any other time, the
SPI/SSP interface either holds it in its inactive state
or does not drive it (leaves it in high-impedance
state).
interface is a bus master, it drives this signal to an
active state before the start of serial data and then
releases it to an inactive state after the data has
been sent.The active state of this signal can be
high or low depending upon the selected bus and
mode. When the SPI/SSP interface is a bus slave,
this signal qualifies the presence of data from the
Master according to the protocol in use.
When there is just one bus master and one bus
slave, the Frame Sync or Slave Select signal from
the Master can be connected directly to the slave’s
corresponding input. When there is more than one
slave on the bus, further qualification of their Frame
Select/Slave Select inputs will typically be
necessary to prevent more than one slave from
responding to a transfer.
Master In Slave Out. The MISO signal transfers
serial data from the slave to the master. When the
SPI/SSP is a slave, serial data is output on this
signal. When the SPI/SSP is a master, it clocks in
serial data from this signal. When the SPI/SSP is a
slave and is not selected by FS/SSEL, it does not
drive this signal (leaves it in high-impedance state).
Master Out Slave In. The MOSI signal transfers
serial data from the master to the slave. When the
SPI/SSP is a master, it outputs serial data on this
signal. When the SPI/SSP is a slave, it clocks in
serial data from this signal.
Remark: Care must be taken when using the SPI because the SPI clock SCK and the
serial wire debug clock SWCLK share the same pin on the WLCSP16 package. Once the
SPI is enabled, the serial wire debugger is no longer available.
11.6 Register description
The register addresses of the SPI controllers are shown in Table 90.
SSP0CR0R/W 0x000Control Register 0. Selects the serial clock rate, bus type, and data size. 0
SSP0CR1R/W 0x004Control Register 1. Selects master/slave and other modes.0
SSP0DRR/W0x008Data Register. Writes fill the transmit FIFO, and reads empty the receive
SSP0SRRO0x00CStatus Register0x0000
SSP0CPSRR/W0x010Clock Prescale Register0
SSP0IMSCR/W0x014Interrupt Mask Set and Clear Register0
SSP0RISRO0x018Raw Interrupt Status Register0x0000
SSP0MISRO0x01CMasked Interrupt Status Register0
SSP0ICRWO0x020SSPICR Interrupt Clear RegisterNA
offset
DescriptionReset
Value
0
FIFO.
0003
0008
[1]
[1] Reset Value reflects the data stored in used bits only. It does not include reserved bits content.
11.6.1 SPI/SSP Control Register 0
This register controls the basic operation of the SPI/SSP controller.
Table 91: SPI/SSP Control Register 0 (SSP0CR0 - address 0x4004 0000) bit description
BitSymbol ValueDescriptionReset
3:0DSSData Size Select. This field controls the number of bits
transferred in each frame. Values 0000 to 0010 are not
supported and should not be used.
0x34-bit transfer
0x45-bit transfer
0x56-bit transfer
0x67-bit transfer
0x78-bit transfer
0x89-bit transfer
0x910-bit transfer
0xA11-bit transfer
0xB12-bit transfer
0xC13-bit transfer
0xD14-bit transfer
0xE15-bit transfer
0xF16-bit transfer
Table 91: SPI/SSP Control Register 0 (SSP0CR0 - address 0x4004 0000) bit description
BitSymbol ValueDescriptionReset
5:4FRFFrame Format.00
6CPOLClock Out Polarity. This bit is onl y used in SPI mode .0
7CPHAClock Out Phase. This bit is only used in SPI mode.0
15:8SCRSerial Clock Rate. The number of prescaler-output clocks per
31:16 --Reserved-
UM10429
Chapter 11: LPC1102 SPI0 with SSP
Value
0x0SPI
0x1TI
0x2Microwire
0x3This combination is not supported and should not be used.
0SPI controller maintains the bus clock low between frames.
1SPI controller maintains the bus clock high between frames.
0SPI controller captures serial data on the first clock transition
of the frame, that is, the transition away from the inter-frame
state of the clock line.
1SPI 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.
0x00
bit on the bus, minus one. Given that CPSDVSR is the
prescale divider, and the APB clock PCLK clocks the
prescaler, the bit frequency is PCLK / (CPSDVSR × [SCR+1]).
11.6.2 SPI/SSP0 Control Register 1
This register controls certain aspects of the operation of the SPI/SSP controller.
Table 92: SPI/SSP Control Register 1 (SSP0CR1 - address 0x4004 0004) bit description
BitSymbolValueDescriptionReset
0LBMLoop Back Mode.0
0During normal operation.
1Serial input is taken from the serial output (MOSI or MISO)
rather than the serial input pin (MISO or MOSI
respectively).
1SSESPI Enable.0
0The SPI controller is disabled.
1The SPI controller will interact with other devices on the
serial bus. Software should write the appropriate control
information to the other SPI/SSP registers and interrupt
controller registers, before setting this bit.
Table 92: SPI/SSP Control Register 1 (SSP0CR1 - address 0x4004 0004) bit description
BitSymbolValueDescriptionReset
2MSMaster/Slave Mode.This bit can only be written when the
3SODSlave Output Disable. This bit is relevant only in slave
31:4-Reserved, user software should not write ones to reserved
11.6.3 SPI/SSP Data Register
Software can write data to be transmitted to this register and read data that has been
received.
Table 93: SPI/SSP Data Regis ter (SSP0DR - address 0x4004 00 08) bit description
BitSymbolDescriptionReset Value
15:0DATAWrite: software can write data to be sent in a future fram e to this
31:16 -Reserved.-
UM10429
Chapter 11: LPC1102 SPI0 with SSP
Value
0
SSE bit is 0.
0The SPI controller acts as a master on the bus, driving the
SCLK, MOSI, and SSEL lines and receiving the MISO line.
1The SPI controller acts as a slave on the bus, driving MISO
line and receiving SCLK, MOSI, and SSEL lines.
0
mode (MS = 1). If it is 1, this blocks this SPI controller from
driving the transmit data line (MISO).
NA
bits. The value read from a reserved bit is not defined.
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 SPI 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 bit, 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 SPI controller
returns data from the least recent frame in the Rx FIFO. If the
data length is less than 16 bit, the data is right-justified in this
field with higher order bits filled with 0s.
11.6.4 SPI/SSP Status Register
This read-only register reflects the current status of the SPI controller.
Table 94:SPI/SSP Status Register (SSP0SR - address 0x4004 000C) bit description
BitSymbolDescriptionReset Value
0TFETransmit FIFO Empty. This bit is 1 is the Transmit FIFO is
empty, 0 if not.
1TNFTransmit FIFO Not Full. This bit is 0 if the Tx FIFO is full, 1 if not. 1
2RNEReceive FIFO Not Empty. This bit is 0 if the Receive FIFO is
Table 94:SPI/SSP Status Register (SSP0SR - address 0x4004 000C) bit description
BitSymbolDescriptionReset Value
3RFFReceive FIFO Full. This bit is 1 if the Receive FIFO is full, 0 if
4BSYBusy. This bit is 0 if the SPI controller is idle, 1 if it is currently
31:5-Reserved, user software should not write ones to reserved bits.
11.6.5 SPI/SSP Clock Prescale Register
This register controls the factor by which the Prescaler divides the SPI peripheral clock
SPI_PCLK to yield the prescaler clock that is, in turn, divided by the SCR factor in the
SSPCR0 registers, to determine the bit clock.
7:0CPSDVSR This even value between 2 and 254, by which SPI_PCLK is
31:8-Reserved.-
UM10429
Chapter 11: LPC1102 SPI0 with SSP
0
not.
0
sending/receiving a frame and/or the Tx FIFO is not empty.
NA
The value read from a reserved bit is not defined.
description
0
divided to yield the prescaler output clock. Bit 0 always reads
as 0.
Important: the SSPnCPSR value must be properly initialized, or the SPI controller will not
be able to transmit data correctly.
In Slave mode, the SPI clock rate provided by the master must not exceed 1/12 of the SPI
peripheral clock selected in Section 3.5.15
. The content of the SSPnCPSR register is not
relevant.
In master mode, CPSDVSR
= 2 or larger (even numbers only).
min
11.6.6 SPI/SSP Interrupt Mask Set/Clear Register
This register controls whether each of the four possible interrupt conditions in the SPI
controller are enabled. Note that ARM uses the word “masked” in the opposite sense from
classic computer terminology, in which “masked” meant “disabled”. ARM uses the word
“masked” to mean “enabled”. To avoid confusion we will not use the word “masked”.
0RORIMSoftware should set this bit to enable interrupt when a Receive
1RTIMSoftware should set this bit to enable interrupt when a Receive
2RXIMSoftware should set this bit to enable interrupt when the Rx FIFO is at
3TXIMSoftware should set this bit to enable interrupt when the Tx FIFO is at
31:4-Reserved, user software should not write ones to reserved bits. The
UM10429
Chapter 11: LPC1102 SPI0 with SSP
description
Value
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.
0
Time-out condition occurs. A Receive Time-out occurs when the Rx
FIFO is not empty, and no has not been read for a “time-out period".
The time-out period is the same for master and slave modes and is
determined by the SSP bit rate: 32 bits at PCLK / (CPSDVSR ×
[SCR+1]).
0
least half full.
0
least half empty.
NA
value read from a reserved bit is not defined.
11.6.7 SPI/SSP Raw Interrupt Status Register
This read-only register contains a 1 for each interrupt condition that is asserted,
regardless of whether or not the interrupt is enabled in the SSPIMSC registers.
Table 97:SPI/SSP Raw Interrupt Status register (SSP0RIS - address 0x4004 0018) bit
description
BitSymbolDescriptionReset Value
0RORRISThis bit is 1 if another frame was completely received while the
RxFIFO was full. The ARM spec implies that the preceding
frame data is overwritten by the new frame data when this
occurs.
1RTRISThis bit is 1 if the Rx FIFO is not empty, and has not been read
for a “time-out period". The time-out period is the same for
master and slave modes and is determined by the SSP bit
rate: 32 bits at PCLK / (CPSDVSR × [SCR+1]).
2RXRISThis bit is 1 if the Rx FIFO is at least half full.0
3TXRISThis bit is 1 if the Tx FIFO is at least half empty.1
31:4-Reserved, user software should not write ones to reserved
bits. The value read from a reserved bit is not defined.
11.6.8 SPI/SSP Masked Interrupt Status Register
This read-only register contains a 1 for each i nterrupt condition that is asserted and
enabled in the SSPIMSC registers. When an SPI interrupt occurs, the interrupt service
routine should read this register to determine the cause(s) of the interrupt.
Table 98: SPI/SSP Masked Interrupt Status register (SSP0MIS - address 0x4004 001C) bit
BitSymbolDescriptionReset Value
0RORMISThis bit is 1 if another frame was completely received while the
1RTMISThis bit is 1 if the Rx FIFO is not empty, has not been re ad fo r
2RXMISThis bit is 1 if the Rx FIFO is at least half full, and this interrupt
3TXMISThi s bi t is 1 if the Tx FIFO is at least half empty, and this
31:4-Reserved, user software should not write ones to reserved
11.6.9 SPI/SSP Interrupt Clear Register
UM10429
Chapter 11: LPC1102 SPI0 with SSP
description
0
RxFIFO was full, and this interrupt is enabled.
0
a “time-out period", and this interrupt is enabled. The time-out
period is the same for master and slave modes and is
determined by the SSP bit rate: 32 bits at PCLK / (CPSDVSR
× [SCR+1]).
0
is enabled.
0
interrupt is enabled.
NA
bits. The value read from a reserved bit is not defined.
Software can write one or more one(s) to this write-only register, to clear the
corresponding interrupt condition(s) in the SPI controller. Note that the other two interrupt
conditions can be cleared by writing or reading the appropriate FIFO or disabled by
clearing the corresponding bit in SSPIMSC registers.
0RORICWriting a 1 to this bit clears the “frame was received when
1RTICWriting a 1 to this bit clears the Rx FIFO was not empty and
31:2-Reserved, user software should not write ones to reserved
11.7 Functional description
11.7.1 Texas Instruments synchronous serial frame format
Figure 13 shows the 4-wire Texas Instruments synchronous serial frame format supported
by the SPI module.
NA
RxFIFO was full” interrupt.
NA
has not been read for a timeout period interrupt. The timeout
period is the same for master and slave modes and is
determined by the SSP bit rate: 32 bits at PCLK / (CPSDVSR
× [SCR+1]).
NA
bits. The value read from a reserved bit is not defined.
Fig 13. 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 in 3-state mode 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-bit 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.
11.7.2 SPI frame format
The SPI interface is a four-wire interface where the SSEL signal behaves as a slave
select. The main feature of the SPI format is that the inactive state and phase of the SCK
signal are programmable through the CPOL and CPHA bits within the SSPCR0 control
register.
11.7.2.1 Clock Polarity (CPOL) and Phase (CPHA) control
When the CPOL clock polarity control bit is LOW, it produces a steady state low value on
the SCK pin. If the CPOL clock polarity control bit is HIGH, a steady state high value is
placed on the CLK pin when data is not being transferred.
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.
11.7.2.2 SPI format with CPOL=0,CPHA=0
Single and continuous transmission signal sequences for SPI format with CPOL = 0,
CPHA = 0 are shown in Figure 14
UM10429
Chapter 11: LPC1102 SPI0 with SSP
.
a. Single transfer with CPOL=0 and CPHA=0
b. Continuous transfer with CPOL=0 and CPHA=0
Fig 14. SPI frame format with CPOL=0 and CPHA=0 (a) Single and b) Continuous Transfer)
In this configuration, during idle periods:
• The CLK signal is forced LOW.
• SSEL is forced HIGH.
• The transmit MOSI/MISO pad is in high impedance.
If the SPI/SSP is enabled and there is valid data within the transmit FIFO, the start of
transmission is signified by the SSEL master signal being driven LOW. This causes slave
data to be enabled onto the MISO input line of the master. Master’s MOSI is enabled.
One half SCK period later, valid master dat a is transferre d 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 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 th e case of continuous ba ck-to- back transmissions, th e SSEL sig nal 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.
11.7.2.3 SPI format with CPOL=0,CPHA=1
The transfer signal sequence for SPI format with CPOL = 0, CPHA = 1 is shown in
Figure 15
UM10429
Chapter 11: LPC1102 SPI0 with SSP
, which covers both single and continuous transfers.
Fig 15. SPI frame format with CPOL=0 and CPHA=1
In this configuration, during idle periods:
• The CLK signal is forced LOW.
• SSEL is forced HIGH.
• The transmit MOSI/MISO pad is in high impedance.
If the SPI/SSP is enabled and there is valid data within the transmit FIFO, the start of
transmission is signified by the SSEL master signal being driven LOW. Master’s MOSI pin
is enabled. After a further one half SCK period, both master and slave valid data is
enabled onto their respective transmission lines. At the same time, the SCK is enabled
with a rising edge transition.
Data is then captured on the falling edges and prop agated 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 th e last bi t 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.
11.7.2.4 SPI format with CPOL = 1,CPHA = 0
Single and continuous transmission signal sequences for SPI format with CPOL=1,