Motorola reserves the right to make changes without further notice to
any products herein to improve reliability, function or design. Motorola
does not assume any liability arising out of the application or use of any
product or circuit described herein; neither does it convey any license
under its patent rights nor the rights of others. Motorola products are not
designed, intended, or authorized for use as components in systems
intendedforsurgicalimplant intothe body,or otherapplications intended
to support or sustain life, or for any other application in which the failure
of the Motorola product could create a situation where personal injury or
death may occur. Should Buyer purchase or use Motorola products for
any such unintended or unauthorized application, Buyer shall indemnify
and hold Motorola and its officers, employees, subsidiaries, affiliates,
and distributors harmless against all claims, costs, damages, and
expenses, and reasonable attorney fees arising out of, directly or
indirectly, any claim of personal injury or death associated with such
unintended or unauthorized use, even if such claim alleges that Motorola
was negligent regarding the design or manufacture of the part.
D-50PWM Frequency Ranges..............................................................................D-76
nc...
I
cale Semiconductor,
Frees
M68HC16 Z SERIESMOTOROLA
USER’S MANUALxxiii
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
nc...
I
cale Semiconductor,
Frees
MOTOROLAM68HC16 Z SERIES
xxivUSER’S MANUAL
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
SECTION 1
INTRODUCTION
M68HC16 Z-series microcontrollers (including the MC68HC16Z1, MC68CM16Z1,
MC68CK16Z1, MC68HC16Z2, MC68HC16Z3, MC68HC16Z4, and MC68CK16Z4)
are high-speed 16-bit control units that are upwardly code compatible with M68HC11
controllers. All are members of the M68HC16 Family of modular microcontrollers.
M68HC16 microcontroller units (MCUs) are built from standard modules that interface
via a common internal bus. Standardization facilitates rapid development of devices
tailored for specific applications.
M68HC16 Z-series MCUs incorporate a number of different modules. Refer to Table
nc...
I
1-1 for information on the contents of a specific Z-series MCU. (
module is used in the MCU. All of these modules are interconnected by the intermodule bus (IMB).
X) indicates that the
cale Semiconductor,
Frees
Table 1-1 M68HC16 Z-Series MCUs
Modules
Central Processor Unit (CPU16)XXX—
Low-Power Central Processor
Unit (CPU16L)
System Integration Module (SIM)XXX—
Low-Power System Integration
Module (SIML)
Standby RAM (SRAM)1 Kbyte2 Kbytes4 Kbytes1 Kbyte
Masked ROM Module (MRM)—8 Kbytes8 Kbytes—
Analog-to-Digital Converter (ADC)XXXX
Queued Serial Module (QSM)XXX—
Multichannel Communication
Interface (MCCI)
General-Purpose Timer (GPT)XXXX
NOTES:
1. “C” designator indicates a 2.7V to 3.6V part; “M” indicates a fast reference frequency and “K” indicates a slow
reference frequency. “HC” stands for HCMOS.
MC68HC16Z1
MC68CK16Z1
MC68CM16Z1
———X
———X
———X
1
MC68HC16Z2MC68HC16Z3
1
MC68HC16Z4
MC68CK16Z4
1
The maximum system clock for M68HC16 Z-series MCUs can be either 16.78 MHz,
20.97 MHz, or 25.17 MHz. An internal phase-locked loop circuit synthesizes the system clock from a slow (typically 32.768 kHz) or fast (typically 4.194 MHz) reference, or
uses an external frequency source. Refer to Table 1-2 for information on which reference frequency is applied to a particular MCU. (
X) indicates the reference frequency
applicable to the MCU.
M68HC16 Z SERIESINTRODUCTIONMOTOROLA
USER’S MANUAL1-1
1. The nominal slow reference frequency is 32.768 kHz, but can range from
20 to 50 kHz. The nominal fast reference frequency is 4.194 MHz, but can
range from 1MHz to 6.25 MHz.
nc...
I
Slow
(32.768 kHz)
—X
(4.194 MHz)
1
Fast
System hardware and software allow changes in clock rate during operation. Because
the MCUs are a fully static design, register and memory contents are not affected by
clock rate changes.
cale Semiconductor,
Frees
High-density complementary metal-oxide semiconductor (HCMOS) architecture
makes the basic power consumption low. Power consumption can be minimized by
stopping the system clocks. The M68HC16 instruction set includes a low-power stop
(LPSTOP) command that efficiently implements this capability. Individual stop bits in
each module allow for selective power reduction.
Documentation for the Modular Microcontroller Family follows the modular construction of the devices in the product line. Each device has a comprehensive user’s manual that provides sufficient information for normal operation of the device. The user’s
manual is supplemented by module reference manuals that provide detailed information about module operation and applications. Refer to Motorola publication
Microcontroller Unit (AMCU) Literature
(BR1116/D) for a complete list of documenta-
Advanced
tion to supplement this manual.
MOTOROLAINTRODUCTIONM68HC16 Z SERIES
1-2USER’S MANUAL
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
SECTION 2
NOMENCLATURE
The following tables show the nomenclature used throughout the M68HC16 Z-series
manual.
2.1 Symbols and Operators
SymbolFunction
+Addition
-Subtraction (two’s complement) or negation
*Multiplication
nc...
I
cale Semiconductor,
/Division
>Greater
<Less
=Equal
≥Equal or greater
≤Equal or less
≠Not equal
•AND
✛Inclusive OR (OR)
⊕Exclusive OR (EOR)
NOTComplementation
:Concatenation
⇒Transferred
⇔Exchanged
±Sign bit; also used to show tolerance
«Sign extension
%Binary value
$Hexadecimal value
Frees
M68HC16 Z SERIESNOMENCLATUREMOTOROLA
USER’S MANUAL2-1
For More Information On This Product,
Go to: www.freescale.com
nc...
I
cale Semiconductor,
Frees
Freescale Semiconductor, Inc.
2.2 CPU16 Register Mnemonics
MnemonicRegister
AAccumulator A
AMAccumulator M
BAccumulator B
CCRCondition code register
DAccumulator D
EAccumulator E
EKExtended addressing extension field
HRMAC multiplier register
IRMAC multiplicand register
IXIndex register X
IYIndex register Y
IZIndex register Z
KAddress extension register
PCProgram counter
PKProgram counter extension field
SKStack pointer extension field
SPStack pointer
XKIndex register X extension field
YKIndex register Y extension field
ZKIndex register Z extension field
XMSKModulo addressing index register X mask
YMSKModulo addressing index register Y mask
SLPSTOP mode control bit
MVAM overflow flag
HHalf carry flag
EVAM extended overflow flag
NNegative flag
ZZero flag
VTwo’s complement overflow flag
CCarry/borrow flag
IPInterrupt priority field
SMSaturation mode control bit
MOTOROLANOMENCLATUREM68HC16 Z SERIES
2-2USER’S MANUAL
For More Information On This Product,
Go to: www.freescale.com
nc...
I
cale Semiconductor,
Frees
Freescale Semiconductor, Inc.
2.3 Register Mnemonics
MnemonicRegister
ADCMCRADC Module Configuration Register
ADCTESTADC Test Register
ADCTL[0:1]ADC Control Registers [0:1]
ADCSTATADC Status Register
CFORCGPT Compare Force Register
CREGSIM Test Module Control Register
CR[0:F]QSM Command RAM [0:F]
CSBARBTSIM Chip-Select Base Address Register Boot
CSBAR[0:10]SIM Chip-Select Base Address Registers [0:10]
TR[0:F]QSM Transmit RAM [0:F]
TSTMSRASIM Test Module Master Shift Register A
TSTMSRBSIM Test Module Master Shift Register B
TSTRCSIM Test Module Repetition Count Register
TSTSCSIM Test Module Shift Count Register
cale Semiconductor,
Frees
M68HC16 Z SERIESNOMENCLATUREMOTOROLA
USER’S MANUAL2-5
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
2.4 Conventions
Logic level one is the voltage that corresponds to a Boolean true (1) state.
Logic level zero is the voltage that corresponds to a Boolean false (0) state.
Set refers specifically to establishing logic level one on a bit or bits.
Clear refers specifically to establishing logic level zero on a bit or bits.
Asserted means that a signal is in active logic state. An active low signal changes
from logic level one to logic level zero when asserted, and an active high signal changes from logic level zero to logic level one.
Negated means that an asserted signal changes logic state. An active low signal
changes from logic level zero to logic level one when negated, and an active high signal changes from logic level one to logic level zero.
nc...
I
cale Semiconductor,
Frees
A specific mnemonic within a range is referred to by mnemonic and number. A15 is
bit 15 of accumulator A; ADDR7 is line 7 of the address bus; CSOR0 is chip-select option register 0. A range of mnemonics is referred to by mnemonic and the numbers
that define the range. VBR[4:0] are bits four to zero of the vector base register;
CSOR[0:5] are the first six chip-select option registers.
Parentheses are used to indicate the content of a register or memory location, rather
than the register or memory location itself. For example, (A) is the content of accumulator A. (M : M + 1) is the content of the word at address M.
LSB means least significant bit or bits. MSB means most significant bit or bits. References to low and high bytes are spelled out.
LSW means least significant word or words. MSW means most significant word or
words.
ADDR is the address bus. ADDR[7:0] are the eight LSB of the address bus.
DATA is the data bus. DATA[15:8] are the eight MSB of the data bus.
MOTOROLANOMENCLATUREM68HC16 Z SERIES
2-6USER’S MANUAL
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
SECTION 3
OVERVIEW
This section provides general information on M68HC16 Z-series MCUs. It lists features of each of the modules, shows device functional divisions and pin assignments,
summarizes signal and pin functions, discusses the intermodule bus, and provides
system memory maps. Timing and electrical specifications for the entire microcontroller and for individual modules are provided in APPENDIX A ELECTRICAL CHARAC-
TERISTICS. Comprehensive module register descriptions and memory maps are
provided in APPENDIX D REGISTER SUMMARY.
3.1 M68HC16 Z-Series MCU Features
nc...
I
cale Semiconductor,
Frees
The following paragraphs highlight capabilities of each of the MCU modules. Each
module is discussed separately in a subsequent section of this manual.
3.1.1 Central Processor Unit (CPU16/CPU16L)
• 16-bit architecture
• Full set of 16-bit instructions
• Three 16-bit index registers
• Two 16-bit accumulators
• Control-oriented digital signal processing capability
• Addresses up to 1 Mbyte of program memory; 1 Mbyte of data memory
• Background debug mode
• Fully static operation
• Expanded LPSTOP operation on CPU16L (MC68HC16Z4, MC68CK16Z4 only)
3.1.2 System Integration Module (SIM/SIML)
• External bus support
• Programmable chip-select outputs
• System protection logic
• Watchdog timer, clock monitor, and bus monitor
• Two 8-bit dual function input/output ports
• One 7-bit dual function output port
• Phase-locked loop (PLL) clock system
• Expanded LPSTOP operation on SIML (MC68HC16Z4, MC68CK16Z4 only)
3.1.3 Standby RAM (SRAM)
• 1-Kbyte static RAM (MC68HC16Z1/Z4 only)
• 2-Kbyte static RAM (MC68HC16Z2 only)
• 4-Kbyte static RAM (MC68HC16Z3 only)
• External standby voltage supply input
M68HC16 Z SERIESOVERVIEWMOTOROLA
USER’S MANUAL3-1
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
3.1.4 Masked ROM Module (MRM) — (MC68HC16Z2/Z3 Only)
• 8-Kbyte array, accessible as bytes or words
• User-selectable default base address
• User-selectable bootstrap ROM function
• User-selectable ROM verification code
3.1.5 Analog-to-Digital Converter (ADC)
• Eight channels, eight result registers
• Eight automated modes
• Three result alignment modes
3.1.6 Queued Serial Module (QSM)
• Enhanced serial communication interface
• Queued serial peripheral interface
nc...
I
3.1.7 Multichannel Communication Interface (MCCI) — (MC68HC16Z4/CKZ4 Only)
• One 8-bit dual function port
cale Semiconductor,
Frees
• Two channels of enhanced SCI (UART)
• One channel of SPI
3.1.8 General-Purpose Timer (GPT)
• Two 16-bit free-running counters with prescaler
• Three input capture channels
• Four output compare channels
• One input capture/output compare channel
• One pulse accumulator/event counter input
• Two pulse width modulation outputs
• Optional external clock input
3.2 Intermodule Bus
The intermodule bus (IMB) is a standardized bus developed to facilitate the design of
modular microcontrollers. It contains circuitry that supports exception processing, address space partitioning, multiple interrupt levels, and vectored interrupts. The standardized modules in M68HC16 Z-series MCUs communicate with one another via the
IMB. Although the full IMB supports 24 address and 16 data lines, M68HC16 Z-series
MCUs use only 20 address lines. ADDR[23:20] follow the state of ADDR19.
3.3 System Block Diagram and Pin Assignment Diagrams
Figure 3-1 is a functional diagram of the MC68HC16Z1/CKZ1/CMZ1 MCU. Refer to
Figure 3-2 for a functional diagram of the MC68HC16Z2/Z3 MCU. Figure 3-3 is a
functional diagram of the MC68HC16Z4/CKZ4 MCU. Although diagram blocks represent the relative size of the physical modules, there is not a one-to-one correspondence between location and size of blocks in the diagram and location and size of
integrated-circuit modules.
MOTOROLAOVERVIEWM68HC16 Z SERIES
3-2USER’S MANUAL
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
M68HC16 Z-series microcontrollers are available in both 132- and 144-pin packages.
Figure 3-4 shows an MC68HC16Z1/CKZ1/CMZ1/Z2/Z3 pin assignment drawing
based ona 132-pinplastic surface-mountpackage. Figure3-5 showsan
MC68HC16Z1/CKZ1/CMZ1/Z2/Z3 pin assignment drawing based on a 144-pin plastic
surface-mount package. Figure 3-6 shows an MC68HC16Z4/CKZ4 pin assignment
drawing based on a 132-pin plastic surface-mount package. Figure 3-7 shows an
MC68HC16Z4/CKZ4 pin assignment drawing based on a 144-pin plastic surfacemount package. Refer to APPENDIX B MECHANICAL DATA AND ORDERING IN-
FORMATION for information on how to obtain package dimensions. Refer to subse-
quent paragraphs in this section for pin and signal descriptions.
Figure 3-7 MC68HC16Z4/CKZ4 Pin Assignments for 144-Pin Package
MOTOROLAOVERVIEWM68HC16 Z SERIES
3-10USER’S MANUAL
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
3.4 Pin Descriptions
The following tables are a summary of the functional characteristics of M68HC16 Zseries MCU pins. Table 3-1 shows all inputs and outputs. Digital inputs and outputs
use CMOS logic levels. An entry in the “Discrete I/O” column indicates that a pin can
also be used for general-purpose input, output, or both. The I/O port designation is given when it applies. Refer to Figure 3-1 for port organization. Table 3-2 shows types
of output drivers. Table 3-3 shows characteristics of power pins.
Table 3-1 M68HC16 Z-Series Pin Characteristics
nc...
I
cale Semiconductor,
Frees
Pin
Mnemonic
ADDR23/
ADDR[22:19]/
CS10/ECLKAYNO—
CS[9:6]AYNOPC[6:3]
ADDR[18:0]AYN——
1
AN[7:0]
ASBYYI/OPE5
AVECBYNI/OPE2
BERRBYN——
BG/CS1B————
BGACK/CS2BYN——
BKPT/DSCLK—YY——
BR/CS0BYNO—
CLKOUTA————
CSBOOTB————
DATA[15:0]
DSACK[1:0]BYNI/OPE[1:0]
DSI/IPIPE1AYY——
DSO/IPIPE0A————
EXTAL
FC[2:0]/CS[5:3]AYNOPC[2:0]
FREEZE/QUOTA————
HALTBoYN——
IC4/OC5AYYI/OPGP7
IC[3:1]AYYI/OPGP[2:0]
IRQ[7:1]BYYI/OPF[7:1]
MISOBoYYI/OPQS0
MISO
MODCLK
MOSIBoYYI/OPQS1
MOSI
OC[4:1]AYYI/OPGP[6:3]
PAI
1
DSBYYI/OPE4
2
3
1
3
4
Output
Driver
—YNIPADA[7:0]
AWYN——
——Special——
BoYYI/OPMC0
BYNI/OPF0
BoYYI/OPMC1
—Y Y I —
Input
Synchronized
Input
Hysteresis
Discrete
I/O
Designation
Port
M68HC16 Z SERIESOVERVIEWMOTOROLA
USER’S MANUAL3-11
1. DATA[15:0] are synchronized during reset only. MODCLK, QSM, MCCI and ADC pins are synchronized
only when used as input port pins.
2. EXTAL, XFC, and XTAL are clock reference connections.
3. MCCI pins used only on the MC68HC16Z4/CK16Z4.
4. PAI and PCLK can be used for discrete input, but are not part of an I/O port.
5. PWMA and PWMB can be used for discrete output, but are not part of an I/O port.
5
3
3
3
3
3
3
2
2
Output
Driver
—Y Y I —
A— — O—
BoYY—PMC6
BoYY—PMC4
BoYY—PMC2
BoYY—PMC3
BoYY—PMC7
BoYY—PMC5
———Special—
———Special—
Input
Synchronized
Input
Hysteresis
Discrete
I/O
Designation
Table 3-2 M68HC16 Z-Series Driver Types
TypeI/ODescription
AOThree-state capable output signals
AwOType A output with weak p-channel pull-up during reset
BO
BoOType B output that can be operated in an open-drain mode
Three-state output that includes circuitry to pull up output before high impedance is established,
to ensure rapid rise time
Port
MOTOROLAOVERVIEWM68HC16 Z SERIES
3-12USER’S MANUAL
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
Table 3-3 M68HC16 Z-Series Power Connections
Pin MnemonicDescription
V
STBY
V
DDSYN
V
DDA/VSSA
V
RH/VRL
V
SS/VDD
Standby RAM power
Clock synthesizer power
A/D converter power
A/D reference voltage
Microcontroller power
3.5 Signal Descriptions
The following tables define the M68HC16 Z-series MCU signals. Table 3-4 shows signal origin, type, and active state. Table 3-5 describes signal functions. Both tables are
sorted alphabetically by mnemonic. MCU pins often have multiple functions. More
than one description can apply to a pin.
MOTOROLAOVERVIEWM68HC16 Z SERIES
3-14USER’S MANUAL
For More Information On This Product,
Go to: www.freescale.com
nc...
I
cale Semiconductor,
Frees
Freescale Semiconductor, Inc.
Table 3-5 M68HC16 Z-Series Signal Function
MnemonicSignal NameFunction
ADDR[19:0]Address Bus20-bit address bus used by CPU16
AN[7:0]ADC Analog InputInputs to ADC multiplexer
ASAddress StrobeIndicates that a valid address is on the address bus
AVECAutovectorRequests an automatic vector during interrupt acknowledge
BERRBus ErrorIndicates that a bus error has occurred
BGBus GrantIndicates that the MCU has relinquished the bus
BGACK
BKPTBreakpointSignals a hardware breakpoint to the CPU
BRBus RequestIndicates that an external device requires bus mastership
CLKOUTSystem ClockoutSystem clock output
CS[10:0]Chip-SelectsSelect external devices at programmed addresses
CSBOOTBoot Chip SelectChip select for external boot start-up ROM
DATA[15:0]Data Bus16-bit data bus
DSData Strobe
DSACK[1:0]
DSI, DSO,
DSCLK
EXTAL, XTALCrystal Oscillator
FC[2:0]Function CodesIdentify processor state and current address space
FREEZEFreezeIndicates that the CPU has entered background mode
HALTHaltSuspend external bus activity
IRQ[7:1]Interrupt Request LevelProvides an interrupt priority level to the CPU
Indicates that an external device has assumed bus mastership
During a read cycle, indicates that an external device should
place valid data on the data bus. During a write cycle, indicates
that valid data is on the data bus.
Provide asynchronous data transfers and dynamic bus sizing
Serial I/O and clock for background debug mode
Connections for clock synthesizer circuit reference a crystal or
an external oscillator can be used
Serial input to QSPI in master mode; serial output from QSPIin
slave mode
Serial input to SPI in master mode; serial output from SPI in
slave mode
Serial output from QSPI in master mode; serial input to QSPIin
slave mode
Serial output from SPI in master mode; serial input to SPI in
slave mode
M68HC16 Z SERIESOVERVIEWMOTOROLA
USER’S MANUAL3-15
For More Information On This Product,
Go to: www.freescale.com
nc...
I
cale Semiconductor,
Frees
Freescale Semiconductor, Inc.
Table 3-5 M68HC16 Z-Series Signal Function (Continued)
MnemonicSignal NameFunction
PF[7:0]Port FPort F digital I/O port signals
PGP[7:0]Port GPGPT digital I/O port signals
PQS[7:0]Port QSQSM digital I/O port signals
PWMA, PWMBPulse Width ModulationOutput for PWM
QUOTQuotient OutProvides the quotient bit of the polynomial divider
WRead/WriteIndicates the direction of data transfer on the bus
R/
RESETResetSystem reset
RXDReceive Data (SCI)Serial input to the SCI
1
RXDA
1
RXDB
SCKSerial Clock (QSPI)
1
SCK
SIZ[1:0]Size
SSSlave Select (QSPI)
1
SS
TSCThree-State ControlPlaces all output drivers in a high-impedance state
TXDSCI Transmit DataSerial output from the SCI
1
TXDA
1
TXDB
XFCExternal Filter CapacitorConnection for external phase-locked loop filter capacitor
NOTES:
1. MCCI signals present only in MC68HC16Z4/CK16Z4.
SCI A Receive DataSerial input from SCI A
SCI B Receive DataSerial input from SCI B
Clock output from QSPI in master mode; clock input to QSPI in
slave mode
Serial Clock (SPI)
Slave Select (SPI)
SCI A Transmit DataSerial output from SCI A
SCI B Transmit DataSerial output from SCI B
Clock output from SPI in master mode; clock input to SPI in
slave mode
Indicates the number of bytes to be transferred during a bus
cycle
Causes serial transmission when QSPI is in slave mode;
causes mode fault in master mode
Causes serial transmission when the SPI is in slave mode;
causes mode fault in master mode
3.6 Internal Register Map
In Figures 3-8, 3-9, and 3-10, IMB ADDR[23:20] are represented by the letter Y. The
value represented by Y determines the base address of MCU module control registers. Y is equal to M111, where M is the logic state of the module mapping (MM) bit in
the system integration module configuration register (SIMCR). Since the CPU16 uses
only ADDR[19:0], and ADDR[23:20] follow the logic state of ADDR19 when CPU driven, the CPU cannot access IMB addresses from $080000 to $F7FFFF. In order for the
MCU to function correctly, MM must be set (Y must equal $F). If M is cleared, internal
registers are mapped to base address $700000, and are inaccessible until a reset occurs. The SRAM array is positioned by a base address register in the SRAM CTRL
block. Unimplemented blocks are mapped externally.
MOTOROLAOVERVIEWM68HC16 Z SERIES
3-16USER’S MANUAL
For More Information On This Product,
Go to: www.freescale.com
$000000
$YFF700
$YFF73F
Freescale Semiconductor, Inc.
ADC
64 BYTES
$YFF900
$YFF93F
$YFFA00
$YFFA7F
$YFFB00
$YFFB07
$YFFC00
nc...
I
$YFFDFF
$FFFFFF
Figure 3-8 MC68HC16Z1/CKZ1/CMZ1 Address Map
cale Semiconductor,
GPT
64 BYTES
SIM
128 BYTES
SRAM CONTROL
8 BYTES
QSM
512 BYTES
1K SRAM ARRAY
(MAPPED TO 1K BOUNDARY)
HC16Z1/CKZ1/CMZ1 ADDRESS MAP
Frees
M68HC16 Z SERIESOVERVIEWMOTOROLA
USER’S MANUAL3-17
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
$000000
$YFF700
$YFF73F
$YFF820
$YFF83F
$YFF900
$YFF93F
$YFFA00
$YFFA7F
$YFFB00
$YFFB07
$YFFC00
nc...
I
SRAM CONTROL
ADC
64 BYTES
ROM CONTROL
32 BYTES
GPT
64 BYTES
SIM
128 BYTES
8 BYTES
QSM
512 BYTES
8K ROM ARRAY
(MAPPED TO 8K BOUNDARY)
2K SRAM ARRAY
(MAPPED TO 2K BOUNDARY)
Z2 ONLY
4K SRAM ARRAY
(MAPPED TO 4K BOUNDARY)
Z3 ONLY
cale Semiconductor,
Frees
$YFFDFF
$FFFFFF
$000000
$YFF700
$YFF73F
$YFF900
$YFF93F
$YFFA00
$YFFA7F
$YFFB00
$YFFB07
$YFFC00
$YFFC3F
Figure 3-9 MC68HC16Z2/Z3 Address Map
ADC
64 BYTES
GPT
64 BYTES
SIML
128 BYTES
SRAM CONTROL
8 BYTES
MCCI
64 BYTES
1K SRAM ARRAY
(MAPPED TO 1K BOUNDARY)
HC16Z2/Z3 ADDRESS MAP
$FFFFFF
HC16Z4/CKZ4 ADDRESS MAP
Figure 3-10 MC68HC16Z4/CKZ4 Address Map
MOTOROLAOVERVIEWM68HC16 Z SERIES
3-18USER’S MANUAL
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
3.7 Address Space Maps
Figures 3-11 through 3-16 show CPU16 address space for M68HC16 Z-series MCUs.
Address space can be split into physically distinct program and data spaces by decoding the MCU function code outputs.
Figures 3-11, 3-12, and 3-13 show the memory map of a system that has combined
program and data spaces. Figures 3-14, 3-15, and 3-16 show the memory map when
MCU function code outputs are decoded.
Reset and exception vectors are mapped into bank 0 and cannot be relocated. The
CPU16 program counter, stack pointer, and Z index register can be initialized to any
address in pseudolinear memory, but exception vectors are limited to 16-bit addresses. To access locations outside of bank 0 during exception handler routines (including
interrupt exceptions), a jump table must be used. Refer to SECTION 4 CENTRAL
PROCESSOR UNIT for more information concerning memory management, extend-
ed addressing, and exception processing. Refer to SECTION 5 SYSTEM INTEGRA-
nc...
I
TION MODULE for more information concerning function codes, address space types,
resets, and interrupts.
cale Semiconductor,
Frees
M68HC16 Z SERIESOVERVIEWMOTOROLA
USER’S MANUAL3-19
1. THE ADDRESSES DISPLAYED IN THIS MEMORY MAP ARE THE FULL 24-BIT IMB ADDRESSES. THE CPU16
ADDRESS BUS IS 20 BITS WIDE, AND CPU16 ADDRESS LINE 19 DRIVES IMB ADDRESS LINES [23:20]. THE
BLOCK OF ADDRESSES FROM $080000 TO $F7FFFF MARKED AS UNDEFINED WILL NEVER APPEAR ON THE
IMB. MEMORY BANKS 0 TO 15 APPEAR FULLY CONTIGUOUS IN THE CPU16’S FLAT 20-BIT ADDRESS SPACE.
THE CPU16 NEED ONLY GENERATE A 20-BIT EFFECTIVE ADDRESS TO ACCESS ANY LOCATION IN THIS RANGE.
HC16Z1/CK/CM MEM MAP (C)
Figure 3-11 MC68HC16Z1/CKZ1/CMZ1 Combined Program and Data Space Map
MOTOROLAOVERVIEWM68HC16 Z SERIES
3-20USER’S MANUAL
1. THE ADDRESSES DISPLAYED IN THIS MEMORY MAP ARE THE FULL 24-BIT IMB ADDRESSES. THE CPU16
ADDRESS BUS IS 20 BITS WIDE, AND CPU16 ADDRESS LINE 19 DRIVES IMB ADDRESS LINES [23:20]. THE
BLOCK OF ADDRESSES FROM $080000 TO $F7FFFF MARKED AS UNDEFINED WILL NEVER APPEAR ON THE
IMB. MEMORY BANKS 0 TO 15 APPEAR FULLY CONTIGUOUS IN THE CPU16’S FLAT 20-BIT ADDRESS SPACE.
THE CPU16 NEED ONLY GENERATE A 20-BIT EFFECTIVE ADDRESS TO ACCESS ANY LOCATION IN THIS RANGE.
HC16 Z2/Z3 MEM MAP (C)
Figure 3-12 MC68HC16Z2/Z3 Combined Program and Data Space Map
M68HC16 Z SERIESOVERVIEWMOTOROLA
USER’S MANUAL3-21
1. THE ADDRESSES DISPLAYED IN THIS MEMORY MAP ARE THE FULL 24-BIT IMB ADDRESSES. THE CPU16
ADDRESS BUS IS 20 BITS WIDE, AND CPU16 ADDRESS LINE 19 DRIVES IMB ADDRESS LINES [23:20]. THE
BLOCK OF ADDRESSES FROM $080000 TO $F7FFFF MARKED AS UNDEFINED WILL NEVER APPEAR ON THE
IMB. MEMORY BANKS 0 TO 15 APPEAR FULLY CONTIGUOUS IN THE CPU16’S FLAT 20-BIT ADDRESS SPACE.
THE CPU16 NEED ONLY GENERATE A 20-BIT EFFECTIVE ADDRESS TO ACCESS ANY LOCATION IN THIS RANGE.
HC16Z4/CKZ4 MEM MAP (C)
Figure 3-13 MC68HC16Z4/CKZ4 Combined Program and Data Space Map
MOTOROLAOVERVIEWM68HC16 Z SERIES
3-22USER’S MANUAL
1. THE ADDRESSES DISPLAYED IN THIS MEMORY MAP ARE THE FULL 24-BIT IMB ADDRESSES. THE CPU16
ADDRESS BUS IS 20 BITS WIDE, AND CPU16 ADDRESS LINE 19 DRIVES IMB ADDRESS LINES [23:20]. THE
BLOCK OF ADDRESSES FROM $080000 TO $F7FFFF MARKED AS UNDEFINED WILL NEVER APPEAR ON THE
IMB. MEMORY BANKS 0 TO 15 APPEAR FULLY CONTIGUOUS IN THE CPU16’S FLAT 20-BIT ADDRESS SPACE.
THE CPU16 NEED ONLY GENERATE A 20-BIT EFFECTIVE ADDRESS TO ACCESS ANY LOCATION IN THIS RANGE.
QSM
BANK 15
INTERNAL REGISTERS
$FF0000
$FFFFFF
HC16Z1/CK/CM MEM MAP (S)
Figure 3-14 MC68HC16Z1/CKZ1/CMZ1 Separate Program and Data Space Map
M68HC16 Z SERIESOVERVIEWMOTOROLA
USER’S MANUAL3-23
1. THE ADDRESSES DISPLAYED IN THIS MEMORY MAP ARE THE FULL 24-BIT IMB ADDRESSES. THE CPU16
ADDRESS BUS IS 20 BITS WIDE, AND CPU16 ADDRESS LINE 19 DRIVES IMB ADDRESS LINES [23:20]. THE
BLOCK OF ADDRESSES FROM $080000 TO $F7FFFF MARKED AS UNDEFINED WILL NEVER APPEAR ON THE
IMB. MEMORY BANKS 0 TO 15 APPEAR FULLY CONTIGUOUS IN THE CPU16’S FLAT 20-BIT ADDRESS SPACE.
THE CPU16 NEED ONLY GENERATE A 20-BIT EFFECTIVE ADDRESS TO ACCESS ANY LOCATION IN THIS RANGE.
HC16 Z2/Z3 MEM MAP (S)
Figure 3-15 MC68HC16Z2/Z3 Separate Program and Data Space Map
MOTOROLAOVERVIEWM68HC16 Z SERIES
3-24USER’S MANUAL
For More Information On This Product,
Go to: www.freescale.com
$000000
$000008
$010000
BANK 0
BANK 1
Freescale Semiconductor, Inc.
VECTOR
ADDRESS
0000
0002
0004
0006
VECTOR
NUMBER
0
RESET — INITIAL ZK, SK, AND PK
1
2
3
RESET — INITIAL PC
RESET — INITIAL SP
RESET — INITIAL IZ (DIRECT PAGE)
TYPE OF
EXCEPTION
BANK 0
EXCEPTION VECTORS
BANK 1
$000000
$000008
$010000
nc...
I
cale Semiconductor,
Frees
$020000
$030000
512 KBYTE
$040000
$050000
$060000
$070000
$07FFFF$07FFFF
$080000
UNDEFINED
$F7FFFF
$F80000
$F90000
$FA0000
$FB0000
512 KBYTE
$FC0000
$FD0000
$FE0000
$FF0000
$FFFFFF
VECTOR
BANK 2
BANK 3
BANK 4
BANK 5
BANK 6
PROGRAM
SPACE
BANK 7
UNDEFINED
1
0012–001C
0032–006E
0070–01FE
ADDRESS
0008
000A
000C
000E
0010
001E
0020
0022
0024
0026
0028
002A
002C
002E
0030
VECTOR
NUMBER
4
5
6
7
8
9–E
F
10
LEVEL 1 INTERRUPT AUTOVECTOR
11
LEVEL 2 INTERRUPT AUTOVECTOR
12
LEVEL 3 INTERRUPT AUTOVECTOR
13
LEVEL 4 INTERRUPT AUTOVECTOR
14
LEVEL 5 INTERRUPT AUTOVECTOR
15
LEVEL 6 INTERRUPT AUTOVECTOR
16
LEVEL 7 INTERRUPT AUTOVECTOR
17
18
19–37
38–FF
TYPE OF
EXCEPTION
BKPT (BREAKPOINT)
BERR (BUS ERROR)
SWI (SOFTWARE INTERRUPT)
ILLEGAL INSTRUCTION
DIVISION BY ZERO
UNASSIGNED, RESERVED
UNINITIALIZED INTERRUPT
UNASSIGNED, RESERVED
SPURIOUS INTERRUPT
UNASSIGNED, RESERVED
USER-DEFINED INTERRUPTS
BANK 2
BANK 3
BANK 4
BANK 5
BANK 6
DATA
SPACE
BANK 7
UNDEFINED
$YFF700
ADC
BANK 8
BANK 9
BANK 10
BANK 11
$YFF73F
$YFF900
$YFF93F
GPT
BANK 8
BANK 9
BANK 10
BANK 11
$YFFA00
BANK 12
SIML
BANK 12
$YFFA7F
BANK 13
BANK 14
$YFFB00
$YFFB07
$YFFC00
SRAM
(CONTROL)
BANK 13
BANK 14
$020000
$030000
$040000
$050000
$060000
$070000
$080000
UNDEFINED
$F7FFFF
$F80000
$F90000
$FA0000
$FB0000
$FC0000
$FD0000
$FE0000
1
MCCI
BANK 15
$YFFC3F
$YFFDFF
BANK 15
INTERNAL REGISTERS
$FF0000
$FFFFFF
NOTE:
1. THE ADDRESSES DISPLAYED IN THIS MEMORY MAP ARE THE FULL 24-BIT IMB ADDRESSES. THE CPU16
ADDRESS BUS IS 20 BITS WIDE, AND CPU16 ADDRESS LINE 19 DRIVES IMB ADDRESS LINES [23:20]. THE
BLOCK OF ADDRESSES FROM $080000 TO $F7FFFF MARKED AS UNDEFINED WILL NEVER APPEAR ON THE
IMB. MEMORY BANKS 0 TO 15 APPEAR FULLY CONTIGUOUS IN THE CPU16’S FLAT 20-BIT ADDRESS SPACE.
THE CPU16 NEED ONLY GENERATE A 20-BIT EFFECTIVE ADDRESS TO ACCESS ANY LOCATION IN THIS RANGE.
HC16Z4/CKZ4 MEM MAP (S)
Figure 3-16 MC68HC16Z4/CKZ4 Separate Program and Data Space Map
M68HC16 Z SERIESOVERVIEWMOTOROLA
USER’S MANUAL3-25
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
nc...
I
cale Semiconductor,
Frees
MOTOROLAOVERVIEWM68HC16 Z SERIES
3-26USER’S MANUAL
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
SECTION 4
CENTRAL PROCESSOR UNIT
This section is an overview of the central processor unit (CPU16). For detailed information, refer to the
4.1 General
The CPU16 provides compatibility with the M68HC11 CPU and also provides additional capabilities associated with 16- and 32-bit data sizes, 20-bit addressing, and digital
signal processing. CPU16 registers are an integral part of the CPU and are not addressed as memory locations.
CPU16 Reference Manual
(CPU16RM/AD).
nc...
I
cale Semiconductor,
Frees
The CPU16 treats all peripheral, I/O, and memory locations as parts of a linear one
Megabyte address space. There are no special instructions for I/O that are separate
from instructions for addressing memory. Address space is made up of sixteen 64Kbyte banks. Specialized bank addressing techniques and support registers provide
transparent access across bank boundaries.
The CPU16 interacts with external devices and with other modules within the microcontroller via a standardized bus and bus interface. There are bus protocols used for
memory and peripheral accesses, as well as for managing a hierarchy of interrupt
priorities.
4.2 Register Model
Figure 4-1 shows the CPU16 register model. Refer to the paragraphs that follow for a
detailed description of each register.
M68HC16 Z SERIESCENTRAL PROCESSOR UNITMOTOROLA
USER’S MANUAL4-1
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
16201508 7BIT POSITION
nc...
I
cale Semiconductor,
Frees
AB
D
E
XKIXINDEX REGISTER X
YKIYINDEX REGISTER Y
ZKIZINDEX REGISTER Z
SKSPSTACK POINTER SP
PKPCPROGRAM COUNTER PC
CCRPK
EKXKYKZK
K
SKSTACK EXTENSION FIELD SK
HR
IR
ACCUMULATORS A AND B
ACCUMULATOR D (A:B)
ACCUMULATOR E
CONDITION CODE REGISTER CCR
PC EXTENSION FIELD PK
ADDRESS EXTENSION REGISTER K
MAC MULTIPLIER REGISTER HR
MAC MULTIPLICAND REGISTER IR
AMMAC ACCUMULATOR MSB[35:16] AM
XMSK
AM
YMSKMAC XY MASK REGISTER
MAC ACCUMULATOR LSB[15:0] AM
CPU16 REGISTER MODEL
Figure 4-1 CPU16 Register Model
MOTOROLACENTRAL PROCESSOR UNITM68HC16 Z SERIES
4-2USER’S MANUAL
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
4.2.1 Accumulators
The CPU16 has two 8-bit accumulators (A and B) and one 16-bit accumulator (E). In
addition, accumulators A and B can be concatenated into a second 16-bit double accumulator (D).
Accumulators A, B, and D are general-purpose registers that hold operands and results during mathematical and data manipulation operations.
Accumulator E, which can be used in the same way as accumulator D, also extends
CPU16 capabilities. It allows more data to be held within the CPU16 during operations,
simplifies 32-bit arithmetic and digital signal processing, and provides a practical 16bit accumulator offset indexed addressing mode.
4.2.2 Index Registers
The CPU16 has three 16-bit index registers (IX, IY, and IZ). Each index register has
nc...
I
an associated 4-bit extension field (XK, YK, and ZK).
Concatenated registers and extension fields provide 20-bit indexed addressing and
support data structure functions anywhere in the CPU16 address space.
cale Semiconductor,
Frees
IX and IY can perform the same operations as M68HC11 registers of the same names,
but the CPU16 instruction set provides additional indexed operations.
IZ can perform the same operations as IX and IY. IZ also provides an additional indexed addressing capability that replaces M68HC11 direct addressing mode. Initial IZ
and ZK extension field values are included in the RESET exception vector, so that
ZK:IZ can be used as a direct page pointer out of reset.
4.2.3 Stack Pointer
The CPU16 stack pointer (SP) is 16 bits wide. An associated 4-bit extension field (SK)
provides 20-bit stack addressing.
Stack implementation in the CPU16 is from high to low memory. The stack grows
downward as it is filled. SK:SP are decremented each time data is pushed on the
stack, and incremented each time data is pulled from the stack.
SK:SP point to the next available stack address rather than to the address of the latest
stack entry. Although the stack pointer is normally incremented or decremented by
word address, it is possible to push and pull byte-sized data. Setting the stack pointer
to an odd value causes data misalignment, which reduces performance.
4.2.4 Program Counter
The CPU16 program counter (PC) is 16 bits wide. An associated 4-bit extension field
(PK) provides 20-bit program addressing.
CPU16 instructions are fetched from even word boundaries. Address line 0 always
has a value of zero during instruction fetches to ensure that instructions are fetched
from word-aligned addresses.
M68HC16 Z SERIESCENTRAL PROCESSOR UNITMOTOROLA
USER’S MANUAL4-3
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
4.2.5 Condition Code Register
The 16-bit condition code register is composed of two functional blocks. The eight
MSB, which correspond to the CCR on the M68HC11, contain the low-power stop control bit and processor status flags. The eight LSB contain the interrupt priority field, the
DSP saturation mode control bit, and the program counter address extension field.
Figure 4-2 shows the condition code register. Detailed descriptions of each status in-
dicator and field in the register follow the figure.
1514131211109876543210
SMVHEVNZVCIP[2:0]SMPK[3:0]
Figure 4-2 Condition Code Register
S — STOP Enable
nc...
I
0 = Stop clock when LPSTOP instruction is executed.
1 = Perform NOP when LPSTOP instruction is executed.
cale Semiconductor,
Frees
MV — Accumulator M overflow flag
MV is set when an overflow into AM35 has occurred.
H — Half Carry Flag
H is set when a carry from A3 or B3 occurs during BCD addition.
EV — Accumulator M Extension Overflow Flag
EV is set when an overflow into AM31 has occurred.
N — Negative Flag
N is set under the following conditions:
• When the MSB is set in the operand of a read operation.
• When the MSB is set in the result of a logic or arithmetic operation.
Z — Zero Flag
Z is set under the following conditions:
• When all bits are zero in the operand of a read operation.
• When all bits are zero in the result of a logic or arithmetic operation.
V — Overflow Flag
V is set when a two’s complement overflow occurs as the result of an operation.
C — Carry Flag
C is set when a carry or borrow occurs during an arithmetic operation. This flag is also
used during shift and rotate to facilitate multiple word operations.
IP[2:0] — Interrupt Priority Field
The priority value in this field (0 to 7) is used to mask interrupts.
MOTOROLACENTRAL PROCESSOR UNITM68HC16 Z SERIES
4-4USER’S MANUAL
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
SM — Saturate Mode Bit
When SM is set and either EV or MV is set, data read from AM using TMER or TMET
is given maximum positive or negative value, depending on the state of the AM sign
bit before overflow.
PK[3:0] — Program Counter Address Extension Field
This field is concatenated with the program counter to form a 20-bit address.
4.2.6 Address Extension Register and Address Extension Fields
There are six 4-bit address extension fields. EK, XK, YK, and ZK are contained by the
address extension register (K), PK is part of the CCR, and SK stands alone.
Extension fields are the bank portions of 20-bit concatenated bank:byte addresses
used in the CPU16 linear memory management scheme.
All extension fields except EK correspond directly to a register. XK, YK, and ZK extend
nc...
I
registers IX, IY, and IZ. PK extends the PC; and SK extends the SP. EK holds the four
MSB of the 20-bit address used by the extended addressing mode.
cale Semiconductor,
Frees
4.2.7 Multiply and Accumulate Registers
The multiply and accumulate (MAC) registers are part of a CPU submodule that performsrepetitive signed fractional multiplication and stores the cumulative result. These
operations are part of control-oriented digital signal processing.
There are four MAC registers. Register H contains the 16-bit signed fractional multiplier. Register I contains the 16-bit signed fractional multiplicand. Accumulator M is a
specialized 36-bit product accumulation register. XMSK and YMSK contain 8-bit mask
values used in modulo addressing.
The CPU16 has a special subset of signal processing instructions that manipulate the
MAC registers and perform signal processing calculations.
4.3 Memory Management
The CPU16 providesa 1-Mbyte address space. There are 16 banks within the address
space. Each bank is made up of 64 Kbytes addressed from $0000 to $FFFF. Banks
are selected by means of the address extension fields associated with individual
CPU16 registers.
In addition, address space can be split into discrete 1-Mbyte program and data spaces
by externally decoding the MCU’s function code outputs. When this technique is used,
instruction fetches and reset vector fetches access program space, while exception
vector fetches (other than for reset), data accesses, and stack accesses are made in
data space.
M68HC16 Z SERIESCENTRAL PROCESSOR UNITMOTOROLA
USER’S MANUAL4-5
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
4.3.1 Address Extension
All CPU16 resources used to generate addresses are effectively 20 bits wide. These
resources include the index registers, program counter, and stack pointer. All addressing modes use 20-bit addresses.
Twenty-bit addresses are formed from a 16-bit byte address generated by an individual CPU16 register and a 4-bit address extension contained in an associated extension field. The byte address corresponds to ADDR[15:0] and the address extension
corresponds to ADDR[19:16].
4.3.2 Extension Fields
Each of the six address extension fields is used for a different type of access. All but
EK are associated with particular CPU16 registers. There are several ways to manipulate extension fields and the address map. Refer to the
(CPU16RM/AD) for detailed information.
There are eight bits in a byte and 16 bits in a word. Bit set and clear instructions use
both byte and word operands. Bit test instructions use byte operands.
Negative integers are represented in two’s complement form. Four-bit signed integers,
packed two to a byte, are used only as X and Y offsets in MAC and RMAC operations.
32-bit integers are used only by extended multiply and divide instructions, and by the
associated LDED and STED instructions.
BCD numbers are packed, two digits per byte. BCD operations use byte operands.
Signed 16-bit fractions are used by the fractional multiplication instructions, and as
multiplicand and multiplier operands in the MAC unit. Bit 15 is the sign bit, and there
is an implied radix point between bits 15 and 14. There are 15 bits of magnitude. The
range of values is –1 ($8000) to 1 – 2
Signed 32-bit fractions are used only by the fractional multiplication and division instructions. Bit 31 is the sign bit. An implied radix point lies between bits 31 and 30.
There are 31 bits of magnitude. The range of values is –1 ($80000000) to 1 – 2
($7FFFFFFF).
MOTOROLACENTRAL PROCESSOR UNITM68HC16 Z SERIES
4-6USER’S MANUAL
For More Information On This Product,
Go to: www.freescale.com
-15
($7FFF).
-31
Freescale Semiconductor, Inc.
Signed 36-bit fixed-point numbers are used only by the MAC unit. Bit 35 is the sign bit.
Bits [34:31] are sign extension bits. There is an implied radix point between bits 31 and
30. There are 31 bits of magnitude, but use of the extension bits allows representation
of numbers in the range –16 ($800000000) to 15.999969482 ($7FFFFFFFF).
4.5 Memory Organization
Both program and data memory are divided into sixteen 64-Kbyte banks. Addressing
is linear. A 20-bit extended address can access any byte location in the appropriate
address space.
A word is composed of two consecutive bytes. A word address is normally an even
byte address. Byte 0 of a word has a lower 16-bit address than byte 1. Long words and
32-bit signed fractions consist of two consecutive words, and are normally accessed
at the address of byte 0 in word 0.
Instruction fetches always access word addresses. Word operands are normally ac-
nc...
I
cessed at even byte addresses, but can be accessed at odd byte addresses, with a
substantial performance penalty.
cale Semiconductor,
Frees
To permit compatibility with the M68HC11, misaligned word transfers and misaligned
stack accesses are allowed. Transferring a misaligned word requires two successive
byte transfer operations.
Figure 4-3 shows how each CPU16 data type is organized in memory. Consecutive
even addresses show size and alignment.
M68HC16 Z SERIESCENTRAL PROCESSOR UNITMOTOROLA
USER’S MANUAL4-7
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AddressType
$0000
$0002BYTE0BYTE1
$0004±X OFFSET±Y OFFSET±X OFFSET±Y OFFSET
$0006BCD1BCD0BCD1BCD0
$0008WORD 0
$000AWORD 1
$000CMSW LONG WORD 0
$000ELSW LONG WORD 0
$0010MSW LONG WORD 1
$0012LSW LONG WORD 1
$0014±⇐ (Radix Point)16-BIT SIGNED FRACTION 0
$0016±⇐ (Radix Point)16-BIT SIGNED FRACTION 1
nc...
I
$0018±⇐ (Radix Point)MSW 32-BIT SIGNED FRACTION 0
$001ALSW 32-BIT SIGNED FRACTION 00
$001C±⇐ (Radix Point)MSW 32-BIT SIGNED FRACTION 1
$001ELSW 32-BIT SIGNED FRACTION 10
The CPU16 uses nine types of addressing. There are one or more addressing modes
within each type. Table 4-1 shows the addressing modes.
MOTOROLACENTRAL PROCESSOR UNITM68HC16 Z SERIES
4-8USER’S MANUAL
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
Table 4-1 Addressing Modes
ModeMnemonicDescription
E,XIndex register X with accumulator E offset
Accumulator Offset
Extended
Immediate
Indexed 8-Bit
Indexed 16-Bit
nc...
I
Indexed 20-Bit
InherentINHInherent
Post-Modified IndexIXP
Relative
E,YIndex register Y with accumulator E offset
E,ZIndex register Z with accumulator E offset
EXTExtended
EXT2020-bit extended
IMM88-bit immediate
IMM1616-bit immediate
IND8, XIndex register X with unsigned 8-bit offset
IND8, YIndex register Y with unsigned 8-bit offset
IND8, ZIndex register Z with unsigned 8-bit offset
IND16, XIndex register X with signed 16-bit offset
IND16, YIndex register Y with signed 16-bit offset
IND16, ZIndex register Z with signed 16-bit offset
IND20, XIndex register X with signed 20-bit offset
IND20, YIndex register Y with signed 20-bit offset
IND20, ZIndex register Z with signed 20-bit offset
Signed 8-bit offset added to index register
X after effective address is used
REL88-bit relative
REL1616-bit relative
cale Semiconductor,
Frees
All modes generate ADDR[15:0]. This address is combined with ADDR[19:16] from an
operand or an extension field to form a 20-bit effective address.
NOTE
Access across 64-Kbyte address boundaries is transparent. ADDR[19:16] of the effective address are changed to make an access
across a bank boundary. Extension field values will not change as a
result of effective address computation.
4.6.1 Immediate Addressing Modes
In the immediate modes, an argument is contained in a byte or word immediately following the instruction. For IMM8 and IMM16 modes, the effective address is the address of the argument.
There are three specialized forms of IMM8 addressing.
• The AIS, AIX, AIY, AIZ, ADDD, and ADDE instructions decrease execution time
by sign-extending the 8-bit immediate operand to 16 bits, then adding it to an appropriate register.
• The MAC and RMAC instructions use an 8-bit immediate operand to specify two
signed 4-bit index register offsets.
• The PSHM and PULM instructions use an 8-bit immediate mask operand to indicate which registers must be pushed to or pulled from the stack.
M68HC16 Z SERIESCENTRAL PROCESSOR UNITMOTOROLA
USER’S MANUAL4-9
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
4.6.2 Extended Addressing Modes
Regular extended mode instructions contain ADDR[15:0] in the word following the opcode.The effective address is formedby concatenating the EK fieldand the 16-bit byte
address. EXT20 mode is used only by the JMP and JSR instructions. These instructions contain a 20-bit effective address that is zero-extended to 24 bits to give the instruction an even number of bytes.
4.6.3 Indexed Addressing Modes
In the indexed modes, registers IX, IY, and IZ, together with their associated extension
fields, are used to calculate the effective address.
For 8-bit indexed modes an 8-bit unsigned offset contained in the instruction is added
to the value contained in an index register and its extension field.
For 16-bit modes, a 16-bit signed offset contained in the instruction is added to the val-
nc...
I
ue contained in an index register and its extension field.
For 20-bit modes, a 20-bit signed offset (zero-extended to 24 bits) is added to the val-
ue contained inan index register. These modes are used for JMP and JSR instructions
only.
cale Semiconductor,
Frees
4.6.4 Inherent Addressing Mode
Inherent mode instructions use information directly available to the processor to determine the effective address. Operands, if any, are system resources and are thus not
fetched from memory.
4.6.5 Accumulator Offset Addressing Mode
Accumulator offset modes form an effective address by sign-extending the content of
accumulator E to 20 bits, then adding the result to an index register and its associated
extension field. This mode allows use of an index register and an accumulator within
a loop without corrupting accumulator D.
4.6.6 Relative Addressing Modes
Relative modes are used for branch and long branch instructions. If a branch condition
is satisfied, a byte or word signed two’s complement offset is added to the concatenated PK field and program counter. The new PK : PC value is the effective address.
4.6.7 Post-Modified Index Addressing Mode
Post-modified index mode is used by the MOVB and MOVW instructions. A signed 8bit offset is added to index register X after the effective address formed by XK : IX is
used.
MOTOROLACENTRAL PROCESSOR UNITM68HC16 Z SERIES
4-10USER’S MANUAL
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
4.6.8 Use of CPU16 Indexed Mode to Replace M68HC11 Direct Mode
In M68HC11 systems, the direct addressing mode can be used to perform rapid accesses to RAM or I/O mapped from $0000 to $00FF. The CPU16 uses the first 512
bytes of bank 0 for exception vectors. To provide an enhanced replacement for the
M68HC11’s direct addressing mode, the ZK field and index register Z have been assigned reset initialization vectors. By resetting the ZK field to a chosen page and using
indexed mode addressing, a programmer can access useful data structures anywhere
in the address map.
4.7 Instruction Set
The CPU16 instruction set is based on the M68HC11 instruction set, but the opcode
map has been rearranged to maximize performance with a 16-bit data bus. Most
M68HC11 code can run on the CPU16 following reassembly. The user must take into
accountchanged instruction times, the interrupt mask, andthe changed interrupt stack
frame (refer to
nc...
I
gramming Note M68HC16PN01/D, for more information).
Transporting M68HC11 Code to M68HC16 Devices
, Motorola Pro-
cale Semiconductor,
Frees
4.7.1 Instruction Set Summary
Table 4-2 is a quick reference to the entire CPU16 instruction set. Refer to the
Reference Manual
sembler syntax, and condition code evaluation. Table 4-3 provides a key to the table
nomenclature.
(CPU16RM/AD) for detailed information about each instruction, as-
CPU16
M68HC16 Z SERIESCENTRAL PROCESSOR UNITMOTOROLA
USER’S MANUAL4-11
CLREClear E$0000 ⇒ EINH2775—2— — — — 0100
CLRMClear AM$000000000⇒ AM[35:0]INH27B7—2—0—0 ————
CLRWClear a Word in
CMPACompare A toMemory(A) − (M)IND8, X
CMPBCompare B toMemory(B) − (M)IND8, X
COMOne’s Complement$FF − (M) ⇒ M, or
COMAOne’s Complement A$FF − (A) ⇒ A, or
COMBOne’s Complement B$FF − (B) ⇒ B, or
COMDOne’s Complement D $FFFF− (D) ⇒ D, or
COMEOne’s Complement E $FFFF − (E) ⇒ E, or
COMWOne’s Complement
Branch if Overflow
Clear
2
Branch if Overflow SetIf V = 1, branchREL8B9rr6, 2— — — — ————
Memory
Memory
Word
Push (PC)
(SK : SP) - 2 ⇒ SK : SP
Push (CCR)
(SK : SP) - 2 ⇒ SK : SP
(PK :PC) +Offset ⇒PK:PC
If V = 0, branchREL8B8rr6, 2— — — — ————
$00 ⇒ MIND8, X
$0000 ⇒ M : M+ 1IND16, X
M ⇒ MIND8, X
M ⇒ AINH3700—2— — — — ∆∆01
B ⇒ BINH3710—2— — — — ∆∆01
D ⇒ DINH27F0—2— — — — ∆∆01
E ⇒ EINH2770—2— — — — ∆∆01
$FFFF − M : M + 1⇒
M : M + 1, or (
M : M + 1) ⇒
M : M + 1
REL836rr10— — — — ————
————0100
IND8, Y
IND8, Z
IND16, X
IND16, Y
IND16, Z
EXT
IND16, Y
IND16, Z
EXT
IND8, Y
IND8, Z
IMM8
IND16, X
IND16, Y
IND16, Z
EXT
E, X
E, Y
E, Z
IND8, Y
IND8, Z
IMM8
IND16, X
IND16, Y
IND16, Z
EXT
E, X
E, Y
E, Z
IND8, Y
IND8, Z
IND16, X
IND16, Y
IND16, Z
EXT
IND16, X
IND16, Y
IND16, Z
EXT
05
15
25
1705
1715
1725
1735
2705
2715
2725
2735
48
58
68
78
1748
1758
1768
1778
2748
2758
2768
C8
D8
E8
F8
17C8
17D8
17E8
17F8
27C8
27D8
27E8
00
10
20
1700
1710
1720
1730
2700
2710
2720
2730
ff
ff
ff
gggg
gggg
gggg
hh ll
gggg
gggg
gggg
hh ll
ff
ff
ff
ii
gggg
gggg
gggg
hh ll
—
—
—
ff
ff
ff
ii
gggg
gggg
gggg
hh ll
—
—
—
ff
ff
ff
gggg
gggg
gggg
hh ll
gggg
gggg
gggg
hh ll
4
4
4
6
6
6
6
6
————0100
6
6
6
———— ∆∆∆∆
6
6
6
2
6
6
6
6
6
6
6
———— ∆∆∆∆
6
6
6
2
6
6
6
6
6
6
6
———— ∆∆01
8
8
8
8
8
8
8
8
———— ∆∆01
8
8
8
M68HC16 Z SERIESCENTRAL PROCESSING UNITMOTOROLA
USER’S MANUAL4-17
TABTransfer A to B(A) ⇒ BINH3717—2— — — — ∆∆0—
TAPTransfer A to CCR(A[7:0]) ⇒ CCR[15:8]INH37FD—4∆∆ ∆ ∆∆∆∆∆
TBATransfer B to A(B) ⇒ AINH3707—2— — — — ∆∆0—
TBEKTransfer B to EK(B[3:0]) ⇒ EKINH27FA—2— — — — ————
TBSKTransfer B to SK(B[3:0]) ⇒ SKINH379F—2— — — — ————
TBXKTransfer B to XK(B[3:0]) ⇒ XKINH379C—2— — — — ————
TBYKTransfer B to YK(B[3:0]) ⇒ YKINH379D—2— — — — ————
TBZKTransfer B to ZK(B[3:0]) ⇒ ZKINH379E—2— — — — ————
TDETransfer D to E(D) ⇒ EINH277B—2— — — — ∆∆0—
TDMSKTransfer D to
1
TDP
TEDTransfer E to D(E) ⇒ DINH27FB—2— — — — ∆∆0—
TEDMTransfer E and D to
TEKBTransfer EK to B(EK) ⇒ B[3:0]
TEMTransfer E to
TMERTransfer Rounded AM
XMSK : YMSK
Transfer D to CCR(D) ⇒ CCR[15:4]INH372D—4∆∆ ∆ ∆∆∆∆∆
AM[31:0]
Sign Extend AM
AM[31:16]
Sign Extend AM
Clear AM LSB
to E
Push (PC)
(SK : SP) −$0002 ⇒SK :SP
Push (CCR)
(SK : SP) −$0002 ⇒SK :SP
$0 ⇒ PK
SWI Vector ⇒ PC
then $FF ⇒A
else $00 ⇒A
(D[15:8]) ⇒ X MASK
(D[7:0]) ⇒ Y MASK
(E) ⇒ AM[31:16]
(D) ⇒ AM[15:0]
AM[35:32] = AM31
$0 ⇒ B[7:4]
(E) ⇒ AM[31:16]
$00 ⇒ AM[15:0]
AM[35:32] = AM31
Rounded (AM) ⇒ Temp
If (SM • (EV ✛ MV))
then Saturation Value ⇒ E
else Temp[31:16] ⇒ E
IND8, Y
IND8, Z
IMM8
IND16, X
IND16, Y
IND16, Z
EXT
E, X
E, Y
E, Z
IND8, Y
IND8, Z
IMM16
IND16, X
IND16, Y
IND16, Z
EXT
E, X
E, Y
E, Z
IND16, X
IND16, Y
IND16, Z
EXT
INH3720—16— — — — ————
INH27F8—2— — — — ∆∆——
INH372F—2— — — — ————
INH27B1—4— 0—0 ————
INH27BB—2— — — — ————
INH27B2—4— 0—0 ————
INH27B4—6— ∆— ∆∆∆——
C0
D0
E0
F0
17C0
17D0
17E0
17F0
27C0
27D0
27E0
80
90
A0
37B0
37C0
37D0
37E0
37F0
2780
2790
27A0
3730
3740
3750
3760
3770
ff
ff
ff
ii
gggg
gggg
gggg
hh ll
—
—
—
ff
ff
ff
jj kk
gggg
gggg
gggg
hh ll
—
—
—
jj kk
gggg
gggg
gggg
hh ll
6
6
6
2
6
6
6
6
6
6
6
———— ∆∆∆∆
6
6
6
4
6
6
6
6
6
6
6
———— ∆∆∆∆
4
6
6
6
6
M68HC16 Z SERIESCENTRAL PROCESSING UNITMOTOROLA
USER’S MANUAL4-27
TXSTransfer X to SP(XK : IX) − $0002⇒ SK : SPINH374E—2— — — — ————
TXYTransfer X to Y(XK : IX) ⇒ YK : IYINH275C—2— — — — ————
TXZTransfer X to Z(XK : IX) ⇒ ZK : IZINH276C—2— — — — ————
TYKBTransfer YK to B(YK) ⇒ B[3:0]
TYSTransfer Y to SP(YK : IY) − $0002⇒ SK : SPINH375E—2— — — — ————
TYXTransfer Y to X(YK : IY) ⇒ XK : IXINH274D—2— — — — ————
TYZTransfer Y to Z(YK : IY) ⇒ ZK : IZINH276D—2— — — — ————
TZKBTransfer ZK to B(ZK) ⇒ B[3:0]
TZSTransfer Z to SP(ZK : IZ) − $0002⇒ SK : SPINH376E—2— — — — ————
TZXTransfer Z to X(ZK : IZ) ⇒ XK : IXINH274E—2— — — — ————
TZYTransfer Z to Y(ZK : IZ) ⇒ YK : IYINH275E—2— — — — ————
WAIWait for InterruptWAITINH27F3—8— — — — ————
XGABExchange A with B(A) ⇔(B)INH371A—2— — — — ————
XGDEExchange D with E(D) ⇔(E)INH277A—2— — — — ————
XGDXExchange D with IX(D) ⇔ (IX)INH37CC—2— — — — ————
If (SM • (EV ✛ MV))
then Saturation Value ⇒ E
else AM[31:16] ⇒ E
AM[35:32] ⇒ IX[3:0]
AM35 ⇒ IX[15:4]
AM[31:16] ⇒ E
AM[15:0] ⇒ D
$0 ⇒ B[7:4]
(M) − $00IND8, X
(A) − $00INH3706—2— — — — ∆∆00
(B) − $00INH3716—2— — — — ∆∆00
(D) − $0000INH27F6—2— — — — ∆∆00
(E) − $0000INH2776—2— — — — ∆∆00
(M : M + 1)− $0000IND16, X
$0 ⇒ B[7:4]
$0 ⇒ B[7:4]
$0 ⇒ B[7:4]
INH27B5—2— — — — ∆∆——
INH27B3—6— — — — ————
INH37AF—2— — — — ————
———— ∆∆00
06
IND8, Y
IND8, Z
IND16, X
IND16, Y
IND16, Z
EXT
IND16, Y
IND16, Z
EXT
INH37AC—2— — — — ————
INH37AD—2— — — — ————
INH37AE—2— — — — ————
16
26
1706
1716
1726
1736
2706
2716
2726
2736
ff
ff
ff
gggg
gggg
gggg
hh ll
gggg
gggg
gggg
hh ll
6
6
6
6
6
6
6
6
———— ∆∆00
6
6
6
MOTOROLACENTRAL PROCESSING UNITM68HC16 Z SERIES
4-28USER’S MANUAL
XGDYExchange D with IY(D) ⇔ (IY)INH37DC—2— — — — ————
XGDZExchange D with IZ(D) ⇔(IZ)INH37EC—2— — — — ————
XGEXExchange E with IX(E) ⇔(IX)INH374C—2— — — — ————
XGEYExchange E with IY(E) ⇔(IY)INH375C—2— — — — ————
XGEZExchange E with IZ(E) ⇔ (IZ)INH376C—2— — — — ————
NOTES:
1. CCR[15:4] change according to the results of the operation. The PK field is not affected.
2. Cycle times for conditional branches are shown in “taken, not taken” order.
3. CCR[15:0] change according to the copy of the CCR pulled from the stack.
4. PK field changes according to the state pulled from the stack. The rest of the CCR is not affected.
nc...
I
cale Semiconductor,
Frees
M68HC16 Z SERIESCENTRAL PROCESSING UNITMOTOROLA
USER’S MANUAL4-29
For More Information On This Product,
Go to: www.freescale.com
nc...
I
cale Semiconductor,
Frees
Freescale Semiconductor, Inc.
Table 4-3 Instruction Set Abbreviations and Symbols
A — Accumulator A X — Register used in operation
AM — Accumulator MM — Address of one memory byte
B — Accumulator BM +1 — Address of byte at M + $0001
CCR — Condition code registerM : M + 1 — Address of one memory word
D — Accumulator D(…)X — Contents of address pointed to by IX
E — Accumulator E(...)Y — Contents of address pointed to by IY
EK — Extended addressing extension field(...)Z — Contents of address pointed to by IZ
IR — MAC multiplicand registerE, X — IX with E offset
HR — MAC multiplier registerE, Y — IY with E offset
IX — Index register XE, Z — IZ with E offset
IY — Index register YEXT — Extended
IZ — Index register ZEXT20 — 20-bit extended
K — Address extension registerIMM8 — 8-bit immediate
PC — Program counterIMM16 — 16-bit immediate
PK — Program counter extension fieldIND8, X — IX with unsigned 8-bit offset
SK — Stack pointer extension fieldIND8, Y — IY with unsigned 8-bit offset
SL — Multiply and accumulate sign latchIND8, Z — IZ with unsigned 8-bit offset
SP — Stack pointerIND16, X — IX with signed 16-bit offset
XK — Index register X extension fieldIND16, Y — IY with signed 16-bit offset
YK — Index register Y extension fieldIND16, Z — IZ with signed 16-bit offset
ZK — Index register Z extension fieldIND20, X — IX with signed 20-bit offset
XMSK — Modulo addressing index register X maskIND20, Y — IY with signed 20-bit offset
YMSK — Modulo addressing index register Y maskIND20, Z — IZ with signed 20-bit offset
S — Stop disable control bitINH — Inherent
MV — AM overflow indicatorIXP — Post-modified indexed
H — Half carry indicatorREL8 — 8-bit relative
EV — AM extended overflow indicatorREL16 — 16-bit relative
N — Negative indicatorb — 4-bit address extension
Z — Zero indicatorff — 8-bit unsigned offset
V — Two’s complement overflow indicatorgggg — 16-bit signed offset
C — Carry/borrow indicatorhh — High byte of 16-bit extended address
IP — Interrupt priority fieldii — 8-bit immediate data
SM — Saturation mode control bitjj — High byte of 16-bit immediate data
PK — Program counter extension fieldkk — Low byte of 16-bit immediate data
— — Bit not affectedll — Low byte of 16-bit extended address
∆ — Bit changes as specifiedmm — 8-bit mask
0 — Bit clearedmmmm — 16-bit mask
1 — Bit setrr — 8-bit unsigned relative offset
M — Memory location used in operationrrrr — 16-bit signed relative offset
R — Result of operationxo — MAC index register X offset
S — Source datayo — MAC index register Y offset
z — 4-bit zero extension
+ — Addition• — AND
− — Subtraction or negation (two’s complement)✛ — Inclusive OR (OR)
∗ — Multiplication ⊕ — Exclusive OR (EOR)
/ — Division
> — Greater : — Concatenation
< — Less ⇒ — Transferred
= — Equal⇔ — Exchanged
≥ — Equal or greater± — Sign bit; also used to show tolerance
≤ — Equal or less« — Sign extension
≠ — Not equal% — Binary value
NOT — Complementation
$ — Hexadecimal value
MOTOROLACENTRAL PROCESSING UNITM68HC16 Z SERIES
4-30USER’S MANUAL
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
4.8 Comparison of CPU16 and M68HC11 CPU Instruction Sets
Most M68HC11 CPU instructions are a source-code compatible subset of the CPU16
instruction set. However, certain M68HC11 CPU instructions have been replaced by
functionally equivalent CPU16 instructions, and some CPU16 instructions with the
same mnemonics as M68HC11 CPU instructions operate differently.
Table 4-4 shows the M68HC11 CPU instructions that either have been replaced by
CPU16 instructions or that operate differently on the CPU16. Replacement instructions are not identical to M68HC11 CPU instructions. M68HC11 code must be altered
to establish proper preconditions.
All CPU16 instruction execution times differ from those of the M68HC11.
M68HC11 Code to M68HC16 Devices
mation about differences between the two instruction sets. Refer to the
ence Manual
nc...
I
(CPU16RM/AD) for further details about CPU operations.
, (M68HC16PN01/D), contains detailed infor-
cale Semiconductor,
Transporting
CPU16 Refer-
Frees
M68HC16 Z SERIESCENTRAL PROCESSING UNITMOTOROLA
USER’S MANUAL4-31
For More Information On This Product,
Go to: www.freescale.com
nc...
I
cale Semiconductor,
Frees
Freescale Semiconductor, Inc.
Table 4-4 CPU16 Implementation of M68HC11 CPU Instructions
M68HC11 InstructionCPU16 Implementation
BHSBCC only
BLOBCS only
BSRGenerates a different stack frame
CLCReplaced by ANDP
CLIReplaced by ANDP
CLVReplaced by ANDP
DESReplaced by AIS
DEXReplaced by AIX
DEYReplaced by AIY
INSReplaced by AIS
INXReplaced by AIX
INYReplaced by AIY
JMPIND8 and EXT addressing modes replaced by IND20 and EXT20 modes
JSR
LSL, LSLDUse ASL instructions
PSHXReplaced by PSHM
PSHYReplaced by PSHM
PULXReplaced by PULM
PULYReplaced by PULM
RTIReloads PC and CCR only
RTSUses two-word stack frame
SECReplaced by ORP
SEIReplaced by ORP
SEVReplaced by ORP
STOPReplaced by LPSTOP
TAP
TPA
TSXAdds two to SK : SP before transfer to XK : IX
TSYAdds two to SK : SP before transfer to YK : IY
TXSSubtracts two from XK : IX before transfer to SK : SP
TXYTransfers XK field to YK field
TYSSubtracts two from YK : IY before transfer to SK : SP
TYXTransfers YK field to XK field
WAI
NOTES:
1. Motorola assemblers automatically translate ASL mnemonics.
IND8 and EXT addressingmodesreplacedbyIND20 and EXT20 modes.
Generates a different stack frame
1
CPU16 CCR bits differ from M68HC11
CPU16 interrupt priority scheme differs from M68HC11
CPU16 CCR bits differ from M68HC11
CPU16 interrupt priority scheme differs from M68HC11
Waits indefinitely for interrupt or reset
Generates a different stack frame
MOTOROLACENTRAL PROCESSING UNITM68HC16 Z SERIES
4-32USER’S MANUAL
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
4.9 Instruction Format
CPU16instructions consist of an 8-bitopcode that can be precededby an 8-bit prebyte
and followed by one or more operands.
Opcodes are mapped in four 256-instruction pages. Page 0 opcodes stand alone.
Page 1, 2, and 3 opcodes are pointed to by a prebyte code on page 0. The prebytes
are $17 (page 1), $27 (page 2), and $37 (page 3).
Operands can be four bits, eight bits or sixteen bits in length. Since the CPU16 fetches
16-bit instruction words from even-byte boundaries, each instruction must contain an
even number of bytes.
Operands are organized as bytes, words, or a combination of bytes and words. Operands of four bits are either zero-extended to eight bits, or packed two to a byte. The
largest instructions are six bytes in length. Size, order, and function of operands are
evaluated when an instruction is decoded.
nc...
I
cale Semiconductor,
Frees
A page 0 opcode and an 8-bit operand can be fetched simultaneously. Instructions
that use 8-bit indexed, immediate, and relative addressing modes have this form.
Code written with these instructions is very compact.
Figure 4-4 shows basic CPU16 instruction formats.
M68HC16 Z SERIESCENTRAL PROCESSING UNITMOTOROLA
USER’S MANUAL4-33
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
8-Bit Opcode with 8-Bit Operand
1514131211109876543210
OpcodeOperand
8-Bit Opcode with 4-Bit Index Extensions
1514131211109876543210
OpcodeX ExtensionY Extension
8-Bit Opcode, Argument(s)
1514131211109876543210
OpcodeOperand
Operand(s)
Operand(s)
8-Bit Opcode with 8-Bit Prebyte, No Argument
1514131211109876543210
nc...
I
8-Bit Opcode with 8-Bit Prebyte, Argument(s)
1514131211109876543210
PrebyteOpcode
PrebyteOpcode
Operand(s)
Operand(s)
cale Semiconductor,
Frees
8-Bit Opcode with 20-Bit Argument
1514131211109876543210
Opcode$0Extension
Operand
Figure 4-4 Basic Instruction Formats
4.10 Execution Model
This description builds up a conceptual model of the mechanism the CPU16 uses to
fetch and execute instructions. The functional divisions in the model do not necessarily
correspond to physical subunits of the microprocessor.
As shown in Figure 4-5, there are three functional blocks involved in fetching, decoding, and executing instructions. These are the microsequencer, the instruction pipeline, and the execution unit. These elements function concurrently. All three may be
active at any given time.
MOTOROLACENTRAL PROCESSING UNITM68HC16 Z SERIES
4-34USER’S MANUAL
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
nc...
I
cale Semiconductor,
Frees
IPIPE0
IPIPE1
DATA
BUS
A
MICROSEQUENCER
INSTRUCTION PIPELINE
B
EXECUTION UNIT
C
16 EXEC UNIT MODEL
Figure 4-5 Instruction Execution Model
4.10.1 Microsequencer
The microsequencer controls the order in which instructions are fetched, advanced
through the pipeline, and executed. It increments the program counter and generates
multiplexed external tracking signals IPIPE0 and IPIPE1 from internal signals that control execution sequence.
4.10.2 Instruction Pipeline
The pipeline is a three stage FIFO that holds instructions while they are decoded and
executed. Depending upon instruction size, as many as three instructions can be in
the pipeline at one time (single-word instructions, one held in stage C, one being executed in stage B, and one latched in stage A).
4.10.3 Execution Unit
The execution unit evaluates opcodes, interfaces with the microsequencer to advance
instructions through the pipeline, and performs instruction operations.
M68HC16 Z SERIESCENTRAL PROCESSING UNITMOTOROLA
USER’S MANUAL4-35
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
4.11 Execution Process
Fetched opcodes are latched into stage A, then advanced to stage B. Opcodes are
evaluated in stage B. The execution unit can access operands in either stage A or
stage B (stage B accesses are limited to 8-bit operands). When execution is complete,
opcodes are moved from stage B to stage C, where they remain until the next instruction is complete.
A prefetch mechanism in the microsequencer reads instruction words from memory
and increments the program counter. When instruction execution begins, the program
counter points to an address six bytes after the address of the first word of the instruction being executed.
The number of machine cycles necessary to complete an execution sequence varies
according to the complexity of the instruction. Refer to the
(CPU16RM/AD) for details.
CPU16 Reference Manual
nc...
I
cale Semiconductor,
Frees
4.11.1 Changes in Program Flow
When program flow changes, instructions are fetched from a new address. Before execution can begin at the new address, instructions and operands from the previous instruction stream must be removed from the pipeline. If a change in flow is temporary,
a return address must be stored, so that execution of the original instruction stream
can resume after the change in flow.
When an instruction that causes a change in program flow executes, PK : PC point to
the address of the first word of the instruction + $0006. During execution of the instruction, PK : PC is loaded with the address of the first instruction word in the new instruction stream. However, stages A and B still contain words from the old instruction
stream. Extra processing steps must be performed before execution from the new instruction stream.
4.12 Instruction Timing
The execution time of CPU16 instructions has three components:
• Bus cycles required to prefetch the next instruction
• Bus cycles required for operand accesses
• Time required for internal operations
A bus cycle requires a minimum of two system clock periods. If the access time of a
memory device is greater than two clock periods, bus cycles are longer. However, all
bus cycles must be an integer number of clock periods. CPU16 internal operations are
always an integer multiple of two clock periods.
Dynamic bus sizing affects bus cycle time. The integration module manages all accesses. Refer to SECTION 5 SYSTEM INTEGRATION MODULE for more information.
The CPU16 does not execute more than one instruction at a time. The total time required to execute a particular instruction stream can be calculated by summing the individual execution times of each instruction in the stream.
MOTOROLACENTRAL PROCESSING UNITM68HC16 Z SERIES
4-36USER’S MANUAL
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
Total execution time is calculated using the expression:
nc...
I
cale Semiconductor,
Frees
()CL
CL
Where:
(CLT) = Total clock periods per instruction
(CLI) = Clock periods used for internal operation
(CLP) = Clock periods used for program access
(CLO) = Clock periods used for operand access
Refer to the
topic.
4.13 Exceptions
An exception is an event that preempts normal instruction processing. Exception processing makes the transition from normal instruction execution to execution of a routine that deals with the exception.
Each exception has an assigned vector that points to an associated handler routine.
Exception processing includes all operations required to transfer control to a handler
routine, but does not include execution of the handler routine itself. Keep the distinction between exception processing and execution of an exception handler in mind
while reading this section.
4.13.1 Exception Vectors
An exception vector is the address of a routine that handles an exception. Exception
vectors are contained in a data structure called the exception vector table, which is located in the first 512 bytes of bank 0. Refer to Table 4-5 for the exception vector table.
All vectors except the reset vector consist of one word and reside in data space. The
reset vector consists of four words that reside in program space. Refer to SECTION 5
SYSTEM INTEGRATION MODULE for information concerning address space types
and the function code outputs. There are 52 predefined or reserved vectors, and 200
user-defined vectors.
CPU16 Reference Manual
()CLO()CL
T
P
(CPU16RM/AD) for more information on this
()++=
I
Each vector is assigned an 8-bit number. Vector numbers for some exceptions are
generated by external devices; others are supplied by the processor. There is a direct
mapping of vector number to vector table address. The processor left shifts the vector
number one place (multiplies by two) to convert it to an address.
M68HC16 Z SERIESCENTRAL PROCESSING UNITMOTOROLA
USER’S MANUAL4-37
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
Table 4-5 Exception Vector Table
Vector
Number
00000PReset — Initial ZK, SK, and PK
40008DBreakpoint
5000ADBus Error
6000CDSoftware Interrupt
7000EDIllegal Instruction
80010DDivision by Zero
During exception processing, the contents of the program counter and condition code
register are stacked at a location pointed to by SK : SP. Unless it is altered during ex-
cale Semiconductor,
ception processing, the stacked PK : PC value is the address of the next instruction in
the current instruction stream, plus $0006. Figure 4-6 shows the exception stack
frame.
Vector
Address
0002PReset — Initial PC
0004PReset — Initial SP
0006PReset — Initial IZ (Direct Page)
Address
Space
Type of
Exception
Frees
Low Address⇐ SP After Exception Stacking
Condition Code Register
High AddressProgram Counter⇐ SP Before Exception Stacking
Figure 4-6 Exception Stack Frame Format
MOTOROLACENTRAL PROCESSING UNITM68HC16 Z SERIES
4-38USER’S MANUAL
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
4.13.3 Exception Processing Sequence
Exception processing is performed in four phases. Priority of all pending exceptions is
evaluated and the highest priority exception is processed first. Processor state is
stacked, then the CCR PK extension field is cleared. An exception vector number is
acquired and converted to a vector address. The content of the vector address is loaded into the PC and the processor jumps to the exception handler routine.
There are variations within each phase for differing types of exceptions. However, all
vectors except RESET are 16-bit addresses, and the PK field is cleared during exception processing. Consequently, exception handlers must be located within bank 0 or
vectors must point to a jump table in bank 0.
4.13.4 Types of Exceptions
Exceptions can be either internally or externally generated. External exceptions, which
are defined as asynchronous, include interrupts, bus errors, breakpoints, and resets.
nc...
I
Internal exceptions, which are defined as synchronous, include the software interrupt
(SWI) instruction, the background (BGND) instruction, illegal instruction exceptions,
and the divide-by-zero exception.
cale Semiconductor,
Frees
4.13.4.1 Asynchronous Exceptions
Asynchronous exceptions occur without reference to CPU16 or IMB clocks, but exception processing is synchronized. For all asynchronous exceptions except RESET, exception processing begins at the first instruction boundary following recognition of an
exception. Refer to 5.8.1 Interrupt Exception Processing for more information concerning asynchronous exceptions.
Because of pipelining, the stacked return PK : PC value for all asynchronous exceptions, other than reset, is equal to the address of the next instruction in the current instruction stream plus $0006. The RTI instruction, which must terminate all exception
handler routines, subtracts $0006 from the stacked value to resume execution of the
interrupted instruction stream.
4.13.4.2 Synchronous Exceptions
Synchronous exception processing is part of an instruction definition. Exception processing for synchronous exceptions is always completed, and the first instruction of
the handler routine is always executed, before interrupts are detected.
Because of pipelining, the value of PK : PC at the time a synchronous exception executes is equal to the address of the instruction that causes the exception plus $0006.
Because RTI always subtracts $0006 upon return, the stacked PK : PC must be adjusted by the instruction that caused the exception so that execution resumes with the
following instruction. For this reason, $0002 is added to the PK : PC value before it is
stacked.
M68HC16 Z SERIESCENTRAL PROCESSING UNITMOTOROLA
USER’S MANUAL4-39
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
4.13.5 Multiple Exceptions
Each exception has a hardware priority based upon its relative importance to system
operation. Asynchronous exceptions have higher priorities than synchronous exceptions. Exception processing for multiple exceptions is completed by priority, from highest to lowest. Priority governs the order in which exception processing occurs, not the
order in which exception handlers are executed.
Unless a bus error, a breakpoint, or a reset occurs during exception processing, the
first instruction of all exception handler routines is guaranteed to execute before another exception is processed. Because interrupt exceptions have higher priority than
synchronous exceptions, the first instruction in an interrupt handler is executed before
other interrupts are sensed.
Bus error, breakpoint, and reset exceptions that occur during exception processing of
a previous exception are processed before the first instruction of that exception’s handler routine. The converse is not true. If an interrupt occurs during bus error exception
nc...
I
processing, for example, the first instruction of the exception handler is executed before interrupts are sensed. This permits the exception handler to mask interrupts during execution.
cale Semiconductor,
Frees
Refer to SECTION 5 SYSTEM INTEGRATION MODULE for detailed information concerning interrupts and system reset. For information concerning processing of specific
exceptions, refer to the
4.13.6 RTI Instruction
The return-from-interrupt instruction (RTI) must be the last instruction in all exception
handlers except the RESET handler. RTI pulls the exception stack frame that was
pushed onto the system stack during exception processing, and restores processor
state. Normal program flow resumes at the address of the instruction that follows the
last instruction executed before exception processing began.
RTI is not used in the RESET handler because RESET initializes the stack pointer and
does not create a stack frame.
4.14 Development Support
The CPU16 incorporates powerful tools for tracking program execution and for system
debugging. These tools are deterministic opcode tracking, breakpoint exceptions, and
background debug mode. Judicious use of CPU16 capabilities permits in-circuit emulation and system debugging using a bus state analyzer, a simple serial interface, and
a terminal.
CPU16 Reference Manual
(CPU16RM/AD).
4.14.1 Deterministic Opcode Tracking
The CPU16 has two multiplexed outputs, IPIPE0 and IPIPE1, that enable external
hardwareto monitor the instruction pipeline during normal program execution. The signals IPIPE0 and IPIPE1 can be demultiplexed into six pipeline state signals that allow
a state analyzer to synchronize with instruction stream activity.
MOTOROLACENTRAL PROCESSING UNITM68HC16 Z SERIES
4-40USER’S MANUAL
For More Information On This Product,
Go to: www.freescale.com
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.