•Breakpoint capability to allow single breakpoint
setting during in-circuit debugging (plus two
more breakpoints in on-chip debug module)
•Debugmodulecontainingtwo comparatorsand
nine trigger modes. Eightdeep FIFO for storing
change-of-flowaddresses and event-onlydata.
Debug module supports both tag and force
breakpoints.
•Support for up to 32 interrupt/reset sources
Memory Options
•Up to 16 KB of on-chip in-circuit programmable
FLASH memory with block protection and
security options
•Up to 1 KB of on-chip RAM
Clock Source Options
•Clocksource optionsinclude crystal, resonator,
external clock, or internally generated clock
with precision NVM trimming
System Protection
•Optional computer operating properly (COP)
reset with option to run from independent
internal clock source or bus clock
•Low-voltage detection with reset or interrupt
•Illegal opcode detection with reset
•Illegal address detection with reset
Peripherals
•ADC — 8-channel, 10-bit analog-to-digital
converter with automatic compare function
•SCI — Two serial communications interface
modules with optional 13-bit break
•SPI — Serial peripheral interface module
•IIC — Inter-integrated circuit bus module to
operate at up to 100 kbps with maximum bus
loading; capable of higher baud rates with
reduced loading
•Timers — Three1 16-bit timer/pulse-width
modulator (TPM) modules — Two1 2-channel
and one 4-channel; each has selectable input
capture, output compare, and edge-aligned
PWM capability on each channel. Each timer
module may be configured for buffered,
centered PWM (CPWM) on all channels
•KBI — 7-pin keyboard interrupt module
Input/Output
•Up to 38 general-purpose input/output (I/O)
pins
•Software selectable pullups on ports when
used as inputs
•Software selectable slew rate control on ports
when used as outputs
•Software selectable drive strength on ports
when used as outputs
•Master reset pin and power-on reset (POR)
•Internal pullup on RESET,IRQ, and BKGD/MS
pins to reduce customer system cost
Package Options
•48-pin quad flat no-lead package (QFN)
•44-pin low-profile quad flat package (LQFP)
•32-pin low-profile quad flat package (LQFP)
Power-Saving Modes
•Wait plus two stops
1. MC9S08AC16 and MC9S08AC8 devices only.
MC9S08AC16 Series Data Sheet
CoversMC9S08AC16
MC9S08AC8
S9S08AW16A
S9S08AW8A
MC9S08AC16
Rev. 0
12/2007
PRELIMINARY
Revision History
To provide the most up-to-date information, the revision of our documents on the WorldWide 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://freescale.com/
The following revision history table summarizes changes contained in this document. For your
convenience, the page number designators have been linked to the appropriate location.
Revision
Number
012/2007Initial Release.
Revision
Date
Description of Changes
This product incorporates SuperFlash® technology licensed from SST.
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
6.3.1Port A ................................................................................................................................83
6.3.2Port B ................................................................................................................................84
6.3.3Port C ................................................................................................................................84
6.3.4Port D ................................................................................................................................85
6.3.5Port E ................................................................................................................................85
6.3.6Port F .................................................................................................................................86
6.3.7Port G ................................................................................................................................86
6.4Parallel I/O Control .........................................................................................................................87
6.5Pin Control ......................................................................................................................................88
10.2 Features .........................................................................................................................................165
10.3 TPMV3 Differences from Previous Versions ................................................................................168
10.3.1 Migrating from TPMV1 ..................................................................................................170
10.3.2 Features ...........................................................................................................................171
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY13
Section NumberTitlePage
10.3.3 Modes of Operation ........................................................................................................171
The MC9S08AC16Series devicesare members of thelow-cost,high-performance HCS08 Familyof 8-bit
microcontroller units (MCUs). All MCUs in the family use the enhanced HCS08 core and are available
with a variety of modules, memory sizes, memory types, and package types. Refer to Table 1-1 for
memory sizes and package types.
NOTE
•The MC9S08AC16and MC9S08AC8 devices are qualified for, and are
intended to be used in, consumer and industrial applications.
•The S9S08AW16A and S9S08AW8A devices are qualified for, and are
intended to be used in, automotive applications.
Table 1-1 summarizes the feature set available in the MCUs.
= Not available on 32-, or 44-pin packages
= Not available on 32-pin packages
= Not available on 32-pin packages
2-CHANNEL TIMER/PWM
MODULE (TPM3)
TPM3CH1
TPM3CH0
PORT G
PTG6/EXTAL
PTG5/XTAL
PTG4/KBIP4
PTG3/KBIP3
PTG2/KBIP2
PTG1/KBIP1
PTG0/KBIP0
= Not available on S9S08AWxxA devices
Notes:
1. Port pins are software configurable with pullup device if input port.
2. Pin contains software configurable pullup/pulldown device if IRQ is enabled (IRQPE = 1). Pulldown is enabled
if rising edge detect is selected (IRQEDG = 1)
3. IRQ does not have a clamp diode to V
. IRQ should not be driven above VDD.
DD
4. Pin contains integrated pullup device.
5. PTD3, PTD2, and PTG4 contain both pullup and pulldown devices. Pulldown enabled when KBI is enabled
(KBIPEn = 1) and rising edge is selected (KBEDGn = 1).
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY21
Chapter 1 Introduction
Figure 1-1. MC9S08AC16 Block Diagram
Table 1-2 lists the functional versions of the on-chip modules.
Table 1-2. Versions of On-Chip Modules
ModuleVersion
Analog-to-Digital Converter(ADC)1
Internal Clock Generator(ICG)4
Inter-Integrated Circuit(IIC)2
Keyboard Interrupt(KBI)1
Serial Communications Interface(SCI)4
Serial Peripheral Interface(SPI)3
Timer Pulse-Width Modulator(TPM)3
Central Processing Unit(CPU)2
1.3System Clock Distribution
ICG
SYSTEM
CONTROL
2
LOGIC
2
XCLK**
COP
BUSCLK
RTI
1 kHz
BDCCPUADC1RAMFLASH
ICGERCLK
FFE
ICGOUT
ICGLCLK*
* ICGLCLK is the alternate BDC clock source for the MC9S08AC16 Series.
** XCLK is the fixed-frequency clock.
*** TPM3 is not available on S9S08AWxxA devices.
TPMCLK
TPM1TPM2IIC1SCI1SCI2SPI1
TPM3***
Figure 1-2. System Clock Distribution Diagram
ADC has min and max
frequency requirements.
See the Electricals appendix
and the ADC chapter.
FLASH has frequency
requirements for program
and erase operation.
See the Electricals
appendix.
Some of the modules inside the MCU have clock source choices. Figure 1-2 shows a simplified clock
connection diagram. The ICG supplies the clock sources:
•ICGOUT is an output of the ICG module. It is one of the following:
— The external crystal oscillator
— An external clock source
MC9S08AC16 Series Data Sheet, Rev. 0
22PRELIMINARYFreescale Semiconductor
Chapter 1 Introduction
— The output of the digitally-controlled oscillator (DCO) in the frequency-locked loop
sub-module
— Control bits inside the ICG determine which source is connected.
•FFE is a control signal generated inside the ICG. If the frequency of ICGOUT > 4 × the frequency
of ICGERCLK, this signal is a logic 1 and the fixed-frequency clock will be ICGERCLK/2.
Otherwise the fixed-frequency clock will be BUSCLK.
•ICGLCLK — Development tools can select this internal self-clocked source (~ 8 MHz) to speed
up BDC communications in systems where the bus clock is slow.
•ICGERCLK — External reference clock can be selected as the real-time interrupt clock source.
Can also be used as the ALTCLK input to the ADC module.
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY23
Chapter 1 Introduction
MC9S08AC16 Series Data Sheet, Rev. 0
24PRELIMINARYFreescale Semiconductor
Chapter 2
Pins and Connections
2.1Introduction
This chapter describes signals that connect to package pins. It includes a pinout diagram, a table of signal
properties, and detailed discussion of signals.
2.2Device Pin Assignment
Figure 2-1 shows the 48-pin QFN pin assignments for the MC9S08AC16 Series device.
REFH
REFL
BKGD/MS
V
40
39
V
38
PTG4/KB1IP4
37
PTG3/KBIP3
36
PTD3/KBIP6/AD1P11
35
PTD2/KBIP5/AD1P10
34
V
33
SSAD
V
32
DDAD
PTD1/AD1P9
31
PTD0/AD1P8
30
PTC4
IRQ/TPMCLK
RESET
PTF0/TPM1CH2
PTF1/TPM1CH3
PTF4/TPM2CH0
PTF5/TPM2CH1
1
2
3
4
5
6
7
PTC5/RxD2
PTC3/TxD2
47
48
PTC1/SDA1
PTC2/MCLK
46
45
SS
PTG6/EXTAL
V
PTC0/SCL1
44
43
42
48-Pin QFN
PTG5/XTAL
41
8
PTF6
PTE0/TxD1
PTE1/RxD1
PTE2/TPM1CH0
PTE3/TPM1CH1
9
10
11
12
14
15
16
17
18
19
20
21
13
PTE4/SS1
PTE6/MOSI1
PTE5/MISO1
SS
V
V
PTE7/SPSCK1
DD
PTG1/KBIP1
PTG0/KBIP0
22
PTA0
PTG2/KBIP2
23
PTA1
Figure 2-1. MC9S08AC16 Series in 48-Pin QFN Package
PTB3/AD1P3
29
PTB2/AD1P2
28
27
PTB1/TPM3CH1/AD1P1
PTB0/TPM3CH0/AD1P0
26
PTA7
25
24
PTA2
1
1
1
1. TPM3 not available on the S9S08AWxxA.
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY25
Chapter 2 Pins and Connections
Figure 2-2. shows the 44-pin LQFP pin assignments for the MC9S08AC16 Series device.
PTC4
IRQ/TPMCLK
RESET
PTF0/TPM1CH2
PTF1/TPM1CH3
PTF4/TPM2CH0
PTF5/TPM2CH1
PTE0/TxD1
PTE1/RxD1
PTE2/TPM1CH0
PTE3/TPM1CH1
11
1
PTC5/RxD2
44
2
3
4
5
6
7
8
9
10
12
PTE4/SS1
PTC3/TxD2
PTC2/MCLK
434241
14
13
PTE6/MOSI1
PTE5/MISO1
PTC0/SCL1
PTC1/SDA1
40
44-Pin LQFP
151617
SS
V
PTE7/SPSCK1
SS
V
39
DD
V
PTG6/EXTAL
37
38
18
PTG0/KBIP0
BKGD/MS
PTG5/XTAL
36
2021
PTG2/KBIP2
PTG1/KBIP1
REFL
V
35
PTA019PTA1
REFH
V
34
PTG3/KBIP3
33
32
PTD3/KBIP6/AD1P11
PTD2/KBIP5/AD1P10
31
V
30
29
28
27
26
25
24
22
SSAD
V
DDAD
PTD1/AD1P9
PTD0/AD1P8
PTB3/AD1P3
PTB2/AD1P2
PTB1/TPM3CH1/AD1P1
PTB0/TPM3CH0/AD1P0
23
1
1
Figure 2-2. MC9S08AC16 Series in 44-Pin LQFP Package
1
1. TPM3 not available on the S9S08AWxxA.
MC9S08AC16 Series Data Sheet, Rev. 0
26PRELIMINARYFreescale Semiconductor
Chapter 2 Pins and Connections
Figure 2-3. shows the 32-pin LQFP pin assignments for the MC9S08AC16 Series device.
IRQ/TPMCLK
RESET
PTF4/TPM2CH0
PTF5/TPM2CH1
PTE0/TxD1
PTE1/RxD1
PTE2/TPM1CH0
PTE3/TPM1CH1
Figure 2-3. MC9S08AC16 Series in 32-Pin LQFP Package
RESET, IRQChapter 5, “Resets, Interrupts, and System Configuration”
MC9S08AC16 Series Data Sheet, Rev. 0
Chapter 2 Pins and Connections
2.3Recommended System Connections
Figure 2-4 shows pin connections that are common to almost all MC9S08AC16 Series application
systems.
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY29
Chapter 2 Pins and Connections
SYSTEM
POWER
+
C
5 V
10 μF
NOTE 1
C1
BACKGROUND HEADER
V
DD
OPTIONAL
MANUAL
RESET
ASYNCHRONOUS
INTERRUPT
BLK
X1
INPUT
V
DD
+
R
F
PTG4/KBIP4
C
BY
0.1 μF
C2
V
DD
4.7 kΩ–10 kΩ
0.1 μF
PTG0/KBIP0
PTG1/KBIP1
PTG2/KBIP2
PTG3/KBIP3
PTG5/XTAL
PTG6/EXTAL
C
BYAD
0.1 μF
R
S
V
DD
4.7 kΩ–
10 kΩ
0.1 μF
V
REFH
V
DDAD
V
SSAD
V
REFL
V
DD
VSS(x2)
XTAL
NOTE 2
EXTAL
NOTE 2
PORT
G
MC9S08AC16
BKGD/MS
RESET
NOTE 3
TPMCLK/IRQ
NOTE 3
PORT
A
PORT
B
PORT
C
PORT
D
PORT
E
PORT
F
PTA0
PTA1
PTA2
PTA7
PTB0/AD1P0/TPM3CH0 NOTE 4
PTB1/AD1P1/TPM3CH1 NOTE 4
PTB2/AD1P2
PTB3/AD1P3
PTC0/SCL1
PTC1/SDA1
PTC2/MCLK
PTC3/TxD2
PTC4
PTC5/RxD2
I/O AND
PERIPHERAL
INTERFACE TO
APPLICATION
PTD0/AD1P8
SYSTEM
PTD1/AD1P9
PTD2/AD1P10/KBIP5
PTD3/AD1P11/KBIP6
PTE0/TxD1
PTE1/RxD1
PTE2/TPM1CH0
PTE3/TPM1CH1
PTE4/
SS1
PTE5/MISO1
PTE6/MOSI1
PTE7/SPSCK1
PTF0/TPM1CH2
PTF1/TPM1CH3
PTF4/TPM2CH0
PTF5/TPM2CH1
PTF6
NOTES:
1. Not required if using the internal clock option.
2. XTAL and EXTAL are PTG5 and PTG6 respectively.
3. RC filters on
RESET and IRQ are recommended for EMC-sensitive applications.
4. TPM3 is not available on S9S08AWxxA.
Figure 2-4. Basic System Connections
MC9S08AC16 Series Data Sheet, Rev. 0
30PRELIMINARYFreescale Semiconductor
Chapter 2 Pins and Connections
2.3.1Power (VDD, 2 x VSS, V
DDAD
, V
SSAD
)
VDD and VSS are the 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 regulated
lower-voltage source to the CPU and other internal circuitry of the MCU.
Typically, application systems have two separate capacitors across the power pins. In this case, there
should be a bulk electrolytic capacitor, such as a 10-μF tantalum capacitor, to provide bulkcharge storage
for the overall system and a 0.1-μF ceramic bypass capacitor located as near to the paired V
DD
and V
SS
power pins as practical to suppress high-frequency noise. The MC9S08AC16 has a second VSSpin. This
pin should be connected to the system ground plane or to the primary V
pin through a low-impedance
SS
connection.
V
DDAD
and V
are the analog power supply pins for the MCU. This voltage source supplies power to
SSAD
the ADC module. A 0.1-μF ceramic bypass capacitor should be located as near to the analog power pins
as practical to suppress high-frequency noise.
2.3.2Oscillator (XTAL, EXTAL)
Out of reset the MCU uses an internally generated clock (self-clocked mode — f
Self_reset
about 8-MHz crystal rate. This frequency source is used during reset startup and can be enabled as the
clock source for stop recovery to avoid the need for a long crystal startup delay. This MCU also contains
a trimmable internal clockgenerator(ICG)module that can be used to run the MCU. For more information
on the ICG, see the Chapter 8, “Internal Clock Generator (S08ICGV4).”
) equivalent to
The oscillator in this MCU is a Pierce oscillator that can accommodate a crystal or ceramic resonator in
either of two frequency ranges selected by the RANGE bit in the ICGC1 register. Rather than a crystal or
ceramic resonator, an external oscillator can be connected to the EXTAL input pin.
Refer to Figure 2-4 for the following discussion. R
(when used) and RF should be low-inductance
S
resistors such as carbon composition resistors. Wire-wound resistors, and some metal film resistors, have
too much inductance. C1 and C2 normally should be high-quality ceramic capacitors that are specifically
designed for high-frequency applications.
is used to provide a bias path to keep the EXTALinput in its linear range during crystal startup and its
R
F
valueis not generally critical. Typicalsystems use 1 MΩ to10 MΩ. Highervaluesare sensitiveto 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 take into account printed circuit board (PCB) capacitance and MCU pin
capacitance when sizing C1 and C2. The crystalmanufacturertypically specifies a load capacitance which
is the series combination of C1 and C2 which are usually 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.3RESET
RESET is a dedicated pin with a pullup devicebuilt in. It has input hysteresis, a high current output driver,
and no output slew rate control. Internal power-on reset and low-voltage reset circuitry typically make
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY31
Chapter 2 Pins and Connections
external reset circuitry unnecessary. This pin is normally connected to the standard 6-pin background
debugconnector so a developmentsystem can directly reset the MCU system. If desired, amanualexternal
reset can be added by supplying a simple switch to ground (pull reset pin low to force a reset).
Whenever any reset is initiated (whether from an external signal or from an internal system), the reset pin
is driven low for approximately 34 bus cycles. The reset circuitry decodes the cause of reset and records it
by setting a corresponding bit in the system control reset status register (SRS).
In EMC-sensitive applications, an external RC filter is recommended on the reset pin. See Figure 2-4 for
an example.
2.3.4Background/Mode Select (BKGD/MS)
While in reset, the BKGD/MS pin functions as a mode select pin. Immediately after reset rises the pin
functions asthebackground pin and can be used for background debugcommunication. While functioning
as a background/mode select pin, the pin includes an internal pullup device, input hysteresis, a standard
output driver, and no output slew rate control.
If nothing is connected to this pin, the MCU will enter normal operating mode at the rising edge of reset.
If a debug system is connected to the 6-pin standard background debug header, it can hold BKGD/MS low
during the rising edge of reset which forces the MCU to active background mode.
The BKGD pin is usedprimarily for background debug controller (BDC) communications using a custom
protocol that uses 16 clock cycles of the target MCU’s BDC clock per bit time. The target MCU’s BDC
clock could be as fast as the busclock rate, so there should never be any significant capacitance connected
to the BKGD/MS pin that could interfere with background serial communications.
Although the BKGD 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 almost no role in determining rise and fall
times on the BKGD pin.
2.3.5ADC Reference Pins (V
The V
REFH
and V
pins are the voltage reference high and voltage reference low inputs respectively
REFL
REFH
, V
REFL
)
for the ADC module.
2.3.6External Interrupt Pin (IRQ)
The IRQ pin is the input source for the IRQ interrupt and is also the input for the BIH and BIL instructions.
If the IRQ function is not enabled, this pin does not perform any function.
In EMC-sensitive applications, an external RC filter is recommended on the IRQ pin. See Figure 2-4 for
an example.
MC9S08AC16 Series Data Sheet, Rev. 0
32PRELIMINARYFreescale Semiconductor
Chapter 2 Pins and Connections
2.3.7General-Purpose I/O and Peripheral Ports
The remaining pins are shared among general-purpose I/O and on-chip peripheralfunctions suchas timers
and serial I/O systems. Immediately after reset, all of these pins are configured as high-impedance
general-purpose inputs with internal pullup devices disabled.
NOTE
To avoid extra current drain from floating input pins, the reset initialization
routine in the application program should either enable on-chip pullup
devices or change the direction of unused pins to outputs so the pins do not
float.
For information about controlling these pins as general-purpose I/O pins, see Chapter 6, “Parallel
Input/Output.” For information about howand whenon-chip peripheral systemsuse these pins,refer to the
appropriate chapter from Table 2-2.
When an on-chip peripheral system is controlling a pin, data direction control bits still determine what is
read from port data registers even though the peripheral module controls the pin direction by controlling
the enable for the pin’s output buffer. See the Chapter 6, “Parallel Input/Output” chapter for more details.
Pullup enable bits for each input pin control whether on-chip pullup devices are enabled wheneverthe pin
is acting as an input evenifit is being controlled by an on-chip peripheral module. When the PTD3, PTD2,
and PTG4 pins are controlled by the KBI module and are configured for rising-edge/high-level sensitivity,
the pullup enable control bits enable pulldown devices rather than pullup devices. Similarly, when IRQ is
configured as the IRQ input and is set to detect rising edges, the pullup enable control bit enables a
pulldown device rather than a pullup device.
NOTE
When an alternative function is first enabled it is possible to get a spurious
edge to the module, user software should clear out any associated flags
before interrupts are enabled. Table 2-1 illustrates the priority if multiple
modules are enabled. The highest priority module will have control over the
pin. Selecting a higher priority pin function with a lower priority function
already enabled can cause spurious edges to the lower priority module. It is
recommended that all modules that share a pin be disabled before enabling
another module.
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY33
Chapter 2 Pins and Connections
MC9S08AC16 Series Data Sheet, Rev. 0
34PRELIMINARYFreescale Semiconductor
Chapter 3
Modes of Operation
3.1Introduction
The operating modes of the MC9S08AC16 Series are described in this chapter. Entry into each mode, exit
from each mode, and functionality while in each of the modes are described.
3.2Features
•Active background mode for code development
•Wait mode:
— CPU shuts down to conserve power
— System clocks running
— Full voltage regulation maintained
•Stop modes:
— System clocks stopped; voltage regulator in standby
— Stop2 — Partial power down of internal circuits, RAM contents retained
— Stop3 — All internal circuits powered for fast recovery
3.3Run Mode
This is the normal operating mode for the MC9S08AC16 Series. This mode is selected when the
BKGD/MS pin is high at the rising edge of reset. In this mode, the CPU executes code from internal
memory with execution beginning at the address fetched from memory at 0xFFFE:0xFFFF after reset.
3.4Active Background Mode
The active background mode functions are managed through the background debug controller (BDC) in
the HCS08 core. The BDC, together with the on-chip debug module (DBG), provide the means for
analyzing MCU operation during software development.
Active background mode is entered in any of five ways:
•When the BKGD/MS pin is low at the rising edge of reset
•When a BACKGROUND command is received through the BKGD pin
•When a BGND instruction is executed
•When encountering a BDC breakpoint
•When encountering a DBG breakpoint
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY35
Chapter 3 Modes of Operation
After entering activebackground mode, the CPU is held in a suspended state waiting for serial background
commands rather than executing instructions from the user’s application program.
Background commands are of two types:
•Non-intrusive commands, defined as commands that can be issued while the user program is
running. Non-intrusive commands can be issued through the BKGD pin while the MCU is in run
mode; non-intrusive commands can also be executed when the MCU is in the active background
mode. Non-intrusive commands include:
•Activebackground commands, which can onlybeexecuted while the MCU isinactive background
mode. Active background commands include commands to:
— Read or write CPU registers
— Trace one user program instruction at a time
— Leave active background mode to return to the user’s application program (GO)
The activebackground mode is used to programa bootloader or user application program into the FLASH
program memory before the MCU is operated in run mode for the first time. When the MC9S08AC16
Series is shipped from the Freescale Semiconductor factory, the FLASH program memory is erased by
default unless specifically noted so there is no program that could be executed in run mode until the
FLASH memory is initially programmed. The active background mode can also be used to erase and
reprogram the FLASH memory after it has been previously programmed.
For additional information about the active background mode, refer to Chapter 15, “Development
Support.”
3.5Wait Mode
Wait mode is entered by executing a WAIT instruction. Upon execution of the WAIT instruction, the CPU
enters a low-power state in which it is not clocked. The I bit in CCR is cleared when the CPU enters the
wait mode, enabling interrupts. When an interrupt request occurs, the CPU exits the wait mode and
resumes processing, beginning with the stacking operations leading to the interrupt service routine.
While the MCU is in wait mode, there are some restrictions on which background debug commands can
be used. Only the BACKGROUND command and memory-access-with-status commands are available
when the MCU is in wait mode. The memory-access-with-status commands do not allowmemory access,
but they report an error indicating that the MCU is in either stop or wait mode. The BACKGROUND
command can be used to wake the MCU from wait mode and enter active background mode.
3.6Stop Modes
One of two stop modes is entered uponexecutionof a STOPinstruction when theSTOPEbit inthe system
option register is set. In both stop modes, all internal clocks are halted. If the STOPE bit is not set when
MC9S08AC16 Series Data Sheet, Rev. 0
36PRELIMINARYFreescale Semiconductor
Chapter 3 Modes of Operation
the CPU executes a STOP instruction, the MCU will not enter either of the stop modes and an illegal
opcode reset is forced. The stop modes are selected by setting the appropriate bits in SPMSC2.
HCS08 devices that are designed for low voltage operation (1.8V to 3.6V) also include stop1 mode. The
MC9S08AC16 Series family of devices does not include stop1 mode.
Table 3-1 summarizes the behavior of the MCU in each of the stop modes.
Table 3-1. Stop Mode Behavior
CPU, Digital
ModePPDC
Peripherals,
FLASH
RAMICGADCRegulatorI/O PinsRTI
Stop21OffStandbyOffDisabledStandbyStates
1
Stop30StandbyStandbyOff
1
Crystal oscillator can be configured to run in stop3. Please see the ICG registers.
Optionally onStandbyStates
held
held
Optionally on
Optionally on
3.6.1Stop2 Mode
The stop2 mode provides very low standby power consumption and maintains the contents of RAM and
the current state of all of the I/O pins. To enter stop2, the user must executea STOP instruction with stop2
selected (PPDC = 1) and stop mode enabled (STOPE = 1). In addition, the LVD must not be enabled to
operate in stop (LVDSE = LVDE = 1). If the LVD is enabled in stop, then the MCU enters stop3 upon the
execution of the STOP instruction regardless of the state of PPDC.
Before entering stop2 mode, the user must save the contents of the I/O port registers, as well as any other
memory-mapped registers which they want to restore after exit of stop2, to locations in RAM. Upon exit
of stop2, these values can be restored by user software before pin latches are opened.
WhentheMCU is in stop2 mode, allinternalcircuits that are poweredfrom the voltage regulatorare turned
off, except for the RAM. The voltage regulator is in a low-power standby state, as is the ADC. Upon entry
into stop2, the states of the I/O pins are latched. The states are held while in stop2 mode and after exiting
stop2 mode until a logic 1 is written to PPDACK in SPMSC2.
Exit from stop2 is done by asserting either of the wake-up pins:
RESET or IRQ/TPMCLK, or by an RTI
interrupt. IRQ/TPMCLK is always an active lowinput when the MCU is in stop2, regardless of how it was
configured before entering stop2.
Upon wake-up from stop2 mode, the MCU will start up as from a power-on reset (POR) except pin states
remain latched. The CPU will take the reset vector. The system and all peripherals will be in their default
reset states and must be initialized.
After waking up from stop2, the PPDF bit in SPMSC2 is set. This flag may be 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 logic 1 is
written to PPDACK in SPMSC2.
To maintain I/O state for pins that were configured as general-purpose I/O, the user must restore the
contents of the I/O port registers, which have been saved in RAM, to the port registers before writing to
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY37
Chapter 3 Modes of Operation
the PPDACK bit. If the port registers are not restored from RAM before writing to PPDACK, then the
register bits will assume their reset states when the I/O pin latches are opened and the I/O pins will switch
to their reset states.
For pins that were configured as peripheral I/O, the user must 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 will be controlled by their associated port control registers when the I/O
latches are opened.
3.6.2Stop3 Mode
To enter stop3, the user must execute a STOP instruction with stop3 selected (PPDC = 0) and stop mode
enabled (STOPE=1).Uponenteringthestop3 mode, all of the clocks in the MCU, including the oscillator
itself, are halted. The ICG enters its standby state, as does the voltage regulator and the ADC. The states
of all of the internal registers and logic, as well as the RAM content, are maintained. The I/O pin states are
not latched at the pin as in stop2. Instead they are maintained by virtue of the states of the internal logic
driving the pins being maintained.
Exit from stop3 is done by asserting
RESET or by an interrupt from one of the following sources: the
real-time interrupt (RTI), LVD system, ADC, IRQ, KBI, or SCI.
If stop3 is exited by means of the
RESET pin, then the MCU will be reset and operation will resume after
taking the reset vector. Exit by means of an asynchronous interrupt or the real-time interrupt will result in
the MCU taking the appropriate interrupt vector.
A separate self-clocked source (≈1 kHz) for the real-time interrupt allows a wakeup from stop2 or stop3
mode with no external components. When RTIS2:RTIS1:RTIS0 = 0:0:0, the real-time interrupt function
and this 1-kHz source are disabled. Power consumption is lowerwhen the 1-kHz source is disabled, but in
that case the real-time interrupt cannot wake the MCU from stop.
3.6.3Active BDM Enabled in Stop Mode
Entry into the active background mode from run mode is enabled if the ENBDM bit in BDCSCR is set.
This register is described in Chapter 15, “Development Support” of this data sheet. If ENBDMis set when
theCPUexecutes aSTOPinstruction, the system clocksto the background debuglogic remain activewhen
the MCU enters stop mode so background debug communication is still possible. In addition, the voltage
regulator does not enter its low-power standby state but maintains full internal regulation. If the user
attempts to enter stop2 with ENBDM set, the MCU will instead enter stop3.
Most background commands are not available in stop mode. The memory-access-with-status commands
do not allow memory access, but they report an error indicating that the MCU is in either stop or wait
mode. The BACKGROUND command can be used to wake the MCU from stop and enter active
background mode if the ENBDM bit is set. After entering background debug mode, all background
commands are available. Table 3-2 summarizes the behavior of the MCU in stop when entry into the
background debug mode is enabled.
The LVD system is capable of generating eitheraninterrupt or a reset when the supply voltagedrops below
the LVD voltage. If the LVD is enabled in stop by setting the LVDE and the LVDSE bits, then the voltage
regulator remains active during stop mode. If the user attempts to enter stop2 with the LVD enabled for
stop, the MCU will instead enter stop3. Table 3-3 summarizes the behavior of the MCU in stop when the
LVD is enabled.
Table 3-3. LVD Enabled Stop Mode Behavior
CPU, Digital
ModePPDC
Stop30StandbyStandbyOffOptionally onActiveStates
Peripherals,
FLASH
RAMICGADCRegulatorI/O PinsRTI
Optionally on
held
3.6.5On-Chip Peripheral Modules in Stop Modes
When the MCU enters any stop mode, system clocks to the internal peripheral modules are stopped. Even
in the exceptioncase (ENBDM = 1), where clocks are kept alive to the background debug logic, clocks to
the peripheral systems are halted to reduce power consumption. Refer to Section 3.6.2, “Stop3 Mode” for
specific information on system behavior in stop modes.
I/O Pins
•All I/O pin states remain unchanged when the MCU enters stop3 mode.
•If the MCU is configured to go into stop2 mode, all I/O pins statesare latched before entering stop.
Memory
•All RAM and register contents are preserved while the MCU is in stop3 mode.
•All registers will be reset upon wake-up from stop2, but the contents of RAM are preserved and
pin states remain latched until the PPDACKbit is written. Theusermay saveany memory-mapped
register data into RAM before entering stop2 and restore the data upon exit from stop2.
•The contents of the FLASH memory are non-volatile and are preserved in any of the stop modes.
ICG — In stop3 mode, the ICG enters its low-power standby state. The oscillator may be kept running
when the ICG is in standby by setting OSCSTEN. In stop2 mode, the ICG is turned off. The oscillator
cannot be kept running in stop2 evenif OSCSTEN is set. If the MCU is configured to go into stop2 mode,
the ICG will be reset upon wake-up from stop and must be reinitialized.
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY39
Chapter 3 Modes of Operation
TPM — When the MCU enters stop mode, the clock to the TPM1 and TPM2 modules stop. The modules
halt operation. If the MCU is configured to go into stop2 mode, the TPM modules will be reset upon
wake-up from stop and must be reinitialized.
ADC — When the MCU enters stop mode, the ADC will enter a low-power standby state unless the
asynchronous clock source, ADACK, is enabled. Conversions can occur in stop3 if ADACK is enabled. If
the MCU is configured to go into stop2 mode, the ADC will be reset upon wake-up from stop and must be
re-initialized.
KBI — During stop3, the KBI pins that are enabled continue to function as interrupt sources that are
capable of waking the MCU from stop3. The KBI is disabled in stop2 and must be reinitialized after
waking up.
SCI — When the MCU enters stop mode, the clocks to the SCI1 and SCI2 modules stop. The modules
halt operation. If the MCU is configured to go into stop2 mode, the SCI modules will be reset upon
wake-up from stop and must be reinitialized.
SPI — When the MCU enters stop mode, the clocks to the SPI module stop. The module halts operation.
If the MCU is configured to go into stop2 mode, the SPI module will be reset upon wake-upfrom stop and
must be reinitialized.
IIC — When the MCU enters stop mode, the clocks to the IIC module stops. The module halts operation.
If the MCU is configured to go into stop2 mode, the IIC module will be reset upon wake-upfrom stop and
must be reinitialized.
Voltage Regulator — The voltage regulator enters a low-powerstandby state when the MCU enterseither
of the stop modes unless the LVD is enabled in stop mode or BDM is enabled.
MC9S08AC16 Series Data Sheet, Rev. 0
40PRELIMINARYFreescale Semiconductor
Chapter 4
Memory
4.1MC9S08AC16 Series Memory Map
Figure 4-1 shows the memory maps for the MC9S08AC16 Series MCUs. On-chip memory in the
MC9S08AC16 Series of MCU consists of RAM, FLASH program memory for nonvolatile data storage,
plus I/O and control/status registers. The registers are divided into three groups:
•Direct-page registers (0x0000 through 0x006F)
•High-page registers (0x1800 through 0x185F)
•Nonvolatile registers (0xFFB0 through 0xFFBF)
0x0000
0x006F
0x0070
0x046F
0x0470
0x17FF
0x1800
0x185F
0x1860
0xBFFF
0xC000
0xFFFF
DIRECT PAGE REGISTERS
RAM
1024 BYTES
UNIMPLEMENTED
5008 BYTES
HIGH PAGE REGISTERS
UNIMPLEMENTED
42,912 BYTES
FLASH
16,384 BYTES
MC9S08AC16 and S9S08AW16A
0x0000
0x006F
0x0070
0x036F
0x0370
0x046F
0x0470
0x17FF
0x1800
0x185F
0x1860
0xBFFF
0xC000
0xDFFF
0xE000
0xFFFF
DIRECT PAGE REGISTERS
RAM
768 BYTES
RESERVED — 256 BYTES
UNIMPLEMENTED
5008 BYTES
HIGH PAGE REGISTERS
UNIMPLEMENTED
42,912 BYTES
RESERVED
8192 BYTES
FLASH
8192 BYTES
MC9S08AC8 and S9S08AW8A
Figure 4-1. MC9S08AC16 Series Memory Maps
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY41
Chapter 4 Memory
4.1.1Reset and Interrupt Vector Assignments
Figure 4-1shows address assignments for reset and interrupt vectors. The vectornames shown in this table
are the labels used in the Freescale-provided equate file for the MC9S08AC16 Series. For more details
about resets, interrupts, interrupt priority, and local interrupt mask controls, refer to Chapter 5, “Resets,
Interrupts, and System Configuration.”
Table 4-1. Reset and Interrupt Vectors
Address (High/Low)VectorVector Name
0xFFC0:FFC1 through 0xFFC4:FFC5Unused Vector Space
The registers in the MC9S08AC16 Series are divided into these three groups:
•Direct-page registers are located in the first 112 locations in the memory map, so they are
accessible with efficient direct addressing mode instructions.
•High-page registers are used much less often, so they are located above 0x1800 in the memory
map. This leaves more room in the direct page for more frequently used registers and variables.
•The nonvolatile register area consists of a block of 16 locations in FLASH memory at
0xFFB0–0xFFBF.
Nonvolatile register locations include:
— Three values which are loaded into working registers at reset
— An 8-byte backdoor comparison key which optionally allows a user to gain controlled access
to secure memory
Because the nonvolatile register locations are FLASH memory, they must be erased and
programmed like other FLASH memory locations.
Direct-page registers can be accessed with efficient direct addressing mode instructions. Bit manipulation
instructions can be used to access any bit in any direct-page register. Table 4-2 is a summary of all
user-accessible direct-page registers and control bits.
The direct page registers in Table 4-2 can use the more efficient direct addressing mode which only
requires the lower byte of the address. Because of this, the lower byte of the address in column one is
shown in bold text. In Table 4-3 and Table 4-4 the whole address in column one is shown in bold. In
Table 4-2, Table 4-3, and Table 4-4, the register names in column two are shown in bold to set them apart
from the bit names to the right. Cells that are not associated with named bits are shaded. A shaded cell with
a 0 indicates this unused bit always reads as a 0. Shaded cells with dashes indicate unused or reserved bit
locations that could read as 1s or 0s.
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY43
Chapter 4 Memory
Table 4-2. Direct-Page Register Summary (Sheet 1 of 3)
Table 4-2. Direct-Page Register Summary (Sheet 3 of 3)
AddressRegister NameBit 7654321Bit 0
0x0055SPI1DL
0x0056SPI1MH
0x0057SPI1ML
0x0058IIC1A
0x0059IIC1F
0x005AIIC1C
0x005BIIC1S
0x005CIIC1D
0x005DIIC1C2
0x005E–
0x005F
Reserved
0x0060TPM2SC
0x0061TPM2CNTH
0x0062TPM2CNTL
0x0063TPM2MODH
0x0064TPM2MODL
0x0065TPM2C0SC
0x0066TPM2C0VH
0x0067TPM2C0VL
0x0068TPM2C1SC
0x0069TPM2C1VH
0x006ATPM2C1VL
0x006B–
0x006F
Reserved
Bit 7654321Bit 0
Bit 1514131211108Bit 8
Bit 7654321Bit 0
AD7AD6AD5AD4AD3AD2AD10
MULTICR
IICENIICIEMSTTXTXAKRSTA00
TCFIAASBUSYARBL0SRWIICIFRXAK
DA TA
GCAENADEXT000AD10AD9AD8
—
—
TOFTOIECPWMSCLKSBCLKSAPS2PS1PS0
Bit 1514131211109Bit 8
Bit 7654321Bit 0
Bit 1514131211109Bit 8
Bit 7654321Bit 0
CH0FCH0IEMS0BMS0AELS0BELS0A00
Bit 1514131211109Bit 8
Bit 7654321Bit 0
CH1FCH1IEMS1BMS1AELS1BELS1A00
Bit 1514131211109Bit 8
Bit 7654321Bit 0
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
High-page registers, shown in Table 4-3, 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.
Table 4-3. High-Page Register Summary (Sheet 1 of 3)
AddressRegister NameBit 7654321Bit 0
0x1800SRS
0x1801SBDFR
0x1802SOPT
0x1803SMCLK
0x1804 –
0x1805
Reserved
0x1806SDIDH
0x1807SDIDL
0x1808SRTISC
0x1809SPMSC1
0x180ASPMSC2
46PRELIMINARYFreescale Semiconductor
PORPINCOPILOPILADICGLVD0
0000000BDFR
COPECOPTSTOPE—00——
000MPE0MCSEL
—
—
REV3REV2REV1REV0ID11ID10ID9ID8
ID7ID6ID5ID4ID3ID2ID1ID0
RTIFRTIACKRTICLKSRTIE0RTIS2RTIS1RTIS0
LVDFLVDACKLVDIELVDRELVDSELVDE0
LVWFLVWACKLVDVLVWVPPDFPPDACK—PPDC
—
—
MC9S08AC16 Series Data Sheet, Rev. 0
—
—
—
—
—
—
—
—
—
—
—
—
1
BGBE
Chapter 4 Memory
Table 4-3. High-Page Register Summary (Sheet 2 of 3)
AddressRegister NameBit 7654321Bit 0
0x180BReserved
0x180CSOPT2
0x180D–
0x180F
Reserved
0x1810DBGCAH
0x1811DBGCAL
0x1812DBGCBH
0x1813DBGCBL
0x1814DBGFH
0x1815DBGFL
0x1816DBGC
0x1817DBGT
0x1818DBGS
0x1819–
0x181F
Reserved
0x1820FCDIV
0x1821FOPT
0x1822Reserved
0x1823FCNFG
0x1824FPROT
0x1825FSTAT
0x1826FCMD
0x1827–
0x182F
0x1830TPM3SC
Reserved
2
0x1831TPM3CNTH
0x1832TPM3CNTL
0x1833TPM3MODH
0x1834TPM3MODL
0x1835TPM3C0SC
0x1836TPM3C0VH
0x1837TPM3C0VL
0x1838TPM3C1SC
0x1839TPM3C1VH
0x183ATPM3C1VL
0x183B
0x183F
Reserved
0x1840PTAPE
0x1841PTASE
0x1842PTADS
2
2
2
2
2
2
2
2
2
2
————————
COPCLKS———————
—
—
Bit 1514131211109Bit 8
Bit 7654321Bit 0
Bit 1514131211109Bit 8
Bit 7654321Bit 0
Bit 1514131211109Bit 8
Bit 7654321Bit 0
DBGENARMTAGBRKENRWARWAENRWBRWBEN
TRGSELBEGIN00TRG3TRG2TRG1TRG0
AFBFARMF0CNT3CNT2CNT1CNT0
—
—
DIVLDPRDIV8DIV5DIV4DIV3DIV2DIV1DIV0
KEYENFNORED0000SEC01SEC00
————————
00KEYACC00000
FPS7FPS6FPS5FPS4FPS3FPS2FPS1FPDIS
FCBEFFCCFFPVIOLFACCERR0FBLANK00
FCMD7FCMD6FCMD5FCMD4FCMD3FCMD2FCMD1FCMD0
—
—
TOFTOIECPWMSCLKSBCLKSAPS2PS1PS0
Bit 1514131211109Bit 8
Bit 7654321Bit 0
Bit 1514131211109Bit 8
Bit 7654321Bit 0
CH0FCH0IEMS0BMS0AELS0BELS0A00
Bit 1514131211109Bit 8
Bit 7654321Bit 0
CH1FCH1IEMS1BMS1AELS1BELS1A00
Bit 1514131211109Bit 8
Nonvolatile FLASH registers, shown in Table 4-4, are located in the FLASH memory. These registers
include an 8-byte backdoor key which optionally can be used to gain access to secure memory resources.
During reset events, the contents of NVPROT and NVOPT in the nonvolatile register area of the FLASH
memory are transferred into corresponding FPROTand FOPT working registers in the high-page registers
to control security and block protection options.
MC9S08AC16 Series Data Sheet, Rev. 0
48PRELIMINARYFreescale Semiconductor
Chapter 4 Memory
Table 4-4. Nonvolatile Register Summary
AddressRegister NameBit 7654321Bit 0
0xFFB0 –
0xFFB7
0xFFB8 –
0xFFBC
0xFFBDNVPROT
0xFFBEReserved
0xFFBFNVOPT
1
This location can be used to store the factory trim value for the ICG.
NVBACKKEY
Reserved
1
8-Byte Comparison Key
—
—
FPS7FPS6FPS5FPS4FPS3FPS2FPS1FPDIS
————————
KEYENFNORED0000SEC01SEC00
—
—
—
—
—
—
—
—
—
—
—
—
—
—
Provided the key enable (KEYEN) bit is 1, the 8-byte comparison key can be used to temporarily
disengagememory security.This keymechanismcan be accessed only throughuser 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 waytodisengagesecurity is by mass erasing the FLASH if needed (normally through the background
debuginterface)and verifyingthat FLASH is blank. Toavoid returning to secure mode after the next reset,
program the security bits (SEC01:SEC00) to the unsecured state (1:0).
4.3RAM
The MC9S08AC16 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.
The RAM retains data when the MCU is in low-power wait, stop2, or stop3 mode. 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.
For compatibility with older M68HC05 MCUs, the HCS08 resets the stack pointer to 0x00FF. In the
MC9S08AC16Series, it is usually best to re-initialize the stack pointer to the top of the RAM so thedirect
page RAM can be used for frequently accessed RAM variables and bit-addressable program variables.
Include thefollowing2-instruction sequence in your reset initializationroutine(whereRamLast is equated
to the highest address of the RAM in the Freescale-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
BDM or through code executing from non-secure memory. See Section 4.5, “Security” for a detailed
description of the security feature.
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY49
Chapter 4 Memory
4.4FLASH
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-controlledcommunication paths.Fora 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.
4.4.1Features
Features of the FLASH memory include:
•FLASH Size
— MC9S08AC16 and S9S08AW16A— 16,384 bytes (32 pages of 512 bytes each)
— MC9S08AC8 and S9S08AW8A— 8192 bytes (16 pages of 512 bytes each)
•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
4.4.2Program and Erase Times
Before any program or erase command can be accepted, the FLASH clock dividerregister (FCDIV) must
be written to set the internal clock for the FLASH module to a frequency (f
200 kHz(see Section 4.6.1, “FLASH Clock Divider Register (FCDIV)”). This register can be written only
once, so normally this write is done during reset initialization. FCDIV cannot be written if the access error
flag, FACCERR in FSTAT, is set. The user must ensure that FACCERR is not set before writing to the
FCDIV register. One period of the resulting clock (1/f
) is used by the command processor to time
FCLK
program and erase pulses. An integer number of these timing pulses are used by the command processor
to complete a program or erase command.
Table 4-5 shows program and erase times. The bus clock frequency and FCDIV determine the frequency
of FCLK (f
). The time for one cycle of FCLK is t
FCLK
of cycles of FCLK and as an absolute time for the case where t
FCLK
= 1/f
FCLK
. The times are shown as a number
FCLK
=5μs. Program and erase times
shown include overhead for the command state machine and enabling and disabling of program and erase
voltages.
) between 150 kHz and
FCLK
MC9S08AC16 Series Data Sheet, Rev. 0
50PRELIMINARYFreescale Semiconductor
Chapter 4 Memory
Table 4-5. Program and Erase Times
ParameterCycles of FCLKTime if FCLK = 200 kHz
Byte program945 μs
Byte program (burst)420 μs
Page erase400020 ms
Mass erase20,000100 ms
1
Excluding start/end overhead
1
4.4.3Program and Erase Command Execution
The steps for executing any of the commands are listed below.The FCDIV registermust be initialized and
any error flags cleared before beginning command execution. The command execution steps are:
1. Write a data value to an address in the FLASH array. The address and data information from this
write is latched into the FLASH interface. This write is a required first step in any command
sequence. For erase and blank check commands, the value of the data is not important. For page
erase commands, the address may be any address in the 512-byte page of FLASH to be erased.For
mass erase and blank check commands, the address can be any address in the FLASH memory.
Whole pages of 512 bytesare the smallest block of FLASH that may be erased. In the 60K version,
there are two instances where the sizeof a block that is accessible to theuser is less than 512 bytes:
the first page followingRAM, and the first page following the high page registers. These pages are
overlapped by the RAM and high page registers respectively.
NOTE
Do not program any byte in the FLASH more than once after a successful
erase operation. Reprogramming bits to a byte which is already
programmed is not allowed without first erasing the page in which the byte
resides or mass erasing the entire FLASH memory. Programming without
first erasing may disturb data stored in the FLASH.
2. Write the command code for the desired command to FCMD. The five valid commands are blank
check (0x05), byte program (0x20), burst program (0x25), page erase (0x40), and mass erase
(0x41). The command code is latched into the command buffer.
3. Write a 1 to the FCBEF bit in FSTAT to clear FCBEF and launch the command (including its
address and data information).
A partial command sequence can be aborted manually by writing a 0 to FCBEF any time after the write to
the memory array and before writing the 1 that clears FCBEF and launches the complete command.
Aborting a command in this way sets the FACCERR access error flag which must be cleared before
starting a new command.
A strictly monitored procedure must be obeyed or the command will not be accepted. This minimizes the
possibility of any unintended changes to the FLASH memory contents. The command complete flag
(FCCF) indicates when a command is complete. The command sequence must be completed by clearing
FCBEF to launch the command. Figure 4-2 is a flowchart for executing all of the commands except for
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY51
Chapter 4 Memory
burst programming. The FCDIV register must be initialized before using any FLASH commands. This
only must be done once following a reset.
FLASH PROGRAM AND
ERASE FLOW
WRITE TO FCDIV
FACCERR ?
CLEAR ERROR
WRITE TO FLASH
TO BUFFER ADDRESS AND DATA
WRITE COMMAND TO FCMD
WRITE 1 TO FCBEF
TO LAUNCH COMMAND
AND CLEAR FCBEF (Note 2)
FPVIOL OR
FACCERR ?
(Note 1)
START
1
NO
Note 1: Required only once after reset.
0
Note 2: Wait at least four bus cycles
before checking FCBEF or FCCF.
YES
ERROR EXIT
0
FCCF ?
1
DONE
Figure 4-2. FLASH Program and Erase Flowchart
4.4.4Burst Program Execution
The burst program command is used to program sequential bytes of data in less time than would be
required using the standard program command. This is possible because the high voltage to the FLASH
array does not need to be disabled between program operations. Ordinarily, when a program or erase
command is issued, an internal charge pump associated with the FLASH memory must be enabled to
supply high voltage to the array. Upon completion of the command, the charge pump is turned off. When
a burstprogram command is issued, the chargepump is enabled and then remains enabled after completion
of the burst program operation if these two conditions are met:
•The next burst program command has been queued before the current program operation has
completed.
MC9S08AC16 Series Data Sheet, Rev. 0
52PRELIMINARYFreescale Semiconductor
Chapter 4 Memory
•The next sequential address selects a byte on the same physical row as the current byte being
programmed. A row of FLASH memory consists of 64 bytes. A byte within a row is selected by
addresses A5 through A0. A new row begins when addresses A5 through A0 are all zero.
The first byte of a series of sequential bytes being programmed in burst mode will take the same amount
of time to program as a byte programmed in standard mode. Subsequent bytes will program in the burst
program time provided that the conditions above are met. In the case the next sequential address is the
beginning of a new row, the program time for that byte will be 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 will be
disabled and high voltage removed from the array.
FLASH BURST
PROGRAM FLOW
WRITE TO FCDIV
FACCERR ?
CLEAR ERROR
FCBEF ?
WRITE TO FLASH
TO BUFFER ADDRESS AND DATA
WRITE COMMAND (0x25) TO FCMD
WRITE 1 TO FCBEF
TO LAUNCH COMMAND
AND CLEAR FCBEF (Note 2)
(Note 1)
START
1
1
Note 1: Required only once after reset.
0
0
Note 2: Wait at least four bus cycles before
checking FCBEF or FCCF.
FPVIO OR
FACCERR ?
YES
NEW BURST COMMAND ?
0
NO
NO
FCCF ?
1
DONE
YES
ERROR EXIT
Figure 4-3. FLASH Burst Program Flowchart
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY53
Chapter 4 Memory
4.4.5Access Errors
An access error occurs whenever the command execution protocol is violated.
Any of the following specific actions will cause the access error flag (FACCERR) in FSTAT to be set.
FACCERRmust be cleared by writing a 1 to FACCERR in FSTAT before any command can be processed.
•Writing to a FLASH address before the internal FLASH clock frequency has been set by writing
to the FCDIV register
•Writing to a FLASH address while FCBEF is not set (A new command cannot be started until the
command buffer is empty.)
•Writing a second time to a FLASH address before launching the previous command (There is only
one write to FLASH for every command.)
•Writing a second time to FCMD before launching the previous command (There is only one write
to FCMD for every command.)
•Writing to any FLASH control register other than FCMD after writing to a FLASH address
•Writing any command code other than the five allowed codes (0x05, 0x20, 0x25, 0x40, or 0x41)
to FCMD
•Writing any FLASH control register other than the write to FSTAT (to clearFCBEF andlaunch the
command) after writing the command to FCMD.
•The MCU enters stop mode while a program or erase command is in progress (The command is
aborted.)
•Writing the byte program, burstprogram, or page erase command code (0x20, 0x25, or 0x40) with
a background debug command while the MCU is secured (The background debug controller can
only do blank check and mass erase commands when the MCU is secure.)
•Writing 0 to FCBEF to cancel a partial command
4.4.6FLASH Block Protection
The block protection feature prevents the protected region of FLASH from program or erase changes.
Block protection is controlled through the FLASH protection register (FPROT). When enabled, block
protection begins at any 512 byte boundary below the last address of FLASH, 0xFFFF. (See Section 4.6.4,
“FLASH Protection Register (FPROT and NVPROT)”).
After exit from reset, FPROT is loaded with the contents of the NVPROT location, which is in the
nonvolatile register block of the FLASH memory. FPROT cannot be changed directly from application
software so a runawayprogram cannot alter the block protection settings. Because NVPROTis within the
last 512 bytes of FLASH, if any amount of memory is protected, NVPROT is itself protected and cannot
be altered (intentionally or unintentionally) by the application software. FPROT can be written through
background debug commands, which allows a way to erase and reprogram a protected FLASH memory.
The block protection mechanism is illustrated in Figure 4-4. The FPS bits are used as the upper bits of the
last address of unprotected memory. This address is formedby concatenating FPS7:FPS1 with logic 1 bits
as shown. Forexample,to protectthe last1536 bytes of memory (addresses 0xFA00through 0xFFFF), the
FPS bits must be set to 1111 100, which results in the value 0xF9FF as the last address of unprotected
memory. Inadditionto programming the FPS bitstothe appropriate value,FPDIS(bit 0 of NVPROT) must
MC9S08AC16 Series Data Sheet, Rev. 0
54PRELIMINARYFreescale Semiconductor
Chapter 4 Memory
be programmed to logic 0 to enable block protection. Therefore the value 0xF8 must be programmed into
NVPROT to protect addresses 0xFA00 through 0xFFFF.
FPS7 FPS6 FPS5 FPS4 FPS3 FPS2 FPS1
A15A14A13A12A11A10A9A81A7 A6 A5 A4 A3 A2 A1 A0
Figure 4-4. Block Protection Mechanism
11111111
One use for block protection is to block protect an area ofFLASH 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.4.7Vector Redirection
Whenever any block protection is enabled, the reset and interrupt vectors will be protected. Vector
redirection allows users to modify interrupt vector information without unprotecting bootloader and reset
vector space. Vector redirection is enabled by programming the FNORED bit in the NVOPT register
located at address 0xFFBF to zero. For redirection to occur, at least some portion but not all of the FLASH
memory must be block protected by programming the NVPROT register located at address 0xFFBD. All
of the interrupt vectors (memory locations 0xFFC0–0xFFFD) are redirected, though the reset vector
(0xFFFE:FFFF) is not.
For example, if 512 bytes of FLASH are protected, the protected address region is from 0xFE00 through
0xFFFF.Theinterrupt vectors (0xFFC0–0xFFFD) are redirected to the locations0xFDC0–0xFDFD.Now,
if an SPI interrupt is taken for instance, the values in the locations 0xFDE0:FDE1 are used for the vector
instead of the values in the locations 0xFFE0:FFE1. This allows the user to reprogram the unprotected
portion of the FLASH with new program code including new interrupt vector values while leaving the
protected area, which includes the default vector locations, unchanged.
4.5Security
The MC9S08AC16Series includes circuitry to preventunauthorized 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 andreads 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 NVOPTare copied from FLASH
into the working FOPT register in high-page register space. A user engages security by programming the
NVOPT location which can be done 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
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY55
Chapter 4 Memory
the MCU secure. During development, whenever the FLASH is erased, it is good practice to immediately
program the SEC00 bit to 0 in NVOPT so SEC01:SEC00 = 1:0. This would allow 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, but the MCU cannot enter active
background mode except by holding BKGD/MS low at the rising edge of reset.
A user 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 should 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
will be disengaged until the next reset.
The security keycan 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.
MC9S08AC16 Series Data Sheet, Rev. 0
56PRELIMINARYFreescale Semiconductor
Chapter 4 Memory
4.6FLASH Registers and Control Bits
The FLASH module has nine 8-bit registers in the high-page register space, three locations in the
nonvolatile register spaceinFLASHmemorywhichare copied into three corresponding high-page control
registers at reset. There is also an 8-byte comparison key in FLASH memory. Refer to Table 4-3 and
Table 4-4 forthe absolute address assignments for all FLASH registers. This section refers to registersand
control bits only by their names. A Freescale-provided equate or header file normally is used to translate
these names into the appropriate absolute addresses.
4.6.1FLASH Clock Divider Register (FCDIV)
Bit 7 of this register is a read-only status flag. Bits 6 through 0 may be read at any time but can be written
only one time. Before any erase or programming operations are possible, write to this register to set the
frequency of the clock for the nonvolatile memory system within acceptable limits.
76543210
RDIVLD
W
Reset00000000
PRDIV8DIV5DIV4DIV3DIV2DIV1DIV0
= Unimplemented or Reserved
Figure 4-5. FLASH Clock Divider Register (FCDIV)
Table 4-6. FCDIV Register Field Descriptions
FieldDescription
7
DIVLD
6
PRDIV8
5:0
DIV[5:0]
Divisor Loaded Status Flag — When set, this read-only status flag indicates that the FCDIV register has been
written since reset. Reset clears this bitand the first write to this register causesthis bit to become setregardless
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.
Prescale (Divide) FLASH Clock by 8
0 Clock input to the FLASH clock divider is the bus rate clock.
1 Clock input to the FLASH clock divider is the bus rate clock divided by 8.
Divisor for FLASH Clock Divider — The FLASH clock divider divides the bus rate clock (or the bus rate clock
divided by 8 if PRDIV8 = 1) by the value in the 6-bit DIV5:DIV0 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/Erasetiming pulses are one cycle of this internal FLASH clock which corresponds to a range of 5 μsto
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, Equation 4-2, and Table 4-6.
if PRDIV8 = 0 — f
if PRDIV8 = 1 — f
FCLK
FCLK
= f
= f
÷ ([DIV5:DIV0] + 1)Eqn. 4-1
Bus
÷ (8 × ([DIV5:DIV0] + 1))Eqn. 4-2
Bus
Table 4-7 shows the appropriate values for PRDIV8 and DIV5:DIV0 for selected bus frequencies.
During reset, the contents of the nonvolatile location NVOPT are copied from FLASH into FOPT. Bits 5
through 2arenot used and always read 0. Thisregistermay be read at anytime,butwrites haveno meaning
or effect.Tochange the valuein this register,eraseand reprogram the NVOPT locationinFLASH memory
as usual and then issue a new MCU reset.
76543210
RKEYENFNORED0000SEC01SEC00
W
ResetThis register is loaded from nonvolatile location NVOPT during reset.
= Unimplemented or Reserved
Figure 4-6. FLASH Options Register (FOPT)
Table 4-8. FOPT Register Field Descriptions
FieldDescription
7
KEYEN
6
FNORED
1:0
SEC0[1:0]
Backdoor Key Mechanism Enable — When this bit is 0, the backdoor key mechanism cannot be used to
disengage security. The backdoor key mechanism is accessible only from user (secured) firmware. BDM
commandscannot beused towrite keycomparison values thatwould unlock thebackdoor key.For more detailed
information about the backdoor key mechanism, refer to Section 4.5, “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.
Vector Redirection Disable — When this bit is 1, then vector redirection is disabled.
0 Vector redirection enabled.
1 Vector redirection disabled.
Security State Code — This 2-bit field determines the security state of the MCU as shown in Table 4-9. When
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. For more detailed information about security, refer
to Section 4.5, “Security.”
MC9S08AC16 Series Data Sheet, Rev. 0
58PRELIMINARYFreescale Semiconductor
Chapter 4 Memory
Table 4-9. Security States
SEC01:SEC00Description
0:0secure
0:1secure
1:0unsecured
1:1secure
SEC01:SEC00 changes to 1:0 after successful backdoor key entry or a successful blank check of FLASH.
4.6.3FLASH Configuration Register (FCNFG)
Bits 7 through 5 may be read or written at any time. Bits 4 through 0 always read 0 and cannot be written.
76543210
R00
KEYACC
W
Reset00000000
= Unimplemented or Reserved
00000
Figure 4-7. FLASH Configuration Register (FCNFG)
Table 4-10. FCNFG Register Field Descriptions
FieldDescription
5
KEYACC
Enable Writing of Access Key — This bit enables writing of the backdoor comparison key. For more detailed
information about the backdoor key mechanism, refer to Section 4.5, “Security.”
0 Writes to 0xFFB0–0xFFB7 are interpreted as the start of a FLASH programming or erase command.
1 Writes to NVBACKKEY (0xFFB0–0xFFB7) are interpreted as comparison key writes.
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY59
Chapter 4 Memory
4.6.4FLASH Protection Register (FPROT and NVPROT)
During reset, the contents of the nonvolatilelocation NVPROTare copied from FLASH into FPROT. This
register can be read at any time. If FPDIS = 0, protection can be increased, i.e., a smaller value of FPS can
be written. If FPDIS = 1, writes do not change protection.
76543210
R
W
ResetThis register is loaded from nonvolatile location NVPROT during reset.
1
Background commands can be used to change the contents of these bits in FPROT.
Figure 4-8. FLASH Protection Register (FPROT)
Table 4-11. FPROT Register Field Descriptions
FieldDescription
FPS
(1)
FPDIS
(1)
7:1
FPS[7:1]
0
FPDIS
FLASH Protect Select Bits — When FPDIS = 0, this 7-bit field determines the ending address of unprotected
FLASH locations at the high address end of the FLASH. Protected FLASH locations cannot be erased or
programmed.
FLASH Protection Disable
0 FLASH block specified by FPS[7:1] is block protected (program and erase not allowed).
1 No FLASH block is protected.
4.6.5FLASH Status Register (FSTAT)
Bits 3, 1, and 0 always read 0 and writes have no meaning or effect. The remaining five bits are status bits
that can be read at any time. Writes to these bits have special meanings that are discussed in the bit
descriptions.
76543210
R
FCBEF
W
Reset11000000
FCCF
FPVIOLFACCERR
= Unimplemented or Reserved
Figure 4-9. FLASH Status Register (FSTAT)
0FBLANK00
MC9S08AC16 Series Data Sheet, Rev. 0
60PRELIMINARYFreescale Semiconductor
Table 4-12. FSTAT Register Field Descriptions
FieldDescription
Chapter 4 Memory
7
FCBEF
6
FCCF
5
FPVIOL
4
FACCERR
2
FBLANK
FLASH Command Buffer Empty Flag — The FCBEF bit is used to launch commands. It also indicates that the
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 one 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 may be written to the command buffer.
FLASH Command Complete Flag — FCCF is set automatically when the command buffer is empty and no
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
Protection Violation Flag — FPVIOL is set automatically when FCBEF is cleared to register a command that
attempts to erase or 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.
Access Error Flag— FACCERRisset automaticallywhen the proper command sequence is not obeyedexactly
(the erroneous command is ignored), if a programor erase operation is attemptedbefore 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 exactactions that are considered access errors, see Section 4.4.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.
FLASH Verified as All Blank (erased) Flag — FBLANK is set automatically at the conclusion of a blank check
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).
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY61
Chapter 4 Memory
4.6.6FLASH Command Register (FCMD)
Only five command codes are recognized in normal user modes as shown in Table 4-14. Refer to
Section 4.4.3, “Program and Erase Command Execution” for a detailed discussion of FLASH
programming and erase operations.
76543210
R
W
Reset00000000
FieldDescription
00000000
FCMD7FCMD6FCMD5FCMD4FCMD3FCMD2FCMD1FCMD0
Figure 4-10. FLASH Command Register (FCMD)
Table 4-13. FCMD Register Field Descriptions
7:0
FCMD[7:0]
FLASH Command Bits — See Table 4-14
Table 4-14. FLASH Commands
CommandFCMDEquate File Label
Blank check0x05mBlank
Byte program0x20mByteProg
Byte program — burst mode0x25mBurstProg
Page erase (512 bytes/page)0x40mPageErase
Mass erase (all FLASH)0x41mMassErase
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.
MC9S08AC16 Series Data Sheet, Rev. 0
62PRELIMINARYFreescale Semiconductor
Chapter 5
Resets, Interrupts, and System Configuration
5.1Introduction
This chapter discusses basic reset and interrupt mechanismsand the varioussources of reset and interrupts
in the MC9S08AC16 Series. Some interrupt sources from peripheral modules are discussed in greater
detail within other chapters of this data manual. This chapter gathers basic information about all reset and
interrupt sources in one place for easy reference. A few reset and interrupt sources, including the computer
operating properly (COP) watchdog and real-time interrupt (RTI), are not part of on-chip peripheral
systems with their own sections but are part of the system control logic.
5.2Features
Reset and interrupt features include:
•Multiple sources of reset for flexible system configuration and reliable operation:
— Power-on detection (POR)
— Low voltage detection (LVD) with enable
— External
— COP watchdog with enable and two timeout choices
RESET pin
— Illegal opcode
— Illegal address
— Serial command from a background debug host
•Reset status register (SRS) to indicate source of most recent reset
•Separate interrupt vectors for each module (reduces polling overhead) (see Table 5-11)
5.3MCU Reset
Resetting the MCU provides a way to start processing from a known set of initial conditions.During reset,
most control and status registers are forced to initial values and the program counter is loaded from the
reset vector (0xFFFE:0xFFFF). On-chip peripheral modules are disabled and I/O pins are initially
configured as general-purpose high-impedance inputs with pullup devices disabled. The I bit in the
condition code register (CCR) is set to block maskable interrupts so the user program has a chance to
initialize the stack pointer (SP) and system control settings. SP is forced to 0x00FF at reset.
The following sources of reset are available on the MC9S08AC16 Series:
•Power-on reset (POR)
•Low-voltage detect (LVD)
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY63
Chapter 5 Resets, Interrupts, and System Configuration
•Computer operating properly (COP) timer
•Illegal opcode detect
•Illegal address detect
•Background debug forced reset
•The reset pin (
RESET)
•Clock generator loss of lock and loss of clock reset
Each of these sources, with the exception of the background debug forced reset, has an associated bit in
the system reset status register.
5.4Computer Operating Properly (COP) Watchdog
The COP watchdog is intended to force a system reset when the application software fails to execute as
expected. To prevent a system reset from the COP timer (when it is enabled), application software must
reset the COP counter periodically. If the application program gets lost and fails to reset the COP counter
before it times out, a system reset is generated to force the system back to a known starting point.
After any reset, the COPE becomes set in SOPT enabling the COP watchdog (see Section 5.9.4, “System
Options Register (SOPT),”for additional information). If the COP watchdog is not used in an application,
it can be disabled by clearing COPE. The COP counter is reset by writing any valueto the address of SRS.
This write does not affect the data in the read-only SRS. Instead, the act of writing to this address is
decoded and sends a reset signal to the COP counter.
The COPCLKS bit in SOPT2 (see Section 5.9.10, “System Options Register 2 (SOPT2),” for additional
information) selects the clock source used for the COP timer. The clock source options are either the bus
clock or an internal 1-kHz clock source. With each clock source, there is an associated short and long
time-out controlled by COPT in SOPT. Table 5-1 summaries the control functions of the COPCLKS and
COPT bits. The COP watchdog defaults to operation from the bus clock source and the associated long
18
time-out (2
cycles).
Table 5-1. COP Configuration Options
Control Bits
COPCLKSCOPT
00
01
10
11
1
Values are shown in this column based on t
Section A.10.1, “Control Timing,” for the tolerance of this value.
Clock SourceCOP Overflow Count
~1 kHz
~1 kHz
Bus
Bus
= 1 ms. See t
RTI
5
cycles (32 ms)
2
8
2
cycles (256 ms)
13
2
cycles
18
2
cycles
in the appendix
RTI
1
1
Even if the application will use the reset default settings of COPE, COPCLKS, and COPT, the user must
write to the write-once SOPT and SOPT2 registers during reset initialization to lock in the settings. That
way, they cannot be changed accidentally if the application program gets lost. The initial writes to SOPT
and SOPT2 will reset the COP counter.
MC9S08AC16 Series Data Sheet, Rev. 0
64PRELIMINARYFreescale Semiconductor
Chapter 5 Resets, Interrupts, and System Configuration
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 will 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-kHzclocksourceis 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.5Interrupts
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 resumes where it left off before the interrupt. Other
than thesoftwareinterrupt (SWI), which is a program instruction, interrupts arecausedby 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 will become set. The
CPU will not respond until and unless the local interrupt enable is a logic 1 to enable the interrupt. 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 masks (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 theCPUreceives a qualifiedinterrupt request, it completes the current instruction beforeresponding
totheinterrupt. The interrupt sequence obeys thesamecycle-by-cycle sequence as theSWI 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
WhiletheCPU is responding to theinterrupt, the I bit is automaticallyset to avoidthe 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 fromthe valuestacked onentry to the ISR. In rare cases, the I bit may be cleared
inside an ISR (after clearing the status flag that generated the interrupt) so that other interrupts can be
serviced withoutwaitingfor the first service routine to finish. This practice is not recommended foranyone
other than the most experienced programmers because it can leadto subtleprogram 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 off the
stack.
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY65
Chapter 5 Resets, Interrupts, and System Configuration
NOTE
For compatibility with the M68HC08, the H register is not automatically
savedand restored. Itisgood programming practice to push Honto 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.
When two or more interrupts are pending when the I bit is cleared, the highest priority source is serviced
first (see Table 5-2).
5.5.1Interrupt Stack Frame
Figure 5-1 shows the contents and organization of a stack frame. Before the interrupt, the stack pointer
(SP) points at the next available byte location on the stack. The current values of CPU registers are stored
on the stack starting with the low-orderbyte of the program counter (PCL) and ending with the CCR. After
stacking, the SP points at the next available location on the stack which is the address that is one less than
the address where the CCR was saved. The PC value that is stacked is the address of the instruction in the
main program that would have executed next if the interrupt had not occurred.
UNSTACKING
ORDER
5
4
3
2
1
STACKING
ORDER
70
1
2
3
4
5
CONDITION CODE REGISTER
ACCUMULATOR
INDEX REGISTER (LOW BYTE X)
PROGRAM COUNTER HIGH
PROGRAM COUNTER LOW
* High byte (H) of index register is not automatically stacked.
TOWARD LOWER ADDRESSES
SP AFTER
INTERRUPT STACKING
*
SP BEFORE
THE INTERRUPT
TOWARD HIGHER ADDRESSES
Figure 5-1. Interrupt Stack Frame
When an RTI instruction is executed, these valuesare recoveredfrom 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 causing the interrupt must be acknowledged (cleared) before returning from the ISR.
Typically, the flag should be cleared at the beginning of the ISR so that if another interrupt is generated by
this same source, it will be registered so it can be serviced after completion of the current ISR.
5.5.2External Interrupt Request (IRQ) Pin
External interrupts are managed by the IRQ status and control register, IRQSC. When the IRQ function is
enabled, synchronous logic monitors the pin for edge-only or edge-and-level events. When the MCU is in
MC9S08AC16 Series Data Sheet, Rev. 0
66PRELIMINARYFreescale Semiconductor
Chapter 5 Resets, Interrupts, and System Configuration
stop mode and system clocks are shut down, a separate asynchronous path is used so the IRQ (if enabled)
can wake the MCU.
5.5.2.1IRQ Pin Configuration Options
The IRQ pin enable (IRQPE) control bit in IRQSCmustbe 1 in order for the IRQ pin to actas theinterrupt
request (IRQ) input. As an IRQ input, the user can choose the polarity of edges or levels detected
(IRQEDG), whether the pin detects edges-only or edges and levels (IRQMOD), and whether an event
causes an interrupt or only sets the IRQF flag which can be polled by software.
The IRQ pin, when enabled, defaults to use an internal pull device (IRQPDD = 0), the device is a pull-up
or pull-down depending on the polarity chosen. If the user desires to use an external pull-up or pull-down,
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
This pin does not contain a clamp diode to V
above V
be as low as V
all the way to V
. The voltage measured on the internally pulled up IRQ pin may
DD
– 0.7 V. The internal gates connected to this pin are pulled
DD
.
DD
and should not be driven
DD
NOTE
When enabling the IRQ pin for use, the IRQF will be set, and should be
cleared prior to enabling the interrupt. When configuring the pin for falling
edge and level sensitivity in a 5V system, it is necessary to wait at least 6
cycles between clearing the flag and enabling the interrupt.
5.5.2.2Edge and Level Sensitivity
The IRQMOD control bit reconfigures the detection logic so it detects edge events and pin levels. In the
edge and leveldetection mode, the IRQF status flag becomes set when an edge is detected (when the IRQ
pin changes from the deasserted to the asserted level), but the flag is continuously set (and cannot be
cleared) as long as the IRQ pin remains at the asserted level.
5.5.3Interrupt Vectors, Sources, and Local Masks
Table 5-2 provides a summary of all interrupt sources. Higher-priority sources are located toward the
bottom of the table. The high-order byte of the address for the interrupt service routine is located at the
first address in the vector address column, and the low-order byte of the address for the interrupt service
routine is located at the next higher address.
When an interrupt condition occurs, an associated flag bit becomes set. If the associated local interrupt
enable is 1, an interrupt request is sent to the CPU. Within the CPU, if the global interrupt mask (I bit in
the CCR) is 0, the CPU will finish the current instruction, stack the PCL, PCH, X, A, and CCR CPU
registers, set the I bit, and then fetch the interrupt vector for the highest priority pending interrupt.
Processing then continues in the interrupt service routine.
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY67
Chapter 5 Resets, Interrupts, and System Configuration
Chapter 5 Resets, Interrupts, and System Configuration
5.6Low-Voltage Detect (LVD) System
The MC9S08AC16 Series includes a system to protect against low voltage conditions in order to protect
memory contents and control MCU system states during supply voltage variations. The system is
comprised of a power-on reset (POR) circuit and an LVD circuit with a user selectable trip voltage, either
high (V
LVDH
) or low (V
voltageis selected by LVDV in SPMSC2. The LVD is disabled upon entering any of the stop modes unless
the LVDSE bit is set. If LVDSE and LVDE are both set, then the MCU cannot enter stop2, and the current
consumption in stop3 with the LVD enabled will be greater.
5.6.1Power-On Reset Operation
). The LVD circuit is enabled when LVDE in SPMSC1 is high and the trip
LVDL
When power is initially applied to the MCU, or when the supply voltage drops below the V
POR
level, the
POR circuit will cause a reset condition. As the supply voltage rises, the LVDcircuit will hold the chip in
reset until the supply has risen above the V
level. Both the POR bit and the LVD bit in SRS are set
LVDL
following a POR.
5.6.2LVD Reset Operation
The LVD can be configured to generate a reset upon detection of a low voltage condition by setting
LVDRE to 1. After anLVDreset has occurred, the LVD system will hold the MCU in reset until the supply
voltage has risen above the level determined by LVDV. The LVD bit in the SRS register is set following
either an LVD reset or POR.
5.6.3LVD Interrupt Operation
When a low voltage condition is detected and the LVDcircuit is configured for interrupt operation (LVDE
set, LVDIE set, and LVDRE clear), then LVDF will be set and an LVD interrupt will occur.
5.6.4Low-Voltage Warning (LVW)
The LVD system has a low voltage warning flag to indicate to the user that the supply voltage is
approaching, but is still above, the LVD voltage. The LVW does not have an interrupt associated with it.
There are two user selectable trip voltages for the LVW, one high (V
) and one low (V
LVWH
voltage is selected by LVWV in SPMSC2. Setting the LVW trip voltage equal to the LVD trip voltage is
not recommended. Typical use of the LVW would be to select V
LVWH
and V
LVDL
.
LVWL
). The trip
5.7Real-Time Interrupt (RTI)
The real-time interrupt function can be used to generate periodic interrupts. The RTI can accept two
sources of clocks, the 1-kHz internal clock or an external clock if available. The 1-kHz internal clock
source iscompletelyindependent of any busclocksource and is used only by the RTImodule and, onsome
MCUs, the COP watchdog. To use an external clock source, it must be available and active.The RTICLKS
bit in SRTISC is used to select the RTI clock source.
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY69
Chapter 5 Resets, Interrupts, and System Configuration
Either RTIclock source can beused when the MCU is in run, wait or stop3mode. Whenusing the external
oscillator in stop3, it must be enabled in stop (OSCSTEN =1)and configured for lowbandwidth operation
(RANGE = 0). Only the internal 1-kHz clock source can be selected to wake the MCU from stop2 mode.
The SRTISC register includes a read-only status flag, a write-only acknowledge bit, and a 3-bit control
value (RTIS2:RTIS1:RTIS0) used to disable the clock source to the real-time interrupt or select one of
seven wakeup periods. The RTI has a local interrupt enable, RTIE, to allow masking of the real-time
interrupt. The RTI can be disabled by writing each bit of RTIS to zeroes, and no interrupts will be
generated. See Section 5.9.7, “System Real-Time Interrupt Status and Control Register (SRTISC),” for
detailed information about this register.
5.8MCLK Output
The PTC2 pin is shared with the MCLK clock output. Setting the pin enable bit, MPE, causes the PTC2
pin to output a divided version of the internal MCU bus clock. The divide ratio is determined by the
MCSEL bits. When MPE is set, the PTC2 pin is forced to operate as an output pin regardless of the state
of the port data direction control bit for the pin. If the MCSEL bits are all 0s, the pin is driven low. The
slew rate and drive strength for the pin are controlled by PTCSE2 and PTCDS2, respectively. The
maximum clock output frequency is limited if slew rate control is enabled, see the electrical chapter for
pin rise and fall times with slew rate enabled.
5.9Reset, Interrupt, and System Control Registers and Control Bits
One 8-bit register in the direct page register space and eight 8-bit registers in the high-page register space
are related to reset and interrupt systems.
Refer to the direct-page register summary in Chapter 4, “Memory,” of this data sheet 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 SOPT 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.”
MC9S08AC16 Series Data Sheet, Rev. 0
70PRELIMINARYFreescale Semiconductor
Chapter 5 Resets, Interrupts, and System Configuration
5.9.1Interrupt Pin Request Status and Control Register (IRQSC)
This direct page register includes status and control bits which are used to configure the IRQ function,
report status, and acknowledge IRQ events.
76543210
R0
IRQPDDIRQEDGIRQPE
WIRQACK
Reset00000000
= Unimplemented or Reserved
Figure 5-2. Interrupt Request Status and Control Register (IRQSC)
Table 5-3. IRQSC Register Field Descriptions
FieldDescription
IRQF0
IRQIEIRQMOD
6
IRQPDD
5
IRQEDG
4
IRQPE
3
IRQF
2
IRQACK
1
IRQIE
Interrupt Request (IRQ) Pull Device Disable— This read/write control bit is used to disable the internal
pull-up/pull-down 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.
Interrupt Request (IRQ) Edge Select — This read/write control bit is used to select the polarity of edges or
levels on the IRQ pin that cause IRQF to be set. The IRQMOD control bit determines whether the IRQ pin is
sensitiveto both edges and levelsor only edges. Whenthe IRQ pinis enabledas the IRQinput and isconfigured
to detect rising edges, it has a pull-down. When the IRQ pin is enabled as the IRQ input and is configured to
detect falling edges, it has a pull-up.
0 IRQ is falling edge or falling edge/low-level sensitive.
1 IRQ is rising edge or rising edge/high-level sensitive.
IRQ Pin Enable — This read/write control bit enables the IRQ pin function. When this bit is set the IRQ pin can
be used as an interrupt request.
0 IRQ pin function is disabled.
1 IRQ pin function is enabled.
IRQ Flag — This read-only status bit indicates when an interrupt request event has occurred.
0 No IRQ request.
1 IRQ event detected.
IRQ Acknowledge — Thiswrite-only bit is used to acknowledgeinterrupt request events(write 1 to clear IRQF).
Writing 0 hasno meaningor effect. Reads alwaysreturn 0. Ifedge-and-leveldetection isselected (IRQMOD = 1),
IRQF cannot be cleared while the IRQ pin remains at its asserted level.
IRQ Interrupt Enable — This read/write control bit determines whether IRQ events generate an interrupt
request.
0 Interrupt request when IRQF set is disabled (use polling).
1 Interrupt requested whenever IRQF = 1.
0
IRQMOD
Freescale SemiconductorPRELIMINARY71
IRQ Detection Mode — This read/write control bit selects either edge-only detection or edge-and-level
detection. The IRQEDG control bit determines the polarity of edges and levels that are detected as interrupt
request events. SeeSection 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.
MC9S08AC16 Series Data Sheet, Rev. 0
Chapter 5 Resets, Interrupts, and System Configuration
5.9.2System Reset Status Register (SRS)
This register includes seven read-only status flags to indicate the source of the most recent reset. When a
debug host forces reset by writing 1 to BDFR in the SBDFR register, none of the status bits in SRS will be
set. Writinganyvalue to thisregisteraddress clears the COP watchdog timerwithoutaffecting the contents
of this register. The reset state of these bits depends on what caused the MCU to reset.
76543210
RPORPINCOPILOPILADICGLVD0
WWriting any value to SRS address clears COP watchdog timer.
POR10000010
LVR:
Any other
U0000010
0Note
(1)
Note
(1)
Note
(1)
0Note
(1)
00
reset:
U = Unaffected by reset
1
Any of these reset sources that are active at the time of reset will cause the corresponding bit(s) to be set; bits corresponding
to sources that are not active at the time of reset will be cleared.
Figure 5-3. System Reset Status (SRS)
Table 5-4. SRS Register Field Descriptions
FieldDescription
7
POR
6
PIN
5
COP
Power-On Reset — Resetwas caused by the power-ondetection logic.Because theinternalsupply voltagewas
ramping up at the time, the low-voltagereset (LVR)status bit is also set to indicate that the reset occurred while
the internal supply was below the LVR threshold.
0 Reset not caused by POR.
1 POR caused reset.
External Reset Pin — Reset was caused by an active-low level on the external reset pin.
0 Reset not caused by external reset pin.
1 Reset came from external reset pin.
Computer Operating Properly (COP) Watchdog— Reset was caused by the COP watchdog timer timing out.
This reset source may be blocked by COPE = 0.
0 Reset not caused by COP timeout.
1 Reset caused by COP timeout.
4
ILOP
72PRELIMINARYFreescale Semiconductor
Illegal Opcode — Reset was caused by an attempt to execute an unimplemented or illegal opcode. The STOP
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.
MC9S08AC16 Series Data Sheet, Rev. 0
Chapter 5 Resets, Interrupts, and System Configuration
Table 5-4. SRS Register Field Descriptions (continued)
FieldDescription
3
ILAD
2
ICG
1
LVD
Illegal Address — Reset was caused by an attempt to access a designated illegal address.
0 Reset not caused by an illegal address access.
1 Reset caused by an illegal address access.
Illegal address areas in the MC9S08AC16 are:
0x0470 - 0x17FF — Gap from end of RAM to start of high page registers
0x1860 - 0xBFFF — Gap from end of high page registers to start of Flash memory
Unused and reserved locations in register areas are not considered illegal addresses and do not trigger illegal
address resets.
Internal Clock Generation Module Reset — Reset was caused by an ICG module reset.
0 Reset not caused by ICG module.
1 Reset caused by ICG module.
Low Voltage Detect — If the LVDRE and LVDSE bits are set and the supply drops below the LVD trip voltage,
an LVD reset will occur. This bit is also set by POR.
0 Reset not caused by LVD trip or POR.
1 Reset caused by LVD trip or POR.
5.9.3System Background Debug Force Reset Register (SBDFR)
This register contains a single write-only control bit. A serial background command such as
WRITE_BYTE must be used to write to SBDFR. Attempts to write this register from a user program are
ignored. Reads always return 0x00.
76543210
R00000000
WBDFR
Reset00000000
= Unimplemented or Reserved
1
BDFR is writable only through serial background debug commands, not from user programs.
1
Figure 5-4. System Background Debug Force Reset Register (SBDFR)
Table 5-5. SBDFR Register Field Descriptions
FieldDescription
0
BDFR
Background Debug Force Reset — A serial background command such as WRITE_BYTE may be used to
allow an external debug host to force a target system reset. Writing logic 1 to this bit forces an MCU reset. This
bit cannot be written from a user program.
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY73
Chapter 5 Resets, Interrupts, and System Configuration
5.9.4System Options Register (SOPT)
This register may be read at any time. Bits 3 and 2 are unimplemented and always read 0. This is a
write-once register so only the first write after reset is honored. Any subsequent attempt to write to SOPT
(intentionally or unintentionally) is ignored to avoid accidental changes to these sensitive settings. SOPT
shouldbewritten during the user’sreset initialization program to setthedesired controls evenif the desired
settings are the same as the reset settings.
76543210
R
COPECOPTSTOPE
W
Reset11010011
= Unimplemented or Reserved
Figure 5-5. System Options Register (SOPT)
Table 5-6. SOPT Register Field Descriptions
FieldDescription
00
7
COPE
6
COPT
5
STOPE
COP Watchdog Enable — This write-once bit defaults to 1 after reset.
0 COP watchdog timer disabled.
1 COP watchdog timer enabled (force reset on timeout).
COP Watchdog Timeout — This write-once bit defaults to 1 after reset.
0 Short timeout period selected.
1 Long timeout period selected.
Stop Mode Enable — This write-once bit defaults to 0 after reset, which disables stop mode. If stop mode is
disabled and a user program attempts to execute a STOP instruction, an illegal opcode reset is forced.
0 Stop mode disabled.1Stop mode enabled.
MC9S08AC16 Series Data Sheet, Rev. 0
74PRELIMINARYFreescale Semiconductor
Chapter 5 Resets, Interrupts, and System Configuration
5.9.5System MCLK Control Register (SMCLK)
This register is used to control the MCLK clock output.
76543210
R000
MPE
W
Reset00000000
= Unimplemented or Reserved
Figure 5-6. System MCLK Control Register (SMCLK)
Table 5-7. SMCLK Register Field Descriptions
FieldDescription
0
MCSEL
4
MPE
2:0
MCSEL
MCLK Pin Enable — This bit is used to enable the MCLK function.
0 MCLK output disabled.
1 MCLK output enabled on PTC2 pin.
MCLK Divide Select — These bits are used to select the divide ratio for the MCLK output according to the
formula below when the MCSEL bits are not equal to all zeroes. In the case that the MCSEL bits are all zero and
MPE is set, the pin is driven low. See Equation 5-1.
MCLK frequency = Bus Clock frequency ÷ (2 * MCSEL)Eqn. 5-1
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY75
Chapter 5 Resets, Interrupts, and System Configuration
This read-only register is included so host development systems can identify the HCS08 derivative and
revision number. This allows the development software to recognize where specific memory blocks,
registers, and control bits are located in a target MCU.
76543210
RID11ID10ID9ID8
W
Reset
————
0000
= Unimplemented or Reserved
Figure 5-7. System Device Identification Register — High (SDIDH)
Table 5-8. SDIDH Register Field Descriptions
FieldDescription
7:4
Reserved
3:0
ID[11:8]
RID7ID6ID5ID4ID3ID2ID1ID0
W
Reset00010010
Bits 7:4 are reserved. Reading these bits will result in an indeterminate value; writes have no effect.
Part Identification Number — Each derivative in the HCS08 Family has a unique identification number. The
MC9S08AC16 Series is hard coded to the value 0x012. See also ID bits in Table 5-9.
76543210
= Unimplemented or Reserved
Figure 5-8. System Device Identification Register — Low (SDIDL)
Table 5-9. SDIDL Register Field Descriptions
FieldDescription
7:0
ID[7:0]
76PRELIMINARYFreescale Semiconductor
Part Identification Number — Each derivative in the HCS08 Family has a unique identification number. The
MC9S08AC16 Series is hard coded to the value 0x012. See also ID bits in Table 5-8.
MC9S08AC16 Series Data Sheet, Rev. 0
Chapter 5 Resets, Interrupts, and System Configuration
5.9.7System Real-Time Interrupt Status and Control Register (SRTISC)
This register contains one read-only status flag, one write-only acknowledge bit, three read/write delay
selects, and three unimplemented bits, which always read 0.
76543210
RRTIF0
RTICLKSRTIE
WRTIACK
Reset00000000
= Unimplemented or Reserved
Figure 5-9. System RTI Status and Control Register (SRTISC)
Table 5-10. SRTISC Register Field Descriptions
FieldDescription
0
RTIS2RTIS1RTIS0
7
RTIF
6
RTIACK
5
RTICLKS
4
RTIE
2:0
RTIS[2:0]
Real-Time Interrupt Flag — This read-only status bit indicates the periodic wakeup timer has timed out.
0 Periodic wakeup timer not timed out.
1 Periodic wakeup timer timed out.
Real-Time Interrupt Acknowledge — This write-only bit is used to acknowledge real-time interrupt request
(write 1 to clear RTIF). Writing 0 has no meaning or effect. Reads always return logic 0.
Real-Time Interrupt Clock Select — This read/write bit selects the clock source for the real-time interrupt.
0 Real-time interrupt request clock source is internal 1-kHz oscillator.
1 Real-time interrupt request clock source is external clock.
Real-Time Interrupt Enable — This read-write bit enables real-time interrupts.
0 Real-time interrupts disabled.
1 Real-time interrupts enabled.
Real-Time Interrupt Delay Selects — These read/write bits select the wakeup delay for the RTI. The clock
source for the real-time interrupt is a self-clocked source which oscillates at about 1 kHz, is independent of other
MCU clock sources. Using external clock source the delays will be crystal frequency divided by value in
RTIS2:RTIS1:RTIS0. See Table 5-11.
Table 5-11. Real-Time Interrupt Frequency
RTIS2:RTIS1:RTIS01-kHz Clock Source Delay
0:0:0Disable periodic wakeup timerDisable periodic wakeup timer
0:0:18 msdivide by 256
0:1:032 ms divide by 1024
0:1:164 msdivide by 2048
1:0:0128 msdivide by 4096
1:0:1256 msdivide by 8192
1:1:0512 msdivide by 16384
1:1:11.024 sdivide by 32768
1
Normal values are shown in this column based on f
Specifications,” f
for the tolerance on these values.
RTI
RTI
1
= 1 kHz. See Appendix A, “Electrical Characteristics and Timing
Using External Clock Source Delay
(Crystal Frequency)
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY77
Chapter 5 Resets, Interrupts, and System Configuration
5.9.8System Power Management Status and Control 1 Register (SPMSC1)
7654321
RLVDF0
LVDIELVDRE
(2)
LVDSE
(2)
LVDE
(2)
1
0
BGBE
WLVDACK
Reset00011100
= Unimplemented or Reserved
1
Bit 1 is a reserved bit that must always be written to 0.
2
This bit can be written only one time after reset. Additional writes are ignored.
Figure 5-10. System Power Management Status and Control 1 Register (SPMSC1)
Table 5-12. SPMSC1 Register Field Descriptions
FieldDescription
7
LVDF
6
LVDACK
5
LVDIE
Low-Voltage Detect Flag — Provided LVDE = 1, this read-only status bit indicates a low-voltage detect event.
Low-Voltage Detect Acknowledge — This write-only bit is used to acknowledge low voltage detection errors
(write 1 to clear LVDF). Reads always return 0.
Low-Voltage Detect Interrupt Enable — This read/write bit enables hardware interrupt requests for LVDF.
0 Hardware interrupt disabled (use polling).
1 Request a hardware interrupt when LVDF = 1.
4
LVDRE
3
LVDSE
2
LVDE
0
BGBE
Low-Voltage Detect Reset Enable — This read/write bit enables LVDF events to generate a hardware reset
(provided LVDE = 1).
0 LVDF does not generate hardware resets.
1 Force an MCU reset when LVDF = 1.
Low-Voltage Detect Stop Enable — Provided LVDE = 1, this read/write bit determines whether the low-voltage
detect function operates when the MCU is in stop mode.
0 Low-voltage detect disabled during stop mode.
1 Low-voltage detect enabled during stop mode.
Low-Voltage Detect Enable — This read/write bit enables low-voltage detect logic and qualifies the operation
of other bits in this register.
0 LVD logic disabled.
1 LVD logic enabled.
Bandgap Buffer Enable — The BGBE bit is used to enable an internal bufferfor the bandgap voltage reference
for use by the ADC module on one of its internal channels.
0 Bandgap buffer disabled.
1 Bandgap buffer enabled.
MC9S08AC16 Series Data Sheet, Rev. 0
78PRELIMINARYFreescale Semiconductor
Chapter 5 Resets, Interrupts, and System Configuration
5.9.9System Power Management Status and Control 2 Register (SPMSC2)
This registeris used to report the status ofthelow voltagewarningfunction, and to configure the stop mode
behavior of the MCU.
76543210
RLVWF0
LVDVLVWV
W
Power-on
(2)
0
LVWACKPPDACK
0000000
reset:
LVD
0
0UU0000
(2)
reset:
Any other
0
0UU0000
(2)
reset:
= Unimplemented or ReservedU = Unaffected by reset
1
This bit can be written only one time after reset. Additional writes are ignored.
2
LVWF will be set in the case when V
transitions below the trip point or after reset and V
Supply
PPDF0
is already below V
Supply
PPDC
LVW
1
.
Figure 5-11. System Power Management Status and Control 2 Register (SPMSC2)
Table 5-13. SPMSC2 Register Field Descriptions
FieldDescription
7
LVWF
6
LVWACK
5
LVDV
4
LVWV
3
PPDF
2
PPDACK
0
PPDC
Low-Voltage Warning Flag — The LVWF bit indicates the low voltage warning status.
0 Low voltage warning not present.
1 Low voltage warning is present or was present.
Low-Voltage Warning Acknowledge — The LVWACK bit is the low-voltage warning acknowledge.
Writing a 1 to LVWACK clears LVWF to a 0 if a low voltage warning is not present.
Low-Voltage Detect Voltage Select — The LVDV bit selects the LVD trip point voltage (V
0 Low trip point selected (V
1 High trip point selected (V
LVD
LVD
= V
= V
LVDL
LVDH
).
).
Low-Voltage Warning Voltage Select — The LVWV bit selects the LVW trip point voltage (V
0 Low trip point selected (V
1 High trip point selected (V
LVW
LVW
= V
= V
LVWL
LVWH
).
).
Partial Power Down Flag — The PPDF bit indicates that the MCU has exited the stop2 mode.
0 Not stop2 mode recovery.
1 Stop2 mode recovery.
Partial Power Down Acknowledge — Writing a 1 to PPDACK clears the PPDF bit.
Partial Power Down Control — The write-once PPDC bit controls whether stop2 or stop3 mode is selected.
Chapter 5 Resets, Interrupts, and System Configuration
5.9.10System Options Register 2 (SOPT2)
This high page register contains bits to configure MCU specific features on the MC9S08AC16 Series
devices.
76543210
R
COPCLKS
W
Reset:10000000
1
0000000
= Unimplemented or Reserved
1
This bit can be written only one time after reset. Additional writes are ignored.
Table 5-14. SOPT2 Register Field Descriptions
FieldDescription
Figure 5-12. System Options Register 2 (SOPT2)
7
COPCLKS
COP Watchdog Clock Select — This write-once bit selects the clock source of the COP watchdog.
0 Internal 1-kHz clock is source to COP.
1 Bus clock is source to COP.
MC9S08AC16 Series Data Sheet, Rev. 0
80PRELIMINARYFreescale Semiconductor
Chapter 6
Parallel Input/Output
6.1Introduction
This chapterexplainssoftware controls related to parallel input/output(I/O).The MC9S08AC16 has seven
I/O ports which include a total of 54 general-purpose I/O pins. See Chapter 2, “Pins and Connections” for
more information about the logic and hardware aspects of these pins.
Many of these pins are shared with on-chip peripherals such as timer systems, communication systems, or
keyboard interrupts. When these other modules are not controlling the port pins, they revert to
general-purpose I/O control.
NOTE
Not all general-purpose I/O pins are available on all packages. To avoid
extra current drain from floating input pins, the user’s reset initialization
routine in the application program should either enable on-chip pullup
devices or change the direction of unconnected pins to outputs so the pins
do not float.
= Not available on 32-, 42-, or 44-pin packages
= Not available on 32- or 42-pin packages
= Not available on 32-pin packages
= Not available on S9S08AWxxA devices
VOLTAGE
REGULATOR
2-CHANNEL TIMER/PWM
MODULE (TPM3)
TPM3CH1
TPM3CH0
PORT G
PTG6/EXTAL
PTG5/XTAL
PTG4/KBIP4
PTG3/KBIP3
PTG2/KBIP2
PTG1/KBIP1
PTG0/KBIP0
Notes:
1. Port pins are software configurable with pullup device if input port.
2. Pin contains software configurable pullup/pulldown device if IRQ is enabled (IRQPE = 1). Pulldown is enabled
if rising edge detect is selected (IRQEDG = 1)
3. IRQ does not have a clamp diode to V
. IRQ should not be driven above VDD.
DD
4. Pin contains integrated pullup device.
5. PTD3, PTD2, and PTG4 contain both pullup and pulldown devices. Pulldown enabled when KBI is enabled
(KBIPEn = 1) and rising edge is selected (KBEDGn = 1).
Parallel I/O and Pin Control features, depending on package choice, include:
•A total of 38 general-purpose I/O pins in seven ports
•Hysteresis input buffers
•Software-controlled pullups on each input pin
•Software-controlled slew rate output buffers
•Four port A pins
•Four port B pins shared with ADC1 and TPM3
1
•Six port C pins shared with SCI2, IIC1, and MCLK
•Four port D pins shared with ADC1, KBI, and TPM1 and TPM2 external clock inputs
•Eight port E pins shared with SCI1, TPM1, and SPI1
•Five port F pins shared with TPM1 and TPM2
•Seven port G pins shared with XTAL, EXTAL, and KBI
6.3Pin Descriptions
The MC9S08AC16 Series has a total of 38 parallel I/O pins in seven ports (PTA–PTG). Not all pins are
bonded out in all packages. Consult the pin assignment in Chapter 2,“Pins and Connections,” for available
parallel I/O pins. All of these pins are available for general-purpose I/O when they are not used by other
on-chip peripheral systems.
After reset, the shared peripheral functions are disabled so that the pins are controlled by the parallel I/O.
All of the parallel I/O are configured as inputs (PTxDDn = 0). The pin control functions for each pin are
configured as follows:slew rate control enabled (PTxSEn = 1), low drive strength selected (PTxDSn = 0),
and internal pullups disabled (PTxPEn = 0).
The following paragraphs discuss each port and the software controls that determine each pin’s use.
6.3.1Port A
Port ABit 7654321Bit 0
MCU Pin:PTA7RRRRPTA2PTA1PTA0
Figure 6-2. Port A Pin Names
Port A pins are general-purpose I/O pins. Parallel I/O function is controlledby theportA data (PTAD)and
data direction (PTADD) registers which are located in page zero register space. The pin control registers,
pullup enable (PTAPE), slew rate control (PTASE), and drive strength select (PTADS) are located in the
high page registers. Refer to Section 6.4, “Parallel I/O Control” for more information about
general-purpose I/O control and Section 6.5, “Pin Control” for more information about pin control.
1. TPM3 is not available on S9S08AWxxA devices.
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY83
Chapter 6 Parallel Input/Output
6.3.2Port B
Port BBit 7654321Bit 0
PTB3/
MCU Pin:RRRR
Figure 6-3. Port B Pin Names
TPM3CH0/
AD1P3
PTB2/
TPM3CH1/
AD1P2
PTB1/
AD1P1
PTB0/
AD1P0
Port B pins are general-purpose I/O pins.ParallelI/O function is controlled by the port Bdata (PTBD) and
data direction (PTBDD) registers which are located in page zero register space. The pin control registers,
pullup enable (PTBPE), slew rate control (PTBSE), and drive strength select (PTBDS) are located in the
high page registers. Refer to Section 6.4, “Parallel I/O Control” for more information about
general-purpose I/O control and Section 6.5, “Pin Control” for more information about pin control.
Port B general-purpose I/O are shared with the ADC and TPM3 timer channels. Any pin enabled as an
ADC input will have the general-purpose I/O function disabled. When any TPM3 function is enabled, the
direction (input or output) is controlled by the TPM3 and not by the data direction register of the parallel
I/O port. Refer to Chapter 10, “Timer/PWM (S08TPMV3),” for more information about using port B pins
as TPM channels. Refer to Chapter 14, “Analog-to-Digital Converter (S08ADC10V1)” for more
information about using port B as analog inputs.
6.3.3Port C
Port CBit 7653321Bit 0
MCU Pin:0R
PTC5/
RxD2
Figure 6-4. Port C Pin Names
PTC4
PTC3/
TxD2
PTC2/
MCLK
PTC1/
SDA1
PTC0/
SCL1
Port C pins are general-purpose I/O pins.ParallelI/O function is controlled by the port Cdata (PTCD) and
data direction (PTCDD) registers which are located in page zero register space. The pin control registers,
pullup enable (PTCPE), slew rate control (PTCSE), and drive strength select (PTCDS) are located in the
high page registers. Refer to Section 6.4, “Parallel I/O Control” for more information about
general-purpose I/O control and Section 6.5, “Pin Control” for more information about pin control.
Port C general-purpose I/O is shared with SCI2, IIC, and MCLK. When any shared function is enabled,
the direction, input or output, is controlled by the shared function and not by the data direction register of
the parallel I/O port. Also, for pins which are configured as outputs by the shared function, the output data
is controlled by the shared function and not by the port data register.
Refer to Chapter 11, “Serial Communications Interface (S08SCIV4)” for more information about using
port C pins as SCI pins.
Refer to Chapter 13, “Inter-Integrated Circuit (S08IICV2)” for more information about using port C pins
as IIC pins.
Refer to Chapter 5, “Resets, Interrupts, and System Configuration” for more information about using
PTC2 as the MCLK pin.
MC9S08AC16 Series Data Sheet, Rev. 0
84PRELIMINARYFreescale Semiconductor
Chapter 6 Parallel Input/Output
6.3.4Port D
Port DBit 7654321Bit 0
PTD2/
AD1P10/
KBIP5
PTD1/
AD1P9
PTD0/
AD1P8
MCU Pin:
PTD3/
RRRR
Figure 6-5. Port D Pin Names
AD1P11/
KBIP6
Port D pins are general-purpose I/O pins. Parallel I/O function is controlled by the port D data (PTDD) and
data direction (PTDDD) registers which are located in page zero register space. The pin control registers,
pullup enable (PTDPE), slew rate control (PTDSE), and drive strength select (PTDDS) are located in the
high page registers. Refer to Section 6.4, “Parallel I/O Control” for more information about
general-purpose I/O control and Section 6.5, “Pin Control” for more information about pin control.
Port D general-purpose I/O are shared with the ADC and KBI. When any of these shared functions is
enabled, the direction, input or output, is controlled by the shared function and not by the data direction
register of the parallel I/O port. When a pin is shared with both the ADC and a digital peripheral function,
the ADC has higher priority. For example,in the case that both the ADC and the KBI are configured touse
PTD7 then the pin is controlled by the ADC module.
Refer to Chapter 10, “Timer/PWM (S08TPMV3)” for more information about using port D pins as TPM
external clock inputs.
Refer to Chapter 14, “Analog-to-Digital Converter (S08ADC10V1)” for more information about using
port D pins as analog inputs.
Refer to Chapter 9, “Keyboard Interrupt (S08KBIV1)” for more information about using port D pins as
keyboard inputs.
6.3.5Port E
Port EBit 7654321Bit 0
MCU Pin:
PTE7/
SPSCK1
Port E pins are general-purpose I/O pins. Parallel I/O function is controlled by the port E data (PTED) and
data direction (PTEDD) registers which are located in page zero register space. The pin control registers,
pullup enable (PTEPE), slew rate control (PTESE), and drive strength select (PTEDS) are located in the
high page registers. Refer to Section 6.4, “Parallel I/O Control” for more information about
general-purpose I/O control and Section 6.5, “Pin Control” for more information about pin control.
Port E general-purpose I/O is shared with SCI1, SPI, andTPM1 timer channels. When any of these shared
functions is enabled, the direction, input or output, is controlled by the shared function and not by the data
direction register of the parallel I/O port. Also, for pins which are configured as outputs by the shared
function, the output data is controlled by the shared function and not by the port data register.
Freescale SemiconductorPRELIMINARY85
PTE6/
MOSI1
Figure 6-6. Port E Pin Names
MC9S08AC16 Series Data Sheet, Rev. 0
PTE5/
MISO1
PTE4/
SS1
PTE3/
TPM1CH1
PTE2/
TPM1CH0
PTE1/
RxD1
PTE0/
TxD1
Chapter 6 Parallel Input/Output
Refer to Chapter 11, “Serial Communications Interface (S08SCIV4)” for more information about using
port E pins as SCI pins.
Refer to Chapter 12, “Serial Peripheral Interface (S08SPIV3)” for more information about using port E
pins as SPI pins.
Refer to Chapter 10, “Timer/PWM (S08TPMV3)” for more information about using port E pins as TPM
channel pins.
6.3.6Port F
Port FBit 7654321Bit 0
MCU Pin:RPTF6
PTF5/
TPM2CH1
Figure 6-7. Port F Pin Names
PTF4/
TPM2CH0
RR
PTF1/
TPM1CH3
PTF0/
TPM1CH2
Port F pins are general-purpose I/O pins. Parallel I/O function is controlled by the port F data (PTFD) and
data direction (PTFDD) registers which are located in page zero register space. The pin control registers,
pullup enable (PTFPE), slew rate control (PTFSE), and drive strength select (PTFDS) are located in the
high page registers. Refer to Section 6.4, “Parallel I/O Control” for more information about
general-purpose I/O control and Section 6.5, “Pin Control” for more information about pin control.
Port F general-purpose I/O is shared with TPM1 and TPM2 timer channels. When any of these shared
functions is enabled, the direction, input or output, is controlled by the shared function and not by the data
direction register of the parallel I/O port. Also, for pins which are configured as outputs by the shared
function, the output data is controlled by the shared function and not by the port data register.
Refer to Chapter 10, “Timer/PWM (S08TPMV3)” for more information about using port F pins as TPM
channel pins.
6.3.7Port G
Port GBit 7654321Bit 0
MCU Pin:0
PTG6/
EXTAL
PTG5/
XTAL
PTG4/
KBIP4
PTG3/
KBIP3
PTG2/
KBIP2
PTG1/
KBIP1
PTG0/
KBIP0
Figure 6-8. Port G Pin Names
Port G pins are general-purpose I/O pins. Parallel I/O function is controlled by the port G data (PTGD) and
data direction (PTGDD) registers which are located in page zero register space. The pin control registers,
pullup enable (PTGPE), slew rate control (PTGSE), and drive strength select (PTGDS) are located in the
high page registers. Refer to Section 6.4, “Parallel I/O Control” for more information about
general-purpose I/O control and Section 6.5, “Pin Control” for more information about pin control.
Port G general-purpose I/O is shared with KBI, XTAL, and EXTAL. When a pin is enabled as a KBI input,
the pin functions as an input regardlessof the state of the associated PTG data direction register bit. When
MC9S08AC16 Series Data Sheet, Rev. 0
86PRELIMINARYFreescale Semiconductor
Chapter 6 Parallel Input/Output
the external oscillator is enabled, PTG5 and PTG6 function as oscillator pins. In this case the associated
parallel I/O and pin control registers have no control of the pins.
Refer to Chapter 8, “Internal Clock Generator (S08ICGV4)” for more information about using port G pins
as XTAL and EXTAL pins.
Refer to Chapter 9, “Keyboard Interrupt (S08KBIV1)” for more information about using port G pins as
keyboard inputs.
6.4Parallel I/O Control
Reading and writing of parallel I/O is done through the port data registers. The direction, input or output,
is controlled through the port data direction registers. The parallel I/O port function for an individual pin
is illustrated in the block diagram below.
PTxDDn
QD
Output Enable
PTxDn
Output Data
Input Data
Port Read
Data
BUSCLK
QD
1
0
Figure 6-9. Parallel I/O Block Diagram
Synchronizer
The data direction control bits determine whether the pin output driver is enabled, and they control what
is read for port data register reads. Each port pin has a data direction register bit. When PTxDDn = 0, the
corresponding pin is an input and reads of PTxD return the pin value. When PTxDDn = 1, the
corresponding pin is an output and reads of PTxD return the last value written to the port data register.
When a peripheral module or system function is in control of a port pin, the data direction register bit still
controls what is returned for reads of the port data register, even though the peripheral system has
overriding control of the actual pin direction.
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY87
Chapter 6 Parallel Input/Output
When a shared analog function is enabled for apin, all digital pin functions are disabled. A read ofthe port
data register returns a value of 0 for any bits which have shared analog functions enabled. In general,
whenevera pin is shared with both an alternate digital function and an analog function, theanalog function
has priority such that if both the digital and analog functions are enabled, the analog function controls the
pin.
It is a good programming practice to write to the port data register before changing the direction of a port
pin to become an output. This ensures that the pin will not be driven momentarily with an old data value
that happened to be in the port data register.
6.5Pin Control
The pin control registersare located in the high page register block of the memory.These registers are used
to control pullups, slew rate, and drive strength for the I/O pins. The pin control registers operate
independently of the parallel I/O registers.
6.5.1Internal Pullup Enable
An internal pullup device can be enabled for each port pin by setting the corresponding bit in one of the
pullup enable registers (PTxPEn). The pullupdeviceis disabled if the pin is configured as an output by the
parallel I/O control logic or any shared peripheral function regardless of the state of the corresponding
pullup enable register bit. The pullup device is also disabled if the pin is controlled by an analog function.
6.5.2Output Slew Rate Control Enable
Slew rate control can be enabled for each port pin by setting the corresponding bit in one of the slew rate
control registers (PTxSEn). When enabled,slewcontrol limits the rate at which an output can transition in
order to reduce EMC emissions. Slew rate control has no effect on pins which are configured as inputs.
6.5.3Output Drive Strength Select
An output pin can be selected to havehigh output drive strength by setting the corresponding bit in one of
the drive strength select registers (PTxDSn). When high drive is selected a pin is capable of sourcing and
sinking greater current. Even though every I/O pin can be selected as high drive, the user must ensure that
the total current source and sink limits for the chip are not exceeded. Drive strength selection is intended
to affect the DC behavior of I/O pins. However, the AC behavior is also affected. High drive allows a pin
to drive a greater load with the same switching speed as a low drive enabled pin into a smaller load.
Because of this the EMC emissions may be affected by enabling pins as high drive.
MC9S08AC16 Series Data Sheet, Rev. 0
88PRELIMINARYFreescale Semiconductor
Chapter 6 Parallel Input/Output
6.6Pin Behavior in Stop Modes
Depending on the stop mode, I/O functions differently as the result of executing a STOP instruction. An
explanation of I/O behavior for the various stop modes follows:
•Stop2 mode is a partial power-down mode, whereby I/O latches are maintained in their state as
before the STOP instruction was executed. CPU register status andthe state of I/O registers should
be saved in RAM before the STOP instruction is executed to place the MCU in stop2 mode. Upon
recoveryfrom stop2 mode, before accessing anyI/O, the user should examine thestateof the PPDF
bit in the SPMSC2 register. If the PPDF bit is 0, I/O must be initialized as if a power on reset had
occurred. If the PPDF bit is 1, I/O data previously stored in RAM, before the STOP instruction was
executed, peripherals may require being initialized and restored to their pre-stop condition. The
user mustthenwrite a 1 to the PPDACKbit in the SPMSC2register.Accessto I/O is now permitted
again in the user’s application program.
•In stop3 mode, all I/O is maintained because internal logic circuity stays powered up. Upon
recovery, normal I/O function is available to the user.
6.7Parallel I/O and Pin Control Registers
This section provides information about the registers associated with the parallel I/O ports and pin control
functions. These parallel I/O registers are located in page zero of the memory map and the pin control
registers are located in the high page register section of memory.
Refer to tables in Chapter 4, “Memory,” for the absolute address assignments for all parallel I/O and pin
control registers.This section refers to registers and control bits only by their names.AFreescale-provided
equate or header file normally is used to translate these names into the appropriate absolute addresses.
6.7.1Port A I/O Registers (PTAD and PTADD)
Port A parallel I/O function is controlled by the registers listed below.
76543210
R
PTAD7RRRRPTAD2PTAD1PTAD0
W
Reset00000000
1
Bits 6 through 3 are reserved bits that must always be written to 0.
FieldDescription
7, 2:0
PTADn
Port A Data Register Bits — For port A pins that are inputs, reads return the logic level on the pin. For port A
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.
Resetforces PTADto all 0s, butthese 0sare notdriven out the corresponding pins because reset also configures
all port pins as high-impedance inputs with pullups disabled.
Figure 6-10. Port A Data Register (PTAD)
Table 6-1. PTAD Register Field Descriptions
1
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY89
Chapter 6 Parallel Input/Output
76543210
R
PTADD7RRRRPTADD2PTADD1PTADD0
W
Reset00000000
1
Figure 6-11. Data Direction for Port A Register (PTADD)
Bits 6 through 3 are reserved bits that must always be written to 0.
1
Table 6-2. PTADD Register Field Descriptions
FieldDescription
7, 2:0
PTADDn
Data Direction for Port A Bits — These read/write bits control the direction of port A pins and what is read for
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.
6.7.2Port A Pin Control Registers (PTAPE, PTASE, PTADS)
In addition to the I/O control, port A pins are controlled by the registers listed below.
76543210
R
PTAPE7RRRRPTAPE2PTAPE1PTAPE0
W
Reset00000000
1
Bits 6 through 3 are reserved bits that must always be written to 0.
Table 6-3. PTADD Register Field Descriptions
FieldDescription
Figure 6-12. Internal Pullup Enable for Port A (PTAPE)
7, 2:0
PTAPEn
Internal Pullup Enable for Port A Bits — Each of these control bits determines if the internal pullup device is
enabled for the associated PTA pin. Forport A pins that are configured as outputs, these bits have no effect and
the internal pullup devices are disabled.
0 Internal pullup device disabled for port A bit n.
1 Internal pullup device enabled for port A bit n.
1
MC9S08AC16 Series Data Sheet, Rev. 0
90PRELIMINARYFreescale Semiconductor
Chapter 6 Parallel Input/Output
76543210
R
PTASE7RRRRPTASE2PTASE1PTASE0
W
Reset00000000
1
Figure 6-13. Internal Pullup Enable for Port A (PTASE)
Bits 6 through 3 are reserved bits that must always be written to 0.
1
Table 6-4. PTASE Register Field Descriptions
FieldDescription
7, 2:0
PTASEn]
Output Slew Rate Control Enable for Port A Bits — Each of these control bits determine whether output slew
rate control 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.
76543210
R
PTADS7RRRRPTADS2PTADS1PTADS0
W
Reset00000000
1
Figure 6-14. Internal Pullup Enable for Port A (PTASE)
Bits 6 through 3 are reserved bits that must always be written to 0.
1
Table 6-5. PTASE Register Field Descriptions
FieldDescription
7, 2:0
PTADSn
Output Drive Strength Selection for Port A Bits — Each of these control bits selects between low and high
output drive for the associated PTA pin.
0 Low output drive enabled for port A bit n.
1 High output drive enabled for port A bit n.
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY91
Chapter 6 Parallel Input/Output
6.7.3Port B I/O Registers (PTBD and PTBDD)
Port B parallel I/O function is controlled by the registers in this section.
76543210
R
W
Reset00000000
1
Bits 7 through 4 are reserved bits that must always be written to 0.
FieldDescription
RRRRPTBD3PTBD2PTBD1PTBD0
Figure 6-15. Port B Data Register (PTBD)
1
Table 6-6. PTBD Register Field Descriptions
3:0
PTBD[3:0]
R
W
Reset00000000
1
Bits 7 through 4 are reserved bits that must always be written to 0.
Port B Data Register Bits — For port B pins that are inputs, reads return the logic level on the pin. For port B
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.
ResetforcesPTBD toall 0s,butthese 0s are not drivenout the corresponding pins becausereset alsoconfigures
all port pins as high-impedance inputs with pullups disabled.
76543210
RRRRPTBDD3PTBDD2PTBDD1PTBDD0
Figure 6-16. Data Direction for Port B (PTBDD)
1
Table 6-7. PTBDD Register Field Descriptions
FieldDescription
3:0
PTBDD[3:0]
Data Direction for Port B Bits — These read/write bits control the direction of port B pins and what is read for
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.
MC9S08AC16 Series Data Sheet, Rev. 0
92PRELIMINARYFreescale Semiconductor
Chapter 6 Parallel Input/Output
6.7.4Port B Pin Control Registers (PTBPE, PTBSE, PTBDS)
In addition to the I/O control, port B pins are controlled by the registers listed below.
76543210
R
W
Reset00000000
1
Bits 7 through 4 are reserved bits that must always be written to 0.
FieldDescription
RRRRPTBPE3PTBPE2PTBPE1PTBPE0
Figure 6-17. Internal Pullup Enable for Port B (PTBPE)
1
Table 6-8. PTBPE Register Field Descriptions
3:0
PTBPE[3:0]
R
W
Reset00000000
1
Bits 7 through 4 are reserved bits that must always be written to 0.
Internal Pullup Enable for Port B Bits — Each of these control bits determines if the internal pullup 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 pullup devices are disabled.
0 Internal pullup device disabled for port B bit n.
1 Internal pullup device enabled for port B bit n.
76543210
RRRRPTBSE3PTBSE2PTBSE1PTBSE0
Figure 6-18. Output Slew Rate Control Enable (PTBSE)
1
Table 6-9. PTBSE Register Field Descriptions
FieldDescription
3:0
PTBSE[3:0]
Output Slew Rate Control Enable for Port B Bits— Each of these control bits determine whether output slew
rate control 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.
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY93
Chapter 6 Parallel Input/Output
76543210
R
RRRRPTBDS3PTBDS2PTBDS1PTBDS0
W
Reset00000000
1
Figure 6-19. Internal Pullup Enable for Port B (PTBDS)
Bits 7 through 4 are reserved bits that must always be written to 0.
1
Table 6-10. PTBDS Register Field Descriptions
FieldDescription
3:0
PTBDS[3:0]
Output Drive Strength Selection for Port B Bits — Each of these control bits selects between low and high
output drive for the associated PTB pin.
0 Low output drive enabled for port B bit n.
1 High output drive enabled for port B bit n.
MC9S08AC16 Series Data Sheet, Rev. 0
94PRELIMINARYFreescale Semiconductor
Chapter 6 Parallel Input/Output
6.7.5Port C I/O Registers (PTCD and PTCDD)
Port C parallel I/O function is controlled by the registers listed below.
76543210
R0
W
Reset00000000
1
Bit 6 is a reserved bit that must always be written to 0.
FieldDescription
RPTCD5PTCD4PTCD3PTCD2PTCD1PTCD0
Figure 6-20. Port C Data Register (PTCD)
1
Table 6-11. PTCD Register Field Descriptions
5:0
PTCD[5:0]
R0
W
Reset00000000
1
Bit 6 is a reserved bit that must always be written to 0.
Port C Data Register Bits — For port C pins that are inputs, reads return the logic level on the pin. For port C
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.
76543210
RPTCDD5PTCDD4PTCDD3PTCDD2PTCDD1PTCDD0
Figure 6-21. Data Direction for Port C (PTCDD)
1
Table 6-12. PTCDD Register Field Descriptions
FieldDescription
5:0
PTCDD[5:0]
Data Direction for Port C Bits — These read/write bits control the direction of port C pins and what is read for
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.
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY95
Chapter 6 Parallel Input/Output
6.7.6Port C Pin Control Registers (PTCPE, PTCSE, PTCDS)
In addition to the I/O control, port C pins are controlled by the registers listed below.
76543210
R0
W
Reset00000000
1
Bit 6 is a reserved bit that must always be written to 0.
FieldDescription
RPTCPE5PTCPE4PTCPE3PTCPE2PTCPE1PTCPE0
Figure 6-22. Internal Pullup Enable for Port C (PTCPE)
1
Table 6-13. PTCPE Register Field Descriptions
5:0
PTCPE[5:0]
R0
W
Reset00000000
1
Bit 6 is a reserved bit that must always be written to 0.
Internal Pullup Enable for Port C Bits — Each of these control bits determines if the internal pullup 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 pullup devices are disabled.
0 Internal pullup device disabled for port C bit n.
1 Internal pullup device enabled for port C bit n.
76543210
RPTCSE5PTCSE4PTCSE3PTCSE2PTCSE1PTCSE0
Figure 6-23. Output Slew Rate Control Enable for Port C (PTCSE)
1
Table 6-14. PTCSE Register Field Descriptions
FieldDescription
5:0
PTCSE[5:0]
Output Slew Rate Control Enable for Port C Bits — Each of these control bits determine whether output slew
rate control 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.
MC9S08AC16 Series Data Sheet, Rev. 0
96PRELIMINARYFreescale Semiconductor
Chapter 6 Parallel Input/Output
76543210
R0
RPTCDS5PTCDS4PTCDS3PTCDS2PTCDS1PTCDS0
W
Reset00000000
1
Figure 6-24. Output Drive Strength Selection for Port C (PTCDS)
Bit 6 is a reserved bit that must always be written to 0.
1
Table 6-15. PTCDS Register Field Descriptions
FieldDescription
5:0
PTCDS[5:0]
Output Drive Strength Selection for Port C Bits — Each of these control bits selects between low and high
output drive for the associated PTC pin.
0 Low output drive enabled for port C bit n.
1 High output drive enabled for port C bit n.
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY97
Chapter 6 Parallel Input/Output
6.7.7Port D I/O Registers (PTDD and PTDDD)
Port D parallel I/O function is controlled by the registers listed below.
76543210
R
W
Reset00000000
1
Bits 7 through 4 are reserved bits that must always be written to 0.
FieldDescription
RRRRPTDD3PTDD2PTDD1PTDD0
Figure 6-25. Port D Data Register (PTDD)
1
Table 6-16. PTDD Register Field Descriptions
3:0
PTDD[3:0]
R
W
Reset00000000
1
Bits 7 through 4 are reserved bits that must always be written to 0.
Port D Data Register Bits — For port D pins that are inputs, reads return the logic level on the pin. For port D
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.
76543210
RRRRPTDDD3PTDDD2PTDDD1PTDDD0
Figure 6-26. Data Direction for Port D (PTDDD)
1
Table 6-17. PTDDD Register Field Descriptions
FieldDescription
3:0
PTDDD[3:0]
Data Direction for Port D Bits — These read/write bits control the direction of port D pins and what is read for
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.
MC9S08AC16 Series Data Sheet, Rev. 0
98PRELIMINARYFreescale Semiconductor
Chapter 6 Parallel Input/Output
6.7.8Port D Pin Control Registers (PTDPE, PTDSE, PTDDS)
In addition to the I/O control, port D pins are controlled by the registers listed below.
76543210
R
W
Reset00000000
1
Bits 7 through 4 are reserved bits that must always be written to 0.
FieldDescription
RRRRPTDPE3PTDPE2PTDPE1PTDPE0
Figure 6-27. Internal Pullup Enable for Port D (PTDPE)
1
Table 6-18. PTDPE Register Field Descriptions
3:0
PTDPE[3:0]
R
W
Reset00000000
1
Bits 7 through 4 are reserved bits that must always be written to 0.
Internal Pullup Enable for Port D Bits — Each of these control bits determines if the internal pullup 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 pullup devices are disabled.
0 Internal pullup device disabled for port D bit n.
1 Internal pullup device enabled for port D bit n.
76543210
RRRRPTDSE3PTDSE2PTDSE1PTDSE0
Figure 6-28. Output Slew Rate Control Enable for Port D (PTDSE)
1
Table 6-19. PTDSE Register Field Descriptions
FieldDescription
3:0
PTDSE[3:0]
Output Slew Rate Control Enable for Port D Bits — Each of these control bits determine whether output slew
rate control 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.
MC9S08AC16 Series Data Sheet, Rev. 0
Freescale SemiconductorPRELIMINARY99
Chapter 6 Parallel Input/Output
76543210
R
RRRRPTDDS3PTDDS2PTDDS1PTDDS0
W
Reset00000000
1
Figure 6-29. Output Drive Strength Selection for Port D (PTDDS)
Bits 7 through 4 are reserved bits that must always be written to 0.
1
Table 6-20. PTDDS Register Field Descriptions
FieldDescription
3:0
PTDDS[3:0]
Output Drive Strength Selection for Port D Bits — Each of these control bits selects between low and high
output drive for the associated PTD pin.
0 Low output drive enabled for port D bit n.
1 High output drive enabled for port D bit n.
MC9S08AC16 Series Data Sheet, Rev. 0
100PRELIMINARYFreescale Semiconductor
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.