MC9S08JM60
MC9S08JM60
MC9S08LG16
Reference Manual
THIS DOCUMENT CONTAINS INFORMATION ON A NEW PRODUCT UNDER DEVELOPMENT. FREESCALE RESERVES THE RIGHT TO CHANGE OR
DISCONTINUE THIS PRODUCT WITHOUT NOTICE.
HCS08
Microcontrollers
MC9S08LG32RM
Rev. 5
8/2009
freescale.com
MC9S08LG32 Series Features
8-Bit HCS08 Central Processor Unit (CPU) • On-chip in-circuit emulator (ICE) debug module
containing three comparators and nine trigger modes;
• Up to 40 MHz CPU at 5.5 V to 2.7 V across temperature eight deep FIFO for storing change-of-flow addresses
range of –40 °C to 85 °C and –40 °C to 105 °C and event-only data; debug module supports both tag and
• HCS08 instruction set with added BGND instruction force breakpoints
• Support for up to 32 interrupt/reset sources Peripherals
On-Chip Memory
• LCD — Up to 4 x 41 or 8 x 37 LCD driver with internal
• 32 KB or 18 KB dual array flash; read/program/erase charge pump
over full operating voltage and temperature • ADC — Up to 16-channel, 12-bit resolution; 2.5 μs
• 1984 byte random access memory (RAM) conversion time; automatic compare function;
temperature sensor; internal bandgap reference channel;
• Security circuitry to prevent unauthorized access to
runs in stop3 and can wake up the system; fully
RAM and flash contents
functional from 5.5 V to 2.7 V
Power-Saving Modes • SCI — Full duplex non-return to zero (NRZ); LIN
master extended break generation; LIN slave extended
• Two low-power stop modes (stop2 and stop3) break detection; wakeup on active edge
• Reduced-power wait mode • SPI— Full-duplex or single-wire bidirectional;
• Peripheral clock gating register can disable clocks to double-buffered transmit and receive; master or slave
unused modules, thereby reducing currents mode; MSB-first or LSB-first shifting
• Low power on-chip crystal oscillator (XOSC) that can be • IIC — With up to 100 kbps with maximum bus loading;
used in low-power modes to provide accurate clock multi-master operation; programmable slave address;
source to real time counter and LCD controller interrupt driven byte-by-byte data transfer; supports
• 100 μs typical wakeup time from stop3 mode broadcast mode and 10-bit addressing
• TPMx — One 6 channel and one 2 channel; selectable
Clock Source Options input capture, output compare, or buffered edge or
center-aligned PWM on each channel
• Oscillator (XOSC) — Loop-control Pierce oscillator; • MTIM — 8-bit counter with match register; four clock
crystal or ceramic resonator range of 31.25 kHz to sources with prescaler dividers; can be used for periodic
38.4 kHz or 1 MHz to 16 MHz wakeup
• Internal Clock Source (ICS) — Internal clock source • RTC — 8-bit modulus counter with binary or decimal
module containing a frequency-locked-loop (FLL) based prescaler; three clock sources including one
controlled by internal or external reference; precision external source; can be used for time base, calendar, or
trimming of internal reference allows 0.2% resolution task scheduling functions
and 2% deviation over temperature and voltage; supports
• KBI — One keyboard control module capable of
bus frequencies from 1 MHz to 20 MHz
supporting 8x8 keyboard matrix
System Protection • IRQ — External pin for wakeup from low-power modes
THIS DOCUMENT CONTAINS INFORMATION ON A NEW PRODUCT UNDER DEVELOPMENT. FREESCALE RESERVES THE RIGHT TO CHANGE OR
DISCONTINUE THIS PRODUCT WITHOUT NOTICE.
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
© Freescale Semiconductor, Inc., 2009. All rights reserved.
Revision History
To provide the most up-to-date information, the revision of our documents on the World Wide Web will be
the most current. Your printed copy may be an earlier revision. To verify you have the latest information
available, refer to:
http://www.freescale.com
The following revision history table summarizes changes contained in this document.
Revision Revision
Description of Changes
Number Date
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
© Freescale Semiconductor, Inc., 2009. All rights reserved.
Chapter 1
Device Overview
1.1 Devices in the MC9S08LG32 Series ...............................................................................................21
1.2 MCU Block Diagram .......................................................................................................................22
1.3 System Clock Distribution ...............................................................................................................24
Chapter 2
Pins and Connections
2.1 Introduction ......................................................................................................................................27
2.2 Device Pin Assignment ....................................................................................................................27
2.3 Recommended System Connections ................................................................................................31
2.3.1 Power ................................................................................................................................33
2.3.2 Oscillator ...........................................................................................................................33
2.3.3 RESET ..............................................................................................................................34
2.3.4 Background / Mode Select (BKGD/MS) ..........................................................................34
2.3.5 IRQ ....................................................................................................................................35
2.3.6 LCD Pins ...........................................................................................................................35
2.3.7 General-Purpose I/O (GPIO) and Peripheral Ports ...........................................................36
Chapter 3
Modes of Operation
3.1 Introduction ......................................................................................................................................41
3.2 Features ............................................................................................................................................41
3.3 Run Mode.........................................................................................................................................41
3.4 Active Background Mode ................................................................................................................41
3.5 Wait Mode ........................................................................................................................................42
3.6 Stop Modes.......................................................................................................................................43
3.6.1 Stop2 Mode .......................................................................................................................43
3.6.2 Stop3 Mode .......................................................................................................................44
3.6.3 Active BDM Enabled in Stop Mode .................................................................................45
3.6.4 LVD Enabled in Stop Mode ..............................................................................................45
3.7 Mode Selection.................................................................................................................................45
3.7.1 On-Chip Peripheral Modules in Stop Modes ....................................................................48
Chapter 4
Memory
4.1 Introduction ......................................................................................................................................49
Chapter 5
Resets, Interrupts, and General System Control
5.1 Introduction ......................................................................................................................................73
5.2 Features ............................................................................................................................................73
5.3 MCU Reset.......................................................................................................................................73
5.4 Computer Operating Properly (COP) Watchdog..............................................................................74
5.5 Interrupts ..........................................................................................................................................75
5.5.1 Interrupt Stack Frame .......................................................................................................76
5.5.2 External Interrupt Request (IRQ) Pin ...............................................................................76
5.5.3 Interrupt Vectors, Sources, and Local Masks ...................................................................77
5.6 Low-Voltage Detect (LVD) System .................................................................................................79
5.6.1 Power-On Reset Operation ...............................................................................................79
5.6.2 Low-Voltage Detection (LVD) Reset Operation ...............................................................79
5.6.3 Low-Voltage Warning (LVW) Interrupt Operation ...........................................................79
5.7 Peripheral Clock Gating ...................................................................................................................79
5.8 Reset, Interrupt, and System Control Registers and Control Bits....................................................80
5.8.1 Interrupt Pin Request Status and Control Register (IRQSC) ............................................80
5.8.2 System Reset Status Register (SRS) .................................................................................82
5.8.3 System Background Debug Force Reset Register (SBDFR) ............................................83
5.8.4 System Options Register 1 (SOPT1) ................................................................................84
Chapter 6
Parallel Input/Output Control
6.1 Introduction ......................................................................................................................................97
6.2 Pins Shared with LCD......................................................................................................................97
6.3 Port Data and Data Direction ...........................................................................................................97
6.4 Pullup, Slew Rate, and Drive Strength.............................................................................................98
6.4.1 Port Internal Pullup Enable ...............................................................................................98
6.4.2 Port Slew Rate Enable ......................................................................................................99
6.4.3 Port Drive Strength Select ................................................................................................99
6.5 Open Drain Operation ......................................................................................................................99
6.6 Pin Behavior in Stop Modes.............................................................................................................99
6.7 Parallel I/O and Pin Control Registers ...........................................................................................100
6.7.1 Port A Registers ..............................................................................................................100
6.7.2 Port B Registers ..............................................................................................................104
6.7.3 Port C Registers ..............................................................................................................107
6.7.4 Port D Registers ..............................................................................................................110
6.7.5 Port E Registers ..............................................................................................................113
6.7.6 Port F Registers ...............................................................................................................116
6.7.7 Port G Registers ..............................................................................................................119
6.7.8 Port H Registers ..............................................................................................................122
6.7.9 Port I Registers ................................................................................................................125
Chapter 7
Keyboard Interrupt (S08KBIV2)
7.1 Introduction ....................................................................................................................................128
7.1.1 Module Configuration .....................................................................................................128
7.1.2 KBI Clock Gating ...........................................................................................................128
7.1.3 Features ...........................................................................................................................130
7.1.4 Modes of Operation ........................................................................................................130
7.1.5 Block Diagram ................................................................................................................130
7.2 External Signal Description ...........................................................................................................131
Chapter 8
Central Processor Unit (S08CPUV5)
8.1 Introduction ....................................................................................................................................135
8.1.1 Features ...........................................................................................................................135
8.2 Programmer’s Model and CPU Registers ......................................................................................136
8.2.1 Accumulator (A) .............................................................................................................136
8.2.2 Index Register (H:X) ......................................................................................................136
8.2.3 Stack Pointer (SP) ...........................................................................................................137
8.2.4 Program Counter (PC) ....................................................................................................137
8.2.5 Condition Code Register (CCR) .....................................................................................137
8.3 Addressing Modes..........................................................................................................................139
8.3.1 Inherent Addressing Mode (INH) ...................................................................................139
8.3.2 Relative Addressing Mode (REL) ..................................................................................139
8.3.3 Immediate Addressing Mode (IMM) ..............................................................................139
8.3.4 Direct Addressing Mode (DIR) ......................................................................................139
8.3.5 Extended Addressing Mode (EXT) ................................................................................140
8.3.6 Indexed Addressing Mode ..............................................................................................140
8.4 Special Operations..........................................................................................................................141
8.4.1 Reset Sequence ...............................................................................................................141
8.4.2 Interrupt Sequence ..........................................................................................................141
8.4.3 Wait Mode Operation ......................................................................................................142
8.4.4 Stop Mode Operation ......................................................................................................142
8.4.5 BGND Instruction ...........................................................................................................143
8.5 HCS08 Instruction Set Summary ...................................................................................................144
Chapter 9
LCD Module (S08LCDLPV1)
9.1 Introduction ....................................................................................................................................158
9.1.1 LCD Clock Sources ........................................................................................................158
9.1.2 LCD Modes of Operation ...............................................................................................158
9.1.3 LCD Status after Stop2 Wakeup .....................................................................................158
9.1.4 LCD Clock Gating ..........................................................................................................158
Chapter 10
Analog-to-Digital Converter (S08ADC12V1)
10.1 Introduction ....................................................................................................................................200
10.1.1 ADC shared with LCD ...................................................................................................200
10.1.2 ADC Reference and Supply Voltage ...............................................................................200
10.1.3 ADC Clock Gating ..........................................................................................................200
10.1.4 Module Configurations ...................................................................................................201
10.1.5 Features ...........................................................................................................................204
10.1.6 ADC Module Block Diagram .........................................................................................204
10.2 External Signal Description ...........................................................................................................205
Chapter 11
Internal Clock Source (S08ICSV3)
11.1 Introduction ....................................................................................................................................226
11.1.1 Features ...........................................................................................................................228
11.1.2 Block Diagram ................................................................................................................228
11.1.3 Modes of Operation ........................................................................................................229
11.2 External Signal Description ...........................................................................................................230
11.3 Register Definition .........................................................................................................................230
11.3.1 ICS Control Register 1 (ICSC1) .....................................................................................231
11.3.2 ICS Control Register 2 (ICSC2) .....................................................................................233
11.3.3 ICS Trim Register (ICSTRM) .........................................................................................233
Chapter 12
Inter-Integrated Circuit (S08IICV2)
12.1 Introduction ....................................................................................................................................241
12.1.1 Module Configuration .....................................................................................................241
12.1.2 IIC Clock Gating .............................................................................................................241
12.1.3 Features ...........................................................................................................................243
12.1.4 Modes of Operation ........................................................................................................243
12.1.5 Block Diagram ................................................................................................................243
12.2 External Signal Description ...........................................................................................................244
12.2.1 SCL — Serial Clock Line ...............................................................................................244
12.2.2 SDA — Serial Data Line ................................................................................................244
12.3 Register Definition .........................................................................................................................244
12.3.1 IIC Address Register (IICxA) .........................................................................................245
12.3.2 IIC Frequency Divider Register (IICxF) ........................................................................245
12.3.3 IIC Control Register (IICxC1) ........................................................................................248
12.3.4 IIC Status Register (IICxS) .............................................................................................248
12.3.5 IIC Data I/O Register (IICxD) ........................................................................................249
12.3.6 IIC Control Register 2 (IICxC2) .....................................................................................250
12.4 Functional Description ...................................................................................................................251
12.4.1 IIC Protocol .....................................................................................................................251
12.4.2 10-bit Address .................................................................................................................254
12.4.3 General Call Address ......................................................................................................255
12.5 Resets .............................................................................................................................................255
12.6 Interrupts ........................................................................................................................................255
12.6.1 Byte Transfer Interrupt ....................................................................................................255
12.6.2 Address Detect Interrupt .................................................................................................256
12.6.3 Arbitration Lost Interrupt ................................................................................................256
12.7 Initialization/Application Information ...........................................................................................257
Chapter 13
Serial Communications Interface (S08SCIV4)
13.1 Introduction ....................................................................................................................................259
13.1.1 Module Instances ............................................................................................................259
13.1.2 Module Configuration .....................................................................................................259
13.1.3 SCI Clock Gating ............................................................................................................259
13.1.4 Features ...........................................................................................................................261
13.1.5 Modes of Operation ........................................................................................................261
13.1.6 Block Diagram ................................................................................................................262
13.2 Register Definition .........................................................................................................................264
13.2.1 SCI Baud Rate Registers (SCIxBDH, SCIxBDL) ..........................................................264
13.2.2 SCI Control Register 1 (SCIxC1) ...................................................................................265
13.2.3 SCI Control Register 2 (SCIxC2) ...................................................................................266
13.2.4 SCI Status Register 1 (SCIxS1) ......................................................................................267
13.2.5 SCI Status Register 2 (SCIxS2) ......................................................................................269
13.2.6 SCI Control Register 3 (SCIxC3) ...................................................................................270
13.2.7 SCI Data Register (SCIxD) .............................................................................................271
13.3 Functional Description ...................................................................................................................271
13.3.1 Baud Rate Generation .....................................................................................................271
13.3.2 Transmitter Functional Description ................................................................................272
13.3.3 Receiver Functional Description ....................................................................................273
13.3.4 Interrupts and Status Flags ..............................................................................................275
13.3.5 Additional SCI Functions ...............................................................................................276
Chapter 14
Serial Peripheral Interface (S08SPIV4)
14.1 Introduction ....................................................................................................................................278
14.1.1 Module Configuration .....................................................................................................278
14.1.2 SPI Clock Gating ............................................................................................................278
14.1.3 Features ...........................................................................................................................280
14.1.4 Block Diagrams ..............................................................................................................280
14.1.5 SPI Baud Rate Generation ..............................................................................................282
14.2 External Signal Description ...........................................................................................................283
14.2.1 SPSCK — SPI Serial Clock ............................................................................................283
14.2.2 MOSI — Master Data Out, Slave Data In ......................................................................283
14.2.3 MISO — Master Data In, Slave Data Out ......................................................................283
14.2.4 SS — Slave Select ..........................................................................................................283
14.3 Modes of Operation........................................................................................................................284
14.3.1 SPI in Stop Modes ..........................................................................................................284
14.4 Register Definition .........................................................................................................................284
14.4.1 SPI Control Register 1 (SPIxC1) ....................................................................................284
14.4.2 SPI Control Register 2 (SPIxC2) ....................................................................................285
Chapter 15
Real-Time Counter (S08RTCV1)
15.1 Introduction ....................................................................................................................................297
15.1.1 RTC Clock Gating ..........................................................................................................297
15.1.2 Features ...........................................................................................................................299
15.1.3 Modes of Operation ........................................................................................................299
15.1.4 Block Diagram ................................................................................................................300
15.2 External Signal Description ...........................................................................................................300
15.3 Register Definition .........................................................................................................................300
15.3.1 RTC Status and Control Register (RTCSC) ....................................................................301
15.3.2 RTC Counter Register (RTCCNT) ..................................................................................302
15.3.3 RTC Modulo Register (RTCMOD) ................................................................................302
15.4 Functional Description ...................................................................................................................302
15.4.1 RTC Operation Example .................................................................................................303
15.5 Initialization/Application Information ...........................................................................................304
Chapter 16
Timer/Pulse-Width Modulator (S08TPMV3)
16.1 Introduction ....................................................................................................................................306
16.1.1 TPM External Clock .......................................................................................................306
16.1.2 Module Instances ............................................................................................................306
16.1.3 Module Configuration .....................................................................................................306
16.1.4 TPM Clock Gating ..........................................................................................................307
16.1.5 Features ...........................................................................................................................308
16.1.6 Modes of Operation ........................................................................................................308
16.1.7 Block Diagram ................................................................................................................309
16.2 Signal Description ..........................................................................................................................311
16.2.1 Detailed Signal Descriptions ..........................................................................................311
16.3 Register Definition .........................................................................................................................314
16.3.1 TPM Status and Control Register (TPMxSC) ................................................................314
16.3.2 TPM-Counter Registers (TPMxCNTH:TPMxCNTL) ....................................................315
Chapter 17
Modulo Timer (S08MTIMV1)
17.1 Introduction ....................................................................................................................................327
17.1.1 MTIM Clock Gating .......................................................................................................327
17.1.2 Features ...........................................................................................................................329
17.1.3 Modes of Operation ........................................................................................................329
17.1.4 Block Diagram ................................................................................................................330
17.2 External Signal Description ...........................................................................................................330
17.3 Memory Map and Register Definition ...........................................................................................331
17.3.1 Memory Map (Register Summary) .................................................................................331
17.3.2 Register Descriptions ......................................................................................................331
17.4 Functional Description ...................................................................................................................335
17.4.1 MTIM Operation Example .............................................................................................336
Chapter 18
Development Support
18.1 Introduction ....................................................................................................................................337
18.1.1 Forcing Active Background ............................................................................................337
18.1.2 Module Configuration .....................................................................................................337
18.1.3 Features ...........................................................................................................................338
18.2 Background Debug Controller (BDC) ...........................................................................................338
18.2.1 BKGD Pin Description ...................................................................................................339
18.2.2 Communication Details ..................................................................................................339
18.2.3 BDC Commands .............................................................................................................343
18.2.4 BDC Hardware Breakpoint .............................................................................................345
18.3 Register Definition .........................................................................................................................345
18.3.1 BDC Registers and Control Bits .....................................................................................346
18.3.2 System Background Debug Force Reset Register (SBDFR) ..........................................348
Chapter 19
Debug Module (DBG) (64K)
19.1 Introduction ....................................................................................................................................350
19.1.1 Features ...........................................................................................................................350
19.1.2 Modes of Operation ........................................................................................................351
19.1.3 Block Diagram ................................................................................................................351
19.2 Signal Description ..........................................................................................................................352
19.3 Memory Map and Registers ...........................................................................................................352
19.3.1 Module Memory Map .....................................................................................................352
19.3.2 Register Descriptions ......................................................................................................354
19.4 Functional Description ...................................................................................................................365
19.4.1 Comparator .....................................................................................................................365
19.4.2 Breakpoints .....................................................................................................................365
19.4.3 Trigger Selection .............................................................................................................366
19.4.4 Trigger Break Control (TBC) .........................................................................................366
19.4.5 FIFO ................................................................................................................................370
19.4.6 Interrupt Priority .............................................................................................................371
19.5 Resets .............................................................................................................................................371
19.6 Interrupts ........................................................................................................................................371
PORT A
LCD25/ADC2/RX2/KBI5/PTA4
LCD24/ADC1/TX2/KBI4/PTA3
BKGD/MS Real Time Counter
BKGD BKP LCD23/ADC0/SDA/PTA2
(RTC) LCD22/SCL/PTA1
LCD21/PTA0
HCS08 SYSTEM CONTROL Modulo Timer TMRCLK
PORT B
(MTIM) LCD[40:37]/PTB[7:4]
RESETS AND INTERRUPTS LCD[32:29]/PTB[3:0]
MODES OF OPERATION KBI[7:0]
8-BIT KEYBOARD
POWER MANAGEMENT
INTERRUPT (KBI)
RESET/PTC6
PORT C
SS BKGD/MS/PTC5
COP RESET SPSCK LCD[20:16]/PTC[4:0]
SERIAL PERIPHERAL MISO
IRQ INTERFACE (SPI)
IRQ LVD MOSI
PORT D
SCL LCD[7:0]/PTD[7:0]
USER FLASH A IIC MODULE (IIC) SDA
(LG32 = 16K BYTES)
PORT E
(LG16 = 2K BYTES) TPM2CH[5:0]
6-CHANNEL TIMER/PWM LCD[15:8]/PTE[7:0]
(TPM2) TPMCLK
USER FLASH B
(LG32 = 16K BYTES) TPM1CH[1:0]
2-CHANNEL TIMER/PWM EXTAL/PTF7
(LG16 = 16K BYTES) XTAL/PTF6
(TPM1) TPMCLK
TPM2CH3/KBI2/MOSI/PTF5
PORT F
TxD1 TPM2CH4/KBI1/MISO/PTF4
SERIAL COMMUNICATIONS
RxD1 TPM2CH5/KBI0/SS/PTF3
USER RAM INTERFACE (SCI1) ADC14/IRQ/TPM1CH1/SPSCK/PTF2
1984 BYTES ADC13/TPM1CH0/RX1/PTF1
TxD2 ADC12/TPM2CH2/KBI3/TX1/PTF0
SERIAL COMMUNICATIONS
RxD2
INTERFACE (SCI2)
PORT G
VLL3_2 12-BIT
ANALOG-TO-DIGITAL AD[15:0] ADC11/TPM1CH0/KBI3/TX1/PTH5
VLL3 CONVERTER (ADC) ADC10/TPM1CH1/KBI2/RX1/PTH4
VLL1 LIQUID CRYSTAL ADC[9:6]/KBI[7:4]/PTH[3:0]
DISPLAY DRIVER
VLL2
(LCD) SS/SCL/TPM2CH0/PTI5
VCAP1
SPSCK/SDA/TPM2CH1/PTI4
PORT I
VCAP2 MOSI/TPM2CH2/PTI3
LCD[44:0] MISO/TPM2CH3/PTI2
TX2/TMRCLK/PTI1
RX2/PTI0
VDD
VSS
VOLTAGE
REGULATOR
VSS2 Available only on 80-pin package
Available only on 64-pin and 80-pin package
VDDA/VREFH */Default function out of reset/*
VSSA/VREFL
Module Version
Analog-to-Digital Converter (ADC12) 1
Central Processor Unit (CPU) 5
Inter-Integrated Circuit (IIC) 2
Internal Clock Source (ICS) 3
Keyboard Interrupt (KBI) 2
Liquid Crystal Display Module (LCD) 1
Low Power Oscillator (XOSC) 1
Modulo Timer (MTIM) 1
On-Chip In-Circuit Debug/Emulator (DBG) 3
Real Time Counter (RTC) 1
Serial Communications Interface (SCI) 4
Serial Peripheral Interface (SPI) 4
Timer Pulse Width Modulator (TPM) 3
• TPMCLK — The TPMCLK is an optional external clock source for the TPM modules. The
TPMCLK must be limited to 1/4th of the frequency of the bus clock for synchronization. For more
information, see the “External TPM Clock Sources” section in Chapter 16, “Timer/Pulse-Width
Modulator (S08TPMV3).”
• TMRCLK — The TMRCLK is an optional external clock source for the MTIM module. For more
information, see Chapter 17, “Modulo Timer (S08MTIMV1).”
NOTE
ICSERCLK is a gated version of OSCOUT. ICSERCLK is not available in
STOP modes while OSCOUT is available if ERCLKEN and EREFSTEN
are set.
TPMCLK TMRCLK
ICSIRCLK
ICSERCLK
ICS ICSFFCLK FFCLK*
÷2 SYNC*
ICSOUT BUSCLK
÷2
ICSLCLK
OSCOUT
XOSC
CPU BDC DBG IIC LCD ADC FLASH KBI
* The fixed frequency clock (FFCLK) is internally ADC has min and max Flash has frequency
EXTAL XTAL synchronized to the bus clock and must not frequency requirements. requirements for program
exceed one half of the bus clock frequency. See the ADC chapter and and erase operation. See the
electricals appendix for electricals appendix for
details. details.
PTG0/LCD33
PTG1/LCD34
PTG4/LCD41
PTG5/LCD42
PTG6/LCD43
PTG7/LCD44
PTC0/LCD16
PTC1/LCD17
PTC2/LCD18
PTC3/LCD19
PTE2/LCD10
PTE3/LCD11
PTE4/LCD12
PTE5/LCD13
PTE6/LCD14
PTE7/LCD15
PTE0/LCD8
PTE1/LCD9
VLL3_2
VSS2
80
79
78
77
76
75
74
73
72
71
70
69
68
67
66
65
64
63
62
61
PTD7/LCD7 1 60 PTC4/LCD20
PTD6/LCD6 2 59 PTA0/LCD21
PTD5/LCD5 3 58 PTG2/LCD35
PTD4/LCD4 4 57 PTG3/LCD36
PTD3/LCD3 5 56 PTA1/SCL/LCD22
PTD2/LCD2 6 55 PTA2/SDA/ADC0/LCD23
PTB3/LCD32 7 54 PTA3/KBI4/TX2/ADC1/LCD24
PTB2/LCD31 8 53 PTA4/KBI5/RX2/ADC2/LCD25
PTB7/LCD40 9 52 PTA5/KBI6/TPM2CH0/ADC3/LCD26
80-Pin LQFP
PTB6/LCD39 10 51 PTA6/KBI7/TPM2CH1/ADC4/LCD27
PTB5/LCD38 11 50 PTA7/TPMCLK/ADC5/LCD28
PTB4/LCD37 12 49 PTC5/BKGD/MS
PTB1/LCD30 13 48 PTC6/RESET
PTB0/LCD29 14 47 PTH0/KBI4/ADC6
PTD1/LCD1 15 46 PTH1/KBI5/ADC7
PTD0/LCD0 16 45 PTH2KBI6/ADC8
VCAP1 17 44 PTH3/KBI7/ADC9
VCAP2 18 43 PTH4/RX1/KBI2/TPM1CH1/ADC10
VLL1 19 42 PTH5/TX1/KBI3/TPM1CH0/ADC11
VLL2 20 41 PTF3/SS/KBI0/TPM2CH5
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
PTI4/TPM2CH1/SDA/SPSCK
PTI5/TPM2CH0/SCL/SS
PTI2/TPM2CH3/MISO
PTI3/TPM2CH2/MOSI
VDD
VDDA/VREFH
PTF5/MOSI/KBI2/TPM2CH3
PTI0/RX2
VLL3
PTI1/TMRCLK/TX2
PTF7/EXTAL
PTH7/KBI1/TPM2CH4
PTF6/XTAL
PTF2/SPSCK/TPM1CH1/IRQ/ADC14
VSS
VSSA/VREFL
PTF1/RX1/TPM1CH0/ADC13
PTH6/TPM2CH5/KBI0/ADC15
PTF0/TX1/KBI3/TPM2CH2/ADC12
PTF4/MISO/KBI1/TPM2CH4
NOTE
VREFH/VREFL are internally connected to VDDA/VSSA.
PTG0/LCD33
PTG1/LCD34
PTC0/LCD16
PTC1/LCD17
PTC2/LCD18
PTC3/LCD19
PTE2/LCD10
PTE3/LCD11
PTE4/LCD12
PTE5/LCD13
PTE6/LCD14
PTE7/LCD15
PTE0/LCD8
PTE1/LCD9
VLL3_2
VSS2
64
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
PTD7/LCD7 1 48 PTC4/LCD20
PTD6/LCD6 2 47 PTA0/LCD21
PTD5/LCD5 3 46 PTG2/LCD35
PTD4/LCD4 4 45 PTG3/LCD36
PTD3/LCD3 5 44 PTA1/SCL/LCD22
PTD2/LCD2 6 43 PTA2/SDA/ADC0/LCD23
PTB3/LCD32 7 42 PTA3/KBI4/TX2/ADC1/LCD24
PTB2/LCD31 8 64-Pin LQFP 41 PTA4/KBI5/RX2/ADC2/LCD25
PTB1/LCD30 9 40 PTA5/KBI6/TPM2CH0/ADC3/LCD26
PTB0/LCD29 10 39 PTA6/KBI7/TPM2CH1/ADC4/LCD27
PTD1/LCD1 11 38 PTA7/TPMCLK/ADC5/LCD28
PTD0/LCD0 12 37 PTC5/BKGD/MS
VCAP1 13 36 PTC6/RESET
VCAP2 14 35 PTH4/RX1/KBI2/TPM1CH1/ADC10
VLL1 15 34 PTH5/TX1/KBI3/TPM1CH0/ADC11
VLL2 16 33 PTF3/SS/KBI0/TPM2CH5
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
VLL3
PTI5/TPM2CH0/SCL/SS
PTF7/EXTAL
PTF5/MOSI/KBI2/TPM2CH3
PTF4/MISO/KBI1/TPM2CH4
PTH7/KBI1/TPM2CH4
PTF6/XTAL
VSSA/VREFL
PTH6/TPM2CH5/KBI0/ADC15
PTI4/TPM2CH1/SDA/SPSCK
VSS
PTF2/SPSCK/TPM1CH1/IRQ/ADC14
PTF1/RX1/TPM1CH0/ADC13
VDD
PTF0/TX1/KBI3/TPM2CH2/ADC12
VDDA/VREFH
NOTE
VREFH/VREFL are internally connected to VDDA/VSSA.
PTC0/LCD16
PTC1/LCD17
PTC2/LCD18
PTC3/LCD19
PTE6/LCD14
PTE5/LCD13
PTE4/LCD12
PTE7/LCD15
PTE2/LCD10
PTE3/LCD11
PTE0/LCD8
PTE1/LCD9
48 37
47 46 45 44 43 42 41 40 39 38
PTD7/LCD7 1 36 PTC4/LCD20
PTD6/LCD6 2 35 PTA0/LCD21
PTD5/LCD5 3 34 PTA1/SCL/LCD22
PTD4/LCD4 4 33 PTA2/SDA/ADC0/LCD23
PTD3/LCD3 5 32 PTA3/KBI4/TX2/ADC1/LCD24
PTD1/LCD1 7 30 PTA5/KBI6/TPM2CH0/ADC3/LCD26
PTD0/LCD0 8 29 PTA6/KBI7/TPM2CH1/ADC4/LCD27
VCAP1 9 28 PTA7/TPMCLK/ADC5/LCD28
VCAP2 10 27 PTC5/BKGD/MS
VLL1 11 26 PTC6/RESET
VLL2 12 25 PTF3/SS/KBI0/TPM2CH5
14 15 16 17 18 19 20 21 22 23
13 24
PTF7/EXTAL
VDDA/VREFH
PTF2/SPSCKS/TPM1CH1/IRQ/ADC14
VLL3
PTF5/MOSI/KBI2/TPM2CH3
PTF4/MISO/KBI1/TPM2CH4
PTF6/XTAL
VSS
VDD
VSSA/VREFL
PTF1/RX1/TPM1CH0/ADC13
PTF0/TX1/KBI3/TPM2CH2/ADC12
NOTE
VREFH/VREFL are internally connected to VDDA/VSSA.
MC9S08LG32
LCD28/ADC5/TPMCLK/PTA7
VDDA/VREFH LCD27/ADC4/TPM2CH1/KBI7/PTA6
CBYAD LCD26/ADC3/TPM2CH0/KBI6/PTA5
PORT A
0.1 μF LCD25/ADC2/RX2/KBI5/PTA4
LCD24/ADC1/TX2/KBI4/PTA3
VSSA/VREFL LCD23/ADC0/SDA/PTA2
LCD22/SCL/PTA1
LCD21/PTA0
VDD
PORT B
+ LCD[40:37]/PTB[7:4]
SYSTEM CBLK + CBY LCD[32:29]/PTB[3:0]
POWER 5 V 10 μF 0.1 μF
VSS RESET_B/PTC6
PORT C
BKGD/MS/PTC5
LCD[20:16]/PTC[4:0]
PORT D
LCD[7:0]/PTD[7:0]
BACKGROUND HEADER
PORT E
VDD BKGD/MS
LCD[15:8]/PTE[7:0]
(NOTE 4)
EXTAL/PTF7
RESET XTAL/PTF6
(NOTE 3) TPM2CH3/KBI2/MOSI/PTF5
PORT F
OPTIONAL TPM2CH4/KBI1/MISO/PTF4
MANUAL TPM2CH5/KBI0/SS/PTF3
RESET ADC14/IRQ/TPM1CH1/SPSCK/PTF2
ADC13/TPM1CH0/RX1/PTF1
PORT G ADC12/TPM2CH2/KBI3/TX1/PTF0
LCD[44:41]/PTG[7:4]
RF LCD[36:33]/PTG[3:0]
EXTAL
C1 X1 C2 TPM2CH4/KBI1/PTH7
ADC15/KBI0/TPM2CH5/PTH6
PORT H
RS
XTAL ADC11/TPM1CH0/KBI3/TX1/PTH5
ADC10/TPM1CH1/KBI2/RX1/PTH4
ADC[9:6]/KBI[7:4]/PTH[3:0]
VLL1
0.1 μF SS/SCL/TPM2CH0/PTI5
SPSCK/SDA/TPM2CH1/PTI4
PORT I
MOSI/TPM2CH2/PTI3
VLL2 MISO/TPM2CH3/PTI2
0.1 μF LCD TX2/TMRCLK/PTI1
Module RX2/PTI0
VLL3
0.1 μF
Available only on 80-pin package
LCD[44:0]
Available only on 64-pin and 80-pin package VCAP1 VCAP2 LCD Glass
*/Default function out of reset/*
0.1μF
NOTES:
1 RESET pin can only be used to reset into user mode, you can not enter BDM using RESET pin. To enter BDM, hold MS low
during POR or write a 1 to BDFR in SBDFR with MS low after issuing BDM command.
2 RC filter on RESET pin recommended for noisy environments.
3
When PTC6 is configured as RESET, pin becomes bi-directional with output being open-drain drive containing an internal
pullup device.
4
When PTC5 is configured as BKGD, pin becomes bi-directional.
5
LCD mode shown is for Charge pump enabled, other configurations are necessary for different LCD modes.
2.3.1 Power
VDD and VSS are primary power supply pins for the MCU. This voltage source supplies power to all I/O
buffer circuitry and to an internal voltage regulator. The internal voltage regulator provides a regulated
lower-voltage source for the CPU and other internal circuitry of the MCU.
The LCD/GPIO can be powered differently. For additional information, see Chapter 6, “Parallel
Input/Output Control.”
Typically, application systems have two separate capacitors across the power pins. In this case, there must
be a bulk electrolytic capacitor, such as a 10-μF tantalum capacitor, to provide bulk charge storage for the
overall system, and a 0.1-μF ceramic bypass capacitor located as near to the MCU power pins as practical
to suppress high-frequency noise.
VDDA and VSSA are the analog power supply pins for the MCU. This voltage source supplies power to the
ADC modules.
VREFH and VREFL pins are the voltage reference high and the voltage reference low inputs, respectively,
for the ADC module. For this MCU, VDDA shares the VREFH pin and VSSA shares the VREFL pin.
2.3.2 Oscillator
Immediately after reset, the MCU uses an internally generated clock provided by the internal clock source
(ICS) module. The ICS can be configured to run off the on-chip oscillator (ICSERCLK). The output of the
oscillator (OSCOUT) is used to run the RTC and LCD bypassing the ICS. The oscillator can be configured
to run in stop2 or stop3 modes. For more information, see Section 1.3, “System Clock Distribution,” and
Chapter 11, “Internal Clock Source (S08ICSV3).”
The oscillator (XOSC) in this MCU is a Pierce oscillator that can accommodate a crystal or ceramic
resonator. An external clock source can optionally be connected to the EXTAL input pin.
Refer to Figure 2-4 for the following discussion. RS (when used) and RF must be low-inductance resistors,
such as carbon composition resistors. Wire-wound resistors and some metal film resistors have too much
inductance. C1 and C2 normally must be high-quality ceramic capacitors that are specifically designed for
high-frequency applications.
RF provides a bias path to keep the EXTAL input in its linear range during crystal startup; its value is not
generally critical. Typical systems use 1 MΩ to 10 MΩ. Higher values are sensitive to humidity and lower
values reduce gain and (in extreme cases) could prevent startup.
C1 and C2 are typically in the 5 pF to 25 pF range and are chosen to match the requirements of a specific
crystal or resonator. Be sure to consider the printed circuit board (PCB) capacitance and the MCU pin
capacitance when selecting C1 and C2. The crystal manufacturer typically specifies a load capacitance,
which is the series combination of C1 and C2 (which are usually of the same size). As a first-order
approximation, use 10 pF as an estimate of combined pin and PCB capacitance for each oscillator pin
(EXTAL and XTAL).
2.3.3 RESET
After a power-on reset (POR), the PTC6/RESET pin defaults to RESET. Clearing RSTPE in SOPT1
configures the pin to be an output-only pin with an open-drain drive and an internal pullup device. RSTPE
is a write-once bit; so once written, it becomes read-only until the next reset. This bit is sticky and is reset
only at POR or LVD; it retains its value across other resets. When enabled, the RESET pin can be used to
reset the MCU from an external source when the pin is driven low.
Internal POR and low-voltage reset circuitry typically make external reset circuitry unnecessary. This pin
is normally connected to the standard 6-pin background debug connector, so a development system can
directly reset the MCU system. A manual external reset can be added by supplying a simple switch to
ground (pull reset pin low to force a reset).
Whenever any non-POR reset is initiated (whether from an external signal or from an internal system), the
enabled RESET pin is driven low for about 34 bus cycles. The reset circuitry decodes the cause of reset
and records it by setting a corresponding bit in the system reset status register (SRS).
NOTE
This pin does not contain a clamp diode to VDD and must not be driven
above VDD.
The voltage on the internally pulled up RESET pin, when measured, is
below VDD. The internal gates connected to this pin are pulled to VDD. If
the RESET pin is required to drive to a VDD level, an external pullup must
be used.
In EMC-sensitive applications, an external RC filter is recommended on the
RESET pin, if enabled.
After any reset, if nothing is connected to this pin, the MCU enters normal operating mode. If a debug
system is connected to the 6-pin standard background debug header, it can hold BKGD/MS low. It can do
this during a POR or after issuing a background debug force reset. This forces the MCU to active
background mode.
The BKGD/MS pin is used primarily with BDC communications, and features a custom protocol that uses
16 clock cycles of the target MCU’s BDC clock per bit time. The target MCU’s BDC clock can run as fast
as the bus clock, so no significant capacitance must be connected to the BKGD/MS pin that could interfere
with background serial communications.
Although the BKGD/MS pin is a pseudo open-drain pin, the background debug communication protocol
provides brief, actively driven, high speedup pulses to ensure fast rise times. Small capacitances from
cables and the absolute value of the internal pullup device play a minimal role in determining rise and fall
times on the BKGD/MS pin.
NOTE
Ensure this pin is not low when the part is coming out of POR or BDFR
reset. Exit from stop2 causes POR, therefore POR includes the exit from
stop2. Because the pin defaults to BKGD/MS function out of reset, a low
value on this pin while coming out of POR or BDFR causes the part to boot
into BDM mode. If this pin is not being used at all, it must be tied high. A
pullup is recommended when using this pin as GPIO.
2.3.5 IRQ
The PTF2/IRQ pin can be used as a wakeup source for the MCU. For stop2 wakeup, this pin has an analog
path which is enabled based on the input buffer enable for this pin, irrespective of whether or not this pin
is configured as IRQ.
NOTE
Care needs to be taken that if this pin is configured as input, it is not low
during stop2 mode, otherwise the part exits stop2 mode irrespective of
whether this pin is configured as IRQ or not. This pin can be disabled as a
wakeup source if it is configured as an output.
depending on the VSUPPLY bits. When VLL3 is connected to VDD externally, VSUPPLY = 11,
FCDEN = 1, and RVEN = 0, the pins operate as full complementary drive. For all other VSUPPLY modes,
the LCD/GPIO operates as open drain.
NOTE
For GPIO muxed with LCD pins, full complimentary or open drain drive is
controlled by the LCD controller. When LCD pins are configured as open
drain GPIOs, then the internal pullup is not disabled in output mode and is
controlled by the GPIO pull control register. This can cause some leakage
from the pads if a pullup is enabled and a zero is being driven.
3.2 Features
• Active background mode for code development.
• Run mode — CPU clocks can be run at full speed and the internal supply is fully regulated.
• Wait mode — CPU shuts down to conserve power; system clocks are running and full regulation
is maintained.
• Stop modes — System clocks are stopped and voltage regulator is in standby.
— Stop3 — All internal circuits are powered for fast recovery.
— Stop2 — Partial power down of internal circuits, RAM content is retained, and the I/O states
are held.
The clocks to the peripherals are controlled by SCGC registers in this mode. For lowest possible current
in WAIT mode, all peripherals which are not required must be clock gated before entering in this mode.
NOTE
When PTC6/RESET or PTF2/IRQ is used as an active low wakeup source
it must be configured as an input prior to executing a STOP instruction.
PTC6/RESET and PTF2/IRQ can be disabled as a wakeup if it is configured
as output port. For lowest power consumption in stop2, these pins must not
be left open if configured as input (enable the internal pullup or tie an
external pullup device).
Upon wakeup from stop2 mode, the MCU starts up as from a POR with the following sequence:
• All module control and status registers are reset, except for SPMSC1-SPMSC2, RTCSC,
RTCCNT, RTCMOD, LCDPENx, LCDBPENx, and LCDWFRx.
• The LVD reset function is enabled and the MCU remains in the reset state if VDD is below the LVD
trip point.
• The CPU takes the reset vector
In addition to the above, upon waking up from stop2 mode, the PPDF bit in SPMSC2 is set. This flag is
used to direct user code to go to a stop2 recovery routine. PPDF remains set and the I/O pin states remain
latched until a 1 is written to PPDACK in SPMSC2.
If using the low-power oscillator during stop2 mode, you reconfigure the ICSC2 register that contains
oscillator control bits before PPDACK is written.
To maintain I/O states for pins that were configured as GPIO before entering stop2, you restore the
contents of the I/O port registers to the port registers before writing to the PPDACK bit. If the port registers
are not restored from RAM before writing to PPDACK, then the pins are switched to their reset states when
PPDACK is written.
For pins that were configured as peripheral I/O, you reconfigure the peripheral module that interfaces to
the pin before writing to the PPDACK bit. If the peripheral module is not enabled before writing to
PPDACK, the pins are controlled by their associated port control registers when the I/O latches are opened.
If enabled, LCD functionality continues in stop2 mode and upon stop2 recovery the LCD control registers
(LCDC0, LCDC1, LCDSUPPLY, LCDRVC, LCDBCTL, and LCDS) must be re-initialized before writing
the PPDACK.
Wait
Wait Full on
Run
Stop3 Standby
2 3 Stop2 Partial powerdown
Stop3 Stop2
Figure 3-1. Allowable Power Mode Transitions for the MC9S08LG32 Series
Figure 3-1 illustrates mode state transitions allowed between the legal states shown in Table 3-1.
Table 3-3 defines triggers for the various state transitions shown in Figure 3-1.
Mode
Peripheral
Stop2 Stop3
CPU Off Standby
RAM Standby Standby
FLASH Off Standby
Port I/O Registers Off Standby
ADC Off Optionally On1
BDM Off2 Optionally On
COP Off Off
ICS Off Optionally On3
IIC Off Standby
IRQ Wake Up Optionally On
KBI Off Optionally On
4
LVD/LVW Off Optionally On
LCD Optionally On Optionally On
MTIM Off Optionally On
SCIx Off Standby
SPI Off Standby
RTC Optionally On Optionally On
TPMx Off Standby
Voltage Regulator Partial Powerdown Optionally On5
XOSC Optionally On6 Optionally On6
I/O Pins States Held Peripheral Control
1 Requires the asynchronous ADC clock. For stop3, LVD must be enabled to
run in stop if converting the bandgap channel.
2 If ENBDM is set when entering stop2, the MCU will actually enter stop3.
3 IRCLKEN and IREFSTEN set in ICSC1, else in standby.
4
If LVDSE is set when entering stop2, the MCU will actually enter stop3.
5 Requires the LVD to be enabled, else in standby. See Section 3.6.4, “LVD
Enabled in Stop Mode”.
6 ERCLKEN and EREFSTEN set in ICSC2, else in standby.
0x0000 0x0000
DIRECT PAGE REGISTERS DIRECT PAGE REGISTERS
0x005F 0x005F
0x0060 0x0060
RAM RAM
1984 BYTES 1984 BYTES
0x081F 0x081F
0x0820 0x0820
LCD Registers LCD Registers
0x085C 0x085C
0x0860 UNIMPLEMENTED 0x0860 UNIMPLEMENTED
0x17FF 4000 BYTES 0x17FF 4000 BYTES
0x1800 0x1800
HIGH PAGE REGISTERS HIGH PAGE REGISTERS
0x187A 0x187A
0x187B 0x187B
UNIMPLEMENTED
UNIMPLEMENTED
0x7FFF
0x8000
16,384 BYTES
FLASH A
0xB7FF
0xB800 FLASH A
2048 BYTES
0xC000 0xC000
16,384 BYTES
FLASHB Flash B
16,384 BYTES
0xFFFF 0xFFFF
MC9S08LG32 MC9S08LG16
Note:
0x085C-0x085F is reserved. Unlike un-implemented spaces, access to these locations would not cause illegal address
reset.
Address
Vector Vector Name
(High/Low)
0xFFC8:FFC9
Address
Vector Vector Name
(High/Low)
Register
Address Bit 7 6 5 4 3 2 1 Bit 0
Name
0x0000 PTAD PTAD7 PTAD6 PTAD5 PTAD4 PTAD3 PTAD2 PTAD1 PTAD0
0x0001 PTADD PTADD7 PTADD6 PTADD5 PTADD4 PTADD3 PTADD2 PTADD1 PTADD0
0x0002 PTBD PTBD7 PTBD6 PTBD5 PTBD4 PTBD3 PTBD2 PTBD1 PTBD0
0x0003 PTBDD PTBDD7 PTBDD6 PTBDD5 PTBDD4 PTBDD3 PTBDD2 PTBDD1 PTBDD0
0x0004 PTCD 0 PTCD6 PTCD5 PTCD4 PTCD3 PTCD2 PTCD1 PTCD0
0x0005 PTCDD 0 PTCDD6 PTCDD5 PTCDD4 PTCDD3 PTCDD2 PTCDD1 PTCDD0
0x0006 PTDD PTDD7 PTDD6 PTDD5 PTDD4 PTDD3 PTDD2 PTDD1 PTDD0
0x0007 PTDDD PTDDD7 PTDDD6 PTDDD5 PTDDD4 PTDDD3 PTDDD2 PTDDD1 PTDDD0
0x0008 IICA AD7 AD6 AD5 AD4 AD3 AD2 AD1 0
0x0009 IICF MULT ICR
0x000A IICC1 IICEN IICIE MST TX TXAK RSTA 0 0
0x000B IICS TCF IAAS BUSY ARBL 0 SRW IICIF RXAK
0x000C IICD DATA
0x000D IICC2 GCAEN ADEXT 0 0 0 AD10 AD9 AD8
0x000E PTED PTED7 PTED6 PTED5 PTED4 PTED3 PTED2 PTED1 PTED0
0x000F PTEDD PTEDD7 PTEDD6 PTEDD5 PTEDD4 PTEDD3 PTEDD2 PTEDD1 PTEDD0
0x0010 SCI1BDH LBKDIE RXEDGIE 0 SBR12 SBR11 SBR10 SBR9 SBR8
0x0011 SCI1BDL SBR7 SBR6 SBR5 SBR4 SBR3 SBR2 SBR1 SBR0
0x0012 SCI1C1 LOOPS SCISWAI RSRC M WAKE ILT PE PT
0x0013 SCI1C2 TIE TCIE RIE ILIE TE RE RWU SBK
0x0014 SCI1S1 TDRE TC RDRF IDLE OR NF FE PF
0x0015 SCI1S2 LBKDIF RXEDGIF 0 RXINV RWUID BRK13 LBKDE RAF
0x0016 SCI1C3 R8 T8 TXDIR TXINV ORIE NEIE FEIE PEIE
0x0017 SCI1D Bit 7 6 5 4 3 2 1 Bit 0
0x0018 SCI2BDH LBKDIE RXEDGIE 0 SBR12 SBR11 SBR10 SBR9 SBR8
0x0019 SCI2BDL SBR7 SBR6 SBR5 SBR4 SBR3 SBR2 SBR1 SBR0
0x001A SCI2C1 LOOPS SCISWAI RSRC M WAKE ILT PE PT
0x001B SCI2C2 TIE TCIE RIE ILIE TE RE RWU SBK
0x001C SCI2S1 TDRE TC RDRF IDLE OR NF FE PF
0x001D SCI2S2 LBKDIF RXEDGIF 0 RXINV RWUID BRK13 LBKDE RAF
0x001E SCI2C3 R8 T8 TXDIR TXINV ORIE NEIE FEIE PEIE
0x001F SCI2D Bit 7 6 5 4 3 2 1 Bit 0
0x0020 TPM2SC TOF TOIE CPWMS CLKSB CLKSA PS2 PS1 PS0
0x0021 TPM2CNTH Bit 15 14 13 12 11 10 9 Bit 8
0x0022 TPM2CNTL Bit 7 6 5 4 3 2 1 Bit 0
0x0023 TPM2MODH Bit 15 14 13 12 11 10 9 Bit 8
0x0024 TPM2MODL Bit 7 6 5 4 3 2 1 Bit 0
0x0025 TPM2C0SC CH0F CH0IE MS0B MS0A ELS0B ELS0A 0 0
0x0026 TPM2C0VH Bit 15 14 13 12 11 10 9 Bit 8
0x0027 TPM2C0VL Bit 7 6 5 4 3 2 1 Bit 0
0x0028 TPM2C1SC CH1F CH1IE MS1B MS1A ELS1B ELS1A 0 0
0x0029 TPM2C1VH Bit 15 14 13 12 11 10 9 Bit 8
Register
Address Bit 7 6 5 4 3 2 1 Bit 0
Name
0x002A TPM2C1VL Bit 7 6 5 4 3 2 1 Bit 0
0x002B TPM2C2SC CH2F CH2IE MS2B MS2A ELS2B ELS2A 0 0
0x002C TPM2C2VH Bit 15 14 13 12 11 10 9 Bit 8
0x002D TPM2C2VL Bit 7 6 5 4 3 2 1 Bit 0
0x002E TPM2C3SC CH3F CH3IE MS3B MS3A ELS3B ELS3A 0 0
0x002F TPM2C3VH Bit 15 14 13 12 11 10 9 Bit 8
0x0030 TPM2C3VL Bit 7 6 5 4 3 2 1 Bit 0
0x0031 TPM2C4SC CH4F CH4IE MS4B MS4A ELS4B ELS4A 0 0
0x0032 TPM2C4VH Bit 15 14 13 12 11 10 9 Bit 8
0x0033 TPM2C4VL Bit 7 6 5 4 3 2 1 Bit 0
0x0034 TPM2C5SC CH5F CH5IE MS5B MS5A ELS5B ELS5A 0 0
0x0035 TPM2C5VH Bit 15 14 13 12 11 10 9 Bit 8
0x0036 TPM2C5VL Bit 7 6 5 4 3 2 1 Bit 0
0x0037 IRQSC 0 IRQPDD IRQEDG IRQPE IRQF IRQACK IRQIE IRQMOD
0x0038 LCDC0 LCDEN SOURCE LCLK2 LCLK1 LCLK0 DUTY2 DUTY1 DUTY0
0x0039 LCDC1 LCDIEN 0 0 0 0 FCDEN LCDWAI LCDSTP
0x003A LCDSUPPLY CPSEL HREFSEL LADJ1 LADJ0 0 BBYPASS VSUPPLY1 VSUPPLY0
0x003B LCDRVC RVEN 0 0 0 RVTRIM3 RVTRIM2 RVTRIM1 RVTRIM0
0x003C LCDBCTL BLINK ALT BLANK 0 BMODE BRATE2 BRATE1 BRATE0
0x003D LCDS LCDIF 0 0 0 0 0 0 0
0x003E PTFD PTFD7 PTFD6 PTFD5 PTFD4 PTFD3 PTFD2 PTFD1 PTFD0
0x003F PTFDD PTFDD7 PTFDD6 PTFDD5 PTFDD4 PTFDD3 PTFDD2 PTFDD1 PTFDD0
0x0040 TPM1SC TOF TOIE CPWMS CLKSB CLKSA PS2 PS1 PS0
0x0041 TPM1CNTH Bit 15 14 13 12 11 10 9 Bit 8
0x0042 TPM1CNTL Bit 7 6 5 4 3 2 1 Bit 0
0x0043 TPM1MODH Bit 15 14 13 12 11 10 9 Bit 8
0x0044 TPM1MODL Bit 7 6 5 4 3 2 1 Bit 0
0x0045 TPM1C0SC CH0F CH0IE MS0B MS0A ELS0B ELS0A 0 0
0x0046 TPM1C0VH Bit 15 14 13 12 11 10 9 Bit 8
0x0047 TPM1C0VL Bit 7 6 5 4 3 2 1 Bit 0
0x0048 TPM1C1SC CH1F CH1IE MS1B MS1A ELS1B ELS1A 0 0
0x0049 TPM1C1VH Bit 15 14 13 12 11 10 9 Bit 8
0x004A TPM1C1VL Bit 7 6 5 4 3 2 1 Bit 0
0x004B ADCSC1 COCO AIEN ADCO ADCH
0x004C ADCSC2 ADACT ADTRG ACFE ACFGT 0 0 — —
0x004D ADCRH 0 0 0 0 ADR11 ADR10 ADR9 ADR8
0x004E ADCRL ADR7 ADR6 ADR5 ADR4 ADR3 ADR2 ADR1 ADR0
0x004F ADCCVH 0 0 0 0 ADCV11 ADCV10 ADCV9 ADCV8
0x0050 ADCCVL ADCV7 ADCV6 ADCV5 ADCV4 ADCV3 ADCV2 ADCV1 ADCV0
0x0051 ADCCFG ADLPC ADIV ADLSMP MODE ADICLK
0x0052 APCTL1 ADPC7 ADPC6 ADPC5 ADPC4 ADPC3 ADPC2 ADPC1 ADPC0
0x0053 APCTL2 ADPC15 ADPC14 ADPC13 ADPC12 ADPC11 ADPC10 ADPC9 ADPC8
Register
Address Bit 7 6 5 4 3 2 1 Bit 0
Name
0x0054 PTGD PTGD7 PTGD6 PTGD5 PTGD4 PTGD3 PTGD2 PTGD1 PTGD0
0x0055 PTGDD PTGDD7 PTGDD6 PTGDD5 PTGDD4 PTGDD3 PTGDD2 PTGDD1 PTGDD0
0x0056 PTHD PTHD7 PTHD6 PTHD5 PTHD4 PTHD3 PTHD2 PTHD1 PTHD0
0x0057 PTHDD PTHDD7 PTHDD6 PTHDD5 PTHDD4 PTHDD3 PTHDD2 PTHDD1 PTHDD0
0x0058 SPIC1 SPIE SPE SPTIE MSTR CPOL CPHA SSOE LSBFE
0x0059 SPIC2 0 0 0 MODFEN BIDIROE 0 SPISWAI SPC0
0x005A SPIBR 0 SPPR2 SPPR1 SPPR0 SPR3 SPR2 SPR1 SPR0
0x005B SPIS SPRF 0 SPTEF MODF 0 0 0 0
0x005C Reserved 0 0 0 0 0 0 0 0
0x005D SPID Bit 7 6 5 4 3 2 1 Bit 0
0x005E PTID 0 0 PTID5 PTID4 PTID3 PTID2 PTID1 PTID0
0x005F PTIDD 0 0 PTIDD5 PTIDD4 PTIDD3 PTIDD2 PTIDD1 PTIDD0
Use the LCD registers shown in table below to enable LCD functionality and display the LCD data.
Table 4-3. LCD Registers (Sheet 1 of 2)
Register
Address Bit 7 6 5 4 3 2 1 Bit 0
Name
0x0820 LCDPEN0 PEN7 PEN6 PEN5 PEN4 PEN3 PEN2 PEN1 PEN0
0x0821 LCDPEN1 PEN15 PEN14 PEN13 PEN12 PEN11 PEN10 PEN9 PEN8
0x0822 LCDPEN2 PEN23 PEN22 PEN21 PEN20 PEN19 PEN18 PEN17 PEN16
0x0823 LCDPEN3 PEN31 PEN30 PEN29 PEN28 PEN27 PEN26 PEN25 PEN24
0x0824 LCDPEN4 PEN39 PEN38 PEN37 PEN36 PEN35 PEN34 PEN33 PEN32
0x0825 LCDPEN5 — — — PEN44 PEN43 PEN42 PEN41 PEN40
0x0826 Reserved — — — — — — — —
0x0827 — — — — — — — —
0x0828 LCDBPEN0 BPEN7 BPEN6 BPEN5 BPEN4 BPEN3 BPEN2 BPEN1 BPEN0
0x0829 LCDBPEN1 BPEN15 BPEN14 BPEN13 BPEN12 BPEN11 BPEN10 BPEN9 BPEN8
0x082A LCDBPEN2 BPEN23 BPEN22 BPEN21 BPEN20 BPEN19 BPEN18 BPEN17 BPEN16
0x082B LCDBPEN3 BPEN31 BPEN30 BPEN29 BPEN28 BPEN27 BPEN26 BPEN25 BPEN24
0x082C LCDBPEN4 BPEN39 BPEN38 BPEN37 BPEN36 BPEN35 BPEN34 BPEN33 BPEN32
0x082D LCDBPEN5 — — — BPEN44 BPEN43 BPEN42 BPEN41 BPEN40
0x082E Reserved — — — — — — — —
0x082F — — — — — — — —
0x0830 LCDWF0 BPHLCD0 BPGLCD0 BPFLCD0 BPELCD0 BPDLCD0 BPCLCD0 BPBLCD0 BPALCD0
0x0831 LCDWF1 BPHLCD1 BPGLCD1 BPFLCD1 BPELCD1 BPDLCD1 BPCLCD1 BPBLCD1 BPALCD1
0x0832 LCDWF2 BPHLCD2 BPGLCD2 BPFLCD2 BPELCD2 BPDLCD2 BPCLCD2 BPBLCD2 BPALCD2
0x0833 LCDWF3 BPHLCD3 BPGLCD3 BPFLCD3 BPELCD3 BPDLCD3 BPCLCD3 BPBLCD3 BPALCD3
0x0834 LCDWF4 BPHLCD4 BPGLCD4 BPFLCD4 BPELCD4 BPDLCD4 BPCLCD4 BPBLCD4 BPALCD4
0x0835 LCDWF5 BPHLCD5 BPGLCD5 BPFLCD5 BPELCD5 BPDLCD5 BPCLCD5 BPBLCD5 BPALCD5
0x0836 LCDWF6 BPHLCD6 BPGLCD6 BPFLCD6 BPELCD6 BPDLCD6 BPCLCD6 BPBLCD6 BPALCD6
0x0837 LCDWF7 BPHLCD7 BPGLCD7 BPFLCD7 BPELCD7 BPDLCD7 BPCLCD7 BPBLCD7 BPALCD7
0x0838 LCDWF8 BPHLCD8 BPGLCD8 BPFLCD8 BPELCD8 BPDLCD8 BPCLCD8 BPBLCD8 BPALCD8
Register
Address Bit 7 6 5 4 3 2 1 Bit 0
Name
0x0839 LCDWF9 BPHLCD9 BPGLCD9 BPFLCD9 BPELCD9 BPDLCD9 BPCLCD9 BPBLCD9 BPALCD9
0x083A LCDWF10 BPHLCD10 BPGLCD10 BPFLCD10 BPELCD10 BPDLCD10 BPCLCD10 BPBLCD10 BPALCD10
0x083B LCDWF11 BPHLCD11 BPGLCD11 BPFLCD11 BPELCD11 BPDLCD11 BPCLCD11 BPBLCD11 BPALCD11
0x083C LCDWF12 BPHLCD12 BPGLCD12 BPFLCD12 BPELCD12 BPDLCD12 BPCLCD12 BPBLCD12 BPALCD12
0x083D LCDWF13 BPHLCD13 BPGLCD13 BPFLCD13 BPELCD13 BPDLCD13 BPCLCD13 BPBLCD13 BPALCD13
0x083E LCDWF14 BPHLCD14 BPGLCD14 BPFLCD14 BPELCD14 BPDLCD14 BPCLCD14 BPBLCD14 BPALCD14
0x083F LCDWF15 BPHLCD15 BPGLCD15 BPFLCD15 BPELCD15 BPDLCD15 BPCLCD15 BPBLCD15 BPALCD15
0x0840 LCDWF16 BPHLCD16 BPGLCD16 BPFLCD16 BPELCD16 BPDLCD16 BPCLCD16 BPBLCD16 BPALCD16
0x0841 LCDWF17 BPHLCD17 BPGLCD17 BPFLCD17 BPELCD17 BPDLCD17 BPCLCD17 BPBLCD17 BPALCD17
0x0842 LCDWF18 BPHLCD18 BPGLCD18 BPFLCD18 BPELCD18 BPDLCD18 BPCLCD18 BPBLCD18 BPALCD18
0x0843 LCDWF19 BPHLCD19 BPGLCD19 BPFLCD19 BPELCD19 BPDLCD19 BPCLCD19 BPBLCD19 BPALCD19
0x0844 LCDWF20 BPHLCD20 BPGLCD20 BPFLCD20 BPELCD20 BPDLCD20 BPCLCD20 BPBLCD20 BPALCD20
0x0845 LCDWF21 BPHLCD21 BPGLCD21 BPFLCD21 BPELCD21 BPDLCD21 BPCLCD21 BPBLCD21 BPALCD21
0x0846 LCDWF22 BPHLCD22 BPGLCD22 BPFLCD22 BPELCD22 BPDLCD22 BPCLCD22 BPBLCD22 BPALCD22
0x0847 LCDWF23 BPHLCD23 BPGLCD23 BPFLCD23 BPELCD23 BPDLCD23 BPCLCD23 BPBLCD23 BPALCD23
0x0848 LCDWF24 BPHLCD24 BPGLCD24 BPFLCD24 BPELCD24 BPDLCD24 BPCLCD24 BPBLCD24 BPALCD24
0x0849 LCDWF25 BPHLCD25 BPGLCD25 BPFLCD25 BPELCD25 BPDLCD25 BPCLCD25 BPBLCD25 BPALCD25
0x084A LCDWF26 BPHLCD26 BPGLCD26 BPFLCD26 BPELCD26 BPDLCD26 BPCLCD26 BPBLCD26 BPALCD26
0x084B LCDWF27 BPHLCD27 BPGLCD27 BPFLCD27 BPELCD27 BPDLCD27 BPCLCD27 BPBLCD27 BPALCD27
0x084C LCDWF28 BPHLCD28 BPGLCD28 BPFLCD28 BPELCD28 BPDLCD28 BPCLCD28 BPBLCD28 BPALCD28
0x084D LCDWF29 BPHLCD29 BPGLCD29 BPFLCD29 BPELCD29 BPDLCD29 BPCLCD29 BPBLCD29 BPALCD29
0x084E LCDWF30 BPHLCD30 BPGLCD30 BPFLCD30 BPELCD30 BPDLCD30 BPCLCD30 BPBLCD30 BPALCD30
0x084F LCDWF31 BPHLCD31 BPGLCD31 BPFLCD31 BPELCD31 BPDLCD31 BPCLCD31 BPBLCD31 BPALCD31
0x0850 LCDWF32 BPHLCD32 BPGLCD32 BPFLCD32 BPELCD32 BPDLCD32 BPCLCD32 BPBLCD32 BPALCD32
0x0851 LCDWF33 BPHLCD33 BPGLCD33 BPFLCD33 BPELCD33 BPDLCD33 BPCLCD33 BPBLCD33 BPALCD33
0x0852 LCDWF34 BPHLCD34 BPGLCD34 BPFLCD34 BPELCD34 BPDLCD34 BPCLCD34 BPBLCD34 BPALCD34
0x0853 LCDWF35 BPHLCD35 BPGLCD35 BPFLCD35 BPELCD35 BPDLCD35 BPCLCD35 BPBLCD35 BPALCD35
0x0854 LCDWF36 BPHLCD36 BPGLCD36 BPFLCD36 BPELCD36 BPDLCD36 BPCLCD36 BPBLCD36 BPALCD36
0x0855 LCDWF37 BPHLCD37 BPGLCD37 BPFLCD37 BPELCD37 BPDLCD37 BPCLCD37 BPBLCD37 BPALCD37
0x0856 LCDWF38 BPHLCD38 BPGLCD38 BPFLCD38 BPELCD38 BPDLCD38 BPCLCD38 BPBLCD38 BPALCD38
0x0857 LCDWF39 BPHLCD39 BPGLCD39 BPFLCD39 BPELCD39 BPDLCD39 BPCLCD39 BPBLCD39 BPALCD39
0x0858 LCDWF40 BPHLCD40 BPGLCD40 BPFLCD40 BPELCD40 BPDLCD40 BPCLCD40 BPBLCD40 BPALCD40
0x0859 LCDWF41 BPHLCD41 BPGLCD41 BPFLCD41 BPELCD41 BPDLCD41 BPCLCD41 BPBLCD41 BPALCD41
0x085A LCDWF42 BPHLCD42 BPGLCD42 BPFLCD42 BPELCD42 BPDLCD42 BPCLCD42 BPBLCD42 BPALCD42
0x085B LCDWF43 BPHLCD43 BPGLCD43 BPFLCD43 BPELCD43 BPDLCD43 BPCLCD43 BPBLCD43 BPALCD43
0x085C LCDWF44 BPHLCD44 BPGLCD44 BPFLCD44 BPELCD44 BPDLCD44 BPCLCD44 BPBLCD44 BPALCD44
High-page registers, shown in Table 4-4, are accessed much less often than other I/O and control registers
so they have been located outside the direct addressable memory space, starting at 0x1800.
Provided the key enable (KEYEN) bit is 1, the 8-byte comparison key can be used to temporarily
disengage memory security. This key mechanism can be accessed only through user code running in secure
memory. (A security key cannot be entered directly through background debug commands.) This security
key can be disabled completely by programming the KEYEN bit to 0. If the security key is disabled, the
only way to disengage security is by mass erasing the flash if needed (normally through the background
debug interface) and verifying that flash is blank. To avoid returning to secure mode after the next reset,
program the security bits (SEC) to the unsecured state (1:0).
4.5 RAM
The MC9S08LG32 series includes static RAM. The locations in RAM below 0x0100 can be accessed
using the more efficient direct addressing mode, and any single bit in this area can be accessed with the bit
manipulation instructions (BCLR, BSET, BRCLR, and BRSET). Locating the most frequently accessed
program variables in this area of RAM is preferred.
At power-on, the contents of RAM are uninitialized. RAM data is unaffected by any reset provided that
the supply voltage does not drop below the minimum value for RAM retention (VRAM).
For compatibility with M68HC05 MCUs, the HCS08 resets the stack pointer to 0x00FF. In the
MC9S08LG32 series, it is usually best to reinitialize the stack pointer to the top of the RAM so the direct
page RAM can be used for frequently accessed RAM variables and bit-addressable program variables.
Include the following 2-instruction sequence in your reset initialization routine (where RamLast is equated
to the highest address of the RAM in the Freescale Semiconductor-provided equate file).
LDHX #RamLast+1 ;point one past RAM
TXS ;SP<-(H:X-1)
When security is enabled, the RAM is considered a secure memory resource and is not accessible through
background debug mode (BDM) or through code executing from non-secure memory. See Section 4.7,
“Security,” for a detailed description of the security feature.
4.6 Flash
The flash memory is intended primarily for program storage. In-circuit programming allows the operating
program to be loaded into the flash memory after final assembly of the application product. It is possible
to program the entire array through the single-wire background debug interface. Because no special
voltages are needed for flash erase and programming operations, in-application programming is also
possible through other software-controlled communication paths. For a more detailed discussion of
in-circuit and in-application programming, refer to the HCS08 Family Reference Manual, Volume I,
Freescale Semiconductor document order number HCS08RMv1/D.
Because the MC9S08LG32 series contains two flash arrays, program and erase operations can be
conducted on one array while executing code from the other. The security and protection features treat the
two arrays as a single memory entity. Programming and erasing of each flash array is conducted through
the same command interface detailed in the following sections.
It is not possible to page erase or program both arrays at the same time. The mass erase command erases
both arrays, and the blank check command checks both arrays.
4.6.1 Features
Features of the flash memory include:
• Flash size
— MC9S08LG32: 32,768 bytes (16,384 bytes in Flash A, 16,384 bytes in Flash B)
— MC9S08LG16: 18,432 bytes (2,048 bytes in Flash A, 16,384 in Flash B)
• Single power supply program and erase
• Command interface for fast program and erase operation
• Up to 100,000 program/erase cycles at typical voltage and temperature
• Flexible block protection
• Security feature for flash and RAM
• Auto power-down for low-frequency read accesses
(1)
WRITE TO FCDIV (1) Required only once after reset.
0
FACCERR?
1
CLEAR ERROR
WRITE TO FLASH
TO BUFFER ADDRESS AND DATA
FPVIOL OR YES
FACCERR? ERROR EXIT
NO
0
FCCF?
1
DONE
The first byte of a series of sequential bytes being programmed in burst mode takes the same amount of
time to program as a byte programmed in standard mode. The subsequent bytes program in the burst
program time provided that the conditions above are met. In the case where the next sequential address is
the beginning of a new row, the program time for that byte is the standard time instead of the burst time.
This is because the high voltage to the array must be disabled and then enabled again. If a new burst
command has not been queued before the current command completes, then the charge pump is disabled
and the high voltage removed from the array.
(1)
WRITE TO FCDIV (1) Required only once after reset.
0
FACCERR?
1
CLEAR ERROR
0
FCBEF?
1
WRITE TO FLASH
TO BUFFER ADDRESS AND DATA
FPVIO OR YES
FACCERR? ERROR EXIT
NO
YES
NEW BURST COMMAND?
NO
0 FCCF?
1
DONE
FPS bits must be set to 1111 100, which results in the value 0xF9FF as the last address of unprotected
memory. In addition to programming the FPS bits to the appropriate value, FPDIS (bit 0 of NVPROT)
must be programmed to logic 0 to enable block protection. Therefore the value 0xF8 must be programmed
into NVPROT to protect addresses 0xFA00 through 0xFFFF.
One use of block protection is to block protect an area of flash memory for a bootloader program. This
bootloader program then can be used to erase the rest of the flash memory and reprogram it. Because the
bootloader is protected, it remains intact even if MCU power is lost in the middle of an erase and
reprogram operation.
4.7 Security
The MC9S08LG32 series includes circuitry to prevent unauthorized access to the contents of flash and
RAM memory. When security is engaged, flash and RAM are considered secure resources. Direct-page
registers, high-page registers, and the background debug controller are considered unsecured resources.
Programs executing within secure memory have normal access to any MCU memory locations and
resources. Attempts to access a secure memory location with a program executing from an unsecured
memory space or through the background debug interface are blocked (writes are ignored and reads return
all 0s).
Security is engaged or disengaged based on the state of two nonvolatile register bits (SEC01:SEC00) in
the FOPT register. During reset, the contents of the nonvolatile location NVOPT are copied from flash into
the working FOPT register in high-page register space. To engage security, program the NVOPT location.
You can do this at the same time the flash memory is programmed. The 1:0 state disengages security and
the other three combinations engage security. Notice the erased state (1:1) makes the MCU secure. During
development, whenever the flash is erased, you must immediately program the SEC00 bit to 0 in NVOPT
so SEC01:SEC00 = 1:0. This allows the MCU to remain unsecured after a subsequent reset.
The on-chip debug module cannot be enabled while the MCU is secure. The separate background debug
controller can still be used for background memory access commands of unsecured resources.
You can choose to allow or disallow a security unlocking mechanism through an 8-byte backdoor security
key. If the nonvolatile KEYEN bit in NVOPT/FOPT is 0, the backdoor key is disabled and there is no way
to disengage security without completely erasing all flash locations. If KEYEN is 1, a secure user program
can temporarily disengage security by:
1. Writing 1 to KEYACC in the FCNFG register. This makes the flash module interpret writes to the
backdoor comparison key locations (NVBACKKEY through NVBACKKEY+7) as values to be
compared against the key rather than as the first step in a flash program or erase command.
2. Writing the user-entered key values to the NVBACKKEY through NVBACKKEY+7 locations.
These writes must be done in order starting with the value for NVBACKKEY and ending with
NVBACKKEY+7. STHX must not be used for these writes because these writes cannot be done
on adjacent bus cycles. User software normally would get the key codes from outside the MCU
system through a communication interface such as a serial I/O.
3. Writing 0 to KEYACC in the FCNFG register. If the 8-byte key that was just written matches the
key stored in the flash locations, SEC01:SEC00 are automatically changed to 1:0 and security
disengages until the next reset.
The security key can be written only from secure memory (either RAM or flash), so it cannot be entered
through background commands without the cooperation of a secure user program.
The backdoor comparison key (NVBACKKEY through NVBACKKEY+7) is located in flash memory
locations in the nonvolatile register space so users can program these locations exactly as they would
program any other flash memory location. The nonvolatile registers are in the same 512-byte block of flash
as the reset and interrupt vectors, so block protecting that space also block protects the backdoor
comparison key. Block protects cannot be changed from user application programs, so if the vector space
is block protected, the backdoor security key mechanism cannot permanently change the block protect,
security settings, or the backdoor key.
Security can always be disengaged through the background debug interface by taking these steps:
1. Disable any block protections by writing FPROT. FPROT can be written only with background
debug commands, not from application software.
2. Mass erase flash if necessary.
3. Blank check flash. Provided flash is completely erased, security is disengaged until the next reset.
To avoid returning to secure mode after the next reset, program NVOPT so SEC01:SEC00 = 1:0.
control registers (FOPT, FPROT) at reset. There is also an 8-byte comparison key in flash memory. Refer
to Table 4-4 and Table 4-5 for the absolute address assignments for all flash registers. This section refers
to registers and control bits only by their names. A Freescale Semiconductor-provided equate or header
file is normally used to translate these names into the appropriate absolute addresses.
7 6 5 4 3 2 1 0
R DIVLD
PRDIV8 DIV
W
Reset 0 0 0 0 0 0 0 0
= Unimplemented or Reserved
Field Description
7 Divisor Loaded Status Flag — When set, this read-only status flag indicates that the FCDIV register has been
DIVLD written since reset. Reset clears this bit and the first write to this register causes this bit to become set regardless
of the data written.
0 FCDIV has not been written since reset; erase and program operations disabled for flash.
1 FCDIV has been written since reset; erase and program operations enabled for flash.
5:0 Divisor for Flash Clock Divider — The flash clock divider divides the bus rate clock (or the bus rate clock
DIV divided by 8 if PRDIV8 = 1) by the value in the 6-bit DIV field plus one. The resulting frequency of the internal
flash clock must fall within the range of 200 kHz to 150 kHz for proper flash operations. Program/Erase timing
pulses are one cycle of this internal flash clock which corresponds to a range of 5 μs to 6.7 μs. The automated
programming logic uses an integer number of these pulses to complete an erase or program operation. See
Equation 4-1 and Equation 4-2.
Table 4-8 shows the appropriate values for PRDIV8 and DIV for selected bus frequencies.
7 6 5 4 3 2 1 0
Reset This register is loaded from nonvolatile location NVOPT during reset.
= Unimplemented or Reserved
Field Description
7 Backdoor Key Mechanism Enable — When this bit is 0, the backdoor key mechanism cannot be used to
KEYEN disengage security. The backdoor key mechanism is accessible only from the user (secured) firmware. BDM
commands cannot be used to write key comparison values that would unlock the backdoor key. For more detailed
information about the backdoor key mechanism, refer to Section 4.7, “Security.”
0 No backdoor key access allowed.
1 If user firmware writes an 8-byte value that matches the nonvolatile backdoor key (NVBACKKEY through
NVBACKKEY+7 in that order), security is temporarily disengaged until the next MCU reset.
6 Vector Redirection Disable — When this bit is 1, then vector redirection is disabled.
FNORED 0 Vector redirection enabled.
1 Vector redirection disabled.
1:0 Security State Code — This 2-bit field determines the security state of the MCU as shown in Table 4-10. When
SEC0[1:0] the MCU is secure, the contents of RAM and flash memory cannot be accessed by instructions from any
unsecured source including the background debug interface. SEC01:SEC00 changes to 1:0 after successful
backdoor key entry or a successful blank check of flash.
For more detailed information about security, refer to Section 4.7, “Security.”
SEC01:SEC00 Description
0:0 secure
0:1 secure
1:0 unsecured
1:1 secure
1
SEC01:SEC00 changes to 1:0 after successful backdoor
key entry or a successful blank check of flash.
7 6 5 4 3 2 1 0
R 0 0 0 0 0 0 0
KEYACC
W
Reset 0 0 0 0 0 0 0 0
= Unimplemented or Reserved
Field Description
5 Enable Writing of Access Key — This bit enables writing of the backdoor comparison key. For more detailed
KEYACC information about the backdoor key mechanism, refer to Section 4.7, “Security.”
0 Writes to flash are interpreted as the start of a flash programming or erase command.
1 Writes to NVBACKKEY (0xFFB0–0xFFB7) are interpreted as comparison key writes while writes to rest of the
flash are ignored.
R
FPS(1) FPDIS(1)
W
Reset This register is loaded from nonvolatile location NVPROT during reset.
1
Background commands can be used to change the contents of these bits in FPROT.
Field Description
7:1 Flash Protect Select Bits — When FPDIS = 0, this 7-bit field determines the ending address of unprotected
FPS flash locations at the high address end of the flash. Protected flash locations cannot be erased or programmed.
R FCCF 0 FBLANK 0 0
FCBEF FPVIOL FACCERR
W
Reset 1 1 0 0 0 0 0 0
= Unimplemented or Reserved
Field Description
7 Flash Command Buffer Empty Flag — The FCBEF bit is used to launch commands. It also indicates that the
FCBEF command buffer is empty so that a new command sequence can be executed when performing burst
programming. The FCBEF bit is cleared by writing a 1 to it or when a burst program command is transferred to
the array for programming. Only burst program commands can be buffered.
0 Command buffer is full (not ready for additional commands).
1 A new burst program command can be written to the command buffer.
6 Flash Command Complete Flag — FCCF is set automatically when the command buffer is empty and no
FCCF command is being processed. FCCF is cleared automatically when a new command is started (by writing 1 to
FCBEF to register a command). Writing to FCCF has no meaning or effect.
0 Command in progress
1 All commands complete
5 Protection Violation Flag — FPVIOL is set automatically when a command is written that attempts to erase or
FPVIOL program a location in a protected block (the erroneous command is ignored). FPVIOL is cleared by writing a 1 to
FPVIOL.
0 No protection violation.
1 An attempt was made to erase or program a protected location.
Field Description
4 Access Error Flag — FACCERR is set automatically when the proper command sequence is not obeyed exactly
FACCERR (the erroneous command is ignored), if a program or erase operation is attempted before the FCDIV register has
been initialized, or if the MCU enters stop while a command was in progress. For a more detailed discussion of
the exact actions that are considered access errors, see Section 4.6.5, “Access Errors.” FACCERR is cleared by
writing a 1 to FACCERR. Writing a 0 to FACCERR has no meaning or effect.
0 No access error.
1 An access error has occurred.
2 Flash Verified as All Blank (erased) Flag — FBLANK is set automatically at the conclusion of a blank check
FBLANK command if the entire flash array was verified to be erased. FBLANK is cleared by clearing FCBEF to write a new
valid command. Writing to FBLANK has no meaning or effect.
0 After a blank check command is completed and FCCF = 1, FBLANK = 0 indicates the flash array is not
completely erased.
1 After a blank check command is completed and FCCF = 1, FBLANK = 1 indicates the flash array is completely
erased (all 0xFF).
R 0 0 0 0 0 0 0 0
W FCMD
Reset 0 0 0 0 0 0 0 0
All other command codes are illegal and generate an access error.
It is not necessary to perform a blank check command after a mass erase operation. Only blank check is
required as part of the security unlocking mechanism.
5.2 Features
Reset and interrupt features include:
• Multiple sources of reset for flexible system configuration and reliable operation
• Reset status register (SRS) to indicate source of most recent reset
• Separate interrupt vector for all modules (reduces polling overhead) (see Table 5-2)
Control Bits
Clock Source COP Overflow Count
COPCLKS COPT
Even if your application uses the reset default settings of COPE, COPCLKS, and COPT; you must write
to the write-once SOPT1 and SOPT2 registers, during reset initialization, to lock in the settings. That way,
the settings cannot be changed accidentally if the application program gets lost. The initial writes to SOPT1
and SOPT2 reset the COP counter.
The write to SRS that services (clears) the COP counter must not be placed in an interrupt service routine
(ISR) because the ISR could continue to be executed periodically even if the main application program
fails.
In background debug mode, the COP counter does not increment.
When the bus clock source is selected, the COP counter does not increment while the system is in stop
mode. The COP counter resumes as soon as the MCU exits stop mode.
When the 1 kHz clock source is selected, the COP counter is re-initialized to zero upon entry to stop mode.
The COP counter begins from zero after the MCU exits stop mode.
5.5 Interrupts
Interrupts provide a way to save the current CPU status and registers, execute an interrupt service routine
(ISR), and then restore the CPU status so processing can resume where it left off before the interrupt. Other
than the software interrupt (SWI), which is a program instruction, interrupts are caused by hardware events
such as an edge on the IRQ pin or a timer-overflow event. The debug module can also generate an SWI
under certain circumstances.
If an event occurs in an enabled interrupt source, an associated read-only status flag is set. The CPU does
not respond unless the local interrupt enable is a 1 (enabled) and the I bit in the CCR is 0 to allow interrupts.
The global interrupt mask (I bit) in the CCR is initially set after reset which prevents all maskable interrupt
sources. The user program initializes the stack pointer and performs other system setup before clearing the
I bit to allow the CPU to respond to interrupts.
When the CPU receives a qualified interrupt request, it completes the current instruction before responding
to the interrupt. The interrupt sequence obeys the same cycle-by-cycle sequence as the SWI instruction
and consists of:
• Saving the CPU registers on the stack
• Setting the I bit in the CCR to mask further interrupts
• Fetching the interrupt vector for the highest-priority interrupt that is currently pending
• Filling the instruction queue with the first three bytes of program information starting from the
address fetched from the interrupt vector locations
While the CPU is responding to the interrupt, the I bit is automatically set to avoid the possibility of
another interrupt interrupting the ISR itself (this is called nesting of interrupts). Normally, the I bit is
restored to 0 when the CCR is restored from the value stacked on entry to the ISR. In rare cases, the I bit
can be cleared inside an ISR (after clearing the status flag that generated the interrupt) so that other
interrupts can be serviced without waiting for the first service routine to finish. This practice is not
recommended for anyone other than the most experienced programmers because it can lead to subtle
program errors that are difficult to debug.
The interrupt service routine ends with a return-from-interrupt (RTI) instruction which restores the CCR,
A, X, and PC registers to their pre-interrupt values by reading the previously saved information from the
stack.
NOTE
For compatibility with M68HC08 devices, the H register is not
automatically saved and restored. It is good programming practice to push
H onto the stack at the start of the interrupt service routine (ISR) and restore
it immediately before the RTI that is used to return from the ISR.
If more than one interrupt is pending when the I bit is cleared, the highest priority source is serviced first
(see Table 5-2).
7 ² 0
SP AFTER
INTERRUPT STACKING
5 1 CONDITION CODE REGISTER
4 2 ACCUMULATOR
3 3 INDEX REGISTER (LOW BYTE X)*
2 4 PROGRAM COUNTER HIGH
SP BEFORE
1 5 PROGRAM COUNTER LOW
THE INTERRUPT
²
²
STACKING TOWARD HIGHER ADDRESSES
ORDER ²
* High byte (H) of index register is not automatically stacked.
When an RTI instruction is executed, these values are recovered from the stack in reverse order. As part
of the RTI sequence, the CPU fills the instruction pipeline by reading three bytes of program information,
starting from the PC address recovered from the stack.
The status flag corresponding to the interrupt source must be acknowledged (cleared) before returning
from the ISR. Typically, the flag is cleared at the beginning of the ISR so that if another interrupt is
generated by this same source it is registered so it can be serviced after completion of the current ISR.
The IRQ pin, when enabled, defaults to use an internal pull device (IRQPDD = 0), configured as a pullup
or pulldown depending on the polarity chosen. If the user desires to use an external pullup or pulldown,
the IRQPDD can be written to a 1 to turn off the internal device.
BIH and BIL instructions may be used to detect the level on the IRQ pin when the pin is configured to act
as the IRQ input.
NOTE
User software must disable the peripheral before disabling the clocks to the
peripheral. When clocks are re-enabled to a peripheral, the peripheral
registers need to be re-initialized by user software.
In stop modes, the bus clock is disabled for all gated peripherals, regardless of the settings in SCGC1 and
SCGC2.
5.8 Reset, Interrupt, and System Control Registers and Control Bits
One 8-bit register in the direct page register space and fourteen 8-bit registers in the high-page register
space are related to reset and interrupt systems.
Refer to Table 4-2 and Table 4-4 in Chapter 4, “Memory,” for the absolute address assignments for all
registers. This section refers to registers and control bits only by their names. A Freescale-provided equate
or header file is used to translate these names into the appropriate absolute addresses.
Some control bits in the SOPT1 and SPMSC2 registers are related to modes of operation. Although brief
descriptions of these bits are provided here, the related functions are discussed in greater detail in
Chapter 3, “Modes of Operation.”
R 0 IRQF 0
IRQPDD IRQEDG IRQPE IRQIE IRQMOD
W IRQACK
Reset 0 0 0 0 0 0 0 0
= Unimplemented or Reserved
Field Description
6 Interrupt Request (IRQ) Pull Device Disable — This read/write control bit is used to disable the internal
IRQPDD pullup/pulldown device when the IRQ pin is enabled (IRQPE = 1) allowing for an external device to be used.
0 IRQ pull device enabled if IRQPE = 1.
1 IRQ pull device disabled if IRQPE = 1.
5 Interrupt Request (IRQ) Edge Select — This read/write control bit is used to select the polarity of edges or
IRQEDG levels on the IRQ pin that cause IRQF to be set. The IRQMOD control bit determines whether the IRQ pin is
sensitive to both edges and levels or only edges. When IRQEDG = 1 and the internal pull device is enabled, the
pullup device is reconfigured as an optional pulldown device.
0 IRQ is falling edge or falling edge/low-level sensitive.
1 IRQ is rising edge or rising edge/high-level sensitive.
Field Description
4 IRQ Pin Enable — This read/write control bit enables the IRQ pin function. When this bit is set the IRQ pin can
IRQPE be used as an interrupt request.
0 IRQ pin function is disabled.
1 IRQ pin function is enabled.
3 IRQ Flag — This read-only status bit indicates when an interrupt request event has occurred.
IRQF 0 No IRQ request.
1 IRQ event detected.
2 IRQ Acknowledge — This write-only bit is used to acknowledge interrupt request events (write 1 to clear IRQF).
IRQACK Writing 0 has no meaning or effect. Reads always return 0. If edge-and-level detection is selected (IRQMOD = 1),
IRQF cannot be cleared while the IRQ pin remains at its asserted level.
1 IRQ Interrupt Enable — This read/write control bit determines whether IRQ events generate an interrupt
IRQIE request.
0 Interrupt request when IRQF set is disabled (use polling).
1 Interrupt requested whenever IRQF = 1.
0 IRQ Detection Mode — This read/write control bit selects either edge-only detection or edge-and-level
IRQMOD detection. The IRQEDG control bit determines the polarity of edges and levels that are detected as interrupt
request events. See Section 5.5.2.2, “Edge and Level Sensitivity,” for more details.
0 IRQ event on falling edges or rising edges only.
1 IRQ event on falling edges and low levels or on rising edges and high levels.
7 6 5 4 3 2 1 0
1
u = unaffected
2
Any of these reset sources that are active at the time of reset entry causes the corresponding bit(s) to be set; bits corresponding
to sources that are not active at the time of reset entry are cleared.
Figure 5-3. System Reset Status (SRS)
Field Description
7 Power-On Reset — Reset was caused by the power-on detection logic. Because the internal supply voltage was
POR ramping up at the time, the low-voltage reset (LVD) status bit is also set to indicate that the reset occurred while
the internal supply was below the LVD threshold.
0 Reset not caused by POR.
1 POR caused reset.
6 External Reset Pin — Reset was caused by an active-low level on the external reset pin.
PIN 0 Reset not caused by external reset pin.
1 Reset came from external reset pin.
5 Computer Operating Properly (COP) Watchdog — Reset was caused by the COP watchdog timer timing out.
COP This reset source can be blocked by COPE = 0.
0 Reset not caused by COP timeout.
1 Reset caused by COP timeout.
4 Illegal Opcode — Reset was caused by an attempt to execute an unimplemented or illegal opcode. The STOP
ILOP instruction is considered illegal if stop is disabled by STOPE = 0 in the SOPT register. The BGND instruction is
considered illegal if active background mode is disabled by ENBDM = 0 in the BDCSC register.
0 Reset not caused by an illegal opcode.
1 Reset caused by an illegal opcode.
Field Description
3 Illegal Address — Reset was caused by an attempt to access either data or an instruction at an unimplemented
ILAD memory address.
0 Reset not caused by an illegal address
1 Reset caused by an illegal address
1 Low Voltage Detect — If the LVDRE bit is set and the supply drops below the LVD trip voltage, an LVD reset
LVD occurs. This bit is also set by POR.
0 Reset not caused by LVD trip or POR.
1 Reset caused by LVD trip or POR.
R 0 0 0 0 0 0 0 0
W BDFR1
Reset: 0 0 0 0 0 0 0 0
= Unimplemented or Reserved
Field Description
0 Background Debug Force Reset — A serial background command such as WRITE_BYTE can be used to allow
BDFR an external debug host to force a target system reset. Writing 1 to this bit forces an MCU reset. This bit cannot
be written from a user program.To enter user mode, PTC5/BKGD/MS must be high immediately after issuing
WRITE_BYTE command. To enter BDM, PTC5/BKGD/MS must be low immediately after issuing WRITE_BYTE
command. See the data sheet for more information.
R 0 0 0
COPE COPT STOPE BKGDPE RSTPE
W
Reset: 1 1 0 0 0 0 1 u(1)
POR and
1 1 0 0 0 0 1 1
LVR:
= Unimplemented or Reserved
Field Description
7 COP Watchdog Enable — This write-once bit selects whether the COP watchdog is enabled.
COPE 0 COP watchdog timer disabled.
1 COP watchdog timer enabled (force reset on timeout).
6 COP Watchdog Timeout — This write-once bit selects the timeout period of the COP. COPT along with
COPT COPCLKS in SOPT2 defines the COP timeout period.
0 Short timeout period selected.
1 Long timeout period selected.
5 Stop Mode Enable — This write-once bit is used to enable stop mode. If stop mode is disabled and a user
STOPE program attempts to execute a STOP instruction, an illegal opcode reset is forced.
0 Stop mode disabled.
1 Stop mode enabled.
1 Background Debug Mode Pin Enable — This write-once bit when set enables the PTC5/BKGD/MS pin to
BKGDPE function as BKGD/MS. When clear, the pin functions as output only GPIO. This pin defaults to the BKGD/MS
function following any MCU reset.
0 PTC5/BKGD/MS pin functions as PTC5.
1 PTC5/BKGD/MS pin functions as BKGD/MS.
0 RESET Pin Enable — This write-once bit when set enables the PTC6/RESET pin to function as RESET. When
RSTPE clear, the pin functions as open drain output only GPIO. This pin defaults to its RESET function following an MCU
POR or LVD. When RSTPE is set, an internal pullup device is enabled on RESET.
0 PTC6/RESET pin functions as PTC6.
1 PTC6/RESET pin functions as RESET.
R 0 0 0 0 0 0
COPCLKS1 SPIFE
W
Reset: 0 0 0 0 0 0 0 1
= Unimplemented or Reserved
Field Description
7 COP Watchdog Clock Select — This write-once bit selects the clock source of the COP watchdog.
COPCLKS 0 Internal 1 kHz clock is source to COP.
1 Bus clock is source to COP.
0 SPI Filter Enable— This bit selects the IFE control of the SPI pins.
SPIFE 0 IFE disabled
1 IFE enabled
7 6 5 4 3 2 1 0
Reset: — — — — 0 0 0 0
= Unimplemented or Reserved
Field Description
7:4 Bits 7:4 are reserved. Reading these bits result in an indeterminate value; writes have no effect.
Reserved
3:0 Part Identification Number — Each derivative in the HCS08 Family has a unique identification number. The
ID[11:8] MC9S08LG32 is hard coded to the value 0x02A. See also ID bits in Table 5-9.
7 6 5 4 3 2 1 0
Reset: 0 0 1 0 1 0 1 0
= Unimplemented or Reserved
Field Description
7:0 Part Identification Number — Each derivative in the HCS08 Family has a unique identification number. The
ID[7:0] MC9S08LG32 is hard coded to the value 0x02A. See also ID bits in Table 5-8.
7 6 5 4 3 2 1 0
R LVWF1 0 03
LVWIE LVDRE2 LVDSE LVDE2 BGBE
W LVWACK
RESET: 0 0 0 1 1 1 0 0
= Unimplemented or Reserved
Figure 5-9. System Power Management Status and Control 1 Register (SPMSC1)
1
LVWF is set in the case when VSupply transitions below the trip point or after reset and VSupply is already below VLVW.
2 Write-once only after any system reset
3 Bit 1 is a reserved bit that must always be written to 0.
Field Description
7 Low-Voltage Warning Flag - The LVWF bit indicates the Low-Voltage Warning status.
LVWF 0 Low voltage warning not present.
1 Low voltage warning is present or was present.
Field Description
7 6 5 4 3 2 1 0
R 0 0 PPDF 0 0
LVDV1 LVWV PPDC2
W PPDACK
POR: 0 0 0 0 0 0 0 0
LVD: 0 0 U U 0 0 0 0
Figure 5-10. System Power Management Status and Control 2 Register (SPMSC2)
1 This bit can be written only one time after power-on reset. Additional writes are ignored.
2 This bit can be written only one time after reset. Additional writes are ignore.
Table 5-11. SPMSC2 Register Field Descriptions
Field Description
Field Description
1 High LVD trip point (VSUPPLY falling, LVDV = 1)1 VLVDXH 3.902 4.10 V
3 Low LVD trip point (VSUPPLY falling, LVDV = 0) VLVDXL 2.48 2.64 V
5 High LVW trip point (VSUPPLY falling, {LVDV,LVWV} = 00) VLVWXLL 2.66 2.82 V
6 High LVW trip point (VSUPPLY rising, {LVDV,LVWV} = 00) 2.72 2.88 V
7 Low LVW trip point (VSUPPLY falling, {LVDV,LVWV} = 01) VLVWXLH 2.84 3.00 V
8 Low LVW trip point (VSUPPLY rising, {LVDV,LVWV} = 01) 2.90 3.06 V
9 High LVW trip point (VSUPPLY falling, {LVDV,LVWV} = 10) VLVWXHL 4.20 4.40 V
10 High LVW trip point (VSUPPLY rising, {LVDV,LVWV} = 10) 4.30 4.50 V
11 Low LVW trip point (VSUPPLY falling, {LVDV,LVWV} = 11) VLVWXHH 4.50 4.70 V
12 Low LVW trip point (VSUPPLY rising, {LVDV,LVWV} = 11) 4.60 4.80 V
1
All values measured with respect to VSUPPLY
2
All values with factory trim
7 6 5 4 3 2 1 0
R
RTC TPM2 TPM1 ADC MTIM IIC SCI2 SCI1
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7 RTC Clock Gate Control — This bit controls the clock gate to the RTC module.
RTC 0 Bus clock to the RTC module is disabled.
1 Bus clock to the RTC module is enabled.
6 TPM2 Clock Gate Control — This bit controls the clock gate to the TPM2 module.
TPM2 0 Bus clock to the TPM2 module is disabled.
1 Bus clock to the TPM2 module is enabled.
5 TPM1 Clock Gate Control — This bit controls the clock gate to the TPM1 module.
TPM1 0 Bus clock to the TPM1 module is disabled.
1 Bus clock to the TPM1 module is enabled.
4 ADC Clock Gate Control — This bit controls the clock gate to the ADC module.
ADC 0 Bus clock to the ADC module is disabled.
1 Bus clock to the ADC module is enabled.
3 MTIM Clock Gate Control — This bit controls the clock gate to the MTIM module.
MTIM 0 Bus clock to the MTIM module is disabled.
1 Bus clock to the MTIM module is enabled.
2 IIC Clock Gate Control — This bit controls the clock gate to the IIC module.
IIC 0 Bus clock to the IIC module is disabled.
1 Bus clock to the IIC module is enabled.
1 SCI2 Clock Gate Control — This bit controls the clock gate to the SCI2 module.
SCI2 0 Bus clock to the SCI2 module is disabled.
1 Bus clock to the SCI2 module is enabled.
0 SCI1 Clock Gate Control — This bit controls the clock gate to the SCI1 module.
SCI1 0 Bus clock to the SCI1 module is disabled.
1 Bus clock to the SCI1 module is enabled.
7 6 5 4 3 2 1 0
R 0 0
DBG FLS IRQ KBI LCD SPI
W — —
Reset: 0 1 0 0 0 0 0 0
= Unimplemented or Reserved
Field Description
7 DBG Register Clock Gate Control — This bit controls the bus clock gate to the DBG module.
DBG 0 Bus clock to the DBG module is disabled.
1 Bus clock to the DBG module is enabled.
6 Flash Clock Gate Control — This bit controls the bus clock gate to the Flash module.
FLS 0 Bus clock to the Flash module is disabled.
1 Bus clock to the Flash module is enabled.
5 IRQ Clock Gate Control — This bit controls the bus clock gate to the IRQ module.
IRQ 0 Bus clock to the IRQ module is disabled.
1 Bus clock to the IRQ module is enabled.
4 KBI Clock Gate Control — This bit controls the clock gate to the KBI module.
KBI 0 Bus clock to the KBI module is disabled.
1 Bus clock to the KBI module is enabled.
1 LCD Clock Gate Control — This bit controls the bus clock gate to the LCD module. Only the bus clock is gated,
LCD the OSCOUT, TODCLK and LPOCLK are still available to the LCD.
0 Bus clock to the LCD module is disabled.
1 Bus clock to the LCD module is enabled.
0 SPI Clock Gate Control — This bit controls the clock gate to the SPI module.
SPI 0 Bus clock to the SPI module is disabled.
1 Bus clock to the SPI module is enabled.
7 6 5 4 3 2 1 0
R
KBI7 KBI6 KBI5 KBI4 KBI3 KBI2 KBI1 KBI0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
8 KBI7 Pin Position — This bit controls the pin position of KBI7.
KBI7 0 KBI7 sourced from PTA6
1 KBI7 sourced from PTH3
7 KBI6 Pin Position — This bit controls the pin position of KBI6.
KBI6 0 KBI6 sourced from PTA5
1 KBI6 sourced from PTH2
6 KBI5 Pin Position — This bit controls the pin position of KBI5.
KBI5 0 KBI5 sourced from PTA4
1 KBI5 sourced from PTH1
5 KBI4 Pin Position — This bit controls the pin position of KBI4.
KBI4 0 KBI4 sourced from PTA3
1 KBI4 sourced from PTH0
4 KBI3 Pin Position — This bit controls the pin position of KBI3.
KBI3 0 KBI3 sourced from PTF0
1 KBI3 sourced from PTH5
3 KBI2 Pin Position — This bit controls the pin position of KBI2.
KBI2 0 KBI2 sourced from PTF5
1 KBI2 sourced from PTH4
2 KBI1 Pin Position — This bit controls the pin position of KBI1.
KBI1 0 KBI1 sourced from PTF4
1 KBI1 sourced from PTH7
1 KBI0 Pin Position — This bit controls the pin position of KBI0.
KBI0 0 KBI0 sourced from PTF3
1 KBI0 sourced from PTH6
7 6 5 4 3 2 1 0
R
TPM2[5] TPM2[4] TPM2[3] TPM2[2] TPM2[1] TPM2[0] TPM1[1] TPM1[0]
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7 TPM2[5] Pin Position — This bit controls the pin position of TPM2[5].
TPM2[5] 0 TPM2[5] sourced from PTF3
1 TPM2[5] sourced from PTH6
6 TPM2[4] Pin Position — This bit controls the pin position of TPM2[4].
TPM2[4] 0 TPM2[4] sourced from PTF4
1 TPM2[4] sourced from PTH7
5 TPM2[3] Pin Position — This bit controls the pin position of TPM2[3].
TPM2[3] 0 TPM2[3] sourced from PTF5
1 TPM2[3] sourced from PTI2
4 TPM2[2] Pin Position — This bit controls the pin position of TPM2[2].
TPM2[2] 0 TPM2[2] sourced from PTF0
1 TPM2[2] sourced from PTI3
3 TPM2[1] Pin Position — This bit controls the pin position of TPM2[1].
TPM2[1] 0 TPM2[1] sourced from PTA6
1 TPM2[1] sourced from PTI4
2 TPM2[0] Pin Position — This bit controls the pin position of TPM2[0].
TPM2[0] 0 TPM2[0] sourced from PTA5
1 TPM2[0] sourced from PTI5
1 TPM1[1] Pin Position — This bit controls the pin position of TPM1[1].
TPM1[1] 0 TPM1[1] sourced from PTF2
1 TPM1[1] sourced from PTH4
0 TPM1[0] Pin Position — This bit controls the pin position of TPM1[0].
TPM1[0] 0 TPM1[0] sourced from PTF1
1 TPM1[0] sourced from PTH5
7 6 5 4 3 2 1 0
R
TX2 RX2 SCL SDA MISO MOSI SCK SS
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7 TX2 Pin Position — This bit controls the pin position of TX2.
TX2 0 TX2 sourced from PTA3.
1 TX2 sourced from PTI1.
6 RX2 Pin Position — This bit controls the pin position of RX2.
RX2 0 RX2 sourced from PTA4.
1 RX2 sourced from PTI0.
5 SCL Pin Position — This bit controls the pin position of SCL.
SCL 0 SCL sourced from PTA1.
1 SCL sourced from PTI5.
4 SDA Pin Position — This bit controls the pin position of SDA.
SDA 0 SDA sourced from PTA2.
1 SDA sourced from PTI4.
3 MISO Pin Position — This bit controls the pin position of MISO.
MISO 0 MISO sourced from PTF4.
1 MISO sourced from PTI2.
2 MOSI Pin Position — This bit controls the pin position of MOSI.
MOSI 0 MOSI sourced from PTF5.
1 MOSI sourced from PTI3.
1 SCK Pin Position — This bit controls the pin position of SCK.
SCK 0 SCK sourced from PTF2.
1 SCK sourced from PTI4.
7 6 5 4 3 2 1 0
R
0 0 0 0 0 0 TX1 RX1
W
Reset: 0 0 0 0 0 0 0 0
Field Description
1 TX1 Pin Position — This bit controls the pin position of TX1.
TX1 0 TX1 sourced from PTF0.
1 TX1 sourced from PTH5.
0 RX1 Pin Position — This bit controls the pin position of RX1.
RX1 0 RX1 sourced from PTF1.
1 RX1 sourced from PTH4.
by the shared function. However, the data direction register bit continues to control the source for reads of
the port data register.
When a shared analog function is enabled for a pin, both the input and output buffers are disabled. A value
of 0 is read for any port data bit where the bit is an input (PTxDDn = 0) and the input buffer is disabled. In
general, whenever a pin is shared with both an alternate digital function and an analog function, the analog
function has priority such that if both the digital and analog functions are enabled, the analog function
controls the pin.
It is good programming practice to write to the port data register before changing the direction of a port
pin so it becomes an output. This ensures that the pin is not driven momentarily with an old data value that
happen to be in the port data register.
PTxDDn
D Q Output Enable
Input Enable
PTxDn
D Q Output Data
1
Port Read
Data
0 Synchronizer Input Data
BUSCLK
Figure 6-1. Parallel I/O Block Diagram
The pullup device is disabled if the pin is controlled by an analog function regardless of the state of the
corresponding pullup enable register bit.
• In stop3 mode, all I/O is maintained because internal logic circuitry stays powered up. Upon
recovery, normal I/O function is available to the user.
7 6 5 4 3 2 1 0
R
PTAD7 PTAD6 PTAD5 PTAD4 PTAD3 PTAD2 PTAD1 PTAD0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Port A Data Register Bits — For port A pins that are inputs, reads return the logic level on the pin. For port A
PTAD[7:0] pins that are configured as outputs, reads return the last value written to this register.
Writes are latched into all bits of this register. For port A pins that are configured as outputs, the logic level is
driven out the corresponding MCU pin.
Reset forces PTAD to all 0s, but these 0s are not driven out the corresponding pins because reset also configures
all port pins as high-impedance inputs with pullups disabled.
7 6 5 4 3 2 1 0
R
PTADD7 PTADD6 PTADD5 PTADD4 PTADD3 PTADD2 PTADD1 PTADD0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Data Direction for Port A Bits — These read/write bits control the direction of port A pins and what is read for
PTADD[7:0] PTAD reads.
0 Input (output driver disabled) and reads return the pin value.
1 Output driver enabled for port A bit n and PTAD reads return the contents of PTADn.
7 6 5 4 3 2 1 0
R
PTAPE7 PTAPE6 PTAPE5 PTAPE4 PTAPE3 PTAPE2 PTAPE1 PTAPE0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Internal Pull Enable for Port A Bits — Each of these control bits determines if the internal pullup or pulldown
PTAPE[7:0] device is enabled for the associated PTA pin. For port A pins that are configured as outputs, these bits have no
effect and the internal pull devices are disabled.
0 Internal pullup device disabled for port A bit n.
1 Internal pullup device enabled for port A bit n.
7 6 5 4 3 2 1 0
R
PTASE7 PTASE6 PTASE5 PTASE4 PTASE3 PTASE2 PTASE1 PTASE0
W
Reset: 1 1 1 1 1 1 1 1
Field Description
7:0 Output Slew Rate Enable for Port A Bits — Each of these control bits determines if the output slew rate control
PTASE[7:0] is enabled for the associated PTA pin. For port A pins that are configured as inputs, these bits have no effect.
0 Output slew rate control disabled for port A bit n.
1 Output slew rate control enabled for port A bit n.
7 6 5 4 3 2 1 0
R
PTADS7 PTADS6 PTADS5 PTADS4 PTADS3 PTADS2 PTADS1 PTADS0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Output Drive Strength Selection for Port A Bits — Each of these control bits selects between low and high
PTADS[7:0] output drive for the associated PTA pin. For port A pins that are configured as inputs, these bits have no effect.
0 Low output drive strength selected for port A bit n.
1 High output drive strength selected for port A bit n.
7 6 5 4 3 2 1 0
R
PTBD7 PTBD6 PTBD5 PTBD4 PTBD3 PTBD2 PTBD1 PTBD0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Port B Data Register Bits — For Port B pins that are inputs, reads return the logic level on the pin. For Port B
PTBD[7:0] pins that are configured as outputs, reads return the last value written to this register.
Writes are latched into all bits of this register. For Port B pins that are configured as outputs, the logic level is
driven out the corresponding MCU pin.
Reset forces PTBD to all 0s, but these 0s are not driven out the corresponding pins because reset also configures
all port pins as high-impedance inputs with pullups disabled.
7 6 5 4 3 2 1 0
R
PTBDD7 PTBDD6 PTBDD5 PTBDD4 PTBDD3 PTBDD2 PTBDD1 PTBDD0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Data Direction for Port B Bits — These read/write bits control the direction of Port B pins and what is read for
PTBDD[7:0] PTBD reads.
0 Input (output driver disabled) and reads return the pin value.
1 Output driver enabled for Port B bit n and PTBD reads return the contents of PTBDn.
7 6 5 4 3 2 1 0
R
PTBPE7 PTBPE6 PTBPE5 PTBPE4 PTBPE3 PTBPE2 PTBPE1 PTBPE0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Internal Pull Enable for Port B Bits — Each of these control bits determines if the internal pullup or pulldown
PTBPE[7:0] device is enabled for the associated PTB pin. For Port B pins that are configured as outputs, these bits have no
effect and the internal pull devices are disabled.
0 Internal pullup device disabled for Port B bit n.
1 Internal pullup device enabled for Port B bit n.
7 6 5 4 3 2 1 0
R
PTBSE7 PTBSE6 PTBSE5 PTBSE4 PTBSE3 PTBSE2 PTBSE1 PTBSE0
W
Reset: 1 1 1 1 1 1 1 1
Field Description
7:0 Output Slew Rate Enable for Port B Bits — Each of these control bits determines if the output slew rate control
PTBSE[7:0] is enabled for the associated PTB pin. For Port B pins that are configured as inputs, these bits have no effect.
0 Output slew rate control disabled for Port B bit n.
1 Output slew rate control enabled for Port B bit n.
7 6 5 4 3 2 1 0
R
PTBDS7 PTBDS6 PTBDS5 PTBDS4 PTBDS3 PTBDS2 PTBDS1 PTBDS0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Output Drive Strength Selection for Port B Bits — Each of these control bits selects between low and high
PTBDS[7:0] output drive for the associated PTB pin. For Port B pins that are configured as inputs, these bits have no effect.
0 Low output drive strength selected for Port B bit n.
1 High output drive strength selected for Port B bit n.
7 6 5 4 3 2 1 0
R 0
PTCD6 PTCD5 PTCD4 PTCD3 PTCD2 PTCD1 PTCD0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
6:0 Port C Data Register Bits — For Port C pins that are inputs, reads return the logic level on the pin. For Port C
PTCD[6:0] pins that are configured as outputs, reads return the last value written to this register.
Writes are latched into all bits of this register. For Port C pins that are configured as outputs, the logic level is
driven out the corresponding MCU pin.
Reset forces PTCD to all 0s, but these 0s are not driven out the corresponding pins because reset also configures
all port pins as high-impedance inputs with pullups disabled.
7 6 5 4 3 2 1 0
R 0
PTCDD6 PTCDD5 PTCDD4 PTCDD3 PTCDD2 PTCDD1 PTCDD0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
6:0 Data Direction for Port C Bits — These read/write bits control the direction of Port C pins and what is read for
PTCDD[6:0] PTCD reads.
0 Input (output driver disabled) and reads return the pin value.
1 Output driver enabled for Port C bit n and PTCD reads return the contents of PTCDn.
7 6 5 4 3 2 1 0
R 0
PTCPE6 PTCPE5 PTCPE4 PTCPE3 PTCPE2 PTCPE1 PTCPE0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
6:0 Internal Pull Enable for Port C Bits — Each of these control bits determines if the internal pullup or pulldown
PTCPE[6:0] device is enabled for the associated PTC pin. For Port C pins that are configured as outputs, these bits have no
effect and the internal pull devices are disabled.
0 Internal pullup device disabled for Port C bit n.
1 Internal pullup device enabled for Port C bit n.
7 6 5 4 3 2 1 0
R 0
PTCSE6 PTCSE5 PTCSE4 PTCSE3 PTCSE2 PTCSE1 PTCSE0
W
Reset: 0 1 1 1 1 1 1 1
Field Description
6:0 Output Slew Rate Enable for Port C Bits — Each of these control bits determines if the output slew rate control
PTCSE[6:0] is enabled for the associated PTC pin. For Port C pins that are configured as inputs, these bits have no effect.
0 Output slew rate control disabled for Port C bit n.
1 Output slew rate control enabled for Port C bit n.
7 6 5 4 3 2 1 0
R 0
PTCDS6 PTCDS5 PTCDS4 PTCDS3 PTCDS2 PTCDS1 PTCDS0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
6:0 Output Drive Strength Selection for Port C Bits — Each of these control bits selects between low and high
PTCDS[6:0] output drive for the associated PTC pin. For Port C pins that are configured as inputs, these bits have no effect.
0 Low output drive strength selected for Port C bit n.
1 High output drive strength selected for Port C bit n.
7 6 5 4 3 2 1 0
R
PTDD7 PTDD6 PTDD5 PTDD4 PTDD3 PTDD2 PTDD1 PTDD0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Port D Data Register Bits — For Port D pins that are inputs, reads return the logic level on the pin. For Port D
PTDD[7:0] pins that are configured as outputs, reads return the last value written to this register.
Writes are latched into all bits of this register. For Port D pins that are configured as outputs, the logic level is
driven out the corresponding MCU pin.
Reset forces PTDD to all 0s, but these 0s are not driven out the corresponding pins because reset also configures
all port pins as high-impedance inputs with pullups disabled.
7 6 5 4 3 2 1 0
R
PTDDD7 PTDDD6 PTDDD5 PTDDD4 PTDDD3 PTDDD2 PTDDD1 PTDDD0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Data Direction for Port D Bits — These read/write bits control the direction of Port D pins and what is read for
PTDDD[7:0] PTDD reads.
0 Input (output driver disabled) and reads return the pin value.
1 Output driver enabled for Port D bit n and PTDD reads return the contents of PTDDn.
7 6 5 4 3 2 1 0
R
PTDPE7 PTDPE6 PTDPE5 PTDPE4 PTDPE3 PTDPE2 PTDPE1 PTDPE0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Internal Pull Enable for Port D Bits — Each of these control bits determines if the internal pullup or pulldown
PTDPE[7:0] device is enabled for the associated PTD pin. For Port D pins that are configured as outputs, these bits have no
effect and the internal pull devices are disabled.
0 Internal pullup device disabled for Port D bit n.
1 Internal pullup device enabled for Port D bit n.
7 6 5 4 3 2 1 0
R
PTDSE7 PTDSE6 PTDSE5 PTDSE4 PTDSE3 PTDSE2 PTDSE1 PTDSE0
W
Reset: 1 1 1 1 1 1 1 1
Field Description
7:0 Output Slew Rate Enable for Port D Bits — Each of these control bits determines if the output slew rate control
PTDSE[7:0] is enabled for the associated PTD pin. For Port D pins that are configured as inputs, these bits have no effect.
0 Output slew rate control disabled for Port D bit n.
1 Output slew rate control enabled for Port D bit n.
7 6 5 4 3 2 1 0
R
PTDDS7 PTDDS6 PTDDS5 PTDDS4 PTDDS3 PTDDS2 PTDDS1 PTDDS0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Output Drive Strength Selection for Port D Bits — Each of these control bits selects between low and high
PTDDS[7:0] output drive for the associated PTD pin. For Port D pins that are configured as inputs, these bits have no effect.
0 Low output drive strength selected for Port D bit n.
1 High output drive strength selected for Port D bit n.
7 6 5 4 3 2 1 0
R
PTED7 PTED6 PTED5 PTED4 PTED3 PTED2 PTED1 PTED0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Port E Data Register Bits — For Port E pins that are inputs, reads return the logic level on the pin. For Port E
PTED[7:0] pins that are configured as outputs, reads return the last value written to this register.
Writes are latched into all bits of this register. For Port E pins that are configured as outputs, the logic level is
driven out the corresponding MCU pin.
Reset forces PTED to all 0s, but these 0s are not driven out the corresponding pins because reset also configures
all port pins as high-impedance inputs with pullups disabled.
7 6 5 4 3 2 1 0
R
PTEDD7 PTEDD6 PTEDD5 PTEDD4 PTEDD3 PTEDD2 PTEDD1 PTEDD0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Data Direction for Port E Bits — These read/write bits control the direction of Port E pins and what is read for
PTEDD[7:0] PTED reads.
0 Input (output driver disabled) and reads return the pin value.
1 Output driver enabled for Port E bit n and PTED reads return the contents of PTEDn.
7 6 5 4 3 2 1 0
R
PTEPE7 PTEPE6 PTEPE5 PTEPE4 PTEPE3 PTEPE2 PTEPE1 PTEPE0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Internal Pull Enable for Port E Bits — Each of these control bits determines if the internal pullup or pulldown
PTEPE[7:0] device is enabled for the associated PTE pin. For Port E pins that are configured as outputs, these bits have no
effect and the internal pull devices are disabled.
0 Internal pullup device disabled for Port E bit n.
1 Internal pullup device enabled for Port E bit n.
7 6 5 4 3 2 1 0
R
PTESE7 PTESE6 PTESE5 PTESE4 PTESE3 PTESE2 PTESE1 PTESE0
W
Reset: 1 1 1 1 1 1 1 1
Field Description
7:0 Output Slew Rate Enable for Port E Bits — Each of these control bits determines if the output slew rate control
PTESE[7:0] is enabled for the associated PTE pin. For Port E pins that are configured as inputs, these bits have no effect.
0 Output slew rate control disabled for Port E bit n.
1 Output slew rate control enabled for Port E bit n.
7 6 5 4 3 2 1 0
R
PTEDS7 PTEDS6 PTEDS5 PTEDS4 PTEDS3 PTEDS2 PTEDS1 PTEDS0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Output Drive Strength Selection for Port E Bits — Each of these control bits selects between low and high
PTEDS[7:0] output drive for the associated PTE pin. For Port E pins that are configured as inputs, these bits have no effect.
0 Low output drive strength selected for Port E bit n.
1 High output drive strength selected for Port E bit n.
7 6 5 4 3 2 1 0
R
PTFD7 PTFD6 PTFD5 PTFD4 PTFD3 PTFD2 PTFD1 PTFD0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Port F Data Register Bits — For Port F pins that are inputs, reads return the logic level on the pin. For Port F
PTFD[7:0] pins that are configured as outputs, reads return the last value written to this register.
Writes are latched into all bits of this register. For Port F pins that are configured as outputs, the logic level is
driven out the corresponding MCU pin.
Reset forces PTFD to all 0s, but these 0s are not driven out the corresponding pins because reset also configures
all port pins as high-impedance inputs with pullups disabled.
7 6 5 4 3 2 1 0
R
PTFDD7 PTFDD6 PTFDD5 PTFDD4 PTFDD3 PTFDD2 PTFDD1 PTFDD0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Data Direction for Port F Bits — These read/write bits control the direction of Port F pins and what is read for
PTFDD[7:0] PTFD reads.
0 Input (output driver disabled) and reads return the pin value.
1 Output driver enabled for Port F bit n and PTFD reads return the contents of PTFDn.
7 6 5 4 3 2 1 0
R
PTFPE7 PTFPE6 PTFPE5 PTFPE4 PTFPE3 PTFPE2 PTFPE1 PTFPE0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Internal Pull Enable for Port F Bits — Each of these control bits determines if the internal pullup or pulldown
PTFPE[7:0] device is enabled for the associated PTF pin. For Port F pins that are configured as outputs, these bits have no
effect and the internal pull devices are disabled.
0 Internal pullup device disabled for Port F bit n.
1 Internal pullup device enabled for Port F bit n.
7 6 5 4 3 2 1 0
R
PTFSE7 PTFSE6 PTFSE5 PTFSE4 PTFSE3 PTFSE2 PTFSE1 PTFSE0
W
Reset: 1 1 1 1 1 1 1 1
Field Description
7:0 Output Slew Rate Enable for Port F Bits — Each of these control bits determines if the output slew rate control
PTFSE[7:0] is enabled for the associated PTF pin. For Port F pins that are configured as inputs, these bits have no effect.
0 Output slew rate control disabled for Port F bit n.
1 Output slew rate control enabled for Port F bit n.
7 6 5 4 3 2 1 0
R
PTFDS7 PTFDS6 PTFDS5 PTFDS4 PTFDS3 PTFDS2 PTFDS1 PTFDS0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Output Drive Strength Selection for Port F Bits — Each of these control bits selects between low and high
PTFDS[7:0] output drive for the associated PTF pin. For Port F pins that are configured as inputs, these bits have no effect.
0 Low output drive strength selected for Port F bit n.
1 High output drive strength selected for Port F bit n.
7 6 5 4 3 2 1 0
R
PTGD7 PTGD6 PTGD5 PTGD4 PTGD3 PTGD2 PTGD1 PTGD0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Port G Data Register Bits — For Port G pins that are inputs, reads return the logic level on the pin. For Port G
PTGD[7:0] pins that are configured as outputs, reads return the last value written to this register.
Writes are latched into all bits of this register. For Port G pins that are configured as outputs, the logic level is
driven out the corresponding MCU pin.
Reset forces PTGD to all 0s, but these 0s are not driven out the corresponding pins because reset also
configures all port pins as high-impedance inputs with pullups disabled.
7 6 5 4 3 2 1 0
R
PTGDD7 PTGDD6 PTGDD5 PTGDD4 PTGDD3 PTGDD2 PTGDD1 PTGDD0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Data Direction for Port G Bits — These read/write bits control the direction of Port G pins and what is read for
PTGDD[7:0] PTGD reads.
0 Input (output driver disabled) and reads return the pin value.
1 Output driver enabled for Port G bit n and PTGD reads return the contents of PTGDn.
7 6 5 4 3 2 1 0
R
PTGPE7 PTGPE6 PTGPE5 PTGPE4 PTGPE3 PTGPE2 PTGPE1 PTGPE0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Internal Pull Enable for Port G Bits — Each of these control bits determines if the internal pullup or pulldown
PTGPE[7:0] device is enabled for the associated PTG pin. For Port G pins that are configured as outputs, these bits have no
effect and the internal pull devices are disabled.
0 Internal pullup device disabled for Port G bit n.
1 Internal pullup device enabled for Port G bit n.
7 6 5 4 3 2 1 0
R
PTGSE7 PTGSE6 PTGSE5 PTGSE4 PTGSE3 PTGSE2 PTGSE1 PTGSE0
W
Reset: 1 1 1 1 1 1 1 1
Field Description
7:0 Output Slew Rate Enable for Port G Bits — Each of these control bits determines if the output slew rate control
PTGSE[7:0] is enabled for the associated PTG pin. For Port G pins that are configured as inputs, these bits have no effect.
0 Output slew rate control disabled for Port G bit n.
1 Output slew rate control enabled for Port G bit n.
7 6 5 4 3 2 1 0
R
PTGDS7 PTGDS6 PTGDS5 PTGDS4 PTGDS3 PTGDS2 PTGDS1 PTGDS0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Output Drive Strength Selection for Port G Bits — Each of these control bits selects between low and high
PTGDS[7:0] output drive for the associated PTG pin. For Port G pins that are configured as inputs, these bits have no effect.
0 Low output drive strength selected for Port G bit n.
1 High output drive strength selected for Port G bit n.
7 6 5 4 3 2 1 0
R
PTHD7 PTHD6 PTHD5 PTHD4 PTHD3 PTHD2 PTHD1 PTHD0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Port H Data Register Bits — For Port H pins that are inputs, reads return the logic level on the pin. For Port H
PTHD[7:0] pins that are configured as outputs, reads return the last value written to this register.
Writes are latched into all bits of this register. For Port H pins that are configured as outputs, the logic level is
driven out the corresponding MCU pin.
Reset forces PTHD to all 0s, but these 0s are not driven out the corresponding pins because reset also configures
all port pins as high-impedance inputs with pullups disabled.
7 6 5 4 3 2 1 0
R
PTHDD7 PTHDD6 PTHDD5 PTHDD4 PTHDD3 PTHDD2 PTHDD1 PTHDD0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Data Direction for Port H Bits — These read/write bits control the direction of Port H pins and what is read for
PTHDD[7:0] PTHD reads.
0 Input (output driver disabled) and reads return the pin value.
1 Output driver enabled for Port H bit n and PTHD reads return the contents of PTHDn.
7 6 5 4 3 2 1 0
R
PTHPE7 PTHPE6 PTHPE5 PTHPE4 PTHPE3 PTHPE2 PTHPE1 PTHPE0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Internal Pull Enable for Port H Bits — Each of these control bits determines if the internal pullup or pulldown
PTHPE[7:0] device is enabled for the associated PTH pin. For Port H pins that are configured as outputs, these bits have no
effect and the internal pull devices are disabled.
0 Internal pullup device disabled for Port H bit n.
1 Internal pullup device enabled for Port H bit n.
7 6 5 4 3 2 1 0
R
PTHSE7 PTHSE6 PTHSE5 PTHSE4 PTHSE3 PTHSE2 PTHSE1 PTHSE0
W
Reset: 1 1 1 1 1 1 1 1
Field Description
7:0 Output Slew Rate Enable for Port H Bits — Each of these control bits determines if the output slew rate control
PTHSE[7:0] is enabled for the associated PTH pin. For Port H pins that are configured as inputs, these bits have no effect.
0 Output slew rate control disabled for Port H bit n.
1 Output slew rate control enabled for Port H bit n.
7 6 5 4 3 2 1 0
R
PTHDS7 PTHDS6 PTHDS5 PTHDS4 PTHDS3 PTHDS2 PTHDS1 PTHDS0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Output Drive Strength Selection for Port H Bits — Each of these control bits selects between low and high
PTHDS[7:0] output drive for the associated PTH pin. For Port H pins that are configured as inputs, these bits have no effect.
0 Low output drive strength selected for Port H bit n.
1 High output drive strength selected for Port H bit n.
7 6 5 4 3 2 1 0
R 0 0
PTID5 PTID4 PTID3 PTID2 PTID1 PTID0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
5:0 Port I Data Register Bits — For Port I pins that are inputs, reads return the logic level on the pin. For Port I pins
PTID[5:0] that are configured as outputs, reads return the last value written to this register.
Writes are latched into all bits of this register. For Port I pins that are configured as outputs, the logic level is driven
out the corresponding MCU pin.
Reset forces PTID to all 0s, but these 0s are not driven out the corresponding pins because reset also configures
all port pins as high-impedance inputs with pullups disabled.
7 6 5 4 3 2 1 0
R 0 0
PTIDD5 PTIDD4 PTIDD3 PTIDD2 PTIDD1 PTIDD0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
5:0 Data Direction for Port I Bits — These read/write bits control the direction of Port I pins and what is read for
PTIDD[5:0] PTID reads.
0 Input (output driver disabled) and reads return the pin value.
1 Output driver enabled for Port I bit n and PTID reads return the contents of PTIDn.
7 6 5 4 3 2 1 0
R 0 0
PTIPE5 PTIPE4 PTIPE3 PTIPE2 PTIPE1 PTIPE0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
5:0 Internal Pull Enable for Port I Bits — Each of these control bits determines if the internal pullup or pulldown
PTIPE[5:0] device is enabled for the associated PTI pin. For Port I pins that are configured as outputs, these bits have no
effect and the internal pull devices are disabled.
0 Internal pullup device disabled for Port I bit n.
1 Internal pullup device enabled for Port I bit n.
7 6 5 4 3 2 1 0
R 0 0
PTISE5 PTISE4 PTISE3 PTISE2 PTISE1 PTISE0
W
Reset: 0 0 1 1 1 1 1 1
Field Description
5:0 Output Slew Rate Enable for Port I Bits — Each of these control bits determines if the output slew rate control
PTISE[6:0] is enabled for the associated PTI pin. For Port I pins that are configured as inputs, these bits have no effect.
0 Output slew rate control disabled for Port I bit n.
1 Output slew rate control enabled for Port I bit n.
7 6 5 4 3 2 1 0
R 0 0
PTIDS5 PTIDS4 PTIDS3 PTIDS2 PTIDS1 PTIDS0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Output Drive Strength Selection for Port I Bits — Each of these control bits selects between low and high
PTIDS[7:0] output drive for the associated PTI pin. For Port I pins that are configured as inputs, these bits have no effect.
0 Low output drive strength selected for Port I bit n.
1 High output drive strength selected for Port I bit n.
KBIn in PINPS1 Port Pin for KBI7 Port Pin for KBI6 Port Pin for KBI5 Port Pin for KBI4
KBIn in PINPS1 Port Pin for KBI3 Port Pin for KBI2 Port Pin for KBI1 Port Pin for KBI0
PORT A
LCD25/ADC2/RX2/KBI5/PTA4
LCD24/ADC1/TX2/KBI4/PTA3
BKGD/MS Real Time Counter
BKGD BKP LCD23/ADC0/SDA/PTA2
(RTC) LCD22/SCL/PTA1
LCD21/PTA0
HCS08 SYSTEM CONTROL Modulo Timer TMRCLK
PORT B
(MTIM) LCD[40:37]/PTB[7:4]
RESETS AND INTERRUPTS LCD[32:29]/PTB[3:0]
MODES OF OPERATION KBI[7:0]
8-BIT KEYBOARD
POWER MANAGEMENT
INTERRUPT (KBI)
RESET/PTC6
PORT C
SS BKGD/MS/PTC5
COP RESET SPSCK LCD[20:16]/PTC[4:0]
SERIAL PERIPHERAL MISO
IRQ INTERFACE (SPI)
IRQ LVD MOSI
PORT D
SCL LCD[7:0]/PTD[7:0]
USER FLASH A IIC MODULE (IIC) SDA
(LG32 = 16K BYTES)
PORT E
(LG16 = 2K BYTES) TPM2CH[5:0]
6-CHANNEL TIMER/PWM LCD[15:8]/PTE[7:0]
(TPM2) TPMCLK
USER FLASH B
(LG32 = 16K BYTES) TPM1CH[1:0]
2-CHANNEL TIMER/PWM EXTAL/PTF7
(LG16 = 16K BYTES) XTAL/PTF6
(TPM1) TPMCLK
TPM2CH3/KBI2/MOSI/PTF5
PORT F
TxD1 TPM2CH4/KBI1/MISO/PTF4
SERIAL COMMUNICATIONS
RxD1 TPM2CH5/KBI0/SS/PTF3
USER RAM INTERFACE (SCI1) ADC14/IRQ/TPM1CH1/SPSCK/PTF2
1984 BYTES ADC13/TPM1CH0/RX1/PTF1
TxD2 ADC12/TPM2CH2/KBI3/TX1/PTF0
SERIAL COMMUNICATIONS
RxD2
INTERFACE (SCI2)
PORT G
INTERNAL CLOCK LCD[44:41]/PTG[7:4]
Source (ICS) LCD[36:33]/PTG[3:0]
XTAL
LOW-POWER OSCILLATOR EXTAL
TPM2CH4/KBI1/PTH7
ADC15/KBI0/TPM2CH5/PTH6
PORT H
VLL3_2 12-BIT
ANALOG-TO-DIGITAL AD[15:0] ADC11/TPM1CH0/KBI3/TX1/PTH5
VLL3
CONVERTER (ADC) ADC10/TPM1CH1/KBI2/RX1/PTH4
VLL1 LIQUID CRYSTAL ADC[9:6]/KBI[7:4]/PTH[3:0]
VLL2 DISPLAY DRIVER
(LCD) SS/SCL/TPM2CH0/PTI5
VCAP1
SPSCK/SDA/TPM2CH1/PTI4
PORT I
VCAP2 MOSI/TPM2CH2/PTI3
LCD[44:0] MISO/TPM2CH3/PTI2
TX2/TMRCLK/PTI1
RX2/PTI0
VDD
VSS
VOLTAGE
REGULATOR
VSS2 Available only on 80-pin package
Available only on 64-pin and 80-pin package
VDDA/VREFH */Default function out of reset/*
VSSA/VREFL
Figure 7-1. MC9S08LG32 Series Block Diagram Highlighting KBI Block and Pins
7.1.3 Features
The KBI features include:
• Up to eight keyboard interrupt pins with individual pin enable bits.
• Each keyboard interrupt pin is programmable as falling edge (or rising edge) only, or both falling
edge and low level (or both rising edge and high level) interrupt sensitivity.
• One software enabled keyboard interrupt.
• Exit from low-power modes.
KBACK BUSCLK
1 VDD RESET
KBF
KBIP0 0
S KBIPE0 D CLR Q
SYNCHRONIZER
CK
KBEDG0
KEYBOARD STOP STOP BYPASS KBI
INTERRUPT FF INTERRUPT
1
REQUEST
KBIPn 0 KBMOD
S KBIPEn
KBIE
KBEDGn
7 6 5 4 3 2 1 0
R 0 0 0 0 KBF 0
KBIE KBMOD
W KBACK
Reset: 0 0 0 0 0 0 0 0
= Unimplemented
Field Description
3 Keyboard Interrupt Flag — KBF indicates when a keyboard interrupt is detected. Writes have no effect on KBF.
KBF 0 No keyboard interrupt detected.
1 Keyboard interrupt detected.
2 Keyboard Acknowledge — Writing a 1 to KBACK is part of the flag clearing mechanism. KBACK always reads
KBACK as 0.
0 Keyboard Detection Mode — KBMOD (along with the KBEDG bits) controls the detection mode of the keyboard
KBMOD interrupt pins.
0 Keyboard detects edges only.
1 Keyboard detects both edges and levels.
7 6 5 4 3 2 1 0
R
KBIPE7 KBIPE6 KBIPE5 KBIPE4 KBIPE3 KBIPE2 KBIPE1 KBIPE0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Keyboard Pin Enables — Each of the KBIPEn bits enable the corresponding keyboard interrupt pin.
KBIPEn 0 Pin not enabled as keyboard interrupt.
1 Pin enabled as keyboard interrupt.
7 6 5 4 3 2 1 0
R
KBEDG7 KBEDG6 KBEDG5 KBEDG4 KBEDG3 KBEDG2 KBEDG1 KBEDG0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 Keyboard Edge Selects — Each of the KBEDGn bits selects the falling edge/low level or rising edge/high level
KBEDGn function of the corresponding pin).
0 Falling edge/low level.
1 Rising edge/high level.
8.1.1 Features
Features of the HCS08 CPU include:
• Object code fully upward-compatible with M68HC05 and M68HC08 Families
• All registers and memory are mapped to a single 64 KB address space
• 16-bit stack pointer (any size stack anywhere in 64 KB CPU address space)
• 16-bit index register (H:X) with powerful indexed addressing modes
• 8-bit accumulator (A)
• Many instructions treat X as a second general-purpose 8-bit register
• Seven addressing modes:
— Inherent — Operands in internal registers
— Relative — 8-bit signed offset to branch destination
— Immediate — Operand in next object code byte(s)
— Direct — Operand in memory at 0x0000–0x00FF
— Extended — Operand anywhere in 64 KB address space
— Indexed relative to H:X — Five submodes including auto increment
— Indexed relative to SP — Improves C efficiency dramatically
• Memory-to-memory data move instructions with four address mode combinations
• Overflow, half-carry, negative, zero, and carry condition codes support conditional branching on
the results of signed, unsigned, and binary-coded decimal (BCD) operations
• Efficient bit manipulation instructions
• Fast 8-bit by 8-bit multiply and 16-bit by 8-bit divide instructions
• Stop and Wait instructions to invoke low-power operating modes
7 0
CONDITION CODE REGISTER V 1 1 H I N Z C CCR
CARRY
ZERO
NEGATIVE
INTERRUPT MASK
HALF-CARRY (FROM BIT 3)
TWO’S COMPLEMENT OVERFLOW
Figure 8-1. CPU Registers
7 0
CONDITION CODE REGISTER V 1 1 H I N Z C CCR
CARRY
ZERO
NEGATIVE
INTERRUPT MASK
HALF-CARRY (FROM BIT 3)
TWO’S COMPLEMENT OVERFLOW
Field Description
7 Two’s Complement Overflow Flag — The CPU sets the overflow flag when a two’s complement overflow occurs.
V The signed branch instructions BGT, BGE, BLE, and BLT use the overflow flag.
0 No overflow
1 Overflow
4 Half-Carry Flag — The CPU sets the half-carry flag when a carry occurs between accumulator bits 3 and 4 during
H an add-without-carry (ADD) or add-with-carry (ADC) operation. The half-carry flag is required for binary-coded
decimal (BCD) arithmetic operations. The DAA instruction uses the states of the H and C condition code bits to
automatically add a correction value to the result from a previous ADD or ADC on BCD operands to correct the
result to a valid BCD value.
0 No carry between bits 3 and 4
1 Carry between bits 3 and 4
3 Interrupt Mask Bit — When the interrupt mask is set, all maskable CPU interrupts are disabled. CPU interrupts
I are enabled when the interrupt mask is cleared. When a CPU interrupt occurs, the interrupt mask is set
automatically after the CPU registers are saved on the stack, but before the first instruction of the interrupt service
routine is executed.
Interrupts are not recognized at the instruction boundary after any instruction that clears I (CLI or TAP). This
ensures that the next instruction after a CLI or TAP will always be executed without the possibility of an intervening
interrupt, provided I was set.
0 Interrupts enabled
1 Interrupts disabled
2 Negative Flag — The CPU sets the negative flag when an arithmetic operation, logic operation, or data
N manipulation produces a negative result, setting bit 7 of the result. Simply loading or storing an 8-bit or 16-bit value
causes N to be set if the most significant bit of the loaded or stored value was 1.
0 Non-negative result
1 Negative result
1 Zero Flag — The CPU sets the zero flag when an arithmetic operation, logic operation, or data manipulation
Z produces a result of 0x00 or 0x0000. Simply loading or storing an 8-bit or 16-bit value causes Z to be set if the
loaded or stored value was all 0s.
0 Non-zero result
1 Zero result
0 Carry/Borrow Flag — The CPU sets the carry/borrow flag when an addition operation produces a carry out of bit
C 7 of the accumulator or when a subtraction operation requires a borrow. Some instructions — such as bit test and
branch, shift, and rotate — also clear or set the carry/borrow flag.
0 No carry out of bit 7
1 Carry out of bit 7
interrupt service routine, this would allow nesting of interrupts (which is not recommended because it
leads to programs that are difficult to debug and maintain).
For compatibility with the earlier M68HC05 MCUs, the high-order half of the H:X index register pair (H)
is not saved on the stack as part of the interrupt sequence. The user must use a PSHH instruction at the
beginning of the service routine to save H and then use a PULH instruction just before the RTI that ends
the interrupt service routine. It is not necessary to save H if you are certain that the interrupt service routine
does not use any instructions or auto-increment addressing modes that might change the value of H.
The software interrupt (SWI) instruction is like a hardware interrupt except that it is not masked by the
global I bit in the CCR and it is associated with an instruction opcode within the program so it is not
asynchronous to program execution.
Affect
Address
Cycles
Mode
Affect
Address
Cycles
Mode
Source Cyc-by-Cyc on CCR
Operation Object Code
Form Details
V11H INZC
ASL opr8a Arithmetic Shift Left DIR 38 dd 5 rfwpp
ASLA INH 48 1 p
ASLX C 0 INH 58 1 p
Þ 1 1 – – Þ Þ Þ
ASL oprx8,X b7 b0
IX1 68 ff 5 rfwpp
ASL ,X IX 78 4 rfwp
ASL oprx8,SP (Same as LSL) SP1 9E 68 ff 6 prfwpp
BHCC rel Branch if Half Carry Bit Clear (if H = 0) REL 28 rr 3 ppp – 1 1 – – – – –
BHCS rel Branch if Half Carry Bit Set (if H = 1) REL 29 rr 3 ppp – 1 1 – – – – –
BIH rel Branch if IRQ Pin High (if IRQ pin = 1) REL 2F rr 3 ppp – 1 1 – – – – –
BIL rel Branch if IRQ Pin Low (if IRQ pin = 0) REL 2E rr 3 ppp – 1 1 – – – – –
Affect
Address
Cycles
Mode
Source Cyc-by-Cyc on CCR
Operation Object Code
Form Details
V11H INZC
BIT #opr8i IMM A5 ii 2 pp
BIT opr8a DIR B5 dd 3 rpp
BIT opr16a Bit Test EXT C5 hh ll 4 prpp
BIT oprx16,X (A) & (M) IX2 D5 ee ff 4 prpp
0 1 1 – – Þ Þ –
BIT oprx8,X (CCR Updated but Operands Not IX1 E5 ff 3 rpp
BIT ,X Changed) IX F5 3 rfp
BIT oprx16,SP SP2 9E D5 ee ff 5 pprpp
BIT oprx8,SP SP1 9E E5 ff 4 prpp
Affect
Address
Cycles
Mode
Source Cyc-by-Cyc on CCR
Operation Object Code
Form Details
V11H INZC
Branch to Subroutine
PC ← (PC) + $0002
BSR rel push (PCL); SP ← (SP) – $0001 REL AD rr 5 ssppp – 1 1 – – – – –
push (PCH); SP ← (SP) – $0001
PC ← (PC) + rel
Affect
Address
Cycles
Mode
Source Cyc-by-Cyc on CCR
Operation Object Code
Form Details
V11H INZC
CPX #opr8i IMM A3 ii 2 pp
CPX opr8a DIR B3 dd 3 rpp
Compare X (Index Register Low) with
CPX opr16a EXT C3 hh ll 4 prpp
Memory
CPX oprx16,X IX2 D3 ee ff 4 prpp
X–M Þ 1 1 – – Þ Þ Þ
CPX oprx8,X IX1 E3 ff 3 rpp
(CCR Updated But Operands Not
CPX ,X IX F3 3 rfp
Changed)
CPX oprx16,SP SP2 9E D3 ee ff 5 pprpp
CPX oprx8,SP SP1 9E E3 ff 4 prpp
Divide
DIV INH 52 6 fffffp – 1 1 – – – Þ Þ
A ← (H:A)÷(X); H ← Remainder
Affect
Address
Cycles
Mode
Source Cyc-by-Cyc on CCR
Operation Object Code
Form Details
V11H INZC
LDA #opr8i IMM A6 ii 2 pp
LDA opr8a DIR B6 dd 3 rpp
LDA opr16a EXT C6 hh ll 4 prpp
LDA oprx16,X Load Accumulator from Memory IX2 D6 ee ff 4 prpp
0 1 1 – – Þ Þ –
LDA oprx8,X A ← (M) IX1 E6 ff 3 rpp
LDA ,X IX F6 3 rfp
LDA oprx16,SP SP2 9E D6 ee ff 5 pprpp
LDA oprx8,SP SP1 9E E6 ff 4 prpp
Unsigned multiply
MUL INH 42 5 ffffp – 1 1 0 – – – 0
X:A ← (X) × (A)
Affect
Address
Cycles
Mode
Source Cyc-by-Cyc on CCR
Operation Object Code
Form Details
V11H INZC
Negate M ← – (M) = $00
– (M)
(Two’s Complement) A ← – (A) = $00 –
NEG opr8a (A) DIR 30 dd 5 rfwpp
NEGA X ← – (X) = $00 – INH 40 1 p
NEGX (X) INH 50 1 p
Þ 1 1 – – Þ Þ Þ
NEG oprx8,X M ← – (M) = $00 IX1 60 ff 5 rfwpp
NEG ,X – (M) IX 70 4 rfwp
NEG oprx8,SP M ← – (M) = $00 SP1 9E 60 ff 6 prfwpp
– (M)
M ← – (M) = $00
– (M)
Affect
Address
Cycles
Mode
Source Cyc-by-Cyc on CCR
Operation Object Code
Form Details
V11H INZC
Reset Stack Pointer (Low Byte)
RSP SPL ← $FF INH 9C 1 p – 1 1 – – – – –
(High Byte Not Affected)
Affect
Address
Cycles
Mode
Source Cyc-by-Cyc on CCR
Operation Object Code
Form Details
V11H INZC
SUB #opr8i IMM A0 ii 2 pp
SUB opr8a DIR B0 dd 3 rpp
SUB opr16a EXT C0 hh ll 4 prpp
SUB oprx16,X Subtract IX2 D0 ee ff 4 prpp
Þ 1 1 – – Þ Þ Þ
SUB oprx8,X A ← (A) – (M) IX1 E0 ff 3 rpp
SUB ,X IX F0 3 rfp
SUB oprx16,SP SP2 9E D0 ee ff 5 pprpp
SUB oprx8,SP SP1 9E E0 ff 4 prpp
Software Interrupt
PC ← (PC) + $0001
Push (PCL); SP ← (SP) – $0001
Push (PCH); SP ← (SP) – $0001
Push (X); SP ← (SP) – $0001
SWI INH 83 11 sssssvvfppp – 1 1 – 1 – – –
Push (A); SP ← (SP) – $0001
Push (CCR); SP ← (SP) – $0001
I ← 1;
PCH ← Interrupt Vector High Byte
PCL ← Interrupt Vector Low Byte
TST opr8a Test for Negative or Zero (M) – $00 DIR 3D dd 4 rfpp
TSTA (A) – $00 INH 4D 1 p
TSTX (X) – $00 INH 5D 1 p
0 1 1 – – Þ Þ –
TST oprx8,X (M) – $00 IX1 6D ff 4 rfpp
TST ,X (M) – $00 IX 7D 3 rfp
TST oprx8,SP (M) – $00 SP1 9E 6D ff 5 prfpp
Affect
Address
Cycles
Mode
Source Cyc-by-Cyc on CCR
Operation Object Code
Form Details
V11H INZC
Transfer Index Reg. to SP
TXS INH 94 2 fp – 1 1 – – – – –
SP ← (H:X) – $0001
Note: All Sheet 2 Opcodes are Preceded by the Page 2 Prebyte (9E) Prebyte (9E) and Opcode in
Hexadecimal 9E60 6 HCS08 Cycles
NEG Instruction Mnemonic
Number of Bytes 3 SP1 Addressing Mode
PORT A
LCD25/ADC2/RX2/KBI5/PTA4
LCD24/ADC1/TX2/KBI4/PTA3
Real Time Counter
BKGD BKP LCD23/ADC0/SDA/PTA2
(RTC) LCD22/SCL/PTA1
LCD21/PTA0
HCS08 SYSTEM CONTROL Modulo Timer TMRCLK
PORT B
(MTIM) LCD[40:37]/PTB[7:4]
RESETS AND INTERRUPTS LCD[32:29]/PTB[3:0]
MODES OF OPERATION KBI[7:0]
BKGD/MS 8-BIT KEYBOARD
POWER MANAGEMENT
INTERRUPT (KBI)
RESET/PTC6
PORT C
SS BKGD/MS/PTC5
COP RESET SPSCK LCD[20:16]/PTC[4:0]
SERIAL PERIPHERAL MISO
IRQ INTERFACE (SPI)
IRQ LVD MOSI
PORT D
SCL LCD[7:0]/PTD[7:0]
USER FLASH A IIC MODULE (IIC) SDA
(LG32 = 16K BYTES)
PORT E
(LG16 = 2K BYTES) TPM2CH[5:0]
6-CHANNEL TIMER/PWM LCD[15:8]/PTE[7:0]
(TPM2) TPMCLK
USER FLASH B
(LG32 = 16K BYTES) TPM1CH[1:0]
2-CHANNEL TIMER/PWM EXTAL/PTF7
(LG16 = 16K BYTES) XTAL/PTF6
(TPM1) TPMCLK
TPM2CH3/KBI2/MOSI/PTF5
PORT F
TxD1 TPM2CH4/KBI1/MISO/PTF4
SERIAL COMMUNICATIONS
RxD1 TPM2CH5/KBI0/SS/PTF3
USER RAM INTERFACE (SCI1) ADC14/IRQ/TPM1CH1/SPSCK/PTF2
1984 BYTES ADC13/TPM1CH0/RX1/PTF1
TxD2 ADC12/TPM2CH2/KBI3/TX1/PTF0
SERIAL COMMUNICATIONS
RxD2
INTERFACE (SCI2)
PORT G
INTERNAL CLOCK LCD[44:41]/PTG[7:4]
Source (ICS) LCD[36:33]/PTG[3:0]
XTAL
LOW-POWER OSCILLATOR EXTAL
TPM2CH4/KBI1/PTH7
ADC15/KBI0/TPM2CH5/PTH6
PORT H
VLL3_2 12-BIT
ANALOG-TO-DIGITAL AD[15:0] ADC11/TPM1CH0/KBI3/TX1/PTH5
VLL3 ADC10/TPM1CH1/KBI2/RX1/PTH4
CONVERTER (ADC)
VLL1 LIQUID CRYSTAL ADC[9:6]/KBI[7:4]/PTH[3:0]
DISPLAY DRIVER
VLL2
(LCD) SS/SCL/TPM2CH0/PTI5
VCAP1
SPSCK/SDA/TPM2CH1/PTI4
PORT I
VCAP2 MOSI/TPM2CH2/PTI3
LCD[44:0] MISO/TPM2CH3/PTI2
TX2/TMRCLK/PTI1
RX2/PTI0
VDD
VSS
VOLTAGE
REGULATOR
VSS2 Available only on 80 pin package
Available only on 64 and 80 pin package
VDDA/VREFH */Default function out of reset/*
VSSA/VREFL
Figure 9-1. MC9S08LG32 Series Block Diagram Highlighting LCD Block and Pins
9.1.5 Features
The LCD module driver features include:
• LCD waveforms functional in wait, stop2 and stop3 low-power modes
• 45 LCD (LCD[44:0]) pins with selectable frontplane/backplane configuration
— Generate up to 44 frontplane signals
— Generate up to 8 backplanes signals
• Programmable LCD frame frequency
• Programmable blink modes and frequency
— All segments blank during blink period
— Alternate display for each LCD segment in x4 or less mode
— Blink operation in low-power modes
• Programmable LCD power supply switch, making it an ideal solution for battery-powered and
board-level applications
— Charge pump requires only four external capacitors
— Internal LCD power using VDD (1.8 to 3.6 V)
— External VLL3 power supply option (3V)
• Integrated charge pump for generating LCD bias voltages
— Hardware configurable to drive 3 V or 5 V LCD panels
— On-chip generation of bias voltages
• Waveform storage registers LCDWF
• Backplane reassignment to assist in vertical scrolling on dot-matrix displays
• Software configurable LCD frame frequency interrupt
• Internal ADC channels are connected to VLL1 to monitor their magnitudes. This feature allows
software to adjust the contrast.
Mode Operation
Stop2 Depending on the state of the LCDSTP bit, the LCD module can operate an LCD panel in stop2 mode. If
LCDSTP = 1, LCD module clock generation is turned off and the LCD module enters a power
conservation state and is disabled.If LCDSTP = 0, the LCD module can operate an LCD panel in stop2,
and the LCD module continues to display the current LCD panel contents based on the LCD operation
prior to the stop2 event.
If the LCD is enabled in stop2, the selected LCD clock source, OSCOUT, must be enabled to operate in
stop2.
The LCD frame interrupt does not cause the MCU to exit stop2.
Stop3 Depending on the state of the LCDSTP bit, the LCD module can operate an LCD panel in stop3 mode. If
LCDSTP = 1, LCD module clock generation is turned off and the LCD module enters a power
conservation state and is disabled. If LCDSTP = 0, the LCD module can operate an LCD panel in stop3,
and the LCD module continues displaying the current LCD panel contents based on the LCD operation
prior to the stop3 event.
If the LCD is enabled in stop3, the selected LCD clock source, OSCOUT, must be enabled to operate in
stop3.
In stop3 mode, the LCD frame interrupt can cause the MCU to exit stop3.
Wait Depending on the configuration, the LCD module can operate an LCD panel in wait mode. If LCDWAI = 1,
the LCD module clock generation is turned off and the LCD module enters a power-conservation state
and is disabled. If LCDWAI = 0, the LCD module can operate an LCD panel in wait, and the LCD module
continues displaying the current LCD panel contents base on the LCDWF registers.
In wait mode, the LCD frame interrupt can cause the MCU to exit wait.
Stop2 provides the lowest power consumption state where the LCD module is functional. To operate the
LCD in stop2 mode, use an external crystal.
Backplane Sequencer
ALT BLINK
BLANK BMODE
8 BP Phases
Write Buffer
IP
BUS LCD Sequenced
BUS LCD Waveform Registers FP or BP data
LCD[x]
MUX
FP or BP
LCDPEN
LCDBPEN
VDD
45 LCD frontplane/backplane LCD[44:0] Switchable frontplane/backplane driver that connects directly High impedance
to the display
LCD[44:0] can operate as GPIO pins
LCD bias voltages VLL1, LCD bias voltages —
VLL2,
VLL3, VLL3_2
LCD charge pump capacitance Vcap1, Vcap2 Charge pump capacitor pins —
9.2.1 LCD[44:0]
When LCD functionality is enabled by the PEN[44:0] bits in the LCDPEN registers, the corresponding
LCD[44:0] pin will generate a frontplane or backplane waveform depending on the configuration of the
backplane-enable bit field (BPEN[44:0]).
Read: anytime
Write: LCDEN anytime. Do not change SOURCE, LCLCK, or DUTY while LCDEN = 1.
Field Description
Eqn. 9-1
LCD Module Frame Frequency = LCDCLK where 30< LCDCLK < 39.063 kHz
((DUTY+1) x 8 x (4 + LCLK[2:0]) x Y)
where Y = 2,2,3,3,4,5,8,16 chosen
by module duty cycle configuration
2:0 LCD Duty Select — DUTY[2:0] bits select the duty cycle of the LCD module driver.
DUTY[2:0] 000 Use 1 BP (1/1 duty cycle).
001 Use 2 BP (1/2 duty cycle).
010 Use 3 BP (1/3 duty cycle).
011 Use 4 BP (1/4 duty cycle). (Default)
100 Use 5 BP (1/5 duty cycle).
101 Use 6 BP (1/6 duty cycle).
110 Use 7 BP (1/7 duty cycle).
111 Use 8 BP (1/8 duty cycle).
Read: anytime
Write: anytime
Field Description
7 LCD Module Frame Frequency Interrupt Enable — Enables an LCD interrupt event that coincides with the
LCDIEN LCD module frame frequency.
0 No interrupt request is generated by this event.
1 The start of the LCD module frame causes an LCD module frame frequency interrupt request.
2 Full Complementary Drive Enable — This bit allows GPIO that are shared with LCD pins to operate as full
FCDEN complementary if the other conditions necessary have been met. The other conditions are:
VSUPPLY = 11 and RVEN = 0.
0 GPIO shared with LCD operate as open drain outputs, input levels and internal pullup resistors are referenced
to VDD.
1 If VSUPPLY = 11 and RVEN = 0, GPIO shared with LCD operate as full complementary outputs. Input levels
and internal pullup resistors are referenced to VLL3.
1 LCD Module Driver and Charge Pump Stop While in Wait Mode
LCDWAI 0 Allows the LCD driver and charge pump to continue running during wait mode.
1 Disables the LCD driver and charge pump when MCU goes into wait mode.
0 LCD Module Driver and Charge Pump Stop While in Stop2 or Stop3 Mode
LCDSTP 0 Allows LCD module driver and charge pump to continue running during stop2 or stop3.
1 Disables LCD module driver and charge pump when MCU goes into stop2 or stop3.
Read: anytime
Write: anytime.
For proper operation, do not modify VSUPPLY[1:0] while the LCDEN bit is asserted. VSUPPLY[1:0]
must also be configured according to the external hardware power supply configuration.
Field Description
7 Charge Pump or Resistor Bias Select — Selects LCD module charge pump or a resistor network to supply the
CPSEL LCD voltages VLL1, VLL2, and VLL3. See Figure 9-16 for more detail.
0 LCD charge pump is disabled. Resistor network selected (The internal 1/3-bias is forced.)
1 LCD charge pump is selected. Resistor network disabled (The internal 1/3-bias is forced.)
6 High Reference Select— This feature is not available for MC9S08LG32 series. Writing to this bit is not
HREFSEL recommended.
5:4 LCD Module Load Adjust — The LCD load adjust bits are used to configure the LCD module to handle different
LADJ[1:0] LCD glass capacitance.
For CPSEL = 1
Adjust the clock source for the charge pump. Higher loads require higher charge pump clock rates.
00 - Fastest clock source for charge pump (LCD glass capacitance 8000pf or lower)
01 - Intermediate clock source for charge pump (LCD glass capacitance 6000pf or lower))
10 - Intermediate clock source for charge pump (LCD glass capacitance 4000pf or lower)
11 - Slowest clock source for charge pump (LCD glass capacitance 2000pf or lower)
For CPSEL = 0
Adjust the resistor bias network for different LCD glass capacitance
00 - Low Load (LCD glass capacitance 2000pf or lower)
01 - Low Load (LCD glass capacitance 2000pf or lower)
10 - High Load (LCD glass capacitance 8000pf or lower)
11 - High Load (LCD glass capacitance 8000pf or lower)
2 Op Amp Control — This feature is not available for MC9S08LG32 series. Writing to this bit is not recommended.
BBYPASS
1:0 Voltage Supply Control — Configures whether the LCD module power supply is external or internal. Avoid
VSUPPLY[1:0] modifying this bit field while the LCD module is enabled (e.g., LCDEN = 1). See Figure 9-16 for more detail.
00 Drive VLL2 internally from VDD
01 Drive VLL3 internally from VDD
10 Reserved
11 Drive VLL3 externally
Read: anytime.
Write: anytime.
This register is not available for MC9S08LG32 series. Writing to this bit is not recommended.
Read: anytime
Write: anytime
Field Description
5 Blank Display Mode — Asserting this bit clears all segments in the LCD display.
BLANK 0 Normal or Alternate Display
1 Blank Display Mode
3 Blink Mode — Selects the blink mode displayed during the blink period. See Table 9-6 for more information on
BMODE how BMODE affects the LCD display.
0 Display blank during the blink period
1 Display alternate display during blink period (Ignored if duty is 5 or greater)
2:0 Blink-Rate Configuration— Selects frequency at which the LCD display blinks when the BLINK is asserted.
BRATE[2:0] Equation 9-2 shows how BRATE[2:0] bit field is used in the LCD blink-rate calculation.
Equation 9-2 provides an expression for the LCD module blink rate
Eqn. 9-2
LCDCLK
LCD module blink rate =
2 (12+ BRATE[2:0])
LCD module blink rate calculations are provided in Section 9.4.3.2, “Blink Frequency.”
Read: anytime
Write: anytime
Table 9-7. LCDS Field Descriptions
Field Description
7 LCD Interrupt Flag — LCDIF indicates an interrupt condition occurred. To clear the interrupt write a 1 to LCDIF.
LCDIF 0 interrupt condition has not occurred.
1 interrupt condition has occurred.
7 6 5 4 3 2 1 0
R
LCDPEN0 PEN7 PEN6 PEN5 PEN4 PEN3 PEN2 PEN1 PEN0
W
Reset Indeterminate after reset
R
LCDPEN1 PEN15 PEN14 PEN13 PEN12 PEN11 PEN10 PEN9 PEN8
W
Reset Indeterminate after reset
R
LCDPEN2 PEN23 PEN22 PEN21 PEN20 PEN19 PEN18 PEN17 PEN16
W
Reset Indeterminate after reset
R
LCDPEN3 PEN31 PEN30 PEN29 PEN28 PEN27 PEN26 PEN25 PEN24
W
Reset Indeterminate after reset
R
LCDPEN4 PEN39 PEN38 PEN37 PEN36 PEN35 PEN34 PEN33 PEN32
W
Reset Indeterminate after reset
R
LCDPEN5 PEN44 PEN43 PEN42 PEN41 PEN40
W
Reset Indeterminate after reset
Unimplemented or Reserved
Figure 9-9. LCD Pin Enable Registers 0–5 (LCDPEN0–LCDPEN5)
Read: anytime
Write: anytime
Table 9-8. LCDPEN0–LCDPEN5 Field Descriptions
Field Description
44:0 LCD Pin Enable — The PEN[44:0] bit enables the LCD[44:0] pin for LCD operation. Each LCD[44:0] pin can be
PEN[44:0] configured as a backplane or a frontplane based on the corresponding BPEN[n] bit in the Backplane Enable
Register (LCDBPEN[5:0]). If LCDEN = 0, these bits have no effect on the state of the I/O pins. Set PEN[44:0]
bits before LCDEN is set.
0 LCD operation disabled on LCDnn.
1 LCD operation enabled on LCDnn.
7 6 5 4 3 2 1 0
R
LCDBPEN0 BPEN7 BPEN6 BPEN5 BPEN4 BPEN3 BPEN2 BPEN1 BPEN0
W
Reset Indeterminate after reset
R
LCDBPEN1 BPEN15 BPEN14 BPEN13 BPEN12 BPEN11 BPEN10 BPEN9 BPEN8
W
Reset Indeterminate after reset
R
LCDBPEN2 BPEN23 BPEN22 BPEN21 BPEN20 BPEN19 BPEN18 BPEN17 BPEN16
W
Reset Indeterminate after reset
R
LCDBPEN3 BPEN31 BPEN30 BPEN29 BPEN28 BPEN27 BPEN26 BPEN25 BPEN24
W
Reset Indeterminate after reset
R
LCDBPEN4 BPEN39 BPEN38 BPEN37 BPEN36 BPEN35 BPEN34 BPEN33 BPEN32
W
Reset Indeterminate after reset
R
LCDBPEN5 BPEN44 BPEN43 BPEN42 BPEN41 BPEN40
W
Reset Indeterminate after reset
Unimplemented or Reserved
Figure 9-10. Backplane Enable Registers 0–5 (BPEN0–BPEN5)
Read: anytime
Write: anytime
Table 9-9. LCDBPEN0–LCDBPEN5 Field Descriptions
Field Description
44:0 Backplane Enable — The BPEN[44:0] bit configures the LCD[44:0] pin to operate as an LCD backplane or LCD
BPEN[44:0] frontplane. If LCDEN = 0, these bits have no effect on the state of the I/O pins. It is recommended to set
BPEN[44:0] bits before LCDEN is set.
0 Frontplane operation enabled on LCD[n].
1 Backplane operation enabled on LCD[n].
7 6 5 4 3 2 1 0
R
LCDWF0 BPHLCD0 BPGLCD0 BPFLCD0 BPELCD0 BPDLCD0 BPCLCD0 BPBLCD0 BPALCD0
W
Reset Indeterminate after reset
R
LCDWF1 BPHLCD1 BPGLCD1 BPFLCD1 BPELCD1 BPDLCD1 BPCLCD1 BPBLCD1 BPALCD1
W
Reset Indeterminate after reset
R
LCDWF2 BPHLCD2 BPGLCD2 BPFLCD2 BPELCD2 BPDLCD2 BPCLCD2 BPBLCD2 BPALCD2
W
Reset Indeterminate after reset
R
LCDWF3 BPHLCD3 BPGLCD3 BPFLCD3 BPELCD3 BPDLCD3 BPCLCD3 BPBLCD3 BPALCD3
W
Reset Indeterminate after reset
R
LCDWF4 BPHLCD4 BPGLCD4 BPFLCD4 BPELCD4 BPDLCD4 BPCLCD4 BPBLCD4 BPALCD4
W
Reset Indeterminate after reset
R
LCDWF5 BPHLCD5 BPGLCD5 BPFLCD5 BPELCD5 BPDLCD5 BPCLCD5 BPBLCD5 BPALCD5
W
Reset Indeterminate after reset
R
LCDWF6 BPHLCD6 BPGLCD6 BPFLCD6 BPELCD6 BPDLCD6 BPCLCD6 BPBLCD6 BPALCD6
W
Reset Indeterminate after reset
R
LCDWF7 BPHLCD7 BPGLCD7 BPFLCD7 BPELCD7 BPDLCD7 BPCLCD7 BPBLCD7 BPALCD7
W
Reset Indeterminate after reset
R
LCDWF8 BPHLCD8 BPGLCD8 BPFLCD8 BPELCD8 BPDLCD8 BPCLCD8 BPBLCD8 BPALCD8
W
Reset Indeterminate after reset
R
LCDWF9 BPHLCD9 BPGLCD9 BPFLCD9 BPELCD9 BPDLCD9 BPCLCD9 BPBLCD9 BPALCD9
W
Reset Indeterminate after reset
R
LCDWF10 BPHLCD10 BPGLCD10 BPFLCD10 BPELCD10 BPDLCD10 BPCLCD10 BPBLCD10 BPALCD10
W
Reset Indeterminate after reset
R
LCDWF11 BPHLCD11 BPGLCD11 BPFLCD11 BPELCD11 BPDLCD11 BPCLCD11 BPBLCD11 BPALCD11
W
Reset Indeterminate after reset
R
LCDWF12 BPHLCD12 BPGLCD12 BPFLCD12 BPELCD12 BPDLCD12 BPCLCD12 BPBLCD12 BPALCD12
W
Reset Indeterminate after reset
R
LCDWF13 BPHLCD13 BPGLCD13 BPFLCD13 BPELCD13 BPDLCD13 BPCLCD13 BPBLCD13 BPALCD13
W
Reset Indeterminate after reset
R
LCDWF14 BPHLCD14 BPGLCD14 BPFLCD14 BPELCD14 BPDLCD14 BPCLCD14 BPBLCD14 BPALCD14
W
Reset Indeterminate after reset
R
LCDWF15 BPHLCD15 BPGLCD15 BPFLCD15 BPELCD15 BPDLCD15 BPCLCD15 BPBLCD15 BPALCD15
W
Reset Indeterminate after reset
R
LCDWF16 BPHLCD16 BPGLCD16 BPFLCD16 BPELCD16 BPDLCD16 BPCLCD16 BPBLCD16 BPALCD16
W
Reset Indeterminate after reset
R
LCDWF17 BPHLCD17 BPGLCD17 BPFLCD17 BPELCD17 BPDLCD17 BPCLCD17 BPBLCD17 BPALCD17
W
Reset Indeterminate after reset
R
LCDWF18 BPHLCD18 BPGLCD18 BPFLCD18 BPELCD18 BPDLCD18 BPCLCD18 BPBLCD18 BPALCD18
W
Reset Indeterminate after reset
R
LCDWF19 BPHLCD19 BPGLCD19 BPFLCD19 BPELCD19 BPDLCD19 BPCLCD19 BPBLCD19 BPALCD19
W
Reset Indeterminate after reset
R
LCDWF20 BPHLCD20 BPGLCD20 BPFLCD20 BPELCD20 BPDLCD20 BPCLCD20 BPBLCD20 BPALCD20
W
Reset Indeterminate after reset
R
LCDWF21 BPHLCD21 BPGLCD21 BPFLCD21 BPELCD21 BPDLCD21 BPCLCD21 BPBLCD21 BPALCD21
W
Reset Indeterminate after reset
R
LCDWF22 BPHLCD22 BPGLCD22 BPFLCD22 BPELCD22 BPDLCD22 BPCLCD22 BPBLCD22 BPALCD22
W
Reset Indeterminate after reset
R
LCDWF23 BPHLCD23 BPGLCD23 BPFLCD23 BPELCD23 BPDLCD23 BPCLCD23 BPBLCD23 BPALCD23
W
Reset Indeterminate after reset
R
LCDWF24 BPHLCD24 BPGLCD24 BPFLCD24 BPELCD24 BPDLCD24 BPCLCD24 BPBLCD24 BPALCD24
W
Reset Indeterminate after reset
R
LCDWF25 BPHLCD25 BPGLCD25 BPFLCD25 BPELCD25 BPDLCD25 BPCLCD25 BPBLCD25 BPALCD25
W
Reset Indeterminate after reset
R
LCDWF26 BPHLCD26 BPGLCD26 BPFLCD26 BPELCD26 BPDLCD26 BPCLCD26 BPBLCD26 BPALCD26
W
R
LCDWF40 BPHLCD40 BPGLCD40 BPFLCD40 BPELCD40 BPDLCD40 BPCLCD40 BPBLCD40 BPALCD40
W
Reset Indeterminate after reset
R
LCDWF41 BPHLCD41 BPGLCD41 BPFLCD41 BPELCD41 BPDLCD41 BPCLCD41 BPBLCD41 BPALCD41
W
Reset Indeterminate after reset
R
LCDWF42 BPHLCD42 BPGLCD42 BPFLCD42 BPELCD42 BPDLCD42 BPCLCD42 BPBLCD42 BPALCD42
W
Reset Indeterminate after reset
R
LCDWF43 BPHLCD43 BPGLCD43 BPFLCD43 BPELCD43 BPDLCD43 BPCLCD43 BPBLCD43 BPALCD43
W
Reset Indeterminate after reset
R
LCDWF44 BPHLCD44 BPGLCD44 BPFLCD44 BPELCD44 BPDLCD44 BPCLCD44 BPBLCD44 BPALCD44
W
Reset Indeterminate after reset
Field Description
BP[y]LCD[x] Segment-on-Frontplane Operation — If the LCD[x] pin is enabled and configured to operate as a frontplane,
the BP[y]LCD[x] bit in the LCDWF registers controls the on/off state for the LCD segment connected between
LCD[x] and BP[y].BP[y] corresponds to an LCD[44:0] pin enabled and configured to operate as a backplane that
is active in phase [y]. Asserting BP[y]LCD[x] displays (turns on) the LCD segment connected between LCD[x]
and BP[y].
0 LCD segment off
1 LCD segment on
Segment-on-Backplane Operation — If the LCD[x] pin is enabled and configured to operate as a backplane,
the BP[y] LCD[x] bit in the LCDWF registers controls the phase (A-H) in which the LCD[x] pin is active.Backplane
phase assignment is done using this method.
0 LCD backplane inactive for phase[y]
1 LCD backplane active for phase[y].
In multiplexed mode, the LCD waveforms are multi-level and depend on the bias mode. Multiplex mode,
depending on the number of backplanes, can drive multiple LCD segments with a single frontplane driver.
This reduces the number of driver circuits and connections to LCD segments. For multiplex mode
operation, at least two backplane drivers are needed. The LCD module is optimized for multiplex mode.
The duty cycle indicates the amount of time the LCD panel segment is energized during each LCD module
frame cycle. The denominator of the duty cycle indicates the number of backplanes that are being used to
drive an LCD panel.
The duty cycle is used by the backplane phase generator to set the phase outputs. The phase outputs A-H
are driven according to the sequence shown below. The sequence is repeated at the LCD frame frequency.
The duty cycle is configured using the DUTY[2:0] bit field in the LCDC0 register, as shown in Table 9-11.
Phase
LCDC0 Register Number of Backplanes
Duty Sequence
DUTY2 DUTY1 DUTY0
1/1 0 0 0 1 A
1/2 0 0 1 2 AB
1/3 0 1 0 3 ABC
1/4 0 1 1 4 ABCD
1/5 1 0 0 5 ABCDE
1/6 1 0 1 6 ABCDEF
1/7 1 1 0 7 ABCDEFG
1/8 1 1 1 8 ABCDEFGH
SOURCE BRATE[2:0]
LCLK[2:0]
An external 32.768 kHz clock input is required to achieve lowest power consumption.
The value of LCDCLK is important because it is used to generate the LCD module frame frequency.
Equation 9-1 provides an expression for the LCD module frame frequency calculation.
The LCD module frame frequency is a function of the LCD module duty cycle as shown in Equation 9-1.
Table 9-13 and Table 9-12 show LCD module frame frequency calculations that consider several possible
LCD module configurations of LCLK[2:0] and DUTY[2:0].
The LCD module frame frequency is defined as the number of times the LCD segments are energized per
second. The LCD module frame frequency must be selected to prevent the LCD display from flickering
(LCD module frame frequency is too low) or ghosting (LCD module frame frequency is too high). To
avoid these issues, an LCD module frame frequency in the range of 28 to 58 Hz is required. LCD module
frame frequencies less than 28 Hz or greater than 58 Hz are out of specification, and so are invalid.
Selecting lower values for the LCD base and frame frequency results in lower current consumption for the
LCD module.
The LCD module base clock frequency is the LCD module frame frequency multiplied by the number of
backplane phases that are being generated. The number of backplane phases is selected using the
DUTY[2:0] bits. The LCD module base clock is used by the backplane sequencer to generate the LCD
waveform data for the enabled phases (A-H).
Duty
1/1 1/2 1/3 1/4 1/5 1/6 1/7 1/8
Cycle
Y 16 8 5 4 3 3 2 2
LCLK[2:0]
0 64 64 68.3 64 68.3 56.9 73.1 64
1 51.2 51.2 54.6 51.2 54.6 45.5 58.5 51.2
2 42.7 42.7 45.5 42.7 45.5 37.9 48.8 42.7
3 36.6 36.6 39 36.6 39 32.5 41.8 36.6
4 32 32 34.1 32 34.1 28.4 36.6 32
5 28.4 28.4 30.3 28.4 30.3 25.3 32.5 28.4
6 25.6 25.6 27.3 25.6 27.3 22.8 29.3 25.6
7 23.3 23.3 24.8 23.3 24.8 20.7 26.6 23.3
1
LCD clock input ~ 32.768 kHz
Shaded table entries would take higher current.
Duty
1/1 1/2 1/3 1/4 1/5 1/6 1/7 1/8
Cycle
Y 16 8 5 4 3 3 2 2
LCLK[2:0]
0 76.3 76.3 81.4 76.3 81.4 67.8 87.2 76.3
1 61 61 65.1 61 65.1 54.3 69.8 61
2 50.9 50.9 54.3 50.9 54.3 45.2 58.1 50.9
3 43.6 43.6 46.5 43.6 46.5 38.8 49.8 43.6
4 38.1 38.1 40.7 38.1 40.7 33.9 43.6 38.1
5 33.9 33.9 36.2 33.9 36.2 30.1 38.8 33.9
6 30.5 30.5 32.6 30.5 32.6 27.1 34.9 30.5
7 27.7 27.7 29.6 27.7 29.6 24.7 31.7 27.7
1
LCD clock input ~ 39.063 kHz
Shaded table entries would take higher current.
9.4.1.4.1 1/2 Duty Multiplexed with 1/3 Bias Mode (Low-power Waveform)
Duty=1/2:DUTY[2:0] = 001
LCD pin 0 (LCD[0])and LCD pin 1, LCD[1] enabled as backplanes:
BPEN0 =1 and BPEN1 =1 in the LCDBPEN0
LCD[0] assigned to Phase A: LCDWF0 = 0x01
LCD[1] assigned to Phase B: LCDWF1 = 0x02
1 Frame
Base_Clk
Frame Interrupt
VLL3
LCD[0]/BP0 VLL2
VLL1
0
VLL3
LCD[1]/BP1 VLL2
VLL1
0
VLL3
VLL2
LCDWF[n]= 0x02 VLL1
= 00000010 0
VLL3
VLL2
BP0-FPn (OFF) VLL1
0
-VLL1
-VLL2
-VLL3
VLL3
VLL2
VLL1
BP1-FPn (ON) 0
-VLL1
-VLL2
-VLL3
9.4.1.4.2 1/4 Duty Multiplexed with 1/3 Bias Mode (Low-power Waveform)
Duty = 1/4: DUTY[2:0] = 011
LCD pins 0 – 3 enabled as backplanes: LCDBPEN0 = 0x0F
LCD[0] assigned to Phase A: LCDWF0 = 0x01
LCD[1] assigned to Phase B: LCDWF1 = 0x02
LCD[2] assigned to Phase C: LCDWF2 = 0x04
LCD[3] assigned to Phase D: LCDWF3 = 0x08
1 Frame
Phase Phase
A B C D A B C D A B C D A B C D
Base_Clk
Frame Interrupt
VLL3
VLL2
LCD[0]/BP0 VLL1
0
VLL3
VLL2
LCD[1]/BP1 VLL1
0
VLL3
LCD[2]/BP2 VLL2
VLL1
0
VLL3
LCD[3]/BP3 VLL2
VLL1
0
VLL3
LCDWFn(0x09) VLL2
=00001001 VLL1
0
VLL3
VLL2
VLL1
BP0–FPn (ON) 0
-VLL1
-VLL2
-VLL3
VLL3
VLL2
VLL1
BP1–FPn (OFF) 0
-VLL1
-VLL2
-VLL3
9.4.1.4.3 1/8 Duty Multiplexed with 1/3 Bias Mode (Low-power Waveform)
Duty = 1/8:DUTY[2:0] = 111
LCD pins 0 – 7 enabled as backplanes: LCDBPEN0 = 0xFF
LCD[0] assigned to Phase A: LCDWF0 = 0x01
LCD[1] assigned to Phase B: LCDWF1 = 0x02
LCD[2] assigned to Phase C: LCDWF2 = 0x04
LCD[3] assigned to Phase D: LCDWF3 = 0x08
LCD[4] assigned to Phase E: LCDWF4 = 0x10
LCD[5] assigned to Phase F: LCDWF5 = 0x20
LCD[6] assigned to Phase G: LCDWF6 = 0x40
LCD[7] assigned to Phase H: LCDWF7 = 0x80
1 Frame
Phase Phase
A B C D E F G H A B C D E F G H
Base_Clk
VLL3
VLL2
LCD[0]/BP0 VLL1
0
VLL3
LCD[1]/BP1 VLL2
VLL1
0
VLL3
LCD[2]/BP2 VLL2
VLL1
0
VLL3
LCD[3]/BP3 VLL2
VLL1
0
VLL3
LCD[4]/BP4 VLL2
VLL1
0
VLL3
VLL2
LCD[5]/BP5 VLL1
0
VLL3
LCD[6]/BP6 VLL2
VLL1
0
VLL3
LCD[7]/BP7 VLL2
VLL1
0
VLL3
VLL2
LCDWFn(0x69) VLL1
0
VLL3
VLL2
BP0–FPn (ON) VLL1
0
-VLL1
-VLL2
-VLL3
VLL3
VLL2
VLL1
BP1–FPn (OFF) 0
-VLL1
-VLL2
-VLL3
1/1 A E
1/2 AB EF
BLINK = 1
BLANK ALT BMODE LCD Duty
BRATE[2:0] 0 1 2 3 4 5 6 7
9.4.4 LCD Charge Pump, Voltage Divider, and Power Supply Operation
This section describes the LCD charge pump, voltage divider, and LCD power supply configuration
options. Figure 9-16 provides a block diagram for the LCD charge pump and the resistor divider network.
For charge pump option please refer to Note 2 at start of chapter.
The LCD bias voltages (VLL1, VLL2 and VLL3) can be generated by the LCD charge pump or a resistor
divider network that is connected using the CPSEL bit. The input source to the LCD charge pump is
controlled by the VSUPPLY[1:0] bit field.
VSUPPLY[1:0] indicates the state of internal signals used to configure power switches as shown in the
table in Figure 9-16. The block diagram in Figure 9-16 illustrates several potential operational modes for
the LCD module including configuration of the LCD module power supply source using VDD or an
external supply on the VLL3/VLL3_2 pins.
Upon Reset the VSUPPLY[1:0] bits are configured to connect VLL3 to VDD. This configuration should be
changed to match the application requirements before the LCD module is enabled.
VDD
powersw1
powersw2
~CPSEL
~CPSEL
~CPSEL
VLL1
CHARGE PUMP VLL2
VLL3
Figure 9-16. LCD Charge Pump and Voltage Divider Block Diagram
NOTE:
The charge pump is optimized for 1/3 bias mode operation only.
During the first 16 timebase clock cycles after the LCDPEN bit is set, all the
LCD frontplane and backplane outputs are disabled, regardless of the state
of the LCDEN bit.
The charge pump requires external capacitance for its operation. To provide
this external capacitance, the Vcap1 and Vcap2 external pins are provided. It
is recommended that a ceramic capacitor be used. Proper orientation is
imperative when using a polarized capacitor. The recommended value for
the external capacitor is 0.1 μF.
VSUPPLY[1:0]
CPSEL
LCD Operational State LCD Power Supply Configuration
VLL3 is driven internally for 5 V LCD Glass For 5 V glass operation VLL3 must equal 5 V.
operation.
Resistor Bias network enabled. Charge pump is disabled. 01 0
VLL3 must equal VDD
Resistor Bias network is used to create VLL1 and VLL2.
VLL2 connected to VDD internally for 3 or For 3 V glass operation VDD must equal 2 V.
5 V glass operation.
For 5 V glass operation VDD must equal 3.33 V 00 1
VLL3 connected to VDD internally for 3 V or For 3 V glass operation VDD must equal 3 V.
5 V glass operation
For 5 V glass operation VDD must equal 5 V. 01 1
VLL3 is driven externally for For 3 V glass operation VLL3 must equal 3 V.
3 V LCD Glass operation. 11 1
Charge pump is used to generate VLL1 and VLL2
VLL3 is driven externally for 5 V LCD Glass For 5 V glass operation VLL3 must equal 5 V.
operation. 11 1
VLL3 must equal VDD Charge pump is used to generate VLL1 and VLL2
VSUPPLY[1:0]
CPSEL
LCD Operational State LCD Power Supply Configuration
VLL3 is driven externally for 3 V LCD Glass For 3 V glass operation VLL3 must equal 3 V.
operation.
Charge pump is disabled. 11 0
Resistor Bias Network enabled.
Resistor Bias network is used to create VLL1 and VLL2
VLL3 is driven externally for 5 V LCD Glass For 5 V glass operation VLL3 must equal 5 V.
operation. Resistor Bias network enabled.
Charge pump is disabled. 11 0
VLL3 must equal VDD
Resistor Bias network is used to create VLL1 and VLL2 .
9.4.5 Resets
During a reset, the LCD module system is configured in the default mode. The default mode includes the
following settings:
• LCDEN is cleared, thereby forcing all frontplane and backplane driver outputs to the high
impedance state.
• 1/4 duty
• 1/3 bias
• LCLK[2:0], VSUPPLY[1:0], CPSEL and BRATE[2:0] revert to their reset values
9.4.6 Interrupts
When an LCD module frame-frequency interrupt event occurs, the LCDIF bit in the LCDS register is
asserted. The LCDIF bit remains asserted until software clears the LCD-module-frame-frequency
interrupt. The interrupt can be cleared by software writing a 1 to the LCDIF bit.
If both the LCDIF bit in the LCDS register and the LCDIEN bit in the LCDC1 register are set, an LCD
interrupt signal asserts.
6. LCDPEN[5:0] register
a) Enable LCD module pins (PEN[44:0] bits).
7. LCDBPEN[5:0]
a) Enable LCD pins to operate as an LCD backplane (BPEN[44:0]).
8. LCDC0 register
a) Enable LCD module (LCDEN bit).
These examples illustrate the flexibility of the LCD module to be configured to meet a wide range of
application requirements including:
• Clock inputs/sources
• LCD power supply
• LCD glass operating voltage
• LCD segment count
• Varied blink modes/frequencies
• LCD frame rate
The table below lists the setup values required to initialize the LCD as specified by Example 1:
Table 9-23. Initialization Register Values for Example 1
bit or Binary
Register Comment
bit field Value
VSUPPLY[1:0] 11 When VSUPPLY[1:0] = 11, the LCD must be externally powered via VLL3 (see
Table 9-19). For 5V glass, the nominal value of VLL3 should be 5V.
LCLK[2:0] 101 For 1/8 duty cycle, select closest value to the desired 30 Hz LCD frame frequency
(see Table 9-12)
DUTY[2:0] 111 For 128 segments (8x16), select 1/8 duty cycle
LCDWF[44:0] LCDWF0 00000001 Configure which phase the eight backplane pins will be active in. This
LCDWF1 00000010 configuration sets LCD[0] to be active in Phase A, LCD[1] to be active in Phase
LCDWF2 00000100 B...etc
LCDWF3 00001000
LCDWF4 00010000 Note: Any backplane pin can be active in any phase.
LCDWF5 00100000
LCDWF6 01000000
LCDWF7 10000000
The table below lists the required setup values required to initialize the LCD as specified by Example 2:
Table 9-24. Initialization Register Values for Example 2
bit or Binary
Register Comment
bit field Value
SOURCE 1 Selects the alternate-clock reference as the LCD clock input (ALTCLK)
This clock source is configured by the ICS TRIM bits to be 39.063Khz.
LCLK[2:0] 010 For 1/4 duty cycle, select closest value to the desired 50 Hz LCD frame
frequency (Table 9-13)
DUTY[2:0] 011 For 100 segments (4x25), select 1/4 duty cycle
bit or Binary
Register Comment
bit field Value
LCDWF[44:0] LCDWF0 00000001 Configure which phase the four backplane pins will be active in. This
LCDWF1 00000010 configuration sets LCD[0] to be active in Phase A, LCD[1] to be active in
LCDWF2 00000100 Phase B etc.
LCDWF3 00001000
Note: Any backplane pin can be active in any of the phases.
The table below lists the required setup values required to initialize the LCD as specified by Example 3:
Table 9-25. Initialization Register Values for Example 3
bit or Binary
Register Comment
bit field Value
LCLK[2:0] 101 For 1/8 duty cycle, select closest value to the desired 30 Hz LCD frame
frequency (see Table 9-12)
DUTY[2:0] 111 For 168 segments (8x21), select 1/8 duty cycle
bit or Binary
Register Comment
bit field Value
LCDWF[44:0] LCDWF0 00000001 Configure which phase the eight backplane pins will be active in. This
LCDWF1 00000010 configuration sets LCD[0] to be active in Phase A, LCD[1] to be active in
LCDWF2 00000100 Phase B. . . etc.
LCDWF3 00001000
LCDWF4 00010000 This configuration sets LCD pins 0-7 to represent backplane 1-8.
LCDWF5 00100000
LCDWF6 01000000 Note: Any backplane pin can be active in any phase
LCDWF7 10000000
LCD Frame
Frequency LCDC1 LCDS
Interrupt LCDIEN LCDIF
Backplane Enable
LCDBPEN[5:0]
BPEN[44:0]
LCDWF contents and output waveforms are also shown. Output waveforms are illustrated in Figure 9-18
and Figure 9-19.
FP Connection BP Connection
a a
LCDWF3 0 0 0 0 0 0 0 1
LCDWF4 0 0 0 0 0 0 1 0
LCDWF5 0 0 0 0 0 1 0 0
LCDWF0 – – – – – e f –
LCDWF1 – – – – – d g a
LCDWF2 – – – – – – c b
To display the character “4”: LCDWF0 = XXXXX01X, LCDWF1 = XXXXX010, LCDWF2 =XXXXXX11
LCDWF0 X X X X X 0 1 X a
f g b
LCDWF1 X X X X X 0 1 0
e c
d
LCDWF2 X X X X X X 1 1
X = don’t care
Figure 9-18. Waveform Output from LCDWF Registers
V3
V2
LCD4/BP1 V1
V0
V3
V2
LCD5/BP2
V1
V0
V3
BPCLCD0 BPBLCD0 BPALCD0 V2
— 0 1 0 LCD0/FP0 V1
V0
V3
BPCLCD1 BPBLCD1 BPALCD1 V2
— 0 1 0 LCD1/FP1 V1
V0
V3
BPCLCD2 BPBLCD2 BPALCD2 V2
LCD2/FP2 V1
— 0 1 1
V0
VLL3
VLL2 R
LCD Power Pins
VLL1
CTYP = 0.1 μF
Vcap1 Vcap2
0.1 μF
LCD charge pump capacitance
HC9S08LG32
Power Supply
VLL3 LCD Power Pins
VLL2
VDD
VLL1
R CTYP = 0.1 μF
Vcap1 Vcap2
0.1 μF
LCD charge pump capacitance
PORT A
LCD25/ADC2/RX2/KBI5/PTA4
LCD24/ADC1/TX2/KBI4/PTA3
BKGD/MS Real Time Counter
BKGD BKP LCD23/ADC0/SDA/PTA2
(RTC) LCD22/SCL/PTA1
LCD21/PTA0
HCS08 SYSTEM CONTROL Modulo Timer TMRCLK
PORT B
(MTIM) LCD[40:37]/PTB[7:4]
RESETS AND INTERRUPTS LCD[32:29]/PTB[3:0]
MODES OF OPERATION KBI[7:0]
8-BIT KEYBOARD
POWER MANAGEMENT
INTERRUPT (KBI)
RESET/PTC6
PORT C
SS BKGD/MS/PTC5
COP RESET SPSCK LCD[20:16]/PTC[4:0]
SERIAL PERIPHERAL MISO
IRQ INTERFACE (SPI)
IRQ LVD MOSI
PORT D
SCL LCD[7:0]/PTD[7:0]
USER FLASH A IIC MODULE (IIC) SDA
(LG32 = 16K BYTES)
PORT E
(LG16 = 2K BYTES) TPM2CH[5:0]
6-CHANNEL TIMER/PWM LCD[15:8]/PTE[7:0]
(TPM2) TPMCLK
USER FLASH B
(LG32 = 16K BYTES) TPM1CH[1:0]
2-CHANNEL TIMER/PWM EXTAL/PTF7
(LG16 = 16K BYTES) XTAL/PTF6
(TPM1) TPMCLK
TPM2CH3/KBI2/MOSI/PTF5
PORT F
TxD1 TPM2CH4/KBI1/MISO/PTF4
SERIAL COMMUNICATIONS
RxD1 TPM2CH5/KBI0/SS/PTF3
USER RAM INTERFACE (SCI1) ADC14/IRQ/TPM1CH1/SPSCK/PTF2
1984 BYTES ADC13/TPM1CH0/RX1/PTF1
TxD2 ADC12/TPM2CH2/KBI3/TX1/PTF0
SERIAL COMMUNICATIONS
RxD2
INTERFACE (SCI2)
PORT G
INTERNAL CLOCK LCD[44:41]/PTG[7:4]
Source (ICS) LCD[36:33]/PTG[3:0]
XTAL
LOW-POWER OSCILLATOR EXTAL
TPM2CH4/KBI1/PTH7
ADC15/KBI0/TPM2CH5/PTH6
PORT H
VLL3_2 12-BIT
ANALOG-TO-DIGITAL AD[15:0] ADC11/TPM1CH0/KBI3/TX1/PTH5
VLL3
CONVERTER (ADC) ADC10/TPM1CH1/KBI2/RX1/PTH4
VLL1 LIQUID CRYSTAL ADC[9:6]/KBI[7:4]/PTH[3:0]
VLL2 DISPLAY DRIVER
(LCD) SS/SCL/TPM2CH0/PTI5
VCAP1
SPSCK/SDA/TPM2CH1/PTI4
PORT I
VCAP2 MOSI/TPM2CH2/PTI3
LCD[44:0] MISO/TPM2CH3/PTI2
TX2/TMRCLK/PTI1
RX2/PTI0
VDD
VSS
VOLTAGE
REGULATOR
VSS2 Available only on 80-pin package
Available only on 64-pin and 80-pin package
VDDA/VREFH */Default function out of reset/*
VSSA/VREFL
Figure 10-1. MC9S08LG32 Series Block Diagram Highlighting ADC Block and Pins
ADCH Channel Input Pin Control ADCH Channel Input Pin Control
NOTE
Selecting the internal bandgap channel requires BGBE = 1 in SPMSC1, see
Section 5.8.7, “System Power Management Status and Control 1 Register
(SPMSC1),” for more details. For value of bandgap voltage reference, see
MC9S08LG32 Data Sheet.
ALTCLK on the MC9S08LG32 series is connected to the ICSERCLK. See Chapter 11, “Internal Clock
Source (S08ICSV3),” for more information.
where:
— VTEMP is the voltage of the temperature sensor channel at the ambient temperature.
— VTEMP25 is the voltage of the temperature sensor channel at 25 °C.
— m is the hot or cold voltage versus temperature slope in V/°C.
For temperature calculations, use the VTEMP25 and m values in the MC9S08LG32 Data Sheet.
In application code, you read the temperature sensor channel, calculate VTEMP, and compare it to
VTEMP25. If VTEMP is greater than VTEMP25 the cold slope value is applied in Equation 10-1. If VTEMP is
less than VTEMP25 the hot slope value is applied in Equation 10-1.
10.1.5 Features
Features of the ADC module include:
• Linear successive approximation algorithm with 12-bit resolution
• Up to 28 analog inputs
• Output formatted in 12-, 10-, or 8-bit right-justified unsigned format
• Single or continuous conversion (automatic return to idle after single conversion)
• Configurable sample time and conversion speed/power
• Conversion complete flag and interrupt
• Input clock selectable from up to four sources
• Operation in wait or stop3 modes for lower noise operation
• Asynchronous clock source for lower noise operation
• Selectable asynchronous hardware conversion trigger
• Automatic compare with interrupt for less-than, or greater-than or equal-to, programmable value
• Temperature sensor
Compare true
3 ADCSC1 ADCCFG
COCO
AIEN
ADLSMP
complete
ADICLK
ADTRG
ADLPC
MODE
ADCO
ADCH
ADIV
Async
1 2 Clock Gen
ADACK
initialize
transfer
sample
convert
abort
AD0
AIEN 1
•••
Interrupt
ADVIN COCO 2
SAR Converter
AD27
Compare true
3
Compare
Logic
Value
ACFGT
Name Function
7 6 5 4 3 2 1 0
R COCO
AIEN ADCO ADCH
W
Reset: 0 0 0 1 1 1 1 1
Field Description
7 Conversion Complete Flag. The COCO flag is a read-only bit set each time a conversion is completed when the
COCO compare function is disabled (ACFE = 0). When the compare function is enabled (ACFE = 1), the COCO flag is
set upon completion of a conversion only if the compare result is true. This bit is cleared when ADCSC1 is written
or when ADCRL is read.
0 Conversion not completed
1 Conversion completed
6 Interrupt Enable AIEN enables conversion complete interrupts. When COCO becomes set while AIEN is high,
AIEN an interrupt is asserted.
0 Conversion complete interrupt disabled
1 Conversion complete interrupt enabled
4:0 Input Channel Select. The ADCH bits form a 5-bit field that selects one of the input channels. The input channels
ADCH are detailed in Table 10-4.
The successive approximation converter subsystem is turned off when the channel select bits are all set. This
feature allows for explicit disabling of the ADC and isolation of the input channel from all sources. Terminating
continuous conversions this way prevents an additional, single conversion from being performed. It is not
necessary to set the channel select bits to all ones to place the ADC in a low-power state when continuous
conversions are not enabled because the module automatically enters a low-power state when a conversion
completes.
00000–01111 AD0–15
10000–11011 AD16–27
11100 Reserved
11101 VREFH
11110 VREFL
11111 Module disabled
7 6 5 4 3 2 1 0
R ADACT 0 0
ADTRG ACFE ACFGT R1 R1
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7 Conversion Active. Indicates that a conversion is in progress. ADACT is set when a conversion is initiated and
ADACT cleared when a conversion is completed or aborted.
0 Conversion not in progress
1 Conversion in progress
6 Conversion Trigger Select. Selects the type of trigger used for initiating a conversion. Two types of triggers are
ADTRG selectable: software trigger and hardware trigger. When software trigger is selected, a conversion is initiated
following a write to ADCSC1. When hardware trigger is selected, a conversion is initiated following the assertion
of the ADHWT input.
0 Software trigger selected
1 Hardware trigger selected
4 Compare Function Greater Than Enable. Configures the compare function to trigger when the result of the
ACFGT conversion of the input being monitored is greater than or equal to the compare value. The compare function
defaults to triggering when the result of the compare of the input being monitored is less than the compare value.
0 Compare triggers when input is less than compare value
1 Compare triggers when input is greater than or equal to compare value
If the MODE bits are changed, any data in ADCRH becomes invalid.
7 6 5 4 3 2 1 0
Reset: 0 0 0 0 0 0 0 0
7 6 5 4 3 2 1 0
Reset: 0 0 0 0 0 0 0 0
7 6 5 4 3 2 1 0
R 0 0 0 0
ADCV11 ADCV10 ADCV9 ADCV8
W
Reset: 0 0 0 0 0 0 0 0
In 10-bit mode, the ADCCVH register holds the upper two bits of the 10-bit compare value (ADCV[9:8]).
These bits are compared to the upper two bits of the result following a conversion in 10-bit mode when the
compare function is enabled.
In 8-bit mode, ADCCVH is not used during compare.
7 6 5 4 3 2 1 0
R
ADCV7 ADCV6 ADCV5 ADCV4 ADCV3 ADCV2 ADCV1 ADCV0
W
Reset: 0 0 0 0 0 0 0 0
7 6 5 4 3 2 1 0
R
ADLPC ADIV ADLSMP MODE ADICLK
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7 Low-Power Configuration. ADLPC controls the speed and power configuration of the successive approximation
ADLPC converter. This optimizes power consumption when higher sample rates are not required.
0 High speed configuration
1 Low-power configuration:The power is reduced at the expense of maximum clock speed.
6:5 Clock Divide Select. ADIV selects the divide ratio used by the ADC to generate the internal clock ADCK.
ADIV Table 10-7 shows the available clock configurations.
4 Long Sample Time Configuration. ADLSMP selects between long and short sample time. This adjusts the
ADLSMP sample period to allow higher impedance inputs to be accurately sampled or to maximize conversion speed for
lower impedance inputs. Longer sample times can also be used to lower overall power consumption when
continuous conversions are enabled if high conversion rates are not required.
0 Short sample time
1 Long sample time
Field Description
3:2 Conversion Mode Selection. MODE bits are used to select between 12-, 10-, or 8-bit operation. See Table 10-8.
MODE
1:0 Input Clock Select. ADICLK bits select the input clock source to generate the internal clock ADCK. See
ADICLK Table 10-9.
7 6 5 4 3 2 1 0
R
ADPC7 ADPC6 ADPC5 ADPC4 ADPC3 ADPC2 ADPC1 ADPC0
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7 ADC Pin Control 7. ADPC7 controls the pin associated with channel AD7.
ADPC7 0 AD7 pin I/O control enabled
1 AD7 pin I/O control disabled
6 ADC Pin Control 6. ADPC6 controls the pin associated with channel AD6.
ADPC6 0 AD6 pin I/O control enabled
1 AD6 pin I/O control disabled
5 ADC Pin Control 5. ADPC5 controls the pin associated with channel AD5.
ADPC5 0 AD5 pin I/O control enabled
1 AD5 pin I/O control disabled
4 ADC Pin Control 4. ADPC4 controls the pin associated with channel AD4.
ADPC4 0 AD4 pin I/O control enabled
1 AD4 pin I/O control disabled
3 ADC Pin Control 3. ADPC3 controls the pin associated with channel AD3.
ADPC3 0 AD3 pin I/O control enabled
1 AD3 pin I/O control disabled
2 ADC Pin Control 2. ADPC2 controls the pin associated with channel AD2.
ADPC2 0 AD2 pin I/O control enabled
1 AD2 pin I/O control disabled
1 ADC Pin Control 1. ADPC1 controls the pin associated with channel AD1.
ADPC1 0 AD1 pin I/O control enabled
1 AD1 pin I/O control disabled
0 ADC Pin Control 0. ADPC0 controls the pin associated with channel AD0.
ADPC0 0 AD0 pin I/O control enabled
1 AD0 pin I/O control disabled
7 6 5 4 3 2 1 0
R
ADPC15 ADPC14 ADPC13 ADPC12 ADPC11 ADPC10 ADPC9 ADPC8
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7 ADC Pin Control 15. ADPC15 controls the pin associated with channel AD15.
ADPC15 0 AD15 pin I/O control enabled
1 AD15 pin I/O control disabled
6 ADC Pin Control 14. ADPC14 controls the pin associated with channel AD14.
ADPC14 0 AD14 pin I/O control enabled
1 AD14 pin I/O control disabled
5 ADC Pin Control 13. ADPC13 controls the pin associated with channel AD13.
ADPC13 0 AD13 pin I/O control enabled
1 AD13 pin I/O control disabled
4 ADC Pin Control 12. ADPC12 controls the pin associated with channel AD12.
ADPC12 0 AD12 pin I/O control enabled
1 AD12 pin I/O control disabled
3 ADC Pin Control 11. ADPC11 controls the pin associated with channel AD11.
ADPC11 0 AD11 pin I/O control enabled
1 AD11 pin I/O control disabled
2 ADC Pin Control 10. ADPC10 controls the pin associated with channel AD10.
ADPC10 0 AD10 pin I/O control enabled
1 AD10 pin I/O control disabled
1 ADC Pin Control 9. ADPC9 controls the pin associated with channel AD9.
ADPC9 0 AD9 pin I/O control enabled
1 AD9 pin I/O control disabled
0 ADC Pin Control 8. ADPC8 controls the pin associated with channel AD8.
ADPC8 0 AD8 pin I/O control enabled
1 AD8 pin I/O control disabled
7 6 5 4 3 2 1 0
R
ADPC23 ADPC22 ADPC21 ADPC20 ADPC19 ADPC18 ADPC17 ADPC16
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7 ADC Pin Control 23. ADPC23 controls the pin associated with channel AD23.
ADPC23 0 AD23 pin I/O control enabled
1 AD23 pin I/O control disabled
6 ADC Pin Control 22. ADPC22 controls the pin associated with channel AD22.
ADPC22 0 AD22 pin I/O control enabled
1 AD22 pin I/O control disabled
5 ADC Pin Control 21. ADPC21 controls the pin associated with channel AD21.
ADPC21 0 AD21 pin I/O control enabled
1 AD21 pin I/O control disabled
4 ADC Pin Control 20. ADPC20 controls the pin associated with channel AD20.
ADPC20 0 AD20 pin I/O control enabled
1 AD20 pin I/O control disabled
3 ADC Pin Control 19. ADPC19 controls the pin associated with channel AD19.
ADPC19 0 AD19 pin I/O control enabled
1 AD19 pin I/O control disabled
2 ADC Pin Control 18. ADPC18 controls the pin associated with channel AD18.
ADPC18 0 AD18 pin I/O control enabled
1 AD18 pin I/O control disabled
1 ADC Pin Control 17. ADPC17 controls the pin associated with channel AD17.
ADPC17 0 AD17 pin I/O control enabled
1 AD17 pin I/O control disabled
0 ADC Pin Control 16. ADPC16 controls the pin associated with channel AD16.
ADPC16 0 AD16 pin I/O control enabled
1 AD16 pin I/O control disabled
configured for low-power operation, long sample time, continuous conversion, and automatic compare of
the conversion result to a software determined compare value.
When a conversion is aborted, the contents of the data registers, ADCRH and ADCRL, are not altered.
However, they continue to be the values transferred after the completion of the last successful conversion.
If the conversion was aborted by a reset, ADCRH and ADCRL return to their reset states.
The maximum total conversion time is determined by the clock source chosen and the divide ratio selected.
The clock source is selectable by the ADICLK bits, and the divide ratio is specified by the ADIV bits. For
example, in 10-bit mode, with the bus clock selected as the input clock source, the input clock divide-by-1
ratio selected, and a bus frequency of 8 MHz, then the conversion time for a single conversion is:
ALTCLK for this MCU. Consult the module introduction for information on ALTCLK specific to this
MCU.
A conversion complete event sets the COCO and generates an ADC interrupt to wake the MCU from wait
mode if the ADC interrupt is enabled (AIEN = 1).
ADCRH/L = 0xxx
Holds results of conversion. Read high byte (ADCRH) before low byte (ADCRL) so that
conversion data cannot be overwritten with data from the next conversion.
ADCCVH/L = 0xxx
Holds compare value when compare function enabled
APCTL1=0x02
AD1 pin I/O control disabled. All other AD pins remain general purpose I/O pins
APCTL2=0x00
All other AD pins remain general purpose I/O pins
Reset
Initialize ADC
ADCCFG = 0x98
ADCSC2 = 0x00
ADCSC1 = 0x41
Check No
COCO=1?
Yes
Read ADCRH
Then ADCRL To
Clear COCO Bit
Continue
There is an inherent quantization error due to the digitization of the result. For 8-bit or 10-bit conversions
the code transitions when the voltage is at the midpoint between the points where the straight line transfer
function is exactly represented by the actual transfer function. Therefore, the quantization error will be ±
1/2 lsb in 8- or 10-bit mode. As a consequence, however, the code width of the first (0x000) conversion is
only 1/2 lsb and the code width of the last (0xFF or 0x3FF) is 1.5 lsb.
For 12-bit conversions the code transitions only after the full code width is present, so the quantization
error is −1 lsb to 0 lsb and the code width of each step is 1 lsb.
PORT A
LCD25/ADC2/RX2/KBI5/PTA4
LCD24/ADC1/TX2/KBI4/PTA3
BKGD/MS Real Time Counter
BKGD BKP LCD23/ADC0/SDA/PTA2
(RTC) LCD22/SCL/PTA1
LCD21/PTA0
HCS08 SYSTEM CONTROL Modulo Timer TMRCLK
PORT B
(MTIM) LCD[40:37]/PTB[7:4]
RESETS AND INTERRUPTS LCD[32:29]/PTB[3:0]
MODES OF OPERATION KBI[7:0]
8-BIT KEYBOARD
POWER MANAGEMENT
INTERRUPT (KBI)
RESET/PTC6
PORT C
SS BKGD/MS/PTC5
COP RESET SPSCK LCD[20:16]/PTC[4:0]
SERIAL PERIPHERAL MISO
IRQ INTERFACE (SPI)
IRQ LVD MOSI
PORT D
SCL LCD[7:0]/PTD[7:0]
USER FLASH A IIC MODULE (IIC) SDA
(LG32 = 16K BYTES)
PORT E
(LG16 = 2K BYTES) TPM2CH[5:0]
6-CHANNEL TIMER/PWM LCD[15:8]/PTE[7:0]
(TPM2) TPMCLK
USER FLASH B
(LG32 = 16K BYTES) TPM1CH[1:0]
2-CHANNEL TIMER/PWM EXTAL/PTF7
(LG16 = 16K BYTES) XTAL/PTF6
(TPM1) TPMCLK
TPM2CH3/KBI2/MOSI/PTF5
PORT F
TxD1 TPM2CH4/KBI1/MISO/PTF4
SERIAL COMMUNICATIONS
RxD1 TPM2CH5/KBI0/SS/PTF3
USER RAM INTERFACE (SCI1) ADC14/IRQ/TPM1CH1/SPSCK/PTF2
1984 BYTES ADC13/TPM1CH0/RX1/PTF1
TxD2 ADC12/TPM2CH2/KBI3/TX1/PTF0
SERIAL COMMUNICATIONS
RxD2
INTERFACE (SCI2)
PORT G
INTERNAL CLOCK LCD[44:41]/PTG[7:4]
Source (ICS) LCD[36:33]/PTG[3:0]
XTAL
LOW-POWER OSCILLATOR EXTAL
TPM2CH4/KBI1/PTH7
ADC15/KBI0/TPM2CH5/PTH6
PORT H
VLL3_2 12-BIT
ANALOG-TO-DIGITAL AD[15:0] ADC11/TPM1CH0/KBI3/TX1/PTH5
VLL3
CONVERTER (ADC) ADC10/TPM1CH1/KBI2/RX1/PTH4
VLL1 LIQUID CRYSTAL ADC[9:6]/KBI[7:4]/PTH[3:0]
VLL2 DISPLAY DRIVER
(LCD) SS/SCL/TPM2CH0/PTI5
VCAP1
SPSCK/SDA/TPM2CH1/PTI4
PORT I
VCAP2 MOSI/TPM2CH2/PTI3
LCD[44:0] MISO/TPM2CH3/PTI2
TX2/TMRCLK/PTI1
RX2/PTI0
VDD
VSS
VOLTAGE
REGULATOR
VSS2 Available only on 80-pin package
Available only on 64-pin and 80-pin package
VDDA/VREFH */Default function out of reset/*
VSSA/VREFL
Figure 11-1. MC9S08LG32 Series Block Diagram Highlighting ICS Block and Pins
11.1.1 Features
Key features of the ICS module are:
• Frequency-locked loop (FLL) is trimmable for accuracy
• Internal or external reference clocks can be used to control the FLL
• Reference divider is provided for external clock
• Internal reference clock has 9 trim bits available
• Internal or external reference clocks can be selected as the clock source for the MCU
• Whichever clock is selected as the source can be divided down
— 2 bit select for clock divider is provided
– Allowable dividers are: 1, 2, 4, 8
• Control signals for a low-power oscillator clock generator (OSCOUT) as the ICS external
reference clock are provided
— HGO, RANGE, EREFS, ERCLKEN, EREFSTEN
• FLL Engaged Internal mode is automatically selected out of reset
• BDC clock is provided as a constant divide by 2 of the low range DCO output
• Three selectable digitally controlled oscillators (DCO) optimized for different frequency ranges.
• Option to maximize output frequency for a 32768 Hz external reference clock source.
OSCOUT
ICSERCLK
ERCLKEN
/ 2n
Internal ICSOUT
Reference DCOOUT n=0-3
Clock LP ICSDCLK
FLL /2 ICSLCLK
DCOL
/ 2n Filter DCOM
n=0-10 DCOH
Name 7 6 5 4 3 2 1 0
R
ICSC1 CLKS RDIV IREFS IRCLKEN IREFSTEN
W
R
ICSC2 BDIV RANGE HGO LP EREFS ERCLKEN EREFSTEN
W
R
ICSTRM TRIM
W
Name 7 6 5 4 3 2 1 0
7 6 5 4 3 2 1 0
R
CLKS RDIV IREFS IRCLKEN IREFSTEN
W
Reset: 0 0 0 0 0 1 0 0
Field Description
7:6 Clock Source Select — Selects the clock source that controls the bus frequency. The actual bus frequency
CLKS depends on the value of the BDIV bits.
00 Output of FLL is selected.
01 Internal reference clock is selected.
10 External reference clock is selected.
11 Reserved, defaults to 00.
5:3 Reference Divider — Selects the amount to divide down the external reference clock. Resulting frequency must
RDIV be in the range 31.25 kHz to 39.0625 kHz. See Table 11-3 for the divide-by factors.
2 Internal Reference Select — The IREFS bit selects the reference clock source for the FLL.
IREFS 1 Internal reference clock selected
0 External reference clock selected
1 Internal Reference Clock Enable — The IRCLKEN bit enables the internal reference clock for use as
IRCLKEN ICSIRCLK.
1 ICSIRCLK active
0 ICSIRCLK inactive
0 Internal Reference Stop Enable — The IREFSTEN bit controls whether or not the internal reference clock
IREFSTEN remains enabled when the ICS enters stop mode.
1 Internal reference clock stays enabled in stop if IRCLKEN is set before entering stop
0 Internal reference clock is disabled in stop
7 6 5 4 3 2 1 0
R
BDIV RANGE HGO LP EREFS ERCLKEN EREFSTEN
W
Reset: 0 1 0 0 0 0 0 0
Field Description
7:6 Bus Frequency Divider — Selects the amount to divide down the clock source selected by the CLKS bits. This
BDIV controls the bus frequency.
00 Encoding 0 — Divides selected clock by 1
01 Encoding 1 — Divides selected clock by 2 (reset default)
10 Encoding 2 — Divides selected clock by 4
11 Encoding 3 — Divides selected clock by 8
5 Frequency Range Select — Selects the frequency range for the external oscillator.
RANGE 1 High frequency range selected for the external oscillator
0 Low frequency range selected for the external oscillator
4 High Gain Oscillator Select — The HGO bit controls the external oscillator mode of operation.
HGO 1 Configure external oscillator for high-gain operation
0 Configure external oscillator for low-power operation
3 Low Power Select — The LP bit controls whether the FLL is disabled in FLL bypassed modes.
LP 1 FLL is disabled in bypass modes unless BDM is active
0 FLL is not disabled in bypass mode
2 External Reference Select — The EREFS bit selects the source for the external reference clock.
EREFS 1 Oscillator requested
0 External Clock Source requested
1 External Reference Enable — The ERCLKEN bit enables the external reference clock for use as ICSERCLK.
ERCLKEN 1 ICSERCLK active
0 ICSERCLK inactive
0 External Reference Stop Enable — The EREFSTEN bit controls whether or not the external reference clock
EREFSTEN source (OSCOUT) remains enabled when the ICS enters stop mode.
1 External reference clock source stays enabled in stop if ERCLKEN is set before entering stop
0 External reference clock source is disabled in stop
7 6 5 4 3 2 1 0
R
TRIM
W
Reset: Note: TRIM is loaded during reset from a factory programmed location when not in BDM mode. If in a BDM
mode, a default value of 0x80 is loaded.
Field Description
7:0 ICS Trim Setting — The TRIM bits control the internal reference clock frequency by controlling the internal
TRIM reference clock period. The bits’ effect are binary weighted (i.e., bit 1 will adjust twice as much as bit 0).
Increasing the binary value in TRIM will increase the period, and decreasing the value will decrease the period.
7 6 5 4 3 2 1 0
Field Description
7-61 DCO Range Status — The DRST read field indicates the current frequency range for the FLL output, DCOOUT.
DRST See Table 11-7. The DRST field does not update immediately after a write to the DRS field due to internal
DRS synchronization between clock domains. Writing the DRS bits to 2’b11 will be ignored and the DRST bits will
remain with the current setting.
DCO Range Select — The DRS field selects the frequency range for the FLL output, DCOOUT. Writes to the
DRS field while the LP bit is set are ignored.
00 Low range.
01 Mid range.
10 High range.
11 Reserved.
5 DCO Maximum frequency with 32.768 kHz reference — The DMX32 bit controls whether or not the DCO
DMX32 frequency range is narrowed to its maximum frequency with a 32.768 kHz reference. See Table 11-7.
0 DCO has default range of 25%.
1 DCO is fined tuned for maximum frequency with 32.768 kHz reference.
4 Internal Reference Status — The IREFST bit indicates the current source for the reference clock. The IREFST
IREFST bit does not update immediately after a write to the IREFS bit due to internal synchronization between clock
domains.
0 Source of reference clock is external clock.
1 Source of reference clock is internal clock.
Table 11-6. ICS Status and Control Register Field Descriptions (continued)
Field Description
3-2 Clock Mode Status — The CLKST bits indicate the current clock mode. The CLKST bits don’t update
CLKST immediately after a write to the CLKS bits due to internal synchronization between clock domains.
00 Output of FLL is selected.
01 FLL Bypassed, Internal reference clock is selected.
10 FLL Bypassed, External reference clock is selected.
11 Reserved.
1 OSC Initialization — If the external reference clock is selected by ERCLKEN or by the ICS being in FEE, FBE,
OSCINIT or FBELP mode, and if EREFS is set, then this bit is set after the initialization cycles of the external oscillator
clock have completed. This bit is only cleared when either ERCLKEN or EREFS are cleared.
0 ICS Fine Trim — The FTRIM bit controls the smallest adjustment of the internal reference clock frequency.
FTRIM Setting FTRIM will increase the period and clearing FTRIM will decrease the period by the smallest amount
possible.
1
Refer to NOTE in Section 11.1, “Introduction.”
FLL Engaged
IREFS=0 Internal (FEI) IREFS=1
CLKS=10 CLKS=01
BDM Enabled BDM Enabled
or LP =0 or LP=0
IREFS=0 IREFS=1
CLKS=10 CLKS=01
BDM Disabled BDM Disabled
and LP=1 FLL Engaged and LP=1
External (FEE)
IREFS=0
CLKS=00
The seven states of the ICS are shown as a state diagram and are described below. The arrows indicate the
allowed movements between the states.
In FLL bypassed external mode, the ICSOUT clock is derived from the external reference clock source.
The FLL clock is controlled by the external reference clock, and the FLL loop will lock the FLL frequency
to the FLL factor times the external reference frequency, as selected by the RDIV bits, so that the
ICSLCLK will be available for BDC communications, and the external reference clock is enabled.
11.4.1.7 Stop
Stop mode is entered whenever the MCU enters a STOP state. In this mode, all ICS clock signals are static
except in the following cases:
ICSIRCLK will be active in stop mode when all the following conditions occur:
• IRCLKEN bit is written to 1
• IREFSTEN bit is written to 1
OSCOUT will be active in stop mode when all the following conditions occur:
• ERCLKEN bit is written to 1
• EREFSTEN bit is written to 1
SDA/SCL in PINPS3 Port Pin for SDA Port Pin for SCL
PORT A
LCD25/ADC2/RX2/KBI5/PTA4
LCD24/ADC1/TX2/KBI4/PTA3
BKGD/MS Real Time Counter
BKGD BKP LCD23/ADC0/SDA/PTA2
(RTC) LCD22/SCL/PTA1
LCD21/PTA0
HCS08 SYSTEM CONTROL Modulo Timer TMRCLK
PORT B
(MTIM) LCD[40:37]/PTB[7:4]
RESETS AND INTERRUPTS LCD[32:29]/PTB[3:0]
MODES OF OPERATION KBI[7:0]
8-BIT KEYBOARD
POWER MANAGEMENT
INTERRUPT (KBI)
RESET/PTC6
PORT C
SS BKGD/MS/PTC5
COP RESET SPSCK LCD[20:16]/PTC[4:0]
SERIAL PERIPHERAL MISO
IRQ INTERFACE (SPI)
IRQ LVD MOSI
PORT D
SCL LCD[7:0]/PTD[7:0]
USER FLASH A IIC MODULE (IIC) SDA
(LG32 = 16K BYTES)
PORT E
(LG16 = 2K BYTES) TPM2CH[5:0]
6-CHANNEL TIMER/PWM LCD[15:8]/PTE[7:0]
(TPM2) TPMCLK
USER FLASH B
(LG32 = 16K BYTES) TPM1CH[1:0]
2-CHANNEL TIMER/PWM EXTAL/PTF7
(LG16 = 16K BYTES) XTAL/PTF6
(TPM1) TPMCLK
TPM2CH3/KBI2/MOSI/PTF5
PORT F
TxD1 TPM2CH4/KBI1/MISO/PTF4
SERIAL COMMUNICATIONS
RxD1 TPM2CH5/KBI0/SS/PTF3
USER RAM INTERFACE (SCI1) ADC14/IRQ/TPM1CH1/SPSCK/PTF2
1984 BYTES ADC13/TPM1CH0/RX1/PTF1
TxD2 ADC12/TPM2CH2/KBI3/TX1/PTF0
SERIAL COMMUNICATIONS
RxD2
INTERFACE (SCI2)
PORT G
INTERNAL CLOCK LCD[44:41]/PTG[7:4]
Source (ICS) LCD[36:33]/PTG[3:0]
XTAL
LOW-POWER OSCILLATOR EXTAL
TPM2CH4/KBI1/PTH7
ADC15/KBI0/TPM2CH5/PTH6
PORT H
VLL3_2 12-BIT
ANALOG-TO-DIGITAL AD[15:0] ADC11/TPM1CH0/KBI3/TX1/PTH5
VLL3
CONVERTER (ADC) ADC10/TPM1CH1/KBI2/RX1/PTH4
VLL1 LIQUID CRYSTAL ADC[9:6]/KBI[7:4]/PTH[3:0]
VLL2 DISPLAY DRIVER
(LCD) SS/SCL/TPM2CH0/PTI5
VCAP1
SPSCK/SDA/TPM2CH1/PTI4
PORT I
VCAP2 MOSI/TPM2CH2/PTI3
LCD[44:0] MISO/TPM2CH3/PTI2
TX2/TMRCLK/PTI1
RX2/PTI0
VDD
VSS
VOLTAGE
REGULATOR
VSS2 Available only on 80-pin package
Available only on 64-pin and 80-pin package
VDDA/VREFH */Default function out of reset/*
VSSA/VREFL
Figure 12-1. MC9S08LG32 Series Block Diagram Highlighting IIC Block and Pins
12.1.3 Features
The IIC includes these distinctive features:
• Compatible with IIC bus standard
• Multi-master operation
• Software programmable for one of 64 different serial clock frequencies
• Software selectable acknowledge bit
• Interrupt driven byte-by-byte data transfer
• Arbitration lost interrupt with automatic mode switching from master to slave
• Calling address identification interrupt
• Start and stop signal generation/detection
• Repeated start signal generation
• Acknowledge bit generation/detection
• Bus busy detection
• General call recognition
• 10-bit address extension
Interrupt
ADDR_DECODE DATA_MUX
Input
Sync
In/Out
Start Data
Stop Shift
Arbitration Register
Control
Clock
Control Address
Compare
SCL SDA
Figure 12-2. IIC Functional Block Diagram
Freescale-provided equate or header file is used to translate these names into the appropriate absolute
addresses.
7 6 5 4 3 2 1 0
R 0
AD7 AD6 AD5 AD4 AD3 AD2 AD1
W
Reset 0 0 0 0 0 0 0 0
= Unimplemented or Reserved
Field Description
7–1 Slave Address. The AD[7:1] field contains the slave address to be used by the IIC module. This field is used on
AD[7:1] the 7-bit address scheme and the lower seven bits of the 10-bit address scheme.
7 6 5 4 3 2 1 0
R
MULT ICR
W
Reset 0 0 0 0 0 0 0 0
Field Description
7–6 IIC Multiplier Factor. The MULT bits define the multiplier factor, mul. This factor, along with the SCL divider,
MULT generates the IIC baud rate. The multiplier factor mul as defined by the MULT bits is provided below.
00 mul = 01
01 mul = 02
10 mul = 04
11 Reserved
5–0 IIC Clock Rate. The ICR bits are used to prescale the bus clock for bit rate selection. These bits and the MULT
ICR bits determine the IIC baud rate, the SDA hold time, the SCL Start hold time, and the SCL Stop hold time.
Table 12-5 provides the SCL divider and hold values for corresponding values of the ICR.
The SCL divider multiplied by multiplier factor mul generates IIC baud rate.
SDA hold time = bus period (s) × mul × SDA hold value Eqn. 12-2
SCL start hold time is the delay from the falling edge of SDA (IIC data) while SCL is high (Start condition) to the
falling edge of SCL (IIC clock).
SCL Start hold time = bus period (s) × mul × SCL Start hold value Eqn. 12-3
SCL stop hold time is the delay from the rising edge of SCL (IIC clock) to the rising edge of SDA
SDA (IIC data) while SCL is high (Stop condition).
SCL Stop hold time = bus period (s) × mul × SCL Stop hold value Eqn. 12-4
For example, if the bus speed is 8 MHz, the table below shows the possible hold time values with different
ICR and MULT selections to achieve an IIC baud rate of 100kbps.
Table 12-4. Hold Time Values for 8 MHz Bus Speed
7 6 5 4 3 2 1 0
R 0 0 0
IICEN IICIE MST TX TXAK
W RSTA
Reset 0 0 0 0 0 0 0 0
= Unimplemented or Reserved
Field Description
7 IIC Enable. The IICEN bit determines whether the IIC module is enabled.
IICEN 0 IIC is not enabled
1 IIC is enabled
6 IIC Interrupt Enable. The IICIE bit determines whether an IIC interrupt is requested.
IICIE 0 IIC interrupt request not enabled
1 IIC interrupt request enabled
5 Master Mode Select. The MST bit changes from a 0 to a 1 when a start signal is generated on the bus and
MST master mode is selected. When this bit changes from a 1 to a 0 a stop signal is generated and the mode of
operation changes from master to slave.
0 Slave mode
1 Master mode
4 Transmit Mode Select. The TX bit selects the direction of master and slave transfers. In master mode, this bit
TX should be set according to the type of transfer required. Therefore, for address cycles, this bit is always high.
When addressed as a slave, this bit should be set by software according to the SRW bit in the status register.
0 Receive
1 Transmit
3 Transmit Acknowledge Enable. This bit specifies the value driven onto the SDA during data acknowledge
TXAK cycles for master and slave receivers.
0 An acknowledge signal is sent out to the bus after receiving one data byte
1 No acknowledge signal response is sent
2 Repeat start. Writing a 1 to this bit generates a repeated start condition provided it is the current master. This
RSTA bit is always read as cleared. Attempting a repeat at the wrong time results in loss of arbitration.
7 6 5 4 3 2 1 0
Reset 1 0 0 0 0 0 0 0
= Unimplemented or Reserved
Field Description
7 Transfer Complete Flag. This bit is set on the completion of a byte transfer and should be ignored when address
TCF phase of IIC is going on. This bit is only valid during or immediately following a transfer to the IIC module or from
the IIC module.The TCF bit is cleared by reading the IICxD register in receive mode or writing to the IICxD in
transmit mode.
0 Transfer in progress
1 Transfer complete
6 Addressed as a Slave. The IAAS bit is set when the calling address matches the programmed slave address or
IAAS when the GCAEN bit is set and a general call is received. Writing the IICxC register clears this bit.
0 Not addressed
1 Addressed as a slave
5 Bus Busy. The BUSY bit indicates the status of the bus regardless of slave or master mode. The BUSY bit is set
BUSY when a start signal is detected and cleared when a stop signal is detected.
0 Bus is idle
1 Bus is busy
4 Arbitration Lost. This bit is set by hardware when the arbitration procedure is lost. The ARBL bit must be cleared
ARBL by software by writing a 1 to it.
0 Standard bus operation
1 Loss of arbitration
2 Slave Read/Write. When addressed as a slave, the SRW bit indicates the value of the R/W command bit of the
SRW calling address sent to the master.
0 Slave receive, master writing to slave
1 Slave transmit, master reading from slave
1 IIC Interrupt Flag. The IICIF bit is set when an interrupt is pending. This bit must be cleared by software, by
IICIF writing a 1 to it in the interrupt routine. One of the following events can set the IICIF bit:
• One byte transfer completes
• Match of slave address to calling address
• Arbitration lost
0 No interrupt pending
1 Interrupt pending
0 Receive Acknowledge. When the RXAK bit is low, it indicates an acknowledge signal has been received after
RXAK the completion of one byte of data transmission on the bus. If the RXAK bit is high it means that no acknowledge
signal is detected.
0 Acknowledge received
1 No acknowledge received
7 6 5 4 3 2 1 0
R
DATA
W
Reset 0 0 0 0 0 0 0 0
Field Description
7–0 Data — In master transmit mode, when data is written to the IICxD, a data transfer is initiated. The most
DATA significant bit is sent first. In master receive mode, reading this register initiates receiving of the next byte of data.
NOTE
When transitioning out of master receive mode, the IIC mode should be
switched before reading the IICxD register to prevent an inadvertent
initiation of a master receive data transfer.
In slave mode, the same functions are available after an address match has occurred.
The TX bit in IICxC must correctly reflect the desired direction of transfer in master and slave modes for
the transmission to begin. For instance, if the IIC is configured for master transmit but a master receive is
desired, reading the IICxD does not initiate the receive.
Reading the IICxD returns the last byte received while the IIC is configured in master receive or slave
receive modes. The IICxD does not reflect every byte transmitted on the IIC bus, nor can software verify
that a byte has been written to the IICxD correctly by reading it back.
In master transmit mode, the first byte of data written to IICxD following assertion of MST is used for the
address transfer and should comprise of the calling address (in bit 7 to bit 1) concatenated with the required
R/W bit (in position bit 0).
7 6 5 4 3 2 1 0
R 0 0 0
GCAEN ADEXT AD10 AD9 AD8
W
Reset 0 0 0 0 0 0 0 0
= Unimplemented or Reserved
Figure 12-8. IIC Control Register (IICxC2)
Field Description
7 General Call Address Enable. The GCAEN bit enables or disables general call address.
GCAEN 0 General call address is disabled
1 General call address is enabled
6 Address Extension. The ADEXT bit controls the number of bits used for the slave address.
ADEXT 0 7-bit address scheme
1 10-bit address scheme
2–0 Slave Address. The AD[10:8] field contains the upper three bits of the slave address in the 10-bit address
AD[10:8] scheme. This field is only valid when the ADEXT bit is set.
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
SDA AD7 AD6 AD5 AD4 AD3 AD2 AD1 R/W XXX D7 D6 D5 D4 D3 D2 D1 D0
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
SDA AD7 AD6 AD5 AD4 AD3 AD2 AD1 R/W XX AD7 AD6 AD5 AD4 AD3 AD2 AD1 R/W
Start Calling Address Read/ Ack Repeated New Calling Address Read/ No Stop
Signal Write Bit Start Write Ack Signal
Signal Bit
SCL1
SCL2
SCL
12.4.1.8 Handshaking
The clock synchronization mechanism can be used as a handshake in data transfer. Slave devices may hold
the SCL low after completion of one byte transfer (9 bits). In such a case, it halts the bus clock and forces
the master clock into wait states until the slave releases the SCL line.
After the master-transmitter has sent the first byte of the 10-bit address, the slave-receiver sees an IIC
interrupt. Software must ensure the contents of IICD are ignored and not treated as valid data for this
interrupt.
After a repeated start condition (Sr), all other slave devices also compare the first seven bits of the first
byte of the slave address with their own addresses and test the eighth (R/W) bit. However, none of them
are addressed because R/W = 1 (for 10-bit devices) or the 11110XX slave address (for 7-bit devices) does
not match.
Slave Address Slave Address Slave Address
R/W R/W
S 1st 7 bits A1 2nd byte A2 Sr 1st 7 bits A3 Data A ... Data A P
11110 + AD10 + AD9 0 AD[8:1] 11110 + AD10 + AD9 1
After the master-receiver has sent the first byte of the 10-bit address, the slave-transmitter sees an IIC
interrupt. Software must ensure the contents of IICD are ignored and not treated as valid data for this
interrupt.
12.5 Resets
The IIC is disabled after reset. The IIC cannot cause an MCU reset.
12.6 Interrupts
The IIC generates a single interrupt.
An interrupt from the IIC is generated when any of the events in Table 12-12 occur, provided the IICIE bit
is set. The interrupt is driven by bit IICIF (of the IIC status register) and masked with bit IICIE (of the IIC
control register). The IICIF bit must be cleared by software by writing a 1 to it in the interrupt routine. You
can determine the interrupt type by reading the status register.
Table 12-12. Interrupt Summary
Register Model
IICA AD[7:1] 0
When addressed as a slave (in slave mode), the module responds to this address
IICF MULT ICR
Baud rate = BUSCLK / (2 x MULT x (SCL DIVIDER))
Clear
IICIF
Y Master N
Mode
?
TX Tx/Rx RX Y Arbitration
? Lost
?
N
Last Byte
Transmitted Y Clear ARBL
?
N
Last N Y
RXAK=0 Byte to Be Read IAAS=1 IAAS=1
N Y
? ? ? ?
Y N Y N
Address Transfer Data Transfer
See Note 1 See Note 2
End of Y
Y Y 2nd Last (Read)
Addr Cycle Byte to Be Read SRW=1 TX/RX RX
(Master Rx) ?
? ?
?
N N N (Write) TX
RTI
NOTES:
1. If general call is enabled, a check must be done to determine whether the received address was a general call address (0x00). If the received address was a
general call address, then the general call must be handled by user software.
2. When 10-bit addressing is used to address a slave, the slave sees an interrupt following the first byte of the extended address. User software must ensure that for
this interrupt, the contents of IICD are ignored and not treated as a valid data transfer
TX1/RX1/TX2/RX2 Port Pin for TX1 Port Pin for RX1 Port Pin for TX2 Port Pin for RX2
PORT A
LCD25/ADC2/RX2/KBI5/PTA4
LCD24/ADC1/TX2/KBI4/PTA3
BKGD/MS Real Time Counter
BKGD BKP LCD23/ADC0/SDA/PTA2
(RTC) LCD22/SCL/PTA1
LCD21/PTA0
HCS08 SYSTEM CONTROL Modulo Timer TMRCLK
PORT B
(MTIM) LCD[40:37]/PTB[7:4]
RESETS AND INTERRUPTS LCD[32:29]/PTB[3:0]
MODES OF OPERATION KBI[7:0]
8-BIT KEYBOARD
POWER MANAGEMENT
INTERRUPT (KBI)
RESET/PTC6
PORT C
SS BKGD/MS/PTC5
COP RESET SPSCK LCD[20:16]/PTC[4:0]
SERIAL PERIPHERAL MISO
IRQ INTERFACE (SPI)
IRQ LVD MOSI
PORT D
SCL LCD[7:0]/PTD[7:0]
USER FLASH A IIC MODULE (IIC) SDA
(LG32 = 16K BYTES)
PORT E
(LG16 = 2K BYTES) TPM2CH[5:0]
6-CHANNEL TIMER/PWM LCD[15:8]/PTE[7:0]
(TPM2) TPMCLK
USER FLASH B
(LG32 = 16K BYTES) TPM1CH[1:0]
2-CHANNEL TIMER/PWM EXTAL/PTF7
(LG16 = 16K BYTES) XTAL/PTF6
(TPM1) TPMCLK
TPM2CH3/KBI2/MOSI/PTF5
PORT F
TxD1 TPM2CH4/KBI1/MISO/PTF4
SERIAL COMMUNICATIONS
RxD1 TPM2CH5/KBI0/SS/PTF3
USER RAM INTERFACE (SCI1) ADC14/IRQ/TPM1CH1/SPSCK/PTF2
1984 BYTES ADC13/TPM1CH0/RX1/PTF1
TxD2 ADC12/TPM2CH2/KBI3/TX1/PTF0
SERIAL COMMUNICATIONS
RxD2
INTERFACE (SCI2)
PORT G
INTERNAL CLOCK LCD[44:41]/PTG[7:4]
Source (ICS) LCD[36:33]/PTG[3:0]
XTAL
LOW-POWER OSCILLATOR EXTAL
TPM2CH4/KBI1/PTH7
ADC15/KBI0/TPM2CH5/PTH6
PORT H
VLL3_2 12-BIT
ANALOG-TO-DIGITAL AD[15:0] ADC11/TPM1CH0/KBI3/TX1/PTH5
VLL3
CONVERTER (ADC) ADC10/TPM1CH1/KBI2/RX1/PTH4
VLL1 LIQUID CRYSTAL ADC[9:6]/KBI[7:4]/PTH[3:0]
VLL2 DISPLAY DRIVER
(LCD) SS/SCL/TPM2CH0/PTI5
VCAP1
SPSCK/SDA/TPM2CH1/PTI4
PORT I
VCAP2 MOSI/TPM2CH2/PTI3
LCD[44:0] MISO/TPM2CH3/PTI2
TX2/TMRCLK/PTI1
RX2/PTI0
VDD
VSS
VOLTAGE
REGULATOR
VSS2 Available only on 80-pin package
Available only on 64-pin and 80-pin package
VDDA/VREFH */Default function out of reset/*
VSSA/VREFL
Figure 13-1. MC9S08LG32 Series Block Diagram Highlighting SCI Block and Pins
13.1.4 Features
Features of SCI module include:
• Full-duplex, standard non-return-to-zero (NRZ) format
• Double-buffered transmitter and receiver with separate enables
• Programmable baud rates (13-bit modulo divider)
• Interrupt-driven or polled operation:
— Transmit data register empty and transmission complete
— Receive data register full
— Receive overrun, parity error, framing error, and noise error
— Idle receiver detect
— Active edge on receive pin
— Break detect supporting LIN
• Hardware parity generation and checking
• Programmable 8-bit or 9-bit character length
• Receiver wakeup by idle-line or address-mark
• Optional 13-bit break character generation / 11-bit break character detection
• Selectable transmitter output polarity
(Write-Only)
LOOPS
SCID – Tx Buffer RSRC
Loop
To Receive
11-bit Transmit Shift Register Control
M Data In
Start
Stop
To TxD Pin
1 ¥ Baud H 8 7 6 5 4 3 2 1 0 L
Rate Clock
lsb
Shift Direction
TXINV
T8
PE Parity
Generation
PT
TDRE
TIE
Tx Interrupt
TC
Request
TCIE
(Read-Only)
16 ¥ Baud Divide
Rate Clock SCID – Rx Buffer
By 16
From
Transmitter
11-Bit Receive Shift Register
LOOPS
Start
Stop
Single-Wire M
lsb
Loop Control
RSRC
LBKDE H 8 7 6 5 4 3 2 1 0 L
From RxD Pin
All 1s
msb
RXINV Data Recovery Shift Direction
WAKE Wakeup
RWU RWUID
Logic
ILT
Active Edge
Detect
RDRF
RIE
IDLE
ILIE
Rx Interrupt
Request
LBKDIF
LBKDIE
RXEDGIF
RXEDGIE
OR
ORIE
FE
FEIE
Error Interrupt
Request
NF
NEIE
PE PARITY
PF
CHECKING
PT
PEIE
7 6 5 4 3 2 1 0
R 0
LBKDIE RXEDGIE SBR[12:8]
W
Reset 0 0 0 0 0 0 0 0
= Unimplemented or Reserved
Field Description
4:0 Baud Rate Modulo Divisor — The 13 bits in SBR[12:0] are referred to collectively as BR, and they set the
SBR[12:8] modulo divide rate for the SCI baud rate generator. When BR is cleared, the SCI baud rate generator is disabled
to reduce supply current. When BR is 1 – 8191, the SCI baud rate equals BUSCLK/(16×BR). See also BR bits
in Table 13-3.
7 6 5 4 3 2 1 0
R
SBR[7:0]
W
Reset 0 0 0 0 0 1 0 0
Field Description
7:0 Baud Rate Modulo Divisor — These 13 bits in SBR[12:0] are referred to collectively as BR, and they set the
SBR[7:0] modulo divide rate for the SCI baud rate generator. When BR is cleared, the SCI baud rate generator is disabled
to reduce supply current. When BR is 1 – 8191, the SCI baud rate equals BUSCLK/(16×BR). See also BR bits
in Table 13-2.
7 6 5 4 3 2 1 0
R
LOOPS SCISWAI RSRC M WAKE ILT PE PT
W
Reset 0 0 0 0 0 0 0 0
Field Description
7 Loop Mode Select — Selects between loop back modes and normal 2-pin full-duplex modes. When LOOPS is
LOOPS set, the transmitter output is internally connected to the receiver input.
0 Normal operation — RxD and TxD use separate pins.
1 Loop mode or single-wire mode where transmitter outputs are internally connected to receiver input. (See
RSRC bit.) RxD pin is not used by SCI.
6 SCI Stops in Wait Mode
SCISWAI 0 SCI clocks continue to run in wait mode so the SCI can be the source of an interrupt that wakes up the CPU.
1 SCI clocks freeze while CPU is in wait mode.
5 Receiver Source Select — This bit has no meaning or effect unless the LOOPS bit is set to 1. When LOOPS is
RSRC set, the receiver input is internally connected to the TxD pin and RSRC determines whether this connection is
also connected to the transmitter output.
0 Provided LOOPS is set, RSRC is cleared, selects internal loop back mode and the SCI does not use the RxD
pins.
1 Single-wire SCI mode where the TxD pin is connected to the transmitter output and receiver input.
4 9-Bit or 8-Bit Mode Select
M 0 Normal — start + 8 data bits (lsb first) + stop.
1 Receiver and transmitter use 9-bit data characters
start + 8 data bits (lsb first) + 9th data bit + stop.
Field Description
3 Receiver Wakeup Method Select — Refer to Section 13.3.3.2, “Receiver Wakeup Operation,” for more
WAKE information.
0 Idle-line wakeup.
1 Address-mark wakeup.
2 Idle Line Type Select — Setting this bit to 1 ensures that the stop bit and logic 1 bits at the end of a character
ILT do not count toward the 10 or 11 bit times of logic high level needed by the idle line detection logic. Refer to
Section 13.3.3.2.1, “Idle-Line Wakeup,” for more information.
0 Idle character bit count starts after start bit.
1 Idle character bit count starts after stop bit.
1 Parity Enable — Enables hardware parity generation and checking. When parity is enabled, the most significant
PE bit (msb) of the data character (eighth or ninth data bit) is treated as the parity bit.
0 No hardware parity generation or checking.
1 Parity enabled.
0 Parity Type — Provided parity is enabled (PE = 1), this bit selects even or odd parity. Odd parity means the total
PT number of 1s in the data character, including the parity bit, is odd. Even parity means the total number of 1s in
the data character, including the parity bit, is even.
0 Even parity.
1 Odd parity.
7 6 5 4 3 2 1 0
R
TIE TCIE RIE ILIE TE RE RWU SBK
W
Reset 0 0 0 0 0 0 0 0
Field Description
Field Description
3 Transmitter Enable
TE 0 Transmitter off.
1 Transmitter on.
TE must be 1 in order to use the SCI transmitter. When TE is set, the SCI forces the TxD pin to act as an output
for the SCI system.
When the SCI is configured for single-wire operation (LOOPS = RSRC = 1), TXDIR controls the direction of
traffic on the single SCI communication line (TxD pin).
TE can also queue an idle character by clearing TE then setting TE while a transmission is in progress. Refer to
Section 13.3.2.1, “Send Break and Queued Idle,” for more details.
When TE is written to 0, the transmitter keeps control of the port TxD pin until any data, queued idle, or queued
break character finishes transmitting before allowing the pin to revert to a general-purpose I/O pin.
2 Receiver Enable — When the SCI receiver is off, the RxD pin reverts to being a general-purpose port I/O pin. If
RE LOOPS is set, the RxD pin reverts to being a general-purpose I/O pin even if RE is set.
0 Receiver off.
1 Receiver on.
1 Receiver Wakeup Control — This bit can be written to 1 to place the SCI receiver in a standby state where it
RWU waits for automatic hardware detection of a selected wakeup condition. The wakeup condition is an idle line
between messages (WAKE = 0, idle-line wakeup), or a logic 1 in the most significant data bit in a character
(WAKE = 1, address-mark wakeup). Application software sets RWU and (normally) a selected hardware
condition automatically clears RWU. Refer to Section 13.3.3.2, “Receiver Wakeup Operation,” for more details.
0 Normal SCI receiver operation.
1 SCI receiver in standby waiting for wakeup condition.
0 Send Break — Writing a 1 and then a 0 to SBK queues a break character in the transmit data stream. Additional
SBK break characters of 10 or 11 (13 or 14 if BRK13 = 1) bit times of logic 0 are queued as long as SBK is set.
Depending on the timing of the set and clear of SBK relative to the information currently being transmitted, a
second break character may be queued before software clears SBK. Refer to Section 13.3.2.1, “Send Break and
Queued Idle,” for more details.
0 Normal transmitter operation.
1 Queue break character(s) to be sent.
7 6 5 4 3 2 1 0
Reset 1 1 0 0 0 0 0 0
= Unimplemented or Reserved
Field Description
7 Transmit Data Register Empty Flag — TDRE is set out of reset and when a transmit data value transfers from
TDRE the transmit data buffer to the transmit shifter, leaving room for a new character in the buffer. To clear TDRE, read
SCIxS1 with TDRE set and then write to the SCI data register (SCIxD).
0 Transmit data register (buffer) full.
1 Transmit data register (buffer) empty.
6 Transmission Complete Flag — TC is set out of reset and when TDRE is set and no data, preamble, or break
TC character is being transmitted.
0 Transmitter active (sending data, a preamble, or a break).
1 Transmitter idle (transmission activity complete).
TC is cleared automatically by reading SCIxS1 with TC set and then doing one of the following:
• Write to the SCI data register (SCIxD) to transmit new data
• Queue a preamble by changing TE from 0 to 1
• Queue a break character by writing 1 to SBK in SCIxC2
5 Receive Data Register Full Flag — RDRF becomes set when a character transfers from the receive shifter into
RDRF the receive data register (SCIxD). To clear RDRF, read SCIxS1 with RDRF set and then read the SCI data
register (SCIxD).
0 Receive data register empty.
1 Receive data register full.
4 Idle Line Flag — IDLE is set when the SCI receive line becomes idle for a full character time after a period of
IDLE activity. When ILT is cleared, the receiver starts counting idle bit times after the start bit. So if the receive character
is all 1s, these bit times and the stop bit time count toward the full character time of logic high (10 or 11 bit times
depending on the M control bit) needed for the receiver to detect an idle line. When ILT is set, the receiver doesn’t
start counting idle bit times until after the stop bit. The stop bit and any logic high bit times at the end of the
previous character do not count toward the full character time of logic high needed for the receiver to detect an
idle line.
To clear IDLE, read SCIxS1 with IDLE set and then read the SCI data register (SCIxD). After IDLE has been
cleared, it cannot become set again until after a new character has been received and RDRF has been set. IDLE
is set only once even if the receive line remains idle for an extended period.
0 No idle line detected.
1 Idle line was detected.
3 Receiver Overrun Flag — OR is set when a new serial character is ready to be transferred to the receive data
OR register (buffer), but the previously received character has not been read from SCIxD yet. In this case, the new
character (and all associated error information) is lost because there is no room to move it into SCIxD. To clear
OR, read SCIxS1 with OR set and then read the SCI data register (SCIxD).
0 No overrun.
1 Receive overrun (new SCI data lost).
2 Noise Flag — The advanced sampling technique used in the receiver takes seven samples during the start bit
NF and three samples in each data bit and the stop bit. If any of these samples disagrees with the rest of the samples
within any bit time in the frame, the flag NF is set at the same time as RDRF is set for the character. To clear NF,
read SCIxS1 and then read the SCI data register (SCIxD).
0 No noise detected.
1 Noise detected in the received character in SCIxD.
Field Description
1 Framing Error Flag — FE is set at the same time as RDRF when the receiver detects a logic 0 where the stop
FE bit was expected. This suggests the receiver was not properly aligned to a character frame. To clear FE, read
SCIxS1 with FE set and then read the SCI data register (SCIxD).
0 No framing error detected. This does not guarantee the framing is correct.
1 Framing error.
0 Parity Error Flag — PF is set at the same time as RDRF when parity is enabled (PE = 1) and the parity bit in
PF the received character does not agree with the expected parity value. To clear PF, read SCIxS1 and then read
the SCI data register (SCIxD).
0 No parity error.
1 Parity error.
7 6 5 4 3 2 1 0
R 0 RAF
LBKDIF RXEDGIF RXINV RWUID BRK13 LBKDE
W
Reset 0 0 0 0 0 0 0 0
= Unimplemented or Reserved
Field Description
7 LIN Break Detect Interrupt Flag — LBKDIF is set when the LIN break detect circuitry is enabled and a LIN break
LBKDIF character is detected. LBKDIF is cleared by writing a 1 to it.
0 No LIN break character has been detected.
1 LIN break character has been detected.
6 RxD Pin Active Edge Interrupt Flag — RXEDGIF is set when an active edge (falling if RXINV = 0, rising if
RXEDGIF RXINV=1) on the RxD pin occurs. RXEDGIF is cleared by writing a 1 to it.
0 No active edge on the receive pin has occurred.
1 An active edge on the receive pin has occurred.
4 Receive Data Inversion — Setting this bit reverses the polarity of the received data input.
RXINV1 0 Receive data not inverted
1 Receive data inverted
3 Receive Wake Up Idle Detect— RWUID controls whether the idle character that wakes up the receiver sets the
RWUID IDLE bit.
0 During receive standby state (RWU = 1), the IDLE bit does not get set upon detection of an idle character.
1 During receive standby state (RWU = 1), the IDLE bit gets set upon detection of an idle character.
2 Break Character Generation Length — BRK13 is used to select a longer transmitted break character length.
BRK13 Detection of a framing error is not affected by the state of this bit.
0 Break character is transmitted with length of 10 bit times (11 if M = 1)
1 Break character is transmitted with length of 13 bit times (14 if M = 1)
Field Description
1 LIN Break Detection Enable— LBKDE selects a longer break character detection length. While LBKDE is set,
LBKDE framing error (FE) and receive data register full (RDRF) flags are prevented from setting.
0 Break character is detected at length of 10 bit times (11 if M = 1).
1 Break character is detected at length of 11 bit times (12 if M = 1).
0 Receiver Active Flag — RAF is set when the SCI receiver detects the beginning of a valid start bit, and RAF is
RAF cleared automatically when the receiver detects an idle line. This status flag can be used to check whether an
SCI character is being received before instructing the MCU to go to stop mode.
0 SCI receiver idle waiting for a start bit.
1 SCI receiver active (RxD input not idle).
1
Setting RXINV inverts the RxD input for all cases: data bits, start and stop bits, break, and idle.
When using an internal oscillator in a LIN system, it is necessary to raise the break detection threshold one
bit time. Under the worst case timing conditions allowed in LIN, it is possible that a 0x00 data character
can appear to be 10.26 bit times long at a slave running 14% faster than the master. This would trigger
normal break detection circuitry designed to detect a 10-bit break symbol. When the LBKDE bit is set,
framing errors are inhibited and the break detection threshold changes from 10 bits to 11 bits, preventing
false detection of a 0x00 data character as a LIN break symbol.
7 6 5 4 3 2 1 0
R R8
T8 TXDIR TXINV ORIE NEIE FEIE PEIE
W
Reset 0 0 0 0 0 0 0 0
= Unimplemented or Reserved
Field Description
7 Ninth Data Bit for Receiver — When the SCI is configured for 9-bit data (M = 1), R8 can be thought of as a ninth
R8 receive data bit to the left of the msb of the buffered data in the SCIxD register. When reading 9-bit data, read
R8 before reading SCIxD because reading SCIxD completes automatic flag clearing sequences that could allow
R8 and SCIxD to be overwritten with new data.
6 Ninth Data Bit for Transmitter — When the SCI is configured for 9-bit data (M = 1), T8 may be thought of as a
T8 ninth transmit data bit to the left of the msb of the data in the SCIxD register. When writing 9-bit data, the entire
9-bit value is transferred to the SCI shift register after SCIxD is written so T8 should be written (if it needs to
change from its previous value) before SCIxD is written. If T8 does not need to change in the new value (such
as when it is used to generate mark or space parity), it need not be written each time SCIxD is written.
5 TxD Pin Direction in Single-Wire Mode — When the SCI is configured for single-wire half-duplex operation
TXDIR (LOOPS = RSRC = 1), this bit determines the direction of data at the TxD pin.
0 TxD pin is an input in single-wire mode.
1 TxD pin is an output in single-wire mode.
Field Description
4 Transmit Data Inversion — Setting this bit reverses the polarity of the transmitted data output.
TXINV1 0 Transmit data not inverted
1 Transmit data inverted
3 Overrun Interrupt Enable — This bit enables the overrun flag (OR) to generate hardware interrupt requests.
ORIE 0 OR interrupts disabled (use polling).
1 Hardware interrupt requested when OR is set.
2 Noise Error Interrupt Enable — This bit enables the noise flag (NF) to generate hardware interrupt requests.
NEIE 0 NF interrupts disabled (use polling).
1 Hardware interrupt requested when NF is set.
1 Framing Error Interrupt Enable — This bit enables the framing error flag (FE) to generate hardware interrupt
FEIE requests.
0 FE interrupts disabled (use polling).
1 Hardware interrupt requested when FE is set.
0 Parity Error Interrupt Enable — This bit enables the parity error flag (PF) to generate hardware interrupt
PEIE requests.
0 PF interrupts disabled (use polling).
1 Hardware interrupt requested when PF is set.
1
Setting TXINV inverts the TxD output for all cases: data bits, start and stop bits, break, and idle.
7 6 5 4 3 2 1 0
R R7 R6 R5 R4 R3 R2 R1 R0
W T7 T6 T5 T4 T3 T2 T1 T0
Reset 0 0 0 0 0 0 0 0
MODULO DIVIDE BY
(1 THROUGH 8191)
DIVIDE BY
BUSCLK 16 Tx BAUD RATE
SBR12:SBR0
SCI communications require the transmitter and receiver (which typically derive baud rates from
independent clock sources) to use the same baud rate. Allowed tolerance on this baud frequency depends
on the details of how the receiver synchronizes to the leading edge of the start bit and how bit sampling is
performed.
The MCU resynchronizes to bit boundaries on every high-to-low transition. In the worst case, there are no
such transitions in the full 10- or 11-bit time character frame so any mismatch in baud rate is accumulated
for the whole character time. For a Freescale Semiconductor SCI system whose bus frequency is driven
by a crystal, the allowed baud rate mismatch is about ±4.5 percent for 8-bit data format and about ±4
percent for 9-bit data format. Although baud rate modulo divider settings do not always produce baud rates
that exactly match standard rates, it is normally possible to get within a few percent, which is acceptable
for reliable communications.
Writing 0 to TE does not immediately release the pin to be a general-purpose I/O pin. Any transmit activity
in progress must first be completed. This includes data characters in progress, queued idle characters, and
queued break characters.
overrun (OR) status flag is set and the new data is lost. Because the SCI receiver is double-buffered, the
program has one full character time after RDRF is set before the data in the receive data buffer must be
read to avoid a receiver overrun.
When a program detects that the receive data register is full (RDRF = 1), it gets the data from the receive
data register by reading SCIxD. The RDRF flag is cleared automatically by a two-step sequence which is
normally satisfied in the course of the user’s program that handles receive data. Refer to Section 13.3.4,
“Interrupts and Status Flags,” for more details about flag clearing.
the end of a message, or at the beginning of the next message, all receivers automatically force RWU to 0
so all receivers wakeup in time to look at the first character(s) of the next message.
interrupts, software polling may be used to monitor the TDRE and TC status flags if the corresponding
TIE or TCIE local interrupt masks are cleared.
When a program detects that the receive data register is full (RDRF = 1), it gets the data from the receive
data register by reading SCIxD. The RDRF flag is cleared by reading SCIxS1 while RDRF is set and then
reading SCIxD.
When polling is used, this sequence is naturally satisfied in the normal course of the user program. If
hardware interrupts are used, SCIxS1 must be read in the interrupt service routine (ISR). Normally, this is
done in the ISR anyway to check for receive errors, so the sequence is automatically satisfied.
The IDLE status flag includes logic that prevents it from getting set repeatedly when the RxD line remains
idle for an extended period of time. IDLE is cleared by reading SCIxS1 while IDLE is set and then reading
SCIxD. After IDLE has been cleared, it cannot become set again until the receiver has received at least
one new character and has set RDRF.
If the associated error was detected in the received character that caused RDRF to be set, the error flags
— noise flag (NF), framing error (FE), and parity error flag (PF) — are set at the same time as RDRF.
These flags are not set in overrun cases.
If RDRF was already set when a new character is ready to be transferred from the receive shifter to the
receive data buffer, the overrun (OR) flag is set instead of the data along with any associated NF, FE, or
PF condition is lost.
At any time, an active edge on the RxD serial data input pin causes the RXEDGIF flag to set. The
RXEDGIF flag is cleared by writing a 1 to it. This function does depend on the receiver being enabled
(RE = 1).
MISO/MOSI/SPSCK/SS Port Pin for MISO Port Pin for MOSI Port Pin for SPSCK Port Pin for SS
PORT A
LCD25/ADC2/RX2/KBI5/PTA4
LCD24/ADC1/TX2/KBI4/PTA3
BKGD/MS Real Time Counter
BKGD BKP LCD23/ADC0/SDA/PTA2
(RTC) LCD22/SCL/PTA1
LCD21/PTA0
HCS08 SYSTEM CONTROL Modulo Timer TMRCLK
PORT B
(MTIM) LCD[40:37]/PTB[7:4]
RESETS AND INTERRUPTS LCD[32:29]/PTB[3:0]
MODES OF OPERATION KBI[7:0]
8-BIT KEYBOARD
POWER MANAGEMENT
INTERRUPT (KBI)
RESET/PTC6
PORT C
SS BKGD/MS/PTC5
COP RESET SPSCK LCD[20:16]/PTC[4:0]
SERIAL PERIPHERAL MISO
IRQ INTERFACE (SPI)
IRQ LVD MOSI
PORT D
SCL LCD[7:0]/PTD[7:0]
USER FLASH A IIC MODULE (IIC) SDA
(LG32 = 16K BYTES)
PORT E
(LG16 = 2K BYTES) TPM2CH[5:0]
6-CHANNEL TIMER/PWM LCD[15:8]/PTE[7:0]
(TPM2) TPMCLK
USER FLASH B
(LG32 = 16K BYTES) TPM1CH[1:0]
2-CHANNEL TIMER/PWM EXTAL/PTF7
(LG16 = 16K BYTES) XTAL/PTF6
(TPM1) TPMCLK
TPM2CH3/KBI2/MOSI/PTF5
PORT F
TxD1 TPM2CH4/KBI1/MISO/PTF4
SERIAL COMMUNICATIONS
RxD1 TPM2CH5/KBI0/SS/PTF3
USER RAM INTERFACE (SCI1) ADC14/IRQ/TPM1CH1/SPSCK/PTF2
1984 BYTES ADC13/TPM1CH0/RX1/PTF1
TxD2 ADC12/TPM2CH2/KBI3/TX1/PTF0
SERIAL COMMUNICATIONS
RxD2
INTERFACE (SCI2)
PORT G
INTERNAL CLOCK LCD[44:41]/PTG[7:4]
Source (ICS) LCD[36:33]/PTG[3:0]
XTAL
LOW-POWER OSCILLATOR EXTAL
TPM2CH4/KBI1/PTH7
ADC15/KBI0/TPM2CH5/PTH6
PORT H
VLL3_2 12-BIT
ANALOG-TO-DIGITAL AD[15:0] ADC11/TPM1CH0/KBI3/TX1/PTH5
VLL3
CONVERTER (ADC) ADC10/TPM1CH1/KBI2/RX1/PTH4
VLL1 LIQUID CRYSTAL ADC[9:6]/KBI[7:4]/PTH[3:0]
VLL2 DISPLAY DRIVER
(LCD) SS/SCL/TPM2CH0/PTI5
VCAP1
SPSCK/SDA/TPM2CH1/PTI4
PORT I
VCAP2 MOSI/TPM2CH2/PTI3
LCD[44:0] MISO/TPM2CH3/PTI2
TX2/TMRCLK/PTI1
RX2/PTI0
VDD
VSS
VOLTAGE
REGULATOR
VSS2 Available only on 80-pin package
Available only on 64-pin and 80-pin package
VDDA/VREFH */Default function out of reset/*
VSSA/VREFL
Figure 14-1. MC9S08LG32 series Block Diagram Highlighting SPI Block and Pins
14.1.3 Features
Features of the SPI module include:
• Master or slave mode operation
• Full-duplex or single-wire bidirectional option
• Programmable transmit bit rate
• Double-buffered transmit and receive
• Serial clock phase and polarity options
• Slave select output
• Selectable MSB-first or LSB-first shifting
MASTER SLAVE
MOSI MOSI
7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
MISO MISO
SPSCK SPSCK
CLOCK
GENERATOR
SS SS
The most common uses of the SPI system include connecting simple shift registers for adding input or
output ports or connecting small peripheral devices such as serial A/D or D/A converters. Although
Figure 14-2 shows a system where data is exchanged between two MCUs, many practical systems involve
simpler connections where data is unidirectionally transferred from the master MCU to a slave or from a
slave to the master MCU.
PIN CONTROL
M
MOSI
SPE
S (MOMI)
Tx BUFFER (WRITE SPIxD)
ENABLE
SPI SYSTEM M MISO
SHIFT SHIFT (SISO)
SPI SHIFT REGISTER S
OUT IN
SPC0
Rx BUFFER (READ SPIxD)
BIDIROE
SHIFT SHIFT Rx BUFFER Tx BUFFER
LSBFE
DIRECTION CLOCK FULL EMPTY
MASTER CLOCK
M
BUS RATE SPIBR CLOCK
SPSCK
CLOCK CLOCK GENERATOR LOGIC SLAVE CLOCK
S
MASTER/SLAVE MASTER/
MSTR
MODE SELECT SLAVE
MODFEN
SPRF SPTEF
SPTIE
SPI
INTERRUPT
MODF REQUEST
SPIE
Figure 14-3. SPI Module Block Diagram
SPPR2:SPPR1:SPPR0 SPR3:SPR2:SPR1:SPR0
Figure 14-4. SPI Baud Rate Generation
7 6 5 4 3 2 1 0
R
SPIE SPE SPTIE MSTR CPOL CPHA SSOE LSBFE
W
Reset 0 0 0 0 0 1 0 0
Field Description
7 SPI Interrupt Enable (for SPRF and MODF) — This is the interrupt enable for SPI receive buffer full (SPRF)
SPIE and mode fault (MODF) events.
0 Interrupts from SPRF and MODF inhibited (use polling)
1 When SPRF or MODF is 1, request a hardware interrupt
6 SPI System Enable — Disabling the SPI halts any transfer that is in progress, clears data buffers, and initializes
SPE internal state machines. SPRF is cleared and SPTEF is set to indicate the SPI transmit data buffer is empty.
0 SPI system inactive
1 SPI system enabled
5 SPI Transmit Interrupt Enable — This is the interrupt enable bit for SPI transmit buffer empty (SPTEF).
SPTIE 0 Interrupts from SPTEF inhibited (use polling)
1 When SPTEF is 1, hardware interrupt requested
Field Description
3 Clock Polarity — This bit effectively places an inverter in series with the clock signal from a master SPI or to a
CPOL slave SPI device. Refer to Section 14.5.3, “SPI Clock Formats,” for more details.
0 Active-high SPI clock (idles low)
1 Active-low SPI clock (idles high)
2 Clock Phase — This bit selects one of two clock formats for different kinds of synchronous serial peripheral
CPHA devices. Refer to Section 14.5.3, “SPI Clock Formats,” for more details.
0 First edge on SPSCK occurs at the middle of the first cycle of an 8-cycle data transfer
1 First edge on SPSCK occurs at the start of the first cycle of an 8-cycle data transfer
1 Slave Select Output Enable — This bit is used in combination with the mode fault enable (MODFEN) bit in
SSOE SPCR2 and the master/slave (MSTR) control bit to determine the function of the SS pin as shown in Table 14-3.
0 LSB First (Shifter Direction)
LSBFE 0 SPI serial data transfers start with most significant bit
1 SPI serial data transfers start with least significant bit
NOTE
Ensure that the SPI should not be disabled (SPE=0) at the same time as a bit change to the CPHA bit. These
changes should be performed as separate operations or unexpected behavior may occur.
7 6 5 4 3 2 1 0
R 0 0 0 0
MODFEN BIDIROE SPISWAI SPC0
W
Reset 0 0 0 0 0 0 0 0
= Unimplemented or Reserved
Field Description
4 Master Mode-Fault Function Enable — When the SPI is configured for slave mode, this bit has no meaning or
MODFEN effect. (The SS pin is the slave select input.) In master mode, this bit determines how the SS pin is used (refer to
Table 14-3 for more details).
0 Mode fault function disabled, master SS pin reverts to general-purpose I/O not controlled by SPI
1 Mode fault function enabled, master SS pin acts as the mode fault input or the slave select output
3 Bidirectional Mode Output Enable — When bidirectional mode is enabled by SPI pin control 0 (SPC0) = 1,
BIDIROE BIDIROE determines whether the SPI data output driver is enabled to the single bidirectional SPI I/O pin.
Depending on whether the SPI is configured as a master or a slave, it uses either the MOSI (MOMI) or MISO
(SISO) pin, respectively, as the single SPI data I/O pin. When SPC0 = 0, BIDIROE has no meaning or effect.
0 Output driver disabled so SPI data I/O pin acts as an input
1 SPI I/O pin enabled as an output
0 SPI Pin Control 0 — The SPC0 bit chooses single-wire bidirectional mode. If MSTR = 0 (slave mode), the SPI
SPC0 uses the MISO (SISO) pin for bidirectional SPI data transfers. If MSTR = 1 (master mode), the SPI uses the MOSI
(MOMI) pin for bidirectional SPI data transfers. When SPC0 = 1, BIDIROE is used to enable or disable the output
driver for the single bidirectional SPI I/O pin.
0 SPI uses separate pins for data input and data output
1 SPI configured for single-wire bidirectional operation
R 0
SPPR2 SPPR1 SPPR0 SPR3 SPR2 SPR1 SPR0
W
Reset 0 0 0 0 0 0 0 0
= Unimplemented or Reserved
Field Description
6:4 SPI Baud Rate Prescale Divisor — This 3-bit field selects one of eight divisors for the SPI baud rate prescaler
SPPR[2:0] as shown in Table 14-6. The input to this prescaler is the bus rate clock (BUSCLK). The output of this prescaler
drives the input of the SPI baud rate divider (see Figure 14-4).
2:0 SPI Baud Rate Divisor — This 4-bit field selects one of eight divisors for the SPI baud rate divider as shown in
SPR[3:0] Table 14-7. The input to this divider comes from the SPI baud rate prescaler (see Figure 14-4). The output of this
divider is the SPI bit rate clock for master mode.
W
Reset 0 0 1 0 0 0 0 0
= Unimplemented or Reserved
Field Description
7 SPI Read Buffer Full Flag — SPRF is set at the completion of an SPI transfer to indicate that received data may
SPRF be read from the SPI data register (SPIxD). SPRF is cleared by reading SPRF while it is set, then reading the
SPI data register.
0 No data available in the receive data buffer
1 Data available in the receive data buffer
5 SPI Transmit Buffer Empty Flag — This bit is set when there is room in the transmit data buffer. It is cleared by
SPTEF reading SPIxS with SPTEF set, followed by writing a data value to the transmit buffer at SPIxD. SPIxS must be
read with SPTEF = 1 before writing data to SPIxD or the SPIxD write will be ignored. SPTEF generates an
SPTEF CPU interrupt request if the SPTIE bit in the SPIxC1 is also set. SPTEF is automatically set when a data
byte transfers from the transmit buffer into the transmit shift register. For an idle SPI (no data in the transmit buffer
or the shift register and no transfer in progress), data written to SPIxD is transferred to the shifter almost
immediately so SPTEF is set within two bus cycles allowing a second 8-bit data value to be queued into the
transmit buffer. After completion of the transfer of the value in the shift register, the queued value from the transmit
buffer will automatically move to the shifter and SPTEF will be set to indicate there is room for new data in the
transmit buffer. If no new data is waiting in the transmit buffer, SPTEF simply remains set and no data moves from
the buffer to the shifter.
0 SPI transmit buffer not empty
1 SPI transmit buffer empty
4 Master Mode Fault Flag — MODF is set if the SPI is configured as a master and the slave select input goes low,
MODF indicating some other SPI device is also configured as a master. The SS pin acts as a mode fault error input only
when MSTR = 1, MODFEN = 1, and SSOE = 0; otherwise, MODF will never be set. MODF is cleared by reading
MODF while it is 1, then writing to SPI control register 1 (SPIxC1).
0 No mode fault error
1 Mode fault error detected
R
Bit 7 6 5 4 3 2 1 Bit 0
W
Reset 0 0 0 0 0 0 0 0
Reads of this register return the data read from the receive data buffer. Writes to this register write data to
the transmit data buffer. When the SPI is configured as a master, writing data to the transmit data buffer
initiates an SPI transfer.
Data should not be written to the transmit data buffer unless the SPI transmit buffer empty flag (SPTEF)
is set, indicating there is room in the transmit buffer to queue a new transmit byte.
Data may be read from SPIxD any time after SPRF is set and before another transfer is finished. Failure
to read the data out of the receive data buffer before a new transfer ends causes a receive overrun condition
and the data from the new transfer is lost.
are disabled and SPSCK, MOSI and MISO are inputs. If a transmission is in progress when the mode fault
occurs, the transmission is aborted and the SPI is forced into idle state.
This mode fault error also sets the mode fault (MODF) flag in the SPI Status Register (SPIxS). If the SPI
interrupt enable bit (SPIE) is set when the MODF flag gets set, then an SPI interrupt sequence is also
requested.
When a write to the SPI Data Register in the master occurs, there is a half SPSCK-cycle delay. After the
delay, SPSCK is started within the master. The rest of the transfer operation differs slightly, depending on
the clock format specified by the SPI clock phase bit, CPHA, in SPI Control Register 1 (see Section 14.5.3,
“SPI Clock Formats”).
NOTE
A change of the bits CPOL, CPHA, SSOE, LSBFE, MODFEN, SPC0,
BIDIROE with SPC0 set, SPPR2-SPPR0 and SPR3-SPR0 in master mode
will abort a transmission in progress and force the SPI into idle state. The
remote slave cannot detect this, therefore the master has to ensure that the
remote slave is set back to idle state.
As long as no more than one slave device drives the system slave’s serial data output line, it is possible for
several slaves to receive the same transmission from a master, although the master would not receive return
information from all of the receiving slaves.
If the CPHA bit in SPI Control Register 1 is clear, odd numbered edges on the SPSCK input cause the data
at the serial data input pin to be latched. Even numbered edges cause the value previously latched from the
serial data input pin to shift into the LSB or MSB of the SPI shift register, depending on the LSBFE bit.
If the CPHA bit is set, even numbered edges on the SPSCK input cause the data at the serial data input pin
to be latched. Odd numbered edges cause the value previously latched from the serial data input pin to shift
into the LSB or MSB of the SPI shift register, depending on the LSBFE bit.
When CPHA is set, the first edge is used to get the first data bit onto the serial data output pin. When CPHA
is clear and the SS input is low (slave selected), the first bit of the SPI data is driven out of the serial data
output pin. After the eighth shift, the transfer is considered complete and the received data is transferred
into the SPI data registers. To indicate transfer is complete, the SPRF flag in the SPI Status Register is set.
NOTE
A change of the bits CPOL, CPHA, SSOE, LSBFE, MODFEN, SPC0 and
BIDIROE with SPC0 set in slave mode will corrupt a transmission in
progress and has to be avoided.
BIT TIME #
(REFERENCE) 1 2 ... 6 7 8
SPSCK
(CPOL = 0)
SPSCK
(CPOL = 1)
SAMPLE IN
(MISO OR MOSI)
MOSI
(MASTER OUT)
MISO
(SLAVE OUT)
SS OUT
(MASTER)
SS IN
(SLAVE)
When CPHA = 1, the slave begins to drive its MISO output when SS goes to active low, but the data is not
defined until the first SPSCK edge. The first SPSCK edge shifts the first bit of data from the shifter onto
the MOSI output of the master and the MISO output of the slave. The next SPSCK edge causes both the
master and the slave to sample the data bit values on their MISO and MOSI inputs, respectively. At the
third SPSCK edge, the SPI shifter shifts one bit position which shifts in the bit value that was just sampled,
and shifts the second data bit value out the other end of the shifter to the MOSI and MISO outputs of the
master and slave, respectively. When CHPA = 1, the slave’s SS input is not required to go to its inactive
high level between transfers.
Figure 14-11 shows the clock formats when CPHA = 0. At the top of the figure, the eight bit times are
shown for reference with bit 1 starting as the slave is selected (SS IN goes low), and bit 8 ends at the last
SPSCK edge. The MSB first and LSB first lines show the order of SPI data bits depending on the setting
in LSBFE. Both variations of SPSCK polarity are shown, but only one of these waveforms applies for a
specific transfer, depending on the value in CPOL. The SAMPLE IN waveform applies to the MOSI input
of a slave or the MISO input of a master. The MOSI waveform applies to the MOSI output pin from a
master and the MISO waveform applies to the MISO output from a slave. The SS OUT waveform applies
to the slave select output from a master (provided MODFEN and SSOE = 1). The master SS output goes
to active low at the start of the first bit time of the transfer and goes back high one-half SPSCK cycle after
the end of the eighth bit time of the transfer. The SS IN waveform applies to the slave select input of a
slave.
BIT TIME #
(REFERENCE) 1 2 ... 6 7 8
SPSCK
(CPOL = 0)
SPSCK
(CPOL = 1)
SAMPLE IN
(MISO OR MOSI)
MOSI
(MASTER OUT)
MSB FIRST BIT 7 BIT 6 ... BIT 2 BIT 1 BIT 0
LSB FIRST BIT 0 BIT 1 ... BIT 5 BIT 6 BIT 7
MISO
(SLAVE OUT)
SS OUT
(MASTER)
SS IN
(SLAVE)
When CPHA = 0, the slave begins to drive its MISO output with the first data bit value (MSB or LSB
depending on LSBFE) when SS goes to active low. The first SPSCK edge causes both the master and the
slave to sample the data bit values on their MISO and MOSI inputs, respectively. At the second SPSCK
edge, the SPI shifter shifts one bit position which shifts in the bit value that was just sampled and shifts the
second data bit value out the other end of the shifter to the MOSI and MISO outputs of the master and
slave, respectively. When CPHA = 0, the slave’s SS input must go to its inactive high level between
transfers.
14.5.4.1 SS Output
The SS output feature automatically drives the SS pin low during transmission to select external devices
and drives it high during idle to deselect external devices. When SS output is selected, the SS output pin
is connected to the SS input pin of the external device.
The SS output is available only in master mode during normal SPI operation by asserting the SSOE and
MODFEN bits as shown in Table 14-3.
The mode fault feature is disabled while SS output is enabled.
NOTE
Care must be taken when using the SS output feature in a multi-master
system since the mode fault feature is not available for detecting system
errors between masters.
The direction of each serial I/O pin depends on the BIDIROE bit. If the pin is configured as an output,
serial data from the shift register is driven out on the pin. The same pin is also the serial input to the shift
register.
The SPSCK is output for the master mode and input for the slave mode.
The SS is the input or output for the master mode, and it is always the input for the slave mode.
The bidirectional mode does not affect SPSCK and SS functions.
NOTE
In bidirectional master mode, with mode fault enabled, both data pins MISO
and MOSI can be occupied by the SPI, though MOSI is normally used for
transmissions in bidirectional mode and MISO is not used by the SPI. If a
mode fault occurs, the SPI is automatically switched to slave mode, in this
case MISO becomes occupied by the SPI and MOSI is not used. This has to
be considered, if the MISO pin is used for another purpose.
PORT A
LCD25/ADC2/RX2/KBI5/PTA4
LCD24/ADC1/TX2/KBI4/PTA3
BKGD/MS Real Time Counter
BKGD BKP LCD23/ADC0/SDA/PTA2
(RTC) LCD22/SCL/PTA1
LCD21/PTA0
HCS08 SYSTEM CONTROL Modulo Timer TMRCLK
PORT B
(MTIM) LCD[40:37]/PTB[7:4]
RESETS AND INTERRUPTS LCD[32:29]/PTB[3:0]
MODES OF OPERATION KBI[7:0]
8-BIT KEYBOARD
POWER MANAGEMENT
INTERRUPT (KBI)
RESET/PTC6
PORT C
SS BKGD/MS/PTC5
COP RESET SPSCK LCD[20:16]/PTC[4:0]
SERIAL PERIPHERAL MISO
IRQ INTERFACE (SPI)
IRQ LVD MOSI
PORT D
SCL LCD[7:0]/PTD[7:0]
USER FLASH A IIC MODULE (IIC) SDA
(LG32 = 16K BYTES)
PORT E
(LG16 = 2K BYTES) TPM2CH[5:0]
6-CHANNEL TIMER/PWM LCD[15:8]/PTE[7:0]
(TPM2) TPMCLK
USER FLASH B
(LG32 = 16K BYTES) TPM1CH[1:0]
2-CHANNEL TIMER/PWM EXTAL/PTF7
(LG16 = 16K BYTES) XTAL/PTF6
(TPM1) TPMCLK
TPM2CH3/KBI2/MOSI/PTF5
PORT F
TxD1 TPM2CH4/KBI1/MISO/PTF4
SERIAL COMMUNICATIONS
RxD1 TPM2CH5/KBI0/SS/PTF3
USER RAM INTERFACE (SCI1) ADC14/IRQ/TPM1CH1/SPSCK/PTF2
1984 BYTES ADC13/TPM1CH0/RX1/PTF1
TxD2 ADC12/TPM2CH2/KBI3/TX1/PTF0
SERIAL COMMUNICATIONS
RxD2
INTERFACE (SCI2)
PORT G
INTERNAL CLOCK LCD[44:41]/PTG[7:4]
Source (ICS) LCD[36:33]/PTG[3:0]
XTAL
LOW-POWER OSCILLATOR EXTAL
TPM2CH4/KBI1/PTH7
ADC15/KBI0/TPM2CH5/PTH6
PORT H
VLL3_2 12-BIT
ANALOG-TO-DIGITAL AD[15:0] ADC11/TPM1CH0/KBI3/TX1/PTH5
VLL3
CONVERTER (ADC) ADC10/TPM1CH1/KBI2/RX1/PTH4
VLL1 LIQUID CRYSTAL ADC[9:6]/KBI[7:4]/PTH[3:0]
VLL2 DISPLAY DRIVER
(LCD) SS/SCL/TPM2CH0/PTI5
VCAP1
SPSCK/SDA/TPM2CH1/PTI4
PORT I
VCAP2 MOSI/TPM2CH2/PTI3
LCD[44:0] MISO/TPM2CH3/PTI2
TX2/TMRCLK/PTI1
RX2/PTI0
VDD
VSS
VOLTAGE
REGULATOR
VSS2 Available only on 80-pin package
Available only on 64-pin and 80-pin package
VDDA/VREFH */Default function out of reset/*
VSSA/VREFL
Figure 15-1. MC9S08LG32 Series Block Diagram Highlighting RTC Block and Pins
15.1.2 Features
Features of the RTC module include:
• 8-bit up-counter
— 8-bit modulo match limit
— Software controllable periodic interrupt on match
• Three software selectable clock sources for input to prescaler with selectable binary-based and
decimal-based divider values
— 1 kHz internal low-power oscillator (LPO)
— External clock (OSCOUT)
— 32 kHz internal clock (IRCLK)
LPO Clock
Source
OSCOUT
Select
IRCLK
VDD
8-Bit Modulo
RTCLKS (RTCMOD)
Background D Q RTIF RTC
Mode Interrupt
Request
RTCPS E
RTCLKS[0] 8-Bit Comparator
R
RTIE
RTC Write 1 to
Prescaler Clock 8-Bit Counter RTIF
Divide-By (RTCCNT)
Name 7 6 5 4 3 2 1 0
R
RTCSC RTIF RTCLKS RTIE RTCPS
W
R RTCCNT
RTCCNT
W
R
RTCMOD RTCMOD
W
7 6 5 4 3 2 1 0
R
RTIF RTCLKS RTIE RTCPS
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7 Real-Time Interrupt Flag This status bit indicates the RTC counter register reached the value in the RTC modulo
RTIF register. Writing a logic 0 has no effect. Writing a logic 1 clears the bit and the real-time interrupt request. Reset
clears RTIF.
0 RTC counter has not reached the value in the RTC modulo register.
1 RTC counter has reached the value in the RTC modulo register.
6–5 Real-Time Clock Source Select. These two read/write bits select the clock source input to the RTC prescaler.
RTCLKS Changing the clock source clears the prescaler and RTCCNT counters. When selecting a clock source, ensure
that the clock source is properly enabled (if applicable) to ensure correct operation of the RTC. Reset clears
RTCLKS.
00 Real-time clock source is the 1 kHz low power oscillator (LPO)
01 Real-time clock source is the external clock (OSCOUT)
1x Real-time clock source is the internal clock (IRCLK)
4 Real-Time Interrupt Enable. This read/write bit enables real-time interrupts. If RTIE is set, then an interrupt is
RTIE generated when RTIF is set. Reset clears RTIE.
0 Real-time interrupt requests are disabled. Use software polling.
1 Real-time interrupt requests are enabled.
3–0 Real-Time Clock Prescaler Select. These four read/write bits select binary-based or decimal-based divide-by
RTCPS values for the clock source. See Table 15-3. Changing the prescaler value clears the prescaler and RTCCNT
counters. Reset clears RTCPS.
RTCPS
RTCLKS[0]
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 Off 210 211 212 213 214 215 216 103 2x103 5x103 104 2x104 5x104 105 2x105
7 6 5 4 3 2 1 0
R RTCCNT
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 RTC Count. These eight read-only bits contain the current value of the 8-bit counter. Writes have no effect to this
RTCCNT register. Reset, writing to RTCMOD, or writing different values to RTCLKS and RTCPS clear the count to 0x00.
7 6 5 4 3 2 1 0
R
RTCMOD
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 RTC Modulo. These eight read/write bits contain the modulo value used to reset the count to 0x00 upon a compare
RTCMOD match and set the RTIF status bit. A value of 0x00 sets the RTIF bit on each rising edge of the prescaler output.
Writing to RTCMOD resets the prescaler and the RTCCNT counters to 0x00. Reset sets the modulo to 0x00.
RTCPS and the RTCLKS[0] bit select the desired divide-by value. If a different value is written to RTCPS,
the prescaler and RTCCNT counters are reset to 0x00. Table 15-6 shows different prescaler period values.
Table 15-6. Prescaler Period
1 kHz Internal Clock 1 MHz External Clock 32 kHz Internal Clock 32 kHz Internal Clock
RTCPS
(RTCLKS = 00) (RTCLKS = 01) (RTCLKS = 10) (RTCLKS = 11)
0010 32 ms 2.048 ms 1 ms 64 ms
The RTC modulo register (RTCMOD) allows the compare value to be set to any value from 0x00 to 0xFF.
When the counter is active, the counter increments at the selected rate until the count matches the modulo
value. When these values match, the counter resets to 0x00 and continues counting. The real-time interrupt
flag (RTIF) is set when a match occurs. The flag sets on the transition from the modulo value to 0x00.
Writing to RTCMOD resets the prescaler and the RTCCNT counters to 0x00.
The RTC allows for an interrupt to be generated when RTIF is set. To enable the real-time interrupt, set
the real-time interrupt enable bit (RTIE) in RTCSC. RTIF is cleared by writing a 1 to RTIF.
Internal 1 kHz
Clock Source
RTC Clock
(RTCPS = 0xA)
RTIF
RTCMOD 0x55
In the example of Figure 15-6, the selected clock source is the 1 kHz internal oscillator clock source. The
prescaler (RTCPS) is set to 0xA or divide-by-4. The modulo value in the RTCMOD register is set to 0x55.
When the counter, RTCCNT, reaches the modulo value of 0x55, the counter overflows to 0x00 and
continues counting. The real-time interrupt flag, RTIF, sets when the counter value changes from 0x55 to
0x00. A real-time interrupt is generated when RTIF is set, if RTIE is set.
/**********************************************************************
Function Name : RTC_ISR
Notes : Interrupt service routine for RTC module.
**********************************************************************/
#pragma TRAP_PROC
void RTC_ISR(void)
{
/* Clear the interrupt flag */
RTCSC.byte = RTCSC.byte | 0x80;
/* RTC interrupts every 1 Second */
Seconds++;
/* 60 seconds in a minute */
if (Seconds > 59){
Minutes++;
Seconds = 0;
}
/* 60 minutes in an hour */
if (Minutes > 59){
Hours++;
Minutes = 0;
}
/* 24 hours in a day */
if (Hours > 23){
Days ++;
Hours = 0;
}
TPMxCHn Port Pin for TPM2CH5 Port Pin for TPM2CH4 Port Pin for TPM2CH3 Port Pin for TPM2CH2
TPMxCHn Port Pin for TPM2CH1 Port Pin for TPM2CH0 Port Pin for TPM1CH1 Port Pin for TPM1CH0
PORT A
LCD25/ADC2/RX2/KBI5/PTA4
LCD24/ADC1/TX2/KBI4/PTA3
BKGD/MS Real Time Counter
BKGD BKP LCD23/ADC0/SDA/PTA2
(RTC) LCD22/SCL/PTA1
LCD21/PTA0
HCS08 SYSTEM CONTROL Modulo Timer TMRCLK
PORT B
(MTIM) LCD[40:37]/PTB[7:4]
RESETS AND INTERRUPTS LCD[32:29]/PTB[3:0]
MODES OF OPERATION KBI[7:0]
8-BIT KEYBOARD
POWER MANAGEMENT
INTERRUPT (KBI)
RESET/PTC6
PORT C
SS BKGD/MS/PTC5
COP RESET SPSCK LCD[20:16]/PTC[4:0]
SERIAL PERIPHERAL MISO
IRQ INTERFACE (SPI)
IRQ LVD MOSI
PORT D
SCL LCD[7:0]/PTD[7:0]
USER FLASH A IIC MODULE (IIC) SDA
(LG32 = 16K BYTES)
PORT E
(LG16 = 2K BYTES) TPM2CH[5:0]
6-CHANNEL TIMER/PWM LCD[15:8]/PTE[7:0]
(TPM2) TPMCLK
USER FLASH B
(LG32 = 16K BYTES) TPM1CH[1:0]
2-CHANNEL TIMER/PWM EXTAL/PTF7
(LG16 = 16K BYTES) XTAL/PTF6
(TPM1) TPMCLK
TPM2CH3/KBI2/MOSI/PTF5
PORT F
TxD1 TPM2CH4/KBI1/MISO/PTF4
SERIAL COMMUNICATIONS
RxD1 TPM2CH5/KBI0/SS/PTF3
USER RAM INTERFACE (SCI1) ADC14/IRQ/TPM1CH1/SPSCK/PTF2
1984 BYTES ADC13/TPM1CH0/RX1/PTF1
TxD2 ADC12/TPM2CH2/KBI3/TX1/PTF0
SERIAL COMMUNICATIONS
RxD2
INTERFACE (SCI2)
PORT G
VLL3_2 12-BIT
ANALOG-TO-DIGITAL AD[15:0] ADC11/TPM1CH0/KBI3/TX1/PTH5
VLL3
CONVERTER (ADC) ADC10/TPM1CH1/KBI2/RX1/PTH4
VLL1 LIQUID CRYSTAL ADC[9:6]/KBI[7:4]/PTH[3:0]
VLL2 DISPLAY DRIVER
(LCD) SS/SCL/TPM2CH0/PTI5
VCAP1
SPSCK/SDA/TPM2CH1/PTI4
PORT I
VCAP2 MOSI/TPM2CH2/PTI3
LCD[44:0] MISO/TPM2CH3/PTI2
TX2/TMRCLK/PTI1
RX2/PTI0
VDD
VSS
VOLTAGE
REGULATOR
VSS2 Available only on 80-pin package
Available only on 64-pin and 80-pin package
VDDA/VREFH */Default function out of reset/*
VSSA/VREFL
Figure 16-1. MC9S08LG32 Series Block Diagram Highlighting TPMx Blocks and Pins
16.1.5 Features
The TPM includes these distinctive features:
• One to eight channels:
— Each channel is input capture, output compare, or edge-aligned PWM
— Rising-edge, falling-edge, or any-edge input capture trigger
— Set, clear, or toggle output compare action
— Selectable polarity on PWM outputs
• Module is configured for buffered, center-aligned pulse-width-modulation (CPWM) on all
channels
• Timer clock source selectable as bus clock, fixed frequency clock, or an external clock
— Prescale taps for divide-by 1, 2, 4, 8, 16, 32, 64, or 128 used for any clock input selection
— Fixed frequency clock is an additional clock input to allow the selection of an on chip clock
source other than bus clock
— Selecting external clock connects TPM clock to a chip level input pin therefore allowing to
synchronize the TPM counter with an off chip clock source
• 16-bit free-running or modulus count with up/down selection
• One interrupt per channel and one interrupt for TPM counter overflow
The value of a 16-bit modulo register plus 1 sets the period of the PWM output signal. The channel
value register sets the duty cycle of the PWM output signal. You can also choose the polarity of the
PWM output signal. Interrupts are available at the end of the period and at the duty-cycle transition
point. This type of PWM signal is called edge-aligned because the leading edges of all PWM
signals are aligned with the beginning of the period that is same for all channels within a TPM.
• Center-aligned PWM mode
Twice the value of a 16-bit modulo register sets the period of the PWM output, and the
channel-value register sets the half-duty-cycle duration. The timer counter counts up until it
reaches the modulo value and then counts down until it reaches zero. As the count matches the
channel value register while counting down, the PWM output becomes active. When the count
matches the channel value register while counting up, the PWM output becomes inactive. This type
of PWM signal is called center-aligned because the centers of the active duty cycle periods for all
channels are aligned with a count value of zero. This type of PWM is required for types of motors
used in small appliances.
This is a high-level description only. Detailed descriptions of operating modes are in later sections.
no clock selected
(TPM counter disable)
PS[2:0]
CLKSB:CLKSA
CPWMS
TPM counter
(16-bit counter) TOF Interrupt
counter reset logic
TOIE
16-bit comparator
TPMxMODH:TPMxMODL
16-bit comparator
TPMxC1VH:TPMxC1VL CH1F
up to 8 channels
The TPM channels are programmable independently as input capture, output compare, or edge-aligned
PWM channels. Alternately, the TPM can be configured to produce CPWM outputs on all channels. When
the TPM is configured for CPWMs (the counter operates as an up/down counter) input capture, output
compare, and EPWM functions are not practical.
Name Function
EXTCLK1 External clock source that is selected to drive the TPM counter.
TPMxCHn2 I/O pin associated with TPM channel n.
1
The external clock pin can be shared with any channel pin. However, depending upon full-chip
implementation, this signal could be connected to a separate external pin.
2 n = channel number (1–8)
be reliably detected—on an input capture pin is four bus clock periods (with ideal clock pulses as near as
two bus clocks can be detected).
When a channel is configured for output compare (CPWMS = 0, MSnB:MSnA = 0:1, and
ELSnB:ELSnA ≠ 0:0), the TPMxCHn pin is an output controlled by the TPM. The ELSnB:ELSnA bits
determine whether the TPMxCHn pin is toggled, cleared, or set each time the 16-bit channel value register
matches the TPM counter.
When the output compare toggle mode is initially selected, the previous value on the pin is driven out until
the next output compare event, the pin is then toggled.
When a channel is configured for edge-aligned PWM (CPWMS = 0, MSnB = 1, and
ELSnB:ELSnA ≠ 0:0), the TPMxCHn pin is an output controlled by the TPM, and ELSnB:ELSnA bits
control the polarity of the PWM output signal. When ELSnB is set and ELSnA is cleared, the TPMxCHn
pin is forced high at the start of each new period (TPMxCNT=0x0000), and it is forced low when the
channel value register matches the TPM counter. When ELSnA is set, the TPMxCHn pin is forced low at
the start of each new period (TPMxCNT=0x0000), and it is forced high when the channel value register
matches the TPM counter.
TPMxMODH:TPMxMODL = 0x0008
TPMxCnVH:TPMxCnVL = 0x0005
TPMxCHn
CHnF bit
TOF bit
TPMxMODH:TPMxMODL = 0x0008
TPMxCnVH:TPMxCnVL = 0x0005
TPMxCHn
CHnF bit
TOF bit
When the TPM is configured for center-aligned PWM (CPWMS = 1 and ELSnB:ELSnA ≠ 0:0), the
TPMxCHn pins are outputs controlled by the TPM, and ELSnB:ELSnA bits control the polarity of the
PWM output signal. If ELSnB is set and ELSnA is cleared, the corresponding TPMxCHn pin is cleared
when the TPM counter is counting up, and the channel value register matches the TPM counter; and it is
set when the TPM counter is counting down, and the channel value register matches the TPM counter. If
ELSnA is set, the corresponding TPMxCHn pin is set when the TPM counter is counting up and the
channel value register matches the TPM counter; and it is cleared when the TPM counter is counting down
and the channel value register matches the TPM counter.
TPMxMODH:TPMxMODL = 0x0008
TPMxCnVH:TPMxCnVL = 0x0005
TPMxCHn
CHnF bit
TOF bit
TPMxMODH:TPMxMODL = 0x0008
TPMxCnVH:TPMxCnVL = 0x0005
TPMxCHn
CHnF bit
TOF bit
7 6 5 4 3 2 1 0
R TOF
TOIE CPWMS CLKSB CLKSA PS2 PS1 PS0
W 0
Reset 0 0 0 0 0 0 0 0
Field Description
7 Timer overflow flag. This read/write flag is set when the TPM counter resets to 0x0000 after reaching the modulo
TOF value programmed in the TPM counter modulo registers. Clear TOF by reading the TPM status and control
register when TOF is set and then writing a logic 0 to TOF. If another TPM overflow occurs before the clearing
sequence is completed, the sequence is reset so TOF remains set after the clear sequence was completed for
the earlier TOF. This is done so a TOF interrupt request cannot be lost during the clearing sequence for a previous
TOF. Reset clears TOF. Writing a logic 1 to TOF has no effect.
0 TPM counter has not reached modulo value or overflow.
1 TPM counter has overflowed.
6 Timer overflow interrupt enable. This read/write bit enables TPM overflow interrupts. If TOIE is set, an interrupt is
TOIE generated when TOF equals one. Reset clears TOIE.
0 TOF interrupts inhibited (use for software polling).
1 TOF interrupts enabled.
5 Center-aligned PWM select. This read/write bit selects CPWM operating mode. By default, the TPM operates in
CPWMS up-counting mode for input capture, output compare, and edge-aligned PWM functions. Setting CPWMS
reconfigures the TPM to operate in up/down counting mode for CPWM functions. Reset clears CPWMS.
0 All channels operate as input capture, output compare, or edge-aligned PWM mode as selected by the
MSnB:MSnA control bits in each channel’s status and control register.
1 All channels operate in center-aligned PWM mode.
4–3 Clock source selection bits. As shown in Table 16-4, this 2-bit field is used to disable the TPM counter or select
CLKS[B:A] one of three clock sources to TPM counter and counter prescaler.
2–0 Prescale factor select. This 3-bit field selects one of eight division factors for the TPM clock as shown in
PS[2:0] Table 16-5. This prescaler is located after any clock synchronization or clock selection so it affects the clock
selected to drive the TPM counter. The new prescale factor affects the selected clock on the next bus clock cycle
after the new value is updated into the register bits.
000 1
001 2
010 4
011 8
100 16
101 32
110 64
111 128
7 6 5 4 3 2 1 0
R TPMxCNT[15:8]
W Any write to TPMxCNTH clears the 16-bit counter
Reset 0 0 0 0 0 0 0 0
7 6 5 4 3 2 1 0
R TPMxCNT[7:0]
W Any write to TPMxCNTL clears the 16-bit counter
Reset 0 0 0 0 0 0 0 0
When BDM is active, the timer counter is frozen (this is the value you read). The coherency mechanism
is frozen so the buffer latches remain in the state they were in when the BDM became active, even if one
or both counter halves are read while BDM is active. This assures that if you were in the middle of reading
a 16-bit register when BDM became active, it reads the appropriate value from the other half of the 16-bit
value after returning to normal execution.
In BDM mode, writing any value to TPMxSC, TPMxCNTH, or TPMxCNTL registers resets the read
coherency mechanism of the TPMxCNTH:TPMxCNTL registers, regardless of the data involved in the
write.
7 6 5 4 3 2 1 0
R
TPMxMOD[15:8]
W
Reset 0 0 0 0 0 0 0 0
7 6 5 4 3 2 1 0
R
TPMxMOD[7:0]
W
Reset 0 0 0 0 0 0 0 0
Reset the TPM counter before writing to the TPM modulo registers to avoid confusion about when the first
counter overflow occurs.
7 6 5 4 3 2 1 0
R CHnF 0 0
CHnIE MSnB MSnA ELSnB ELSnA
W 0
Reset 0 0 0 0 0 0 0 0
= Unimplemented or Reserved
Field Description
7 Channel n flag. When channel n is an input capture channel, this read/write bit is set when an active edge occurs
CHnF on the channel n input. When channel n is an output compare or edge-aligned/center-aligned PWM channel,
CHnF is set when the value in the TPM counter registers matches the value in the TPM channel n value registers.
When channel n is an edge-aligned/center-aligned PWM channel and the duty cycle is set to 0% or 100%, CHnF
is not set even when the value in the TPM counter registers matches the value in the TPM channel n value
registers.
A corresponding interrupt is requested when this bit is set and channel n interrupt is enabled (CHnIE = 1). Clear
CHnF by reading TPMxCnSC while this bit is set and then writing a logic 0 to it. If another interrupt request occurs
before the clearing sequence is completed CHnF remains set. This is done so a CHnF interrupt request is not lost
due to clearing a previous CHnF.
Reset clears this bit. Writing a logic 1 to CHnF has no effect.
0 No input capture or output compare event occurred on channel n.
1 Input capture or output compare event on channel n.
6 Channel n interrupt enable. This read/write bit enables interrupts from channel n. Reset clears this bit.
CHnIE 0 Channel n interrupt requests disabled (use for software polling).
1 Channel n interrupt requests enabled.
5 Mode select B for TPM channel n. When CPWMS is cleared, setting the MSnB bit configures TPM channel n for
MSnB edge-aligned PWM mode. Refer to the summary of channel mode and setup controls in Table 16-7.
4 Mode select A for TPM channel n. When CPWMS and MSnB are cleared, the MSnA bit configures TPM channel
MSnA n for input capture mode or output compare mode. Refer to Table 16-7 for a summary of channel mode and setup
controls.
Note: If the associated port pin is not stable for at least two bus clock cycles before changing to input capture
mode, it is possible to get an unexpected indication of an edge trigger.
3–2 Edge/level select bits. Depending upon the operating mode for the timer channel as set by CPWMS:MSnB:MSnA
ELSnB and shown in Table 16-7, these bits select the polarity of the input edge that triggers an input capture event, select
ELSnA the level that is driven in response to an output compare match, or select the polarity of the PWM output.
If ELSnB and ELSnA bits are cleared, the channel pin is not controlled by TPM. This configuration can be used
by software compare only, because it does not require the use of a pin for the channel.
7 6 5 4 3 2 1 0
R
TPMxCnV[15:8]
W
Reset 0 0 0 0 0 0 0 0
7 6 5 4 3 2 1 0
R
TPMxCnV[7:0]
W
Reset 0 0 0 0 0 0 0 0
In input capture mode, reading either byte (TPMxCnVH or TPMxCnVL) latches the contents of both bytes
into a buffer where they remain latched until the other half is read. This latching mechanism also resets
(becomes unlatched) when the TPMxCnSC register is written (whether BDM mode is active or not). Any
write to the channel registers is ignored during the input capture mode.
When BDM is active, the coherency mechanism is frozen (unless reset by writing to TPMxCnSC register)
so the buffer latches remain in the state they were in when the BDM became active, even if one or both
halves of the channel register are read while BDM is active. This assures that if you were in the middle of
reading a 16-bit register when BDM became active, it reads the appropriate value from the other half of
the 16-bit value after returning to normal execution. The value read from the TPMxCnVH and
TPMxCnVL registers in BDM mode is the value of these registers and not the value of their read buffer.
In output compare or PWM modes, writing to either byte (TPMxCnVH or TPMxCnVL) latches the value
into a buffer. After both bytes were written, they are transferred as a coherent 16-bit value into the
timer-channel registers according to the value of CLKSB:CLKSA bits and the selected mode:
• If CLKSB and CLKSA are cleared, the registers are updated when the second byte is written.
• If CLKSB and CLKSA are not cleared and in output compare mode, the registers are updated after
the second byte is written and on the next change of the TPM counter (end of the prescaler
counting).
• If CLKSB and CLKSA are not cleared and in EPWM or CPWM modes, the registers are updated
after both bytes were written, and the TPM counter changes from
(TPMxMODH:TPMxMODL – 1) to (TPMxMODH:TPMxMODL). If the TPM counter is a
free-running counter, the update is made when the TPM counter changes from 0xFFFE to 0xFFFF.
The latching mechanism is manually reset by writing to the TPMxCnSC register (whether BDM mode is
active or not). This latching mechanism allows coherent 16-bit writes in either big-endian or little-endian
order that is friendly to various compiler implementations.
When BDM is active, the coherency mechanism is frozen so the buffer latches remain in the state they
were in when the BDM became active even if one or both halves of the channel register are written while
BDM is active. Any write to the channel registers bypasses the buffer latches and directly write to the
channel register while BDM is active. The values written to the channel register while BDM is active are
used for PWM and output compare operation after normal execution resumes. Writes to the channel
registers while BDM is active do not interfere with partial completion of a coherency sequence. After the
coherency mechanism is fully exercised, the channel registers are updated using the buffered values (while
BDM was not active).
activity depend upon the operating mode, these topics are covered in the associated mode explanation
sections.
16.4.1 Counter
All timer functions are based on the main 16-bit counter (TPMxCNTH:TPMxCNTL). This section
discusses selection of the clock, end-of-count overflow, up-counting vs. up/down counting, and manual
counter reset.
Writes to any of TPMxCnVH and TPMxCnVL registers actually write to buffer registers. In output
compare mode, the TPMxCnVH:TPMxCnVL registers are updated with the value of their write buffer
only after both bytes were written and according to the value of CLKSB:CLKSA bits:
• If CLKSB and CLKSA are cleared, the registers are updated when the second byte is written
• If CLKSB and CLKSA are not cleared, the registers are updated at the next change of the TPM
counter (end of the prescaler counting) after the second byte is written.
The coherency sequence can be manually reset by writing to the channel status/control register
(TPMxCnSC).
An output compare event sets a flag bit (CHnF) that optionally generates a CPU interrupt request.
period
pulse width
TPMxCHn
When the channel value register is set to 0x0000, the duty cycle is 0%. A 100% duty cycle is achieved by
setting the timer-channel register (TPMxCnVH:TPMxCnVL) to a value greater than the modulus setting.
This implies that the modulus setting must be less than 0xFFFF in order to get 100% duty cycle.
The timer channel registers are buffered to ensure coherent 16-bit updates and to avoid unexpected PWM
pulse widths. Writes to any of the registers TPMxCnVH and TPMxCnVL actually write to buffer registers.
In edge-aligned PWM mode, the TPMxCnVH:TPMxCnVL registers are updated with the value of their
write buffer according to the value of CLKSB:CLKSA bits:
• If CLKSB and CLKSA are cleared, the registers are updated when the second byte is written
• If CLKSB and CLKSA are not cleared, the registers are updated after both bytes were written, and
the TPM counter changes from (TPMxMODH:TPMxMODL – 1) to
TPM counter = 0
TPM counter = channel match channel match TPM counter =
TPMxMODH:TPMxMODL (count down) (count up) TPMxMODH:TPMxMODL
TPMxCHn
pulse width
2 × TPMxCnVH:TPMxCnVL
period
2 × TPMxMODH:TPMxMODL
Figure 16-16. CPWM period and pulse width (ELSnA=0)
Center-aligned PWM outputs typically produce less noise than edge-aligned PWMs because fewer I/O pin
transitions are lined up at the same system clock edge. This type of PWM is also required for some types
of motor drives.
Input capture, output compare, and edge-aligned PWM functions do not make sense when the counter is
operating in up/down counting mode so this implies that all active channels within a TPM must be used in
CPWM mode when CPWMS is set.
The timer channel registers are buffered to ensure coherent 16-bit updates and to avoid unexpected PWM
pulse widths. Writes to any of the registers TPMxCnVH and TPMxCnVL actually write to buffer registers.
In center-aligned PWM mode, the TPMxCnVH:TPMxCnVL registers are updated with the value of their
write buffer according to the value of CLKSB:CLKSA bits:
• If CLKSB and CLKSA are cleared, the registers are updated when the second byte is written
• If CLKSB and CLKSA are not cleared, the registers are updated after both bytes were written, and
the TPM counter changes from (TPMxMODH:TPMxMODL – 1) to
(TPMxMODH:TPMxMODL). If the TPM counter is a free-running counter, the update is made
when the TPM counter changes from 0xFFFE to 0xFFFF.
When TPMxCNTH:TPMxCNTL equals TPMxMODH:TPMxMODL, the TPM can optionally generate a
TOF interrupt (at the end of this count).
16.5.1 General
The TPM is reset whenever any MCU reset occurs.
16.6 Interrupts
16.6.1 General
The TPM generates an optional interrupt for the main counter overflow and an interrupt for each channel.
The meaning of channel interrupts depends on each channel’s mode of operation. If the channel is
configured for input capture, the interrupt flag is set each time the selected input capture edge is
recognized. If the channel is configured for output compare or PWM modes, the interrupt flag is set each
time the main timer counter matches the value in the 16-bit channel value register.
All TPM interrupts are listed in Table 16-8.
Local
Interrupt Source Description
Enable
TOF TOIE Counter overflow Set each time the TPM counter reaches its terminal
count (at transition to its next count value)
CHnF CHnIE Channel event An input capture event or channel match took place
on channel n
PORT A
LCD25/ADC2/RX2/KBI5/PTA4
LCD24/ADC1/TX2/KBI4/PTA3
BKGD/MS Real Time Counter
BKGD BKP LCD23/ADC0/SDA/PTA2
(RTC) LCD22/SCL/PTA1
LCD21/PTA0
HCS08 SYSTEM CONTROL Modulo Timer TMRCLK
PORT B
(MTIM) LCD[40:37]/PTB[7:4]
RESETS AND INTERRUPTS LCD[32:29]/PTB[3:0]
MODES OF OPERATION KBI[7:0]
8-BIT KEYBOARD
POWER MANAGEMENT
INTERRUPT (KBI)
RESET/PTC6
PORT C
SS BKGD/MS/PTC5
COP RESET SPSCK LCD[20:16]/PTC[4:0]
SERIAL PERIPHERAL MISO
IRQ INTERFACE (SPI)
IRQ LVD MOSI
PORT D
SCL LCD[7:0]/PTD[7:0]
USER FLASH A IIC MODULE (IIC) SDA
(LG32 = 16K BYTES)
PORT E
(LG16 = 2K BYTES) TPM2CH[5:0]
6-CHANNEL TIMER/PWM LCD[15:8]/PTE[7:0]
(TPM2) TPMCLK
USER FLASH B
(LG32 = 16K BYTES) TPM1CH[1:0]
2-CHANNEL TIMER/PWM EXTAL/PTF7
(LG16 = 16K BYTES) XTAL/PTF6
(TPM1) TPMCLK
T2CH3/KBI2/MOSI/PTF5
PORT F
TxD1 T2CH4/KBI1/MISO/PTF4
SERIAL COMMUNICATIONS
RxD1 T2CH5/KBI0/SS/PTF3
USER RAM INTERFACE (SCI1) ADC14/IRQ/T1CH1/SPSCK/PTF2
1984 BYTES ADC13/T1CH0/RX1/PTF1
TxD2 ADC12/T2CH2/KBI3/TX1/PTF0
SERIAL COMMUNICATIONS
RxD2
INTERFACE (SCI2)
PORT G
INTERNAL CLOCK LCD[44:41]/PTG[7:4]
Source (ICS) LCD[36:33]/PTG[3:0]
XTAL
LOW-POWER OSCILLATOR EXTAL
T2CH4/KBI1/PTH7
ADC15/KBI0/T2CH5/PTH6
PORT H
VLL3_2 12-BIT
ANALOG-TO-DIGITAL AD[15:0] ADC11/T1CH0/KBI3/TX1/PTH5
VLL3
CONVERTER (ADC) ADC10/T1CH1/KBI2/RX1/PTH4
VLL1 LIQUID CRYSTAL ADC[9:6]/KBI[7:4]/PTH[3:0]
VLL2 DISPLAY DRIVER
(LCD) SS/SCL/T2CH0/PTI5
VCAP1
SPSCK/SDA/T2CH1/PTI4
PORT I
VCAP2 MOSI/T2CH2/PTI3
LCD[44:0] MISO/T2CH3/PTI2
TX2/TMRCLK/PTI1
RX2/PTI0
VDD
VSS
VOLTAGE
REGULATOR
VSS2 Available only on 80-pin package
Available only on 64-pin and 80-pin package
VDDA/VREFH */Default function out of reset/*
VSSA/VREFL
Figure 17-1. MC9S08LG32 Series Block Diagram Highlighting MTIM Block and Pins
17.1.2 Features
Timer system features include:
• 8-bit up-counter
— Free-running or 8-bit modulo limit
— Software controllable interrupt on overflow
— Counter reset bit (TRST)
— Counter stop bit (TSTP)
• Four software selectable clock sources for input to prescaler:
— System bus clock — rising edge
— Fixed frequency clock (XCLK) — rising edge
— External clock source on the TPMCLK pin — rising edge
— External clock source on the TPMCLK pin — falling edge
• Nine selectable clock prescale values:
— Clock source divide by 1, 2, 4, 8, 16, 32, 64, 128, or 256
BUSCLK
CLOCK PRESCALE 8-BIT COUNTER TRST
XCLK
SOURCE AND SELECT (MTIMCNT) TSTP
TPMCLK
SYNC SELECT DIVIDE BY
8-BIT COMPARATOR
CLKS PS
MTIM
INTERRUPT
REQUEST TOF
8-BIT MODULO
(MTIMMOD)
TOIE
The TPMCLK input must be synchronized by the bus clock. Also, variations in duty cycle and clock jitter
must be accommodated. Therefore, the TPMCLK signal must be limited to one-fourth of the bus
frequency.
The TPMCLK pin can be muxed with a general-purpose port pin. See the Chapter 2, “Pins and
Connections,” chapter for the pin location and priority of this function.
Name 7 6 5 4 3 2 1 0
R TOF 0 0 0 0 0
MTIMSC TOIE TSTP
W TRST
R 0 0
MTIMCLK CLKS PS
W
R COUNT
MTIMCNT
W
R
MTIMMOD MOD
W
7 6 5 4 3 2 1 0
R TOF 0 0 0 0 0
TOIE TSTP
W TRST
Reset: 0 0 0 1 0 0 0 0
Field Description
7 MTIM Overflow Flag — This read-only bit is set when the MTIM counter register overflows to $00 after reaching
TOF the value in the MTIM modulo register. Clear TOF by reading the MTIMSC register while TOF is set, then writing
a 0 to TOF. TOF is also cleared when TRST is written to a 1 or when any value is written to the MTIMMOD register.
0 MTIM counter has not reached the overflow value in the MTIM modulo register.
1 MTIM counter has reached the overflow value in the MTIM modulo register.
6 MTIM Overflow Interrupt Enable — This read/write bit enables MTIM overflow interrupts. If TOIE is set, then an
TOIE interrupt is generated when TOF = 1. Reset clears TOIE. Do not set TOIE if TOF = 1. Clear TOF first, then set TOIE.
0 TOF interrupts are disabled. Use software polling.
1 TOF interrupts are enabled.
5 MTIM Counter Reset — When a 1 is written to this write-only bit, the MTIM counter register resets to $00 and TOF
TRST is cleared. Reading this bit always returns 0.
0 No effect. MTIM counter remains at current state.
1 MTIM counter is reset to $00.
4 MTIM Counter Stop — When set, this read/write bit stops the MTIM counter at its current value. Counting resumes
TSTP from the current value when TSTP is cleared. Reset sets TSTP to prevent the MTIM from counting.
0 MTIM counter is active.
1 MTIM counter is stopped.
7 6 5 4 3 2 1 0
R 0 0
CLKS PS
W
Reset: 0 0 0 0 0 0 0 0
Field Description
5:4 Clock Source Select — These two read/write bits select one of four different clock sources as the input to the
CLKS MTIM prescaler. Changing the clock source while the counter is active does not clear the counter. The count
continues with the new clock source. Reset clears CLKS to 000.
00 Encoding 0. Bus clock (BUSCLK)
01 Encoding 1. Fixed-frequency clock (XCLK)
10 Encoding 3. External source (TPMCLK pin), falling edge
11 Encoding 4. External source (TPMCLK pin), rising edge
All other encodings default to the bus clock (BUSCLK).
3:0 Clock Source Prescaler — These four read/write bits select one of nine outputs from the 8-bit prescaler. Changing
PS the prescaler value while the counter is active does not clear the counter. The count continues with the new
prescaler value. Reset clears PS to 0000.
0000 Encoding 0. MTIM clock source ÷ 1
0001 Encoding 1. MTIM clock source ÷ 2
0010 Encoding 2. MTIM clock source ÷ 4
0011 Encoding 3. MTIM clock source ÷ 8
0100 Encoding 4. MTIM clock source ÷ 16
0101 Encoding 5. MTIM clock source ÷ 32
0110 Encoding 6. MTIM clock source ÷ 64
0111 Encoding 7. MTIM clock source ÷ 128
1000 Encoding 8. MTIM clock source ÷ 256
All other encodings default to MTIM clock source ÷ 256.
7 6 5 4 3 2 1 0
R COUNT
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 MTIM Count — These eight read-only bits contain the current value of the 8-bit counter. Writes have no effect to
COUNT this register. Reset clears the count to $00.
7 6 5 4 3 2 1 0
R
MOD
W
Reset: 0 0 0 0 0 0 0 0
Field Description
7:0 MTIM Modulo — These eight read/write bits contain the modulo value used to reset the count and set TOF. A value
MOD of $00 puts the MTIM in free-running mode. Writing to MTIMMOD resets the COUNT to $00 and clears TOF. Reset
sets the modulo to $00.
selected
clock source
MTIM clock
(PS=%0010)
TOF
MTIMMOD: $AA
In the example of Figure 17-8, the selected clock source could be any of the four possible choices. The
prescaler is set to PS = %0010 or divide-by-4. The modulo value in the MTIMMOD register is set to $AA.
When the counter, MTIMCNT, reaches the modulo value of $AA, the counter overflows to $00 and
continues counting. The timer overflow flag, TOF, sets when the counter value changes from $AA to $00.
An MTIM overflow interrupt is generated when TOF is set, if TOIE = 1.
18.1.3 Features
Features of the BDC module include:
• Single pin for mode selection and background communications
• BDC registers are not located in the memory map
• SYNC command to determine target communications rate
• Non-intrusive commands for memory access
• Active background mode commands for CPU register access
• GO and TRACE1 commands
• BACKGROUND command can wake CPU from stop or wait modes
• One hardware address breakpoint built into BDC
• Oscillator runs in stop mode, if BDC enabled
• COP watchdog disabled while in active background mode
BKGD 1 2 GND
NO CONNECT 3 4 RESET
NO CONNECT 5 6 VDD
when this timeout occurs is aborted without affecting the memory or operating mode of the target MCU
system.
The custom serial protocol requires the debug pod to know the target BDC communication clock speed.
The clock switch (CLKSW) control bit in the BDC status and control register allows the user to select the
BDC clock source. The BDC clock source can either be the bus or the alternate BDC clock source.
The BKGD pin can receive a high or low level or transmit a high or low level. The following diagrams
show timing for each of these cases. Interface timing is synchronous to clocks in the target BDC, but
asynchronous to the external host. The internal BDC clock signal is shown for reference in counting
cycles.
Figure 18-2 shows an external host transmitting a logic 1 or 0 to the BKGD pin of a target HCS08 MCU.
The host is asynchronous to the target so there is a 0-to-1 cycle delay from the host-generated falling edge
to where the target perceives the beginning of the bit time. Ten target BDC clock cycles later, the target
senses the bit level on the BKGD pin. Typically, the host actively drives the pseudo-open-drain BKGD pin
during host-to-target transmissions to speed up rising edges. Because the target does not drive the BKGD
pin during the host-to-target transmission period, there is no need to treat the line as an open-drain signal
during this period.
BDC CLOCK
(TARGET MCU)
HOST
TRANSMIT 1
HOST
TRANSMIT 0
10 CYCLES
EARLIEST START
OF NEXT BIT
SYNCHRONIZATION TARGET SENSES BIT LEVEL
UNCERTAINTY
PERCEIVED START
OF BIT TIME
Figure 18-2. BDC Host-to-Target Serial Bit Timing
Figure 18-3 shows the host receiving a logic 1 from the target HCS08 MCU. Because the host is
asynchronous to the target MCU, there is a 0-to-1 cycle delay from the host-generated falling edge on
BKGD to the perceived start of the bit time in the target MCU. The host holds the BKGD pin low long
enough for the target to recognize it (at least two target BDC cycles). The host must release the low drive
before the target MCU drives a brief active-high speedup pulse seven cycles after the perceived start of the
bit time. The host should sample the bit level about 10 cycles after it started the bit time.
BDC CLOCK
(TARGET MCU)
HOST DRIVE
TO BKGD PIN HIGH-IMPEDANCE
TARGET MCU
SPEEDUP PULSE
HIGH-IMPEDANCE HIGH-IMPEDANCE
PERCEIVED START
OF BIT TIME
R-C RISE
BKGD PIN
10 CYCLES
EARLIEST START
OF NEXT BIT
10 CYCLES
Figure 18-4 shows the host receiving a logic 0 from the target HCS08 MCU. Because the host is
asynchronous to the target MCU, there is a 0-to-1 cycle delay from the host-generated falling edge on
BKGD to the start of the bit time as perceived by the target MCU. The host initiates the bit time but the
target HCS08 finishes it. Because the target wants the host to receive a logic 0, it drives the BKGD pin low
for 13 BDC clock cycles, then briefly drives it high to speed up the rising edge. The host samples the bit
level about 10 cycles after starting the bit time.
BDC CLOCK
(TARGET MCU)
HOST DRIVE
TO BKGD PIN HIGH-IMPEDANCE
SPEEDUP
TARGET MCU PULSE
DRIVE AND
SPEED-UP PULSE
PERCEIVED START
OF BIT TIME
BKGD PIN
10 CYCLES
EARLIEST START
10 CYCLES OF NEXT BIT
1 The SYNC command is a special operation that does not have a command code.
The SYNC command is unlike other BDC commands because the host does not necessarily know the
correct communications speed to use for BDC communications until after it has analyzed the response to
the SYNC command.
To issue a SYNC command, the host:
• Drives the BKGD pin low for at least 128 cycles of the slowest possible BDC clock (The slowest
clock is normally the reference oscillator/64 or the self-clocked rate/64.)
• Drives BKGD high for a brief speedup pulse to get a fast rise time (This speedup pulse is typically
one cycle of the fastest clock in the system.)
• Removes all drive to the BKGD pin so it reverts to high impedance
• Monitors the BKGD pin for the sync response pulse
The target, upon detecting the SYNC request from the host (which is a much longer low time than would
ever occur during normal BDC communications):
• Waits for BKGD to return to a logic high
• Delays 16 cycles to allow the host to stop driving the high speedup pulse
• Drives BKGD low for 128 BDC clock cycles
• Drives a 1-cycle high speedup pulse to force a fast rise time on BKGD
• Removes all drive to the BKGD pin so it reverts to high impedance
The host measures the low time of this 128-cycle sync response pulse and determines the correct speed for
subsequent BDC communications. Typically, the host can determine the correct communication speed
within a few percent of the actual target speed and the communication protocol can easily tolerate speed
errors of several percent.
This section refers to registers and control bits only by their names. A Freescale-provided equate or header
file is used to translate these names into the appropriate absolute addresses.
7 6 5 4 3 2 1 0
Normal 0 0 0 0 0 0 0 0
Reset
Reset in 1 1 0 0 1 0 0 0
Active BDM:
= Unimplemented or Reserved
Field Description
7 Enable BDM (Permit Active Background Mode) — Typically, this bit is written to 1 by the debug host shortly
ENBDM after the beginning of a debug session or whenever the debug host resets the target and remains 1 until a normal
reset clears it.
0 BDM cannot be made active (non-intrusive commands still allowed)
1 BDM can be made active to allow active background mode commands
6 Background Mode Active Status — This is a read-only status bit.
BDMACT 0 BDM not active (user application program running)
1 BDM active and waiting for serial commands
5 BDC Breakpoint Enable — If this bit is clear, the BDC breakpoint is disabled and the FTS (force tag select)
BKPTEN control bit and BDCBKPT match register are ignored.
0 BDC breakpoint disabled
1 BDC breakpoint enabled
4 Force/Tag Select — When FTS = 1, a breakpoint is requested whenever the CPU address bus matches the
FTS BDCBKPT match register. When FTS = 0, a match between the CPU address bus and the BDCBKPT register
causes the fetched opcode to be tagged. If this tagged opcode ever reaches the end of the instruction queue,
the CPU enters active background mode rather than executing the tagged opcode.
0 Tag opcode at breakpoint address and enter active background mode if CPU attempts to execute that
instruction
1 Breakpoint match forces active background mode at next instruction boundary (address need not be an
opcode)
3 Select Source for BDC Communications Clock — CLKSW defaults to 0, which selects the alternate BDC clock
CLKSW source.
0 Alternate BDC clock source
1 MCU bus clock
Field Description
2 Wait or Stop Status — When the target CPU is in wait or stop mode, most BDC commands cannot function.
WS However, the BACKGROUND command can be used to force the target CPU out of wait or stop and into active
background mode where all BDC commands work. Whenever the host forces the target MCU into active
background mode, the host should issue a READ_STATUS command to check that BDMACT = 1 before
attempting other BDC commands.
0 Target CPU is running user application code or in active background mode (was not in wait or stop mode when
background became active)
1 Target CPU is in wait or stop mode, or a BACKGROUND command was used to change from wait or stop to
active background mode
1 Wait or Stop Failure Status — This status bit is set if a memory access command failed due to the target CPU
WSF executing a wait or stop instruction at or about the same time. The usual recovery strategy is to issue a
BACKGROUND command to get out of wait or stop mode into active background mode, repeat the command
that failed, then return to the user program. (Typically, the host would restore CPU registers and stack values and
re-execute the wait or stop instruction.)
0 Memory access did not conflict with a wait or stop instruction
1 Memory access command failed because the CPU entered wait or stop mode
0 Data Valid Failure Status — This status bit is not used in the MC9S08LG32 series because it does not have
DVF any slow access memory.
0 Memory access did not conflict with a slow memory access
1 Memory access command failed because CPU was not finished with a slow memory access
7 6 5 4 3 2 1 0
R 0 0 0 0 0 0 0 0
W BDFR1
Reset 0 0 0 0 0 0 0 0
= Unimplemented or Reserved
1
BDFR is writable only through serial background mode debug commands, not from user programs.
Field Description
0 Background Debug Force Reset — A serial active background mode command such as WRITE_BYTE allows
BDFR an external debug host to force a target system reset. Writing 1 to this bit forces an MCU reset. This bit cannot
be written from a user program.
19.1.1 Features
The on-chip ICE system includes these distinctive features:
• Three comparators (A, B, and C) with ability to match addresses in 64K space
— Dual mode, Comparators A and B used to compare addresses
— Full mode, Comparator A compares address and Comparator B compares data
— Can be used as triggers and/or breakpoints
— Comparator C can be used as a normal hardware breakpoint
— Loop1 capture mode, Comparator C is used to track most recent COF event captured into FIFO
• Tag and Force type breakpoints
• Nine trigger modes
— A
— A Or B
— A Then B
— A And B, where B is data (Full mode)
— A And Not B, where B is data (Full mode)
— Event Only B, store data
— A Then Event Only B, store data
— Inside Range, A ≤ Address ≤ B
— Outside Range, Address < Α or Address > B
• FIFO for storing change of flow information and event only data
— Source address of conditional branches taken
— Destination address of indirect JMP and JSR instruction
— Destination address of interrupts, RTI, RTC, and RTS instruction
— Data associated with Event B trigger modes
Read DBGFL
Read DBGFH
Read DBGFX
Instr. Lastcycle
ppage_sel1
Bus Clk register m m
u 8 deep FIFO Data
m FIFO u
x x
subtract 2 u
x addr[16:0]1
Write Data Bus
m
u
Read Data Bus
x
Read/Write
1. In 64K versions of this module there are only 16 address lines [15:0], there are no core_cpu_aob_14_t2,
core_cpu_aob_15_t2, core_ppage_t2[2:0], and ppage_sel signals.
Figure 19-1. DBG Block Diagram
Table 19-2 shows the register bit summary for the registers contained in the DBG module.
Table 19-2. Register Bit Summary (Sheet 1 of 2)
7 6 5 4 3 2 1 0
7 6 5 4 3 2 1 0
7 6 5 4 3 2 1 0
R
Bit 15 Bit 14 Bit 13 Bit 12 Bit 11 Bit 10 Bit 9 Bit 8
W
POR
or non- 1 1 1 1 1 1 1 1
end-run
Reset
U U U U U U U U
end-run1
Field Description
Bits 15–8 Comparator A High Compare Bits — The Comparator A High compare bits control whether Comparator A will
compare the address bus bits [15:8] to a logic 1 or logic 0.
0 Compare corresponding address bit to a logic 0
1 Compare corresponding address bit to a logic 1
7 6 5 4 3 2 1 0
R
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
W
POR
or non- 1 1 1 1 1 1 1 0
end-run
Reset
U U U U U U U U
end-run1
Field Description
Bits 7–0 Comparator A Low Compare Bits — The Comparator A Low compare bits control whether Comparator A will
compare the address bus bits [7:0] to a logic 1 or logic 0.
0 Compare corresponding address bit to a logic 0
1 Compare corresponding address bit to a logic 1
7 6 5 4 3 2 1 0
R
Bit 15 Bit 14 Bit 13 Bit 12 Bit 11 Bit 10 Bit 9 Bit 8
W
POR
or non- 0 0 0 0 0 0 0 0
end-run
Reset
U U U U U U U U
end-run1
Field Description
Bits 15–8 Comparator B High Compare Bits — The Comparator B High compare bits control whether Comparator B will
compare the address bus bits [15:8] to a logic 1 or logic 0. Not used in Full mode.
0 Compare corresponding address bit to a logic 0
1 Compare corresponding address bit to a logic 1
7 6 5 4 3 2 1 0
R
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
W
POR
or non- 0 0 0 0 0 0 0 0
end-run
Reset
U U U U U U U U
end-run1
1
In the case of an end-trace to reset where DBGEN=1 and BEGIN=0, the bits in this register do not change after reset.
Field Description
Bits 7–0 Comparator B Low Compare Bits — The Comparator B Low compare bits control whether Comparator B will
compare the address bus or data bus bits [7:0] to a logic 1 or logic 0.
0 Compare corresponding address bit to a logic 0, compares to data if in Full mode
1 Compare corresponding address bit to a logic 1, compares to data if in Full mode
7 6 5 4 3 2 1 0
R
Bit 15 Bit 14 Bit 13 Bit 12 Bit 11 Bit 10 Bit 9 Bit 8
W
POR
or non- 0 0 0 0 0 0 0 0
end-run
Reset
U U U U U U U U
end-run1
Field Description
Bits 15–8 Comparator C High Compare Bits — The Comparator C High compare bits control whether Comparator C will
compare the address bus bits [15:8] to a logic 1 or logic 0.
0 Compare corresponding address bit to a logic 0
1 Compare corresponding address bit to a logic 1
7 6 5 4 3 2 1 0
R
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
W
POR
or non- 0 0 0 0 0 0 0 0
end-run
Reset
U U U U U U U U
end-run1
Field Description
Bits 7–0 Comparator C Low Compare Bits — The Comparator C Low compare bits control whether Comparator C will
compare the address bus bits [7:0] to a logic 1 or logic 0.
0 Compare corresponding address bit to a logic 0
1 Compare corresponding address bit to a logic 1
7 6 5 4 3 2 1 0
W
POR
or non- 0 0 0 0 0 0 0 0
end-run
Reset
U U U U U U U U
end-run1
= Unimplemented or Reserved
Field Description
Bits 15–8 FIFO High Data Bits — The FIFO High data bits provide access to bits [15:8] of data in the FIFO. This register
is not used in event only modes and will read a $00 for valid FIFO words.
7 6 5 4 3 2 1 0
POR
or non- 0 0 0 0 0 0 0 0
end-run
Reset
U U U U U U U U
end-run1
= Unimplemented or Reserved
Field Description
Bits 7–0 FIFO Low Data Bits — The FIFO Low data bits contain the least significant byte of data in the FIFO. When
reading FIFO words, read DBGFX and DBGFH before reading DBGFL because reading DBGFL causes the
FIFO pointers to advance to the next FIFO location. In event-only modes, there is no useful information in DBGFX
and DBGFH so it is not necessary to read them before reading DBGFL.
7 6 5 4 3 2 1 0
R 0 0 0 0 0 0
RWAEN RWA
W
POR
or non- 0 0 0 0 0 0 0 0
end-run
Reset
U U U 0 0 0 0 U
end-run1
= Unimplemented or Reserved
Field Description
7 Read/Write Comparator A Enable Bit — The RWAEN bit controls whether read or write comparison is enabled
RWAEN for Comparator A.
0 Read/Write is not used in comparison
1 Read/Write is used in comparison
6 Read/Write Comparator A Value Bit — The RWA bit controls whether read or write is used in compare for
RWA Comparator A. The RWA bit is not used if RWAEN = 0.
0 Write cycle will be matched
1 Read cycle will be matched
7 6 5 4 3 2 1 0
R 0 0 0 0 0 0
RWBEN RWB
W
POR
or non- 0 0 0 0 0 0 0 0
end-run
Reset
U U U 0 0 0 0 U
end-run1
= Unimplemented or Reserved
Field Description
7 Read/Write Comparator B Enable Bit — The RWBEN bit controls whether read or write comparison is enabled
RWBEN for Comparator B. In full modes, RWAEN and RWA are used to control comparison of R/W and RWBEN is
ignored.
0 Read/Write is not used in comparison
1 Read/Write is used in comparison
6 Read/Write Comparator B Value Bit — The RWB bit controls whether read or write is used in compare for
RWB Comparator B. The RWB bit is not used if RWBEN = 0. In full modes, RWAEN and RWA are used to control
comparison of R/W and RWB is ignored.
0 Write cycle will be matched
1 Read cycle will be matched
7 6 5 4 3 2 1 0
R 0 0 0 0 0 0
RWCEN RWC
W
POR
or non- 0 0 0 0 0 0 0 0
end-run
Reset
U U U 0 0 0 0 U
end-run1
= Unimplemented or Reserved
Field Description
7 Read/Write Comparator C Enable Bit — The RWCEN bit controls whether read or write comparison is enabled
RWCEN for Comparator C.
0 Read/Write is not used in comparison
1 Read/Write is used in comparison
6 Read/Write Comparator C Value Bit — The RWC bit controls whether read or write is used in compare for
RWC Comparator C. The RWC bit is not used if RWCEN = 0.
0 Write cycle will be matched
1 Read cycle will be matched
7 6 5 4 3 2 1 0
R 0 0 0
DBGEN ARM TAG BRKEN LOOP1
W
POR
or non- 1 1 0 0 0 0 0 0
end-run
Reset
U 0 U 0 0 0 0 U
end-run1
= Unimplemented or Reserved
Field Description
7 DBG Module Enable Bit — The DBGEN bit enables the DBG module. The DBGEN bit is forced to zero and
DBGEN cannot be set if the MCU is secure.
0 DBG not enabled
1 DBG enabled
6 Arm Bit — The ARM bit controls whether the debugger is comparing and storing data in FIFO. See
ARM Section 19.4.4.2, “Arming the DBG Module,” for more information.
0 Debugger not armed
1 Debugger armed
5 Tag or Force Bit — The TAG bit controls whether a debugger or comparator C breakpoint will be requested as
TAG a tag or force breakpoint to the CPU. The TAG bit is not used if BRKEN = 0.
0 Force request selected
1 Tag request selected
4 Break Enable Bit — The BRKEN bit controls whether the debugger will request a breakpoint to the CPU at the
BRKEN end of a trace run, and whether comparator C will request a breakpoint to the CPU.
0 CPU break request not enabled
1 CPU break request enabled
0 Select LOOP1 Capture Mode — This bit selects either normal capture mode or LOOP1 capture mode. LOOP1
LOOP1 is not used in event-only modes.
0 Normal operation - capture COF events into the capture buffer FIFO
1 LOOP1 capture mode enabled. When the conditions are met to store a COF value into the FIFO, compare the
current COF address with the address in comparator C. If these addresses match, override the FIFO capture
and do not increment the FIFO count. If the address does not match comparator C, capture the COF address,
including the PPACC indicator, into the FIFO and into comparator C.
7 6 5 4 3 2 1 0
R 0 0
TRGSEL BEGIN TRG
2
W
POR
or non- 0 1 0 0 0 0 0 0
end-run
Reset
U U 0 0 U U U U
end-run1
= Unimplemented or Reserved
Field Description
7 Trigger Selection Bit — The TRGSEL bit controls the triggering condition for the comparators. See
TRGSEL Section 19.4.4, “Trigger Break Control (TBC),” for more information.
0 Trigger on any compare address access
1 Trigger if opcode at compare address is executed
6 Begin/End Trigger Bit — The BEGIN bit controls whether the trigger begins or ends storing of data in FIFO.
BEGIN 0 Trigger at end of stored data
1 Trigger before storing data
3–0 Trigger Mode Bits — The TRG bits select the trigger mode of the DBG module as shown in Table 19-16.
TRG
NOTE
The DBG trigger register (DBGT) can not be changed unless ARM=0.
7 6 5 4 3 2 1 0
R AF BF CF 0 0 0 0 ARMF
POR
or non- 0 0 0 0 0 0 0 1
end-run
Reset
U U U 0 0 0 0 0
end-run1
= Unimplemented or Reserved
Field Description
7 Trigger A Match Bit — The AF bit indicates if Trigger A match condition was met since arming.
AF 0 Comparator A did not match
1 Comparator A match
6 Trigger B Match Bit — The BF bit indicates if Trigger B match condition was met since arming.
BF 0 Comparator B did not match
1 Comparator B match
5 Trigger C Match Bit — The CF bit indicates if Trigger C match condition was met since arming.
CF 0 Comparator C did not match
1 Comparator C match
0 Arm Flag Bit — The ARMF bit indicates whether the debugger is waiting for trigger or waiting for the FIFO to fill.
ARMF While DBGEN = 1, this status bit is a read-only image of the ARM bit in DBGC. See Section 19.4.4.2, “Arming
the DBG Module,” for more information.
0 Debugger not armed
1 Debugger armed
7 6 5 4 3 2 1 0
R 0 0 0 0 CNT
POR
or non- 0 0 0 0 0 0 0 0
end-run
Reset
0 0 0 0 U U U U
end-run1
= Unimplemented or Reserved
Field Description
3–0 FIFO Valid Count Bits — The CNT bits indicate the amount of valid data stored in the FIFO. Table 19-16 shows
CNT the correlation between the CNT bits and the amount of valid data in FIFO. The CNT will stop after a count to
eight even if more data is being stored in the FIFO. The CNT bits are cleared when the DBG module is armed,
and the count is incremented each time a new word is captured into the FIFO. The host development system is
responsible for checking the value in CNT[3:0] and reading the correct number of words from the FIFO because
the count does not decrement as data is read out of the FIFO at the end of a trace run.
19.4.1 Comparator
The DBG module contains three comparators, A, B, and C. Comparator A compares the core address bus
with the address stored in the DBGCAH and DBGCAL registers. Comparator B compares the core address
bus with the address stored in the DBGCBH and DBGCBL registers except in full mode, where it
compares the data buses to the data stored in the DBGCBL register. Comparator C compares the core
address bus with the address stored in the DBGCCH and DBGCCL registers. Matches on Comparators A,
B, and C are signaled to the Trigger Break Control (TBC) block.
19.4.2 Breakpoints
A breakpoint request to the CPU at the end of a trace run can be created if the BRKEN bit in the DBGC
register is set. The value of the BEGIN bit in DBGT register determines when the breakpoint request to
the CPU will occur. If the BEGIN bit is set, begin-trigger is selected and the breakpoint request will not
occur until the FIFO is filled with 8 words. If the BEGIN bit is cleared, end-trigger is selected and the
breakpoint request will occur immediately at the trigger cycle.
When traditional hardware breakpoints from comparators A or B are desired, set BEGIN=0 to select an
end-trace run and set the trigger mode to either 0x0 (A-only) or 0x1 (A OR B) mode.
There are two types of breakpoint requests supported by the DBG module, tag-type and force-type. Tagged
breakpoints are associated with opcode addresses and allow breaking just before a specific instruction
executes. Force breakpoints are not associated with opcode addresses and allow breaking at the next
instruction boundary. The TAG bit in the DBGC register determines whether CPU breakpoint requests will
be a tag-type or force-type breakpoints. When TAG=0, a force-type breakpoint is requested and it will take
effect at the next instruction boundary after the request. When TAG=1, a tag-type breakpoint is registered
into the instruction queue and the CPU will break if/when this tag reaches the head of the instruction queue
and the tagged instruction is about to be executed.
correspond to separate instructions that could be propagating through the instruction queue at the same
time.
In end-type trace runs (BEGIN=0), when the comparator registers match, including the optional R/W
match, this signal goes to the CPU break logic where BRKEN determines whether a CPU break is
requested and the TAG control bit determines whether the CPU break will be a tag-type or force-type
breakpoint. When TRGSEL is set, the R/W qualified comparator match signal also passes through the
opcode tracking logic. If/when it propagates through this logic, it will cause a trigger to the ICE logic to
begin or end capturing information into the FIFO. In the case of an end-type (BEGIN=0) trace run, the
qualified comparator signal stops the FIFO from capturing any more information.
If a CPU breakpoint is also enabled, you would want TAG and TRGSEL to agree so that the CPU break
occurs at the same place in the application program as the FIFO stopped capturing information. If
TRGSEL was 0 and TAG was 1 in an end-type trace run, the FIFO would stop capturing as soon as the
comparator address matched, but the CPU would continue running until a TAG signal could propagate
through the CPUs instruction queue which could take a long time in the case where changes of flow caused
the instruction queue to be flushed. If TRGSEL was one and TAG was zero in an end-type trace run, the
CPU would break before the comparator match signal could propagate through the opcode tracking logic
to end the trace run.
In begin-type trace runs (BEGIN=1), the start of FIFO capturing is triggered by the qualified comparator
signals, and the CPU breakpoint (if enabled by BRKEN=1) is triggered when the FIFO becomes full. Since
this FIFO full condition does not correspond to the execution of a tagged instruction, it would not make
sense to use TAG=1 for a begin-type trace run.
the DBG module clears the AF, BF, and CF flags in the DBGS register. In all trigger modes except for the
event only modes change of flow addresses are stored in the FIFO. In the event only modes only the value
on the data bus at the trigger event B comparator match address will be stored.
19.4.4.3.1 A Only
In the A Only trigger mode, if the match condition for A is met, the AF flag in the DBGS register is set.
19.4.4.3.2 A Or B
In the A Or B trigger mode, if the match condition for A or B is met, the corresponding flag(s) in the DBGS
register are set.
19.4.4.3.3 A Then B
In the A Then B trigger mode, the match condition for A must be met before the match condition for B is
compared. When the match condition for A or B is met, the corresponding flag in the DBGS register is set.
0 0 1 1 Do not use(2)
(1)
0 1 0 x Fill FIFO until trigger opcode about to execute (No CPU
breakpoint - keep running)
0 1 1 0 Do not use(3)
1 0 1 1 Do not use(4)
(1) Start FIFO at trigger opcode (No CPU breakpoint - keep
1 1 0 x
running)
1 1 1 1 Do not use(4)
1
When BRKEN = 0, TAG is do not care (x in the table).
2
In end trace configurations (BEGIN = 0) where a CPU breakpoint is enabled (BRKEN = 1), TRGSEL should agree with TAG. In this case, where
TRGSEL = 0 to select no opcode tracking qualification and TAG = 1 to specify a tag-type CPU breakpoint, the CPU breakpoint would not take
effect until sometime after the FIFO stopped storing values. Depending on program loops or interrupts, the delay could be very long.
3
In end trace configurations (BEGIN = 0) where a CPU breakpoint is enabled (BRKEN = 1), TRGSEL should agree with TAG. In this case, where
TRGSEL = 1 to select opcode tracking qualification and TAG = 0 to specify a force-type CPU breakpoint, the CPU breakpoint would erroneously
take effect before the FIFO stopped storing values and the debug run would not complete normally.
4 In begin trace configurations (BEGIN = 1) where a CPU breakpoint is enabled (BRKEN = 1), TAG should not be set to 1. In begin trace debug
runs, the CPU breakpoint corresponds to the FIFO full condition which does not correspond to a taggable instruction fetch.
19.4.5 FIFO
The FIFO is an eight word deep FIFO. In all trigger modes except for event only, the data stored in the
FIFO will be change of flow addresses. In the event only trigger modes only the data bus value
corresponding to the event is stored. In event only trigger modes, the high byte of the valid data from the
FIFO will always read a 0x00.
the FIFO to shift. This action could cause a valid entry to be lost because the unexpected read blocked the
FIFO advance.
If the DBG module is not armed and the DBGFL register is read, the TBC will store the current opcode
address. Through periodic reads of the DBGFH and DBGFL registers while the DBG module is not armed,
host software can provide a histogram of program execution. This is called profile mode.
19.5 Resets
The DBG module cannot cause an MCU reset.
There are two different ways this module will respond to reset depending upon the conditions before the
reset event. If the DBG module was setup for an end trace run with DBGEN=1 and BEGIN=0, ARM,
ARMF, and BRKEN are cleared but the reset function on most DBG control and status bits is overridden
so a host development system can read out the results of the trace run after the MCU has been reset. In all
other cases including POR, the DBG module controls are initialized to start a begin trace run starting from
when the reset vector is fetched. The conditions for the default begin trace run are:
• DBGCAH=0xFF, DBGCAL=0xFE so comparator A is set to match when the 16-bit CPU address
0xFFFE appears during the reset vector fetch
• DBGC=0xC0 to enable and arm the DBG module
• DBGT=0x40 to select a force-type trigger, a BEGIN trigger, and A-only trigger mode
19.6 Interrupts
The DBG contains no interrupt source.
Web Support: Freescale Semiconductor reserves the right to make changes without further notice to
http://www.freescale.com/support any products herein. Freescale Semiconductor makes no warranty, representation or
USA/Europe or Locations Not Listed: guarantee regarding the suitability of its products for any particular purpose, nor does
Freescale Semiconductor Freescale Semiconductor assume any liability arising out of the application or use of any
Technical Information Center, CH370 product or circuit, and specifically disclaims any and all liability, including without
1300 N. Alma School Road limitation consequential or incidental damages. “Typical” parameters that may be
Chandler, Arizona 85224 provided in Freescale Semiconductor data sheets and/or specifications can and do vary
+1-800-521-6274 or +1-480-768-2130 in different applications and actual performance may vary over time. All operating
www.freescale.com/support parameters, including “Typicals”, must be validated for each customer application by
customer’s technical experts. Freescale Semiconductor does not convey any license
Europe, Middle East, and Africa:
Freescale Halbleiter Deutschland GmbH under its patent rights nor the rights of others. Freescale Semiconductor products are
Technical Information Center not designed, intended, or authorized for use as components in systems intended for
Schatzbogen 7 surgical implant into the body, or other applications intended to support or sustain life,
81829 Muenchen, Germany or for any other application in which the failure of the Freescale Semiconductor product
+44 1296 380 456 (English) could create a situation where personal injury or death may occur. Should Buyer
+46 8 52200080 (English) purchase or use Freescale Semiconductor products for any such unintended or
+49 89 92103 559 (German) unauthorized application, Buyer shall indemnify and hold Freescale Semiconductor and
+33 1 69 35 48 48 (French) its officers, employees, subsidiaries, affiliates, and distributors harmless against all
www.freescale.com/support
claims, costs, damages, and expenses, and reasonable attorney fees arising out of,
Japan: directly or indirectly, any claim of personal injury or death associated with such
Freescale Semiconductor Japan Ltd. unintended or unauthorized use, even if such claim alleges that Freescale
Headquarters Semiconductor was negligent regarding the design or manufacture of the part.
ARCO Tower 15F
1-8-1, Shimo-Meguro, Meguro-ku,
Tokyo 153-0064 RoHS-compliant and/or Pb-free versions of Freescale products have the functionality
Japan and electrical characteristics as their non-RoHS-compliant and/or non-Pb-free
0120 191014 or +81 3 5437 9125 counterparts. For further information, see http://www.freescale.com or contact your
[email protected] Freescale sales representative.
Asia/Pacific:
Freescale Semiconductor China Ltd. For information on Freescale’s Environmental Products program, go to
Exchange Building 23F http://www.freescale.com/epp.
No. 118 Jianguo Road
Chaoyang District
Beijing 100022 Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
China All other product or service names are the property of their respective owners.
+86 10 5879 8000 © Freescale Semiconductor, Inc. 2009. All rights reserved.
[email protected]
MC9S08LG32
Rev. 5, 8/2009