![NXP Semiconductors P89LPC9321 UM10310 User Manual Download Page 138](http://html1.mh-extra.com/html/nxp-semiconductors/p89lpc9321-um10310/p89lpc9321-um10310_user-manual_1721873138.webp)
UM10310_1
© NXP B.V. 2008. All rights reserved.
User manual
Rev. 01 — 1 December 2008
138 of 139
NXP Semiconductors
UM10310
P89LPC9321 User manual
23. Contents
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Pin configuration . . . . . . . . . . . . . . . . . . . . . . . . 3
Pin description . . . . . . . . . . . . . . . . . . . . . . . . . 5
Functional diagram . . . . . . . . . . . . . . . . . . . . . . 8
Block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Special function registers . . . . . . . . . . . . . . . . 10
Memory organization . . . . . . . . . . . . . . . . . . . 20
Clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Enhanced CPU . . . . . . . . . . . . . . . . . . . . . . . . 21
Clock definitions . . . . . . . . . . . . . . . . . . . . . . . 21
Oscillator Clock (OSCCLK). . . . . . . . . . . . . . . 21
External crystal oscillator option . . . . . . . . . . . 21
Low speed oscillator option . . . . . . . . . . . . . . 21
Medium speed oscillator option . . . . . . . . . . . 22
High speed oscillator option . . . . . . . . . . . . . . 22
Clock output . . . . . . . . . . . . . . . . . . . . . . . . . . 22
On-chip RC oscillator option . . . . . . . . . . . . . . 22
Watchdog oscillator option . . . . . . . . . . . . . . . 23
External clock input option . . . . . . . . . . . . . . . 23
Clock sources switch on the fly. . . . . . . . . . . . 24
Oscillator Clock (OSCCLK) wake-up delay . . 25
Low power select . . . . . . . . . . . . . . . . . . . . . . 25
Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Interrupt priority structure . . . . . . . . . . . . . . . . 26
External Interrupt pin glitch suppression. . . . . 27
I/O ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Port configurations . . . . . . . . . . . . . . . . . . . . . 29
Quasi-bidirectional output configuration . . . . . 29
Open drain output configuration . . . . . . . . . . . 30
Input-only configuration . . . . . . . . . . . . . . . . . 31
Push-pull output configuration . . . . . . . . . . . . 31
Port 0 and Analog Comparator functions . . . . 31
Additional port features. . . . . . . . . . . . . . . . . . 32
Power monitoring functions . . . . . . . . . . . . . . 33
Brownout detection . . . . . . . . . . . . . . . . . . . . . 33
Power-on detection. . . . . . . . . . . . . . . . . . . . . 34
Power reduction modes . . . . . . . . . . . . . . . . . 34
Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Reset vector . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Timers 0 and 1 . . . . . . . . . . . . . . . . . . . . . . . . . 39
Mode 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Mode 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Mode 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Mode 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Mode 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Timer overflow toggle output . . . . . . . . . . . . . 43
Real-time clock system timer . . . . . . . . . . . . . 43
Real-time clock source . . . . . . . . . . . . . . . . . . 44
Changing RTCS1/RTCS0. . . . . . . . . . . . . . . . 45
Real-time clock interrupt/wake-up . . . . . . . . . 45
Real-time clock read back . . . . . . . . . . . . . . . 45
Reset sources affecting the Real-time clock. . 45
Capture/Compare Unit (CCU) . . . . . . . . . . . . . 47
CCU Clock (CCUCLK) . . . . . . . . . . . . . . . . . . 47
CCU Clock prescaling . . . . . . . . . . . . . . . . . . 47
Basic timer operation . . . . . . . . . . . . . . . . . . . 48
Output compare . . . . . . . . . . . . . . . . . . . . . . . 50
Input capture . . . . . . . . . . . . . . . . . . . . . . . . . 51
PWM operation . . . . . . . . . . . . . . . . . . . . . . . 52
Alternating output mode. . . . . . . . . . . . . . . . . 53
Synchronized PWM register update . . . . . . . 54
HALT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
PLL operation. . . . . . . . . . . . . . . . . . . . . . . . . 55
CCU interrupt structure . . . . . . . . . . . . . . . . . 56
UART . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Mode 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Mode 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Mode 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Mode 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
SFR space . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Baud Rate generator and selection . . . . . . . . 60
Updating the BRGR1 and BRGR0 SFRs . . . . 60
Framing error . . . . . . . . . . . . . . . . . . . . . . . . . 61
Break detect. . . . . . . . . . . . . . . . . . . . . . . . . . 61
More about UART Mode 0 . . . . . . . . . . . . . . . 63
More about UART Mode 1 . . . . . . . . . . . . . . . 64
More about UART Modes 2 and 3 . . . . . . . . . 65
Break detect. . . . . . . . . . . . . . . . . . . . . . . . . . 66
Double buffering. . . . . . . . . . . . . . . . . . . . . . . 66
Double buffering in different modes . . . . . . . . 66
Multiprocessor communications. . . . . . . . . . . 68
Automatic address recognition. . . . . . . . . . . . 69
2
C interface . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
2
C data register . . . . . . . . . . . . . . . . . . . . . . . 71
C slave address register. . . . . . . . . . . . . . . 71
2
C control register . . . . . . . . . . . . . . . . . . . . . 72
2
C Status register . . . . . . . . . . . . . . . . . . . . . 73
2
C SCL duty cycle registers I2SCLH and
I2SCLL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
2
C operation modes . . . . . . . . . . . . . . . . . . . 74
Master Transmitter mode . . . . . . . . . . . . . . . . 74
Master Receiver mode. . . . . . . . . . . . . . . . . . 75
Slave Receiver mode. . . . . . . . . . . . . . . . . . . 76
Slave Transmitter mode . . . . . . . . . . . . . . . . . 77
Serial Peripheral Interface (SPI). . . . . . . . . . . 84
Configuring the SPI . . . . . . . . . . . . . . . . . . . . 88
Additional considerations for a slave . . . . . . . 89
Additional considerations for a master . . . . . . 89
Mode change on SS . . . . . . . . . . . . . . . . . . . 89
Write collision . . . . . . . . . . . . . . . . . . . . . . . . . 90
Data mode . . . . . . . . . . . . . . . . . . . . . . . . . . . 90