2004
applications, or technology described is intended to suggest possible uses and may be superseded. ZiLOG,
INC. DOES NOT ASSUME LIABILITY FOR OR PROVIDE
THE INFORMA
ALSO DOES NOT ASSUME LIABILITY FOR INTELLECTU
RELA
DESCRIBED HEREIN OR O
limitation of liability pro
mak
es no w
ZiLOG, use of information, de
authorized. No licenses are conve
property rights.
gistered trademark of ZiLOG Inc. in the United States and in other countries.
by ZiLOG, Inc.
TION, DEVICES, OR TECHN
TED IN
ANY MANNER TO USE OF INFORMA
arranty of merchantability or fi
All rights reserv
THER
visions appearing in the ZiLOG, Inc. Terms and Conditions of Sale. ZiLOG, Inc.
vices, or technology as critical components of life support systems is not
yed, implicitly or otherwise, by this document under an
ed. Information in this publication concerning the de
A REPRESENTATION OF ACCURA
OLOGY DESCRIBED IN
AL PR
TION, DEVICES, OR TECHN
WISE. De
vices sold by ZiLOG, Inc. are covered by w
tness for an
y purpose Except with the e
All other products
y are associated.
THIS DOCUMENT
OPER
TY INFRINGEMENT
xpress written approval of
y intellectual
vices,
CY OF
. ZiLOG
OLOGY
arranty and
UM001602-0904
Revision History
Z8 CPU
User Manual
iii
Date
Sept.
2
004
Each instance in Table 1
ous re
vision. To see more detail, click the appropriate link in the table.
The ZiLOG Z8 microcontroller (MCU) product line continues to expand
with new product introductions. ZiLOG MCU products are targeted for
cost-sensitive, high-volume applications including consumer, automotive,
security, and HVAC. It includes ROM-based products geared for highvolume production (where software is stable) and one-time programmable (OTP) equivalents for prototyping as well as volume production
where time to market or code flexibility is critical (see Table 1 on page 4).
A variety of packaging options are available including plastic DIP, SOIC,
PLCC, and QFP.
A generalized Z8 CPU® block diagram is shown in Figure 1. The same
on-chip peripherals are used across the MCU product line with the primary differences being the amount of ROM/RAM, number of I/O lines
present, and packaging/temperature ranges available. This allows code
written for one MCU device to be easily ported to another family member.
Z8 CPU
User Manual
1
Key Features
General-Purpose Register File. Every RAM register acts like an accumulator, speeding instruction execution and maximizing coding efficiency. Working register groups allow fast context switching.
Flexible I/O. I/O byte, nibble, and/or bit programmable as inputs or outputs. Outputs are software programmable as open-drain or push–pull on a
port basis. Inputs are Schmitt-triggered with autolatches to hold unused
inputs at a known voltage state.
Analog Inputs. Three input pins are software programmable as digital or
analog inputs. When in analog mode, two comparator inputs are provided
with a common reference input. These inputs are ideal for a variety of
common functions, including threshold level detection, analog-to-digital
UM001602-0904Z8 CPU Product Overview
Z8 Family of Microcontrollers
User Manual
2
conversion, and short circuit detection. Each analog input provides a
unique maskable interrupt input.
Timer/Counter. The Timer/Counter (T/C) consists of a programmable 6bit prescaler and 8-bit downcounter, with maskable interrupt upon end-ofcount. Software controls T/C load/start/stop, countdown read (at any time
on the fly), and maskable end-of-count interrupt. Special functions available include TIN (external counter input, external gate input, or external
trigger input) and T
system clock.) These special functions allow accurate hardware input
pulse measurement and output waveform generation.
Interrupts. There are six vectored interrupt sources with software-programmable enable and priority for each of the six sources.
Watch–Dog Timer. An internal Watch–Dog Timer (WDT) circuit is
included as a fail-safe mechanism so that if software strays outside the
bounds of normal operation, the WDT will time-out and reset the MCU.
To maximize circuit robustness and reliability, the default WDT clock
source is an internal RC circuit (isolated from the device clock source).
(external access to timer output or the internal
OUT
Auto Reset/Low-Voltage Protection. All family devices have internal
Power-On Reset. ROM devices add low-voltage protection. Low-voltage
protection ensures the MCU is in a known state at all times (in active
RUN mode or RESET) without external hardware (or a device reset pin).
Low-EMI Operation. Mode is programmable via software or as a mask
option. This new option provides for reduced radiated emission via clock
and output drive circuit changes.
Low-Power. CMOS with two standby modes; STOP and HALT.
Full Z8 Instruction Set. Forty-eight basic instructions, supported by six
addressing modes with the ability to operate on bits, nibbles, bytes, and
words.
Z8 CPU Product OverviewUM001602-0904
Z8 CPU
User Manual
3
Output
Port 3
Counter/
Timers (2)
Interrupt
Control
Analog
Comparators
(2)
Input
V
CC
Register File
256 x 8-Bit
GND
ALU
FLAG
Register
Pointer
XTAL
AS DS
Machine Timing
& Instruction Control
RESET, WDT,
POR
Prg. Memory
512/K x 8-Bit
Program
Counter
R/W RESET
Port 2
I/O
(Bit Programmable)
Port 0
44
Address or I/O
(Nibble Programmable)
Port 1
8
Address/Data or I/O
(Byte Programmable)
Figure 1. Z8 CPU Block Diagram
UM001602-0904Z8 CPU Product Overview
Z8 Family of Microcontrollers
User Manual
4
Product Development Support
The Z8® MCU product line is fully supported with a range of cross
assemblers, C compilers, ICEBOX emulators, single and gang OTP/
EPROM programmers, and software simulators.
The Z86CCP01ZEM low-cost Z8 CCP™ real-time emulator/programmer
kit was designed specifically to support all of the products outlined in
Table 1.
Table 1. ZiLOG General-Purpose Microcontroller Product Family
ROM/
Product
Z86C03512/6014126FYYY818
Z86E03512/6014126FYNY818
Z86C041K/12414226FYYY818
Z86E041K/12414226FYNY818
Z86C061K/12414226PYYY1218
Z86E061K/12414226PYNY1218
Z86C082K/12414226FYYY1218
Z86E082K/12414226FYNY1218
Z86C304K/23624226PYYY1228
Z86E304K/23624226PYNY1228
Z86C312K/12424226PYYY828
Z86E312K/12424226PYNY828
Z86C404K/23632226PYYY1640/44
Z86E404K/23632226PYNY1640/44
*Note: Z86Cxx signify ROM devices; 86xx signify EPROM devices; F = fixed; P = programmable
RAMI/0T/CANINTWDT POR V
BO
RC
Speed
(MHz)
Pin
Count
Z8 CPU Product OverviewUM001602-0904
Z8 CPU
User Manual
The Z86CCP01ZEM kit comes with:
•
Z8 CCP Evaluation Board
•
Z8 CCP Power Cable
•
ZiLOG Developer’s Studio (ZDS) CD-ROM , Including WindowsBased GUI Host Software
•
1999 ZiLOG Technical Library
•
Z8 CCP User Manual
A Z8 CCP Emulator Accessory Kit (Z8CCP00ZAC) is also available and
provides an RS-232 cable and power cable along with the 28- and 40- pin
ZIF sockets and 28- and 40- pin target connector cables required to emulate/program 28/40 pin devices.
5
UM001602-0904Z8 CPU Product Overview
Z8 Family of Microcontrollers
User Manual
6
Z8 CPU Product OverviewUM001602-0904
Address Space
Introduction
Four address spaces are available for the Z8® CPU:
•
The Z8® Standard Register File contains addresses for peripheral,
control, all general-purpose, and all I/O port registers. This is the
default register file specification.
•
The Z8
trol and data registers for additional peripherals/features.
•
Z8 external program memory contains addresses for all memory locations having executable code and/or data.
®
Expanded Register File (ERF) contains addresses for con-
Z8 CPU
User Manual
7
•
Z8 external data memory contains addresses for all memory locations
that hold data only, whether internal or external.
Z8 CPU Standard Register File
The Z8
ters). The register file consists of 4 I/O ports (00h–03h), 236 GeneralPurpose Registers (04h–EFh), and 16 control registers (F0h–FFh).
Table 2 shows the layout of the register file, including register names,
locations, and identifiers.
Table 2. Z8 Standard Register File
UM001602-0904Address Space
®
Standard Register File totals up to 256 consecutive bytes (Regis-
Registers can be accessed as either 8-bit or 16-bit registers using Direct,
Indirect, or Indexed Addressing. All 236 general-purpose registers can be
Address SpaceUM001602-0904
Z8 CPU
User Manual
referenced or modified by any instruction that accesses an 8-bit register,
without the requirement for special instructions. Registers accessed as 16
bits are treated as even-odd register pairs (there are 118 valid pairs). In
this case, the data’s Most Significant Byte (MSB) is stored in the even
numbered register, while the Least Significant Byte (LSB) goes into the
next higher odd numbered register. See Figure 2.
9
MSB
Rn Rn+1
n = Even Address
Figure 2. 16-Bit Register Addressing
LSB
By using a logical instruction and a mask, individual bits within registers
can be accessed for bit set, bit clear, bit complement, or bit test operations. For example, the instruction AND R15, MASK performs a bit clear
operation. Figure 3 shows this example.
0 1 1 1 0 0 0 0
1 1 0 1 1 1 1 1
AND R15, DFh ;Clear Bit 5 of Working Register 15
0 1 0 1 0 0 0 0
R15
MASK
R15
Figure 3. Accessing Individual Bits (Example)
UM001602-0904Address Space
Z8 Family of Microcontrollers
User Manual
10
When instructions are executed, registers are read when defined as
sources and written when defined as destinations. All General-Purpose
Registers function as accumulators, address pointers, index registers,
stack areas, or scratch pad memory.
General-Purpose Registers
General-Purpose Registers (GPR) are undefined after the device is powered up. The registers keep their last value after any reset, as long as the
reset occurs in the VCC voltage-specified operating range. It will not keep
its last state from a VLV reset if VCC drops below 1.8v.
Note:
Registers in Bank E0-EF may only be accessed through the working register and indirect addressing modes. Direct access cannot be used because
the 4-bit working register address mode already uses the format [E | dst],
where dst represents the working register number from 0h to Fh.
RAM Protect
The upper portion of the register file address space 80h to EFh (excluding
the control registers) may be protected from reading and writing. The
RAM Protect bit option is mask-programmable and is selected by the customer when the ROM code is submitted. After the mask option is
selected, the user activates this feature from the internal ROM code to
turn off/on the RAM Protect by loading either a 0 or 1 into the IMR register, bit D6. A 1 in D6 enables RAM Protect. Only devices that use registers 80h to EFh offer this feature.
Working Register Groups
Z8 instructions can access 8-bit registers and register pairs (16-bit words)
using either 4-bit or 8-bit address fields. 8-bit address fields refer to the
actual address of the register. For example, Register 58h is accessed by
calling upon its 8-bit binary equivalent, 01011000 (58h).
With 4-bit addressing, the register file is logically divided into 16 Working Register Groups of 16 registers each, as shown in Table 3. These 16
Address SpaceUM001602-0904
Z8 CPU
User Manual
registers are known as Working Registers. A Register Pointer (one of the
control registers, FDh) contains the base address of the active Working
Register Group. The high nibble of the Register Pointer determines the
current Working Register Group.
When accessing one of the Working Registers, the 4-bit address of the
Working Register is combined within the upper four bits (high nibble) of
the Register Pointer, thus forming the 8-bit actual address. Figure 4 illustrates this operation. Because working registers are typically specified by
short format instructions, there are fewer bytes of code required, which
reduces execution time. In addition, when processing interrupts or changing tasks, the Register Pointer speeds context switching. A special Set
Register Pointer (SRP) instruction sets the contents of the Register
Pointer.
Table 3. Working Register Groups
11
Register Pointer
(FDh) High Nibble
1111bFF0–FF
1110bEE0–EF
1101bDD0–DF
1100bCC0–CF
1011bBB0–BF
1010bAA0–AF
1001b990–9F
1000b880–8F
0111b770–7F
0110b660–6F
0101b550–5F
0100b440–4F
UM001602-0904Address Space
Working Register
Group (Hex)
Actual Registers
(Hex)
Z8 Family of Microcontrollers
User Manual
12
Table 3. Working Register Groups (Continued)
Register Pointer
(FDh) High Nibble
0011b330–3F
0010b220–2F
0001b110–1F
0000b000–0F
0 1 1 1 0 0 0 0
1 1 0 1 1 1 1 1
0 1 1 1 0 1 1 0
Figure 4. Working Register Addressing Examples
Working Register
Group (Hex)
Register Pointer (FDh), Standard Register File
INC R6 (instruction, short format)
Actual register address (76h)
Actual Registers
(Hex)
Address SpaceUM001602-0904
Z8 CPU
User Manual
13
R7 R6 R5 R4 R3 R2 R1 R0
The upper nibble of the register file address,
provided by the register pointer, specifies
the active working-register group.
*Note: The full register file is shown. Please refer to the selected device product specification for actual file size.
Working Register Group F
Specified Working Register Group
Working Register Group 1
Working Register Group 0
I/O Ports
R253
(Register Pointer)
The lower nibble
of the register
file address
(provided by the
instruction) points
to the specified
register.
R15 to R0
R15 to R4
R3 to R0
Figure 5. Register Pointer
Error Conditions
Registers in the Z8
because certain conditions produce inconsistent results and should be
avoided.
•
Registers F3h and F5h–F9h are write-only registers. If an attempt is
made to read these registers, FFh is returned. Reading any write-only
register will return FFh.
UM001602-0904Address Space
®
Standard Register File must be correctly used
Z8 Family of Microcontrollers
User Manual
14
•
•
•
•
•
When register FDh (Register Pointer) is read, the least significant four
bits (lower nibble) will indicate the current Expanded Register File
Bank. (Example: 0000 indicates the Standard Register File, while
1010 indicates Expanded Register File Bank A.)
When Ports 0 and 1 are defined as address outputs, registers 00h and
01h will return 1s in each address bit location when read.
Writing to bits that are defined as timer output, serial output, or handshake output will have no effect.
The Z8® CPU instruction DJNZ uses any general-purpose working
register as a counter.
Logical instructions such as OR and AND require that the current
contents of the operand be read. They therefore will not function
properly on write-only registers.
•
The WDTMR register must be written within the first 60 internal system clocks (SCLK) of operation after a reset.
Z8 Expanded Register File
The standard register file of the Z8
Expanded Register File (ERF) Banks, as shown in Figure 6. Each ERF
Bank consists of up to 256 registers (the same amount as in the Standard
Register File) that can then be divided into 16 Working Register Groups.
This expansion allows for access to additional feature/peripheral control
and data registers.
*Note: The fully implemented register file is shown. Please refer to the specific product specification for actual register file architecture implemented.
Figure 6. Expanded Register File Architecture
UM001602-0904Address Space
Z8 Family of Microcontrollers
User Manual
16
Currently, three out of the possible sixteen Z8 ERF Banks have been
implemented. ERF Bank 0, also known as the Z8® Standard Register File,
has all 256 bytes defined, as shown in Figure 7. Only Working Register
Group 0 (register addresses 00h to 0Fh) have been defined for ERF Bank
C and ERF Bank F (see Table 4). All other working register groups in
ERF Banks C and F, as well as the remaining thirteen ERF Banks, are not
implemented. All are reserved for future use.
When an ERF Bank is selected, register addresses 00h to 0Fh access
those sixteen ERF Bank registers—in effect replacing the first sixteen
locations of the Z8® Standard Register File.
For example, if ERF Bank C is selected, the Z8® Standard Registers 00h
through 0Fh are no longer accessible. Registers 00h through 0Fh are now
the 16 registers from ERF Bank C, Working Register Group 0. No other
Z8 Standard Registers are affected because only Working Register Group
0 is implemented in ERF Bank C.
Access to the ERF is accomplished through the Register Pointer (FDh).
The lower nibble of the Register Pointer determines the ERF Bank while
the upper nibble determines the Working Register Group within the register file, as Figure 7 shows.
0 1 1 1
Working
Register
Group
Select ERF Bank Ch
Working Register Group 7h
Figure 7. Register Pointer Example
Address SpaceUM001602-0904
1 1 0 0
Expanded
Register
Bank
Z8 CPU
User Manual
The value of the lower nibble in the Register Pointer (FDh) corresponds to
the ERF Bank identification. Table 4 shows the lower nibble value and the
register file assigned to it.
Table 4. ERF Bank Address
Register
Pointer (FDh)
Low Nibble
0000b0Z8 Standard Register File.*
0001b1Expanded Register File Bank 1.
0010b2Expanded Register File Bank 2.
0011b3Expanded Register File Bank 3..
0100b4Expanded Register File Bank 4
Hex
Register File
17
0101b5Expanded Register File Bank 5..
0110b6Expanded Register File Bank 6
0111b7Expanded Register File Bank 7..
1000b8Expanded Register File Bank 8
1001b9Expanded Register File Bank 9..
1010bAExpanded Register File Bank A
1011bBExpanded Register File Bank B.
1100bCExpanded Register File Bank C.
1101bDExpanded Register File Bank D..
1110bEExpanded Register File Bank E
1111bFExpanded Register File Bank F.
*Note: the Z8® Standard Register File is equivalent to Expanded Register File Bank 0.
UM001602-0904Address Space
Z8 Family of Microcontrollers
User Manual
18
The upper nibble of the register pointer selects which group of 16 bytes in
the Register File, out of the 256 total bytes, will be accessed as working
registers. Table 5 shows an example.
Table 5. Register Pointer Access Example
R253 RP = 00h;ERF Bank 0, Working Reg. Group 0.
R0 = Port 0 = 00h
R1 = Port 1 = 01h
R2 = Port 2 = 02h
R3 = Port 3 = 03h
R11 = GPR 0Bh
R15 = GPR 0Fh
If R253 RP = 0Fh ;ERF Bank F, Working Reg. Group 0.
R0 = PCON = 00h
R1 = Reserved = 01h
R2 = Reserved = 02h
R11 = SMR = 0Bh
R15 = WDTMR = 0Fh
Address SpaceUM001602-0904
Table 5. Register Pointer Access Example (Continued)
If R253 RP = FFh
;ERF Bank F, Working Reg. Group F.
00h = PCON
R0 = SI001h = Reserved
R1 = TMR02h = Reserved
...
R2 = T10Bh = SMR
...
R15 = SPL0Fh = WDTMR
Z8 CPU
User Manual
19
Because enabling an ERF Bank (C or F) only changes register addresses
00h to 0Fh, the working register pointer can be used to access either the
selected ERF Bank (Bank C or F, Working Register Group 0) or the Z8
®
Standard Register File (ERF Bank 0, Working Register Groups 1 through
F).
When an ERF Bank other than Bank 0 is enabled, the first 16 bytes of the
Z8® Standard Register File (I/O ports 0 to 3, Groups 4 to F) are no longer
accessible (the selected ERF Bank, Registers 00h to 0Fh are accessed
instead). It is important to re-initialize the Register Pointer to enable ERF
Bank 0 when these registers are required for use.
The SPI register is mapped into ERF Bank C. Access is easily done using
the example in Table 6.
UM001602-0904Address Space
Z8 Family of Microcontrollers
User Manual
20
Table 6. ERF Bank C Access Example
LDRP, #0Ch;Select ERF Bank C working
LDR2,#xx;access SCON
LDR1, #xx;access RXBUF
LDRP, #00h;Select ERF Bank 0 so I/O ports
Table 7. Z8 Expanded Register File Bank Layout
Expanded Register
File BankERF
;register group 0 for access.
;are again accessible.
FhPCON, SMR, WDT, (00h, 0Bh, 0Fh),
Working Register Group 0 only
implemented.
EhNot implemented (reserved)
DhNot implemented (reserved)
ChSPI Registers: SCOMP, RXBUF, SCON
(00h, 01h, 02h), Working Register Group 0
only implemented.
BhNot implemented (reserved)
AhNot implemented (reserved)
9hNot implemented (reserved)
8hNot implemented (reserved)
7hNot implemented (reserved)
6hNot implemented (reserved)
5hNot implemented (reserved)
Address SpaceUM001602-0904
Z8 CPU
User Manual
Table 7. Z8 Expanded Register File Bank Layout
Expanded Register
File BankERF
4hNot implemented (reserved)
3hNot implemented (reserved)
2hNot implemented (reserved)
1hNot implemented (reserved)
0hZ8 Ports 0, 1, 2, 3, and General-Purpose
Registers 04h to EFh, and control
registers F0h to FFh.
Please refer to the specific product specification to determine the above
registers are implemented.
21
Z8 Control and Peripheral Registers
Standard Z8 Registers
The standard Z8 control registers govern the operation of the CPU. Any
instruction which references the register file can access these control registers. Available control registers are:
•
Interrupt Priority Register (IPR)
•
Interrupt Mask Register (IMR)
•
Interrupt Request Register (IRQ)
•
Program Control Flags (FLAGS)
•
Register Pointer (RP)
•
Stack Pointer High-Byte (SPH)
•
Stack Pointer Low-Byte (SPL)
UM001602-0904Address Space
Z8 Family of Microcontrollers
User Manual
22
The Z8® CPU uses a 16-bit Program Counter (PC) to determine the
sequence of current program instructions. The PC is not an addressable
register.
Peripheral registers are used to transfer data, configure the operating
mode, and control the operation of the on-chip peripherals. Any instruction that references the register file can access the peripheral registers.
The peripheral registers are:
•
•
•
•
•
Serial I/O (SIO)
Timer Mode (TMR)
Timer/Counter 0 (T0)
T0 Prescaler (PRE0)
Timer/Counter 1 (T1)
•
T1 Prescaler (PRE1)
•
Port 0–1 Mode (P01M)
•
Port 2 Mode (P2M)
•
Port 3 Mode (P3M)
In addition, the four port registers (P0–P3) are considered to be peripheral
registers.
Expanded Z8 Registers
The expanded Z8 control registers govern the operation of additional features or peripherals. Any instruction which references the register file can
access these registers.
The ERF contains the control registers for WDT, Port Control, Serial
Peripheral Interface (SPI), and the SMR functions. Figure 6 on page 15
shows the layout of the Register Banks in the ERF. Register Bank C in the
ERF consists of the registers for the SPI. Table 8 shows the registers
within ERF Bank C, Working Register Group 0.
Address SpaceUM001602-0904
Table 8. Expanded Register File Register Bank C
WR Group 0
Working
RegisterFunction
FReservedR15
EReservedR14
DReservedR13
CReservedR12
BReservedR11
AReservedR10
9ReservedR9
8ReservedR8
Register
Z8 CPU
User Manual
23
7ReservedR7
6ReservedR6
5ReservedR5
4ReservedR4
3ReservedR3
2SPI Control (SCON)R2
1SPI Tx/Rx Data (Roxburgh)R1
0SPI Compare (SCOMP)R0
UM001602-0904Address Space
Z8 Family of Microcontrollers
User Manual
24
Working Register Group 0 in ERF Bank 0 consists of the registers for Z8
General-Purpose Registers and ports. Table 9 shows the registers within
this group.
Table 9. Expanded Register File Bank 0
WR Group 0
RegisterFunction
FGeneral-Purpose RegisterR15
EGeneral-Purpose RegisterR14
DGeneral-Purpose RegisterR13
CGeneral-Purpose RegisterR12
BGeneral-Purpose RegisterR11
Working
Register
AGeneral-Purpose RegisterR10
9General-Purpose RegisterR9
8General-Purpose RegisterR8
7General-Purpose RegisterR7
6General-Purpose RegisterR6
5General-Purpose RegisterR5
4General-Purpose RegisterR4
3Port 3R3
2Port 2R2
1Port 1R1
0Port 0R0
Address SpaceUM001602-0904
Z8 CPU
User Manual
Working Register Group 0 in ERF Bank F consists of the control registers
for STOP mode, WDT, and port control. Table 10 shows the registers
within this group.
Table 10. Expanded Register File Bank F
WR Group 0
Working
RegisterFunction
FWDTMRR15
EReservedR14
DReservedR13
CReservedR12
BSMRR11
Register
25
AReservedR10
9ReservedR9
8ReservedR8
7ReservedR7
6ReservedR6
5ReservedR5
4ReservedR4
3ReservedR3
2ReservedR2
1ReservedR1
0PCONR0
UM001602-0904Address Space
Z8 Family of Microcontrollers
User Manual
26
The functions and applications of the control and peripheral registers are
described in subsequent sections of this manual.
Program Memory
The first 12 bytes of program memory are reserved for the interrupt vectors, as shown in Figure 8. These locations contain six 16-bit vectors that
correspond to the six available interrupts. Address 12 up to the maximum
ROM address consists of on-chip mask-programmable ROM. See the
product data sheet for the exact program, data, register memory size, and
address range available. At addresses outside the internal ROM, the Z8®
CPU executes external program memory fetches through Port 0 and Port
1 in Address/Data mode for devices with Port 0 and Port 1 featured. Otherwise, the program counter will continue to execute NOPs up to address
FFFFh, roll over to 0000h, and continue to fetch executable code (see
Figure 8).
The internal program memory is one-time programmable (OTP) or mask
programmable dependent on the specific device. A ROM protect feature
prevents dumping of the ROM contents by inhibiting execution of the
LDC, LDCI, LDE, and LDEI instructions to program memory in all
modes. ROM look-up tables cannot be used with this feature.
The ROM Protect option is mask-programmable, to be selected by the
customer when the ROM code is submitted. For the OTP ROM, the ROM
Protect option is an OTP programming option.
Address SpaceUM001602-0904
Location of
First Byte of
Instruction
Executed
After RESET
65535
4096
4095
12
External
ROM and RAM
On–Chip
ROM
Z8 CPU
User Manual
27
Interrupt
Vector
(Lower Byte)
Interrupt
Vector
(Upper Byte)
Figure 8. Z8 Program Memory Map
Z8 External Memory
The Z8® CPU, in some cases, has the capability to access external program memory with the 16-bit Program Counter. To access external pro-
11
10
9
8
7
6
5
4
3
2
1
0
IRQ
IRQ
IRQ
IRQ
IRQ
IRQ
IRQ
IRQ
IRQ
IRQ
IRQ
IRQ
5
5
4
4
3
3
2
2
1
1
0
0
UM001602-0904Address Space
Z8 Family of Microcontrollers
User Manual
28
gram memory the Z8® CPU offers multiplexed address/data lines (AD7–
AD0) on Port 1 and address lines (A15–A8) on Port 0. This feature only
applies to devices that offer Port 0 and Port 1. The maximum external
address is FFFF. This memory interface is supported by the control lines
AS (Address Strobe), DS (Data Strobe), and R/W (Read/Write). The origin of the external program memory starts after the last address of the
internal ROM. Figure 9 shows an example of external program memory
for the Z8® CPU.
External Data Memory
The Z8® CPU, in some cases, can address up to 60 KB of external data
memory beginning at location 4096. External data memory (DM) can be
included with, or separated from, the external program memory space.
DM, an optional I/O function that can be programmed to appear on pin
P34, is used to distinguish between data and program memory space. The
state of the DM signal is controlled by the type of instruction being executed. An LDC opcode references program memory (DM inactive) , and
an LDE instruction references data memory (DM active Low) . The user
must configure Port 3 Mode Register (P3M) bits D3 and D4 for this
mode.
Address SpaceUM001602-0904
65535
External
Memory
Z8 CPU
User Manual
29
4096
4095
Not Addressable
0
*Note: For additional information on using external memory, see Chapter 10 of this manual. For exact
memory addressing options available, see the device product specification.
Figure 9. External Memory Map
UM001602-0904Address Space
Z8 Family of Microcontrollers
User Manual
30
Z8 Stacks
Stack operations can occur in either the Z8® Standard Register File or
external data memory. Under software control, Port 0–1 Mode register
(F8h) selects the stack location. Only the General-Purpose Registers can
be used for the stack when the internal stack is selected.
The register pair FEh and FFh form the 16-bit Stack Pointer (SP), that is
used for all stack operations. The stack address is stored with the MSB in
FEh and LSB in FFh; see Figure 10.
FFh
LOWER Byte
Stack Pointer Low
FEh
Figure 10. Stack Pointer
UPPER Byte
Stack Pointer High
The stack address is decremented prior to a PUSH operation and incremented after a POP operation. The stack address always points to the data
stored on the top of the stack. The Z8® CPU stack is a return stack for
CALL instructions and interrupts, as well as a data stack.
During a CALL instruction, the contents of the PC are saved on the stack.
The PC is restored during a RETURN instruction. Interrupts cause the
contents of the PC and Flag registers to be saved on the stack. The IRET
instruction restores them Figure 11.
When the Z8® CPU is configured for an internal stack (using the Z8®
Standard Register File), register FFh serves as the Stack Pointer. The
Address SpaceUM001602-0904
Z8 CPU
User Manual
value in FEh is ignored. FEh can be used as a general-purpose register in
this case only.
An overflow or underflow can occur when the stack address is incremented or decremented during normal stack operations. The programmer
must prevent this occurrence or unpredictable operation will result.
PCL
31
Top of Stack
PCL
PCH
Stack Contents
After a Call
Instruction
Top of Stack
Figure 11. Stack Operations
PCH
FLAGS
Stack Contents
After an
Interrupt Cycle
UM001602-0904Address Space
Z8 Family of Microcontrollers
User Manual
32
Address SpaceUM001602-0904
Clock
Frequency Control
Z8 CPU
User Manual
33
The Z8® CPU derives its timing from on-board clock circuitry connected
to pins XTAL1 and XTAL2. The clock circuitry consists of an oscillator, a
divide-by-two shaping circuit, and a clock buffer. Figure 12 illustrates the
clock circuitry. The oscillator’s input is XTAL1 and its output is XTAL2.
The clock can be driven by a crystal, a ceramic resonator, LC clock, RC,
or an external clock source.
In some cases, the Z8® CPU has an EPROM/OTP option or a Mask ROM
option bit to bypass the divide-by-two flip flop in Figure 12. This feature
is used in conjunction with the low EMI option. When low EMI is
selected, the device output drive and oscillator drive is reduced to approximately 25 percent of the standard drive and the divide-by-two flip flop is
bypassed such that the XTAL clock frequency is equal to the internal system clock frequency. In this mode, the maximum frequency of the XTAL
clock is 4 MHz. Please refer to specific product specification for availability of options and output drive characteristics.
XTAL1
OSC
XTAL2
Figure 12. Z8® CPU Clock Circuit
÷2
Buffer
Internal
Clock
Clock Control
In some cases, the Z8® CPU offers software control of the internal system
clock via programming register bits. The bits are located in the StopMode Recovery Register in Expanded Register File Bank F, Register 0Bh.
UM001602-0904Clock
Z8 Family of Microcontrollers
User Manual
34
This register selects the clock divide value and determines the mode of
Stop-Mode Recovery (see Figure 13). Please refer to the specific product
specification for availability of this feature/register.
SMR (F) OB
D7 D6 D5 D4 D3 D2 D1 D0
SCLK ÷ TCLK D ivide by 16
0 OFF **
1 ON
External Clock Divide Mode by 2
0 = SCLK
* Default setting after RESET.
**Default setting after RESET and Stop-Mode R ecovery.
The D0 bit of the SMR controls a divide-by-16 prescaler of
SCLK ÷ TCLK. The purpose of this control is to selectively reduce
device power consumption during normal processor execution (SCLK
control) and/or HALT mode (where TCLK sources counter/timers and
interrupt logic).
External Clock Divide-By-Two
The D1 bit can eliminate the oscillator divide-by-two circuitry. When this
bit is 0, SCLK (System Clock) and TCLK (Timer Clock) are equal to the
external clock frequency divided by two. The SCLK ÷ TCLK is equal to
the external clock frequency when this bit is set (D1 = 1). Using this bit,
together with D7 of PCON, further helps lower EMI (D7 (PCON) = 0, D1
(SMR) = 1). The default setting is 0. Maximum frequency is 4 MHz with
D1 = 1 (see Figure 14).
÷
TCLK = XTAL
÷
TCLK = X TAL
2*
÷
ClockUM001602-0904
D1 (SMR)
D0 (SMR)
OSC
÷2
Z8 CPU
User Manual
35
Figure 14. External Cloc k Cir cuit
Oscillator Contr ol
In some cases, the Z8
select lo w EMI dri v e or standard dri v e. The selection is done by program ming bit D7 of the Port Confi guration (PCON) re gister ( see Figure 15 ) .
The PCON re gister is located in Expanded Re gister File Bank F , Re gister
00h
UM001602-0904
External Clock
.
÷16
®
CPU of fers softw are control of the oscillator to
Clock
Z8 Family of Microcontrollers
User Manual
36
A 1 in bit D7 confi
fi
gures the oscillator with Lo
capability of the oscillator and does not affect the relationship of the
XTAL clock frequency to the internal system clock (SCLK).
PCON (Fh) 00h
D7 D6 D5 D4 D3 D2 D1 D0
Figure 15. Port Configuration Register (Write-Only)
Oscillator Operation
The Z8® CPU uses a Pierce oscillator with an internal feedback (see
Figure 16). The advantages of this circuit are low cost, large output signal,
low-power level in the crystal, stability with respect to VCC and temperature, and low impedances (not disturbed by stray affects).
One drawback is the requirement for high gain in the amplifier to compensate for feedback path losses. The oscillator amplifies its own noise at
start-up until it settles at the frequency that satisfies the gain/phase
requirements A x B = 1, where A = V0/VI is the gain of the amplifier and
B = VI/V0 is the gain of the feedback element. The total phase shift
around the loop is forced to zero (360 degrees). Because VIN must be in
phase with itself, the amplifier/inverter provides 180 degree phase shift
and the feedback element is forced to provide the other 180 degrees of
phase shift.
gures the oscillator with standard drive, while a 0 con
w EMI dri
ve. This only affects the drive
Low EMI Oscillator
0 Low EMI
1 Standard
-
Clock
R1 is a resistive component placed from output to input of the amplifier.
The purpose of this feedback is to bias the amplifier in its linear region
and to provide the start-up transition.
UM001602-0904
Z8 CPU
User Manual
Capacitor C2 combined with the amplifier output resistance provides a
small phase shift. It will also provide some attenuation of overtones.
Capacitor C1 combined with the crystal resistance provides additional
phase shift.
C1 and C2 can affect the start-up time if they increase dramatically in size.
As C1 and C2 increase, the start-up time increases until the oscillator
reaches a point where it does not start up any more.
For fast and reliable oscillator start-up over the manufacturing process
range, ZiLOG recommends that the load capacitors be sized as low as
possible without resulting in overtone operation.
37
Layout
XTAL1
Z8 CPU
A
RI
V
1
C1
V
0
XTAL2
C2
V
SS
Figure 16. Pierce Oscillator with Internal Feedback Circuit
Traces connecting crystal, caps, and the Z8® CPU oscillator pins should
be as short and wide as possible. This reduces parasitic inductance and
resistance. The components (caps, crystal, resistors) should be placed as
close as possible to the oscillator pins of the Z8® CPU .
The traces from the oscillator pins of the IC and the ground side of the
lead caps should be guarded from all other traces (clock, VCC, address/
UM001602-0904Clock
Z8 Family of Microcontrollers
User Manual
38
data lines, system ground) to reduce cross talk and noise injection. This is
usually accomplished by keeping other traces and system ground trace
planes away from the oscillator circuit and by placing a Z8® CPU device
VSS ground ring around the traces/components. The ground side of the
oscillator lead caps should be connected to a single trace to the Z8®
CPU’s VSS (GND) pin. It should not be shared with any other system
ground trace or components except at the Z8® CPU’s VSS pin. This is to
prevent differential system ground noise injection into the oscillator (see
Figure 17).
Indications of an Unreliable Design
Start-up time and output level are two major indicators that are used in
working designs to determine their reliability over full lot and temperature variations. These two indicators are described below.
Start-Up Time. If start-up time is excessive, or varies widely from unit to
unit, there is probably a gain problem. C1/C2 must be reduced; the amplifier gain is not adequate at frequency, or crystal resistance is too large.
Output Level. The signal at the amplifier output should swing from
ground to VCC. This indicates there is adequate gain in the amplifier. As
the oscillator starts up, the signal amplitude grows until clipping occurs,
at which point the loop gain is effectively reduced to unity and constant
oscillation is achieved. A signal of less than 2.5 volts peak-to-peak is an
indication that low gain may be a problem. Either C1 or C2 should be
made smaller or a low-resistance crystal should be used.
Circuit Board Design Rules
The following circuit board design rules are suggested:
•
To prevent induced noise the crystal and load capacitors should be
physically located as close to the Z8® CPU as possible.
ClockUM001602-0904
Z8 CPU
User Manual
•
Signal lines should not run parallel to the clock oscillator inputs. In
particular, the crystal input circuitry and the internal system clock
output should be separated as much as possible.
•
VCC power lines should be separated from the clock oscillator input
circuitry.
•
Resistivity between XTAL1 or XTAL2 and the other pins should be
greater than 10 MΩ.
39
UM001602-0904Clock
Z8 Family of Microcontrollers
User Manual
40
C1
C2
XTAL1
Z8 CPU
XTAL2
V
SS
20 mm
max
Signal Line
Layout Should
Avoid High
Lighted Areas
Clock Generator Circuit
Signals A B
(Parallel Traces
Must Be Avoided)
Signal C
2
3
(Connection to System Group
Must Be Avoided)
Figure 17. Circuit Board Design Rules
Crystals and Resonators
Crystals and ceramic resonators, shown in Figure 18 should have the
characteristics listed in Table 11 to ensure proper oscillator operation.
Depending on operation frequency, the oscillator may require the addition
of capacitors C1 and C2 (shown in Figure 18). The capacitance values are
dependent on the manufacturer’s crystal specifications.
41
V
SS
XTAL2
R
C2
D
Z8 CPU
XTAL1
RF
C1
Figure 18. Crystal/Ceramic Resonator Oscillator
UM001602-0904Clock
Z8 Family of Microcontrollers
User Manual
42
C1
C2
Figure 19. LC Clock
In most cases, the RD is 0Ω and RF is infinite. It is determined and specified by the crystal/ceramic resonator manufacturer. The RD can be
increased to decrease the amount of drive from the oscillator output to the
crystal. It can also be used as an adjustment to avoid clipping of the oscillator signal to reduce noise. The RF can be used to improve the start-up of
the crystal/ceramic resonator. The Z8® oscillator already has an internal
shunt resistor in parallel to the crystal/ceramic resonator.
L
XTAL1
Z8 CPU
XTAL2
V
SS
XTAL1
Z8 CPU
V
SS
XTAL2
Figure 20. External Clock
ClockUM001602-0904
Z8 CPU
User Manual
In Figures 18 through 20, ZiLOG recommends that the user connect the
load capacitor ground trace directly to the VSS (GND) pin of the Z8®
CPU to ensure that no system noise is injected into the Z8® clock. This
trace should not be shared with any other components except at the VSS
pin of the Z8® CPU.
In some cases, the Z8® CPU’s XTAL1 pin also functions as one of the
EPROM high-voltage mode programming pins or as a special factory test
pin. In this case, applying 2 V above VCC on the XTAL1 pin will cause
the device to enter one of these modes. Because this pin accepts high voltages to enter these respective modes, the standard input protection diode
to VCC is not on XTAL1. ZiLOG recommends that in applications where
the Z8® CPU is exposed to much system noise, a diode from XTAL1 to
VCC be used to prevent accidental enabling of these modes. This diode
will not affect the crystal/ceramic resonator operation.
43
Please note that a parallel resonant crystal or resonator data sheet will
specify a load capacitor value that is the series combination of C1 and C2,
including all parasitics (PCB and holder).
LC Oscillator
The Z8® CPU oscillator can use a LC network to generate a XTAL clock
(see Figure 19).
The frequency stays stable over VCC and temperature. The oscillation frequency is determined by the equation.
Frequency =
where L is the total inductance including parasitics and CT is the total
series capacitance including the parasitics.
Simple series capacitance is calculated using the following equation:
UM001602-0904Clock
1
2 π (LCT)
1/2
Z8 Family of Microcontrollers
User Manual
44
1
CT C1 C
If C1 = C
1 = 2
CT = C
C1 = 2CT
Sample calculation of capacitance C1 and C2 for 5.83 MHz frequency and
inductance value of 27 µH.
5.83 (106) =
CT = 27.6 pF
Thus C1 = 55.2 pF and C2 = 55.2 pF.
RC Oscillator
In some cases, the Z8® CPU features an RC oscillator option. Please refer
to the specific product specification for availability. The RC oscillator
requires a resistor across XTAL1 and XTAL2. An additional load capacitor is required from the XTAL1 input to VSS pin (see Figure 21).
=
1
1
+
2
2
1
1
2π [2.7 (10–6) CT] 1/2
ClockUM001602-0904
XTAL1
R
Z8 CPU
XTAL2
C1
Figure 21. RC Clock
Z8 CPU
User Manual
45
V
SS
UM001602-0904Clock
Z8 Family of Microcontrollers
User Manual
46
ClockUM001602-0904
Reset
Z8 CPU
User Manual
47
This section describes the Z8® CPU reset conditions, reset timing, and
register initialization procedures. Reset is generated by Power-On Reset
(POR), Reset Pin, Watch–Dog Timer (WDT), and Stop-Mode Recovery.
A system reset overrides all other operating conditions and puts the Z8®
CPU into a known state. To initialize the chip’s internal logic, the RESET
input must be held Low for at least 21 SCP or 5 XTAL clock cycles. The
control register and ports are reset to their default conditions after a POR,
a reset from the RESET pin, or Watch–Dog Timer time-out while in RUN
mode and HALT mode. The control registers and ports are not reset to
their default conditions after Stop- Mode Recovery and WDT time-out
while in STOP mode.
While RESET pin is Low, AS is output at the internal clock rate, DS is
forced Low, and R/W remains High. The program counter is loaded with
000Ch. I/O ports and control registers are configured to their default reset
state.
Resetting the Z8® CPU does not affect the contents of the general-purpose registers.
Reset Pin, Internal POR Operation
In some cases, the Z8® CPU hardware RESET pin initializes the control
and peripheral registers, as shown in Tables 12 through 15. Specific reset
values are shown by 1 or 0, while bits whose states are unknown are indicated by the letter U. Tables 12 through 15 show the reset conditions for
the Z8 CPU.
Note:
UM001602-0904Reset
The register file reset state is device dependent. Please refer to the selected
device product specifications for register availability and reset state.
Z8 Family of Microcontrollers
User Manual
48
Table 12. Sample Control and Peripheral Register Reset Values (ERF Bank 0)
Register
(Hex)Register Name
F0Serial I/OUUUUUUUU
F1Timer Mode00000000 Counter/Timers stopped.
F2Counter/Timer1UUUUUUUU
F3T1 PrescalerUUUUUU00 Single-pass count mode,
F4Counter/Timer0UUUUUUUU
F5T0 PrescalerUUUUUUU0 Single-pass count mode.
F6Port 2 Mode11111111 All inputs.
F7Port 3 Mode00000000 Port 2 open-drain, P33–
F8Port 0–1 Mode01001101 Internal Stack, Normal
F9Interrupt PriorityUUUUUUUU
FAInterrupt Request00000000 All Interrupts Cleared.
FBInterrupt Mask0UUUUUUU Interrupts Disabled.
FCFlagsUUUUUUUU
FDRegister Pointer00000000
FEStack Pointer
(High)
FFStack Pointer
(Low)
UUUUUUUU
UUUUUUUU
Bits
Comments76543210
external clock source.
P30 Input, P37–P34
Output.
Memory Timing.
ResetUM001602-0904
Clock
SCLK
Z8 CPU
User Manual
49
Program execution starts 5 to 10 clock cycles after internal RESET has
returned High. The initial instruction fetch is from location 000Ch.
Figure 22 illustrates reset timing.
First Machine Cycle
T1
RESET
AS
DS
R/W
Hold Low For 4 SCLK
Periods (Minimum)
First Instruction Fetch
Figure 22. Reset Timing
After a reset, the first routine executed should be one that initializes the
control registers to the required system configuration.
The RESET pin is the input of a Schmitt-triggered circuit. Resetting the
Z8® CPU will initialize port and control registers to their default states.
To form the internal reset line, the output of the trigger is synchronized
with the internal clock. The clock must therefore be running for RESET
to function. It requires 4 internal system clocks after reset is detected for
the Z8® CPU to reset the internal circuitry. An internal pull-up, combined
with an external capacitor of 1 uf, provides enough time to properly reset
the Z8® CPU (see Figure 23). In some cases, the Z8® CPU has an internal
POR timer circuit that holds the Z8® CPU in reset mode for a duration
UM001602-0904Reset
Z8 Family of Microcontrollers
User Manual
50
(T
POR
internally generated reset drives the reset pin low for the POR time. Any
devices driving the reset line must be open-drained in order to avoid damage from possible conflict during reset conditions. This reset time allows
the on-board clock oscillator to stabilize.
To avoid asynchronous and noisy reset problems, the Z8® CPU is
equipped with a reset filter of four external clocks (4TpC). If the external
reset signal is less than 4TpC in duration, no reset occurs. On the fifth
clock after the reset is detected, an internal RST signal is latched and held
for an internal register count of 18 external clocks, or for the duration of
the external reset, whichever is longer. During the reset cycle, DS is held
active low while AS cycles at a rate of the internal system clock. Program
execution begins at location 000Ch, 5-10 TpC cycles after RESET is
released. For the internal Power-On Reset, the reset output time is specified as T
ues.
) before releasing the device out of reset. On these Z8 devices, the
. Please refer to specific product specifications for actual val-
POR
+5V
100 KΩ
RESET
1K
Figure 23. Example of External Power-On Reset Circuit
ResetUM001602-0904
1 µF
10 V
to
200 KΩ
User Manual
Table 13. Expanded Register File Bank 0 Reset Values at RESET
Z8 CPU
51
Register
(Hex)Register Name
00Port 0UUUUUUUU Input mode, output set to
01Port 1UUUUUUUU Input mode, output set to
02Port 2UUUUUUUU Input mode, output set to
03Port 31111UUUU Standard digital input and
04–EFGeneral-Purpose
Registers 04h–
EFh
Table 14. Sample Expanded Register File Bank C Reset Values
Register
(Hex)Register Name
00SPI Compare
(SCOMP)
01Receive Buffer
(RxBUF)
02SPI Control
(SCON)
UUUUUUUU Undefined.
00000000
UUUUUUUU
UUUU0000
Bits
Comments76543210
push–pull.
push–pull.
open drain.
output
Z86L7X Family Device
Port P34-P37 = 0
(Except Z86L70/71/75)
All other Z8 = 1.
Bits
Comments76543210
UM001602-0904Reset
Z8 Family of Microcontrollers
User Manual
52
Table 15. Sample Expanded Register File Bank F Reset Values
Register
(Hex)Register Name
00Port Configuration
(PCON)
0BStop-Mode
Recovery (SMR)
0FWatch–Dog Timer
Mode (WDTMR)
Bits
Comments76543210
11111110 Comparator outputs
disabled on Port 3.
Port 0 and 1 output is
push–pull.
Port 0, 1, 2, 3, and
oscillator with standard
output drive.
00100000 Clock divide by 16 off.
XTAL divide by 2.
POR and/OR External
Reset.
Stop delay on.
Stop recovery level is low,
STOP flag is POR.
UUU01101 512 TPC for WDT time
out, WDT runs during
STOP.
ResetUM001602-0904
Z8 CPU
User Manual
53
RESET
WDT Select
(WDTMR)
CLK Source
Select (WDTMR)
XTAL
VDD
2.6V REF
WDT
.
From Stop Mode
Recovery Source
RC
OSC.
2.6V Operating
Voltage Det.
+
-
4 Clock
Filter
Clear 18 Clock RESET RESET
CLK Generator
WDT TAP SELECT
256 TpC 256 512 1024 4096
M
POR TpC TpC TpC TpC
U
X
CK CLR
WDT/POR Counter Chain
Internal
RESET
Stop Delay
Select (SMR)
Figure 24. Example of Z8 Reset with RESET Pin, WDT, SMR, and POR
UM001602-0904Reset
Z8 Family of Microcontrollers
User Manual
54
WDT Select
(WDTMR)
CLK Source
Select (WDTMR)
XTAL
V
DD
V
LV
WDT
.
From Stop Mode
Recovery Source
4 Clock
Filter
Internal
RC OSC.
2V Operating
Voltage Det.
+
-
CLEAR
M
U
X
CLK
18 Clock RESET
Generator
5ms POR 5ms 15ms 25ms 100ms
CLK
WDT/POR Counter Chain
CLR
RESET
WDT TAP SELECT
Internal
RESET
Stop Delay
Select (SMR)
Figure 25. Example of Z8 Reset with WDT, SMR, and POR
ResetUM001602-0904
Watch–Dog Timer
The Watch-Dog Timer (WDT) is a retriggerable one-shot timer that resets
the Z8® CPU if it reaches its terminal count. When operating in the RUN
or HALT modes, a WDT reset is functionally equivalent to a hardware
POR reset. The WDT is initially enabled by executing the WDT instruction and refreshed on subsequent executions of the WDT instruction. The
WDT cannot be disabled after it has been initially enabled. Permanently
enabled WDTs are always enabled and the WDT instruction is used to
refresh it. The WDT circuit is driven by an on-board RC oscillator or
external oscillator from the XTAL1 pin. The POR clock source is selected
with bit 4 of the Watch–Dog Timer Mode register (WDTMR). In some
cases, a Z8 that offers the WDT but does not have a WDTMR register, has
a fixed WDT time-out and uses the on board RC oscillator as the only
clock source. Please refer to specific product specifications for selectability of time-out, WDT during HALT and STOP modes, source of WDT
clock, and availability of the permanently-on WDT option.
Z8 CPU
User Manual
55
Execution of the WDT instruction affects the Z (zero), S (sign), and V
(overflow) flags.
UM001602-0904Watch–Dog Timer
Z8 Family of Microcontrollers
User Manual
56
WDTMR (F) 0F
D7 D6 D5 D4 D3 D2 D1 D0
Select for WDT
* Must be 0 for Z86C03
** Default setting after RESET
INT
WDT RC SYS
TAP* OSC CLK
00 5 128
01** 10 256
10 20 512
11 80 2048
WDT During HALT
0 OFF
1 ON *
WDT During STOP
0 OFF
1 ON *
XTAL1/INT RC
0 On-Board RC *
1 XTAL
Reserved (Must be 0)
Reserved (Must be 0)
Figure 26. Example of Z8 Watch–Dog Timer Mode Register (Write-
Only)
The WDTMR register is accessible only during the first 60 processor
cycles from the execution of the first instruction after Power-On Reset,
Watch–Dog Reset or a Stop-Mode Recovery. After this point, the register
cannot be modified by any means, intentional or otherwise. The WDTMR
is a write-only register.
WDTMR is located in Expanded Register File Bank F, register 0Fh. This
register’s control bits are described on the next two pages.
Watch–Dog TimerUM001602-0904
Z8 CPU
User Manual
WDT Time Select. Bits D1 and D0 control a tap circuit that determines
the time-out period. Table 16 shows the different values that can be
obtained. The default value of D1 and D0 are 0 and 1, respectively.
Table 16. Time-Out Period of the WDT
57
Time-Out of
005 ms min256 TpC
0115 ms min512 TpC
1025 ms min1024 TpC
11100 ms min4096 TpC
*Notes: The values given are for VCC = 5.0V. See the device product specification
for exact WDTMR time out select options available.
1. TpC = XTAL clock cycle
2. The default on reset is, D0 = 1 and D1 = 0.
Typical Time-Out of
Internal RC OSCSystem ClockD1D0
WDT During HALT. The D2 bit determines whether or not the WDT is
active during HALT mode. A 1 indicates active during HALT. The default
is 1. A WDT time out during HALT mode will reset control register ports
to their default reset conditions.
WDT During STOP. The D3 bit determines whether or not the WDT is
active during STOP mode. Because XTAL clock is stopped during STOP
mode, unless as specified below, the on-board RC must be selected as the
clock source to the POR counter. A 1 indicates active during STOP. The
default is 1. If bits D3 and D4 are both set to 1, the WDT only, is driven
by the external clock during STOP mode. This feature makes it possible
to wake up from STOP mode from an internal source. Please refer to specific product specifications for conditions of control and port registers
when the Z8® CPU comes out of STOP mode. A WDT time out during
STOP mode will not reset all control registers. The reset conditions of the
ports from STOP mode due to WDT time out is the same as if recovered
using any of the other STOP mode sources.
UM001602-0904Watch–Dog Timer
Z8 Family of Microcontrollers
User Manual
58
Clock Source for WDT. The D4 bit determines which oscillator source
is used to clock the internal POR and WDT counter chain. If the bit is a 1,
the internal RC oscillator is bypassed and the POR and WDT clock source
is driven from the external pin, XTAL1. The default configuration of this
bit is 0, which selects the internal RC oscillator.
Bits 5, 6, and 7. These bits are reserved.
VCC Voltage Comparator. An on-board voltage comparator checks that
VCC is at the required level to insure correct operation of the device. Reset
is globally driven if VCC is below the specified voltage. This feature is
available in select ROM Z8 devices. See the device product specification
for feature availability and operating range.
Power-On-Reset
A timer circuit clocked by a dedicated on-board RC oscillator is used for
the Power-On Reset (POR) timer function, T
VCC and the oscillator circuit to stabilize before instruction execution
begins.
The POR timer circuit is a one-shot timer triggered by one of three conditions:
•
Power fail to Power OK status (cold start)
•
Stop-Mode Recovery (if bit 5 of SMR = 1)
•
WDT time-out
The POR time is specified as T
Mode Recovery register (SMR), bit 5 selects whether the POR timer is
used after Stop-Mode Recovery or by-passed. If bit D5 = 1 then the POR
timer is used. If bit 5 = 0 then the POR timer is by-passed. In this case, the
Stop-Mode Recovery source must be held in the recovery state for 5 TPC
or 5 crystal clocks to pass the reset signal internally. This option is used
Watch–Dog TimerUM001602-0904
. On Z8 devices that feature a Stop-
POR
. This POR time allows
POR
Z8 CPU
User Manual
when the clock is provided with an RC/LC clock. See the device product
specification for timing details.
POR (cold start) will always reset the Z8® CPU control and port registers
to their default condition. If a Z8 has a SMR register, the warm start bit
will be reset to a 0 to indicate POR.
59
VBO
WDT
POR
(Cold Start)
P27
(Stop Mode)
INT OSC
Delay Line
T
ms
POR
XTAL OSC
18 CLK
Reset Filter
Figure 27. Example of Z8 with Simple SMR and POR
Chip
Reset
UM001602-0904Watch–Dog Timer
Z8 Family of Microcontrollers
User Manual
60
Watch–Dog TimerUM001602-0904
I/O Ports
The Z8® CPU features up to 32 lines dedicated to input and output. These
lines are grouped into four 8-bit ports known as Port 0, Port 1, Port 2, and
Port 3. Port 0 is nibble programmable as input, output, or address. Port 1
is byte configurable as input, output, or address/data. Port 2 is bit programmable as either inputs or outputs, with or without handshake and
SPI. Port 3 can be programmed to provide timing, serial and parallel
input/output, or comparator input/output.
All ports have push–pull CMOS outputs. In addition, the push–pull outputs of Port 2 can be turned off for open-drain operation.
Mode Registers
Z8 CPU
User Manual
61
Each port has an associated Mode Register that determines the port’s
functions and allows dynamic change in port functions during program
execution. Port and Mode Registers are mapped into the Standard Register File as shown in Figure 28.
UM001602-0904I/O Ports
Z8 Family of Microcontrollers
User Manual
62
Register
Port 0–1 Mode
Port 3 Mode
Port 2 Mode
Port 3
Port 2
Port 1
Port 0
HEX
F8h
F7h
F6h
03h
02h
01h
00h
Identifier
P01M
P3M
P2M
P3
P2
P1
P0
Figure 28. I/O Ports and Mode Registers
Because of their close association, Port and Mode registers are treated
like any other general-purpose register. There are no special instructions
for port manipulation. Any instruction which addresses a register can
address the ports. Data can be directly accessed in the Port Register, with
no extra moves.
Input and Output Registers
Each bit of Ports 0, 1, and 2, have an input register, an output register,
associated buffer, and control logic. Because there are separate input and
output registers associated with each port, writing to bits defined as inputs
stores the data in the output register. This data cannot be read as long as
the bits are defined as inputs. However, if the bits are reconfigured as outputs, the data stored in the output register is reflected on the output pins
I/O PortsUM001602-0904
Z8 CPU
User Manual
and can then be read. This mechanism allows the user to initialize the outputs prior to driving their loads (see Figure 29).
Because port inputs are asynchronous to the Z8® CPU internal clock, a
READ operation could occur during an input transition. In this case, the
logic level might be uncertain (somewhere between a logic 1 and 0). To
eliminate this meta-stable condition, the Z8® CPU latches the input data
two clock periods prior to the execution of the current instruction. The
input register uses these two clock periods to stabilize to a legitimate logic
level before the instruction reads the data.
63
Note:
Port 0
The following sections describe the generic function of the Z8® CPU
ports. Any additional features of the ports such as SPI, C/T, and StopMode Recovery are covered in their own section.
This section deals with only the I/O operation of Port 0. The port's external memory interface operation is covered later in this manual. Figure 29
shows a block diagram of Port 0. This diagram also applies to Ports 1 and
2.
UM001602-0904I/O Ports
Z8 Family of Microcontrollers
User Manual
64
Port I/O
Lines
88
Input
Register
Read
Port
8
Write
Port
Output
Register
E
Handshake
Selected
Internal
Timing
88
Input
Buffer
Handshake
Handshake
Logic
Logic
Output
Buffer
8
DAV/RDY
RDY/DAV
8
Output
Enable
Internal
Bus
Figure 29. Ports 0, 1, 2 Generic Block Diagram
I/O PortsUM001602-0904
General I/O Mode
Port 0 can be an 8-bit, bidirectional, CMOS or TTL compatible I/O port.
These eight I/O lines can be configured under software control as a nibble
I/O port (P03–P00 input/output and P07–P04 input/output), or as an
address port for interfacing external memory. The input buffers can be
Schmitt-triggered, level shifted, or a single-trip point buffer and can be
nibble programmed. Either nibble output can be globally programmed as
push–pull or open-drain. Low EMI output buffers in some cases can be
globally programmed by the software as an OTP program option or as a
ROM mask option. In such cases, the Z8® MCU features autolatches that
are hardwired to the inputs. Please refer to the specific Z8 MCU product
specification for the exact input/output buffer features that are available
(see Figures 30 and 31).
Z8 CPU
User Manual
65
UM001602-0904I/O Ports
Z8 Family of Microcontrollers
User Manual
66
OPEN-DRAIN
OEN
OUT
IN
1.5
Z8
4
4
2.3V Hysteresis
Port 1
(I/O or AD15–AD08)
Handshake Controls
DAV0 and RDY0
(P32 and P35)
PIN
Autolatch
R ≈ 500 KΩ
Figure 30. Port 0 Configuration with Open-Drain Capability,
Autolatch, and Schmitt-Trigger
I/O PortsUM001602-0904
OEN
OUT
Z8 CPU
User Manual
67
PIN
TTL Level Shifter
IN
Figure 31. Port 0 Configuration with TTL Level Shifter
Read/Write Operations
In the nibble I/0 Mode, Port 0 is accessed as general-purpose register P0
(00h) with ERF Bank set to 0. The port is written by specifying P0 as an
instruction's destination register. Writing to the port causes data to be
stored in the port's output register.
The port is read by specifying P0 as the source register of an instruction.
When an output nibble is read, data on the external pins is returned.
Under normal loading conditions this is equivalent to reading the output
register. However, for Port 0 outputs defined as open–drain, the data
returned is the value forced on the output by the external system. This
may not be the same as the data in the output register. Reading a nibble
defined as input also returns data on the external pins. However, input bits
UM001602-0904I/O Ports
Z8 Family of Microcontrollers
User Manual
68
under handshake control return data latched into the input register via the
input strobe.
The Port 0–1 Mode resistor bits D1–D0 and D7–D6 are used to configure
Port 0 nibbles. The lower nibble (P00–P03) can be defined as inputs by
setting bits D1 to 0 and D0 to 1, or as outputs by setting both D1 and D0
to 0. Likewise, the upper nibble (P04–P07) can be defined as inputs by
setting bits D7 to 0 and D6 to 1, or as outputs by setting both D6 and D7
to 0 (see Figure 32).
Handshake Operation
When used as an I/0 port, Port 0 can be placed under handshake control
by programming the Port 3 Mode register bit D2 to 1. In this configuration, handshake control lines are DAV0 (P32) and RDY0 (P35) when Port
0 is an input port, or RDY0 (P32) and DAV0 (P35) when Port 0 is an output port (see Figure 33).
Handshake direction is determined by the configuration (input or output)
assigned to the Port 0 upper nibble, P04–P07. The lower nibble must have
the same I/0 configuration as the upper nibble to be under handshake control. Figure 30 illustrates the Port 0 upper and lower nibbles and the associated handshake lines of Port 3.
Port 1
This section deals only with the I/0 operation. The port's external memory
interface operation is discussed later in this manual. Figure 29 shows a
block diagram of Port 1.
General I/O Mode
Port 1 can be an 8-bit, bidirectional, CMOS or TTL compatible port with
multiplexed address (A7–A0) and data (D7–D0) ports. These eight I/O
lines can be byte programmed as inputs or outputs or can be configured
under software control as an Address/Data port for interfacing to external
I/O PortsUM001602-0904
Z8 CPU
User Manual
memory. The input buffers can be Schmitt-triggered, level- shifted, or a
single-point buffer. In some cases, the output buffers can be globally programmed as either push–pull or open-drain. Low-EMI output buffers can
be globally programmed by software, as an OTP program option, or as a
ROM Mask Option. In some cases, the Z8® MCU can have autolatches
hardwired to the inputs. Please refer to specific product specifications for
exact input/output buffer-type features available (Figures 32 and 33).
Register F8h (P01M)
Port 0–1 Mode Register (P01M)
(Write-Only)
D7 D6 D1 D0
69
P04–P07 Mode
00 = Output
01 = Input
1X = A12–A15
P00–P03 Mode
00 = Output
01 = Input
1X = A8–A11
Figure 32. Port 0 I/O Operation
Register F7h
Port 3 Mode Register (P3M)
(Write-Only)
D2
0 P32 = Input
P35 = Output
1 P32 = DAV0/RDY0
P35 = RDY0/DAV0
Figure 33. Port 0 Handshake Operation
UM001602-0904I/O Ports
Z8 Family of Microcontrollers
User Manual
70
OPEN-DRAIN
OEN
OUT
IN
1.5
Z8
8
2.3V Hysteresis
Port 1
(I/O or AD7–AD0)
Handshake Controls
DAV1 and RDY1
(P33 and P34)
PIN
Autolatch
R ≈ 500 KΩ
Figure 34. Port 1 Configuration with Open-Drain Capability,
Autolatch, and Schmitt-Trigger
I/O PortsUM001602-0904
Z8 CPU
User Manual
71
OEN
OUT
IN
Z8
TTL Level Shifter
8
Port 1
(I/O or AD7–AD0)
Handshake Controls
DAV1 and RDY1
(P33 and P34)
PIN
Figure 35. Port 1 Configuration with TTL Level Shifter
Read/Write Operations
In byte input or byte output mode, the port is accessed as General-Purpose
Register P1 (01h). The port is written by specifying P1 as an instruction's
UM001602-0904I/O Ports
Z8 Family of Microcontrollers
User Manual
72
destination register. Writing to the port causes data to be stored in the
port's output register.
The port is read by specifying P1 as the source register of an instruction.
When an output is read, data on the external pins is returned. Under normal loading conditions, this is equivalent to reading the output register.
However, if Port 1 outputs are defined as open-drain, the data returned is
the value forced on the output by the external system. This may not be the
same as the data in the output register. When Port 1 is defined as an input,
reading also returns data on the external pins. However, inputs under
handshake control return data latched into the input register via the input
strobe.
Using the Port 0–1 Mode Register, Port 1 is configured as an output port
by setting bits D4 and D3 to 0, or as an input port by setting D4 to 0 and
D3 to 1 (see Figure 36).
R248 P01M
Port 0–1 Mode Register
(F8, Write-Only)
D4 D3
P10–P13 Mode
00 = Byte Output
01 = Byte Output
10 = AD0-AD7
11 = High Impedance AD0–AD7,
AS, DS, R/W,
A8–A11, A12–A15
Figure 36. Port 1 I/O Operation
I/O PortsUM001602-0904
Handshake Operations
When used as an I/O port, Port 1 can be placed under handshake control
by programming the Port 3 Mode register bits D4 and D3 both to 1. In this
configuration, handshake control lines are DAV1 (P33) and RDY1 (P34)
when Port 1 is an input port, or RDY1 (P33) and DAV1 (P34) when Port 1
is an output port. See Figures 37 and 39.
Handshake direction is determined by the configuration (input and output)
assigned to Port 1. For example, if Port 1 is an output port then handshake
is defined as output.
Port 2 is a general-purpose port. Figure 29 shows a block diagram of Port
2. Each of its lines can be independently programmed as input or output
via the Port 2 Mode Register (F6h) as seen in Figure 38. A bit set to a 1 in
P2M configures the corresponding bit in Port 2 as an input, while a bit set
to 0 configures an output line.
UM001602-0904I/O Ports
Z8 Family of Microcontrollers
User Manual
74
Register F6h
Port 2 Mode Register (P2M)
(Write-Only)
D7 D6 D5 D4 D3 D2 D1 D0
Figure 38. Port 2 I/O Mode Configuration
General Port I/O
Port 2 can be an 8-bit, bidirectional, CMOS- or TTL- compatible I/O port.
These eight I/O lines can be configured under software control to be an
input or output, independently. Input buffers can be Schmitt-triggered,
level-shifted, or a single trip point buffer and may contain autolatches.
Bits programmed as outputs may be globally programmed as either push–
pull or open-drain. Low-EMI output buffers can be globally programmed
by the software, an OTP program option, or as a ROM mask option. In
addition, when the SPI is featured and enabled, P20 functions as data-in
(DI), and P27 functions as data-out (DO). Please refer to specific product
specifications for exact input/output buffer type features available. See
Figures 39 through 41.
Port 2 Mode
0 = Output
1 = Input
I/O PortsUM001602-0904
OPEN-DRAIN
P21–P26 OE
P21–P26 OUT
Z8 CPU
User Manual
75
P21–P26
PIN
P21–P26 IN
1.5
2.3V Hysteresis @ VCC = 5.0V
Autolatch
R ≈ 500 KΩ
Figure 39. Port 2 Configuration with Open-Drain Capability,
Autolatch, and Schmitt-Trigger
UM001602-0904I/O Ports
Z8 Family of Microcontrollers
User Manual
76
Open-Drain
OEN
OUT
TTL Level Shifter
IN
PIN
Figure 40. Port 2 Configuration with TTL Level Shifter
I/O PortsUM001602-0904
OPEN-DRAIN
P20 OE
SPI EN
P20 OUT
P20 IN
or
SPI DI
OPEN-DRAIN
Z8 CPU
User Manual
77
P20
PIN
Autolatch
R ≈ 500 KΩ
P27 OUT
SPI DO
SPI DO
P27 OE
SPI Active
P27 IN
Standard
SPI
Standard
SPI
SCON
D2
0 SOI D0 Enable
1 P27 OUT
*SPI must be enabled with D0
R ≈ 500 KΩ
P27
PIN
Autolatch
Figure 41. Port 2 Configuration with Open-Drain Capability,
Autolatch, Schmitt-Trigger and SPI
UM001602-0904I/O Ports
Z8 Family of Microcontrollers
User Manual
78
Read/Write Operations
Port 2 is accessed as General-Purpose Register P2 (02h). Port 2 is written
by specifying P2 as an instruction’s destination register. Writing to Port 2
causes data to be stored in the output register of Port 2, and reflected
externally on any bit configured as an output.
Port 2 is read by specifying P2 as the source register of an instruction.
When an output bit is read, data on the external
pin is returned. Under normal loading conditions, this is equivalent to
reading the output register. However, if a bit of Port 2 is defined as an
open-drain output, the data returned is the value forced on the output pin
by the external system. This may not be the same as the data in the output
register. Reading input bits of Port 2 also returns data on the external pins.
However, inputs under handshake control return data latched into the
input register via the input strobe.
Handshake Operation
Port 2 can be placed under handshake control by programming bit 6 in the
Port 3 Mode Register (see Figure 42). In this configuration, Port 3 lines
P31 and P36 are used as the handshake control lines DAV2 and RDY2 for
input handshake, or RDY2 and DAV2 for output handshake.
Handshake direction is determined by the configuration (input or output)
assigned to bit 7 of Port 2. Only those bits with the same configuration as
P27 will be under handshake control. Figure 43 illustrates the bit lines of
Port 2 and the associated handshake lines of Port 3.
Port 3 differs structurally from Port 0, 1, and 2. Port 3 lines are fixed as
four inputs (P33–P30) and four outputs (P37–P34) Port 3 does not have
an input and output register for each bit. Instead, all of the input lines have
one input register, and all of the output lines have an output register. Port
3 can be a CMOS- or TTL- compatible I/O port. Under software control,
the lines can be configured as special control lines for handshake, comparator inputs, SPI control, external memory status, or I/O lines for the
on-board serial and timer facilities. Figure 44 is a generic block diagram
of Port 3.
The inputs can be Schmitt-triggered, level-shifted, or single-trip point
buffered. In some cases, the Z8® MCU may have autolatches hardwired
on certain Port 3 inputs and Low-EMI capabilities on the outputs. Please
refer to specific product specifications for exact input/output buffer type
features. Please refer to the section on counter/timers, Stop-Mode Recovery, serial I/O, comparators, and interrupts for more information on the
relationships of Port 3 to that feature.
I/O PortsUM001602-0904
Z8 CPU
User Manual
81
Read
Port
Input
4
Read
4
Port
4
Input
Register
Output
Data
Return
Buffer
4
To Interrupt Timer,
Handshake Logic,
or Serial I/O
Input
Buffer
Buffer
Port
Input
4
Lines
P30–P3
3
Write
Port
4
Internal
Bus
Output
Output
Output
Register
Register
Register
4
From Timer,
Handshake Logic,
or Serial I/O
Output
Output
Buffer
Buffer
Port
Output
4
Lines
P34–P3
7
Figure 44. Port 3 Block Diagram
UM001602-0904I/O Ports
Z8 Family of Microcontrollers
User Manual
82
I/O PortsUM001602-0904
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.