Dear Intel Customer:
We have updated the infor ma tion that was provided in the 1992 version of the 8XC196MC User’s
Manual, added information about the 8XC196MD and 8XC196MH, and corrected known errata.
We hope these changes make it easier for you to use our products. Your feedback will help us to
provide the information you need. We’ll use your responses to guide us in developing other manuals and new versions of this one.
Does the manual contain the information that you need? If not, what’s missing?
What do you like the most about thi s manual?
What do you like t he least about this manual?
How would you rate the overall quality? (1=awful, 2=average, 3=better than average) ________ _
Name
Title
Company
Address
City, State or Country
Zip Code or Postal Cod e
Phone
Fax
Intel product s us ed
Type of application
Please fax this f orm to (602)554-7436 or mail it to
Marcia Bethel, Glenn Dotson, Robin Manelis, and Sue Ranta
Technical Information Developers
Intel Corpor ation, Mail Stop CH6-224
5000 W. Chandl er Blv d.
Chandler, AZ 85226
-2
8XC196MC,
8XC196MD, 8XC196MH
Microcontrol ler
User’s Manual
August 2004 Order Number 272181-003
Information in this document is provided solely to enable use of Intel products. Intel assumes no liability whatsoever, including
infringement of any patent or copyrig ht, for sale and use of Intel products except as provided in Intel’s Terms and Conditi on s
of Sale for such products.
Intel Corporation makes no warranty for the use of its products and assumes no responsibility for any errors which may appear
in this document nor does it make a commitment to update the information contained herein.
Intel retains the right to make changes to these specifications at any time, without notice.
Contact your local Intel sales office or your distributor to obtain the latest specifications before placing your product order.
MDS is an ordering code only and is not used as a product name or trademark of Intel Corporation.
Intel Corporation and Intel’s FASTPATH are not affiliated with Kinetics, a division of Excelan, Inc. or its FASTPATH trademark
or products.
*Other brands and names are the property of their respective owners.
Additional copies of this document or other Intel literature may be obtained from:
Intel Corporation
Literature Sales
P.O. Box 7641
Mt. Prospect, IL 60056-7641
_TIME Addresses and Reset Values............................................................C-17
x
_CON Addresses and Reset Values................................................................C-20
x
_TIME Addresses and Reset Values................................................................C-21
_DIR Addresses and Reset Values.......................................................................C-30
_MODE Addresses and Reset Values..................................................................C-31
_PIN Addresses and Reset Values.......................................................................C-33
_REG Addresses and Reset Values.....................................................................C-34
xviii
Guide to This Manual
1
CHAPT ER 1
GUIDE TO THIS MANUAL
This manual describes the 8XC1 96MC, 8XC196M D, and 8XC196M H embedded microcontrollers. It is intended for use by both software and hardware designers familiar with the principles
of microcontrollers. This chapter describes what you’ll find in this manual, lists other documents
that may be useful, and explains how to access the support services we provide to help you complete your design.
1.1MANUAL CONTENTS
This manual contai ns several chapters and appen dixes, a glossary, and an index. Thi s chapter,
Chapter 1, provides an ov e rview of the manua l. Thi s section su m mariz es the conte nts of the remaining chapters and appendixes. The remainder of this chapter describes notational conventions
and terminology used throughout the manual, provides refere nc es to re late d doc ument ation, describes custome r support services, and explains how to access information and assi stance .
Chapter 2 — Architectural Overvi ew — provides an over view of the device hardware. It describes the core, internal timing, int ernal periphera ls, and special operati ng modes.
Chapter 3 — Programming Considerations — provides an overview of the instruction set, describes general standards a nd conventions, and defines the ope rand types and addres sing mode s
supported by the MCS
tion set, see Appendix A.)
®
96 microcontroller family . (For additional information about the instruc-
Chapter 4 — Me m ory Par titions — describe s the a d dressa ble memory spa ce of the devi ce. It
describes the mem ory partitions and explains how to use win dows to increa se the amount of
memory that can be accessed with register-direct instructions.
Chapter 5 — Standard and PTS Interrupts — describes the interrupt control circuitry , priority
scheme, and timing for standard and perip heral transaction server (PTS) inter rupts. It also explains interrupt programming and control.
Chapter 6 — I/O Ports — describes the input/out put ports and explains how to configure the
ports for input, output, or special functions.
Chapter 7 — Serial I/O (SIO) Port — describes the 8XC196M H ’s asynchronous/synchronous
serial I/O (SIO) port and explains how to program it.
Chapter 8 — Frequency Generator — describes the 8XC196MD’s frequency generator and explains how to configure it. For additional information and application examples, consult AP-483,
Application Examples Usi ng the 8XC196MC / MD Mic rocontroller (order number 272282).
1-1
8XC196MC, MD, MH USER’S MANUAL
Chapter 9 — Waveform Generator — describes the waveform gene rator and expl ains h ow to
configure it. For additional information and application examples, consult AP-483, ApplicationExamples Using the 8XC196MC/MD Microcontroller (order number 272282).
Chapter 10 — Pulse-wi dth Modulat or — provides a funct ional overview of the pulse width
modulator (PWM) mo dules, describes how to program them, and provides sample circuitry f or
converting the PWM outputs to anal o g signals.
Chapter 11 — Event Processor Array (EPA) — describes the eve nt processor array, a timer/counter-based, high-speed input/outp ut u nit. It de scri bes t he timer/counters a n d expla ins h ow
to program the EPA and how to use the EPA to produce pulse-width modulated (PWM) outputs .
Chapter 12 —Anal og-to-digital (A/D) Converter— provides an overview of the analog-todigital (A/D) converter and describes how to program the converter, read the conversion results,
and interface with external circuitry.
Chapter 13 — Minimum Hardware Considerations — describes options for providing the basic requirements for devi ce operat ion w ithin a system , discuss es other hardware considerati ons,
and describes device reset o ptions.
Chapter 14 — Spec ial Operating Modes — provides an overview of the idle, powerdown,
and on-circuit emulation (ONCE ) modes and describes how to enter and exit each mode.
Chapter 15 — Interfacing with External Memory — lists the external memory signals and describes the registers tha t control the exte rnal memory interface. It discusses the bus width and
memory configurations, the bus-hold protocol, write-control modes, and internal wait states and
ready control. Finall y, it provides timing information for the system bus.
Chapter 16—Programming the Nonvolatile Memory — provides recommended circuits, the
corresponding memory maps, and flow diagrams. It also provides procedures for auto programming.
Appendix A — Instruction Set Reference — provides reference information for the instruction
set. It describes each instruction; defines the processor sta tus word (PSW) flags; shows the relationships between instructions and PSW flags; and lists hexadecimal opcodes, instruction
lengths, and execution times. (For additional information about the instruction set, see Chapter 3,
“Programming Consideratio ns.”)
Appendix B — Signal Descr iptions — provides referenc e information for the device pins, including descriptions of the pin functions, reset status of the I/O and control pins, and package pin
assignments.
1-2
GUIDE TO THIS MANUAL
Appendix C — Re gisters — provides a compilation of all device special-function registers
(SFRs) arranged alphabeti cally by register mnemonic . It also includes tables that list the windowed direct addresses for all SFRs in each possible window.
Glossary — define s terms with spec ial me aning used th roughout this manual.
Index — lists key topics with page number references.
1.2NOTATIONAL CONV ENTI ONS AND TERMINOLOGY
The following notations an d terminol ogy are used throughout this manual. The Glossary defines
other terms with special meanings.
#The pound symbol (#) has either of two meanings, depending on the
context. When used wi th a signal name, the symbol means that the
signal is active low. When used in an instruction, the symbol prefixes
an immediate value in immediate addressing mode.
assert and deassertThe terms assert and deassert refer to the act of making a signal
active (enabled) and inactive (disabled), respectively. The active
polarity (low or high) is defined by the signal name. Active-low
signals are designated by a pound symbol (#) suffix; active-high
signals have no suffix. To assert RD# is to drive it low; to assert ALE
is to drive it high; to deassert RD# is to drive it high; to deassert ALE
is to drive it low.
clear and setThe terms clear and set refer to the value of a bit or the act of giving
it a value. If a bit is c lear, its val ue is “0”; cleari ng a bit gives it a “0”
value. If a bit is set, its value is “1”; settin g a bit gives it a “1” value.
instructionsInstruction mnem onics are shown in upper case to av oid confusion.
In general, you may use either upper case or lower case when
programming. Consult the manual for your assembl er or compiler to
determine its specific req uirem ent s.
italicsItalics identify variables and introduce new terminology. The context
in which italics are used distinguishes between the two possible
meanings.
Vari able s in regist ers and signal names are commonly represente d by
x and y, where x represents the first variable and y represents the
second variable . For example, in register P x_MODE.y, x represents
the variable that identifies the specific port associated with the
register, and y represents the register bit variable (7:0 or 15:0).
Vari ables must be replaced with the correct values when configuring
or programming regi sters or ident ifyi ng signals.
1-3
8XC196MC, MD, MH USER’S MANUAL
numbersHexadecimal numbers are represented by a string of hexadecimal
digits followed by the character H. Decimal and binary numbers are
represented by t heir customa ry notations. (That is, 255 is a decimal
number and 1111 1111 is a binary number. In some cases, the letter B
is appended to binary numbers for clarity.)
register bitsBit locations are indexed by 7:0 (or 15:0), where bit 0 is the least-
significant bit and bit 7 (or 15) is the most-significant bit. An
individual bit is represented by the register name, followed by a
period and the bit number. For example, WSR.7 is bit 7 of the
window selection register. In some discuss ions, bit names are used.
register namesRegister mnemonics are shown in upper case. For example, TIMER2
is the timer 2 register; timer 2 is the timer. A register name containing
a lowercase italic character represents more than one register. For
example, the x in Px_REG indicate s that the register name re fers to
any of the p ort data registers.
reserved bitsCertain bits are described a s reserved bits. In illustrat ions, reserved
bits are indicated with a dash (—). These bits are not used in this
device, but they may be used in future implementations. To help
ensure that a current software design is compatible with future implementations, rese rved bits should be c leared (given a value of “0”) or
left in thei r de fault states, unles s ot he rwis e not ed. Do not rel y o n the
values of reserved bits; conside r them undefin ed.
signal namesSignal names are shown in upper case. When several signals share a
common name, an individual signal is represented by the signal name
followed by a number. For example, the EPA signals are named
EPA0, EPA1, EPA2, etc. Port pins are represente d by t he p ort ab breviation, a period, a nd the pin number (e.g., P1.0, P 1.1); a range of
pins is represented by Px.y:z (e.g., P1.4:0 represents five port pins:
P1.4, P1.3, P1.2, P1.1, P1.0). A pound symbol (#) appended to a
signal name identifies an active-low signal.
1-4
GUIDE TO THIS MANUAL
units of measureThe following abbreviations are used to represent units of measure:
XUppercase X (no italics) represents an unknown value or an
elevant (“don’t care”) state or condition. The value may be either
irr
or hexadecimal, depending on the context. For example,
binary
2XAFH
ind
(hex) indicates that bits 11:8 are unknown; 10XXB (binary)
icates that the two least-significant bits are unknown.
1.3RELATED DOCUMENTS
The tables in this section list additional documents that you may find useful in designing systems
corporating MCS 96 microcontrollers. These are not comprehensive lists, but are a representa-
in
tive sample of relevant documents. For a complete list of available printed documents, please or-
the literature catalog (order number 210621). To order documents, please call the Intel
der
literature center for your area (telephone numbers are listed on page 1-11).
1-5
8XC196MC, MD, MH USER’S MANUAL
Table 1-1. Handbooks and Product Information
Title and DescriptionOrder Number
Intel Embedded Quick Reference Guide
Solution s for Embedd ed Appl icat io ns Guide
Data on Dema nd
Data on Dema nd
Complete set of Intel handbooks on CD-ROM.
Handboo k Set
Complete set of Intel’s product line handbooks. Contains datasheets, application
notes, article reprints and other desig n informatio n on microprocessors, peripherals, embedded controllers, memory components, single-board computers,
microcommunications, software development tools, and operating systems.
Automotive Products
Application notes and article reprints on topics including the MCS 51 and MCS 96
microcon trol le r s. Docu men t s in this handb ook discuss hardware and software
implementations and present helpful design techniques.
Embedded A pplications
Datasheets, architecture descriptions, and application notes on topics including
flash memor y device s, netwo rkin g chips, an d MCS 51 and MCS 96 microc ontrollers. Documents in this handbook discuss hardware and software implementations and present helpful design techniques.
Embedded Microcontrollers
Datasheets and architecture descriptions for Intel’s three industry-standard microcontrollers, the MCS 48, MCS 51, and MCS 96 microcontrollers.
Peripheral Components
Comprehensive information on Intel’s peripheral components, including
datasheets, application notes, and technical briefs.
Flas h Memory
A collection of datasheets and application notes devoted to techniques and
information to help design semiconductor memory into an application or system.
Packaging
Detailed information on the manufacturing, applications, and attributes of a variety
of semiconductor packages.
Development Tools Handbook
Information on third-party hardware and software tools that support Intel’s
embedded microcontrollers.
Table 1-2. Application Notes, Application Briefs, and Article Reprints
TitleOrder Number
Using the SIO on the 8XC196MH
Designing Microcontroller Systems for Electrically Noisy Environments
Oscillators for Microcontrollers
Motor Controllers Take the Single-Chip Route
Automotive Products
Embedded Applications
Automotive Products
(application brief)272594
†††
†††
(article reprin t) 270056
handbook (order number 231792)
handbook (order number 270648)
and
Embedded Applications
handbooks
210313
230659
GUIDE TO THIS MANUAL
Table 1-2. Application Notes, Application Briefs, and Article Reprints (Continued)
TitleOrder Number
AP-406,
AP-445,
AP-449,
MCS® 96 Analog Acquisition Primer
8XC196KR Peripherals: A User’s Point of View
A Comparison of the Event Processor Array (EPA) and High Speed
Input/Output (HSIO) Unit
AP-475,
Using the 8XC196NT
AP-477,
AP-483,
AP-700,
AP-711,
AP-715,
†
††
†††
Low Voltage Embedded Design
Application Examples Using the 8XC196MC/MD Microcontroller
Intel Fuzzy Logic Tool Simplifies ABS Design
EMI Design Techniques for Microcon tro llers in Auto mo ti ve Appl icat io ns
Interfacing an I2C Serial EEPROM to an MCS® 96 Microcontroller
We offer a variety o f information throug h th e World Wide Web (URL:http://www.intel.com/). Select “Embedded Design Products” from the Intel home page.
1.5TECHNICAL S UPPO RT
In the U.S. and Canada, technical support representatives are availabl e to answer your questions
between 5 a.m. and 5 p.m. PST. You can also fax your questions to us. (Please include your voice
telephone number and indicate whether you prefer a response b y phone or by fax). Outside the
U.S. and Canada, please contac t your local distribut or.
1-800-628-8686U.S. and Canada
916-356-7599U.S. and Canada
916-356-6100 (fax)U.S. and Canada
1.6PRODUCT LITE RAT U RE
You can order product literature from the following Intel literat ure centers .
The 16-bit 8XC196M C, 8XC196MD, and 8XC1 96MH C HMOS m icrocontrollers are desig ned
to handle high -speed calcul ations and fast input/out put (I/O) operat ions. They shar e a common
architecture and instruction set with other members of the MCS
NOTE
This manual describes a family of microcontrollers. For brevity, the name
8XC196Mx is used when the discussion applies to all family members. When
information applies to spe ci fic microcontrollers, individual product names are
used.
2.1TYPICAL APPLICATIONS
MCS 96 microcont rollers are t ypically use d for high-speed event control s ystems. Commerci al
applications include modems, motor-control systems, printers, photocopiers, air conditioner control systems, disk drives, and medical instruments. Automotive customers use MCS 96 microcontrollers in engi ne-control systems, airba gs, suspension systems, and a ntilock braking system s
(ABS).
2.2M ICROCON TROL LER FEATURES
®
96 microcontroller family.
Table 2-1 lists the features of each member of the 8XC196Mx family.
2-1
8XC196MC, MD, MH USER’S MANUAL
T able 2-1. Features of the 8XC196Mx Product Family
1.No nvol at ile memo r y is optional. The second chara ct er of the device name indicat es the prese nce and
type of nonvolat ile memory. 80C196M
2.Re gist er RAM amoun ts include the 24 bytes allocat ed to core SFR s and the stack pointer.
3.The 8XC196MC and 8XC19 6MD have no serial I/O ports, but have PTS modes that allow asynchronous or synchronous serial communication.
4.The numb er of PWM ch annels in clud es the ou tputs fro m the PW M periph er al and the waveform generator. For the 8XC196MD, it also includes the output from the frequency generator.
ROM
Bytes
(Note 1)
Register
RAM
Bytes
(Note 2)
I/O
EPA
Pins
Pins
x
= none; 83C196Mx = ROM; 87C196Mx = OTPROM.
SIO
Ports
(Note 3)
PWM
Channels
(Note 4)
A/D
Channels
External
Interrupt
Pins
2.3FUNCTIONAL OVERVIEW
Figure 2-1 shows the majo r blocks within the m icrocontroll er. The core of the mi crocontrolle r
(Figure 2-2) consists of the central processing unit (CPU) and memory controller. The CPU contains the register file and the register arithmetic-logic unit (RALU). A 16-bit internal bus connects
the CPU to both the memory controller and the interrupt controller. An extension of this bus connects the CPU to the internal peripheral mo dules. In addition, an 8-bit internal bus transfers instruction bytes from the memory controll er to the inst ruction regist er in the RALU .
2-2
ARCHITECTURAL OVERVIEW
Core
Clock and
Power Mgmt.
PWMI/O
Note:
The frequency generator is unique to the 8XC196MD.
The serial I/O port is unique to the 8XC196MH.
Optional
ROM
WG
Interrupt
Controller
A/DEPA
Figure 2-1. 8XC196Mx Block Diagram
CPU
Register File
RALU
Microcode
Engine
PTS
WDT
Memory Controller
Prefetch Queue
FG
Slave PC
SIO
A2798-02
Register
RAM
CPU SFRs
Figure 2-2. Block Diagram of the Core
ALU
Master PC
PSW
Registers
Address Register
Data Register
Bus Controller
A2797-01
2-3
8XC196MC, MD, MH USER’S MANUAL
2.3.1CPU Control
The CPU is controlled by the microcode engine, which instructs the RALU to perform operations
using bytes, words, or double-words from either the 256-byte lower register file or through a win-dow that directly accesses the upper register file. (See Chapter 4, “Memory Partitions,” for more
information about the register file and windowing.) CPU instructions move from the 4-byte
prefetch queue in the memory controller into the RALU’s instruction register. The microcode engine decodes the instruct i ons an d then generates the seque nce of eve nts that cause desi red fu nctions to occur.
2.3.2Register File
The register file is divided into an upper and a lower file. In the lower register file, the lowest 24
bytes are allocated to the CPU’ s special-function registers (SFRs) and the stack pointer, while the
remainder is available as general -purpose register RAM. The upper register file cont ains only
general-purpose register RAM. The register RAM can be accessed as bytes, words, or double words.
The RALU accesses the upper and lower register files differently. The lower register file is always
directly accessible with direct addressing (see “Addressing Modes” on page 3-5). The upper register file is accessible with direct addressing only when windowing is enabled. Windowing i s a
technique that maps blocks of the upper register file into a window in the lower regist er file. See
Chapter 4, “Memory Partitions,” for more information about the register file and windowing.
2.3.3Register Arithmetic-logic Unit (RALU)
The RALU contains the microcode engine, the 16-bit arithmetic logic unit (ALU), the master program counter (PC), the processor status word (PSW), and several registers. The regist ers in the
RALU are the instr uction register, a constants register, a bit-select register, a loop counter, and
three temporary registers (the upper-word, lower-word, and second-operand registers).
The PSW contains one bit (PSW.1) that globally enables or disables servicing of all maskable interrupts, one bit (PSW.2) that enables or disables the peripheral transaction server (PTS), and six
Boolean flags that reflect the state of your program. Appendix A, “Instruction Set Refe rence,”
provides a detailed descript ion of the PSW.
All registers, except the 3-bit bit-select register and the 6-bit loop counter, are either 16 or 17 bits
(16 bits plus a sign extension). Some of these registe rs can reduce the ALU’s workload by performing simple operations.
2-4
ARCHITECTURAL OVERVIEW
The RALU uses the upper- and lower-word registers together for the 32-bit instructions and as
temporary registers for many instructions. These registers have their own shift logic and are used
for operations that require logical shifts, including norm alize, multiply, and divide operations.
The six-bit loop counter counts repetitive shifts. The seco nd-operand register stores the second
operand for two-operand instructions, including the multiplier during multiply operations and the
divisor during divide operations. During subtraction operations, the output of this register is complemented before it is moved into the ALU.
The RALU speeds up calculations by storing constants (e.g., 0, 1, and 2) in the constants register
so that they are readily available when complem enting, incre menti ng, or decreme nting bytes or
words. In addition, the co nstants regi ster ge nera tes singl e-bit mas ks, base d on the bit-se lect register, for bit-test instructions.
2.3.3.1Code Execution
The RALU performs most calculations for the microcontrol ler, but it does not use an accumulator. Instead it operates directly on the lower register file, which essentially provides 256 accumu-
lators. Because data does not flow through a single accumulator, the microcontroller ’s code
executes faster and more efficiently.
2.3.3.2Instruction Format
MCS 96 microcontrollers combi ne a la rge set of general-purpose registers wi th a three - operand
instruction form at. This format allows a single inst ruction to spe cify two source re gisters an d a
separate destination register. For example, the following instructio n multiplies two 16-bit variables and stores the 32-bit result in a third variable .
MUL RESULT, FACTOR_1, FACTOR_2;multiply FACTOR_1 and FACTOR_2
;and store answer in RESULT
;(RESULT)←(FACTOR_1 × FACTOR_2)
An 80C186 microprocessor requires four instructions to accomplish the same operation. The following example shows the equivalent code for an 80C186 microprocessor.
MOV AX, FACTOR_1;move FACTOR_1 into accumulator (AX)
The RALU communicates with all memory, except the register file and peripheral SFRs, through
the memory controller. (It communicates with the upper register file through the memory controller except when windowing is used; see Chapter 4, “Memory Partitions.”) The memory controller
contains the prefetch queue, the slave program counter (slave PC), address and data registers, and
the bus co ntroller.
The bus controller drives t he memory bus, which consists of an internal memory bus and the external address/data bus. The bus controller receives memory-access requests from either the
RALU or the prefetch queue; queue requests always have priority. This queue is transparent to
the RALU and your software.
NOTE
When using a logic analyzer to debug code, remember that instructi ons are
preloaded into the prefetch queue and are not necessari l y execute d
immediately aft er they are fetched.
When the bus controller receives a re q uest from the queue, it fetches the code f r om the address
contained in the sl ave PC . The slave PC increa ses exec utio n speed bec ause the next inst ructi on
byte is available immediately and the processor need not wait for the master PC to send the address to the memory controller. If a jump, interrupt, call, or return changes the address sequence,
the master PC loads the new address into the slave PC, then the CPU flushes the queue and continues processing.
2.3.5Interru pt Ser vic e
The microcontroller’s flexible interrupt-handling system has two main components: the programmable interrupt controll er and t he perip heral transa ction se rver (PTS). The programmabl e interrupt controller has a hardware priority schem e that can be modified by your software. Interrupts
that go through the in terrupt controller are serviced by in terrupt service routines that you provide.
The peripheral transaction server (PTS), a microcoded hardware interrupt processor, provides
high-speed, low-overhead interrupt handl ing. You can configure m ost interrupts (except NM I,
trap, and unimplemented opcode) to be servic ed by the PTS instead of the interrupt contr oll er.
The PTS can transfer bytes or words, either individually or in blocks, between any memory locations, manage multiple analo g-to-digi tal (A/D) conversi o ns, and can generat e puls e-wi dth modulated (PWM) signals. The 8XC196MC and 8XC196MD have additional modes that allow
asynchronous or synchronous serial communication. PTS interrupts have a higher priority than
standard interrupts and may t emporarily suspend int errupt service routines. See Chapter 5, “Standard and PTS Interrupts,” for more information.
2-6
ARCHITECTURAL OVERVIEW
2.4INTERNAL TIMING
The clock circuitry (Figure 2-3) receives an input clock signal on XTAL1 provided b y an external
crystal or oscillator and divi des the fre quency by two. T he cl ock generato rs accept the divided
input frequency from the divide-by-two circuit and produce two nonoverlapping internal timing
signals, PH1 and PH2. These signals are active when high.
.
Disable Clock Input
(Powerdown)
F
XTAL1
XTAL2
XTAL1
Disable
Oscillator
(Powerdown)
Divide-by-two
Circuit
Clock
Generators
Disable Clocks
(Powerdown)
Peripheral Clocks (PH1, PH2)
CLKOUT
CPU Clocks (PH1, PH2)
Disable Clocks
(Idle, Powerdown)
NOTE: The CLKOUT pin is unique to the 8XC196MC and MD.
A3115-02
Figure 2-3. Clock Circuitry
The rising edges of PH1 and PH2 generate the internal CLKOUT signal (Figure 2-4). The clock
circuitry routes separate internal clock signals to the CPU and the peripherals to provide flexibility in power manageme nt. (“Reducing Powe r Consumption” on pa ge 14-3 des cribes the p ower
management modes.) The 8XC 196MC and 8XC196M D microcontrol lers output the CLKOUT
signal on the CLKOUT pin. Because of the complex logic in the clock circuitry, the signal on the
CLKOUT pin is a delayed version of the internal CLKOUT signal. This delay vari es with temperature and voltage.
The 8XC196MH mic rocontroller has no CLKOUT pin. If your 8XC1 96MH design requires a
system clock, we recommend that you use an external oscillator and add external logic to generate
the system clock signal.
2-7
8XC196MC, MD, MH USER’S MANUAL
XTAL1
T
XTAL1
1 State Time
PH1
PH2
CLKOUT
T
XTAL1
1 State Time
Phase 1Phase 2
Phase 1Phase 2
A0114-04
Figure 2-4. Internal Clock Phases
The combined period of phase 1 and phase 2 of the internal CLKOUT signal defines the basic
time unit known a s a state time or state. Tab le 2-2 l ists state time durations at var ious frequencies.
Table 2-2. State Times at Various Frequencies
F
(Frequency Input to the
Divide-by-two Circu it)
XTAL1
State Time
8 MHz250 ns
12 MHz167 ns
16 MHz125 ns
The following formulas calculate the frequency of PH1 and PH2, the duration of a state time, and
the duration of a clock period (T
F
XTAL1
PH1 (in MHz)
------- ----------- -
PH2==State Time (in µs)
2
XTAL1
).
2
----- ----------- -- -
=T
F
XTAL1
XTAL1
=
1
------- ------------
F
XTAL1
Because the microcontroll er can operate at many frequencies, this manua l defines time requirements (such as instruction exec ution times ) in terms of state ti mes rather tha n spec ific m easu rements. Datasheets list AC characteri stics in terms of clock periods (T
XTAL1
or T
OSC
).
2.5INTERNAL PERIPHERALS
The internal peripheral modules provide special functions for a variety of applications. This section provides a brief description of the periphera ls; su bsequent chapters descri be them in detail.
2-8
ARCHITECTURAL OVERVIEW
2.5.1I/O Ports
The 8XC196Mx microcontrollers have seven I/O ports, ports 0–6. The 8XC196MD has an additional port, port 7. Individual port pins are multiplexed to serve as standard I/O or to carry specialfunction signals associ ated w ith an on-chip peri pheral or an off-chip component. If a particula r
special-function s ignal is not use d in an appli ca tion, the as soci ated pi n c an be individual l y configured to serve as a standard I/O pin. Ports 3 and 4 are exceptions; they are controlled at the port
level, not at the pin level. When the bus controller needs to use the address/data bus, it takes control of the ports. When the address/data bus is idle, you can use the ports for I/O.
Port 0 is an input-only port that is also the analog input for the A/D converter. On the 8XC196MH,
port 0 provides two pins for the EPA. On the 8XC196MC and 8XC196MD, port 1 is also an inputonly port that provides analog inputs for the A/D converter. On the 8XC196MH, port 1 is a bidirectional port that shares pins wit h the seria l I/O port.
Port 2 is a s tandard, bidirectional I/O port th at provides p ins for the EP A and timers. Port 7, which
is unique to the 8XC196MD, is a standard, bidirectional I/O port that provides additional pins for
the EP A and also provides pins for the frequency generator. Por ts 3, 4, and 5 are memory-mapped,
bidirectional I/O ports. Ports 3 and 4 serve as the external address/data bus, while port 5 provides
bus-control signals. Port 6 is a standard, output-only port that provides pins for the puls e-width
modulator and waveform generator. Chapter 6, “I/O Ports,” describes the I/O ports in more detail.
2.5.2Seria l I/O (SIO) P ort
The 8XC196MH microcontroller has a two-channel serial I/O port that shares pins with ports 1
and 2. (The 8XC196MC and 8XC196MD have no serial I/O ports, but have PTS modes that allow
asynchronous or synchronous serial communication. See Chapter 5, “Standard and PTS Interrupts,” for more information.) The serial I/O (SIO) port is an asynchronous/synchronous port that
includes a universal asynchronous receiver and transmitter (UART ). The UART has two synchronous modes (modes 0 and 4) and three asynchronous modes (modes 1, 2, and 3) for both transmission and recepti on. The a sy nchr onous modes are full duplex, meaning that they can transmit
and receive data simultaneously. The receiver is buffered, so the reception of a second byte can
begin before the first byte is read. The transmitter is also buffered, allowing continuous transmissions. The SIO port has two channels (channels 0 and 1) with identical signals and regist ers. See
Chapter 7, “Seria l I/O (SIO ) Port,” for details.
2-9
8XC196MC, MD, MH USER’S MANUAL
2.5.3Event Processor Arra y (EPA) and Timer/Counters
The event processor array (EPA) performs high-speed input and output functions associated with
its timer/counte rs. In t he input mode, the EPA monitors an input for signal tra nsitions. When an
event occurs, the EPA records the timer value assoc iated with it. This is a capture event . In the
output mode, the EPA monitors a timer until its value matches tha t of a stored time value . When
a match occurs, the EPA triggers an outp ut event, whic h can se t, clear, or toggle an outp ut pin.
This is a compare event. Both capture and compare events can initiate interrupts, which can be
serviced by either the inte rrupt controller or the PTS.
Timer 1 and timer 2 are both 16-bit up/down timer/counters that can be clocked internally or extern ally. Each t imer/ counte r is calle d a timer if it is clocked internally and a counter if it is clo cked
externally. See Chapter 11, “Event Processor Array (EPA),” for additional information o n the
EPA and timer/counters.
2.5.4Pulse-width M od ul ator (PWM )
The output w aveform from each P WM channel is a variable duty-cycle puls e. Several type s of
motors require a PWM waveform for most e fficient operat ion. When filtered, the P WM wa veform produces a DC level that can change in 256 steps by varying the duty cycle. The number of
steps per PWM period is also programmable (8 bits). See Chapter 10, “Pulse-widt h Modulator,”
for more information.
2.5.5Frequency Gen erato r
The 8XC196MD has a peripheral not f ound on other 8XC19 6Mx microcontrollers — the frequency generator . This peripheral produces a waveform with a fixed duty cycle (50%) and a programmable freq uency (ra n ging from 4 kHz to 1 M Hz with a 16 MHz in p ut clock ). See Chapte r
8, “Frequency Generato r,” for details.
2.5.6Waveform Generator
A waveform generator simplifie s the task of generating synchronized, pulse-w idth modulated
(PWM) outputs. Thi s waveform generator is opti mized for motion c ontrol appli cations such a s
driving 3-phase AC induction motors, 3-phase DC brushless motors, or 4-phase stepping motors.
The waveform generator can produce three inde pendent pai rs of compl ementary PW M o utputs,
which share a com mon carrie r peri od, de ad tim e, a nd operat ing m o de. Once it is initialized, the
waveform generator operates witho ut CPU interventi on unless you need to chan ge a duty cycle.
See Chapter 9, “Waveform Generator,” for more information.
2-10
ARCHITECTURAL OVERVIEW
2.5.7Analog-to-digital Converter
The analog-to-digital (A/D) converter conve rts an analog input voltage to a digital equivalent.
Resolution is either 8 or 10 bits; sampl e and convert times are programma ble. Co nversions can
be performed on the analog ground and r ef erence voltage, and the results can be used to calculate
gain and zero-offset errors. The internal zero-offset compensation circuit enables automatic zerooffset adjustment. The A/D also has a threshold-detection mode, which can be used to generate
an interrupt when a programmable threshold voltage is crossed in either direction. The A/D scan
mode of the PTS facilitates automated A/D conversions and result storage. See Chapter 12, “Analog-to-digital (A/D) Converter,” for more information.
2.5.8Watchdog Timer
The watchdog timer is a 16-bit internal timer that resets the microcontroll er i f the softwa re fai ls
to operate properly. See Chapter 13, “M inimum Hardware Considera tions,” for more information.
2.6SPECIAL OPERATING MODES
In addition to the normal execution mode, the microcontroller operates in several special-purpose
modes. Idle and powerdown modes conserve power when the microcontroller is inactive. Oncircuit emulation (ONCE) m ode electrically isolates the mic rocontroller from the system, and
several other modes provide programming options for nonvolatile memory. See Chapter 14,
“Special Operating Modes,” for more information about idle, powerdown, and ONCE modes, and
see Chapter 16, “Programming the Nonvolatile Memory, ” for detai ls about pro gramming options .
2.6.1Reducing Power Con sump tion
In idle mode, the CPU stops executing instructions, but the peripheral clocks remain active. Power consumption drops to about 40% of normal execution mode consumption. Either a hardware
reset or any enabled interrupt source will bring the microcontroller out of idle mode.
In powerdown mode, all internal clocks are frozen at logic state zero and the internal oscillator is
shut off. The register file and most peripherals retain their data if V
is maintained. Power con-
CC
sumption drops into the µW range.
2.6.2Testing the Printed Circuit Board
The on-circuit emulation (ONCE) mode electrically isolates the microcontroller from the system.
By invoking the ONCE mode, you can test the printed circuit board while the microcontroller is
soldered onto the board.
2-11
8XC196MC, MD, MH USER’S MANUAL
2.6.3Prog ram mi ng th e Nonvo lati le Mem or y
MCS 96 microcontrollers that have internal OTPR OM provide several programming options:
• Slave programming allows a master EPR OM programmer to program and verify one or
more slave MCS 96 microcontr ollers. Programming ven dors and Intel distribut ors typically
use this mode to program a large number of microcontrollers with a custome r’s code and
data.
• Auto programming allows an MCS 96 microcontroller to program itself with code and data
located in an external memory device. Customers typically use this low-cost method to
program a small number of microcontrollers after development and testing are complete.
• Run-time programming allows you to program individual nonvolatile memory locations
during normal code execution, un der complet e software co ntrol. Customers typically use
this mode to download a small amount of information to the microcontroller after the rest of
the array has been programmed. For example, you might use run-time programming to
download a unique identificat ion number to a security device.
• ROM dump mode allows you to dump the contents of the microcontroller ’s nonvolatile
memory to a tester or to a memory device (such as flash memory or RAM).
Chapter 16, “Programming the Nonvola tile Memory,” provides recommended circuits, the corresponding memory maps, and flow diagrams. It also provides procedures fo r auto programming.
2-12
Programming
Considerations
3
CHAPT ER 3
PROGRAMMING CONSIDERATIONS
This section provides an overview of the instruction set of the MCS® 96 microcontrollers and offers guidelines for program development. For detailed information ab out specific instructions,
see Appendix A.
3.1OVERVIEW OF THE
INSTRUCTION SET
The instructi on se t supports a variety of operand types likely to be useful in control application s
(see Table 3-1).
NOTE
The operand-type variables are shown in all capitals to avoid confusion. For
example , a BYT E is an unsigned 8-bit variable in an instruction, while a byte is
any 8-bit unit of data (either signed or unsigned).
Table 3-1. Operand Type Definitions
Operand Type
BIT1NoTrue (1) or False (0)As components of bytes
BYTE8No0 through 2
SHORT-INTEGER8Yes–2
WORD16No0 through 2
INTEGER16Yes–2
DOUBLE-WORD
(Note 1)
LONG-INTEGER
(Note 1)
NOTES:
1.The 32-bit variables are supported only as the operand in shift operations, as the dividend in 32-by16 divide opera ti ons, and as the produ ct of 16-b y- 16 multip ly operations.
2.F or consistency with thir d-party software , you should adopt the C prog ramming conventio ns for
addressing 32-bit operands. For more information, refer to page 3-9.
No. of
SignedPossible Values
Bits
7
through +27–1
(–128 through +127)
(0 through 65,535)
15
through +215–1
(–32,768 through +32,767)
32No0 through 2
32Yes–2
(0 through 4,294,967,295)
31
through +231–1
(–2,147,483,648 through
+2,147,483,647)
8
–1 (0 through 255)None
16
–1
32
–1
Addressing
Restrictions
None
Even byte address
Even byte address
An address in the lowe r
register file that is evenly
divisible by four (Note 2)
An address in the lowe r
register file that is evenly
divisible by four (Note 2)
3-1
8XC196MC, MD, MH USER’S MANUAL
Table 3-2 lists the equivalent operand-type names for both C programming and assembly language.
Table 3-2. Equivalent Operand Types for Assembly and C Programming Languages
Operand TypesAssembly Language EquivalentC Programming Language Equivalent
BYTEBYTEunsigned char
SHORT-INTEGERBYTEchar
WORDWORDunsigned int
INTEGERWORDint
DOUBLE-WORDLONGunsigned long
LONG-INTEGERLONGlong
3.1.1BIT Operands
A BIT is a single-bit variable that can have the Boolean values, “true” and “false.” The architecture requires that BITs be addressed as components of BYTEs or WORDs. It does not support the
direct addressing of BITs.
3.1.2BYTE Operands
8
A BYTE is an unsigned, 8-bit variabl e that can take on values from 0 through 255 (2
–1). Arithmetic and relational operators can be applied to BYTE operands, but the result must be interpreted in modulo 256 arithmetic. Logical operations on BYTEs are applied bitwise. Bits within
BYTEs are label ed from 0 to 7; bit 0 is the least-sig nificant bit. There are no alignme nt restric tions for BYTEs, so they may be plac ed anywhere in the address space.
3.1.3SHORT-INTEGER Operands
7
A SHORT-INTEGER is an 8-bit, signed variable that can take on values from –128 (–2
7
+127 (+2
–1). Arithmetic operations that generate results outside the range of a SHORT-
) through
INTEGER set the overflow flags in the processor status word (PSW). The numeric result is the
same as the result of the equivalent operation on BYTE variables. There are no alignment restrictions on SHORT-INTEGERs, so they may be placed anywhere in the address space.
3.1.4WORD Operands
16
A WORD is an unsigned, 16-bit variable that can take on values from 0 through 65,535 (2
–1).
Arithmetic and relational operators can be applied to WORD operands, but the result must be interpreted in modulo 65536 arithmetic. Logical operations on WORDs are appl ied bitwise. Bits
within WORDs are labeled from 0 to 15; bit 0 is the least-significant bit.
3-2
PROGRAMMING CONSIDERATIONS
WORDs must be aligned at even byte boundaries in the address space. The least-significant byte
of the WORD is in the even byte address, and the most-significant byte is in the next higher (odd)
address. The address of a WORD is that of its least-significant byte (the even byte address).
WORD operations to odd addresses are not guaranteed to operate in a consistent manner.
3.1.5INTEGER Operands
15
An INTEGER is a 16-bit, si gned variable that can t ake on values from –32,768 ( –2
15
+32,767 (+2
–1). Arithmetic operations that generate results outside the range of an INTEGER
) through
set the overflow flags in the processor status word (PSW). The nume ric result is the same as the
result of the equivalent operati on on WORD varia ble s.
INTEGERs must be aligned at eve n byte boundaries in the address space. The leas t-sig nificant
byte of the INTEGER is in the even byte address, and the most-significant byte is in the next higher (odd) address. The address of an INTEGE R is that of its least-significa nt byte (the even byte
address). INTEGE R operations to odd address es are not guaranteed t o operate in a consistent
manner.
3.1.6DOUBLE-WORD Operan ds
A DOUBLE-WORD is an unsigned, 32-bit variable that can take on values from 0 through
32
4,294,967,295 (2
–1). The architecture directly supports DOUBLE-WORD opera nds only as
the operand in shift operations, as the dividend in 32-by-16 divide operations, and as the product
of 16-by-16 multiply operations. For these ope rations, a DOUBL E-WOR D vari abl e must reside
in the lower registe r file and must be aligned at an address t hat is eve nly divisibl e by four. The
address of a DOUBLE-WORD is that of its least-significant byt e (the even byte address). The
least-significant word of the DOUBLE-WORD is always in the lower address, even when the
data is in the stack. This means that the most-significant word must be pushed into the stack first.
DOUBLE-WORD operations that are not directly supported can be ea sil y im plemen ted with two
WORD operations. For example, the following sequences of 16-bit operations perform a 32-bit
addition and a 32-bit subtraction, respective ly.
SUB REG1,REG3 ; (2-operand subtraction)
SUBC REG2,REG4
3-3
8XC196MC, MD, MH USER’S MANUAL
3.1.7LONG-INTEGE R Ope rand s
A LONG-INTEGER is a 32-bit, signed variable that can take on values from –2,147,483,648
31
) through +2,147,483,647 (+231–1). The architecture directly supports LONG-INTEGER
(– 2
operands only as the o perand in shi ft operat ions, a s the divi dend in 32-by-16 divide operations,
and as the product of 16-by-16 multiply operations. For these operations, a LONG-INTEGER
variable must reside in the lower register file and must be aligned at an address that is evenly divisible by four. The addres s of a LONG-INTEGER is that of its least-significant byt e (the e ven
byte address).
LONG-INTEGER operations that are not directly suppor ted can be easily implemented with two
INTEGER operations. See the example in “DOUBLE-WORD O perands” on page 3-3.
3.1.8Converting Operands
The instruction set supports conversions between the operand types. The LDBZE (load byte, zero
extended) instruction converts a BYTE to a WORD. CLR (clear) converts a WORD to a
DOUBLE-WORD by clea ring (writing zeros to) the upper WORD of the DO UBLE-WORD.
LDBSE (load byte, sign extended) convert s a SHORT-INTE GER into an INT EGE R. EXT (sign
extend) converts an INTEGER to a LONG-INTEGER.
3.1.9Conditional Jumps
The instructio ns for a ddit ion, subtraction, an d c ompari s on do not distinguish bet wee n unsi g ned
(BYTE, WORD) and signed (SHORT-INTEGER, INTEGER) operands. However, the conditional jump instructions allow you to treat the results of these operations as signed or unsigned quantities. For example, the CMP (compare) instruction is used to compare both signed and unsigned
16-bit quantities. Following a compare operation, you can use the JH (jump if higher) instruction
for unsigned operands or the JGT (jump if greater than) instruction for signed operands.
3.1.10 Floating Point Operations
The hardware does not directly support operations on REAL (floating point) variables. Those operations are supported by floating point libraries from third-party tool vendors. (See the Develop-ment Tools Handbook.) The performance of these operations is significantly improved by the
NORML instruction and by the sticky bit (ST) flag in the pr ocessor status word (PSW). The
NORML instruction normalizes a 32-bit variable; the sticky bit (ST) flag can be used in conjunction with the carry (C) flag to achieve finer resolution in roundin g.
3-4
PROGRAMMING CONSIDERATIONS
3.2ADDRESSING MODES
The instruction set uses four basic addressing modes:
• direct
• immediate
• indirect (with or without autoincrement)
• indexed (short-, long-, or zero-indexed)
The stack pointer ca n be used with indirect addressin g to access the top of the stac k, and it can
also be used with short-indexed addressin g to access data within the stack. The zer o register can
be used with long-indexed addressing to access any memory location.
An instruction can contain only one immediate, indirect, or indexed reference; any remaining operands must be direct references.
This section describes the addressing modes as they are handled by the hardware. An understanding of these details will help programmers to take full advantage of the architecture. The assembly
language hides some of the details of how these addres sing modes work. “Assembl y Language
Addressin g Mode Selectio ns” on page 3-9 describes how the assembl y language handles direct
and indexed addressing modes.
The examples in this section assume that temporary registers are defined as shown in this seg ment
of assembly code an d describe d in Table 3-3.
AXword-ali gned 16-bit registe r; AH is the high byte of AX and AL is the low byte
BXword-ali gned 16-bit registe r; BH is the high byte of BX and BL is the low byte
CXword-align ed 16-b it reg ister; CH is the high byte of CX and CL is the low byte
DXword-align ed 16-b it reg ister; DH is the high byte of DX and DL is the low byte
3.2.1Direct Addressing
Direct addressing directly accesses a location in the 256-byte lower register file, without involving the memory controller. Windowing allows you to remap other sections of memory into the
lower register file for direct access (see Chapter 4, “Memory Partitions,” for details). You specify
the registers as operands within the instruction. The register addresses must conform to the alignment rules for the operand type. Depending on the instruction, up to three registers can take part
in a calculation. The following instr uctions use direct add ressin g:
Immediate addressing mode a ccepts one immedia te value as an operand in the instruc tion. You
specify an immediate value by preceding it with a number symbol (#). An instruction can contain
only one imme dia te val ue; t he remaining o perands must be dire ct refe rence s. The foll owing instructions use immediate addressing:
The indirect addressing mode accesses an operand by obtaining it s address from a WORD register in the lower register file. Y ou specify the register containing the indirect address by enclosing
it in square brackets ([ ]). The indirect address can refer to any location within the address space,
including the register file. The regi ster that contains the indirect address must be word-aligne d,
and the indirect address must conform to the rules for the operand type. An instruction can contain
only one indirect reference; any remaining operands must be direct references. The following instructions use indirect addressing:
LDAX,[BX] ; AX ← MEM_WORD(BX)
3-6
PROGRAMMING CONSIDERATIONS
ADDB AL,BL,[CX]; AL ← BL + MEM_BYTE(CX)
POP [AX] ; MEM_WORD(AX) ← MEM_WORD(SP)
3.2.3.1Indirect Addressin g with Autoincrement
; SP ← SP + 2
Y ou c an choose to automatically increment the indirect address after the current access. Y ou specify autoincrementi ng by adding a plus sign (+) to the end of the indirect reference. In this case,
the instruction automatically increments the indirect address (by one if the destination is an 8-bit
register or by two if it is a 16-bit register). When your code is assembled, the assembler automatically sets the least-significa nt bit of the indirec t address register. The following instructions use
indirect addressing with autoincrement:
You can also use indirec t addressi ng to acces s the top of the sta ck by using the stac k pointer a s
the WORD register in an indirect reference. The following instruction us es indirect addressing
with the stack pointer:
PUSH [SP]; duplicate top of stack
; SP ← SP + 2
3.2.4Indexed Add ressi ng
Indexed addressing calcula tes an address by adding an offset to a base ad dress. There are three
variations of indexed addressing: short-indexed, long-indexed, and zero-indexed. Both short- and
long-indexed addressing are use d to a ccess a specific element wi thi n a st ruct ure. Short-indexed
addressing can access up to 255 byte locations, long-indexed addressing can access up to 65,535
byte locations, and zero-indexed addressing can access a single location. An instruction can contain only one indexed reference; any remaining operands must be direc t reference s.
3.2.4.1Short-indexed Addressing
In a short-indexed instruction, you specify the offset as an 8-bit constant and the base address as
an indirect address register (a WORD). The following instructions use short-indexed addressing.
The instruction LD AX,12H[BX] loads AX with the contents of the memory location that resides
at address BX+12H. That is, the instruct ion adds the c onstant 12H (the offset) to the contents o f
BX (the base address), then loads AX with the conte nts of the resultin g address. For example, if
BX contains 1000H, then AX is loaded with the contents of location 1012H. Short-indexed addressing is typi cally used to a cc ess elem ent s in a struc ture, whe re BX co nta ins the base addres s
of the structure and the constant (12H in this example) is the offset of a specific element in a structure.
You can also use the stack pointer in a short-in dexed instruction to access a particul ar location
within the stack, as shown in the following instruct i on.
LDAX,2[SP]
3.2.4.2Long-indexed Addressing
In a long-indexed instructio n, you specify the ba se address as a 16-bit vari able and the offset a s
an indirect address register (a WOR D). The followi ng instruct ions use long-indexe d addressing.
LDAX,TABLE[BX]; AX ← MEM_WORD(TABLE + BX)
AND AX,BX,TABLE[CX]; AX ← BX AND MEM_WORD(TABLE + CX)
STAX,TABLE[BX]; MEM_WORD(TABLE + BX) ← AX
ADDB AL,BL,LOOKUP[CX]; AL ← BL + MEM_BYTE(LOOKUP + CX)
The instruction LD AX, T ABLE[BX] loads AX with the contents of the memory location that resides at address TABLE+B X. That is, the instructi on adds the contents of BX (the offset) to the
constant TABLE (the base address), then loads AX with the contents of the resulting address. For
example, if TABLE equals 4000H and BX contains 12H, then AX is loaded with the contents of
location 4012H. Long-indexed addressing is typi cally use d to access elements in a table, where
TABLE is a constant tha t is the ba se a ddre ss of the struct u re and B X is the sc aled o ffset (n× element size, in bytes) into the str ucture .
3.2.4.3Zero-indexed Addressing
In a zero-indexed instructi on, you specif y the add ress as a 16-bit va ria ble; the offset is zero, a nd
you can express it in one of three ways: [0], [ZERO_REG], or nothing. Each of the following load
instructions loads AX with the contents of the variable THISVAR.
The assembly language simplifies the choice of addressing modes. Use these features wherever
possible.
3.3.1Direct Addressing
The assembly la nguage chooses betwee n direct and zero-indexed addressing depending on the
memory location of the operand. Simply refer to the operand by its symbolic name. If the operand
is in the lower regis ter file, the asse mbly language choose s a direct reference . If the ope rand is
elsewhere in memory, it chooses a zer o-indexed reference.
3.3.2Indexed Add ressi ng
The assembly language chooses betw een short-indexe d an d long-indexed ad dressing depending
on the value of the index expression. If the value can be expressed in eight bits, the assembly language chooses a short-indexed reference. If the value is greater than eight bits, it chooses a longindexed reference.
3.4SOFTWARE STANDARDS AND CONVENTIONS
For a software project of any size, it is a good idea to develop the program in mo dules and to establish standards that control communication between the modules. These standards vary with the
needs of the final application. However, all standards must include some mechanism for passing
parameters to procedures and returning results from procedures. We recommend that you use the
conventions adopted by the C programming language for procedure linkage. These standards are
usable for both the assembly language and C programming environments, and they offer compatibility between these environments.
3.4.1Using Registers
The 256-byte lower register file contains the CPU special-function registers and the stack pointer.
The remainder of the lower register file and all of the upper register file is available for your use.
Peripheral special-function registers (SFRs) and memory-mapped SFRs reside in higher memory .
The peripheral SFRs can be windowed into the lower register fi le for direct access. M emorymapped SFRs cannot be windowed; you must use indirect or indexed addressing to access them.
All SFRs can be operated on as BYT Es or WORDs, unless otherwi se specified. See “Specialfunction Registers (SFRs)” on page 4-4 a nd “Register File” on page 4-9 for more information.
3-9
8XC196MC, MD, MH USER’S MANUAL
To use t hese re gisters effectively, you must have some overall strategy for alloc ating the m. The
C programming language adopts a simple, effective strategy. It allocates the eight bytes beginning
at address 1CH as temporary storage and treats the remaining area in the register file as a segment
of memory that is allocated as required.
NOTE
Using any SFR as a base or index register for indirect or indexed operations
can cause unpredictable results because external events can change the
contents of SFRs. Also, because some SFRs are cleared when read, consider
the implications of using an SFR as an operand in a read-modify-write
instructi on (e.g., XORB ).
3.4.2Addressing 32-bit Operands
The 32-bit operands (DOUBL E-WORDs and LONG-INTE GERs) are formed by t wo adjacent
16-bit words in m emory. The least-significant word of a DOUBLE-WORD is always in the lower
address, even when the data is in the stack (which means that the most-si gni fic ant word must be
pushed into the stack first). The address of a 32-bit operand is that of its least-signifi ca nt b yte.
The hardware supports the 32-bit data types as operands in shift operations, as divi dends of 3 2by-16 divide operations, and as products of 16-by-16 multiply operations. For these operations,
the 32-bit operand must reside in the lower register file and must be aligned at an address that is
evenly divisible by four.
3.4.3Linking Subroutines
Parameters are passed to subroutines via the stack. Parameters are pushed into the stack from the
rightmost parameter to the left. The 8-bit parameters are pushed into the stack with the high-order
byte undefined. The 32 -bit parameters are p ushed into the stack as two 16-bit values; the mostsignificant hal f of the parame ter is pushe d into the st ack first. As an example, c onsider the following procedure:
void example_procedure (char param1, long param2, int param3);
When this procedure executes at run-time, the stack will contain the parameters in the following
order:
param3
low word of param2
high word of param2
undefined;param1
return address← Stack Pointer
3-10
PROGRAMMING CONSIDERATIONS
If a procedure returns a value to the calling code (as opposed to modifying more global variables),
the result is returned in the temporary storage space (TMPREG0, in this example) starting at 1CH.
TMPREG0 is viewed as either a n 8-, 16-, o r 32bit variable, dependi ng on the type o f the procedure.
The standard calling convention adopte d by the C programming language has several key features:
• Procedure s can alwa ys assume that the eight bytes of registe r file mem ory startin g at 1CH
can be used as temporary storage within the body of the procedure.
• Code that calls a procedure must assume that the procedure modifies the e ight bytes of
register file memory starting at 1CH.
• Code that calls a procedure m ust assume that the procedure mo difies the processor status
word (PSW) condition flags because procedures do not save and restore the PSW.
• Function results from procedures are always returned in the variable TMPREG0.
The C programming language allows the definitio n of i nterrupt p rocedures, whi ch are exe cute d
when a predefined interrupt request occ urs. Interrupt procedures do not conform to the rules o f
normal procedures. Parameters c annot be passed to these procedures and they cannot return results. Since interrupt procedures can execute essential ly a t any t i me, t hey must save and restore
both the PSW and TMPREG0.
3.5SOFTWARE PROTE CTI ON FEATU RES AND GUI DELINES
The device has several features to assist in recoverin g from hardware and software errors. The
unimplemented opcode interrupt provides protection from executing unimplemented opcodes.
The hardware reset instruction (RST) can cause a reset if the program counter goes out of bounds.
The RST instruction opcode is FFH, so the processor will reset itself if it tries to fetch an instruction from unprogrammed locations in nonvolatile memory or from bus lines that have been pulled
high. The watchdog timer (WDT) can also reset the device in the event of a hardware or software
error .
We recommend that you fill unused areas of code with NOPs and perio dic jumps to an error routine or RST instruction. This is particularly important in the code surrounding lookup t ables, s ince
accidentally exec uting from lookup tables will cause undesired resul ts. Wherever space allows,
surround each table with seven NOPs (because the longest device instruction has seven bytes) and
a RST or a jump to an error routine. Since RST is a one-byte instruction, the NOPs are unnece ssary if RSTs are used instead of jumps to an error routine. This will help to ensure a speedy recovery from a software error.
3-11
8XC196MC, MD, MH USER’S MANUAL
When using the watchdog timer (WDT) for software protection, we recommend that you reset the
WDT from only one place in code, reducin g the chance of an undesire d WDT reset. The sec ti on
of code that resets the WDT should monitor the other code sections for proper operation. This can
be done by checki ng variables to make sure they are wi thin reas onable value s. Simply usin g a
software timer to reset the WDT every 10 millisec onds will provide protection only for catastrophic failures.
3-12
Memory
Partitions
4
CHAPT ER 4
MEMORY PARTITIONS
This chapter describes the address space, its major partitions, and a windowing technique for accessing the upper register file and peripheral SFRs with regist er-direct instr uctions.
4.1MEMORY PARTITIONS
Table 4-1 is a memory map of the 8XC196Mx devices. The remainder of this section describe s
the partitions.
4.1.1External Devi ces (Memo ry or I/O )
Several partitions are assigned to external devices (see Table 4-1). Data can be sto red in any part
of this memory. Chapter 15, “Interfacing with External Memory ,” describes the external memory
interface and shows examples of external mem ory configurations. These partitions can also be
used to interface with external peripherals connected to the address/data bus.
4.1.2Prog ram and Special-purpose Me m ory
Internal nonv o latil e me mory is an optional component of the 8XC196Mx devices. Va rious devices are available with masked ROM, EPROM, QROM, or OTPROM. Please consult the
datasheets in the Embedded Microcontrollers databook for details.
If present, the nonvolatile memory occupies the special-purpose memory and program memory
partitions (loca tions 2 000H and above; see Table 4-1 on page 4-2). The E A# signa l control s access to these m emory pa rtitio ns. Accesse s to these part itions are di rected to i nterna l memo ry if
EA# is held high and to external memory if EA# is held low. For devices without i nte rnal nonvolatile memory, the EA# signal must be tied low. EA# is latched at reset.
4-1
8XC196MC, MD, MH USER’S MANUAL
Table 4-1. Memory Map
Device and
Hex Address
Range
MC, MDMH
FFFF
6000
5FFF
2080
207F
2000
1FFF
1FE0
1FDF
1F00
1EFF
0200
01FF
0100
00FF
0000
NOTES:
1.After a reset, the device fetches its first instruction from 2080H.
2.The content or function of these locations may change in future device revisions, in which case a pro-
FFFF
External device (memory or I/O) connecte d to the
A000
address/data bus
9FFF
Program memo ry (in ter na l nonvola ti le or exte rna l
2080
memory); see Note 1.
207 F
Special-purpose memory (internal nonvolatile or
2000
external memory)
1FFF
Memory-mapped SFRsIndirect or indexed
1FE0
1FDF
Peripheral SFRs
1F00
1EFF
External device (memory or I/O) connecte d to the
0300
address/data bus (future SFR expansion; see Note 2)
gram that relie s on a locatio n in this rang e migh t not function properl y.
DescriptionAddressing Modes
Indirect or indexed
Indirect or indexed
Indirect or indexed
Indirect, indexed, or
windowed direct
Indirect or indexed
Indirect, indexed, or
windowed direct
Direct, indirect, or indexe d
4.1.3Prog ram Memory
Program memory oc cupies a memory p art ition beginning at 208 0H. (See Table 4-1 for the ending
address for each devic e.) This enti re parti tion is avai lable f or storing executabl e code and dat a.
The EA# signal control s acce ss to program memory. Accesses to this address range are directed
to internal memory if EA# is held high and to external memory if EA# is held low. For devices
without internal nonvolatile memory, the EA# signal must be tied low. EA# is latched at reset.
NOTE
We recommend that you write FFH (the opcode fo r the RST instruction) to
unused program memory locations. This causes a device reset if a program
unintentional ly begins to exec ute in unused mem o ry.
4-2
MEMORY PARTITIONS
4.1.4Special-purpose Memory
Special-purpose memory resides in locations 2000–207FH (Table 4-2). It contains seve ral reserved memory locations, the c hip configuratio n bytes (CCBs), and ve ctors for both peri pheral
transaction server (PTS) and standard interrupts. Accesses to this address range are directed to
internal memory if EA# is held high and to external memory if EA# is held low . For devices without internal nonvolatile memory, the EA# signal must be tied low. EA# is latched at reset.
Several memory locations are reserved for testing or for use in future products. Do not read or
write these locations exce pt to initialize the m. The function or contents of thes e locations may
change in future revisions; software t hat uses reser ved locations may not functio n properly. Always initialize reserved locati ons to the values listed in Table 4-2.
4.1.4.2Interrupt and PTS Vectors
The upper and lower interrupt vectors contain the addresses of the interrupt service routines. The
peripheral transactio n server (PTS) vectors conta in the addresse s of the PTS control bloc ks. See
Chapter 5, “Standard and PTS Interrupts, ” for more information on interrupt and PTS vectors.
4-3
8XC196MC, MD, MH USER’S MANUAL
4.1.4.3Security Key
The security key prevents unauthorized programming access to the nonvolatile memory. See
Chapter 16, “Programming the Nonvolatile Memory,” for details.
4.1.4.4Chip Configuration Bytes (CCBs)
The chip configurat ion bytes (CCBs) s pecify the operatin g environment. They specif y the bus
width, bus-control mode, and wait states. They also control powerdown mode, the watchdog timer, and nonvolatile memory protection.
The CCBs are the first bytes fetched from memory when the device leaves the reset state. The
post-reset seque nce loa ds the C C Bs int o the chip configurati o n regis ters (CCRs). Once the y are
loaded, the CCRs cannot be c hanged until the next device reset. Typically, the CCBs are programmed once when the user program is compiled and are not redefined during normal operation.
“Chip Configuration Registers and Chip Configuration Bytes” on page 15-5 describes the CCBs
and CCRs.
For devices with customer-programmable nonvolatile memory, the CCBs are loaded for normal
operation, but the PCCBs are loaded into the CCRs if the device is entering programming modes.
See Chapter 16, “Programming the Nonvolatile Memory,” for details.
4.1.5Special-function Registers (SFRs)
These devices have both memory-mapped SFRs and peripheral SFRs. The memory-mapped
SFRs must be accesse d using indirect or indexed ad dressing modes, an d they cannot be windowed. The peripheral SFRs are physically located in the on-chip peripherals, and they can be
windowed (see “Windowing” on page 4-12). Do not use reserved SFRs; write zeros to the m or
leave them in their default sta te. When read, reserved bit s and reserved SFRs return undefi ned
values.
NOTE
Using any SFR as a base or index register for indirect or indexed operations
can cause unpredictable results because external events can change the
contents of SFRs. Also, because some SFRs are cleared when read, consider
the implications of using an SFR as an operand in a read-modify-write
instructi on (e.g., XORB ).
4-4
MEMORY PARTITIONS
4.1.5.1Memory-mapped SFRs
Locations 1FE0–1FFFH contain mem o ry-mapped SFR s (se e Table 4-3). Locations in this range
that are omitted from the table are reserved. The memory-ma pped SFRs must be access ed with
indirect or indexed addressing modes, and they cannot be windowed. If you read a location in this
range through a window, the SFR appears to contain FFH (al l ones). If y ou write a location in
this range through a window, the write operation has no effect on the SFR.
The memory-mapped SFRs are accesse d through the memory controller, so instructions that operate on these SFRs execute as they wo uld from external memory wit h zero wait states.
Locations 1F00–1FDFH provide access to the peripheral SFRs. Table 4-6 on page 4-8, Table 4-6
on page 4-8, and Table 4-6 on page 4-8 list the peripheral SFRs of the 8XC196MC, 8XC196MD,
and 8XC196MH, respe ctively. Locations that are omitted from the tables are reserved. The peripheral SFRs are I/O control regist ers; they are ph ysically located in t he on-chip peripherals.
These peripheral SFRs can be windowed and they can be addressed either as words or bytes, except as noted in the tables.
The peripheral SFRs are acce ssed directly, without using the memory controller, so instructions
that operate on these SFRs execute as they would if they were operating on the register file.
The register fi le (Figure 4-1) is divi ded into an uppe r register file and a lower register fi le. The
upper register file consists of general-purpose register RAM. The lower register file contains general-purpose register RAM along with the stack pointer (SP) and the CPU special-function registers (SFRs).
T ab le 4-1 on page 4-2 l ists the register file memory addresses. The RALU accesses the lower register file directly, without the use of the memory controller. It also accesses a windowed location
directly (see “Windowing” on page 4-12). The upper register file and the peripheral SFRs can be
windowed. Registers in the lower register file and registers being windowed can be accessed with
register-direct addressing.
NOTE
The register file must n ot contain code. An attempt to exec ute an instruct ion
from a location in the register file cause s the me mory controller to fetch the
instruction from externa l memo ry.
Address
02FFH (MH)
0200H
01FFH (MC, MD)
0100H
00FFH
001AH
0019H
0018H
0017H
0000H
Address
02FFH
0100H
00FFH
0000H
Upper
Register File
Lower
Register File
General-purpose
Register RAM
General-purpose
General-purpose
Register RAM
Register RAM
Stack Pointer
Stack Pointer
CPU SFRs
Figure 4-1. Register File Memory Map
A3066-02
4-9
8XC196MC, MD, MH USER’S MANUAL
Table 4-7. Register File Memory Addresses
Device and Hex
Address Range
MC, MDMH
01FF
0100
00FF
001A
0019
0018
0017
0000
02FF
0100
00FF
001A
0019
0018
0017
0000
Upper register file (register RAM)Indirect, indexed, or windowed direct
Lower register file (register RAM)Direct, indirect, or indexed
Lower register file (stack pointer)Direct, indirect, or indexed
Lower register file (CPU SFRs)Direct, indirect, or indexed
DescriptionAddressing Mode s
4.1.6.1General-purpose Register RAM
The lower regis ter file conta ins general -purpose register RAM. The s tack pointer l ocations can
also be used as general-purpose register RAM when stack operations are not being performed.
The RALU can access this m em ory directl y, using register-direct addressing.
The upper register file also conta ins general-p urpose register RAM. The RAL U normally uses
indirect or indexed addressing to acces s the RAM in the upper register file . Windowing enables
the RALU to use register-direct addressing to access this memory. (S ee Chapt er 3 , “Prog ramming
Considerations,” f or a discussion of ad dressin g modes.) Windowing can provide for fast context
switching of interrupt tasks and faster program execution. (See “Windowing” on page 4-12.) PTS
control blocks and the stack are most efficient when locat ed in the upper register file.
4.1.6.2Stack Pointer (SP)
Memory locations 0018H and 0019H contain the stack pointer (SP). The SP contains the address
of the stack. The SP must point to a word (even) address that is two bytes greater than the desired
starting addre ss. Before the CPU executes a subroutine call or interrupt service routine, it decrements the SP by t wo and c opies (PUSHes ) the addres s of the next ins tructi on from the p rogram
counter onto the stack. It then loads the address of the subroutine or interrupt service routine into
the program counter . When it e xecutes the r eturn-from-subro utine ( RET) instruction at the end of
the subroutine or interrupt service routine, the C PU loads (POPs ) the contents of the top o f the
stack (that is, the return address) into the progra m cou nter and incre ment s the SP by two.
Subroutines may be nested. That is , each subroutine may cal l other subro utines. The CPU pushes
the contents of the program counter onto the stack each time it executes a subroutine call. The
stack grows downward as entries are added. The only limit to the nesting depth is the amount of
available memory. As the CPU returns from each nested subroutine, it pops the address off the
top of the stack, and the next return address moves to the top of the stack.
4-10
MEMORY PARTITIONS
Your program must load a word-aligned (even) address into the stack pointer. Select an address
that is two byte s grea ter tha n the desi red s tarti ng ad d ress beca use the CP U aut omat ica lly dec rements the stack pointer before it pushes the first byte of the return address onto the stack. Remember that the stack grows downward, so allow sufficient room for the maximum number of stack
entries. The st ack must be l oca ted in e ither t he i nte rnal re gist er fi le or ext ernal R AM . The st ack
can be used most efficiently when it is located in the regis ter file .
The following example init ializes the top of the upper regi ster file (8XC196MC, MD) as the
stack. (For the 8XC196MH, the im me dia te value w o uld be #3 00H. )
LDSP, #200H;Load stack pointer
The following example shows how to allow the linker locator to determine where the stack fits
in the memory map that you specify.
LDSP, #STACK
4.1.6.3CPU Special-function Registers (SFRs)
Locations 0000–0017H in the lower register file are the CPU SFRs (Table 4-8). Appendix C describes the CPU SFR s.
Using any SFR as a base or index register for indirect or indexed operations
can cause unpredictable results because external events can change the
contents of SFRs. Also, because some SFRs are cleared when read, consider
the implications of using an SFR as an operand in a read-modify-write
instructi on (e.g., XORB ).
4-11
8XC196MC, MD, MH USER’S MANUAL
4.2WINDOWING
Windowing expands the amount of memory that is accessible with register-direct addressin g.
Register-direct a ddressing can a ccess the lowe r register file with short, fast-executi ng instructions. With windowing, re gist e r-direct addressi ng c an also ac cess t he u pper regi ster fi le and peripheral SFRs.
Windowing maps a se gment of hig her memory (the upper register file or peripheral SFRs) into
the lower register file. The window selection register (WSR) selects a 32-, 64-, or 128-byte segment of higher memory to be windowed into the t op of the lower register file space. Figure 4-2
illustrates a 128-byte window.
02FFH
128-byte Window
(WSR = 13H)
WSR Window in
Lower Register File
8XC196MC,MD8XC196MH
01FFH
0180H
00FFH
0080H
0000H
128-byte Window
(WSR = 13H)
WSR Window in
Lower Register File
Figure 4-2. Windowing
NOTE
Memory-mapped SFRs must be accessed using indirect or indexed addressing
modes; they cannot be accessed through a window. Reading a memorymapped SFR through a window returns FFH (all ones), and writing to a
memory-mapped SFR through a window has no effect.
A3062-01
4-12
MEMORY PARTITIONS
4.2.1Selecting a Window
The window selection register (Figure 4-3) selects a window to be mapped into the top of the lower register file.
Table 4-9 provides a quick reference of WSR values for windowing the p eripheral SFRs. Table
4-10 on page 4-14 lists the WSR values for windowing the upper register file.
WSR
The window sele ctio n reg iste r (WSR) map s sectio ns of RAM in to the top of the lower regi st er file, in
32-, 64-, or 128-byte increments. PUSHA saves this register on the stack and POPA restores it.
70
—W6W5W4W3W2W1W0
Bit
Number
7—Reserve d; for compa tibil ity with future device s, write zero to this bit.
6:0W6:0Window Selection
Bit
Mnemonic
Function
These bits specify the window size and number. See Table 4-9 on page
4-13 or T able 4-10 on page 4-14. See T able 4-9 for peripheral SFR windows
or Ta b le 4-1 0 for uppe r regi st er fil e windo ws .
Address:
Reset State:
Figure 4-3. Window Selection (WSR) Register
Table 4-9. Selecting a Window of Peripheral SFRs
Periphe rals
Port 2
Waveform generator
Port 7 (MD only)
Peripheral interrupts
Pulse-wid th modula to r
A/D converter
Frequency generator (MD only)
Reset control (MH only)
Table 4-10. Selecting a Window of the Upper Register File
Register RAM
Locations
8XC196 MH Only
02E0–02FFH57H
02C0–0 2DF H56H
02A0–02BFH55H
0260–027FH53H
0240–025FH52H
0220–023FH51H
8XC196MC, 8XC196MD, and 8XC196MH
01E0–01FFH4FH
01C0–01DFH4EH
01A0–01BFH4DH
0160–017FH4BH
0140–015FH4AH
0120–013FH49H
WSR Value
for 32-byte Window
(00E0–00FFH)
WSR Value
for 64-byte Window
(00C0–00FFH)
2BH
2AH0280–029FH54H
29H
28H0200–021FH50H
27H
26H0180–019FH4CH
25H
24H0100–011FH48H
WSR Value
for 128-byte Window
(0080–00FFH)
15H
14H
13H
12H
4.2.2Addressing a Location Through a Window
After you have selected the desired window, you need to know the windowed direct address of
the memory location (the address in the lower register fi le). Calculate the wi ndowed direct address as follow s:
1.Subtract the base address of the area to be remap ped (from Table 4-11 on page 4-15) from
the address of the desired location. This give s you the offset of that particular locat ion.
2.Add the offset to the base address of the window (from Table 4-12 on page 4-15). The
result is the windowed direct address.
Appendix C includes a table of the windowable SFRs with the WSR values and windowed direct
addresses for each window size. Examples beginning on page 4-16 explain how to determine the
WSR value and windowed direct address for any windowable location. An additional example
shows how to set up a window by using the linker locator.
4-14
MEMORY PARTITIONS
Table 4-11. Windows
Base
Address
Periphe ral SFRs
1FE0H7FH (Note)
1FC0H7EH
1FA0H7DH
1F60H7BH
1F40H7AH
1F20H7 9H
02E0H57H
02C0 H5 6 H
02A0H55H
0260H53 H
0240H52 H
0220H51 H
01E0H4FH
01C0 H4EH
01A0H4DH
0160H4BH
0140H4AH
0120H49 H
NOTE: Locations 1FE0– 1FFFH contain memory-ma pped SFRs that cannot be acces sed thro ugh a
window. Reading these locations through a window returns FFH; writing these locations
through a window has no effect.
WSR Value
for 32-byte Window
(00E0–00FFH)
WSR Value
for 64-byte Window
(00C0–00FFH)
3FH (Note)
3EH1F80H7CH
3DH
3CH1F00H78H
2BH
2AH0280H54H
29H
28H0200 H50H
27H
26H0180 H4CH
25H
24H0100 H48H
WSR Value for
128-byte
Window
(0080–00FFH)
1FH (Note)
1EH
15H
14H
13H
12H
Table 4-12. Windowed Base Addresses
Window Size
32-byte00E0H
64-byte00C0H
128-byte0080H
WSR Windowed Bas e Addre ss
(Base Address in Lower Register File)
4-15
8XC196MC, MD, MH USER’S MANUAL
Appendix C includes a table of the windowable SFRs with the WSR values and direct addresses
for each window size. The following examples explain how to determine the WSR value and direct address for any windowable location. An additional example shows how to set up a window
by using the linker locator.
4.2.2.132-byte Windowing Example
Assume that you wish to access location 014BH (a location in the upper register file used for general-purpose register RAM) with register-direct addressing through a 32-byte window . T able 4-11
on page 4-15 shows that you need to write 4AH to the window selection register. It also shows
that the base address of the 32-byte memory area is 0140H. To determine the offset, subtract that
base address from the address to be accessed (014B H – 01 40H = 000BH). Add the offset t o the
base address of the window in the lower regi ster file (00E0H, from Table 4-12). The direct address is 00EBH (000BH + 00E0H).
4.2.2.264-byte Windowing Example
Assume that you wish to access the WG_CONTROL register (location 1FCCH) with register-direct addressing through a 64-byte window. Table 4-11 shows that you need to write 3FH to the
window selection register. It also shows that the base address of the 64-byte memory area is
1FC0H. To determine the offset, subtract that base address from the address to be accessed
(1FCCH – 1FC0H = 000C H). Add the offset to the base address of t he window in the lower register file (00C0H, from Table 4-12). The direct address is 00CCH (000CH + 00C0H).
4.2.2.3128-byte Windowing Ex ample
Assume that you wish to access location 1F42H (the EPA0_TIME regist er) with register-direct
addressing through a 128-byte window. Table 4-11 shows that you need to write 1EH to the window selection register. It also shows that the base address of the 128-byte memory area is 1F00H.
To determine the offset, su btract that base address f rom the address to be accesse d (1F42H –
1F00H = 0042H). Add the offset to the base address of the window in the lower register file
(0080H, from Table 4-12). The direct address is 00C2H (0042H + 0080H).
4.2.2.4Unsupported Locations Windowing Example
Assume that y ou wish to access location 1FF1H (the P5_MODE register, a memory-mapped
SFR) with register-direct addressing through a 128-byte window. This location is in the range of
addresses (1FE0–1FFFH) that cannot be windowed. Although you could set up the window by
writing 1FH to the WSR, reading this location through the window would return FFH (all ones)
and writing to it would not change the contents. However, you could access the peripheral SFRs
in the range of 1F80–1FDFH with the ir windowed direct addresses.
4-16
MEMORY PARTITIONS
4.2.2.5Using the Linker Locator to Set Up a Window
In this example, the linker locator is used to set up a window. The linker locator locates the window in the upper register file and determines the value to load in the WSR for access to that window. (Please consul t the manual provided with the linker locato r for details.)
********* mod1 **************
mod1 module main ;Main module for linker
public function1
extrn ?WSR ;Must declare ?WSR as external
wsr equ 14h:byte
sp equ 18h:word
oseg
var1: dsw 1 ;Allocate variables in an
var2: dsw 1 ;overlayable segment
var3: dsw 1
cseg
function1:
push wsr ;Prolog code for wsr
ldb wsr, #?WSR ;Prolog code for wsr
add var1, var2, var3 ;Use the variables as registers
;
;
;
ldb wsr, [sp] ;Epilog code for wsr
add sp, #2 ;Epilog code for wsr
ret
end
******** mod2 **************
public function2
extrn ?WSR
wsr equ 14h:byte
sp equ 18h:word
oseg
var1: dsw 1
var2: dsw 1
var3: dsw 1
cseg
function2:
push wsr ;Prolog code for wsr
4-17
8XC196MC, MD, MH USER’S MANUAL
ldb wsr, #?WSR ;Prolog code for wsr
add var1, var2, var3
;
;
;
ldb wsr, [sp] ;Epilog code for wsr
add sp, #2 ;Epilog code for wsr
ret
end
******************************
The following is an example of a linker invocation to link and loc ate the modules and to determine the proper windowing.
The above linker control s tel l the lin ker to us e regist ers 0100– 0 1FFH for windowing an d to use
a window size of 32 bytes. (These two controls enable windowing.)
The following is the map listing for the resultant output module (MOD1 by default):
SEGMENT MAP FOR mod1(MOD1):
TYPE BASE LENGTH ALIGNMENT MODULE NAME
---- ---- ------ --------- ----------**RESERVED* 0000H 001AH
STACK 001AH 0006H WORD
*** GAP *** 0020H 00E0H
OVRLY 0100H 0006H WORD MOD2
OVRLY 0106H 0006H WORD MOD1
*** GAP *** 010CH 1F74H
CODE 2080H 0011H BYTE MOD2
CODE 2091H 0011H BYTE MOD1
*** GAP *** 20A2H DF5EH
The C compiler can also take a dvantage of this fea ture if the “windows” switch is enabled. F or
details, see the MCS 96 microcontroller architecture software products in the Development ToolsHandbook.
4.2.3Windowi ng and Add ressi ng Modes
Once windowing is enabled, the windowed locations can be accessed both through the window
using direct (8-bit) addressing and by the usual 16-bit addressing. The lower register file locations
that are covered b y the window are a lways acc essible by indire ct or indexed opera tions. To reenable direc t acce ss t o the ent ire lower regi ste r file, c lear t he W SR. To enable direct a cc ess to a
particular location in the lower register file, you can select a sma ller window that does not cover
that locatio n.
When windowing is enabled:
• a register-direct instruction that uses an address within the lower register file actually
accesses the window in the upper register file;
• an indirect, indexe d, or zero -regist er inst ruct ion that uses an address withi n eit her the lowe r
register file or the upper register file accesses the actual location in me mory.
The following sample code illustrates the difference between register-direct and indexed addressing when using windowing.
PUSHA; pushes the contents of WSR onto the stack
LDB WSR, #12H; select window 12H, a 128-byte block
ADD 40H, 380H[0]; mem_word(40H)←mem_word(40H) + mem_word(380H +0)
POPA; reloads the previous contents into WSR
; The next instruction uses register-direct addr
; The next two instructions use indirect addr
4-19
Standard and PTS
Interrupts
5
CHAPT ER 5
STANDARD AND PTS INTERRUPTS
This chapter describes the interrupt control circuitry, priority scheme, and timing for standard and
peripheral transaction server (PTS) interrupts. I t discusses the three special interrupts and the seven PTS modes, f our of which are us ed with the EPA to provide a software serial I/O channel for
both synchronous and asynchronous transfers and receptions. It also explains interrupt programming and control.
5.1OVERVIEW OF INTERRUPTS
The interrupt control circuitry withi n a microcontrolle r permits real-time events to cont rol program flow. When an event generates an interrupt, the device suspends the execution of current
instructions while it performs some service in response to the interrupt. When the interrupt is serviced, program executi on resume s at the point whe re t he interrupt oc curred. An inte r nal peripheral, an external signa l, or an instruction can generate an interrupt request. In the simplest case,
the device receives the request, performs the service, and returns to the task that was interrupted.
This microcontroller’s flexible interrupt-handling system has tw o main comp onents: the programmable interrupt c ontroller and the periphera l transaction server (PTS). The programmable
interrupt controller has a hardware priority scheme that can be modified by your software. Interrupts that go through the inte rrupt controller are serviced by interrupt servic e routines that you
provide. The upper and lower interrupt vectors in special-purpose memory (see Chapter 4,
“Memory Partitions”) co ntain the interrupt service routi nes’ addresses. The periphera l transaction server (PTS), a microcoded hardware interrupt processor, provide s high-speed, low-overhead interrupt handling; it does not modify the stack or the PSW. You can configure most
interrupts (except NMI, trap, and unimple mente d opcode) to be se rviced by t he PTS instead of
the interrupt controller.
The PTS supports seven speci al mi croc oded r outines that enabl e i t t o compl ete specific tasks i n
much less time than an eq uivalent interrupt ser vice routine can. It can transfer byte s or words,
either individually or in blocks, between any memory locations; manage multiple analog-to-digital (A/D) conversions; and transmit and receive serial data in eithe r asynchronous or synchronous mode (MC, MD only). PTS interrupts have a higher priority than standard interrupts and
may temporarily suspend inter rupt service routines .
A block of data called the PTS control block (PTSCB) contains the specific deta ils for each PTS
routine (see “Initializing the PTS Control Blocks” on page 5-24). When a PTS interrupt occurs,
the priority encoder selects the appropriate vector and fetches the PTS control block (PTSCB).
5-1
8XC196MC, MD, MH USER’S MANUAL
Interrupt Pending or PTSSRV Bit Set
INT _MASK.
Yes
Yes
PTSSEL.
Yes
Highest Priority PTS Interrupt
Reset INT_PEND.x
Execute 1 PTS Cycle
(Microcoded)
Decrement
PTSCOUNT
NMI
Pending
?
No
= 1?
PTS
Enabled?
Bit = 1?
Priority
Encoder
Bit
Yes
No
x
No
No
x
Return
YesNo
Reset PTSSRV.x
Bit
Interrupts
Enabled
?
Yes
Priority
Encoder
PTSSRV.
= 1?
PUSH PC
on Stack
No
Highest Priority Interrupt
x
Reset INT_PEND.
Bit
Return
x
5-2
LJMP to
ISR
Execute Interrupt
Service Routine
POP PC
from Stack
Return
Return
No
PTSCOUNT
= 0?
Yes
Clear PTSSEL.
Set PTSSRV.x Bit
Return
x
Bit
Figure 5-1. Flow Diagram for PTS and Standard Interrupts
A0320-02
STANDARD AND PTS INTERRUPTS
Figure 5-1 illustrates the interrupt pr ocessing flow. In this flow diagram, “INT_MASK” represents both the INT _MASK and INT_M ASK1 regi sters, and “INT_PE ND” represents bot h the
INT_PEND and INT_PEND 1 registers.
5.2INTERRUPT SIGNALS AND REGISTERS
Table 5-1 describe s the exte rnal int errupt signal s and Table 5-2 describes t he control and statu s
registers for both the interrupt controller and PTS.
Table 5-1. Interr upt Sign als
Port PinInterrupt Signal TypeDes crip tion
—EXTINTIExte rn al Interr upt
This programmable interrupt is controlled by the
WG_PROTECT registe r. This register controls whether the
interrupt is edge triggered or sampled and whether a rising
edge/hi gh level or fal ling edge/l ow level activate s the
interr u pt.
In powerdown mode, asserting the EXTINT signal for at least
50 ns causes the device to resume normal operation. The
interrupt need not be enabled . If the EXTINT interru pt is
enabled, the CPU executes the interrup t service routine.
Otherwise, the CPU executes the instruction that immediately
follows the command that invoked the power-saving mode.
In idle mode, asserting any enabled interrupt causes the
device to resume normal operation.
—NMIINonmaskable Interrupt
In normal operating mode, a rising edge on NMI generates a
nonmas kabl e interr up t. NMI has the highe st prior ity of all
prioritized interrupts. Assert NMI for greater than one state
time to guarantee that it is recognized.
Table 5-2. Interrupt and PTS Control and Status Registers
MnemonicAddressDescription
INT_MASK
INT_MASK1
INT_PEND
INT_PEND1
PI_MAS K1FB C HPeripheral Int errupt Mask
0008H
0013H
0009H
0012H
Interrupt Mask Registers
These registers enable/disable each maskable interrupt (that is,
each interrupt except unimplemented opcode, software trap, and
NMI).
Interrupt Pending Registers
The bits in this registe r are set by hardwa re to in dica te that an
interrupt is pending.
The bits in this register enable and disable (mask) the timer 1 and 2
overflow/underflow interrupt requests, the waveform generator
interrupt request (MC, MD), the EPA compare-only channel 5
interrupt request (MD), and the serial port error interrupts (MH).
5-3
8XC196MC, MD, MH USER’S MANUAL
Table 5-2. Interrupt and PTS Control and Status Registers (Continued)
MnemonicAddre ssDescription
PI_PE ND1FBEHPeripheral Interru pt Pend in g
Any bit set indicates a pending interrupt request.
PSWNo direct accessProcessor Status Word
This registe r conta ins one bit that globall y enab le s or disa bles
servici ng of all mas kabl e interrupts and anoth er that en ab les or
disables the PTS. These bits are set or cleared by execu ting the
enable interrupts (EI), disable interrupts (DI), enable PTS (EPTS),
and disable PTS (DPTS) instructions.
PTSSEL0004H, 0005HPTS Select Register
This registe r selects eith er a PTS routi ne or a standar d interru pt
service rout in e for ea ch of the maskable interru pt requests.
PTSSRV0006H, 0007HPTS Service Register
The bits in this register are set by hardware to request an end-ofPTS interrupt.
5.3INTERRUPT SOURCES AND PRIORITIES
Table 5-3 lists the interrupts so urces, their default priorities (30 is highest and 0 is lowest), an d
their vector addresses . The unimplemented opco de and software trap interrupts are not prioritized; they go dire ctly to the i nterrupt cont roller for s ervicing. The pri ority enc oder determ ines
the priority of all other pending interrupt requests. NMI has the highest priority of all prioritized
interrupts, PTS interrupts have the next highest priority, and standard interrupts have the lowest.
The priority encoder selec ts the highest priority pendin g request and the interrupt controller selects the corresponding vector location in special-purpose memory. This vector contains the starting (base) address of the corres pondin g PTS control block (PTSCB) or inte rr upt servi ce routine.
PTSCBs must be located on a quad-word boundary in the internal register file.
5-4
Table 5-3. Interrupt Sources, Vectors, and Priorities
Interrupt SourceMnemonic
STANDARD AND PTS INTERRUPTS
Interrupt Controller
Service
PTS Service
Name
Vector
Priority
Name
Vector
Nonmaskable InterruptNMIINT15203EH30———
EXTINT PinEXTINTINT14203CH14PTS14205CH29
WF Gen (MC)
WF Gen & EPA Comp 5 (MD)
Waveform Generator (MH)
Reserved (MC)
PTS service is not useful for multiplexe d int erru pt s because the PTS cannot readily det ermin e the
†
INT002000H00PTS00 2040H15
source of these interru pt s.
Priority
5-5
8XC196MC, MD, MH USER’S MANUAL
5.3.1Special Interrupts
This microcontroller has three special interrupt sources that are always enabled: unimplemented
opcode, softwa re tra p, an d NMI . These interrupts are n ot a ffected b y the E I (e nable i nter rupts)
and DI (disable interrupts) instruc tions, and they cannot be maske d. All of these interrupts are
serviced by the interrupt controller; they cannot be assigned to the PTS. Of these three, only NMI
goes through the transition detector and priority encode r. The other two special interrupts go directly to the interrupt controller for servicing. Be aware that these interrupts are often assigned to
special functions in development tools .
5.3.1.1Unimplemented Opcode
If the CPU attempts to execute an unimplemented opcode, an indirect vector through location
2012H occurs. This prevents random software exe cut ion durin g hardware and software failures.
The interrupt vector should contain the starting address of an error routine that will not further
corrupt an a lready erroneous s ituation. The unimplemented opcode interrupt prevents other interrupt requests from being acknowledged until after the next instruction is executed.
5.3.1.2Software Trap
The TRAP instr uction (opcode F7H) cause s an interrupt call that is vectored th rough location
2010H. The TRAP inst ruct ion pr ovides a single-i nstruc tio n inter rupt tha t is useful when debugging software or generating software inte rrupts. The TRAP instr uction prevents other inter rupt
requests from being ack nowle dge d until aft er the next inst ruct ion is exec ute d.
5.3.1.3NMI
The external NMI pin generat es a nonmaska ble interrupt for implem ent at ion of critical inter rupt
routines. NMI has the highest priority o f all the prioritize d interrupts. It is passed directly f rom
the transition detector to the priority encoder, and it vectors indirectly through location 203EH.
The NMI pin is sampled during phase 2 (CLKOUT high) and is latched internally. Because interrupts are edge-triggered, only one interrupt is generated, even if the pin is held high.
If your system does not use the NMI interrupt, connect the NMI pin to V
to prevent sp urious
SS
interrupts.
5.3.2External Interru pt Pi n
The protection ci rcuitry in t he waveform generat or (Figure 5 -2) monitors the external inter rupt
(EXTINT) signal. When it detects a valid event on the input, it sumultaneously disables the waveform generator outputs and generates an EXTINT interrupt request. Bits 2 and 3 in the waveform
generator protection (WG_PROTECT) regi ster (Figure 9-9 on page 9-15) select the type of external event that will generate an interrupt request: a falling or rising edge or a low or high level.
5-6
STANDARD AND PTS INTERRUPTS
When the level-sensi tive eve nt is selecte d, the externa l interrupt si gnal must rem ain asse rte d for
at least 24 T
XTAL1
(24/F
the level sam pler sample s the le vel of the signa l thre e ti mes during a 24 T
) to be recognized a s a valid i nte rrupt. When the signal i s a sse rte d,
XTAL1
period. When a
XTAL1
valid level occurs, the level sampler generates a a single output pulse. The output pulse generates
the EXTINT interrupt re quest. T he l eve l-sensitive mo de is use f ul in noisy environments, where
a noise spike might cause an unintenti ona l interrupt request.
When an edge-triggered event is selected, the input must remain asserted for at least two T
(2/F
) to be recognized as a valid interrupt. When a valid transition occurs, the transition de-
XTAL1
XTAL1
tector generates a single output pulse. The output pulse generates the EXTINT interrupt request.
The PI (MD), OVRTM (Mx), and SPI (MH) interrupts have multiple s ourc es (see Table 5-3 on
page 5-5). An individual source will generate the interrupt only if software enables both the interrupt source and multiplexed interrupt. To enable the multiplexed interrupt, set the appropriate
bit in the interrupt mask register (Figures 5-7 and 5-8). To enable an interrupt source, set the appropriate bit in the PI_MASK regis ter (Figure 5 -9 on pa ge 5- 17). Figure 5 -3 shows the flow fo r
the timer interrupt.
NOTE
Although the PI interrupt on the 8XC196MC has a single source (the
waveform generator), software must still enable both the source interrupt
(WG) in the PI_PEND register and the PI interrupt in the INT_MASK register.
5-7
8XC196MC, MD, MH USER’S MANUAL
The interrupt service routine should read the PI_PEND (Figure 5-12 on page 5-23) register to determine the source of the interrupt. Before executin g the return instruct ion, the i nterrupt se rvice
routine should check to see i f any of the ot her inte rr upt sources are pe nding. Ge nerally, PTS interrupt service is not useful for multiple xed inte rr upts because the PTS cannot readily determine
the interrupt source.
Timer x
Overflows
Set OVRTM
bit in PI_PEND
Is OVRTM
bit set in
PI_MASK
Set OVRTM
bit in INT_PEND
Is OVRTM
bit set in
INT_MASK
Generate
OVRTM interrupt
x
x
?
Yes
?
Yes
No
No
OVRTM bit
is not set
in INT_PEND
OVRTM interrupt
is not generated
5-8
Read PI_PEND
to see which
timer overflowed
A3254-01
Figure 5-3. Flow Diagram for the OVRTM Interrupt
STANDARD AND PTS INTERRUPTS
5.3.4End-of-PT S Interrupts
When the PTSCOUNT regis ter decrem ents to zero at the end of a single transfer, block transfer,
A/D scan, or seria l I/O routine, hardware clears the corresponding bit in the PTSSEL regist er,
(Figure 5-6 on page 5-14) which disables PTS service for that interrupt. It also sets the corresponding PTSSRV bit, requesting an end-of-P TS in terrupt. An end-of-P TS interrupt has the same
priority as a corresponding standard interrupt. The interrupt controller processes it with an interrupt service routine that is stored in the memory location pointed to by the standard interrupt vector. For example , the PTS services the EPA0 interrupt if PTSS EL.2 is set. The interrupt vectors
through 2044H, but the corresponding end-of-PTS interrupt vectors through 2004H, the standard
EPA 0 interrupt vector. When the end-of-PTS interrupt vectors to the interrupt service routine,
hardware clears the PTSSRV bit. The end-of-PTS interrupt service routine should reinitialize the
PTSCB, if required, and set the appropriate PTSSE L bit to re-enable PTS interrupt service.
5.4INTERRUPT LATENCY
Interrupt latency is the total del ay between the time that the interrupt reque st is generated (not
acknowledged) and the time that the device begins executing either the standard interrupt service
routine or the PTS interrupt service ro utine. A delay occurs between the time that the interr upt
request is detected an d the time that it is acknowle dged. An interrupt req uest is acknowledged
when the current instructi on finishe s execut ing. If t he inte r rupt request occurs during o ne of the
last four state times of the instruction, it may not be acknowledged until after the next instruction
finishes. This additional delay occurs because instructions are prefetched and prepared a few state
times before they are executed. Thus, the maximum del ay between interrupt request and acknowledgment is four state times plus the execut ion time of the next instr uctio n.
When a standard interrupt request is acknowledged, the hardware clears the interrupt pending bit
and forces a call to the address cont ained i n the corresponding i nter rupt vector. When a PTS interrupt request is acknowledged, the hardware immediately vectors to the PTSCB and begins executing the PTS routine.
5.4.1Situations that In crease Interrupt Late ncy
If an interrupt request occurs while any of the following instr uctions are exe cut ing, the interr upt
will not be acknowledged until after the next instruction is execute d:
• the signed prefix opcode (FE) for the two-byte, signed multiply and divide instructions
• any of these eight protected instructions: DI, EI, DPTS, EPTS, POPA, POPF, PUSHA,
PUSHF (see Appendix A for descriptions of these instructions)
• any of the read-modify-write instructions: AND, ANDB , OR, ORB, XOR, XORB
Both the unimplemented opcode interrupt and the software trap interrupt prevent other inter rupt
requests from being ack nowle dge d until aft er the next inst ruct ion is exec ute d.
5-9
8XC196MC, MD, MH USER’S MANUAL
Each PTS cycle wi thin a PTS routine can not be i nterrupted. A PTS cycle i s the ent ire PTS response to a single interrupt request. In block transfer mode, a PTS cycle consists of the transfer
of an entire block of bytes or words. This means a worst-case latency of 500 states if you assume
a block transfer of 32 words from one external memory location to another. See T able 5-4 on page
5-12 for PTS cycle execution times.
5.4.2Calculatin g Latency
The maximum latency occurs when the interrupt request occurs too late for acknowledgment following the current instruction. The following worst-case calculation assumes that the current instruction is not a protected instructi on. To calculate latency, add the following terms :
• Time for the current instruction to finish executi on (4 state times ).
— I f this is a protected inst ruct ion, t he inst ruct ion tha t follows it must also exec ute bef ore
the interrupt can be acknowledged. Add the execution time of the instruction that
follows a protected instruction.
• Time for the next instruction to execut e. (The longest instruc tion, NORML, takes 39 state
times. However, the BMOV instruction could actually take longer if it is transferring a large
block of data. If your code contains routines that transfer large blocks of data, you may get a
more accurate worst-case value if you use the BMOV instruction in your calculation instead
of NORML. See A ppendix A for instruction exec uti on ti me s.)
• For standard interrupts only, the response time to get the vector and force the call.
— 11 state times for an internal stack or 13 for an exte rnal stack (assuming a zero-wait-
state bus)
5.4.2.1Standard Interrupt Latency
The worst-case delay for a standard interrupt is 56 state times (4 + 39 + 11 + 2) if the stack is in
external memory (Figure 5 -4). This de lay time d oes not include the tim e needed to exec ute the
first instruction in the interrupt service routine or to execute the instruction following a protected
instruction.
5-10
STANDARD AND PTS INTERRUPTS
Execution
EXTINT
Pending
Interrupt
Response
Time
4 3 2 1
Ending
Instruction
"NORML"
End
"NORML"
56 State Times
1121239
Call is
Forced
ClearedSet
If Stack
External
"PUSHA"
6
If Stack
External
Interrupt Routine
A0136-02
Figure 5-4. Standard Interrupt Response Time
5.4.2.2PTS Interrupt Latency
The maximum delay for a PTS interrupt is 43 state times (4 + 39) as shown in Figure 5-5. This
delay time does not include the added delay if a protected instruction is being executed or if a PTS
request is already in progress. See Table 5-4 for execution times for PTS cycles.
39
End
"NORML"
Vector to PTS
Control Block
PTS Interrupt Routine
PTS
PTS
Execution
EXTINT
4 3 2 1
Ending
Instruction
"NORML"
Pending
Interrupt
Response Time
ClearedSet
Latency Time
43 State Times
A0142-01
Figure 5-5. PTS Interrupt Response Time
5-11
8XC196MC, MD, MH USER’S MANUAL
Table 5-4. Execution Times for PTS Cycles
PTS ModeExecution Time (in State Times)
Single transfer mode
register/register
memory/re gister
memory/memory
Block transfer mode
register/register
memory/register
memory/memory
A/D scan mode
register/register
register/memory
ASIO receive mode (MC, MD only)
Majority disabled
†
†
†
†
†
†
†
†
18 per byte or word transfer + 1
21 per byte or word transfer + 1
24 per byte or word transfer + 1
13 + 7 per byte or word transfer (1 minimum)
16 + 7 per byte or word transfer (1 minimum)
19 + 7 per byte or word transfer (1 minimum)
SSIO transmit mode (MC, MD only)30 (transmit data bit)
†
Register
indicates an access to the register file or peripheral SFR.
memory-map ped register, I/O, or memory. See Table 4-1 on page 4-2 for address information.
36 + sample time (second sample)
36 + 7 + sample time (third sample)
36 + 2 (if parity enabled)
21 (no reception)
20 (no transmission)
Memory
indicates an access to a
5.5PROG RAM MING THE INTERRUPTS
The PTS select register (PTSSEL) selects either PTS service or a standard software interrupt service routine for each of the maskable interrupt requests (see Figure 5-6). The bits in the interrupt
mask registers, INT_M ASK and INT_MASK1, ena ble or disable (mask) individual interrupts
(see Figures 5-7 and 5-8). For the mul tiplexed interrupt sources, bits in the PI_MASK regi ster
(Figure 5-9 on page 5-17) enable or disable (mask) the individual interrupt sources. With the exception of the nonmaskable interrupt (NMI) bit (INT_MASK1.7), setting a bit enables the corresponding interrupt source and clearin g a bit disables the source.
To disable any inte r rupt, clear i ts ma sk bit . To enable an interrupt for standard interrupt service,
set its mask bit a nd clear its PTS select bit . To enable an interrupt for PTS service, set both the
mask bit and the PTS select bit.
5-12
STANDARD AND PTS INTERRUPTS
When you assign an interrupt to the PTS, you must set up a PTS control block (PTSCB) for each
interrupt source (see “Initiali zing the PTS Control Blocks” on page 5-24) and us e the EPTS instruction to globally enable the PTS. When you assign an interrupt to a standard software service
routine, use the EI (enable interr upts) inst ruction to globally enabl e interrupt servi ci ng.
NOTE
The DI (disable interrupts) instruction does not disable PTS service. However,
it does disable service for the end-of-PTS interrupt request. If an interrupt
request occurs while interrupts are disabl ed, the corresp onding pending bit is
set in the INT_PEND or INT_PEND1 register.
PTS servic e is not useful for multiple xed inte rrupts because the PTS cannot
readily determine the source of these interrupts.
5-13
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.