



User’s Manual

Information in this document is provided solely to enable use of Intel products. Intel assumes no liability whatsoever, including infringement of any patent or copyright, for sale and use of Intel products except as provided in Intel’s Terms and Conditions 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
or call 1-800-879-4683


ADVANCED MATH FEATURES 3.1 ENHANCED MULTIPLICATION INSTRUCTIONS 3-1 3.2 OPERATING MODES 3-2 3.2.1 Saturation Mode 3-2 3.2.2 Fractional Mode 3-3 3.3 ACCUMULATOR REGISTER (ACC_0x) 3-4 3.4 ACCUMULATOR CONTROL AND STATUS REGISTER (ACC_STAT) 3-5
PROGRAMMING CONSIDERATIONS 4.1 OVERVIEW OF THE INSTRUCTION SET 4-1 4.1.1 BIT Operands 4-2 4.1.2 BYTE Operands 4-2 4.1.3 SHORT-INTEGER Operands 4-2 4.1.4 WORD Operands 4-3 4.1.5 INTEGER Operands 4-3 4.1.6 DOUBLE-WORD Operands 4-3 4.1.7 LONG-INTEGER Operands 4-4 4.1.8 QUAD-WORD Operands 4-4 4.1.9 Converting Operands 4-4 4.1.10 Conditional Jumps 4-4 4.1.11 Floating Point Operations 4-5 4.1.12 Extended Instructions 4-5 4.2 ADDRESSING MODES 4-6 4.2.1 Direct Addressing 4-7 4.2.2 Immediate Addressing 4-7 4.2.3 Indirect Addressing 4-7 4.2.3.1 Extended Indirect Addressing 4-8 4.2.3.2 Indirect Addressing with Autoincrement 4-8 4.2.3.3 Extended Indirect Addressing with Autoincrement 4-8 4.2.3.4 Indirect Addressing with the Stack Pointer 4-9 4.2.4 Indexed Addressing 4-9 4.2.4.1 Short-indexed Addressing 4-9 4.2.4.2 Long-indexed Addressing 4-9 4.2.4.3 Extended Indexed Addressing 4-10 4.2.4.4 Zero-indexed Addressing 4-10 4.2.4.5 Extended Zero-indexed Addressing 4-10 4.3 ASSEMBLY LANGUAGE ADDRESSING MODE SELECTIONS 4-11 4.3.1 Direct Addressing 4-11 4.3.2 Indexed Addressing 4-11 4.3.3 Extended Addressing 4-11 4.4 DESIGN CONSIDERATIONS FOR 1-MBYTE DEVICES 4-11 4.5 SOFTWARE STANDARDS AND CONVENTIONS 4-11

4.5.1 Using Registers 4-12 4.5.2 Addressing 32-bit Operands 4-12 4.5.3 Addressing 64-bit Operands 4-12 4.5.4 Linking Subroutines 4-13 4.6 SOFTWARE PROTECTION FEATURES AND GUIDELINES 4-14
MEMORY PARTITIONS 5.1 MEMORY MAP OVERVIEW 5-1 5.2 MEMORY PARTITIONS 5-3 5.2.1 External Memory 5-5 5.2.2 Program and Special-purpose Memory 5-5 5.2.2.1 Program Memory in Page FFH 5-5 5.2.2.2 Special-purpose Memory 5-6 5.2.2.3 Reserved Memory Locations 5-7 5.2.2.4 Interrupt and PTS Vectors 5-7 5.2.2.5 Chip Configuration Bytes 5-7 5.2.3 Peripheral Special-function Registers (SFRs) 5-7 5.2.4 Register File 5-9 5.2.4.1 General-purpose Register RAM 5-11 5.2.4.2 Stack Pointer (SP) 5-11 5.2.4.3 CPU Special-function Registers (SFRs) 5-12 5.3 WINDOWING 5-13 5.3.1 Selecting a Window 5-14 5.3.2 Addressing a Location Through a Window 5-16 5.3.2.1 32-byte Windowing Example 5-18 5.3.2.2 64-byte Windowing Example 5-18 5.3.2.3 128-byte Windowing Example 5-18 5.3.2.4 Unsupported Locations Windowing Example (8XC196NP Only) 5-19 5.3.2.5 Using the Linker Locator to Set Up a Window 5-19 5.3.3 Windowing and Addressing Modes 5-21 5.4 REMAPPING INTERNAL ROM (83C196NP ONLY) 5-22 5.5 FETCHING CODE AND DATA IN THE 1-MBYTE AND 64-KBYTE MODES 5-23 5.5.1 Fetching Instructions 5-23 5.5.2 Accessing Data 5-23 5.5.3 Code Fetches in the 1-Mbyte Mode 5-25 5.5.4 Code Fetches in the 64-Kbyte Mode 5-25 5.5.5 Data Fetches in the 1-Mbyte and 64-Kbyte Modes 5-26 5.6 MEMORY CONFIGURATION EXAMPLES 5-27 5.6.1 Example 1: Using the 64-Kbyte Mode 5-27 5.6.2 Example 2: A 64-Kbyte System with Additional Data Storage 5-29 5.6.3 Example 3: Using 1-Mbyte Mode 5-31

STANDARD AND PTS INTERRUPTS 6.1 OVERVIEW OF INTERRUPTS 6-1 6.2 INTERRUPT SIGNALS AND REGISTERS 6-3 6.3 INTERRUPT SOURCES AND PRIORITIES 6-4 6.3.1 Special Interrupts 6-4 6.3.1.1 Unimplemented Opcode 6-5 6.3.1.2 Software Trap 6-5 6.3.1.3 NMI 6-6 6.3.2 External Interrupt Pins 6-6 6.3.3 Multiplexed Interrupt Sources 6-6 6.3.4 End-of-PTS Interrupts 6-6 6.4 INTERRUPT LATENCY 6-7 6.4.1 Situations that Increase Interrupt Latency 6-7 6.4.2 Calculating Latency 6-8 6.4.2.1 Standard Interrupt Latency 6-8 6.4.2.2 PTS Interrupt Latency 6-9 6.5 PROGRAMMING THE INTERRUPTS 6-10 6.5.1 Programming Considerations for Multiplexed Interrupts 6-11 6.5.2 Modifying Interrupt Priorities 6-13 6.5.3 Determining the Source of an Interrupt 6-15 6.6 INITIALIZING THE PTS CONTROL BLOCKS 6-17 6.6.1 Specifying the PTS Count 6-18 6.6.2 Selecting the PTS Mode 6-19 6.6.3 Single Transfer Mode 6-20 6.6.4 Block Transfer Mode 6-23 6.6.5 PWM Modes 6-26 6.6.5.1 PWM Toggle Mode Example 6-27 6.6.5.2 PWM Remap Mode Example 6-32
I/O PORTS 7.1 I/O PORTS OVERVIEW 7-1 7.2 BIDIRECTIONAL PORTS 1–4 7-1 7.2.1 Bidirectional Port Operation 7-3 7.2.2 Bidirectional Port Pin Configurations 7-7 7.2.3 Bidirectional Port Pin Configuration Example 7-8 7.2.4 Bidirectional Port Considerations 7-9 7.2.5 Design Considerations for External Interrupt Inputs 7-11 7.3 EPORT 7-11 7.3.1 EPORT Operation 7-12 7.3.1.1 Reset 7-14 7.3.1.2 Output Enable 7-14 7.3.1.3 Complementary Output Mode 7-14

7.3.1.4 Open-drain Output Mode 7-14 7.3.1.5 Input Mode 7-16 7.3.2 Configuring EPORT Pins 7-17 7.3.2.1 Configuring EPORT Pins for Extended-address Functions 7-17 7.3.2.2 Configuring EPORT Pins for I/O 7-17 7.3.3 EPORT Considerations 7-18 7.3.3.1 EPORT Status During Reset, CCB Fetch, Idle, Powerdown, and Hold 7-18 7.3.3.2 EP_REG Settings for Pins Configured as Extended-address Signals 7-18 7.3.3.3 EPORT Status During Instruction Execution 7-18 7.3.3.4 Design Considerations 7-19
SERIAL I/O (SIO) PORT 8.1 SERIAL I/O (SIO) PORT FUNCTIONAL OVERVIEW 8-1 8.2 SERIAL I/O PORT SIGNALS AND REGISTERS 8-2 8.3 SERIAL PORT MODES 8-4 8.3.1 Synchronous Mode (Mode 0) 8-4 8.3.2 Asynchronous Modes (Modes 1, 2, and 3) 8-5 8.3.2.1 Mode 1 8-6 8.3.2.2 Mode 2 8-7 8.3.2.3 Mode 3 8-7 8.3.2.4 Mode 2 and 3 Timings 8-7 8.3.2.5 Multiprocessor Communications 8-8 8.4 PROGRAMMING THE SERIAL PORT 8-8 8.4.1 Configuring the Serial Port Pins 8-8 8.4.2 Programming the Control Register 8-8 8.4.3 Programming the Baud Rate and Clock Source 8-8 8.4.4 Enabling the Serial Port Interrupts 8-13 8.4.5 Determining Serial Port Status 8-13
PULSE-WIDTH MODULATOR 9.1 PWM FUNCTIONAL OVERVIEW 9-1 9.2 PWM SIGNALS AND REGISTERS 9-2 9.3 PWM OPERATION 9-3 9.4 PROGRAMMING THE FREQUENCY AND PERIOD 9-5 9.5 PROGRAMMING THE DUTY CYCLE 9-7 9.5.1 Sample Calculations 9-9 9.5.2 Enabling the PWM Outputs 9-9 9.5.3 Generating Analog Outputs 9-9
EVENT PROCESSOR ARRAY (EPA) 10.1 EPA FUNCTIONAL OVERVIEW 10-1

10.2 EPA AND TIMER/COUNTER SIGNALS AND REGISTERS 10-2 10.3 TIMER/COUNTER FUNCTIONAL OVERVIEW 10-5 10.3.1 Cascade Mode (Timer 2 Only) 10-6 10.3.2 Quadrature Clocking Mode 10-6 10.4 EPA CHANNEL FUNCTIONAL OVERVIEW 10-8 10.4.1 Operating in Capture Mode 10-9 10.4.1.1 EPA Overruns 10-11 10.4.1.2 Preventing EPA Overruns 10-12 10.4.2 Operating in Compare Mode 10-12 10.4.2.1 Generating a Low-speed PWM Output 10-12 10.4.2.2 Generating a Medium-speed PWM Output 10-13 10.4.2.3 Generating a High-speed PWM Output 10-14 10.4.2.4 Generating the Highest-speed PWM Output 10-15 10.5 PROGRAMMING THE EPA AND TIMER/COUNTERS 10-15 10.5.1 Configuring the EPA and Timer/Counter Port Pins 10-15 10.5.2 Programming the Timers 10-15 10.5.3 Programming the Capture/Compare Channels 10-18 10.6 ENABLING THE EPA INTERRUPTS 10-22 10.7 DETERMINING EVENT STATUS 10-22 10.7.1 Using Software to Service the Multiplexed Overrun Interrupts 10-23 10.8 PROGRAMMING EXAMPLES FOR EPA CHANNELS 10-24 10.8.1 EPA Compare Event Program 10-24 10.8.2 EPA Capture Event Program 10-25 10.8.3 EPA PWM Output Program 10-26
MINIMUM HARDWARE CONSIDERATIONS 11.1 MINIMUM CONNECTIONS 11-1 11.1.1 Unused Inputs 11-2 11.1.2 I/O Port Pin Connections 11-2 11.2 APPLYING AND REMOVING POWER 11-4 11.3 NOISE PROTECTION TIPS 11-4 11.4 THE ON-CHIP OSCILLATOR CIRCUITRY 11-5 11.5 USING AN EXTERNAL CLOCK SOURCE 11-7 11.6 RESETTING THE DEVICE 11-8 11.6.1 Generating an External Reset 11-9 11.6.2 Issuing the Reset (RST) Instruction 11-11 11.6.3 Issuing an Illegal IDLPD Key Operand 11-11
SPECIAL OPERATING MODES 12.1 SPECIAL OPERATING MODE SIGNALS AND REGISTERS 12-1 12.2 REDUCING POWER CONSUMPTION 12-3

12.3 IDLE MODE 12-5 12.4 STANDBY MODE (80C196NU ONLY) 12-6 12.4.1 Enabling and Disabling Standby Mode 12-6 12.4.2 Entering Standby Mode 12-6 12.4.3 Exiting Standby Mode 12-7 12.5 POWERDOWN MODE 12-7 12.5.1 Enabling and Disabling Powerdown Mode 12-7 12.5.2 Entering Powerdown Mode 12-7 12.5.3 Exiting Powerdown Mode 12-8 12.5.3.1 Generating a Hardware Reset 12-8 12.5.3.2 Asserting an External Interrupt Signal 12-8 12.5.3.3 Selecting C1 12-10 12.6 ONCE MODE 12-12 12.7 RESERVED TEST MODES (80C196NU ONLY) 12-12
INTERFACING WITH EXTERNAL MEMORY 13.1 INTERNAL AND EXTERNAL ADDRESSES 13-1 13.2 EXTERNAL MEMORY INTERFACE SIGNALS 13-2 13.3 THE CHIP-SELECT UNIT 13-5 13.3.1 Defining Chip-select Address Ranges 13-7 13.3.2 Controlling Wait States, Bus Width, and Bus Multiplexing 13-10 13.3.3 Chip-select Unit Initial Conditions 13-11 13.3.4 Initializing the Chip-select Registers 13-11 13.3.5 Example of a Chip-select Setup 13-12 13.4 CHIP CONFIGURATION REGISTERS AND CHIP CONFIGURATION BYTES 13-14 13.5 BUS WIDTH AND MULTIPLEXING 13-18 13.5.1 A 16-bit Example System 13-21 13.5.2 16-bit Bus Timings 13-22 13.5.3 8-bit Bus Timings 13-24 13.5.4 Comparison of Multiplexed and Demultiplexed Buses 13-26 13.6 WAIT STATES (READY CONTROL) 13-26 13.7 BUS-HOLD PROTOCOL 13-30 13.7.1 Enabling the Bus-hold Protocol 13-32 13.7.2 Disabling the Bus-hold Protocol 13-32 13.7.3 Hold Latency 13-32 13.7.4 Regaining Bus Control 13-33 13.8 WRITE-CONTROL MODES 13-33 13.9 SYSTEM BUS AC TIMING SPECIFICATIONS 13-36 13.9.1 Deferred Bus-cycle Mode (80C196NU Only) 13-40 13.9.2 Explanation of AC Symbols 13-42 13.9.3 AC Timing Definitions 13-42

INSTRUCTION SET REFERENCE
APPENDIX B
SIGNAL DESCRIPTIONS B.1 FUNCTIONAL GROUPINGS OF SIGNALS B-1 B.2 SIGNAL DESCRIPTIONS B-6 B.3 DEFAULT CONDITIONS B-13
REGISTERS
GLOSSARY
INDEX

FIGURES
Figure Page 2-1 8XC196NP and 80C196NU Block Diagram 2-2 2-2 Block Diagram of the Core 2-3 2-3 Clock Circuitry (8XC196NP) 2-7 2-4 Clock Circuitry (80C196NU) 2-8 2-5 Internal Clock Phases 2-9 2-6 Effect of Clock Mode on CLKOUT Frequency 2-10 3-1 Accumulator (ACC_0x) Register 3-4 3-2 Accumulator Control and Status (ACC_STAT) Register 3-5 5-1 16-Mbyte Address Space 5-2 5-2 Pages FFH and 00H 5-3 5-3 Register File Memory Map 5-10 5-4 Windowing 5-13 5-5 Window Selection (WSR) Register 5-14 5-6 Window Selection 1 (WSR1) Register 5-15 5-7 The 24-bit Program Counter 5-23 5-8 Formation of Extended and Nonextended Addresses 5-24 5-9 A 64-Kbyte System With an 8-bit Bus 5-27 5-10 A 64-Kbyte System with Additional Data Storage 5-29 5-11 Example System Using the 1-Mbyte Mode 5-31 6-1 Flow Diagram for PTS and Standard Interrupts 6-2 6-2 Standard Interrupt Response Time 6-9 6-3 PTS Interrupt Response Time 6-9 6-4 PTS Select (PTSSEL) Register 6-11 6-5 Interrupt Mask (INT_MASK) Register 6-12 6-6 Interrupt Mask 1 (INT_MASK1) Register 6-13 6-7 Interrupt Pending (INT_PEND) Register 6-16 6-8 Interrupt Pending 1 (INT_PEND1) Register 6-17 6-9 PTS Control Blocks 6-18 6-10 PTS Service (PTSSRV) Register 6-19 6-11 PTS Mode Selection Bits (PTSCON Bits 7:5) 6-20 6-12 PTS Control Block — Single Transfer Mode 6-21 6-13 PTS Control Block — Block Transfer Mode 6-24 6-14 A Generic PWM Waveform 6-27 6-15 PTS Control Block — PWM Toggle Mode 6-29 6-16 EPA and PTS Operations for the PWM Toggle Mode Example 6-31 6-17 PTS Control Block — PWM Remap Mode 6-34 6-18 EPA and PTS Operations for the PWM Remap Mode Example 6-36 7-1 Bidirectional Port Structure 7-5 7-2 EPORT Block Diagram 7-13 7-3 EPORT Structure 7-15 8-1 SIO Block Diagram 8-1 8-2 Typical Shift Register Circuit for Mode 0 8-4 8-3 Mode 0 Timing 8-5 8-4 Serial Port Frames for Mode 1 8-6

Figure Page 8-5 Serial Port Frames in Mode 2 and 3 8-7 8-6 Serial Port Control (SP_CON) Register 8-9 8-7 Serial Port Baud Rate (SP_BAUD) Register 8-11 8-8 Serial Port Status (SP_STATUS) Register 8-14 9-1 PWM Block Diagram (8XC196NP Only) 9-1 9-2 PWM Block Diagram (80C196NU Only) 9-2 9-3 PWM Output Waveforms 9-5 9-4 Control (CON_REG0) Register 9-7 9-5 PWM Control (PWMx_CONTROL) Register 9-8 9-6 D/A Buffer Block Diagram 9-10 9-7 PWM to Analog Conversion Circuitry 9-10 10-1 EPA Block Diagram 10-2 10-2 EPA Timer/Counters 10-5 10-3 Quadrature Mode Interface 10-7 10-4 Quadrature Mode Timing and Count 10-8 10-5 A Single EPA Capture/Compare Channel 10-9 10-6 EPA Simplified Input-capture Structure 10-10 10-7 Valid EPA Input Events 10-10 10-8 Timer 1 Control (T1CONTROL) Register 10-16 10-9 Timer 2 Control (T2CONTROL) Register 10-17 10-10 EPA Control (EPAx_CON) Registers 10-19 10-11 EPA Interrupt Mask (EPA_MASK) Register 10-22 10-12 EPA Interrupt Pending (EPA_PEND) Register 10-23 11-1 Minimum Hardware Connections 11-3 11-2 Power and Return Connections 11-4 11-3 On-chip Oscillator Circuit 11-5 11-4 External Crystal Connections 11-6 11-5 External Clock Connections 11-7 11-6 External Clock Drive Waveforms 11-7 11-7 Reset Timing Sequence 11-8 11-8 Internal Reset Circuitry 11-9 11-9 Minimum Reset Circuit 11-10 11-10 Example System Reset Circuit 11-10 12-1 Clock Control During Power-saving Modes (8XC196NP) 12-4 12-2 Clock Control During Power-saving Modes (80C196NU) 12-5 12-3 Power-up and Powerdown Sequence When Using an External Interrupt 12-9 12-4 External RC Circuit 12-9 12-5 Typical Voltage on the RPD Pin While Exiting Powerdown 12-11 13-1 Calculation of a Chip-select Output 13-6 13-2 Address Compare (ADDRCOMx) Register 13-7 13-3 Address Mask (ADDRMSKx) Register 13-8 13-4 Bus Control (BUSCONx) Register 13-10 13-5 Example System for Setting Up Chip-select Outputs 13-13 13-6 Chip Configuration 0 (CCR0) Register 13-15

FIGURES
Figure Page 13-7 Chip Configuration 1 (CCR1) Register 13-16 13-8 Multiplexing and Bus Width Options 13-19 13-9 Bus Activity for Four Types of Buses 13-20 13-10 16-bit External Devices in Demultiplexed Mode 13-22 13-11 Timings for Multiplexed and Demultiplexed 16-bit Buses (8XC196NP) 13-23 13-12 Timings for Multiplexed and Demultiplexed 8-bit Buses (8XC196NP) 13-25 13-13 READY Timing Diagram — Multiplexed Mode 13-28 13-14 READY Timing Diagram — Demultiplexed Mode (8XC196NP) 13-29 13-15 READY Timing Diagram — Demultiplexed Mode (80C196NU) 13-30 13-16 HOLD#, HLDA# Timing 13-31 13-17 Write-control Signal Waveforms 13-34 13-18 Decoding WRL# and WRH# 13-35 13-19 A System with 8-bit and 16-bit Buses 13-36 13-20 Multiplexed System Bus Timing (8XC196NP) 13-37 13-21 Multiplexed System Bus Timing (80C196NU) 13-38 13-22 Demultiplexed System Bus Timing (8XC196NP) 13-39 13-23 Demultiplexed System Bus Timing (80C196NU) 13-40 13-24 Deferred Bus-cycle Mode Timing Diagram (80C196NU) 13-41 B-1 8XC196NP 100-lead SQFP Package B-2 B-2 8XC196NP 100-lead QFP Package B-3 B-3 80C196NU 100-lead SQFP Package B-4 B-4 80C196NU 100-lead QFP Package B-5

Table Page 1-1 Handbooks and Product Information 1-6 1-2 Application Notes, Application Briefs, and Article Reprints 1-6 1-3 MCS® 96 Microcontroller Datasheets (Commercial/Express) 1-7 1-4 MCS® 96 Microcontroller Datasheets (Automotive) 1-7 1-5 MCS® 96 Microcontroller Quick References 1-8 2-1 Features of the 8XC196NP and 80C196NU 2-2 2-2 State Times at Various Frequencies 2-9 2-3 Relationships Between Input Frequency, Clock Multiplier, and State Times 2-10 3-1 Multiply/Accumulate Example Code 3-2 3-2 Effect of SME and FME Bit Combinations 3-6 4-1 Operand Type Definitions 4-1 4-2 Equivalent Operand Types for Assembly and C Programming Languages 4-2 4-3 Definition of Temporary Registers 4-7 5-1 8XC196NP and 80C196NU Memory Map 5-4 5-2 Program Memory Access for the 83C196NP 5-5 5-3 8XC196NP and 80C196NU Special-purpose Memory Addresses 5-6 5-4 Special-purpose Memory Access for the 83C196NP 5-6 5-5 Peripheral SFRs 5-8 5-6 Register File Memory Addresses 5-11 5-7 CPU SFRs 5-12 5-8 Selecting a Window of Peripheral SFRs 5-15 5-9 Selecting a Window of the Upper Register File 5-15 5-10 Windows 5-17 5-11 Windowed Base Addresses 5-18 5-12 Memory Map for the System in Figure 5-9 5-28 5-13 Memory Map for the System in Figure 5-10 5-30 5-14 Memory Map for the System in Figure 5-11 5-32 6-1 Interrupt Signals 6-3 6-2 Interrupt and PTS Control and Status Registers 6-3 6-3 Interrupt Sources, Vectors, and Priorities 6-5 6-4 Execution Times for PTS Cycles 6-10 6-5 Single Transfer Mode PTSCB 6-23 6-6 Block Transfer Mode PTSCB 6-23 6-7 Comparison of PWM Modes 6-26 6-8 PWM Toggle Mode PTSCB 6-28 6-9 PWM Remap Mode PTSCB 6-33 7-1 Device I/O Ports 7-1 7-2 Bidirectional Port Pins 7-2 7-3 Bidirectional Port Control and Status Registers 7-3 7-4 Logic Table for Bidirectional Ports in I/O Mode 7-6 7-5 Logic Table for Bidirectional Ports in Special-function Mode 7-6 7-6 Control Register Values for Each Configuration 7-8 7-7 Port Configuration Example 7-8 7-8 Port Pin States After Reset and After Example Code Execution 7-9

TABLES
Table Page 7-9 EPORT Pins 7-11 7-10 EPORT Control and Status Registers 7-12 7-11 Logic Table for EPORT in I/O Mode 7-16 7-12 Logic Table for EPORT in Address Mode 7-16 7-13 Configuration Register Settings for EPORT Pins 7-17 8-1 Serial Port Signals 8-2 8-2 Serial Port Control and Status Registers 8-2 8-3 SP_BAUD Values When Using the Internal Clock at 25 MHz 8-12 8-4 SP_BAUD Values When Using the Internal Clock at 50 MHz (80C196NU Only) 8-13 9-1 PWM Signals 9-2 9-2 PWM Control and Status Registers 9-3 9-3 PWM Output Frequencies (8XC196NP) 9-6 9-4 PWM Output Frequencies (80C196NU) 9-6 9-5 PWM Output Alternate Functions 9-9 10-1 EPA and Timer/Counter Signals 10-2 10-2 EPA Control and Status Registers 10-3 10-3 Quadrature Mode Truth Table 10-7 10-4 Action Taken when a Valid Edge Occurs 10-11 10-5 Example Control Register Settings and EPA Operations 10-18 11-1 Minimum Required Signals 11-1 11-2 I/O Port Configuration Guide 11-2 12-1 Operating Mode Control Signals 12-1 12-2 Operating Mode Control and Status Registers 12-2 12-3 80C196NU Clock Modes 12-13 13-1 Example of Internal and External Addresses 13-1 13-2 External Memory Interface Signals 13-2 13-3 Chip-select Registers 13-6 13-4 ADDRCOMx Addresses and Reset Values 13-7 13-5 ADDRMSKx Addresses and Reset Values 13-8 13-6 Base Addresses for Several Sizes of the Address Range 13-9 13-7 BUSCONx Addresses and Reset Values 13-11 13-8 BUSCONx Registers for the Example System 13-13 13-9 Results for the Chip-select Example 13-14 13-10 Comparison of AC Timings for Demultiplexed and Multiplexed 16-bit Buses 13-26 13-11 READY Signal Timing Definitions 13-27 13-12 HOLD#, HLDA# Timing Definitions 13-31 13-13 Maximum Hold Latency 13-33 13-14 Write Signals for Standard and Write Strobe Modes 13-34 13-15 AC Timing Symbol Definitions 13-42 13-16 AC Timing Definitions 13-42 A-1 Opcode Map (Left Half) A-2 A-1 Opcode Map (Right Half) A-3 A-2 Processor Status Word (PSW) Flags A-4 A-3 Effect of PSW Flags or Specified Conditions on Conditional Jump Instructions A-5

Table Page A-4 PSW Flag Setting Symbols A-5 A-5 Operand Variables A-6 A-6 Instruction Set A-7 A-7 Instruction Opcodes A-47 A-8 Instruction Lengths and Hexadecimal Opcodes A-53 A-9 Instruction Execution Times (in State Times) A-60 B-1 8XC196NP and 80C196NU Signals Arranged by Function B-1 B-2 Description of Columns of Table B-3 B-6 B-3 Signal Descriptions B-6 B-4 Definition of Status Symbols B-13 B-5 8XC196NP and 80C196NU Pin Status B-13 C-1 Modules and Related Registers C-1 C-2 Register Name, Address, and Reset Status C-2 C-3 ACC_0x Addresses and Reset Values C-5 C-4 Effect of SME and FME Bit Combinations C-7 C-5 ADDRCOMx Addresses and Reset Values C-8 C-6 ADDRMSKx Addresses and Reset Values C-9 C-7 BUSCONx Addresses and Reset Values C-10 C-8 EPAx_CON Addresses and Reset Values C-23 C-9 EPAx_TIME Addresses and Reset Values C-24 C-10 Px_DIR Addresses and Reset Values C-30 C-11 Px_MODE Addresses and Reset Values C-31 C-12 Special-function Signals for Ports 1–4 C-31 C-13 Px_PIN Addresses and Reset Values C-32 C-14 Px_REG Addresses and Reset Values C-33 C-15 PWMx_CONTROL Addresses and Reset Values C-38 C-16 SP_BAUD Values When Using the Internal Clock at 25 MHz C-43 C-17 TIMERx Addresses and Reset Values C-48 C-18 WSR Settings and Direct Addresses for Windowable SFRs C-49 C-19 WSR1 Settings and Direct Addresses for Windowable SFRs C-52




This manual describes the 8XC196NP and 80C196NU 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.
This manual contains several chapters and appendixes, a glossary, and an index. This chapter, Chapter 1, provides an overview of the manual. This section summarizes the contents of the re- maining chapters and appendixes. The remainder of this chapter describes notational conventions and terminology used throughout the manual, provides references to related documentation, de- scribes customer support services, and explains how to access information and assistance.
Chapter 2 — Architectural Overview — provides an overview of the device hardware. It de- scribes the core, internal timing, internal peripherals, and special operating modes.
Chapter 3 — Advanced Math Features — describes the advanced mathematical features of the 80C196NU. The 80C196NU is the first member of the MCS® 96 microcontroller family to in- corporate enhanced 16-bit multiplication instructions for performing multiply-accumulate oper- ations and a dedicated, 32-bit accumulator register for storing the results of these operations. The accumulator and the enhanced instructions combine to decrease the amount of time required to perform multiply-accumulate operations. The instructions and accumulator support signed and unsigned integers as well as signed fractional data.
Chapter 4 — Programming Considerations — provides an overview of the instruction set, de- scribes general standards and conventions, and defines the operand types and addressing modes supported by the MCS® 96 microcontroller family. (For additional information about the instruc- tion set, see Appendix A.)
Chapter 5 — Memory Partitions — describes the addressable memory space of the device. It describes the memory partitions, explains how to use windows to increase the amount of memory that can be accessed with direct addressing, and provides examples of memory configurations.
Chapter 6 — Standard and PTS Interrupts — describes the interrupt control circuitry, priority scheme, and timing for standard and peripheral transaction server (PTS) interrupts. It also ex- plains interrupt programming and control.
Chapter 7 — I/O Ports — describes the input/output ports and explains how to configure the ports for input, output, or special functions.

Chapter 8 — Serial I/O (SIO) Port — describes the asynchronous/synchronous serial I/O (SIO) port and explains how to program it.
Chapter 9 —Pulse-width Modulator — provides a functional overview of the pulse width mod- ulator (PWM) modules, describes how to program them, and provides sample circuitry for con- verting the PWM outputs to analog signals.
Chapter 10 — Event Processor Array (EPA) — describes the event processor array, a tim- er/counter-based, high-speed input/output unit. It describes the timer/counters and explains how to program the EPA and how to use the EPA to produce pulse-width modulated (PWM) outputs.
Chapter 11 — Minimum Hardware Considerations — describes options for providing the ba- sic requirements for device operation within a system, discusses other hardware considerations, and describes device reset options.
Chapter 12 — Special Operating Modes — provides an overview of the idle, powerdown, standby, and on-circuit emulation (ONCE) modes and describes how to enter and exit each mode.
Chapter 13 — Interfacing with External Memory — lists the external memory signals and de- scribes the registers that control the external memory interface. It discusses the chip selects, mul- tiplexed and demultiplexed bus modes, bus width and memory configurations, the bus-hold protocol, write-control modes, and internal wait states and ready control. Finally, it provides tim- ing information for the system bus.
Appendix A — Instruction Set Reference — provides reference information for the instruction set. It describes each instruction; defines the processor status word (PSW) flags; shows the rela- tionships between instructions and PSW flags; and lists hexadecimal opcodes, instruction lengths, and execution times. (For additional information about the instruction set, see Chapter 4, “Programming Considerations.”)
Appendix B — Signal Descriptions — provides reference information for the device pins, in- cluding descriptions of the pin functions, reset status of the I/O and control pins, and package pin assignments.
Appendix C — Registers — provides a compilation of all device special-function registers (SFRs) arranged alphabetically by register mnemonic. It also includes tables that list the win- dowed direct addresses for all SFRs in each possible window.
Glossary — defines terms with special meaning used throughout this manual.
Index — lists key topics with page number references.

1.2 NOTATIONAL CONVENTIONS AND TERMINOLOGY
The following notations and terminology 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 with 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.
addresses In this manual, both internal and external addresses use the number of hexadecimal digits that correspond with the number of available address lines. For example, the highest possible internal address is shown as FFFFFFH, while the highest possible external address is shown as FFFFFH. When writing code, use the appropriate address conventions for the software tool you are using. (In general, assemblers require a zero preceding an alphabetic hexadecimal character and an “H” following any hexadecimal value, so FFFFFFH must be written as 0FFFFFFH. ANSI ‘C’ compilers require a zero plus an “x” preceding a hexadecimal value, so FFFFFFH must be written as 0xFFFFFF.) Consult the manual for your assembler or compiler to determine its specific requirements.
assert and deassert The 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 set The terms clear and set refer to the value of a bit or the act of giving it a value. If a bit is clear, its value is “0”; clearing a bit gives it a “0” value. If a bit is set, its value is “1”; setting a bit gives it a “1” value.
f Lowercase “f” represents the internal operating frequency. See “Internal Timing” on page 2-7 for details.
instructions Instruction mnemonics are shown in upper case to avoid confusion. In general, you may use either upper case or lower case when programming. Consult the manual for your assembler or compiler to determine its specific requirements.

italics Italics identify variables and introduce new terminology. The context in which italics are used distinguishes between the two possible meanings.
Variables in registers and signal names are commonly represented by x and y, where x represents the first variable and y represents the second variable. For example, in register Px_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). Variables must be replaced with the correct values when configuring or programming registers or identifying signals.
numbers Hexadecimal numbers are represented by a string of hexadecimal digits followed by the character H. Decimal and binary numbers are represented by their customary 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 bits Bit 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 discussions, bit names are used.
register names Register 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 indicates that the register name refers to any of the port data registers.
reserved bits Certain bits are described as reserved bits. In illustrations, 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 imple- mentations, reserved bits should be cleared (given a value of “0”) or left in their default states, unless otherwise noted. Do not rely on the values of reserved bits; consider them undefined.
signal names Signal 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 represented by the port abbre- viation, a period, and the pin number (e.g., P1.0, P1.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.

t Lowercase “t” represents the internal operating period. See “Internal Timing” on page 2-7 for details.
units of measure The following abbreviations are used to represent units of measure:
A amps, amperes DCV direct current volts Kbytes kilobytes kHz kilohertz kΩ kilo-ohms mA milliamps, milliamperes Mbytes megabytes MHz megahertz ms milliseconds mW milliwatts ns nanoseconds pF picofarads W watts V volts µA microamps, microamperes µF microfarads µs microseconds µW microwatts
X Uppercase X (no italics) represents an unknown value or an irrelevant (“don’t care”) state or condition. The value may be either binary or hexadecimal, depending on the context. For example, 2XAFH (hex) indicates that bits 11:8 are unknown; 10XXB (binary) indicates that the two least-significant bits are unknown.
The tables in this section list additional documents that you may find useful in designing systems incorporating MCS 96 microcontrollers. These are not comprehensive lists, but are a representa- tive sample of relevant documents. For a complete list of available printed documents, please or- der the literature catalog (order number 210621). To order documents, please call the Intel literature center for your area (telephone numbers are listed on page 1-11).
Intel’s ApBUILDER software, hypertext manuals and datasheets, and electronic versions of ap- plication notes and code examples are also available from the BBS (see “Bulletin Board System (BBS)” on page 1-9). New information is available first from FaxBack and the BBS. Refer to “Electronic Support Systems” on page 1-8 for details.

Title and Description Order Number
Intel Embedded Quick Reference Guide 272439
Solutions for Embedded Applications Guide 240691
Data on Demand fact sheet 240952
Data on Demand annual subscription (6 issues; Windows* version)
Complete set of Intel handbooks on CD-ROM.
Handbook Set — handbooks and product overview
Complete set of Intel’s product line handbooks. Contains datasheets, application notes, article reprints and other design information on microprocessors, periph- erals, embedded controllers, memory components, single-board computers, microcommunications, software development tools, and operating systems.
Application notes and article reprints on topics including the MCS 51 and MCS 96 microcontrollers. Documents in this handbook discuss hardware and software implementations and present helpful design techniques.
Embedded Applications handbook (2 volume set) †
Datasheets, architecture descriptions, and application notes on topics including flash memory devices, networking chips, and MCS 51 and MCS 96 microcon- trollers. Documents in this handbook discuss hardware and software implementa- tions and present helpful design techniques.
Datasheets and architecture descriptions for Intel’s three industry-standard micro- controllers, the MCS 48, MCS 51, and MCS 96 microcontrollers.
Comprehensive information on Intel’s peripheral components, including datasheets, application notes, and technical briefs.
Flash Memory (2 volume set) †
A collection of datasheets and application notes devoted to techniques and information to help design semiconductor memory into an application or system.
Detailed information on the manufacturing, applications, and attributes of a variety of semiconductor packages.
Information on third-party hardware and software tools that support Intel’s embedded microcontrollers.
† Included in handbook set (order number 231003)
AB-71, Using the SIO on the 8XC196MH (application brief) 272594
AP-125, Design Microcontroller Systems for Electrically Noisy Environments ††† 210313
AP-155, Oscillators for Microcontrollers ††† 230659
AR-375, Motor Controllers Take the Single-Chip Route (article reprint) 270056
AP-406, MCS® 96 Analog Acquisition Primer ††† 270365
† Included in Automotive Products handbook (order number 231792) †† Included in Embedded Applications handbook (order number 270648) ††† Included in Automotive Products and Embedded Applications handbooks

Table 1-2. Application Notes, Application Briefs, and Article Reprints (Continued)
AP-449, A Comparison of the Event Processor Array (EPA) and High Speed
Input/Output (HSIO) Unit †
AP-475, Using the 8XC196NT †† 272315
AP-477, Low Voltage Embedded Design †† 272324
AP-483, Application Examples Using the 8XC196MC/MD Microcontroller 272282
AP-700, Intel Fuzzy Logic Tool Simplifies ABS Design † 272595
AP-711, EMI Design Techniques for Microcontrollers in Automotive Applications 272324
AP-715, Interfacing an I2C Serial EEPROM to an MCS® 96 Microcontroller 272680
† Included in Automotive Products handbook (order number 231792) †† Included in Embedded Applications handbook (order number 270648) ††† Included in Automotive Products and Embedded Applications handbooks
8XC196KR/KQ/JR/JQ Commercial/Express CHMOS Microcontroller † 270912
8XC196KT Commercial CHMOS Microcontroller † 272266
87C196KT/87C196KS 20 MHz Advanced 16-Bit CHMOS Microcontroller † 272513
8XC196MC Industrial Motor Control Microcontroller † 272323
87C196MD Industrial Motor Control CHMOS Microcontroller † 270946
8XC196NP Commercial CHMOS 16-Bit Microcontroller † 272459
8XC196NT CHMOS Microcontroller with 1-Mbyte Linear Address Space † 272267
80C196NU Commercial CHMOS 16-Bit Microcontroller 272644
† Included in Embedded Microcontrollers handbook (order number 270646)
Title and Description Order Number
87C196CA/87C196CB 20 MHz Advanced 16-Bit CHMOS Microcontroller with Integrated CAN 2.0 †
87C196JT 20 MHz Advanced 16-Bit CHMOS Microcontroller † 272529
87C196JV 20 MHz Advanced 16-Bit CHMOS Microcontroller † 272580
87C196KR/KQ, 87C196JV/JT, 87C196JR/JQ Advanced 16-Bit CHMOS Microcontroller †
87C196KT/87C196KS Advanced 16-Bit CHMOS Microcontroller † 270999
87C196KT/KS 20 MHz Advanced 16-Bit CHMOS Microcontroller † 272513
† Included in Automotive Products handbook (order number 231792)
Title Order Number · Title Order Number

Title and Description Order Number
8XC196KR Quick Reference (includes the JQ, JR, KQ, KR) 272113
8XC196KT Quick Reference 272269
8XC196MC Quick Reference 272114
8XC196NP Quick Reference 272466
8XC196NT Quick Reference 272270

Page Intentionally Left Blank


1.4.4 World Wide Web
We offer a variety of information through the World Wide Web (URL:http://www.intel.com/). Se- lect “Embedded Design Products” from the Intel home page.
In the U.S. and Canada, technical support representatives are available 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 by phone or by fax). Outside the U.S. and Canada, please contact your local distributor.
1-800-628-8686 U.S. and Canada 916-356-7599 U.S. and Canada 916-356-6100 (fax) U.S. and Canada
You can order product literature from the following Intel literature centers.
1-800-468-8118, ext. 283 U.S. and Canada 708-296-9333 U.S. (from overseas) 44(0)1793-431155 Europe (U.K.) 44(0)1793-421333 Germany 44(0)1793-421777 France 81(0)120-47-88-32 Japan (fax only)






The 16-bit 8XC196NP and 80C196NU CHMOS microcontrollers are designed to handle high- speed calculations and fast input/output (I/O) operations. They share a common architecture and instruction set with other members of the MCS® 96 microcontroller family. In addition to their 16-bit address/data buses, both microcontrollers have extended addressing ports consisting of 4 external address pins, for a total of 20 address pins. With 20 address pins, these microcontrollers can access up to 1 Mbyte of linear address space. Both devices also have chip-select units that provide a glueless interface to external memory devices. The extended addressing port and chip- select unit enable these microcontrollers to handle larger, more complex programs and to access more external memory at a faster rate than could earlier MCS 96 microcontrollers.
The 8XC196NP and 80C196NU are pin-compatible and have identical cores. However, the 80C196NU can operate at twice the frequency of the 8XC196NP. The 80C196NU also employs an accumulator and enhanced multiplication instructions to support multiply-accumulate opera- tions. The 80C196NU is the first MCS 96 microcontroller with this capability. This chapter pro- vides a high-level overview of the architecture.
MCS 96 microcontrollers are typically used for high-speed event control systems. Commercial applications include modems, motor-control systems, printers, photocopiers, air conditioner con- trol systems, disk drives, and medical instruments. Automotive customers use MCS 96 microcon- trollers in engine-control systems, airbags, suspension systems, and antilock braking systems (ABS).

Table 2-1 lists the features of the 8XC196NP and 80C196NU.
Device Pins ROM (Note 1)
I/O Pins (Note 3)
8XC196NP 100 4 K 1024 64 4 1 3 6 4
80C196NU 100 0 1024 64 4 1 3 6 4
NOTES: 1. Nonvolatile memory is optional for the 8XC196NP, but is not available for the 80C196NU. The second character of the device name indicates the presence and type of nonvolatile memory. 80C196NP = none; 83C196NP = ROM. 2. Register RAM amounts include the 24 bytes allocated to core special-function registers (SFRs) and the stack pointer. 3. I/O pins include address, data, and bus control pins and 32 I/O port pins.
Figure 2-1 shows the major blocks within the device. The core of the device (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). The CPU connects to both the memory controller and an interrupt controller via a 16-bit internal bus. An extension of this bus connects the CPU to the internal peripheral modules. In addition, an 8-bit internal bus transfers instruction bytes from the memory controller to the instruction register in the RALU.
Clock and Power Mgmt.
PWM SIO I/O EPA
Figure 2-1. 8XC196NP and 80C196NU Block Diagram

CPU
RALU
ALU
RAM
PSW
Figure 2-2. Block Diagram of the Core
2.3.1 CPU 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 5, “Memory Partitions,” for more information about the register file and windowing.) CPU instructions move from the 4-byte (for the 8XC196NP) or 8-byte (for the 80C196NU) prefetch queue in the memory controller into the RALU’s instruction register. The microcode engine decodes the instructions and then generates the sequence of events that cause desired functions to occur.
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 contains 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 4-6). The upper reg- ister file is accessible with direct addressing only when windowing is enabled. Windowing is a technique that maps blocks of the upper register file into a window in the lower register file. See Chapter 5, “Memory Partitions,” for more information about the register file and windowing.

The RALU contains the microcode engine, the 16-bit arithmetic logic unit (ALU), the master pro- gram counter (PC), the processor status word (PSW), and several registers. The registers in the RALU are the instruction 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 24-bit master program counter (PC) provides a linear, nonsegmented 16-Mbyte memory space. Only 20 of the address lines are implemented with external pins, so you can physically ad- dress only 1 Mbyte. (For compatibility with earlier devices, the PC can be configured as 16 bits wide.) The master PC contains the address of the next instruction and has a built-in incrementer that automatically loads the next sequential address. However, if a jump, interrupt, call, or return changes the address sequence, the ALU loads the appropriate address into the master PC.
The PSW contains one bit (PSW.1) that globally enables or disables servicing of all maskable in- terrupts, 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 Reference,” provides a detailed description 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 registers can reduce the ALU’s workload by per- forming simple operations.
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 normalize, multiply, and divide operations. The six-bit loop counter counts repetitive shifts. The second-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 com- plemented 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 complementing, incrementing, or decrementing bytes or words. In addition, the constants register generates single-bit masks, based on the bit-select reg- ister, for bit-test instructions.
The RALU performs most calculations for the device, but it does not use an accumulator. Instead it operates directly on the lower register file, which essentially provides 256 accumulators. Be- cause data does not flow through a single accumulator, the device’s code executes faster and more efficiently.

2.3.3.2 Instruction Format
MCS 96 microcontrollers combine a large set of general-purpose registers with a three-operand instruction format. This format allows a single instruction to specify two source registers and a separate destination register. For example, the following instruction multiplies two 16-bit vari- ables 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 device requires four instructions to accomplish the same operation. The following ex- ample shows the equivalent code for an 80C186 device.
MOV AX, FACTOR_1 ;move FACTOR_1 into accumulator (AX) ;(AX)←FACTOR1 MUL FACTOR_2 ;multiply FACTOR_2 and AX ;(DX:AX)←(AX)×(FACTOR_2) MOV RESULT, AX ;move lower byte into RESULT ;(RESULT)←(AX) MOV RESULT+2, DX ;move upper byte into RESULT+2 ;(RESULT+2)←(DX)
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 control- ler except when windowing is used; see Chapter 5, “Memory Partitions,”) The memory controller contains the prefetch queue, the slave program counter (slave PC), address and data registers, and the bus controller.
The bus controller drives the memory bus, which consists of an internal memory bus and the ex- ternal 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.
When the bus controller receives a request from the queue, it fetches the code from the address contained in the slave PC. The slave PC increases execution speed because the next instruction byte is available immediately and the processor need not wait for the master PC to send the ad- dress 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 con- tinues processing.

The extended program counter (EPC) is an extension of the slave PC. The EPC generates the up- per eight address bits for extended code fetches and outputs them on the extended addressing port (EPORT). Because only four EPORT pins are implemented, only the lower four address bits are available. (See Chapter 5, “Memory Partitions,” for additional information.)
The memory controller includes a chip-select unit with six chip-select outputs for selecting an ex- ternal device during an external bus cycle. During an external memory access, a chip-select out- put is asserted if the address falls within the address range assigned to that chip-select. The bus width, the number of wait states, and multiplexed or demultiplexed address/data lines are pro- grammed independently for the six chip-selects. The address range of the chip-selects can be pro- grammed for various granularities: 256 bytes, 512 bytes, … 512 Kbytes, or 1 Mbyte. The base address can be any address that is evenly divisible by the selected address range. See Chapter 13, “Interfacing with External Memory,” for more information.
The 80C196NU is able to process multiply-accumulate operations through the use of a hardware accumulator and enhanced multiplication instructions. The accumulator includes a 16-bit adder, a 3-to-1 multiplexer, a 32-bit accumulator register, and a control register. The multiply-accumu- late function is enabled by any 16-bit multiplication instruction with a destination address that is in the range 00–0FH. The instructions can operate on signed integers, unsigned integers, and signed fractional numbers. The control register allows you to enable saturation mode and frac- tional mode for signed multiplication. Chapter 3, “Advanced Math Features,” describes the accu- mulator.
The device’s flexible interrupt-handling system has two main components: the programmable in- terrupt controller and the peripheral transaction server (PTS). The programmable interrupt con- troller has a hardware priority scheme that can be modified by your software. Interrupts that go through the interrupt controller are serviced by interrupt service routines that you provide. The peripheral transaction server (PTS), a microcoded hardware interrupt processor, provides high- speed, low-overhead interrupt handling. You can configure most interrupts (except NMI, trap, and unimplemented opcode) to be serviced by the PTS instead of the interrupt controller.
The PTS can transfer bytes or words, either individually or in blocks, between any memory loca- tions and can generate pulse-width modulated (PWM) signals. PTS interrupts have a higher pri- ority than standard interrupts and may temporarily suspend interrupt service routines. See Chapter 6, “Standard and PTS Interrupts,” for more information.

2.4 INTERNAL TIMING
The clock circuitry of the 8XC196NP (Figure 2-3) is identical to that of earlier MCS 96 micro- controllers. It receives an input clock signal on XTAL1 provided by an external crystal or clock and divides the frequency by two. The clock generators 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.
XTAL1
XTAL2
Peripheral Clocks (PH1, PH2)
CPU Clocks (PH1, PH2)
Disable Clocks (Idle, Powerdown)
The 80C196NU’s clock circuitry (Figure 2-4) implements phase-locked loop and clock multiplier circuitry, which can substantially increase the CPU clock rate while using a lower-frequency in- put clock. The clock circuitry accepts an input clock signal on XTAL1 provided by an external crystal or oscillator. Depending on the values of the PLLEN1 and PLLEN2 pins, this frequency is routed either through the phase-locked loop and multiplier or directly to the divide-by-two cir- cuit. The multiplier circuitry can double or quadruple the input frequency (FXTAL1) before the fre- quency (f) reaches the divide-by-two circuitry. The clock generators accept the divided input frequency (f/2) from the divide-by-two circuit and produce two nonoverlapping internal timing signals, PH1 and PH2. These signals are active when high.
NOTE For brevity, this manual uses lowercase “f” to represent the internal clock frequency of both the 8XC196NP and the 80C196NU. For the 8XC196NP, f is equal to FXTAL1. For the 80C196NU, f is equal to either FXTAL1, 2FXTAL1, or 4FXTAL1, depending on the clock multiplier mode, which is controlled by the PLLEN1 and PLLEN2 input pins.

XTAL1
F XTAL1
2F XTAL1 4F XTAL1
XTAL2
Disable Clocks (Standby, Powerdown)
PLLEN2
Peripheral Clocks (PH1, PH2)
CPU Clocks (PH1, PH2)
Disable Clocks (Idle, Standby, Powerdown)
For both the 8XC196NP and 80C196NU, the rising edges of PH1 and PH2 generate CLKOUT (Figure 2-5). The clock circuitry routes separate internal clock signals to the CPU and the periph- erals to provide flexibility in power management. (“Reducing Power Consumption” on page 12-3 describes the power management modes.) It also outputs the CLKOUT signal on the CLKOUT pin. Because of the complex logic in the clock circuitry, the signal on the CLKOUT pin is a de- layed version of the internal CLKOUT signal. This delay varies with temperature and voltage.

XTAL1
PH1
PH2
CLKOUT
Phase 1 Phase 2
Phase 1 Phase 2
The combined period of phase 1 and phase 2 of the internal CLKOUT signal defines the basic time unit known as a state time or state. Table 2-2 lists state time durations at various frequencies.
f (Frequency Input to the
12.5 MHz 160 ns
25 MHz 80 ns
50 MHz 40 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).
PH1 (in MHz) f
2 -- PH2 = = State Time (in µs) 2
f -- = t 1
Because the device can operate at many frequencies, this manual defines time requirements (such as instruction execution times) in terms of state times rather than specific measurements. Datasheets list AC characteristics in terms of clock periods (t).
For the 80C196NU, Table 2-3 details the relationships between the input frequency (FXTAL1), the configuration of PLLEN1 and PLLEN2, the operating frequency (f), the clock period (t), and state times. Figure 2-6 illustrates the timing relationships between the input frequency (FXTAL1), the operating frequency (f), and the CLKOUT signal with each of the three valid PLLENx pin configurations. (Since the maximum operating frequency is 50 MHz, only a 12.5 MHz external clock frequency allows all three clock modes.)

FXTAL1 (Frequency
f (Input Frequency to the Divide-by-two Circuit)
PLLEN2:1 Multiplier
50 MHz † 00 1 50 MHz 20 ns 40 ns
25 MHz 00 1 25 MHz 40 ns 80 ns
10 2 50 MHz 20 ns 40 ns
00 1 12.5 MHz 80 ns 160 ns
12.5 MHz
10 2 25 MHz 40 ns 80 ns
11 4 50 MHz 20 ns 40 ns
† Assumes an external clock. The maximum frequency for an external crystal oscillator is 25 MHz.
XTAL1 (12.5 MHz)
f PLLEN2:1=00
f PLLEN2:1=10
f PLLEN2:1=11
Figure 2-6. Effect of Clock Mode on CLKOUT Frequency

2.5 INTERNAL PERIPHERALS
The internal peripheral modules provide special functions for a variety of applications. This sec- tion provides a brief description of the peripherals; subsequent chapters describe them in detail.
The 8XC196NP and 80C196NU have five I/O ports, ports 1–4 and the EPORT. Individual port pins are multiplexed to serve as standard I/O or to carry special-function signals associated with an on-chip peripheral or an off-chip component. If a particular special-function signal is not used in an application, the associated pin can be individually configured to serve as a standard I/O pin. Port 4 has a higher drive capability than the other ports to support pulse-width modulator (PWM) high-drive outputs.
Ports 1–4 are eight-bit, bidirectional, standard I/O ports. Only the lower nibble of port 4 is imple- mented in current package offerings. Port 1 provides I/O pins for the four event processor array (EPA) modules and the two timers. Port 2 is used for the serial I/O (SIO) port, two external inter- rupts, and bus hold functions. Port 3 is used for chip-select functions and two external interrupts. Port 4 (functionally only a 4-bit port) provides I/O pins associated with the three on-chip pulse- width modulators. The EPORT provides address lines A19:16 to support extended addressing. See Chapter 7, “I/O Ports,” for more information.
The serial I/O (SIO) port is an asynchronous/synchronous port that includes a universal asynchro- nous receiver and transmitter (UART). The UART has one synchronous mode (mode 0) and three asynchronous modes (modes 1, 2, and 3) for both transmission and reception. The asynchronous modes are full duplex, meaning that they can transmit and receive data simultaneously. The re- ceiver 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. See Chapter 8, “Serial I/O (SIO) Port,” for details.
The event processor array (EPA) performs high-speed input and output functions associated with its timer/counters. In the input mode, the EPA monitors an input for signal transitions. When an event occurs, the EPA records the timer value associated with it. This is a capture event. In the output mode, the EPA monitors a timer until its value matches that of a stored time value. When a match occurs, the EPA triggers an output event, which can set, clear, or toggle an output pin. This is a compare event. Both capture and compare events can initiate interrupts, which can be serviced by either the interrupt controller or the PTS.

Timer 1 and timer 2 are both 16-bit up/down timer/counters that can be clocked internally or ex- ternally. Each timer/counter is called a timer if it is clocked internally and a counter if it is clocked externally. See Chapter 10, “Event Processor Array (EPA),” for additional information on the EPA and timer/counters.
The output waveform from each PWM channel is a variable duty-cycle pulse with a programma- ble frequency that occurs every 256 or 512 state times (for the 8XC196NP) or every 256, 512, or 1024 state times (for the 80C196NU), as programmed. Several types of motors require a PWM waveform for most efficient operation. When filtered, the PWM waveform produces a DC level that can change in 256 steps by varying the duty cycle. See Chapter 9, “Pulse-width Modulator,” for more information.
In addition to the normal execution mode, the device operates in several special-purpose modes. Idle and powerdown modes conserve power when the device is inactive. An additional power conservation mode, standby, is available on the 80C196NU. On-circuit emulation (ONCE) mode electrically isolates the microcontroller from the system. See Chapter 12, “Special Operating Modes,” for more information about idle, powerdown, standby, and ONCE modes.
The power saving modes selectively disable internal clocks to reduce power consumption. Figure 2-3 on page 2-7 and Figure 2-4 on page 2-8 illustrate the clock circuitry of the 8XC196NP and 80C196NU, respectively.
In idle mode, the CPU stops executing instructions, but the peripheral clocks remain active. Pow- er consumption drops to about 40% of normal execution mode consumption. Either a hardware reset or any enabled interrupt source will bring the device out of idle mode.
The 80C196NU has an additional power saving mode, standby. In standby mode, all internal clocks are frozen at logic state zero, but the oscillator and phase-locked loop continue to run. Power consumption drops to about 10% of normal execution mode consumption. Either a hard- ware reset or any enabled external interrupt source will bring the device out of standby mode.
In powerdown mode, all internal clocks are frozen at logic state zero and the oscillator is shut off. The register file and most peripherals retain their data if VCC is maintained. Power consumption drops into the µW range.

2.6.2 Testing the Printed Circuit Board
The on-circuit emulation (ONCE) mode electrically isolates the 8XC196 device from the system. By invoking ONCE mode, you can test the printed circuit board while the device is soldered onto the board.
This section summarizes differences to consider when converting your design requirements from the 80C196NP to the 80C196NU.
— the 80C196NU has PLLEN1 in place of a no-connection pin of the 80C196NP
— the 80C196NU has PLLEN2 in place of a VSS pin of the 80C196NP
— the 80C196NU has a VCC pin in place of a no-connection pin of the 80C196NP





The 80C196NU is the first member of the MCS® 96 microcontroller family to incorporate en- hanced 16-bit multiplication instructions for performing multiply-accumulate operations and a dedicated, 32-bit accumulator register for storing the results of these operations. The accumulator and the enhanced instructions combine to decrease the amount of time required to perform mul- tiply-accumulate operations. The instructions and accumulator support signed and unsigned inte- gers as well as signed fractional data. This chapter describes the 80C196NU’s advanced mathematical features.
The 16-bit multiplication instructions, MULU and MUL, that exist for all MCS 96 microcontrol- lers have been enhanced for the 80C196NU. The MULU instruction supports unsigned integers, while the MUL instruction supports signed integers and signed fractionals.
When you execute a 16-bit multiplication instruction with a destination address that is 0FH or below, the 80C196NU automatically stores the result in the accumulator. If bit 3 of the destination address is set (address 08H, 09H, …, 0FH), the 80C196NU clears the accumulator before it stores the result of the current instruction. If bit 3 of the destination address is clear (address 00H, 01H, …, 07H), it adds the result of the current instruction to the existing contents of the accumulator.
This simple example illustrates the results of consecutive multiply-accumulate instructions. The results of the first three instructions are automatically added together in the accumulator, while the last instruction clears the accumulator before the result is stored.
register_1 = 10 decimal (0AH),register_2 = 20 decimal (14H) register_3 = 30 decimal (1EH),register_4 = 40 decimal (28H)
mul 00H,register_1,register_2 ;10×20= 200. Accumulator = 200 decimal. mul 00H,register_3,register_4 ;30×40=1200. Accumulator =1400 decimal. mul 00H,register_2,register_4 ;20×40= 800. Accumulator =2200 decimal. mul 08H,register_2,register_3 ;20×30= 600. Accumulator = 600 decimal.
Table 3-1 compares the instructions required to perform a multiply-accumulate operation for the 8XC196NP and those required for the 80C196NU. The 8XC196NP requires four instructions, while the 80C196NU requires only one to accomplish the same operation. The four 8XC196NP instructions take a total of 32 state times to execute, while the single 80C196NU instruction takes only 16 state times. In addition, the 80C196NU can operate at twice the frequency of the 8XC196NP; therefore, a state time for the 80C196NU is half that of the 8XC196NP. These two factors combine to make the 80C196NU code execute in one-fourth the time required for the 8XC196NP code.

Device Instructions Execution Time
8XC196NP (25 MHz; 1 state time = 80 ns)
80C196NU (50 MHz; 1 state time = 40 ns)
mul 08H,operand_2,operand_1† 16 states
† Because bit 3 of the destination address (08H) is set, the 80C196NU clears the accumulator before adding the result of the current instruction to it. If bit 3 were clear (destination address 07H–00H), the 80C196NU would add the result of the current instruction to the existing value of the accumulator.
The accumulator has two operating modes that allow you to control the results of operations on signed numbers. These modes are called saturation mode and fractional mode.
Saturation occurs when the result of two positive numbers generates a negative sign bit or the re- sult of two negative numbers generates a positive sign bit. Without saturation mode, an underflow or overflow occurs and the overflow (OVF) flag is set. Saturation mode prevents an underflow or overflow of the accumulated value. In saturation mode, the accumulator’s value is changed to 7FFFFFFFH for a positive saturation or 80000000H for a negative saturation and the sticky sat- uration (STSAT) flag is set. The following two examples illustrate the contents of the accumulator as a result of positive and negative saturation, respectively:
7FFFFFFFH = 0111 1111 = 231 – 1 = +2147483647
80000000H = 1000 0000 = –2147483648

3.2.2 Fractional Mode
A signed fractional contains an imaginary decimal point between the sign bit (the MSB) and the adjacent bit. These examples illustrate the representation of 32-bit signed fractional numbers:
2147483647 2147483648 1 = =
0.111 1111
0.000 0000 = 0
1.111 1111 =
1.000 0000 = –1
Fractional mode shifts the result of a multiplication instruction left by one bit before writing the result to the accumulator. This left shift eliminates the extra sign bit when both operands are signed, leaving a correctly signed result and the correct decimal placement.

The 32-bit accumulator register (Figure 3-1) resides at locations 0C–0FH. Read from or write to the accumulator register as two words at locations 0CH and 0EH.
ACC_0x x = 0, 2 (80C196NU)
The 32-bit accumulator register (ACC_0x) resides at locations 0C–0FH. You can read from or write to the accumulator register as two words at locations 0CH and 0EH.
Accumulator Value (word 1, high byte)
ACC_02 Accumulator Value (word 1, low byte)
Accumulator Value (word 0, high byte)
ACC_00 Accumulator Value (word 0, low byte)
15:0 Accumulator Value
You can read this register to determine the current value of the accumulator. You can write to this register to clear or preload a value into the accumulator.
Bit Number Function

3.4 ACCUMULATOR CONTROL AND STATUS REGISTER (ACC_STAT)
The ACC_STAT register controls the operating mode and reflects the status of the accumulator. The mode bits (FME and SME) are effective only for signed multiplication. Table 3-2 describes the 80C196NU’s operation with each of the four possible configurations of these bits.
The accumulator control and status (ACC_STAT) register enables and disables fractional and saturation modes and contains three status flags that indicate the status of the accumulator’s contents.
80C196NU FME SME — — — STOVF OVF STSAT
7 FME Fractional Mode Enable
Set this bit to enable fractional mode. (See Table 3-2.) In this mode, the result of a signed multiplication instruction is shifted left by one bit before it is added to the contents of the accumulator.
For unsigned multiplication, this bit is ignored.
6 SME Saturation Mode Enable
Set this bit to enable saturation mode. (See Table 3-2.) In this mode, the result of a signed multiplication operation is not allowed to overflow or underflow.
For unsigned multiplication, this bit is ignored.
5:3 — Reserved; for compatibility with future devices, write zeros to these bits.
2 STOVF Sticky Overflow Flag
For unsigned multiplication, this bit is set if a carry out of bit 31 occurs.
Unless saturation mode is enabled, this bit is set for signed multiplication to indicate that the sign bit of the accumulator and the sign bit of the addend are equal, but the sign bit of the result is the opposite. (See Table 3-2.)
Software can clear this flag; hardware does not clear it.
1 OVF Overflow Flag
This bit indicates that an overflow occurred during the preceding accumu- lation. (See Table 3-2.)
This flag is dynamic; it can change after each accumulation.
0 STSAT Sticky Saturation Flag
This bit indicates that a saturation has occurred during accumulation with saturation mode enabled. (See Table 3-2.)
Software can clear this flag; hardware does not clear it.
Bit Number · Bit Mnemonic Function

0 0 Sets the OVF and STOVF flags if the sign bits of the accumulator and the addend (the number to be added to the contents of the accumulator) are equal, but the sign bit of the result is the opposite.
0 1 Shifts the addend (the number to be added to the contents of the accumulator) left by one bit before adding it to the accumulator. Sets the OVF and STOVF flags if the sign bits of the accumulator and the addend are equal, but the sign bit of the result is the opposite.
1 0 Accumulates a signed integer value up or down to saturation and sets the STSAT flag. Positive saturation changes the accumulator value to 7FFFFFFFH; negative saturation changes the accumulator value to 80000000H. Accumulation proceeds normally after saturation, which means that the accumulator value can increase from a negative saturation or decrease from a positive saturation.
1 1 Shifts the addend (the number to be added to the contents of the accumulator) left by one bit before adding it to the accumulator. Accumulates a signed integer value up or down to saturation and sets the STSAT flag. Positive saturation changes the accumulator value to 7FFFFFFFH; negative saturation changes the accumulator value to 80000000H. Accumu- lation proceeds normally after saturation, which means that the accumulator value can increase from a negative saturation or decrease from a positive saturation.
SME FME Description




This section provides an overview of the instruction set of the MCS® 96 microcontrollers and of- fers guidelines for program development. For detailed information about specific instructions, see Appendix A.
The instruction set supports a variety of operand types likely to be useful in control applications (see Table 4-1).
Operand Type No. of
Bits Signed Possible Values Addressing Restrictions
BIT 1 No True (1) or False (0) As components of bytes
BYTE 8 No 0 through 28–1 (0 through 255) None
SHORT-INTEGER 8 Yes –27 through +27–1 (–128 through +127)
WORD 16 No 0 through 216–1 (0 through 65,535)
INTEGER 16 Yes –215 through +215–1 (–32,768 through +32,767)
32 No 0 through 232–1 (0 through 4,294,967,295)
An address in the lower register file that is evenly divisible by four (Note 2)
32 Yes –231 through +231–1 (–2,147,483,648 through +2,147,483,647)
An address in the lower register file that is evenly divisible by four (Note 2)
64 No 0 through 264–1 An address in the lower register file that is evenly divisible by eight
NOTES: 1. The 32-bit variables are supported 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. 2. For consistency with third-party software, you should adopt the C programming conventions for addressing 32-bit operands. For more information, refer to page 4-11. 3. QUAD-WORD variables are supported only as the operand for the EBMOVI instruction.

Table 4-2 lists the equivalent operand-type names for both C programming and assembly lan- guage.
Operand Types Assembly Language Equivalent C Programming Language Equivalent
BYTE BYTE unsigned char
WORD WORD unsigned int
DOUBLE-WORD LONG unsigned long
4.1.1 BIT Operands
A BIT is a single-bit variable that can have the Boolean values, “true” and “false.” The architec- ture requires that BITs be addressed as components of BYTEs or WORDs. It does not support the direct addressing of BITs.
A BYTE is an unsigned, 8-bit variable that can take on values from 0 through 255 (28–1). Arith- metic and relational operators can be applied to BYTE operands, but the result must be interpret- ed in modulo 256 arithmetic. Logical operations on BYTEs are applied bitwise. Bits within BYTEs are labeled from 0 to 7; bit 0 is the least-significant bit. There are no alignment restric- tions for BYTEs, so they may be placed anywhere in the address space.
A SHORT-INTEGER is an 8-bit, signed variable that can take on values from –128 (–27) through +127 (+27–1). Arithmetic operations that generate results outside the range of a SHORT-INTE- GER 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.
SHORT-INTEGER BYTE char · INTEGER WORD int · LONG-INTEGER LONG long

4.1.4 WORD Operands
A WORD is an unsigned, 16-bit variable that can take on values from 0 through 65,535 (216–1). Arithmetic and relational operators can be applied to WORD operands, but the result must be in- terpreted in modulo 65536 arithmetic. Logical operations on WORDs are applied bitwise. Bits within WORDs are labeled from 0 to 15; bit 0 is the least-significant bit.
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.
An INTEGER is a 16-bit, signed variable that can take on values from –32,768 (–215) through +32,767 (+215–1). Arithmetic operations that generate results outside the range of an 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 WORD variables.
INTEGERs must be aligned at even byte boundaries in the address space. The least-significant byte of the INTEGER is in the even byte address, and the most-significant byte is in the next high- er (odd) address. The address of an INTEGER is that of its least-significant byte (the even byte address). INTEGER operations to odd addresses are not guaranteed to operate in a consistent manner.
A DOUBLE-WORD is an unsigned, 32-bit variable that can take on values from 0 through 4,294,967,295 (232–1). The architecture directly supports DOUBLE-WORD operands 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 operations, a DOUBLE-WORD variable must reside in the lower register file and must be aligned at an address that is evenly divisible by four. The address of a DOUBLE-WORD is that of its least-significant byte (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 easily implemented with two WORD operations. For example, the following sequences of 16-bit operations perform a 32-bit addition and a 32-bit subtraction, respectively.
ADD REG1,REG3 ; (2-operand addition) ADDC REG2,REG4
SUB REG1,REG3 ; (2-operand subtraction) SUBC REG2,REG4

A LONG-INTEGER is a 32-bit, signed variable that can take on values from –2,147,483,648 (– 231) through +2,147,483,647 (+231–1). The architecture directly supports LONG-INTEGER operands 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 operations, a LONG-INTEGER variable must reside in the lower register file and must be aligned at an address that is evenly di- visible by four. The address of a LONG-INTEGER is that of its least-significant byte (the even byte address).
LONG-INTEGER operations that are not directly supported can be easily implemented with two INTEGER operations. See the example in “DOUBLE-WORD Operands” on page 4-3.
A QUAD-WORD is a 64-bit, unsigned variable that can take on values from 0 through 264–1. The architecture directly supports the QUAD-WORD operand only as the operand of the EB- MOVI instruction. For this operation, the QUAD-WORD variable must reside in the lower reg- ister file and must be aligned at an address that is evenly divisible by eight.
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 clearing (writing zeros to) the upper WORD of the DOUBLE-WORD. LDBSE (load byte, sign extended) converts a SHORT-INTEGER into an INTEGER. EXT (sign extend) converts an INTEGER to a LONG-INTEGER.
The instructions for addition, subtraction, and comparison do not distinguish between unsigned (BYTE, WORD) and signed (SHORT-INTEGER, INTEGER) operands. However, the condition- al jump instructions allow you to treat the results of these operations as signed or unsigned quan- tities. 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.

4.1.11 Floating Point Operations
The hardware does not directly support operations on REAL (floating point) variables. Those op- erations 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 processor status word (PSW). The NORML instruction normalizes a 32-bit variable; the sticky bit (ST) flag can be used in conjunc- tion with the carry (C) flag to achieve finer resolution in rounding.
This section briefly describes the instructions that have been added to enable code execution and data access anywhere in the 1-Mbyte address space.
EBMOVI Extended interruptable block move. Moves a block of word data from one memory location to another. This instruction allows you to move blocks of up to 64K words between any two locations in the address space. It uses two 24-bit autoincrementing pointers and a 16-bit counter.
EBR Extended branch. This instruction is an unconditional indirect jump to anywhere in the address space. It functions only in extended addressing modes.
ECALL Extended call. This instruction is an unconditional relative call to anywhere in the address space. It functions only in extended addressing modes.
EJMP Extended jump. This instruction is an unconditional, relative jump to anywhere in the address space. It functions only in extended addressing modes.
ELD Extended load word. Loads the value of the source word operand into the destination operand. This instruction allows you to move data from anywhere in the address space into the lower register file. It operates in extended indirect and extended indexed modes.
ELDB Extended load byte. Loads the value of the source byte operand into the destination operand. This instruction allows you to move data from anywhere in the address space into the lower register file. It operates in extended indirect and extended indexed modes.

EST Extended store word. Stores the value of the source (leftmost) word operand into the destination (rightmost) operand. This instruction allows you to move data from the lower register file to anywhere in the address space. It operates in extended indirect and extended indexed modes.
ESTB Extended store byte. Stores the value of the source (leftmost) byte operand into the destination (rightmost) operand. This instruction allows you to move data from the lower register file to anywhere in the address space. It operates in extended indirect and extended indexed modes.
The instruction set uses four basic addressing modes:
The stack pointer can be used with indirect addressing to access the top of the stack, and it can also be used with short-indexed addressing to access data within the stack. The zero register can be used with long-indexed addressing to access any memory location.
Extended variations of the indirect and indexed modes support the extended load and store in- structions. An extended load instruction moves a word (ELD) or a byte (ELDB) from any location in the address space into the lower register file. An extended store instruction moves a word (EST) or a byte (ESTB) from the lower register file into any location in the address space. An instruction can contain only one immediate, indirect, or indexed reference; any remaining oper- ands must be direct references.
This section describes the addressing modes as they are handled by the hardware. An understand- ing of these details will help programmers to take full advantage of the architecture. The assembly language hides some of the details of how these addressing modes work. “Assembly Language Addressing Mode Selections” on page 4-11 describes how the assembly language handles direct and indexed addressing modes.
The examples in this section assume that temporary registers are defined as shown in this segment of assembly code and described in Table 4-3.
Oseg at 1ch AX DSW 1 BX DSW 1 CX DSW 1 DX DSW 1 EX DSL 1

Table 4-3. Definition of Temporary Registers
AX word-aligned 16-bit register; AH is the high byte of AX and AL is the low byte
BX word-aligned 16-bit register; BH is the high byte of BX and BL is the low byte
CX word-aligned 16-bit register; CH is the high byte of CX and CL is the low byte
DX word-aligned 16-bit register; DH is the high byte of DX and DL is the low byte
EX double-word-aligned 24-bit register
Direct addressing directly accesses a location in the 256-byte lower register file, without involv- ing the memory controller. Windowing allows you to remap other sections of memory into the lower register file for direct access (see Chapter 5, “Memory Partitions,” for details). You specify the registers as operands within the instruction. The register addresses must conform to the align- ment rules for the operand type. Depending on the instruction, up to three registers can take part in a calculation. The following instructions use direct addressing:
ADD AX,BX,CX ; AX ← BX + CX ADDB AL,BL,CL ; AL ← BL + CL MUL AX,BX ; AX ← AX × BX INCB CL ; CL ← CL + 1
Immediate addressing mode accepts one immediate value as an operand in the instruction. You specify an immediate value by preceding it with a number symbol (#). An instruction can contain only one immediate value; the remaining operands must be direct references. The following in- structions use immediate addressing:
ADD AX,#340 ; AX ← AX + 340 PUSH #1234H ; SP ← SP - 2 ; MEM_WORD(SP) ← 1234H DIVB AX,#10 ; AL ← AX/10 ; AH ← AX MOD 10
The indirect addressing mode accesses an operand by obtaining its address from a WORD regis- ter in the lower register file. You 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 register that contains the indirect address must be word-aligned, 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 in- structions use indirect addressing:
Temporary Register Description

LD AX,[BX] ; AX ← MEM_WORD(BX) ADDB AL,BL,[CX] ; AL ← BL + MEM_BYTE(CX) POP [AX] ; MEM_WORD(AX) ← MEM_WORD(SP) ; SP ← SP + 2
Extended load and store instructions can use indirect addressing. The only difference is that the register containing the indirect address must be a word-aligned 24-bit register to allow access to the entire 1-Mbyte address space. The following instructions use extended indirect addressing:
ELD AX,[EX] ; AX ← MEM_WORD(EX) ELDB AL,[EX] ; AL ← MEM_BYTE(EX) EST AX,[EX] ; MEM_WORD(EX) ← AX ESTB AL,[EX] ; MEM_BYTE(EX) ← AL
You can choose to automatically increment the indirect address after the current access. You spec- ify autoincrementing 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 automat- ically sets the least-significant bit of the indirect address register. The following instructions use indirect addressing with autoincrement:
LD AX,[BX]+ ; AX ← MEM_WORD(BX) ; BX ← BX + 2 ADDB AL,BL,[CX]+ ; AL ← BL + MEM_BYTE(CX) ; CX ← CX + 1 PUSH [AX]+ ; SP ← SP - 2 ; MEM_WORD(SP) ← MEM_WORD(AX) ; AX ← AX + 2
The extended load and store instructions can also use indirect addressing with autoincrement. The only difference is that the register containing the indirect address must be a word-aligned 24-bit register to allow access to the entire 1-Mbyte address space. The following instructions use ex- tended indirect addressing with autoincrement:
ELD AX,[EX]+ ; AX ← MEM_WORD(EX) ; EX ← EX + 2 ELDB AL,[EX]+ ; AL ← MEM_BYTE(EX) ; EX ← EX + 2 EST AX,[EX]+ ; MEM_WORD(EX) ← AX ; MEM_WORD(EX) ← MEM_WORD(EX + 2) ESTB AL,[EX]+ ; MEM_BYTE(EX) ← AL ; MEM_BYTE(EX) ← MEM_BYTE(EX + 2)
![Page 66 of the Intel 80C196NU user manual — LD AX,2[SP]](/cdn/reader/81/81ad13d66dee05077accc2a672ac95c5d3927783e4df5c8f79b065346bb263ae/images/page-66.webp?w=400)
4.2.3.4 Indirect Addressing with the Stack Pointer
You can also use indirect addressing to access the top of the stack by using the stack pointer as the WORD register in an indirect reference. The following instruction uses indirect addressing with the stack pointer:
PUSH [SP] ; duplicate top of stack ; SP ← SP +2
Indexed addressing calculates an address by adding an offset to a base address. There are three variations of indexed addressing: short-indexed, long-indexed, and zero-indexed. Both short- and long-indexed addressing are used to access a specific element within a structure. 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 con- tain only one indexed reference; any remaining operands must be direct references.
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.
LD AX,12H[BX] ; AX ← MEM_WORD(BX+12H) MULB AX,BL,3[CX] ; AX ← BL × MEM_BYTE(CX+3)
The instruction LD AX,12H[BX] loads AX with the contents of the memory location that resides at address BX+12H. That is, the instruction adds the constant 12 (the offset) to the contents of BX (the base address), then loads AX with the contents of the resulting address. For example, if BX contains 1000H, then AX is loaded with the contents of location 1012H. Short-indexed address- ing is typically used to access elements in a structure, where BX contains the base address 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-indexed instruction to access a particular location within the stack, as shown in the following instruction.
4.2.4.2 Long-indexed Addressing
In a long-indexed instruction, you specify the base address as a 16-bit variable and the offset as an indirect address register (a WORD). The following instructions use long-indexed addressing.
LD AX,TABLE[BX] ; AX ← MEM_WORD(TABLE+BX) AND AX,BX,TABLE[CX] ; AX ← BX AND MEM_WORD(TABLE+CX)
![Page 67 of the Intel 80C196NU user manual — ELD AX,23456H[ZERO_REG] ; AX ← MEM_WORD(23456H)](/cdn/reader/81/81ad13d66dee05077accc2a672ac95c5d3927783e4df5c8f79b065346bb263ae/images/page-67.webp?w=400)
ST AX,TABLE[BX] ; MEM_WORD(TABLE+BX) ← AX ADDB AL,BL,LOOKUP[CX] ; AL ← BL + MEM_BYTE(LOOKUP+CX)
The instruction LD AX, TABLE[BX] loads AX with the contents of the memory location that re- sides at address TABLE+BX. That is, the instruction 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 typically used to access elements in a table, where TABLE is a constant that is the base address of the structure and BX is the scaled offset (n × el- ement size, in bytes) into the structure.
The extended load and store instructions can use extended indexed addressing. The only differ- ence from long-indexed addressing is that both the base address and the offset must be 24 bits to support access to the entire 1-Mbyte address space. The following instructions use extended in- dexed addressing. (In these instructions, OFFSET is a 24-bit variable containing the offset, and EX is a double-word aligned 24-bit register containing the base address.)
ELD AX,OFFSET[EX] ; AX ← MEM_WORD(EX+OFFSET) ELDB AL,OFFSET[EX] ; AL ← MEM_BYTE(EX+OFFSET) EST AX,OFFSET[EX] ; MEM_WORD(EX+OFFSET) ← AX ESTB AL,OFFSET[EX] ; MEM_BYTE(EX+OFFSET) ← AL
In a zero-indexed instruction, you specify the address as a 16-bit variable; the offset is zero, and 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 following instructions also use zero-indexed addressing:
ADD AX,1234H[ZERO_REG] ; AX ← AX + MEM_WORD(1234H) POP 5678H[ZERO_REG] ; MEM_WORD(5678H) ← MEM_WORD(SP) ; SP ← SP + 2
The extended instructions can also use zero-indexed addressing. The only difference is that you specify the address as a 24-bit constant or variable. The following extended instruction uses zero- indexed addressing. ZERO_REG acts as a 32-bit fixed source of the constant zero for an extended indexed reference.

4.3 ASSEMBLY LANGUAGE ADDRESSING MODE SELECTIONS
The assembly language simplifies the choice of addressing modes. Use these features wherever possible.
The assembly language chooses between 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 register file, the assembly language chooses a direct reference. If the operand is elsewhere in memory, it chooses a zero-indexed reference.
The assembly language chooses between short-indexed and long-indexed addressing depending on the value of the index expression. If the value can be expressed in eight bits, the assembly lan- guage chooses a short-indexed reference. If the value is greater than eight bits, it chooses a long- indexed reference.
If the operand is outside page 00H, then you must use the extended load and store instructions, ELD, ELDB, EST, and ESTB.
In general, you should avoid creating tables or arrays that cross page boundaries. For example, if you are building a large array, start it at a base address that will accommodate the entire array within the same page. If you cannot avoid crossing a page boundary, keep in mind that you must use extended instructions to access data outside the original page.
For a software project of any size, it is a good idea to develop the program in modules and to es- tablish 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 compat- ibility between these environments.

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 file for direct access. Memory- mapped SFRs cannot be windowed; you must use indirect or indexed addressing to access them. All SFRs can be operated on as BYTEs or WORDs, unless otherwise specified. See “Peripheral Special-function Registers (SFRs)” on page 5-7 and “Register File” on page 5-9 for more infor- mation.
To use these registers effectively, you must have some overall strategy for allocating them. The C programming language adopts a simple, effective strategy. It allocates the eight or sixteen 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.
The 32-bit operands (DOUBLE-WORDs and LONG-INTEGERs) are formed by two adjacent 16-bit words in memory. 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-significant word must be pushed into the stack first). The address of a 32-bit operand is that of its least-significant byte.
The hardware supports the 32-bit data types as operands in shift operations, as dividends of 32- by-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.
The hardware supports the QUAD-WORD only as the operand of the EBMOVI instruction. For this operation, the QUAD-WORD variable must reside in the lower register file and must be aligned at an address that is evenly divisible by eight.

4.5.4 Linking 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 pushed onto the stack as two 16-bit values; the most- significant half of the parameter is pushed into the stack first. As an example, consider the fol- lowing procedure:
void example_procedure (char param1, long param2, int param3);
When this procedure is entered at run-time, the stack will contain the parameters in the following order:
low word of param2
high word of param2
return address ← Stack Pointer
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 an 8-, 16-, 32-, or 64-bit variable, depending on the type of the procedure.
The standard calling convention adopted by the C programming language has several key fea- tures:
The C programming language allows the definition of interrupt procedures, which are executed when a predefined interrupt request occurs. Interrupt procedures do not conform to the rules of normal procedures. Parameters cannot be passed to these procedures and they cannot return re- sults. Since interrupt procedures can execute essentially at any time, they must save and restore both the PSW and TMPREG0.
param3 · undefined;param1

The device has several features to assist in recovering 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 instruc- tion from unprogrammed locations in nonvolatile memory or from bus lines that have been pulled high.
We recommend that you fill unused areas of code with NOPs and periodic jumps to an error rou- tine or RST instruction. This is particularly important in the code surrounding lookup tables, since accidentally executing from lookup tables will cause undesired results. 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 unneces- sary if RSTs are used instead of jumps to an error routine. This will help to ensure a speedy re- covery from a software error.




This chapter describes the organization of the address space, its major partitions, and the 1-Mbyte and 64-Kbyte operating modes. 1-Mbyte refers to the address space defined by the 20 external address lines. In 1-Mbyte mode, code can execute from almost anywhere in the 1-Mbyte space. In 64-Kbyte mode, code can execute only from the 64-Kbyte area FF0000–FFFFFFH. The 64- Kbyte mode provides compatibility with software written for previous 16-bit MCS® 96 micro- controllers. In either mode, nearly all of the 1-Mbyte address space is available for data storage.
Other topics covered in this chapter include the following:
The instructions can address 16 Mbytes of memory. However, only 20 of the 24 address lines are implemented by external pins: A19:0 in demultiplexed mode, or A19:16 and AD15:0 in multi- plexed mode. The lower 16 address/data lines, AD15:0, are the same as those in all other MCS 96 microcontrollers. The four extended address lines, A19:16, are provided by the EPORT. If, for example, an internal 24-bit address is FF2018H, the 20 external-address pins output F2018H. Further, the address seen by an external device depends on how many of the extended address lines are connected to the device. (See “Internal and External Addresses” on page 13-1.)
The 20 external-address pins can address 1 Mbyte of external memory. For purposes of discussion only, it is convenient to view this 1-Mbyte address space as sixteen 64-Kbyte pages, numbered 00H–0FH (see Figure 5-1 on page 5-2). The lower 16 address lines enable the device to address page 00H. The four extended address lines enable the device to address the remaining external address space, pages 01H–0FH.

Because the four most-significant bits (MSBs) of the internal address can take any values without changing the external address, these four bits effectively produce 16 copies of the 1-Mbyte ad- dress space, for a total of 16 Mbytes in 256 pages, 00H–FFH (Figure 5-1). For example, page 01H has 15 duplicates: 11H, 21H, ..., F1H. The shaded areas in Figure 5-1 represent the overlaid areas.
Figure 5-1. 16-Mbyte Address Space
The memory pages of interest are 00H–0EH and FFH. Pages 01H–0EH are external memory with unspecified contents; they can store either code or data. Pages 00H and FFH, shown in Figure 5-2, have special significance. Page 00H contains the register file and the special-function regis- ters (SFRs), while page FFH contains special-purpose memory (chip configuration bytes and in- terrupt vectors) and program memory. The device fetches its first instruction from location FF2080H. Addresses in page FFH exist only in the internal 24-bit address space.
The implementation of page FFH in the 83C196NP differs from that in the 80C196NP and 80C196NU. For the 83C196NP, locations FF2000–FF2FFFH are implemented by 4 Kbytes of in- ternal ROM and the remainder of page FFH (FF3000–FFFFFFH) is implemented by external memory in page 0FH. For the 80C196NP and the 80C196NU, which have no internal ROM, all of page FFH is implemented by external memory in page 0FH.
16 Mbyte FFH

FFFFFFH
00FFFFH 003000H 002FFFH 002000H 001FFFH 001F00H 001EFFH 001C00H 001BFFH 000400H 0003FFH 000100H 0000FFH 000000H
FF2080H FF207FH
FF2000H FF1FFFH
A Copy of Page FFH if
FF0100H FF00FFH
FF0000H
Figure 5-2. Pages FFH and 00H
5.2 MEMORY PARTITIONS
Table 5-1 is a memory map of the 8XC196NP and 80C196NU. The remainder of this section de- scribes the partitions.

Hex Address Description Addressing Modes
External device (memory or I/O) connected to address/data bus Indirect, indexed, extended
FF2FFF FF2080
Program memory (Note 1) After a device reset, the first instruction fetch is from FF2080H (or F2080H in external memory).
FF207F FF2000 Special-purpose memory (Note 1) Indirect, indexed, extended
External device (memory or I/O) connected to address/data bus Indirect, indexed, extended
FF00FF FF0000 Reserved (Note 2) —
0F0000 Overlaid memory; xF0000—xF00FFH are reserved Indirect, indexed, extended
0EFFFF 010000 External device (memory or I/O) connected to address/data bus Indirect, indexed, extended
00FFFF 003000 External device (memory or I/O) connected to address/data bus Indirect, indexed, extended
002FFF 002000 External device (memory or I/O) connected to address/data bus (Note 3) Indirect, indexed, extended
001FFF 001F00 Peripheral SFRs (Note 4) Indirect, indexed, extended,
001EFF 001C00 External device (memory or I/O) connected to address/data bus; future SFR expansion (Note 5) Indirect, indexed, extended
001BFF 000400 External device (memory or I/O) connected to address/data bus Indirect, indexed, extended
0003FF 000100 Upper register file (register RAM) Indirect, indexed,
0000FF 000000 Lower register file (register RAM, stack pointer, CPU SFRs) Direct, indirect, indexed
NOTES: 1. For the 80C196NP and 80C196NU, the program and special-purpose memory locations (FF2000– FF2FFFH) reside in external memory. For the 83C196NP, these locations can reside either in exter- nal memory or in internal ROM. 2. Do not use these locations except to initialize them. Except as otherwise noted, initialize unused program memory locations and reserved memory locations to FFH. 3. For the 80C196NP and 80C196NU, locations 002000–002FFFH reside in external memory. For the 83C196NP, locations 002000–002FFFH can be external memory (CCB1.2=0) or a copy of program and special-purpose memory stored in the internal ROM (CCB1.2=1). 4. For the 8XC196NP, locations 1FE0–1FFFH contain memory-mapped SFRs. They must be accessed with indirect, indexed, or extended addressing and they cannot be windowed. 5. WARNING: The contents or functions of these locations may change with future device revisions, in which case a program that relies on one or more of these locations might not function properly.
Indirect, indexed, extended · windowed direct · windowed direct

5.2.1 External Memory
Several partitions in pages 00H and FFH and all of pages 01H–0EH are assigned to external memory (see Table 5-1). Data can be stored in any part of this memory. Instructions can be stored in any part of this memory in 1-Mbyte mode, but can be stored only in page FFH in 64-Kbyte mode. “Memory Configuration Examples” on page 5-27 contains examples of memory configu- rations in the two modes. Chapter 13, “Interfacing with External Memory,” describes the external memory interface and shows additional examples of external memory configurations.
Program memory and special-purpose memory occupy a 4-Kbyte memory partition from FF2000–FF2FFFH. For the 80C196NP and 80C196NU, this partition resides in external memory (external addresses F2000–F2FFFH). For the 83C196NP, this partition resides in on-chip ROM in page FFH, and it can also be mapped to page 00H (see “Remapping Internal ROM (83C196NP Only)” on page 5-22).
Three partitions in page FFH can be used for program memory:
— 80C196NP and 80C196NU: This partition is in external memory (external addresses F2080–F2FFFH).
— 83C196NP: The REMAP bit (CCB1.2), the EA# input, and the type of instruction (extended or nonextended) control access to this partition, as shown in Table 5-2.
REMAP (CCB1.2) EA# Pin Instruction Type Memory Location Accessed
X Asserted Extended or nonextended External memory, F2080–F2FFFH
0 Deasserted Extended or nonextended Internal ROM, FF2080–FF2FFFH
Extended Internal ROM, FF2080–FF2FFFH
Nonextended External memory, 02080–02FFFH
1 Deasserted

Special-purpose memory resides in locations FF2000–FF207FH. It contains several reserved memory locations, the chip configuration bytes (CCBs), and vectors for both peripheral transac- tion server (PTS) and standard interrupts. Note that the special-purpose memory partition of the 80C196NU differs slightly from that of the 8XC196NP. Table 5-3 describes the special-purpose memory; bold type highlights the differences.
FF207F FF205E
FF207F FF2060 Reserved (each byte must contain FFH)
FF205F FF2040 PTS vectors
FF203F FF2030
FF203F FF2030 Upper interrupt vectors
FF202F FF201B Reserved (each byte must contain FFH)
FF2019 FF2019 Reserved (must contain 20H)
FF2017 FF2014
FF2017 FF2010 Reserved (each byte must contain FFH)
FF200F FF2000 Lower interrupt vectors
— 80C196NP and 80C196NU: This partition is in external memory (external addresses F2000–F207FH).
— 83C196NP: The REMAP bit (CCB1.2), the EA# input, and the type of instruction (extended or nonextended) control access to this partition, as shown in Table 5-4.
REMAP (CCB1.2) EA# Pin Instruction
Type Memory Location Accessed
X Asserted Extended or nonextended External memory, F2000–F207FH
0 Deasserted Extended or nonextended Internal ROM, FF2000–FF207FH
Extended Internal ROM, FF2000–FF207FH
Nonextended External memory, 02000–0207FH

5.2.2.3 Reserved Memory Locations
Several memory locations are reserved for testing or for use in future products. Do not read or write these locations except to initialize them to the values shown in Table 5-3. The function or contents of these locations may change in future revisions; software that uses reserved locations may not function properly.
The peripheral transaction server (PTS) vectors contain the addresses of the PTS control blocks. The upper and lower interrupt vectors contain the addresses of the interrupt service routines. See Chapter 6, “Standard and PTS Interrupts,” for more information.
The chip configuration bytes (CCB0 and CCB1) specify the operating environment. They specify the bus width, bus mode (multiplexed or demultiplexed), write-control mode, wait states, power- down enabling, and the operating mode (1-Mbyte or 64-Kbyte mode). For the 83C196NP, CCB1 also controls ROM remapping. For the 80C196NP and 80C196NU, the CCBs are stored in exter- nal memory (locations F2018–F201AH). For the 83C196NP, the CCBs can be stored either in ex- ternal memory (locations F2018–F201AH) or in the on-chip ROM (locations FF2018– FF201AH).
The chip configuration bytes are the first bytes fetched from memory when the device leaves the reset state. The post-reset sequence loads the CCBs into the chip configuration registers (CCRs). Once they are loaded, the CCRs cannot be changed until the next device reset. Typically, the CCBs are programmed once when the user program is compiled and are not redefined during nor- mal operation. “Chip Configuration Registers and Chip Configuration Bytes” on page 13-14 de- scribes the CCBs and CCRs.
Locations 1F00–1FFFH provide access to the peripheral SFRs (see Table 5-5). Locations in this range that are omitted from the table are reserved. The peripheral SFRs are I/O control registers; they are physically located in the on-chip peripherals. Peripheral SFRs can be windowed and they can be addressed either as words or bytes, except as noted in the table.

Reserved Locations EPORT SFRs
Address High (Odd) Byte Low (Even) Byte Address High (Odd) Byte Low (Even) Byte 1FEEH Reserved Reserved ††1FE6H EP_PIN Reserved
1FECH Reserved Reserved ††1FE4H EP_REG Reserved
1FEAH Reserved Reserved ††1FE2H EP_DIR Reserved
1FE8H Reserved Reserved ††1FE0H EP_MODE Reserved
Ports 1–4 SFRs Serial I/O and PWM SFRs
Address High (Odd) Byte Low (Even) Byte Address High (Odd) Byte Low (Even) Byte 1FDEH P4_PIN P3_PIN 1FBEH Reserved Reserved
1FDAH P4_DIR P3_DIR 1FBAH SP_CON SBUF_TX
1FD8H P4_MODE P3_MODE 1FB8H SP_STATUS SBUF_RX
1FD6H P2_PIN P1_PIN 1FB6H Reserved CON_REG0
1FD4H P2_REG P1_REG 1FB4H Reserved PWM2_CONTROL
1FD2H P2_DIR P1_DIR 1FB2H Reserved PWM1_CONTROL
1FD0H P2_MODE P1_MODE 1FB0H Reserved PWM0_CONTROL
1FCEH Reserved Reserved 1FAEH Reserved Reserved
1FC0H Reserved Reserved 1FA0H Reserved Reserved
EPA, Timer 1, and Timer 2 SFRs Chip-select SFRs
Address High (Odd) Byte Low (Even) Byte Address High (Odd) Byte Low (Even) Byte 1F9EH Reserved EPA_PEND ††† †1F6EH Reserved Reserved
1F9CH Reserved EPA_MASK †1F6CH Reserved BUSCON5
1F9AH Reserved Reserved †1F6AH ADDRMSK5 (H) ADDRMSK5 (L)
1F98H Reserved Reserved 1F68H ADDRCOM5 (H) ADDRCOM5 (L)
†1F96H TIMER2 (H) TIMER2 (L) †1F66H Reserved Reserved
1F94H Reserved T2CONTROL †1F64H Reserved BUSCON4
†1F92H TIMER1 (H) TIMER1 (L) †1F62H ADDRMSK4 (H) ADDRMSK4 (L)
1F90H Reserved T1CONTROL 1F60H ADDRCOM4 (H) ADDRCOM4 (L)
†1F8EH EPA3_TIME (H) EPA3_TIME (L) 1F5EH Reserved Reserved
†1F8CH EPA3_CON (H) EPA3_CON (L) 1F5CH Reserved BUSCON3
†1F8AH EPA2_TIME (H) EPA2_TIME (L) 1F5AH ADDRMSK3 (H) ADDRMSK3 (L)
1F88H Reserved EPA2_CON 1F58H ADDRCOM3 (H) ADDRCOM3 (L)
†1F86H EPA1_TIME (H) EPA1_TIME (L) 1F56H Reserved Reserved
†1F84H EPA1_CON (H) EPA1_CON (L) 1F54H Reserved BUSCON2
†1F82H EPA0_TIME (H) EPA0_TIME (L) 1F52H ADDRMSK2 (H) ADDRMSK2 (L)
1F80H Reserved EPA0_CON 1F50H ADDRCOM2 (H) ADDRCOM2 (L)
† Must be addressed as a word. †† For the 8XC196NP, these are memory-mapped locations. They must be addressed with indirect or indexed instructions, and they cannot be windowed. ††† The EPA_PEND register was called EPA_STAT in previous documentation for the 8XC196NP. †††† The 8XC196NP can be identified by its signature word, 80EFH, at locations 1F46–1F47H. The
8XC196NU has no signature word; locations 1F46–1F47H are reserved.

Table 5-5. Peripheral SFRs (Continued)
EPA, Timer 1, and Timer 2 SFRs (Continued) Chip-select SFRs (Continued)
Address High (Odd) Byte Low (Even) Byte Address High (Odd) Byte Low (Even) Byte 1F7EH Reserved Reserved 1F4EH Reserved Reserved
1F7CH Reserved Reserved 1F4CH Reserved BUSCON1
1F7AH Reserved Reserved 1F4AH ADDRMSK1 (H) ADDRMSK1 (L)
1F78H Reserved Reserved 1F48H ADDRCOM1 (H) ADDRCOM1 (L)
1F76H Reserved Reserved 1F46H Signature (H)†††† Signature (L)††††
1F74H Reserved Reserved 1F44H Reserved BUSCON0
1F72H Reserved Reserved 1F42H ADDRMSK0 (H) ADDRMSK0 (L)
1F70H Reserved Reserved 1F40H ADDRCOM0 (H) ADDRCOM0 (L)
† Must be addressed as a word. †† For the 8XC196NP, these are memory-mapped locations. They must be addressed with indirect or indexed instructions, and they cannot be windowed. ††† The EPA_PEND register was called EPA_STAT in previous documentation for the 8XC196NP. †††† The 8XC196NP can be identified by its signature word, 80EFH, at locations 1F46–1F47H. The
8XC196NU has no signature word; locations 1F46–1F47H are reserved.
The register file is divided into an upper register file and a lower register file (Figure 5-3). The upper register file consists of general-purpose register RAM. The lower register file contains ad- ditional general-purpose register RAM along with the stack pointer (SP) and the CPU special- function registers (SFRs).

0100H 00FFH 001AH 0019H 0018H 0017H 0000H CPU SFRs
03FFH 0100H 00FFH 0000H
Figure 5-3. Register File Memory Map
Table 5-6 on page 5-11 lists 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 loca- tion directly (see “Windowing” on page 5-13). Only 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 direct addressing.

Table 5-6. Register File Memory Addresses
Range Description Addressing Modes
03FFH 0100H General-purpose register RAM; upper register file Indirect, indexed, windowed direct
00FFH 001AH General-purpose register RAM; lower register file Direct, indirect, indexed
0019H 0018H Stack pointer (SP); lower register file Direct, indirect, indexed
0017H 0000H CPU special-function registers (SFRs); lower register file Direct, indirect, indexed
The lower register file contains general-purpose register RAM. The stack pointer locations can also be used as general-purpose register RAM when stack operations are not being performed. The RALU can access this memory directly, using direct addressing.
The upper register file also contains general-purpose register RAM. The RALU normally uses indirect or indexed addressing to access the RAM in the upper register file. Windowing enables the RALU to use direct addressing to access this memory. (See Chapter 4, “Programming Con- siderations,” for a discussion of addressing modes.) Windowing provides fast context switching of interrupt tasks and faster program execution. (See “Windowing” on page 5-13.) PTS control blocks and the stack are most efficient when located in the upper register file.
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 (for 64-Kbyte mode) or four bytes (for 1-Mbyte mode) greater than the desired starting address. Before the CPU exe- cutes a subroutine call or interrupt service routine, it decrements the SP (by two in 64-Kbyte mode; by four in 1-Mbyte mode). Next, it copies (PUSHes) the address of the next instruction from the program counter onto the stack. It then loads the address of the subroutine or interrupt service routine into the program counter. When it executes the return-from-subroutine (RET) in- struction at the end of the subroutine or interrupt service routine, the CPU loads (POPs) the con- tents of the top of the stack (that is, the return address) into the program counter. Finally, it increments the SP (by two in 64-Kbyte mode; by four in 1-Mbyte mode).
Address

Subroutines may be nested. That is, each subroutine may call other subroutines. The CPU PUSH- es 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.
Your program must load a word-aligned (even) address into the stack pointer. Select an address that is two bytes (for 64-Kbyte mode) or four bytes (for 1-Mbyte mode) greater than the desired starting address because the CPU automatically decrements 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 stack must be located in page 00H, in either the internal register file or external RAM. The stack can be used most efficiently when it is located in the upper register file.
The following example initializes the top of the upper register file as the stack.
LD SP, #400H ;Load stack pointer
Locations 0000–0017H in the lower register file are the CPU SFRs. Table 5-7 lists the CPU SFRs for the 8XC196NP and the 80C196NU and highlights those that are unique to the 80C196NU. Appendix C describes the CPU SFRs.
8XC196NP CPU SFRs 80C196NU CPU SFRs
Address High (Odd) Byte Low (Even) Byte Address High (Odd) Byte Low (Even) Byte
0016H Reserved Reserved 0016H Reserved Reserved
0014H Reserved WSR 0014H WSR1† WSR
0010H Reserved Reserved 0010H Reserved Reserved
000EH Reserved Reserved 000EH†† ACC_03† ACC_02†
000CH Reserved Reserved 000CH†† ACC_01† ACC_00†
000AH Reserved Reserved 000AH ACC_STAT† Reserved
0006H PTSSRV (H) PTSSRV (L) 0006H PTSSRV (H) PTSSRV (L)
0004H PTSSEL (H) PTSSEL (L) 0004H PTSSEL (H) PTSSEL (L)
0002H ONES_REG (H) ONES_REG (L) 0002H ONES_REG (H) ONES_REG (L)
0000H ZERO_REG (H) ZERO_REG (L) 0000H ZERO_REG (H) ZERO_REG (L)
† These SFRs are unique to the 80C196NU. †† Must be addressed as a word.

5.3 WINDOWING
Windowing expands the amount of memory that is accessible with direct addressing. Direct ad- dressing can access the lower register file with short, fast-executing instructions. With window- ing, direct addressing can also access the upper register file and peripheral SFRs.
Windowing maps a segment of higher memory (the upper register file or peripheral SFRs) into the lower register file. The 8XC196NP has a single window selection register, while the 80C196NU has two. The first, WSR, is the same in both devices. WSR selects a 32-, 64-, or 128- byte segment of higher memory to be windowed into the top of the lower register file space.
The second, WSR1, is unique to the 80C196NU. WSR1 selects a 32- or 64-byte segment of high- er memory to be windowed into the middle of the lower register file (Figure 5-4). Because the areas in the lower register file do not overlap, two windows can be in effect at the same time. For example, you can activate a 128-byte window using WSR and a 64-byte window using WSR1 (Figure 5-4). These two windows occupy locations 0040–00FFH in the lower register file, leav- ing locations 001A–003FH for use as general-purpose register RAM, locations 0018–0019H for the stack pointer or general-purpose register RAM, and locations 0000–0017H for the CPU SFRs.
128-byte Window (WSR = 17H)
128-byte Window (WSR = 17H)
64-byte Window (WSR1 = 2DH)
Window in Lower Register File
WSR Window in Lower Register File
WSR1 Window in Lower Register File
Figure 5-4. Windowing

The window selection register (Figure 5-5) has two functions. The HLDEN bit (WSR.7) enables and disables the bus-hold protocol (see Chapter 13, “Interfacing with External Memory”); it is unrelated to windowing. The remaining bits select a window to be mapped into the top of the low- er register file. Window selection register 1 (Figure 5-6) selects a second window to be mapped into the middle of the 80C196NU’s lower register file.
Table 5-8 provides a quick reference of WSR values for windowing the peripheral SFRs. Table 5-9 on page 5-15 lists the WSR values for windowing the upper register file.
The window selection register (WSR) has two functions. One bit enables and disables the bus-hold protocol. The remaining bits select windows. Windows map sections of RAM into the top of the lower register file, in 32-, 64-, or 128-byte increments. PUSHA saves this register on the stack and POPA restores it.
7 HLDEN HOLD#, HLDA# Protocol Enable
This bit enables and disables the bus-hold protocol (see Chapter 13, “Interfacing with External Memory”). It has no effect on windowing.
1 = enable 0 = disable
6:0 W6:0 Window Selection
These bits specify the window size and window number. See Table 5-8 on page 5-15 or Table 5-9 on page 5-15.
Bit Number · Bit Mnemonic Function

WSR1 (80C196NU)
Window selection 1 (WSR1) register selects a 32- or 64-byte segment of the upper register file or peripheral SFRs to be windowed into the middle of the lower register file, below any window selected by the WSR.
80C196NU — W6 W5 W4 W3 W2 W1 W0
7 — Reserved; always write as zero.
6:0 W6:0 Window Selection
These bits specify the window size and window number. See Table 5-8 on page 5-15 or Table 5-9 on page 5-15.
Table 5-8. Selecting a Window of Peripheral SFRs
WSR or WSR1 Value
WSR or WSR1 Value
WSR Value for 128-byte Window (0080–00FFH)
for 32-byte Window (00E0–00FFH or 0060–007FH)
for 64-byte Window (00C0–00FFH or 0040–007FH)
3FH †
PWM and SIO 7DH
3EH EPA and Timers 7CH
Chip selects 4–5 7BH
3DH 1EH Chip selects 0–3 7AH
† For the 8XC196NP, the EPORT SFRs are memory-mapped SFRs. They must be accessed with indirect, indexed, or extended addressing; they cannot be windowed.
WSR or WSR1 Value
WSR or WSR1 Value
WSR Value for 128-byte Window
for 32-byte Window (00E0–00FFH or 0060–007FH)
for 64-byte Window (00C0–00FFH or 0040–007FH)
03E0–03FF 5FH
03C0–03DF 5EH
2FH
03A0–03BF 5DH
2EH 0380–039F 5CH
17H

WSR or WSR1 Value
WSR or WSR1 Value
WSR Value for 128-byte Window
for 32-byte Window (00E0–00FFH or 0060–007FH)
for 64-byte Window (00C0–00FFH or 0040–007FH)
0360–037F 5BH
0340–035F 5AH
2DH
0320–033F 59H
2CH 0300–031F 58H
16H
02E0–02FF 57H
02C0–02DF 56H
2BH
02A0–02BF 55H
2AH 0280–029F 54H
15H
0260–027F 53H
0240–025F 52H
29H
0220–023F 51H
28H 0200–021F 50H
14H
01E0–01FF 4FH
01C0–01DF 4EH
27H
01A0–01BF 4DH
26H 0180–019F 4CH
13H
0160–017F 4BH
0140–015F 4AH
25H
0120–013F 49H
24H 0100–011F 48H
12H
5.3.2 Addressing a Location Through a Window
After you have selected the desired window, you need to know the direct address of the memory location (the address in the lower register file). For SFRs, refer to the WSR tables in Appendix C. For register file locations, calculate the direct address as follows:
Register RAM · Locations · (Hex)

Table 5-10. Windows
WSR or WSR1 Value
WSR or WSR1 Value
for 32-byte Window (00E0–00FFH or 0060–007FH)
for 64-byte Window (00C0–00FFH or 0040–007FH)
1FC0 7EH
† 3FH
1FA0 7DH
3EH 1F80 7CH
† 1FH
1F60 7BH
1F40 7AH
3DH
1F20 79H
3CH 1F00 78H
1EH
03E0H 5FH
03C0H 5EH
2FH
03A0H 5DH
2EH 0380H 5CH
17H
0360H 5BH
0340H 5AH
2DH
0320H 59H
2CH 0300H 58H
16H
02E0H 57H
02C0H 56H
2BH
02A0H 55H
2AH 0280H 54H
15H
0260H 53H
0240H 52H
29H
0220H 51H
28H 0200H 50H
14H
01E0H 4FH
01C0H 4EH
27H
01A0H 4DH
26H 0180H 4CH
13H
0160H 4BH
0140H 4AH
25H
0120H 49H
24H 0100H 48H
12H
† For the 8XC196NP, locations 1FE0–1FFFH contain memory-mapped SFRs that cannot be windowed. Reading these locations through a window returns FFH; writing these locations through a window has no effect. For the 80C196NU, these locations are not memory-mapped; they can be windowed.

Window Size WSR Windowed Base Address (Base Address in Lower Register File)
WSR1 Windowed Base Address (Base Address in Lower Register File)
Appendix C includes a table of the windowable SFRs with the window selection register 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.
Assume that you wish to access location 014BH (a location in the upper register file used for gen- eral-purpose register RAM) with direct addressing through a 32-byte window. Table 5-10 on page 5-17 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 ad- dress from the address to be accessed (014BH – 0140H = 000BH). Add the offset to the base ad- dress of the window in the lower register file (from Table 5-11). The direct address is 00EBH (000BH + 00E0H) for a WSR window or 006BH (000BH + 0060H) for a WSR1 window.
Assume that you wish to access the SFR at location 1F8CH with direct addressing through a 64- byte window. Table 5-10 on page 5-17 shows that you need to write 3EH to the window selection register. It also shows that the base address of the 64-byte memory area is 1F80H. To determine the offset, subtract that base address from the address to be accessed (1F8CH – 1F80H = 000CH). Add the offset to the base address of the window in the lower register file (from Table 5-11). The direct address is 00CCH (000CH + 00C0H) for a WSR window or 004CH (000CH + 0040H) for a WSR1 window.
Assume that you wish to access the SFR at location 1F82H with direct addressing through a 128- byte window. Table 5-11 on page 5-18 shows that you need to write 1FH to the window selection register. It also shows that the base address of the 128-byte memory area is 1F80H. To determine the offset, subtract that base address from the address to be accessed (1F82H – 1F80H = 0002H). Add the offset to the base address of the window in the lower register file (from Table 5-11). The direct address is 0082H (0002H + 0080H).

5.3.2.4 Unsupported Locations Windowing Example (8XC196NP Only)
Assume that you wish to access location 1FE7H (the EP_PIN register, a memory-mapped SFR) with 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 directly address the remaining SFRs in the range of 1F80–1FDFH.
In this example, the linker locator is used to set up a window. The linker locator locates the win- dow in the upper register file and determines the value to load in the WSR for access to that win- dow. (Please consult the manual provided with the linker locator 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
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
cseg · ******** mod2 **************

public function2 extrn ?WSR
wsr equ 14h:byte sp equ 18h:word
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 locate the modules and to deter- mine the proper windowing.
RL196 MOD1.OBJ, MOD2.OBJ registers(100h-03ffh) windowsize(32)
The above linker controls tell the linker to use registers 0100–03FFH for windowing and 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
cseg

This listing shows the disassembled code:
2080H ;C814 | PUSH WSR 2082H ;B14814 | LDB WSR,#48H 2085H ;44E4E2E0 | ADD E0H,E2H,E4H 2089H ;B21814 | LDB WSR,[SP] 208CH ;65020018 | ADD SP,#02H 2090H ;F0 | RET 2091H ;C814 | PUSH WSR 2093H ;B14814 | LDB WSR,#48H 2096H ;44EAE8E6 | ADD E6H,E8H,EAH 209AH ;B21814 | LDB WSR,[SP] 209DH ;65020018 | ADD SP,#02H 20A1H ;F0 | RET
The C compiler can also take advantage of this feature if the “windows” switch is enabled. For details, see the MCS 96 microcontroller architecture software products in the Development Tools Handbook.
Once windowing is enabled, the windowed locations can be accessed both through the window using direct addressing and through its actual address using indirect or indexed addressing. The lower register file locations that are covered by the window are always accessible by indirect or indexed operations. To re-enable direct access to the entire lower register file, clear bits 6:0 of the window selection register. To enable direct access to a particular location in the lower register file, you may select a smaller window that does not cover that location.
When windowing is enabled:
The following sample code illustrates the difference between direct and indexed addressing when using windowing.
PUSHA ; Pushes the contents of WSR onto the stack LDB WSR, #17H ; Selects window 17H, a 128-byte block ; (windows 0380-03FFH into 0080-00FFH) ; The next instruction uses direct addr ADD 40H, 80H ; mem_word(40H)←mem_word(40H) + mem_word(380H) ; The next two instructions use indirect addr ADD 40H, 80H[0] ; mem_word(40H)←mem_word(40H) + mem_word(80H +0) ADD 40H, 380H[0] ; mem_word(40H)←mem_word(40H) + mem_word(380H +0) POPA ; reloads the previous contents into WSR

The 83C196NP’s 4 Kbytes of ROM are located in FF2000–FF2FFFH. By using the REMAP bit (CCB1.2) and the EA# input, you can also access these locations in external memory (page 0FH or page 00H). The REMAP bit is loaded from CCB1 upon leaving reset and cannot be changed until the next reset. Tie EA# low to access external memory or tie it high to access the on-chip ROM. (Refer to the EA# description in Appendix B for additional information on using the EA# pin.)
Without remapping (CCB1.2 = 0), an access to FF2000–FF2FFFH is directed to internal ROM (FF2000–FF2FFFH) if EA# is high and to external memory (F2000–F2FFFH) if EA# is low. In either case, data in this area must be accessed with extended instructions.
With remapping enabled (CCB1.2 = 1) and EA# high, you can access the contents of FF2000– FF2FFFH in two ways:
With remapping enabled (CCB1.2 = 1) and EA# low, you can access the contents of FF2000– FF2FFFH in external memory (F2000–F2FFFH) using an extended instruction.
An advantage of remapping ROM is that it makes the data in ROM accessible as near data in ex- ternal memory page 00H. The data can then be accessed more quickly with nonextended instruc- tions. An advantage of not remapping ROM is that the corresponding area in external memory page 00H is available for storing additional near data.

5.5 FETCHING CODE AND DATA IN THE 1-MBYTE AND 64-KBYTE MODES
This section describes how the device fetches instructions and accesses data in the 1-Mbyte and 64-Kbyte modes. When the device leaves reset, the MODE64 bit (CCB1.1) selects the 1-Mbyte or 64-Kbyte mode. The mode cannot be changed until the next reset.
The 24-bit program counter (Figure 5-7) consists of the 8-bit extended program counter (EPC) concatenated with the 16-bit master program counter (PC). It holds the address of the next in- struction to be fetched. The page number of the instruction is in the EPC. In 1-Mbyte mode, the EPC can have any 8-bit value. However, only the four LSBs of the EPC are implemented exter- nally, as EPORT pins A19:16. This means that in the 1-Mbyte mode, the device can fetch code from any page in the 1-Mbyte address space: 00H–0FH and FFH (FFH overlays 0FH). In 64- Kbyte mode, the EPC is fixed at FFH, which limits program memory to page FFH (and 0FH).
23 16 15 0
5.5.2 Accessing Data
Internally, data addresses have 24 bits (Figure 5-8 on page 5-24). The lower 16 bits are supplied by the 16-bit data address register. The upper 8 bits (the page number) come from different sourc- es for nonextended and extended instructions. (“EPORT Operation” on page 7-12 describes how the page number is output to the EPORT pins.)

For nonextended instructions, the EP_REG register provides the page number. Data and constants in this page are called near data and near constants.
Data outside the page specified by EP_REG is called far data. To access far data, you must use extended instructions. For extended instructions, the CPU provides the page number.
From EP_REG 16-bit Data Address Register
23 16 15 0
From CPU 16-bit Data Address Register
23 16 15 0
The code example below illustrates the use of extended instructions to access data in page 01H.
EP_REG EQU 1FE5H RSEG AT 1CH TEMP: DSW 1 RESULT: DSW 1 CSEG AT 0FF2080H . ;some code . ; . ; SUBB: PUSHA ;save flags, disable interrupts LD TEMP,#1234H ; EST TEMP,010600H ;store temp value in 010600H ADD RESULT,TEMP,#4000H ;do something with registers EST RESULT,010602H ;store result in 010602H . ;more eld/est instructions . ; . ; POPA ;restore flags and interrupts RET ; . ;more code . ; . ; DONE: BR DONE END
Nonextended Address · Extended Address

5.5.3 Code Fetches in the 1-Mbyte Mode
CCR1.1 (the MODE64 bit) controls whether the device operates in 1-Mbyte or 64-Kbyte mode. CCR1 is loaded with the contents of CCB1 at reset. When MODE64 is clear, the device operates in 1-Mbyte mode. In this mode, code can execute from any page in the 1-Mbyte address space. An extended jump, branch, or call instruction across pages changes the EPC value to the destina- tion page. For example, assume that code is executing from page FFH. The following code seg- ment branches to an external memory location in page 00H and continues execution.
0FF2090H: LD TEMP,#12H ; code executing in page FFH ST TEMP,PORT1 ; code executing in page FFH EBR 003000H ; jump to location 3000H in page 00H 003000H: ADD TEMP,#50H ; code executing in page 00H
Code fetches are from external memory or internal memory, depending on the device, the instruc- tion address, and the value of the EA# input.
Code executes from any page in external memory.
For devices without internal nonvolatile memory, EA# must be tied low, and code executes from any page in external memory.
Code in all locations except FF2000–FF2FFFH executes from external memory.
Instruction fetches from FF2000–FF2FFFH are controlled by the EA# input:
CCR1.1 (the MODE64 bit) controls whether the device operates in 1-Mbyte or 64-Kbyte mode. CCR1 is loaded with the contents of CCB1 at reset. When MODE64 is set, the device operates in 64-Kbyte mode. In this mode, the EPC (Figure 5-7 on page 5-23) is fixed at FFH, which allows instructions to execute from page FFH only. Extended jump, branch, and call instructions do not function in the 64-Kbyte mode.

Code fetches are from external memory or internal memory, depending on the device, the mem- ory location, and the value of the EA# input.
Code executes from page 0FH in external memory. (The 80C196NU has no EA# input.)
For devices without internal nonvolatile memory, EA# must be tied low, and code executes only from page 0FH in external memory.
Code in all locations except FF2000–FF2FFFH executes from external memory.
Instruction fetches from FF2000–FF2FFFH are controlled by the EA# input:
Data fetches are the same in the 1-Mbyte and 64-Kbyte modes. The device can access data in any page. Data accesses to page 00H are nonextended. Data accesses to any other page are extended.
Data accesses to the register file (0000–03FFH) and the SFRs (1F00–1FFFH) are directed to the internal registers. All other data accesses are directed to external memory.
Data accesses to the register file (0000–03FFH) and the SFRs (1F00–1FFFH) are directed to the internal registers. Accesses to other locations are directed to external memory, except as noted below:
Data accesses to FF2000–FF2FFFH depend on the EA# input:

Data accesses to 002000–002FFFH depend on the REMAP bit and the EA# input:
— If EA# is low, accesses are external (REMAP is ignored).
— If EA# is high, accesses are to the internal ROM.
This section provides examples of memory configurations for both 64-Kbyte and 1-Mbyte mode. Each example consists of a circuit diagram and a memory map that describes how the address space is implemented. Chapter 13, “Interfacing with External Memory,” discusses the interface in detail and provides additional examples.
Figure 5-9 shows a system designed for operation in the 64-Kbyte mode. Code executes only from page FFH, which is implemented by the 64-Kbyte flash memory. The 32-Kbyte RAM in the upper half of page 00H stores near data. Table 5-12 on page 5-28 lists the memory addresses for this example. (For memory map details, see Table 5-1 on page 5-4.)
CS0#
Flash 64Kx8 Code & Data
RAM 32Kx8 Data 008000– 00FFFFH
FF0000– FFFFFFH
AD7:0
AD7:0
AD7:0
D7:0
D7:0
OE# WE#
OE# WE#
RD#
WR#
Figure 5-9. A 64-Kbyte System With an 8-bit Bus
80C196NP and 80C196NU: The flash memory, which implements page FFH, holds the special- purpose memory (FF2000–FF207FH), code, and far constants.
CE# Page FFH · CE# Page 00H

83C196NP only: Locations FF2000–FF2FFFH, which store code and special-purpose memory, are implemented by internal ROM. Data accesses to locations FF2000–FF2FFFH are directed to the flash memory if EA# is low and to internal ROM if EA# is high. Locations FF2000–FF2FFFH can be remapped to page 00H by setting the REMAP bit (CCB1.2). An access to the remapped area, 002000–002FFFH, is directed to ROM if EA# is high and to external memory if EA# is low. With remapping enabled (REMAP = 1) and EA# high, the far constants in the special-purpose memory can be accessed as near constants in page 00H.
FFFFFFH
FF3000H External flash memory (code or far constants)
Program memory: 80C196NP and 80C196NU: External flash memory 83C196NP: Internal ROM (EA# = 1), external memory (EA# = 0)
FF1FFFH FF0100H External flash memory (code or far constants)
00FFFFH 008000H 32-Kbyte external RAM (near data)
002FFFH 002000H 80C196NP and 80C196NU: Unimplemented 83C196NP: Program and special-purpose memory remapped from internal ROM (REMAP = 1; EA# = 1)
001FFFH 001F00H Internal peripheral special-function registers (SFRs)
001EFFH 001C00H Unimplemented (future SFR expansion)
0003FFH 000100H Upper register file (general-purpose register RAM)
0000FFH 000018H Lower register file (general-purpose register RAM and stack pointer)
000017H 000000H Lower register file (CPU SFRs)

5.6.2 Example 2: A 64-Kbyte System with Additional Data Storage
Figure 5-10 shows another system designed for operation in the 64-Kbyte mode. Code executes from page FFH only. This system is the same as the example in “Example 1: Using the 64-Kbyte Mode” on page 5-27, but with additional RAM. The 64-Kbyte RAM stores near data in page 00H. The 128-Kbyte RAM stores far data in pages 01H and 02H. Table 5-13 lists the memory address- es. (For memory map details, see Table 5-1 on page 5-4.)
80C196NP and 80C196NU: The flash memory, which implements page FFH, holds the special- purpose memory (FF2000–FF207FH), code, and far constants.
83C196NP only: Locations FF2000–FF2FFFH, which store code and special-purpose memory, are implemented by internal ROM. Data accesses to locations FF2000–FF2FFFH are directed to the flash memory if EA# is low and to internal ROM if EA# is high. Locations FF2000–FF2FFFH can be remapped to page 00H by setting the REMAP bit (CCB1.2). An access to the remapped area, 002000–002FFFH, is directed to ROM if EA# is high and to external memory if EA# is low. With remapping enabled (REMAP = 1) and EA# high, the far constants in the special-purpose memory can be accessed as near constants in page 00H.
CS1#
CS0#
Flash 64Kx8 Code & Data
RAM 64Kx8 Data 000000– 00FFFFH
RAM 128Kx8 Data 010000– 02FFFFH
FF0000– FFFFFFH
AD7:0
AD7:0
AD7:0
AD7:0
D7:0
D7:0
D7:0
OE# WE#
OE# WE#
OE#
WE#
RD#
WR#
Figure 5-10. A 64-Kbyte System with Additional Data Storage
CE# Page FFH · CE# Page 00H · CE# Pages 01-02H

FFFFFFH
FF3000H External flash memory (code or far constants)
Program memory: 80C196NP and 80C196NU: External flash memory 83C196NP: Internal ROM (EA# = 1), external memory (EA# = 0)
FF1FFFH FF0100H External flash memory (code or far constants)
02FFFFH 010000H 128-Kbyte external RAM (far data)
00FFFFH 003000H External RAM (near data)
002FFFH 002000H 80C196NP and 80C196NU: External RAM 83C196NP: External RAM (CCB1.2 = 0) or remapped internal ROM (CCB1.2 = 1)
001FFFH 001F00H Internal peripheral special-function registers (SFRs)
001EFFH 001C00H External RAM (future SFR expansion)
001BFFH 000400H External RAM (near data)
0003FFH 000100H Upper register file (general-purpose register RAM)
0000FFH 000018H Lower register file (general-purpose register RAM and stack pointer)
000017H 000000H Lower register file (CPU SFRs)
Address Description · FF00FFH FF0000H Reserved · 030000H Unimplemented

5.6.3 Example 3: Using 1-Mbyte Mode
Figure 5-11 shows a system designed for operation in the 1-Mbyte mode. In this mode, code can execute from any page in the 1-Mbyte memory space. The system uses both 8-bit and 16-bit buses and uses the write-strobe mode. (See Chapter 13, “Interfacing with External Memory.”)
The 32K×8 RAM stores near data in the upper half of page 00H. The 32K×16 RAM stores far data in page 01H. Using the WRL# and WRH# signals makes this RAM both byte- and word- accessible. The 128K×16 flash memory stores code and far constants in pages FCH, FDH, FEH, and FFH. With the write-signals connected as shown, the flash memory is word-accessible only. Table 5-14 lists the memory addresses. (For memory map details, see Table 5-3 on page 5-6.)
83C196NP only. The code and data in FF2000–FF2FFFH are implemented by internal ROM. Remapping this area into page 00H by setting the REMAP bit (CCB1.2) makes the far constants in FF2000–FF2FFFH of ROM accessible as near constants. An access to this address range is di- rected to external memory if EA# is low and to internal ROM if EA# is high.
CS1#
CS0#
Flash 128Kx16 Code & Data
RAM 32Kx8 Data 008000– 00FFFFH
RAM 32Kx16 Data 010000– 01FFFFH
FC0000 FFFFFFH
AD15:0
AD7:0
AD15:0
AD15:0
D15:0
D7:0
D15:0
OE# WE#
OE# WE#
OE# WRH#
WRL#
RD#
WRH#
WRL#
Figure 5-11. Example System Using the 1-Mbyte Mode
CE# Pages FC–FFH · CE# Page 00H · CE# Page 01H

FFFFFFH
FF3000H External memory (code or far constants)
Program memory: 80C196NP and 80C196NU: External memory 83C196NP: Internal ROM (EA# = 1), external memory (EA# = 0)
FF1FFFH FF0100H External flash memory (code or far constants)
FEFFFFH FC0000H External flash memory (far code, far constants)
01FFFFH 010000H 64-Kbyte external RAM (far data)
00FFFFH 008000H 32-Kbyte external RAM (near data)
00207FH
80C196NP and 80C196NU: Unimplemented 83C196NP: Special-purpose memory (near constants) remapped from internal ROM (CCB1.2 = 1; EA# = 1)
001FFFH 001F00H Internal peripheral special-function registers (SFRs)
001EFFH 001C00H Unimplemented (future SFR expansion)
0003FFH 000100H Upper register file (general-purpose register RAM)
0000FFH 000018H Lower register file (general-purpose register RAM and stack pointer)
000017H 000000H Lower register file (CPU SFRs)




This chapter describes the interrupt control circuitry, priority scheme, and timing for standard and peripheral transaction server (PTS) interrupts. It discusses the three special interrupts and the four PTS modes, two of which are used with the EPA to produce pulse-width modulated (PWM) out- puts. It also explains interrupt programming and control.
The interrupt control circuitry within a microcontroller permits real-time events to control pro- gram 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 ser- viced, program execution resumes at the point where the interrupt occurred. An internal periph- eral, an external signal, 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 two main components: the pro- grammable interrupt controller and the peripheral transaction server (PTS). The programmable interrupt controller has a hardware priority scheme that can be modified by your software. Inter- rupts that go through the interrupt controller are serviced by interrupt service routines that you provide. The upper and lower interrupt vectors in special-purpose memory (see Chapter 5, “Memory Partitions”) contain the lower 16 bits of the interrupt service routines’ addresses. The CPU automatically adds FF0000H to the 16-bit vector in special-purpose memory to calculate the address of the interrupt service routine, and then executes the routine. The peripheral transaction server (PTS), a microcoded hardware interrupt processor, provides high-speed, low-overhead in- terrupt handling; it does not modify the stack or the PSW. You can configure most interrupts (ex- cept NMI, trap, and unimplemented opcode) to be serviced by the PTS instead of the interrupt controller.
The PTS supports four special microcoded routines that enable it to complete specific tasks in much less time than an equivalent interrupt service routine can. It can transfer bytes or words, either individually or in blocks, between any memory locations in page 00H and can generate pulse-width modulated (PWM) signals. PTS interrupts have a higher priority than standard inter- rupts and may temporarily suspend interrupt service routines.
A block of data called the PTS control block (PTSCB) contains the specific details for each PTS routine (see “Initializing the PTS Control Blocks” on page 6-17). When a PTS interrupt occurs, the priority encoder selects the appropriate vector and fetches the PTS control block (PTSCB).

Interrupt Pending or PTSSRV Bit Set
INT_MASK.x
PTSSEL.x
Highest Priority PTS Interrupt
PTSSRV.x
Reset INT_PEND.x
Bit Reset PTSSRV.x
Reset INT_PEND.x
Execute 1 PTS Cycle
ISR
PTSCOUNT
Clear PTSSEL.x Bit
POP PC from Stack
Set PTSSRV.x Bit

Figure 6-1 illustrates the interrupt processing flow. In this flow diagram, “INT_MASK” repre- sents both the INT_MASK and INT_MASK1 registers, and “INT_PEND” represents both the INT_PEND and INT_PEND1 registers.
Table 6-1 describes the external interrupt signals and Table 6-2 describes the control and status registers for both the interrupt controller and PTS.
Port Pin Interrupt Signal Type Description
EXTINT0 EXTINT1 EXTINT2 EXTINT3
In normal operating mode, a rising edge on EXTINTx sets the EXTINTx interrupt pending bit. EXTINTx is sampled during phase 2 (CLKOUT high). The minimum high time is one state time.
In standby and powerdown modes, asserting the EXTINTx signal for at least 50 ns causes the device to resume normal operation. The interrupt need not be enabled, but the pin must be configured as a special-function input (see “Bidirec- tional Port Pin Configurations” on page 7-7). If the EXTINTx interrupt is enabled, the CPU executes the interrupt 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.
— NMI I Nonmaskable Interrupt
In normal operating mode, a rising edge on NMI generates a nonmaskable interrupt. NMI has the highest priority of all prioritized interrupts. Assert NMI for greater than one state time to guarantee that it is recognized.
EPA_MASK 1FA0H, 1FA1H EPA Interrupt Mask Register
This register enables/disables the four capture overrun interrupts (OVR0-3).
EPA_PEND 1FA2H, 1FA3H EPA Interrupt Pending Register
The bits in this register are set by hardware to indicate that a capture overrun has occurred.
0008H
INT_MASK1
0013H
These registers enable/disable each maskable interrupt (that is, each interrupt except unimplemented opcode, software trap, and NMI).
I External Interrupts · Mnemonic Address Description · Interrupt Mask Registers

INT_PEND
0009H
INT_PEND1
0012H
The bits in this register are set by hardware to indicate that an interrupt is pending.
PSW No direct access Processor Status Word
This register contains one bit that globally enables or disables servicing of all maskable interrupts and another that enables or disables the PTS. These bits are set or cleared by executing the enable interrupts (EI), disable interrupts (DI), enable PTS (EPTS), and disable PTS (DPTS) instructions.
PTSSEL 0004H, 0005H PTS Select Register
This register selects either a PTS routine or a standard interrupt service routine for each of the maskable interrupt requests.
PTSSRV 0006H, 0007H PTS Service Register
The bits in this register are set by hardware to request an end-of- PTS interrupt.
Table 6-3 lists the interrupts sources, their default priorities (30 is highest and 0 is lowest), and their vector addresses. The unimplemented opcode and software trap interrupts are not priori- tized; they go directly to the interrupt controller for servicing. The priority encoder determines 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 selects the highest priority pending request and the interrupt controller se- lects the corresponding vector location in special-purpose memory. This vector contains the start- ing (base) address of the corresponding PTS control block (PTSCB) or interrupt service routine. PTSCBs must be located on a quad-word boundary in the internal register file. Interrupt service routines must begin execution in page FFH, but can jump anywhere after the initial vector is tak- en.
This microcontroller has three special interrupt sources that are always enabled: unimplemented opcode, software trap, and NMI. These interrupts are not affected by the EI (enable interrupts) and DI (disable interrupts) instructions, and they cannot be masked. 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 encoder. The other two special interrupts go di- rectly to the interrupt controller for servicing. Be aware that these interrupts are often assigned to special functions in development tools.
Mnemonic Address Description · Interrupt Pending Registers

Table 6-3. Interrupt Sources, Vectors, and Priorities
Nonmaskable Interrupt NMI INT15 FF203EH 30 — — —
EXTINT3 Pin EXTINT3 INT14 FF203CH 14 PTS14 FF205CH 29
EXTINT2 Pin EXTINT2 INT13 FF203AH 13 PTS13 FF205AH 28
EPA capture overrun in channel 2 or 3 OVR2_3 † INT12 FF2038H 12 PTS12 FF2058H 27
EPA capture overrun in channel 0 or 1 OVR0_1 † INT11 FF2036H 11 PTS11 FF2056H 26
EPA Capture/Compare 3 EPA3 INT10 FF2034H 10 PTS10 FF2054H 25
EPA Capture/Compare 2 EPA2 INT09 FF2032H 09 PTS09 FF2052H 24
EPA Capture/Compare 1 EPA1 INT08 FF2030H 08 PTS08 FF2050H 23
Unimplemented Opcode — — FF2012H —
Software TRAP Instruction — — 0FF2010H —
EPA Capture/Compare 0 EPA0 INT07 FF200EH 07 PTS07 FF204EH 22
SIO Receive RI INT06 FF200CH 06 PTS06 FF204CH 21
SIO Transmit TI INT05 FF200AH 05 PTS05 FF204AH 20
EXTINT1 Pin EXTINT1 INT04 FF2008H 04 PTS04 FF2048H 19
EXTINT0 Pin EXTINT0 INT03 FF2006H 03 PTS03 FF2046H 18
Reserved Reserved INT02 FF2004H 02 PTS02 FF2044H 17
Timer 2 Overflow OVRTM2 INT01 FF2002H 01 PTS01 FF2042H 16
Timer 1 Overflow OVRTM1 INT00 FF2000H 00 PTS00 FF2040H 15
† PTS service is not recommended because the PTS cannot determine the source of shared interrupts.
If the CPU attempts to execute an unimplemented opcode, an indirect vector through location FF2012H occurs. This prevents random software execution during hardware and software fail- ures. The interrupt vector should contain the starting address of an error routine that will not fur- ther corrupt an already erroneous situation. The unimplemented opcode interrupt prevents other interrupt requests from being acknowledged until after the next instruction is executed.
The TRAP instruction (opcode F7H) causes an interrupt call that is vectored through location FF2010H. The TRAP instruction provides a single-instruction interrupt that is useful when de- bugging software or generating software interrupts. The TRAP instruction prevents other inter- rupt requests from being acknowledged until after the next instruction is executed.

The external NMI pin generates a nonmaskable interrupt for implementation of critical interrupt routines. NMI has the highest priority of all the prioritized interrupts. It is passed directly from the transition detector to the priority encoder, and it vectors indirectly through location FF203EH. The NMI pin is sampled during phase 2 (CLKOUT high) and is latched internally. Because inter- rupts are edge-triggered, only one interrupt is generated, even if the pin is held high. If your sys- tem does not use the NMI interrupt, connect the NMI pin to VSS to prevent spurious interrupts.
The external interrupt pins are multiplexed with port pins as follows: EXTINT0/P2.2, EXTINT1/P2.4, EXTINT2/P3.6, and EXTINT3/P3.7. Writing to a bit in the Px_MODE register also sets the corresponding external interrupt bit in the interrupt pending register. To prevent false interrupts, first configure the port pins and then clear the interrupt pending registers before glo- bally enabling interrupts. See “Design Considerations for External Interrupt Inputs” on page 7-11.
The interrupt detection logic can generate an interrupt if a momentary negative glitch occurs while the input pin is held high. For this reason, interrupt inputs should normally be held low when they are inactive.
The overrun errors for the four capture/compare modules are multiplexed into two interrupt pairs: OVR0_1 (channels 0 and 1) and OVR2_3 (channels 2 and 3). Generally, PTS interrupt service is not useful for multiplexed interrupts because the PTS cannot readily determine the interrupt source. Your interrupt service routine should read the EPA_PEND register to determine the source of the interrupt and to ensure that no additional interrupts are pending before executing the return instruction. Chapter 10, “Event Processor Array (EPA),” discusses the EPA interrupts in detail.
When the PTSCOUNT register decrements to zero at the end of a single transfer or block transfer routine, hardware clears the corresponding bit in the PTSSEL register, which disables PTS service for that interrupt. It also sets the corresponding PTSSRV bit, requesting an end-of-PTS interrupt. An end-of-PTS 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 SIO transmit inter-

rupt if PTSSEL.5 is set. The interrupt vectors through FF204AH, but the corresponding end-of- PTS interrupt vectors through FF200AH, the standard SIO transmit 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 appro- priate PTSSEL bit to re-enable PTS interrupt service.
Interrupt latency is the total delay between the time that the interrupt request is generated (not acknowledged) and the time that the device begins executing either the standard interrupt service routine or the PTS interrupt service routine. A delay occurs between the time that the interrupt request is detected and the time that it is acknowledged. An interrupt request is acknowledged when the current instruction finishes executing. If the interrupt request occurs during one 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 delay between interrupt request and ac- knowledgment is four state times plus the execution time of the next instruction.
When a standard interrupt request is acknowledged, the hardware clears the interrupt pending bit and forces a call to the address contained in the corresponding interrupt vector. When a PTS in- terrupt request is acknowledged, the hardware immediately vectors to the PTSCB and begins ex- ecuting the PTS routine.
If an interrupt request occurs while any of the following instructions are executing, the interrupt will not be acknowledged until after the next instruction is executed:
Both the unimplemented opcode interrupt and the software trap interrupt prevent other interrupt requests from being acknowledged until after the next instruction is executed.
Each PTS cycle within a PTS routine cannot be interrupted. A PTS cycle is the entire PTS re- sponse 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 Table 6-4 on page 6-10 for PTS cycle execution times.

The maximum latency occurs when the interrupt request occurs too late for acknowledgment fol- lowing the current instruction. The following worst-case calculation assumes that the current in- struction is not a protected instruction. To calculate latency, add the following terms:
— in 64-Kbyte mode, 11 state times for an internal stack or 13 for an external stack (assuming a zero-wait-state bus)
— in 1-Mbyte mode, 15 state times for an internal stack or 18 for an external stack (assuming a zero-wait-state bus)
In 64-Kbyte mode, the worst-case delay for a standard interrupt is 56 state times (4 + 39 + 11 + 2) if the stack is in external memory (Figure 6-2). In 1-Mbyte mode, the worst-case delay increas- es to 61 state times (4 + 39 + 15 + 3) (Figure 6-2). This delay time does not include the time need- ed to execute the first instruction in the interrupt service routine or to execute the instruction following a protected instruction.


6.4.2.2 PTS Interrupt Latency
In both 64-Kbyte and 1-Mbyte modes, the maximum delay for a PTS interrupt is 43 state times (4 + 39) as shown in Figure 6-3. 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 6-4 for execution times for PTS cycles.


PTS Mode Execution Time (in State Times)
register/register† memory/register† memory/memory†
18 per byte or word transfer + 1 21 per byte or word transfer + 1 24 per byte or word transfer + 1
register/register† memory/register† memory/memory†
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)
PWM remap mode 15
PWM toggle mode 15
† Register indicates an access to the register file or peripheral SFR. Memory indicates an access to a memory-mapped register, I/O, or memory. See Table 5-1 on page 5-4 for address information.
The PTS select register (PTSSEL) selects either PTS service or a standard software interrupt ser- vice routine for each of the maskable interrupt requests (see Figure 6-4). The interrupt mask reg- isters, INT_MASK and INT_MASK1, enable or disable (mask) individual interrupts (see Figures 6-5 and 6-6). With the exception of the nonmaskable interrupt (NMI) bit (INT_MASK1.7), setting a bit enables the corresponding interrupt source and clearing a bit dis- ables the source.
To disable any interrupt, clear its mask bit. To enable an interrupt for standard interrupt service, set its mask bit and clear its PTS select bit. To enable an interrupt for PTS service, set both the mask bit and the PTS select bit.
When you assign an interrupt to the PTS, you must set up a PTS control block (PTSCB) for each interrupt source (see “Initializing the PTS Control Blocks” on page 6-17) and use the EPTS in- struction to globally enable the PTS. When you assign an interrupt to a standard software service routine, use the EI (enable interrupts) instruction to globally enable interrupt servicing.
Single transfer mode · Block transfer mode

The PTS select (PTSSEL) register selects either a PTS microcode routine or a standard interrupt service routine for each interrupt request. Setting a bit selects a PTS microcode routine; clearing a bit selects a standard interrupt service routine. When PTSCOUNT reaches zero, hardware clears the corresponding PTSSEL bit. The PTSSEL bit must be set manually to re-enable the PTS channel.
EPA0 RI TI EXTINT1 EXTINT0 — OVRTM2 OVRTM1
15, 2 Reserved; for compatibility with future devices, write zero to this bit.
14:3 1:0 Setting a bit causes the corresponding interrupt to be handled by a PTS microcode routine.
The PTS interrupt vector locations are as follows:
Bit Mnemonic Interrupt PTS Vector EXTINT3 EXTINT3 pin FF205CH EXTINT2 EXTINT2 pin FF205AH OVR2_3† EPA Capture Channel 2 or 3 Overrun FF2058H OVR0_1† EPA Capture Channel 0 or 1 Overrun FF2056H EPA3 EPA Capture/Compare Channel 3 FF2054H EPA2 EPA Capture/Compare Channel 2 FF2052H EPA1 EPA Capture/Compare Channel 1 FF2050H EPA0 EPA Capture/Compare Channel 0 FF204EH RI SIO Receive FF204CH TI SIO Transmit FF204AH EXTINT1 EXTINT1 pin FF2048H EXTINT0 EXTINT0 pin FF2046H OVRTM2 Timer 2 Overflow/ Underflow FF2042H OVRTM1 Timer 1 Overflow/ Underflow FF2040H
† PTS service is not recommended because the PTS cannot determine the source of shared interrupts.
6.5.1 Programming Considerations for Multiplexed Interrupts
An overrun on the EPA capture compare channels can generate the multiplexed capture overrun interrupts (OVR0_1 and OVR2_3). Write to the EPA_MASK (Figure 10-11 on page 10-22) reg- ister to enable or disable the multiplexed interrupt sources and the INT_MASK1 register to en- able or disable the OVR0_1 and OVR2_3 interrupts.
PTS service is not recommended for multiplexed interrupts because it cannot determine the inter- rupt source.
Bit Number Function

The interrupt mask (INT_MASK) register enables or disables (masks) individual interrupt requests. (The EI and DI instructions enable and disable servicing of all maskable interrupts.) INT_MASK is the low byte of the processor status word (PSW); therefore, PUSHF or PUSHA saves this register on the stack and POPF or POPA restores it.
7:3 1:0 Setting a bit enables the corresponding interrupt.
The standard interrupt vector locations are as follows:
Bit Mnemonic Interrupt Standard Vector EPA0 EPA Capture/Compare Channel 0 FF200EH RI SIO Receive FF200CH TI SIO Transmit FF200AH EXTINT1 EXTINT1 pin FF2008H EXTINT0 EXTINT0 pin FF2006H OVRTM2 Timer 2 Overflow/Underflow FF2002H OVRTM1 Timer 1 Overflow/Underflow FF2000H
2 Reserved; for compatibility with future devices, write zero to this bit.
Bit Number Function

The interrupt mask 1 (INT_MASK1) register enables or disables (masks) individual interrupt requests. (The EI and DI instructions enable and disable servicing of all maskable interrupts.) INT_MASK1 can be read from or written to as a byte register. PUSHA saves this register on the stack and POPA restores it.
7:0 Setting a bit enables the corresponding interrupt.
The standard interrupt vector locations are as follows:
Bit Mnemonic Interrupt Standard Vector NMI Nonmaskable Interrupt FF203EH EXTINT3 EXTINT3 pin FF203CH EXTINT2 EXTINT2 pin FF203AH OVR2_3† EPA Capture Channel 2 or 3 Overrun FF2038H OVR0_1† EPA Capture Channel 0 or 1 Overrun FF2036H EPA3 EPA Capture/Compare Channel 3 FF2034H EPA2 EPA Capture/Compare Channel 2 FF2032H EPA1 EPA Capture/Compare Channel 1 FF2030H
† An overrun on the EPA capture/compare channels can generate the multiplexed capture overrun interrupts. The EPA_MASK and EPA_PEND registers decode these multiplexed interrupts. Write to EPA_MASK to enable the interrupt sources; read EPA_PEND to determine which source caused the interrupt.
6.5.2 Modifying Interrupt Priorities
Your software can modify the default priorities of maskable interrupts by controlling the interrupt mask registers (INT_MASK and INT_MASK1). For example, you can specify which interrupts, if any, can interrupt an interrupt service routine. The following code shows one way to prevent all interrupts, except EXTINT3 (priority 14), from interrupting an SIO receive interrupt service routine (priority 06).
Bit Number Function

PUSHA ; Save PSW, INT_MASK, INT_MASK1, & WSR ; (this disables all interrupts) LDB INT_MASK1, #01000000B ; Enable EXTINT3 only EI ; Enable interrupt servicing
; Service the RI interrupt
POPA ; Restore PSW, INT_MASK, INT_MASK1, & ; WSR registers RET
CSEG AT 0FF200CH ; fill in interrupt table
DCW LSW SERIAL_RI_ISR ; LSW is a compiler directive that means ; least-significant word of vector address
This routine, like all interrupt service routines, is handled in the following manner:
2. The PUSHA instruction saves the contents of the PSW, INT_MASK, INT_MASK1, and window selection register (WSR) onto the stack and then clears the PSW, INT_MASK, and INT_MASK1 registers. In addition to the arithmetic flags, the PSW contains the global interrupt enable bit (I) and the PTS enable bit (PSE). By clearing the PSW and the interrupt mask registers, PUSHA effectively masks all maskable interrupts, disables standard interrupt servicing, and disables the PTS. Because PUSHA is a protected instruction, it also inhibits interrupt calls until after the next instruction executes.

Notice that the “preamble” and exit code for this routine does not save or restore register RAM. The interrupt service routine is assumed to allocate its own private set of registers from the lower register file. The general-purpose register RAM in the lower register file makes this quite practi- cal. In addition, the RAM in the upper register file is available via windowing (see “Windowing” on page 5-13).
When the transition detector detects an interrupt, it sets the corresponding bit in the INT_PEND or INT_PEND1 register (Figures 6-7 and 6-8). This bit is set even if the individual interrupt is disabled (masked). The pending bit is cleared when the program vectors to the interrupt service routine. INT_PEND and INT_PEND1 can be read, to determine which interrupts are pending. They can also be modified (written), either to clear pending interrupts or to generate interrupts under software control. However, we recommend the use of the read-modify-write instructions, such as AND and OR, to modify these registers.
ANDB INT_PEND, #11111110B ; Clears the OVRTM1 pending bit ORB INT_PEND, #00000001B ; Sets the OVRTM1 pending bit
Other methods could result in a partial interrupt cycle. For example, an interrupt could occur dur- ing an instruction sequence that loads the contents of the interrupt pending register into a tempo- rary register, modifies the contents of the temporary register, and then writes the contents of the temporary register back into the interrupt pending register. If the interrupt occurs during one of the last four states of the second instruction, it will not be acknowledged until after the completion of the third instruction. Because the third instruction overwrites the contents of the interrupt pend- ing register, the jump to the interrupt vector will not occur.
An overrun on the EPA capture compare channels can generate the multiplexed capture overrun interrupts (OVR0_1 and OVR2_3). Read the EPA_PEND register to determine the source of the interrupt request (Figure 10-12 on page 10-23).

When hardware detects a pending interrupt, it sets the corresponding bit in the interrupt pending (INT_PEND or INT_PEND1) registers. When the vector is taken, the hardware clears the pending bit. Software can generate an interrupt by setting the corresponding interrupt pending bit.
7:3 1:0 Any set bit indicates that the corresponding interrupt is pending. The interrupt bit is cleared when processing transfers to the corresponding interrupt vector.
The standard interrupt vector locations are as follows:
Bit Mnemonic Interrupt Standard Vector EPA0 EPA Capture/Compare Channel 0 FF200EH RI SIO Receive FF200CH TI SIO Transmit FF200AH EXTINT1 EXTINT1 pin FF2008H EXTINT0 EXTINT0 pin FF2006H OVRTM2 Timer 2 Overflow/Underflow FF2002H OVRTM1 Timer 1 Overflow/Underflow FF2000H
2 Reserved. This bit is undefined.
Bit Number Function

When hardware detects a pending interrupt, it sets the corresponding bit in the interrupt pending (INT_PEND or INT_PEND1) registers. When the vector is taken, the hardware clears the pending bit. Software can generate an interrupt by setting the corresponding interrupt pending bit.
7:0 Any set bit indicates that the corresponding interrupt is pending. The interrupt bit is cleared when processing transfers to the corresponding interrupt vector.
The standard interrupt vector locations are as follows:
Bit Mnemonic Interrupt Standard Vector NMI Nonmaskable Interrupt FF203EH EXTINT3 EXTINT3 pin FF203CH EXTINT2 EXTINT2 pin FF203AH OVR2_3† EPA Capture Channel 2 or 3 Overrun FF2038H OVR0_1† EPA Capture Channel 0 or 1 Overrun FF2036H EPA3 EPA Capture/Compare Channel 3 FF2034H EPA2 EPA Capture/Compare Channel 2 FF2032H EPA1 EPA Capture/Compare Channel 1 FF2030H
† An overrun on the EPA capture/compare channels can generate the multiplexed capture overrun interrupts. The EPA_MASK and EPA_PEND registers decode these multiplexed interrupts. Write to EPA_MASK to enable the interrupt sources; read EPA_PEND to determine which source caused the interrupt.
6.6 INITIALIZING THE PTS CONTROL BLOCKS
Each PTS interrupt requires a block of data, in register RAM, called the PTS control block (PTSCB). The PTSCB identifies which PTS microcode routine will be invoked and sets up the specific parameters for the routine. You must set up the PTSCB for each interrupt source before enabling the corresponding PTS interrupts.
Bit Number Function

The address of the first (lowest) PTSCB byte is stored in the PTS vector table in special-purpose memory (see “Special-purpose Memory” on page 5-6). Figure 6-9 shows the PTSCB for each PTS mode. Unused PTSCB bytes can be used as extra RAM.
NOTE The PTSCB must be located in the internal register file. The location of the first byte of the PTSCB must be aligned on a quad-word boundary (an address evenly divisible by 8). Because the PTS uses nonextended addressing, it cannot operate across page boundaries. For example, PTSSRC cannot point to a location on page 05 while PTSDST points to page 00. In the 8XC196NP, all nonextended data accesses will operate from the page defined by EP_REG. For PTS routines, write 00H to EP_REG to select page 00H (see “Accessing Data” on page 5-23). The 80C196NU forces all nonextended data accesses to page 00H. You cannot use EP_REG to change pages.
Single Transfer Block Transfer PWM Toggle
Unused Unused PTSCONST2 (H) Unused
Unused PTSBLOCK PTSCONST2 (L) Unused
PTSDST (L) PTSDST (L) PTSCONST1 (L) PTSCONST1 (L)
PTSSRC (H) PTSSRC (H) PTSPTR1 (H) PTSPTR1 (H)
PTSSRC (L) PTSSRC (L) PTSPTR1 (L) PTSPTR1 (L)
PTSCON PTSCON PTSCON PTSCON
PTSVECT PTSCOUNT PTSCOUNT Unused Unused
6.6.1 Specifying the PTS Count
For single and block transfer routines, the first location of the PTSCB contains an 8-bit value called PTSCOUNT. This value defines the number of interrupts that will be serviced by the PTS routine. The PTS decrements PTSCOUNT after each PTS cycle. When PTSCOUNT reaches zero, hardware clears the corresponding PTSSEL bit and sets the PTSSRV bit (Figure 6-10), which re- quests an end-of-PTS interrupt. The end-of-PTS interrupt service routine should reinitialize the PTSCB, if required, and set the appropriate PTSSEL bit to re-enable PTS interrupt service.
PWM Remap · Mode · Mode

The PTS service (PTSSRV) register is used by the hardware to indicate that the final PTS interrupt has been serviced by the PTS routine. When PTSCOUNT reaches zero, hardware clears the corre- sponding PTSSEL bit and sets the PTSSRV bit, which requests the end-of-PTS interrupt. When the end-of-PTS interrupt is called, hardware clears the PTSSRV bit. The PTSSEL bit must be set manually to re-enable the PTS channel.
EPA0 RI TI EXTINT1 EXTINT0 — OVRTM1 OVRTM2
15, 2 Reserved. These bits are undefined.
14:3 1:0 A bit is set by hardware to request an end-of-PTS interrupt for the corresponding interrupt through its standard interrupt vector.
The standard interrupt vector locations are as follows.
Bit Mnemonic Interrupt Standard Vector EXTINT3 EXTINT3 Pin FF203CH EXTINT2 EXTINT2 Pin FF203AH OVR2_3† EPA Capture Channel 2 or 3 Overrun FF2038H OVR0_1† EPA Capture Channel 0 or 1 Overrun FF2036H EPA3 EPA Capture/Compare Channel 3 FF2034H EPA2 EPA Capture/Compare Channel 2 FF2032H EPA1 EPA Capture/Compare Channel 1 FF2030H EPA0 EPA Capture/Compare Channel 0 FF200EH RI SIO Receive FF200CH TI SIO Transmit FF200AH EXTINT1 EXTINT1 pin FF2008H EXTINT0 EXTINT0 pin FF2006H OVRTM2 Timer 2 Overflow/Underflow FF2002H OVRTM1 Timer 1 Overflow/Underflow FF2000H
† PTS service is not recommended for multiplexed interrupts. This bit is cleared when both corresponding interrupt pending bits are cleared in EPA_PEND.
6.6.2 Selecting the PTS Mode
The second byte of each PTSCB is always an 8-bit value called PTSCON. Bits 5–7 select the PTS mode (Figure 6-11). The function of bits 0–4 differ for each PTS mode. Refer to the sections that describe each mode in detail to see the function of these bits. Table 6-4 on page 6-10 lists the cycle execution times for each PTS mode.
Bit Number Function

The PTS control (PTSCON) register selects the PTS mode and sets up control functions for that mode.
7:5 M2:0 PTS Mode
These bits select the PTS mode:
M2 M1 M0 0 0 0 block transfer 0 0 1 reserved 0 1 0 PWM toggle or remap 0 1 1 reserved 1 0 0 single transfer 1 0 1 reserved 1 1 0 reserved 1 1 1 reserved
† The function of this bit depends upon which mode is selected. See the PTS control block description in each PTS mode section.
6.6.3 Single Transfer Mode
In single transfer mode, an interrupt causes the PTS to transfer a single byte or word (selected by the BW bit in PTSCON) from one memory location to another. This mode is typically used with serial I/O or synchronous serial I/O interrupts. It can also be used with the EPA to move captured time values from the event-time register to internal RAM for further processing. See AP-445, 8XC196KR Peripherals: A User’s Point of View, for application examples with code. Figure 6-12 shows the PTS control block for single transfer mode.
Bit Number · Bit Mnemonic Function

PTS Single Transfer Mode Control Block
In single transfer mode, the PTS control block contains a source and destination address (PTSSRC and PTSDST), a control register (PTSCON), and a transfer count (PTSCOUNT).
Unused 0
Unused 0
PTSDST (HI) PTS Destination Address (high byte)
PTSDST (LO) PTS Destination Address (low byte)
PTSSRC (HI) PTS Source Address (high byte)
PTSSRC (LO) PTS Source Address (low byte)
PTSCON M2 M1 M0 BW SU DU SI DI
PTSCOUNT Consecutive Byte or Word Transfers
PTSDST PTSCB + 4 PTS Destination Address
Write the destination memory location to this register. A valid address is any unreserved memory location within page 00H; however, it must point to an even address if word transfers are selected.
PTSSRC PTSCB + 2 PTS Source Address
Write the source memory location to this register. A valid address is any unreserved memory location within page 00H; however, it must point to an even address if word transfers are selected.
Register Location Function

PTS Single Transfer Mode Control Block (Continued)
PTSCON PTSCB + 1 PTS Control Bits
M2:0 PTS Mode
M2 M1 M0 1 0 0 single transfer mode
0 = word transfer 1 = byte transfer
SU† Update PTSSRC
0 = reload original PTS source address after each byte or word transfer 1 = retain current PTS source address after each byte or word transfer
DU† Update PTSDST
0 = reload original PTS destination address after each byte or word transfer 1 = retain current PTS destination address after each byte or word transfer
SI† PTSSRC Autoincrement
0 = do not increment the contents of PTSSRC after each byte or word transfer 1 = increment the contents of PTSSRC after each byte or word transfer
DI† PTSDST Autoincrement
0 = do not increment the contents of PTSDST after each byte or word transfer 1 = increment the contents of PTSDST after each byte or word transfer
PTSCOUNT PTSCB + 0 Consecutive Word or Byte Transfers
Defines the number of words or bytes that will be transferred during the single transfer routine. Each word or byte transfer is one PTS cycle. Maximum value is 255.
† The DU/DI bits and SU/SI bits are paired in single transfer mode. Each pair must be set or cleared together. However, the two pairs, DU/DI and SU/SI, need not be equal.
The PTSCB in Table 6-5 defines nine PTS cycles. Each cycle moves a single word from location 20H to an external memory location. The PTS transfers the first word to location 6000H. Then it increments and updates the destination address and decrements the PTSCOUNT register; it does not increment the source address. When the second cycle begins, the PTS moves a second word from location 20H to location 6002H. When PTSCOUNT equals zero, the PTS will have filled locations 6000–600FH, and an end-of-PTS interrupt is generated.
Register Location Function · BW Byte/Word Transfer

Table 6-5. Single Transfer Mode PTSCB
PTSDST (HI) = 60H
PTSDST (LO) = 00H
PTSSRC (HI) = 00H
PTSSRC (LO) = 20H
PTSCON = 85H (Mode = 100, BW = 0, SI/SU = 0, DI/DU = 1)
6.6.4 Block Transfer Mode
In block transfer mode, an interrupt causes the PTS to move a block of bytes or words from one memory location to another. See AP-445, 8XC196KR Peripherals: A User’s Point of View, for ap- plication examples with code. Figure 6-13 shows the PTS control block for block transfer modes.
In this mode, each PTS cycle consists of the transfer of an entire block of bytes or words. Because a PTS cycle cannot be interrupted, the block transfer mode can create long interrupt latency. The worst-case latency could be as high as 500 states, if you assume a block transfer of 32 words from one external memory location to another, using an 8-bit bus with no wait states. See Table 6-4 on page 6-10 for execution times of PTS cycles.
The PTSCB in Table 6-6 sets up three PTS cycles that will transfer five bytes from memory loca- tions 20–24H to 6000–6004H (cycle 1), 6005–6009H (cycle 2), and 600A–600EH (cycle 3). The source and destination are incremented after each byte transfer, but the original source address is reloaded into PTSSRC at the end of each block-transfer cycle. In this routine, the PTS always gets the first byte from location 20H.
PTSBLOCK = 05H
PTSDST (HI) = 60H
PTSDST (LO) = 00H
PTSSRC (HI) = 00H
PTSSRC (LO) = 20H
PTSCON = 17H (Mode = 000; DI, SI, DU, BW = 1; SU = 0)
Unused · Unused · Unused

PTS Block Transfer Mode Control Block
In block transfer mode, the PTS control block contains a block size (PTSBLOCK), a source and destination address (PTSSRC and PTSDST), a control register (PTSCON), and a transfer count (PTSCOUNT).
Unused 0
PTSBLOCK PTS Block Size
PTSDST (HI) PTS Destination Address (high byte)
PTSDST (LO) PTS Destination Address (low byte)
PTSSRC (HI) PTS Source Address (high byte)
PTSSRC (LO) PTS Source Address (low byte)
PTSCON M2 M1 M0 BW SU DU SI DI
PTSCOUNT Consecutive Block Transfers
PTSBLOCK PTSCB + 6 PTS Block Size
Specifies the number of bytes or words in each block. Valid values are 1–32, inclusive.
PTSDST PTSCB + 4 PTS Destination Address
Write the destination memory location to this register. A valid address is any unreserved memory location within page 00H; however, it must point to an even address if word transfers are selected.
PTSSRC PTSCB + 2 PTS Source Address
Write the source memory location to this register. A valid address is any unreserved memory location within page 00H; however, it must point to an even address if word transfers are selected.
Register Location Function

PTS Block Transfer Mode Control Block (Continued)
PTSCON PTSCB + 1 PTS Control Bits
M2:0 PTS Mode
These bits select the PTS mode:
M2 M1 M0 0 0 0 block transfer mode
0 = word transfer 1 = byte transfer
0 = reload original PTS source address after each block transfer is complete 1 = retain current PTS source address after each block transfer is complete
0 = reload original PTS destination address after each block transfer is complete 1 = retain current PTS destination address after each block transfer is complete
0 = do not increment the contents of PTSSRC after each byte or word transfer 1 = increment the contents of PTSSRC after each byte or word transfer
0 = do not increment the contents of PTSDST after each byte or word transfer 1 = increment the contents of PTSDST after each byte or word transfer
PTSCOUNT PTSCB + 0 Consecutive Block Transfers
Defines the number of blocks that will be transferred during the block transfer routine. Each block transfer is one PTS cycle. Maximum number is 255.

The PWM toggle and PWM remap modes are designed for use with the event processor array (EPA) to generate pulse-width modulated (PWM) output signals. These modes can also be used with an interrupt signal from any other source. The PWM toggle mode uses a single EPA channel to generate a PWM signal. The PWM remap mode uses two EPA channels, but it can generate signals with duty cycles closer to 0% or 100% than are possible with the PWM toggle mode. Ta- ble 6-7 compares the two PWM modes. For code examples, see AP-445, 8XC196KR Peripherals: A User’s Point of View, and “EPA PWM Output Program” on page 10-26.
PWM Toggle Mode PWM Remap Mode
Uses a single EPA channel. Uses two EPA channels.
Reads the location specified by PTSPTR1 (usually EPAx_TIME).
Reads the location specified by PTSPTR1 (usually EPAx_TIME).
Adds one of two values to the location specified by PTSPTR1. If TBIT is clear, it adds the value in PTSCONST1. If TBIT is set, it adds the value in PTSCONST2.
Adds the value in PTSCONST1 to the location specified by PTSPTR1.
Stores the sum back into the location specified by PTSPTR1.
Stores the sum back into the location specified by PTSPTR1.
Toggles TBIT. Toggles the unused TBIT.
Figure 6-14 illustrates a generic PWM waveform. The length of an entire PWM output pulse is T2. The time the output is “on” is T1; the time the output is “off” is T2 – T1. The formulas for frequency and duty cycle are shown below. In most applications, the frequency is held constant and the duty cycle is varied to change the average value of the waveform.
Frequency, in Hertz =
T1
T2 ------
Duty Cycle = × 100%

1 on off on off
0 0 T1 T2 T2 + T1 time
On-time = T1 Off-time = T2 - T1
The PWM modes do not use a PTSCOUNT register to specify the number of consecutive PTS cycles. To stop producing the PWM output, first clear the PTSSEL.x bit to disable PTS service for the interrupt and then use the interrupt service routine to reconfigure the EPA channel.
Figure 6-15 shows the PTS control block for PWM toggle mode. To generate a PWM waveform using PWM toggle mode and EPA0, complete the following procedure. This example uses the values stored in CSTORE1 and CSTORE2 to control the frequency and duty cycle of a PWM.
— Load PTSCON with 43H (selects PWM toggle mode, initial TBIT value = 1).
— Set up PTSPTR1 to point to EPA0_TIME (the EPA0 event-time register).
— Load PTSCONST1 with the on-time value (T1) from CSTORE1.
— Load PTSCONST2 with the off-time value (T2 – T1) from CSTORE2.
Output Value

PTSCONST2 (HI) = T2 – T1 (HI)
PTSCONST2 (LO) = T2 – T1 (LO)
PTSCONST1 (HI) = T1 (HI)
PTSCONST1 (LO) = T1 (LO)
PTSPTR1 (HI) = 1FH
PTSPTR1 (LO) = 82H
PTSCON = 43H (Mode = 010, TMOD = 1, TBIT = 1)
— Clear P1_DIR.0 (selects output).
— Set P1_MODE.0 (selects the EPA0 special-function signal).
— Set P1_REG.0 (initializes the output to “1”).
— Load EPA0_CON with 0078H (timer 1, compare, toggle output pin, re-enable).
— Load EPA0_TIME with the value in PTSCONST1 (selects T1 as first event time).
— Load T1CONTROL with C2H (enables timer 1, selects up counting at f/4, and enables
the divide-by-four prescaler).
— Set INT_MASK.7.
— Set PTSSEL.7.
Unused

PTS PWM Toggle Mode Control Block
In PWM toggle mode, the PTS uses a single EPA channel to generate a pulse-width modulated (PWM) output signal. The control block contains registers that contain the PWM on-time (PTSCONST1), the PWM off-time (PTSCONST2), the address pointer (PTSPTR1), and a control register (PTSCON).
PTSCONST2 (H) PWM Off-time (high byte)
PTSCONST2 (L) PWM Off-time (low byte)
PTSCONST1 (H) PWM On-time (high byte)
PTSCONST1 (L) PWM On-time (low byte)
PTSPTR1 (H) Pointer 1 Value (high byte)
PTSPTR1 (L) Pointer 1 Value (low byte)
PTSCON M2 M1 M0 — — — TMOD TBIT
Unused 0
PTSCONST2 PTSCB + 6 PWM Off-time
Write the desired PWM off-time to these bits.
PTSCONST1 PTSCB + 4 PWM On-time
Write the desired PWM on-time to these bits.
PTSPTR1 PTSCB + 2 Pointer 1 Value
These bits point to a memory location, usually EPAx_TIME. PTSPTR1 can point to any unreserved memory location within page 00H.
Register Location Function

PTS PWM Toggle Mode Control Block (Continued)
PTSCON PTSCB + 1 PTS Control Bits
M2:0 PTS Mode
These bits specify the PTS mode:
TMOD Toggle Mode Select
1 = PWM toggle mode
TBIT Toggle Bit Initial Value
Defines the initial value of TBIT.
0 = selects initial value as zero 1 = selects initial value as one
The TBIT value determines whether PTSCONST1 or PTSCONST2 is added to the PTSPTR1 value:
0 = PTSCONST1 is added to PTSPTR1 1 = PTSCONST2 is added to PTSPTR1
Reading this bit returns the current value of TBIT, which is toggled by hardware at the end of each PWM toggle cycle.
Figure 6-16 is a flow diagram of the EPA and PTS operations for this example. Operation begins when the timer is enabled (at time = 0 in Figure 6-14 on page 6-27) by the write to T1CONTROL. The first timer match occurs at time = T1. The EPA toggles the output pin to zero and generates an interrupt to initiate the first PTS cycle.
PWM Toggle Cycle 1. Because TBIT is initialized to one, the PTS adds the off-time value (T2 – T1) to EPA0_TIME and toggles TBIT to zero.
The second timer match occurs at time = T2 (the end of one complete PWM pulse). The EPA tog- gles the output to one and generates an interrupt to initiate the second PTS cycle.
PWM Toggle Cycle 2. Because TBIT is zero, the PTS adds the on-time value (T1) to EPA0_TIME and toggles the TBIT to one.
The next timer match occurs at time = T2 + T1. The EPA toggles the output to zero and initiates the third PTS cycle. The PTS actions are the same as in cycle 1, and generation of the PWM output continues with PTS cycle 1 and cycle 2 alternating.
Register Location Function

EPA
EPA
PTS
TBIT
TBIT
EPA0_TIME = EPA0_TIME + T1 EPA0_TIME = EPA0_TIME + (T2 - T1)
EPA0_TIME = EPA0_TIME + T1 EPA0_TIME = EPA0_TIME + (T2 - T1)
You can modify the duty cycle without interrupting the PWM operation. To change the duty cycle during a PWM cycle, the PTS service routine should write new T1 and T2 – T1 values to CSTORE1 and CSTORE2 and select normal interrupt service for the next EPA0 interrupt. When the next timer match occurs, the output is toggled, and the device executes a normal interrupt ser- vice routine, which performs these operations:

When the next timer match occurs, the PTS cycle (Figure 6-16) increments EPA0_TIME by T1 (if TBIT is zero (output = 0)) or T2 – T1 (if TBIT is one (output = 1)). (Note that although the values of the EPA0 output and TBIT are the same in this example, these two values are unrelated. To establish the initial value of the output, set or clear P1_REG.x.)
The PWM toggle mode has the advantage of using only one EPA channel. However, if the wave- form edges are close together, the PTS may take too long and miss setting up the next edge. The PWM remap mode uses two EPA channels to eliminate this problem.
Figure 6-17 shows the PTS control block for PWM remap mode. The following example uses two EPA channels and a single timer to generate a PWM waveform in PWM remap mode. EPA0 as- serts the output, and EPA1 deasserts it. For each channel, an interrupt is generated every T2 pe- riod, but the comparison times for the channels are offset by the on-time, T1 (see Figure 6-14 on page 6-27). Although TBIT is toggled at the end of every PWM remap mode cycle (see Table 6-7 on page 6-26), it plays no role in this mode. To generate a PWM waveform, follow this procedure.
— Clear P1_DIR.1 (selects output).
— Set P1_MODE.1 (selects the EPA0 special-function signal).
— Set P1_REG.1 (initializes the output to “1”).

Table 6-9. PWM Remap Mode PTSCB
PTSCB0 for EPA0 PTSCB1 for EPA1
PTSCONST1 (HI) = T2 (HI) PTSCONST1 (HI) = T2 (HI)
PTSCONST1 (LO) = T2 (LO) PTSCONST1 (LO) = T2 (LO)
PTSPTR1 (HI) = 1FH (EPA0_TIME, HI) PTSPTR1 (HI) = 1FH (EPA1_TIME, HI)
PTSPTR1 (LO) = 82H (EPA0_TIME, LO) PTSPTR1 (LO) = 86H (EPA1_TIME, LO)
PTSCON = 40H (Mode = 010, TMOD = 0) PTSCON = 40H (Mode = 010, TMOD = 0)
— Load EPA0_CON with 68H (timer 1, compare mode, assert output pin, re-enable).
— Load EPA1_CON with 158H (timer 1, compare mode, deassert output pin, re-enable,
remap enabled).
— Load EPA0_TIME with 0000H (selects time 0 as first event time for EPA0).
— Load EPA1_TIME with the value of T1 (selects time T1 as first event time for EPA1).
— Load timer 1 with FFFFH to ensure that the EPA0 event time (time = 0) is matched
first.
— Load T1CONTROL with C2H (enables timer 1, selects up-counting at f/4, and enables
the divide-by-four prescaler).
— Set INT_MASK.7 and INT_MASK1.0.
— Set PTSSEL.7 and PTSSEL.8.
Unused Unused · Unused Unused · Unused Unused


In PWM remap mode, the PTS uses two EPA channels to generate a pulse-width modulated (PWM) output signal. The control block contains registers that contain the PWM on-time (PTSCONST1), the address pointer (PTSPTR1), and a control register (PTSCON).
Unused 0
Unused 0
PTSCON M2 M1 M0 — — — TMOD TBIT
Unused 0
These bits point to a memory location, usually EPAx_TIME. PTSPTR1 can point to any unreserved memory location within page 00H.

PTS PWM Remap Mode Control Block (Continued)
PTSCON PTSCB + 1 PTS Control Bits
M2:0 PTS Mode
These bits specify the PTS mode:
TMOD Remap Mode Select
0 = PWM remap mode
TBIT Toggle Bit Initial Value
Defines the initial value of TBIT.
1 = selects initial value as one 0 = selects initial value as zero
Figure 6-18 shows the EPA and PTS operations for this example. The first timer match occurs at time = 0 for EPA0, which asserts the output and generates an interrupt.
PWM Remap Cycle 1. The PTS adds T2 to EPA0_TIME and toggles the TBIT.
The output remains asserted until the second timer match occurs at T1 for EPA1, which deasserts the output and generates an interrupt.
PWM Remap Cycle 2. The PTS adds T2 to EPA1_TIME and toggles the TBIT.
Alternating EPA0 and EPA1 interrupts continue, with EPA0 asserting the output and EPA1 deas- serting it.
Register Location Function

EPA
If EPA0, set the output If EPA1, clear the output
If EPA0, set the output If EPA1, clear the output
Toggle TBIT (TBIT is not used)
Toggle TBIT (TBIT is not used)
You can change the duty cycle by changing the time that the output is high and keeping the period constant. After a timer match occurs for EPA1 (when the output falls), schedule the next EPA1 match for T2 + DT, where DT is the time to be added to the on-time. Thereafter, schedule the next EPA1 match for T2. You can do this by replacing one EPA1 PTS interrupt with a normal interrupt (clear PTSSEL.8). Have the interrupt service routine add T2 + DT to EPA1_TIME and set PTSSEL.8 to re-enable PTS service for EPA1. This adjustment changes the duty cycle without affecting the period.
By using two EPA channels in the PWM remap mode, you can generate duty cycles closer to 0% and 100% than is possible with PWM toggle mode. For further information about generating PWM waveforms with the EPA, see “Operating in Compare Mode” on page 10-12.




I/O PORTS
I/O ports provide a mechanism to transfer information between the device and the surrounding system circuitry. They can read system status, monitor system operation, output device status, configure system options, generate control signals, provide serial communication, and so on. Their usefulness in an application is limited only by the number of I/O pins available and the imagination of the engineer.
Standard I/O port registers are located in the SFR address space and they can be windowed. Mem- ory-mapped I/O port registers are located in memory-mapped address space. Memory-mapped registers must be accessed with indirect or indexed addressing; they cannot be windowed. All ports can provide low-speed input/output pins or serve alternate functions. Table 7-1 provides an overview of the device I/O ports. The remainder of this chapter describes the ports in more detail and explains how to configure the pins. The chapters that cover the associated peripherals discuss using the pins for their special functions.
Port Bits Type Direction Associated Peripheral(s)
Port 1 8 Standard Bidirectional EPA and timers
Port 2 8 Standard Bidirectional SIO, interrupts, bus control, clock gen.
Port 3 8 Standard Bidirectional Chip-select unit, interrupts
Port 4 4 Standard Bidirectional PWM
EPORT 4 Memory mapped (NP) Standard (NU) Bidirectional Extended address lines
The bidirectional ports are very similar in both circuitry and configuration. All ports use Schmitt- triggered input buffers for improved noise immunity. Table 7-2 lists the bidirectional port pins with their special-function signals and associated peripherals.

P1.0 EPA0 I/O EPA
P1.1 EPA1 I/O EPA
P1.2 EPA2 I/O EPA
P1.3 EPA3 I/O EPA
P1.4 T1CLK I Timer 1
P1.5 T1DIR I Timer 1
P1.6 T2CLK I Timer 2
P1.7 T2DIR I Timer 2
P2.1 RXD I/O SIO
P2.2 EXTINT0 I Interrupts
P2.3 BREQ# O Bus controller
P2.4 EXTINT1 I Interrupts
P2.5 HOLD# I Bus controller
P2.6 HLDA# O Bus controller
P2.7 CLKOUT O Clock generator
P3.0 CS0# O Chip-select unit
P3.1 CS1# O Chip-select unit
P3.2 CS2# O Chip-select unit
P3.3 CS3# O Chip-select unit
P3.4 CS4# O Chip-select unit
P3.5 CS5# O Chip-select unit
P3.6 EXTINT2 I Interrupts
P3.7 EXTINT3 I Interrupts
P4.1 PWM1 O PWM
P4.2 PWM2 O PWM
P4.3 — I/O —
Table 7-3 lists the registers associated with the bidirectional ports. Each port has three control reg- isters (Px_MODE, Px_DIR, and Px_REG); they can be both read and written. The Px_PIN regis- ter is a status register that returns the logic level present on the pins; it can only be read. The registers are byte-addressable and can be windowed.“Bidirectional Port Considerations” on page 7-9 discusses special considerations for reading P2_REG.7.

Table 7-3. Bidirectional Port Control and Status Registers
P1_DIR P2_DIR P3_DIR P4_DIR
1FD2H 1FCBH 1FDAH 1FDBH
Each bit of Px_DIR controls the direction of the corresponding pin.
0 = complementary output (output only) 1 = input or open-drain output (input, output, or bidirectional) Open-drain outputs require external pull-ups.
1FD0H 1FC9H 1FD8H 1FD9H
Each bit of Px_MODE controls whether the corresponding pin functions as a standard I/O port pin or as a special-function signal.
0 = standard I/O port pin 1 = special-function signal
1FD6H 1FCFH 1FDEH 1FDFH
Each bit of Px_PIN reflects the current state of the corresponding pin, regardless of the pin configuration.
1FD4H 1FCDH 1FDCH 1FDDH
Port x Data Output
For an input, set the corresponding Px_REG bit.
For an output, write the data to be driven out by each pin to the corresponding bit of Px_REG. When a pin is configured as standard I/O (Px_MODE.y = 0), the result of a CPU write to Px_REG is immediately visible on the pin. When a pin is configured as a special-function signal (Px_MODE.y = 1), the associated on-chip peripheral or off-chip component controls the pin. The CPU can still write to Px_REG, but the pin is unaffected until it is switched back to its standard I/O function.
This feature allows software to configure a pin as standard I/O (clear Px_MODE.y), initialize or overwrite the pin value, then configure the pin as a special-function signal (set Px_MODE.y). In this way, initial- ization, fault recovery, exception handling, etc., can be done without changing the operation of the associated peripheral.
Figure 7-1 shows the logic for driving the output transistors, Q1 and Q2. On ports 1, 2, and 3, Q1 can source at least –3 mA at VCC – 0.7 volts. On port 4, which has a high-current sink capability for the PWMs, Q1 can source at least –3 mA at 0.45 volts. Q2 can sink at least 10 mA at 0.45 volts. (Consult the datasheet for specifications.)
In I/O mode (selected by clearing Px_MODE.y), Px_REG and Px_DIR are input to the multiplex- ers. These signals combine to drive the gates of Q1 and Q2 so that the output is high, low, or high impedance. Table 7-4 is a logic table for I/O operation of these ports.

In special-function mode (selected by setting Px_MODE.y), SFDIR and SFDATA are input to the multiplexers. These signals combine to drive the gates of Q1 and Q2 so that the output is high, low, or high impedance. Special-function output signals clear SFDIR; special-function input sig- nals set SFDIR. Table 7-5 is a logic table for special-function operation of these ports. Even if a pin is to be used in special-function mode, you must still initialize the pin as an input or output by writing to Px_DIR.
Resistor R1 provides ESD protection for the pin. Input signals are buffered. The ports use Schmitt-triggered buffers for improved noise immunity. The signals are latched into the Px_PIN sample latch and output onto the internal bus when the Px_PIN register is read.
The falling edge of RESET# turns on transistor Q3, which remains on for about 300 ns, causing the pin to change rapidly to its reset state. The active-low level of RESET# turns on transistor Q4, which weakly holds the pin high. (Q4 can source approximately –10 µA; consult the datasheet for exact specifications.) Q4 remains on, weakly holding the pin high, until your software writes to the Px_MODE register.



Configuration Complementary Output Open-drain
Px_MODE 0
Px_DIR 0 0 1 1
SFDATA X X X X
Px_REG 0 1 0, 1 (Note 2) 1
Q1 off on off off
Q2 on off on, off (Note 2) off
Px_PIN 0 1 X (Note 3) high-impedance (Note 4)
Configuration Complementary Output Open-drain
Px_MODE 1
Px_DIR 0 0 1 1
SFDATA 0 1 0, 1 (Note 2) 1
Px_REG X X X 1
Q1 off on off off
Q2 on off on, off (Note 2) off
Px_PIN 0 1 X (Note 3) high-impedance (Note 4)
Output Input · Output Input

7.2.2 Bidirectional Port Pin Configurations
Each bidirectional port pin can be individually configured to operate either as an I/O pin or as a pin for a special-function signal. In the special-function configuration, the signal is controlled by an on-chip peripheral or an off-chip component. In either configuration, two modes are possible:
To prevent the CMOS inputs from floating, the bidirectional port pins are weakly pulled high dur- ing and after reset, until your software writes to Px_MODE. The default values of the control reg- isters after reset configure the pins as high-impedance inputs with weak pull-ups. To ensure that the ports are initialized correctly and that the weak pull-ups are turned off, follow this suggested initialization sequence:
— For a complementary output, clear its Px_DIR bit.
— For a high-impedance input or an open-drain output, set its Px_DIR bit. (Open-drain
outputs require external pull-ups.)
— For a standard I/O pin, clear its Px_MODE bit. In this mode, the pin is driven as
defined in steps 1 and 3.
— For a special-function signal, set its Px_MODE bit. In this mode, the associated
peripheral controls the pin.
— For output pins defined in step 1, write the data that is to be driven by the pins to the
corresponding Px_REG bits. For special-function outputs, the value is immaterial because the peripheral controls the pin. However, you must still write to Px_REG to initialize the pin.
— For input pins defined in step 1, set the corresponding Px_REG bits.
Table 7-6 lists the control register values for each possible configuration. For special-function outputs, the Px_REG value is irrelevant (don’t care) because the associated peripheral controls the pin in special-function mode. However, you must still write to Px_REG to initialize the pin. For a bidirectional pin to function as an input (either special function or port pin), you must set Px_REG.

Desired Pin Configuration Configuration Register Settings
Standard I/O Signal Px_DIR Px_MODE† Px_REG
Complementary output, driving 0
Complementary output, driving 1 0 0 1
Open-drain output, strongly driving 0 1 0 0
Open-drain output, high impedance 1 0 1
Input 1 0 1
Special-function signal Px_DIR Px_MODE† Px_REG
Complementary output, output value controlled by peripheral 0 1 X
Open-drain output, output value controlled by peripheral 1 1 X
Input 1 1 1
† During reset and until the first write to Px_MODE, the pins are weakly held high.
Assume that you wish to configure the pins of a bidirectional port as shown in Table 7-7.
Port Pin(s) Configuration Data
Px.0, Px.1 high-impedance input high-impedance
Px.2, Px.3 open-drain output 0
Px.4 open-drain output 1 (assuming external pull-up)
Px.5, Px.6 complementary output 0
Px.7 complementary output 1
To do so, you could use the following example code segment. Table 7-8 shows the state of each pin after reset and after execution of each line of the example code.
LDB Px_DIR,#00011111B LDB Px_MODE,#00000000B LDB Px_REG,#10010011B

Table 7-8. Port Pin States After Reset and After Example Code Execution
Resulting Pin States†
Px.7 Px.6 Px.5 Px.4 Px.3 Px.2 Px.1 Px.0
Reset wk1
LDB Px_DIR, #00011111B 1 1 1 wk1
LDB Px_MODE, #00000000B 1 1 1 HZ1
LDB Px_REG, #10010011B 1 0 0 HZ1 0 0 HZ1 HZ1
† wk1 = weakly pulled high, HZ1 = high impedance (actually a “1” with an external pull-up).
This section outlines special considerations for using the pins of these ports.
Port 1 After reset, your software must configure the device to match the external system. This is accomplished by writing appropriate config- uration data into P1_MODE. Writing to P1_MODE not only configures the pins but also turns off the transistor that weakly holds the pins high (Q4 in Figure 7-1 on page 7-5). For this reason, even if port 1 is to be used as it is configured at reset, you should still write data into P1_MODE.
Port 2 After reset, your software must configure the device to match the external system. This is accomplished by writing appropriate config- uration data into P2_MODE. Writing to P2_MODE not only configures the pins but also turns off the transistor that weakly holds the pins high (Q4 in Figure 7-1 on page 7-5). For this reason, even if port 2 is to be used as it is configured at reset, you should still write data into P2_MODE.
P2.2/EXTINT0 Writing to P2_MODE.2 sets the EXTINT0 interrupt pending bit (INT_PEND.3). After configuring the port pins, clear the interrupt pending registers before globally enabling interrupts. See “Design Considerations for External Interrupt Inputs” on page 7-11.
P2.4/EXTINT1 Writing to P2_MODE.4 sets the EXTINT1 interrupt pending bit (INT_PEND.4). After configuring the port pins, clear the interrupt pending registers before globally enabling interrupts. See “Design Considerations for External Interrupt Inputs” on page 7-11.
P2.5/HOLD# If P2.5 is configured as a standard I/O port pin, the device does not recognize signals on this pin as HOLD#. Instead, the bus controller receives an internal HOLD signal. This enables the device to access the external bus while it is performing I/O at P2.5.
Action or Code

P2.7/CLKOUT Following reset, P2.7 carries the strongly driven CLKOUT signal. It is not held high. When P2.7 is configured as CLKOUT, it is always a complementary output.
P2.7 A value written to P2_REG.7 is held in a buffer until P2_MODE.7 is cleared, at which time the value is loaded into P2_REG.7. A value read from P2_REG.7 is the value currently in the register, not the value in the buffer. Therefore, any change to P2_REG.7 can be read only after P2_MODE.7 is cleared.
Port 3 After reset, your software must configure the device to match the external system. This is accomplished by writing appropriate config- uration data into P3_MODE. Writing to P3_MODE not only configures the pins but also turns off the transistor that weakly holds the pins high (Q4 in Figure 7-1 on page 7-5). For this reason, even if port 3 is to be used as it is configured at reset, you should still write data into P3_MODE.
P3.0/CS0# P3.0/CS0# is weakly pulled high during reset. After reset, it defaults to the CS0# function. This chip-select signal detects address ranges that contain the CCBs and FF2080H (program start-up address). See Chapter 13, “Interfacing with External Memory,” for a detailed description of chip-select signal functions after reset.
P3.6/EXTINT2 Writing to P3_MODE.6 sets the EXTINT2 interrupt pending bit (INT_PEND1.5). After configuring the port pins, clear the interrupt pending registers before globally enabling interrupts. See “Design Considerations for External Interrupt Inputs” on page 7-11.
P3.7/EXTINT3 Writing to P3_MODE.7 sets the EXTINT3 interrupt pending bit (INT_PEND1.6). After configuring the port pins, clear the interrupt pending registers before globally enabling interrupts. See “Design Considerations for External Interrupt Inputs” on page 7-11.
Port 4 After reset, your software must configure the device to match the external system. This is accomplished by writing appropriate config- uration data into P4_MODE. Writing to P4_MODE not only configures the pins but also turns off the transistor that weakly holds the pins high (Q4 in Figure 7-1 on page 7-5). For this reason, even if port 4 is to be used as it is configured at reset, you should still write data into P4_MODE.

7.2.5 Design Considerations for External Interrupt Inputs
To configure a port pin that serves as an external interrupt input, you must set the corresponding bits in the configuration registers (Px_DIR, Px_MODE, and Px_REG). However, setting the Px_MODE bit causes the device to set the corresponding interrupt pending bit, indicating an in- terrupt request. To configure P2.2/EXTINT0, P2.4/EXTINT1, P3.6/EXTINT2, and P3.7/EXTINT3, we recommend the following sequence to prevent the false interrupt request:
The EPORT is a four-bit, bidirectional, memory-mapped I/O port in the 8XC196NP, but a stan- dard I/O port in the 80C196NU. For the 8XC196NP, it must be accessed using indirect or indexed addressing, and it cannot be windowed. For the 80C196NU, it can be windowed. This port pro- vides the address signals necessary to support extended addressing. If one or more extended ad- dress pins are unnecessary in an application, the unused port pins can be used for I/O. Figure 7-2 shows a block diagram of the EPORT.
Table 7-9 lists the EPORT pins with their extended-address signals. Table 7-10 lists the registers that affect the function and indicate the status of EPORT pins.
EPORT.0 A16 I/O
EPORT.1 A17 I/O
EPORT.2 A18 I/O
EPORT.3 A19 I/O
Port Pin Extended-address · Signal Signal Type

EP_DIR 1FE3H EPORT Direction
In I/O mode, each bit of EP_DIR controls the direction of the corre- sponding pin. Clearing a bit configures a pin as a complementary output; setting a bit configures a pin as either an input or an open- drain output. (Open-drain outputs require external pull-ups).
Any pin that is configured for its extended-address function is forced to the complementary output mode except during reset, hold, idle, powerdown, and standby. (Standby mode is available only on the 80C196NU.)
EP_MODE 1FE1H EPORT Mode
Each bit of EP_MODE controls whether the corresponding pin functions as a standard I/O port pin or as an extended-address signal. Setting a bit configures a pin as an extended-address signal; clearing a bit configures a pin as a standard I/O port pin.
EP_PIN 1FE7H EPORT Pin State
Each bit of EP_PIN reflects the current state of the corresponding pin, regardless of the pin configuration.
EP_REG 1FE5H EPORT Data Output
Each bit of EP_REG contains data to be driven out by the corre- sponding pin. When a pin is configured as standard I/O (EP_MODE.x = 0), the result of a CPU write to EP_REG is immediately visible on the pin.
During nonextended data accesses, EP_REG contains the value of the memory page that is to be accessed. For compatibility with software tools, clear the EP_REG bit for any EPORT pin that is configured as an extended-address signal (EP_MODE.x set).
80C196NU Only: For nonextended data accesses, the 80C196NU forces the page address to 00H. You cannot change pages by modifying EP_REG.
As Figure 7-2 shows, each EPORT pin serves either as I/O or as an address line, as selected by the I/O multiplexer. This multiplexer is controlled by the EP_MODE register. If EP_MODE.x is clear (I/O mode), the pin serves as I/O until EP_MODE.x is changed.
Mnemonic Address Description

I/O MUX
EP_REG
I/O (0)
EPC
CODE
ADR
64K
Q1
DATA
EDAR
1M
Q2
EP_MODE
EP_DIR
V SS
EP_PIN
D Q
LE
If EP_MODE.x is set (address mode), the address multiplexer determines the address source. For an instruction fetch, the address multiplexer is set to the CODE input, which selects the extended program counter (EPC) as the address source. For a data fetch, or when there is no external bus activity, the address multiplexer is set to the DATA input, which selects the extended data address register (EDAR) as the address source.
The EDAR is loaded from two different sources, depending on whether the data access is extend- ed or nonextended. For extended data accesses, the data multiplexer is set to the 1-Mbyte mode input and EDAR is loaded with the extended address. For nonextended data accesses, the data multiplexer is set to the 64-Kbyte mode input and EDAR is loaded from EP_REG. The last value loaded remains in EDAR until the next data access. (Refer to “Fetching Code and Data in the 1- Mbyte and 64-Kbyte Modes” on page 5-23 for more information.)

The 8XC196NP allows you to change the value of EP_REG to control which memory page a non- extended instruction accesses. However, software tools require that EP_REG be equal to 00H. The 80C196NU forces all nonextended data accesses to page 00H. You cannot use EP_REG to change pages.
You can read EP_PIN at any time to determine the value of a pin. When EP_PIN is read, the con- tents of the sample latch are output onto the internal bus.
Figure 7-3 shows a circuit schematic for a single bit of the EPORT. Q1 and Q2 are the strong com- plementary drivers for the pin. Q1 can source at least –3 mA at VCC – 0.7 volts. Q2 can sink at least 3 mA at VSS + 0.45 volts. (Consult the datasheet for specifications.) Resistor R1 provides ESD protection for the pin.
During reset, the falling edge of RESET# generates a short pulse that turns on the medium pull- up transistor Q3, which remains on for about 300 ns, causing the pin to change rapidly to its reset state. The active-low level of RESET# turns on transistor Q4, which weakly holds the pin high. (Q4 can source approximately –10 µΑ; consult the datasheet for exact specifications.) When RESET# is inactive, both Q3 and Q4 are off; Q1 and Q2 determine output drive.
If RESET#, HOLD#, idle, or powerdown is asserted, the gates that control Q1 and Q2 are dis- abled and Q1 and Q2 remain off. Otherwise, the gates are enabled and complementary or open- drain operation is possible.
For complementary output mode, the gates that control Q1 and Q2 must be enabled. The Q2 gate is always enabled (except when RESET#, HOLD#, idle, or powerdown is asserted). Either clear- ing EP_DIR (selecting complementary mode) or setting EP_MODE (selecting address mode) en- ables the logic gate preceding Q1. The value of DATA determines which transistor is turned on. If DATA is equal to one, Q1 is turned on and the pin is pulled high. If DATA is equal to zero, Q2 is turned on and the pin is pulled low.
For open-drain output mode, the gate that controls Q1 must be disabled. Setting EP_DIR (select- ing open-drain mode) and clearing EP_MODE (selecting I/O mode) disables the logic gate pre- ceding Q1. The value of DATA determines whether Q2 is turned on. If DATA is equal to one, both Q1 and Q2 remain off and the pin is left in high-impedance state (floating). If DATA is equal to zero, Q2 is turned on and the pin is pulled low.



Input mode is obtained by configuring the pin as an open-drain output (EP_DIR set and EP_MODE clear) and writing a one to EP_REG.x. In this configuration, Q1 and Q2 are both off, allowing an external device to drive the pin. To determine the value of the I/O pin, read EP_PIN.x.
Table 7-11 is a logic table for I/O operation and Table 7-12 is a logic table for address mode op- eration of EPORT.
Configuration Complementary Output Open-drain
EP_DIR 0 0 0, 1 (Note 2) 1
Address Bit X
Q1 off on off off
Q2 on off on off
EP_PIN 0 1 0 high-impedance
Configuration Complementary Output (Note 1)
EP_DIR X X
EP_REG X (Note 2) X (Note 2)
Address Bit 0 1
Output Input · Q1 off on · Q2 on off

7.3.2 Configuring EPORT Pins
Each EPORT pin can be individually configured to operate either as an extended-address signal or as an I/O pin in one of these modes:
The EPORT pins default to their extended-address functions upon reset (see Table B-5 on page B-13). During program execution, the pins can be reconfigured at any time from address to I/O and back to address. However, this is not recommended unless you understand the implications of changing memory addressing “on the fly.” To change a pin from I/O to address, clear the EP_REG.x bit and set the EP_MODE.x bit. (Clearing EP_REG.x is required for compatibility with software development tools.)
To configure a pin for I/O, write the appropriate values to the control registers, in this order:
2. EP_MODE
3. EP_REG
Table 7-13 lists the register settings for the EPORT pins.
Configuration Register Settings EP_PIN
Value EP_DIR EP_MODE EP_REG
Address X† 1 0†† address
Complementary output 0 0 data value data value
Open-drain output 1 0 data value data value
Input 1 0 1 I/O pin value
† X = Don’t care. †† Must be zero for compatibility with software tools.
Desired Pin Configuration

This section outlines considerations for using the EPORT pins.
During reset, the EPORT pins are forced to their extended-address functions and are weakly pulled high. During the CCB fetch, FFH is strongly driven onto the pins. This value remains strongly driven until either the pin is configured for I/O or a different extended address is access- ed. If the pins remain configured as extended-address functions, they are placed in a high-imped- ance state during idle, powerdown, standby (80C196NU only), and hold. If they are configured as I/O, they retain their I/O function during those modes. See Figure 11-7 on page 11-8 and Table B-5 on page B-13 for additional information.
Nonextended data accesses go to the address contained in EP_REG. Therefore, if you configure EP_REG to point to the desired address, you can use nonextended addressing modes to access the extended address space. However, we recommend that you clear the EP_REG bits for any EPORT pins configured as extended-address signals in order to maintain compatibility with soft- ware development tools.
The 8XC196NP allows you to change the value of EP_REG to control which memory page a nonextended instruction accesses. However, software tools require that EP_REG be equal to 00H. The 80C196NU forces all nonextended data accesses to page 00H. You cannot use EP_REG to change pages.
When using the EPORT to address memory outside page 00H, keep these points in mind:

EST 1CH, 01001CH[0] ;reg 1CH stored at memory location 01001CH
At the end of EPORT bus activity and during periods of internal bus activity, EPORT pins con- tinue to drive the last data address that was output. If these lines are being used to enable external memory, that memory will remain enabled until a different page is accessed.
During the CCB fetch, all EPORT lines are strongly driven high. Designers should ensure that this does not conflict with external systems that are outputting signals to the EPORT.
When EPORT pins are floated during idle, powerdown, or hold, the external system must provide circuitry to prevent CMOS inputs on external devices from floating. During powerdown, the EPORT input buffers on pins configured for their extended-address function are disconnected from the pins, so a floating pin will not cause increased power consumption.
Open-drain outputs require an external pull-up resistor. Inputs must be driven or pulled high or low; they must not be allowed to float.






A serial input/output (SIO) port provides a means for the system to communicate with external devices. This device has a serial I/O (SIO) port that shares pins with port 2. This chapter describes the SIO port and explains how to configure it. Chapter 7, “I/O Ports,” explains how to configure the port pins for their special functions. Refer to Appendix B for details about the signals dis- cussed in this chapter.
The serial I/O port (Figure 8-1) is an asynchronous/synchronous port that includes a universal asynchronous receiver and transmitter (UART). The UART has one synchronous mode (mode 0) and three asynchronous modes (modes 1, 2, and 3) for both transmission and reception.
SBUF_RX Receive Shift Register
SBUF_TX
TXD
TI
T1CLK
Control Logic Baud Rate
(÷2)
SP_BAUD
SP_CON.6
MSB
The serial port receives data into the receive buffer; it transmits data from the port through the transmit buffer. The transmit and receive buffers are separate registers, permitting simultaneous reads and writes to both. The transmitter and receiver are buffered to support continuous trans- missions and to allow reception of a second byte before the first byte has been read.

An independent, 15-bit baud-rate generator controls the baud rate of the serial port. Either the in- ternal peripheral clock or T1CLK can provide the clock signal. The baud-rate register (SP_BAUD) selects the clock source and the baud rate.
Table 8-1 describes the SIO signals and Table 8-2 describes the control and status registers.
P2.0 TXD O Transmit Serial Data
In modes 1, 2, and 3, TXD transmits serial port output data. In mode 0, it is the serial clock output.
P2.1 RXD I/O Receive Serial Data
In modes 1, 2, and 3, RXD receives serial port input data. In mode 0, it functions as an input or an open-drain output for data.
P1.4 T1CLK I Timer 1 Clock
External clock source for the baud-rate generator input.
INT_MASK 0013H Interrupt Mask
Setting the TI bit enables the transmit interrupt; clearing the bit disables (masks) the interrupt.
Setting the RI bit enables the receive interrupt; clearing the bit disables (masks) the interrupt.
INT_PEND 0012H Interrupt Pending
When set, the TI bit indicates a pending transmit interrupt.
When set, the RI bit indicates a pending receive interrupt.
P1_DIR 1FD2H Port 1 Direction
This register selects the direction of each port 1 pin. To use T1CLK as the input clock to the baud-rate generator, clear P1_DIR.4.
P1_MODE 1FD0H Port 1 Mode
This register selects either the general-purpose input/output function or the peripheral function for each pin of port 1. To use T1CLK as the clock source for the baud-rate generator, set P1_MODE.4 to configure T1CLK (P1.4) for the SIO port.

Table 8-2. Serial Port Control and Status Registers (Continued)
P1_PIN 1FD6H Port 1 Pin State
If you are using T1CLK (P1.4) as the clock source for the baud-rate generator, you can read P1_PIN.4 to determine the current value of T1CLK.
P1_REG 1FD4H Port 1 Output Data
To use T1CLK as the clock source for the baud-rate generator, set P1_REG.4.
P2_DIR 1FCBH Port 2 Direction
This register selects the direction of each port 2 pin. Clear P2_DIR.1 to configure RXD (P2.1) as a high-impedance input/open-drain output, and set P2_DIR.0 to configure TXD (P2.0) as a comple- mentary output.
P2_MODE 1FC9H Port 2 Mode
This register selects either the general-purpose input/output function or the peripheral function for each pin of port 2. Set P2_MODE.1:0 to configure TXD (P2.0) and RXD (P2.1) for the SIO port.
P2_PIN 1FCFH Port 2 Pin State
Two bits of this register contain the values of the TXD (P2.0) and RXD (P2.1) pins. Read P2_PIN to determine the current value of the pins.
P2_REG 1FCDH Port 2 Output Data
This register holds data to be driven out on the pins of port 2. Set P2_REG.1 for the RXD (P2.1) pin. Write the desired output data for the TXD (P2.0) pin to P2_REG.0.
SBUF_RX 1FB8H Serial Port Receive Buffer
This register contains data received from the serial port.
SBUF_TX 1FBAH Serial Port Transmit Buffer
This register contains data that is ready for transmission. In modes 1, 2, and 3, writing to SBUF_TX starts a transmission. In mode 0, writing to SBUF_TX starts a transmission only if the receiver is disabled (SP_CON.3 = 0)
SP_BAUD 1FBCH,1FBDH Serial Port Baud Rate
This register selects the serial port baud rate and clock source. The most-significant bit selects the clock source. The lower 15 bits represent the BAUD_VALUE, an unsigned integer that determines the baud rate.
SP_CON 1FBBH Serial Port Control
This register selects the communications mode and enables or disables the receiver, parity checking, and ninth-bit data transmis- sions. The TB8 bit is cleared after each transmission.
Mnemonic Address Description

SP_STATUS 1FB9H Serial Port Status
This register contains the serial port status bits. It has status bits for receive overrun errors (OE), transmit buffer empty (TXE), framing errors (FE), transmit interrupt (TI), receive interrupt (RI), and received parity error (RPE) or received bit 8 (RB8). Reading SP_STATUS clears all bits except TXE; writing a byte to SBUF_TX clears the TXE bit.
The serial port has both synchronous and asynchronous operating modes for transmission and re- ception. This section describes the operation of each mode.
The most common use of mode 0, the synchronous mode, is to expand the I/O capability of the device with shift registers (see Figure 8-2). In this mode, the TXD pin outputs a set of eight clock pulses, while the RXD pin either transmits or receives data. Data is transferred eight bits at a time with the least-significant bit first. Figure 8-3 shows a diagram of the relative timing of these sig- nals. Note that only mode 0 uses RXD as an open-drain output.
Px.x
Data 15KΩ 74HC05
Q#
74HC165
TXD
74HC164
Px.x

In mode 0, RXD must be enabled for receptions and disabled for transmissions. (See “Program- ming the Control Register” on page 8-8.) When RXD is enabled, either a rising edge on the RXD input or clearing the receive interrupt (RI) flag in SP_STATUS starts a reception. When RXD is disabled, writing to SBUF_TX starts a transmission.
Disabling RXD stops a reception in progress and inhibits further receptions. To avoid a partial or undesired complete reception, disable RXD before clearing the RI flag in SP_STATUS. This can be handled in an interrupt environment by using software flags or in straight-line code by using the interrupt pending register to signal the completion of a reception.
During a reception, the RI flag in SP_STATUS is set after the stop bit is sampled. The RI pending bit in the interrupt pending register is set immediately before the RI flag is set. During a transmis- sion, the TI flag is set immediately after the end of the last (eighth) data bit is transmitted. The TI pending bit in the interrupt pending register is generated when the TI flag in SP_STATUS is set.
RXD (OUT)
D0
D1 D2 D3 D4 D5 D6 D7
RXD (IN) D0
D1 D2 D3 D4 D5 D6 D7
Expanded:
TXD
RXD (OUT)
D0
D1 D2
RXD (IN)
D0
D1
Figure 8-3. Mode 0 Timing
8.3.2 Asynchronous Modes (Modes 1, 2, and 3)
Modes 1, 2, and 3 are full-duplex serial transmit/receive modes, meaning that they can transmit and receive data simultaneously. Mode 1 is the standard 8-bit, asynchronous mode used for nor- mal serial communications. Modes 2 and 3 are 9-bit asynchronous modes typically used for in- terprocessor communications (see “Multiprocessor Communications” on page 8-8). In mode 2, the serial port sets an interrupt pending bit only if the ninth data bit is set. In mode 3, the serial port always sets an interrupt pending bit upon completion of a data transmission or reception.

When the serial port is configured for mode 1, 2, or 3, writing to SBUF_TX causes the serial port to start transmitting data. New data placed in SBUF_TX is transmitted only after the stop bit of the previous data has been sent. A falling edge on the RXD input causes the serial port to begin receiving data if RXD is enabled. Disabling RXD stops a reception in progress and inhibits fur- ther receptions. (See “Programming the Control Register” on page 8-8.)
Mode 1 is the standard asynchronous communications mode. The data frame used in this mode (Figure 8-4) consists of ten bits: a start bit (0), eight data bits (LSB first), and a stop bit (1). If parity is enabled, a parity bit is sent instead of the eighth data bit, and parity is checked on recep- tion.
Start Stop D0 D1 D2 D3 D4 D5 D6 D7 Stop
8 Bits of Data or 7 Bits of Data with Parity Bit
The transmit and receive functions are controlled by separate shift clocks. The transmit shift clock starts when the baud-rate generator is initialized. The receive shift clock is reset when a start bit (high-to-low transition) is received. Therefore, the transmit clock may not be synchronized with the receive clock, although both will be at the same frequency.
The transmit interrupt (TI) and receive interrupt (RI) flags in SP_STATUS are set to indicate com- pleted operations. During a reception, both the RI flag and the RI interrupt pending bit are set just before the end of the stop bit. During a transmission, both the TI flag and the TI interrupt pending bit are set at the beginning of the stop bit. The next byte cannot be sent until the stop bit is sent.
Use caution when connecting more than two devices with the serial port in half-duplex (i.e., with one wire for transmit and receive). The receiving processor must wait for one bit time after the RI flag is set before starting to transmit. Otherwise, the transmission could corrupt the stop bit, causing a problem for other devices listening on the link.
10-Bit Frame

8.3.2.2 Mode 2
Mode 2 is the asynchronous, ninth-bit recognition mode. This mode is commonly used with mode 3 for multiprocessor communications. Figure 8-5 shows the data frame used in this mode. It con- sists of a start bit (0), nine data bits (LSB first), and a stop bit (1). During transmissions, setting the TB8 bit in the SP_CON register before writing to SBUF_TX sets the ninth transmission bit. The hardware clears the TB8 bit after every transmission, so it must be set (if desired) before each write to SBUF_TX. During receptions, the RI flag and RI interrupt pending bit are set only if the TB8 bit is set. This provides an easy way to have selective reception on a data link. (See “Multi- processor Communications” on page 8-8). Parity cannot be enabled in this mode.
Start Stop D0 D1 D2 D3 D4 D5 D6 D7 D8 Stop
8 Bits of Data
11-Bit Frame Programmable 9th Bit
8.3.2.3 Mode 3
Mode 3 is the asynchronous, ninth-bit mode. The data frame for this mode is identical to that of mode 2. Mode 3 differs from mode 2 during transmissions in that parity can be enabled, in which case the ninth bit becomes the parity bit. When parity is disabled, data bits 0–7 are written to the serial port transmit buffer, and the ninth data bit is written to bit 4 (TB8) bit in the SP_CON reg- ister. In mode 3, a reception always sets the RI interrupt pending bit, regardless of the state of the ninth bit. If parity is disabled, the SP_STATUS register bit 7 (RB8) contains the ninth data bit. If parity is enabled, then bit 7 (RB8) is the received parity error (RPE) flag.
Operation in modes 2 and 3 is similar to mode 1 operation. The only difference is that the data consists of 9 bits, so 11-bit packages are transmitted and received. During a reception, the RI flag and the RI interrupt pending bit are set just after the end of the stop bit. During a transmission, the TI flag and the TI interrupt pending bit are set at the beginning of the stop bit. The ninth bit can be used for parity or multiprocessor communications.

Modes 2 and 3 are provided for multiprocessor communications. In mode 2, the serial port sets the RI interrupt pending bit only when the ninth data bit is set. In mode 3, the serial port sets the RI interrupt pending bit regardless of the value of the ninth bit. The ninth bit is always set in ad- dress frames and always cleared in data frames.
One way to use these modes for multiprocessor communication is to set the master processor to mode 3 and the slave processors to mode 2. When the master processor wants to transmit a block of data to one of several slaves, it sends out an address frame that identifies the target slave. Be- cause the ninth bit is set, an address frame interrupts all slaves. Each slave examines the address byte to check whether it is being addressed. The addressed slave switches to mode 3 to receive the data frames, while the slaves that are not addressed remain in mode 2 and are not interrupted.
To use the SIO port, you must configure the port pins to serve as special-function signals and set up the SIO channel.
Before you can use the serial port, you must configure the associated port pins to serve as special- function signals. Table 8-1 on page 8-2 lists the pins associated with the serial port. Table 8-2 lists the port configuration registers, and Chapter 7, “I/O Ports,” explains how to configure the pins.
The SP_CON register (Figure 8-6) selects the communication mode and enables or disables the receiver, parity checking, and nine-bit data transmissions. Selecting a new mode resets the serial I/O port and aborts any transmission or reception in progress on the channel.
The SP_BAUD register (Figure 8-7 on page 8-11) selects the clock input for the baud-rate gen- erator and defines the baud rate for all serial I/O modes. This register acts as a control register during write operations and as a down-counter monitor during read operations.

The serial port control (SP_CON) register selects the communications mode and enables or disables the receiver, parity checking, and nine-bit data transmission. For the 80C196NU, it also enables or disables the divide-by-two prescaler.
8XC196NP — — PAR TB8 REN PEN M1 M0
80C196NU — PRS PAR TB8 REN PEN M1 M0
7 — Reserved; for compatibility with future devices, write zero to this bit.
6† PRS Prescale
This bit enables the divide-by-two prescaler.
0 =disable the prescaler 1 =enable the prescaler
5 PAR Parity Selection Bit
Selects even or odd parity.
0 = even parity 1 = odd parity
4 TB8 Transmit Ninth Data Bit
This is the ninth data bit that will be transmitted in mode 2 or 3. This bit is cleared after each transmission, so it must be set before SBUF_TX is written. When SP_CON.2 is set, this bit takes on the even parity value.
3 REN Receive Enable
Setting this bit enables the receiver function of the RXD pin. When this bit is set, a high-to-low transition on the pin starts a reception in mode 1, 2, or 3. In mode 0, this bit must be clear for transmission to begin and must be set for reception to begin. Clearing this bit stops a reception in progress and inhibits further receptions.
2 PEN Parity Enable
In modes 1 and 3, setting this bit enables the parity function. This bit must be cleared if mode 2 is used. When this bit is set, TB8 takes the parity value on transmissions. With parity enabled, SP_STATUS.7 becomes the receive parity error bit.
† This bit is reserved on the 8XC196NP. For compatibility with future devices, write zero to this bit.
Bit Number · Bit Mnemonic Function

The serial port control (SP_CON) register selects the communications mode and enables or disables the receiver, parity checking, and nine-bit data transmission. For the 80C196NU, it also enables or disables the divide-by-two prescaler.
8XC196NP — — PAR TB8 REN PEN M1 M0
80C196NU — PRS PAR TB8 REN PEN M1 M0
1:0 M1:0 Mode Selection
These bits select the communications mode.
M1 M0 0 0 mode 0 0 1 mode 1 1 0 mode 2 1 1 mode 3
† This bit is reserved on the 8XC196NP. For compatibility with future devices, write zero to this bit.
Bit Number · Bit Mnemonic Function

The serial port baud rate (SP_BAUD) register selects the serial port baud rate and clock source. The most-significant bit selects the clock source. The lower 15 bits represent BAUD_VALUE, an unsigned integer that determines the baud rate.
The maximum BAUD_VALUE is 32,767 (7FFFH). In asynchronous modes 1, 2, and 3, the minimum BAUD_VALUE is 0000H when using the internal clock source (f) and 0001H when using T1CLK. In synchronous mode 0, the minimum BAUD_VALUE is 0001H for transmissions and 0002H for receptions.
BV7 BV6 BV5 BV4 BV3 BV2 BV1 BV0
15 CLKSRC Serial Port Clock Source
This bit determines whether the serial port is clocked from an internal or an external source.
0 = signal on the T1CLK pin (external source) 1 = internal operating frequency (f)
14:0 BV14:0 Baud Rate
These bits constitute the BAUD_VALUE.
Use the following equations to determine the BAUD_VALUE for a given baud rate.
Baud Rate 2 × 1 – = T1CLK
Asynchronous modes 1, 2, and 3:
Baud Rate 16 × 1 – = T1CLK
Baud Rate 8 ×
† For mode 0 receptions, the BAUD_VALUE must be 0002H or greater. Otherwise, the resulting data in the receive shift register will be incorrect.

For mode 0 receptions, the BAUD_VALUE must be 0002H or greater. Otherwise, the resulting data in the receive shift register will be incorrect.
The reason for this restriction is that the receive shift register is clocked from an internal signal rather than the signal on TXD. Although these two signals are normally synchronized, the internal signal generates one clock before the first pulse transmitted by TXD and this first clock signal is not synchronized with TXD. This clock signal causes the receive shift register to shift in whatever data is present on the RXD pin. This data is treated as the least- significant bit (LSB) of the reception. The reception then continues in the normal synchronous manner, but the data received is shifted left by one bit because of the false LSB. The seventh data bit transmitted is received as the most-significant bit (MSB), and the transmitted MSB is never shifted into the receive shift register.
Using the internal peripheral clock at 25 MHz, the maximum baud rate is 4.17 Mbaud for mode 0 receptions and 6.25 Mbaud for mode 0 transmissions. The maximum baud rate for modes 1, 2, and 3 is 1.56 Mbaud for both receptions and transmissions. For the 80C196NU using the internal peripheral clock at 50 MHz, the maximum baud rates are doubled: 12.5 Mbaud for mode 0 trans- missions, 8.33 Mbaud for mode 0 receptions, and 3.13 Mbaud for modes 1, 2, and 3.
Table 8-3 shows the SP_BAUD values for common baud rates when using a 25 MHz internal clock. These values also apply to the 80C196NU at 50 MHz with the prescaler enabled. Table 8-3 shows the SP_BAUD value for 9600 baud when using a 50 MHz clock input with the prescaler disabled. Because of rounding, the BAUD_VALUE formula is not exact and the resulting baud rate is slightly different than desired. The tables show the percentage of error when using the sam- ple SP_BAUD values. In most cases, a serial link will work with up to 5.0% difference in the re- ceiving and transmitting baud rates.
SP_BAUD Register Value (Note 1) % Error
Mode 0 Mode 1, 2, 3 Mode 0 Mode 1, 2, 3
4800 8A2BH 8144H 0 0.16
2400 9457H 828AH 0 0
1200 A8AFH 8515H 0 0
300 (Note 2) 9457H (Note 2) 0
Baud Rate

Table 8-4. SP_BAUD Values When Using the Internal Clock at 50 MHz (80C196NU Only)
SP_BAUD Register Value† % Error
Mode 0 Mode 1, 2, 3 Mode 0 Mode 1, 2, 3
†Bit 15 is always set when the internal peripheral clock is selected as the clock source for the baud-rate generator.
The serial port has both a transmit interrupt (TI) and a receive interrupt (RI). To enable an inter- rupt, set the corresponding mask bit in the interrupt mask register (see Table 8-2 on page 8-2) and execute the EI instruction to globally enable servicing of interrupts. See Chapter 6, “Standard and PTS Interrupts,” for more information about interrupts.
You can read the SP_STATUS register (Figure 8-8) to determine the status of the serial port. Reading SP_STATUS clears all bits except TXE. For this reason, we recommend that you copy the contents of the SP_STATUS register into a shadow register and then execute bit-test instruc- tions such as JBC and JBS on the shadow register. Otherwise, executing a bit-test instruction clears the flags, so any subsequent bit-test instructions will return false values. You can also read the interrupt pending register (see Table 8-2 on page 8-2) to determine the status of the serial port interrupts.
Baud Rate

The serial port status (SP_STATUS) register contains bits that indicate the status of the serial port.
7 RPE/RB8 Received Parity Error/Received Bit 8
RPE is set if parity is disabled (SP_CON.2 = 0) and the ninth data bit received is high.
RB8 is set if parity is enabled (SP_CON.2 = 1) and a parity error occurred.
Reading SP_STATUS clears this bit.
6 RI Receive Interrupt
This bit is set when the last data bit is sampled. Reading SP_STATUS clears this bit.
This bit need not be clear for the serial port to receive data.
5 TI Transmit Interrupt
This bit is set at the beginning of the stop bit transmission. Reading SP_STATUS clears this bit.
4 FE Framing Error
This bit is set if a stop bit is not found within the appropriate period of time. Reading SP_STATUS clears this bit.
3 TXE SBUF_TX Empty
This bit is set if the transmit buffer is empty and ready to accept up to two bytes. It is cleared when a byte is written to SBUF_TX.
2 OE Overrun Error
This bit is set if data in the receive shift register is loaded into SBUF_RX before the previous bit is read. Reading SP_STATUS clears this bit.
1:0 — Reserved. These bits are undefined.
The receiver checks for a valid stop bit. Unless a stop bit is found within the appropriate time, the framing error (FE) bit in the SP_STATUS register is set. When the stop bit is detected, the data in the receive shift register is loaded into SBUF_RX and the receive interrupt (RI) flag is set. If this happens before the previous byte in SBUF_RX is read, the overrun error (OE) bit is set. SBUF_RX always contains the latest byte received; it is never a combination of the last two bytes.
Bit Number · Bit Mnemonic Function

The receive interrupt (RI) flag indicates whether an incoming data byte has been received. The transmit interrupt (TI) flag indicates whether a data byte has finished transmitting. These flags also set the corresponding bits in the interrupt pending register. A reception or transmission sets the RI or TI flag in SP_STATUS and the corresponding interrupt pending bit. However, a soft- ware write to the RI or TI flag in SP_STATUS has no effect on the interrupt pending bits and does not cause an interrupt. Similarly, reading SP_STATUS clears the RI and TI flags, but does not clear the corresponding interrupt pending bits. The RI and TI flags in the SP_STATUS and the corresponding interrupt pending bits can be set even if the RI and TI interrupts are masked.
The transmitter empty (TXE) bit is set if SBUF_TX and its buffer are empty and ready to accept up to two bytes. TXE is cleared as soon as a byte is written to SBUF_TX. One byte may be written if TI alone is set. By definition, if TXE has just been set, a transmission has completed and TI is set.
The received parity error (RPE) flag or the received bit 8 (RB8) flag applies for parity enabled or disabled, respectively. If parity is enabled, RPE is set if a parity error is detected. If parity is dis- abled, RB8 is the ninth data bit received in modes 2 and 3.






The pulse-width modulator (PWM) module has three output pins, each of which can output a PWM signal with a fixed frequency and a variable duty cycle. These outputs can be used to drive motors that require an unfiltered PWM waveform for optimal efficiency, or they can be filtered to produce a smooth analog signal.
This chapter provides a functional overview of the pulse-width modulator module, describes how to program it, and provides sample circuitry for converting the PWM outputs to analog signals. For detailed descriptions of the signals and registers discussed in this chapter, please refer to Ap- pendix B, “Signal Descriptions” and Appendix C, “Registers.”
The PWM module has three channels, each of which consists of a control register (PWMx_CONTROL, where x is 0, 1, or 2), a buffer, a comparator, an RS flip-flop, and an output pin. Two other components, an eight-bit counter and a clock prescaler, are shared across the PWM module’s three channels, completing the circuitry (see Figures 9-1 and 9-2).
(CLK0 Bit) RS Flip-flopx
Q
P4_MODE
P4.x/ PWMx
Figure 9-1. PWM Block Diagram (8XC196NP Only)

CON_REG0.1
R
Q
P4_MODE
00 01 10 11
Up Counter – 2
P4.x/ PWMx
Figure 9-2. PWM Block Diagram (80C196NU Only)
9.2 PWM SIGNALS AND REGISTERS
Table 9-1 describes the PWM’s signals and Table 9-2 briefly describes the control and status reg- isters.
Port Pin PWM Signal
PWM Signal Type Description
P4.0 PWM0 O Pulse-width modulator 0 output with high-drive capability.
P4.1 PWM1 O Pulse-width modulator 1 output with high-drive capability.
P4.2 PWM2 O Pulse-width modulator 2 output with high-drive capability.

Table 9-2. PWM Control and Status Registers
CON_REG0 1FB6H PWM Control Register
This register controls the clock prescaler.
Bit 0 (CLK0) controls the output period of the PWM channels by enabling or disabling the divide-by-two clock prescaler (8XC196NP only).
Bits 0 and 1 (CLK0, CLK1) control the output period of the PWM channels by enabling or disabling the divide-by-two or divide-by-four clock prescaler (80C196NU only).
1FB0H 1FB2H 1FB4H
This register controls the PWM duty cycle. A zero loaded into this register causes the PWM to output a low continu- ously (0% duty cycle). An FFH in this register causes the PWM to have its maximum duty cycle (99.6% duty cycle).
P4_DIR 1FDBH Port 4 Direction
The P4_DIR register determines the I/O mode for each port 4 pin. The register settings for an open-drain output or a high-impedance input are identical. An open-drain output configuration requires an external pull-up. A high- impedance input configuration requires that the corre- sponding bit in P4_REG be set. This port has a higher drive capability than the other ports in order to support PWM high-drive output requirements.
P4_MODE 1FD9H Port 4 Mode
Each bit in this register determines whether the corre- sponding pin functions as a standard I/O port pin or is used for a special-function signal.
P4_PIN 1FDFH Port 4 Pin State
P4_PIN contains the current state of each port pin, regardless of the pin mode setting.
P4_REG 1FDDH Port 4 Output Data
P4_REG contains data to be driven out by the respective pins. When a port pin is configured as an input, the corre- sponding bit in P4_REG must be set.
For the 8XC196NP, CON_REG0.0 (CLK0) controls the PWM output frequency by enabling or disabling the divide-by-two clock prescaler. Enabling the prescaler causes the 8-bit counter to in- crement once every two state times; disabling it causes the counter to increment once every state time.
Mnemonic Address Description · PWM Duty Cycle

For the 80C196NU, two bits control the PWM output frequency, CON_REG0.0 (CLK0) and CON_REG0.1 (CLK1). The two bits control the PWM output frequency by enabling or disabling the divide-by-two or divide-by-four clock prescaler.
Each control register (PWMx_CONTROL; x = 0, 1, or 2) controls the duty cycle (the pulsewidth stated as a percentage of the period) of the corresponding PWM output. Each control register con- tains an 8-bit value that is loaded into a buffer when the 8-bit counter rolls over from FFH to 00H. The comparators compare the contents of the buffers to the counter value. Since the value written to the control register is buffered, you can write a new 8-bit value to PWMx_CONTROL at any time. However, the comparators do not recognize the new value until the counter has expired the remainder of the current 8-bit count. The new value is used during the next PWM output period.
The counter continually increments until it rolls over to 00H, at which time the PWM output is driven high and the contents of the control registers are loaded into the buffers. The PWM output remains high until the counter value matches the value in the buffer, at which time the output is pulled low. When the counter resets again (i.e., when an overflow occurs) the output is switched high. (Loading PWMx_CONTROL with 00H forces the output to remain low.) Figure 9-3 shows typical PWM output waveforms.
The PWM can generate a duty cycle ranging in length from 0% to 99.6% of the pulse. To deter- mine the desired duty cycle measurement, you must apply a multiplier (2, 4, or 8) to the PWMx_CONTROL value to compensate for the divided input frequency from the divide-by-two circuitry. (See Chapter 2, “Architectural Overview,” for additional information.)
Clearing CON_REG0.0 (CLK0) disables the prescaler, generating a pulse that is 512 state times in length. With the prescaler disabled, the correct multiplier is 2.
Setting CON_REG0.0 (CLK0) enables the PWM’s divide-by-two clock prescaler, generating a pulse that is 1,024 state times in length. With the divide-by-two clock prescaler enabled, the cor- rect multiplier is 4. For example, assume that CLK0 is set and the value you write to the PWMx_CONTROL register is 19H (25 decimal). To arrive at the appropriate duty cycle, you must multiply the value stored in PWMx_CONTROL by 4, then divide that result by the total pulse length (1,024). This calculation results in a duty cycle value of approximately 10% (.0977).
For the 80C196NU, setting CON_REG0.1 (CLK1) enables the divide-by-four clock prescaler, generating a pulse that is 2,048 state times in length. With the divide-by-four prescaler enabled, the correct multiplier is 8. (When CON_REG0.1 is set, the divide-by-four clock prescaler is en- abled and CON_REG0.0 is ignored.)

PWM Control Register Value
10% 19H
50% 80H
90% E6H
99.6% FFH
Figure 9-3. PWM Output Waveforms
9.4 PROGRAMMING THE FREQUENCY AND PERIOD
The PWM module provides two selectable, fixed PWM output frequencies for a specified internal operating frequency (f). Table 9-3 shows the PWM output frequencies for common operating frequencies on the 8XC196NP. The value of CON_REG0.0 determines the output fre- quency by enabling or disabling the clock prescaler. Use the following formulas to calculate the output frequency (FPWM) or output period (TPWM).
÷4 Clock Prescaler†
f 512 f 1024 f 2048
FPWM (in MHz) =
512 f 1024 f 2048 f
TPWM (in µs) =
† 80C196NU only.

For the 80C196NU, the PWM module provides three selectable, fixed PWM output frequencies for a specified internal operating frequency (f). Table 9-3 shows the PWM output frequencies for common operating frequencies. The value of bits 0 and 1 in the CON_REG0 register determines the output frequency by enabling or disabling the divide-by-two or divide-by-four clock prescal- er.
CLK0
16 MHz 20 MHz 25 MHz
0 31.25 kHz 39.06 kHz 48.83 kHz
1 15.63 kHz 19.53 kHz 24.41 kHz
CLK1 CLK0
12.5 MHz 25 MHz 50 MHz
0 0 24.41 kHz 48.83 kHz 97.66 kHz
0 1 12.21 kHz 24.41 kHz 48.83 kHz
1 X 6.10 kHz 12.21 kHz 24.41 kHz
f · f

The control (CON_REG0) register controls the clock prescaler for the three pulse-width modulators (PWM0–PWM2).
8XC196NP — CLK0†
80C196NU — CLK1 CLK0
7:1 (NP) 7:2 (NU) — Reserved; for compatibility with future devices, write zeros to these bits.
0 (NP) CLK0 Enable PWM Clock Prescaler
This bit controls the PWM output period by enabling or disabling the clock prescaler (divide-by-two) on the three pulse width modulators (PWM2:0).
0 = disable; PWM output period is 512 state times 1 = enable; PWM output period is 1024 state times
1:0 (NU) CLK1:0 Enable PWM Clock Prescaler
These bits control the PWM output period on the three pulse-width modulators (PWM2:0).
0 0 disable clock prescaler 0 1 enable divide-by-two prescaler; PWM output period is 1024 state times 1 X enable divide-by-four prescaler; PWM output period is 2048 state times
† This bit was called SLOW_PWM in earlier documentation for the 8XC196NP.
9.5 PROGRAMMING THE DUTY CYCLE
The value written to the PWMx_CONTROL register controls the width of the high pulse, effec- tively controlling the duty cycle. The 8-bit value written to the control register is loaded into a buffer, and this value is used during the next period. Use the following formula to calculate a de- sired pulsewidth by extrapolating an appropriate value for PWMx_CONTROL from the range 00–FFH, and then write the value to the PWMx_CONTROL register.
Bit Number · Bit Mnemonic Function

÷4 Clock Prescaler†
f PWMx_CON 4 ×
f PWMx_CON 8 ×
Pulsewidth (in µs) =
Duty Cycle (in %) =
where:
PWMx_CON = 8-bit value to load into the PWMx_CONTROL register
Pulsewidth = width of each high pulse
f = operating frequency, in MHz
TPWM = output period on the PWM pin, in µs
† 80C196NU only.
PWMx_CONTROL x = 0–2
The PWM control (PWMx_CONTROL) register determines the duty cycle of the PWM x channel. A zero loaded into this register causes the PWM to output a low continuously (0% duty cycle). An FFH in this register causes the PWM to have its maximum duty cycle (99.6% duty cycle).
7:0 PWM Duty Cycle
This register controls the PWM duty cycle. A zero loaded into this register causes the PWM to output a low continuously (0% duty cycle). An FFH in this register causes the PWM to have its maximum duty cycle (99.6% duty cycle).

9.5.1 Sample Calculations
For example, assume that the operating frequency equals 25 MHz, the desired period of the PWM output waveform is either 20.48 µs (512 state times) if the divide-by-two prescaler is disabled or 40.96 µs (1,024 state times) if the prescaler is enabled. If PWMx_CONTROL equals 8AH (138 decimal), the pulsewidth is held high for 11.04 µs (and low for 9.44 µs) of the total 20.48 µs pe- riod, resulting in a duty cycle of approximately 54%. If the prescaler is enabled, the same values would produce a period of 40.96 µs with the pulsewidth being held high for 22.08 µs (and low for 18.88 µs), for the same duty cycle, approximately 54%.
Each PWM output is multiplexed with a port pin, so you must configure it as a special-function output signal before using the PWM function. To do so, follow this sequence:
Table 9-5 shows the alternate port function along with the register setting that selects the PWM output instead of the port function.
PWM Output Alternate Port Function PWM Output Enabled When:
PWM0 P4.0 P4_DIR.0 = 0, P4_MODE.0 = 1, P4_REG = X
PWM1 P4.1 P4_DIR.1 = 0, P4_MODE.1 = 1, P4_REG = X
PWM2 P4.2 P4_DIR.2 = 0, P4_MODE.2 = 1, P4_REG = X
The PWM modules can generate a rectangular pulse train that varies in duty cycle and period. Filtering this output will create a smooth analog signal. To make a signal swing over the desired analog range, first buffer the signal and then filter it with either a simple RC network or an active filter. Figure 9-6 is a block diagram of the type of circuit needed to create the smooth analog sig- nal.

Buffer to Make Output Swing
Figure 9-6. D/A Buffer Block Diagram
Figure 9-7 shows a sample circuit used for low output currents (less than 100 µA). Consider tem- perature and power-supply drift when selecting components for the external D/A circuitry. With proper components, a highly accurate 8-bit D/A converter can be made using the PWM.
R
Consider both ripple and response time requirements when selecting R and C.




Control applications often require high-speed event control. For example, the controller may need to periodically generate pulse-width modulated outputs or an interrupt. In another application, the controller may monitor an input signal to determine the status of an external device. The event processor array (EPA) was designed to reduce the CPU overhead associated with these types of event control. This chapter describes the EPA and its timers and explains how to configure and program them.
The EPA performs input and output functions associated with two timer/counters, timer 1 and timer 2 (Figure 10-1). In the input mode, the EPA monitors an input pin for an event: a rising edge, a falling edge, or an edge in either direction. When the event occurs, the EPA records the value of the timer/counter, so that the event is tagged with a time. This is called an input capture. Input captures are buffered to allow two captures before an overrun occurs. In the output mode, the EPA monitors a timer/counter and compares its value with a value stored in a register. When the tim- er/counter value matches the stored value, the EPA can trigger an event: a timer reset or an output event (set a pin, clear a pin, toggle a pin, or take no action). This is called an output compare. Each input capture or an output compare sets an interrupt pending bit. This bit can optionally cause an interrupt. The EPA has four capture/compare channels, EPA3:0.

TIMER2
EPA1
EPA2
EPA3
Figure 10-1. EPA Block Diagram
10.2 EPA AND TIMER/COUNTER SIGNALS AND REGISTERS
Table 10-1 describes the EPA and timer/counter input and output signals. Each signal is multi- plexed with a port pin as shown in the first column. Table 10-2 briefly describes the registers for the EPA capture/compare channels and timer/counters.
Port Pin EPA Signal(s) EPA Signal Type Description
P1.3:0 EPA3:0 I/O High-speed input/output for capture/compare channels 0–3.
P1.4 T1CLK I External clock source for timer 1.
P1.5 T1DIR I External direction control for timer 1.
P1.6 T2CLK I External clock source for timer 2.
P1.7 T2DIR I External direction control for timer 2.

Table 10-2. EPA Control and Status Registers
EPA_MASK 1F9CH EPA Mask
Four bits (OVR0, OVR1, OVR2, and OVR3) in this 8-bit register enable and disable (mask) the individual capture overrun interrupt sources associated with capture/compare channels EPA3:0.
EPA_PEND 1F9EH EPA Pending
Four bits (OVR0, OVR1, OVR2, and OVR3) in this 8-bit register indicate an overrun status for the associated capture/compare channels, EPA3:0. OVR0 and OVR1 are multiplexed to share one interrupt pending bit (OVR0_1) in INT_PEND1; OVR2 and OVR3 are multiplexed to share another interrupt pending bit (OVR2_3) in INT_PEND1.
1F80H 1F84H 1F88H 1F8CH
These registers control the functions of the capture/compare channels. EPA1_CON and EPA3_CON require an extra byte because they contain an additional bit for PWM remap mode. These two registers must be addressed as words; the others can be addressed as bytes.
1F82H 1F86H 1F8AH 1F8EH
In capture mode, these registers contain the captured timer value. In compare mode, these registers contain the time at which an event is to occur. In capture mode, these registers are buffered to allow two captures before an overrun occurs. However, they are not buffered in compare mode.
INT_MASK 0008H Interrupt Mask
Three bits in this 8-bit register (OVRTM1, OVRTM2, and EPA0) enable and disable (mask) the three interrupts associated with the corresponding bits in INT_PEND register.
INT_MASK1 0013H Interrupt Mask 1
Five bits in this 8-bit register (EPA1, EPA2, EPA3, OVR0_1, and OVR2_3) enable and disable (mask) the five interrupts associated with the corresponding bits in INT_PEND1 register.
INT_PEND 0009H Interrupt Pending
Any set bit in this 8-bit register indicates a pending interrupt. The three bits associated with EPA interrupts are OVRTM1, OVRTM2, and EPA0.
INT_PEND1 0012H Interrupt Pending 1
Any set bit in this 8-bit register indicates a pending interrupt. The five bits associated with EPA interrupts are EPA1, EPA2, EPA3, OVR0_1, and OVR2_3.
P1_DIR 1FD2H Port 1 Direction
Each bit of P1_DIR controls the direction of the corresponding pin. Clearing a bit configures a pin as a complementary output; setting a bit configures a pin as an input or open-drain output. (Open-drain outputs require external pull-ups.)
Mnemonic Address Description · EPAx Capture/Compare Control · EPAx Capture/Compare Time

P1_MODE 1FD0H Port 1 Mode
Each bit of P1_MODE controls whether the corresponding pin functions as a standard I/O port pin or as a special-function signal. Setting a bit configures a pin as a special-function signal; clearing a bit configures a pin as a standard I/O port pin.
P1_PIN 1FD6H Port 1 Input
Each bit of P1_PIN reflects the current state of the corresponding pin, regardless of the pin configuration.
P1_REG 1FD4H Port 1 Data Output
For an input, set the corresponding P1_REG bit.
For an output, write the data to be driven out by each pin to the corresponding bit of P1_REG. When a pin is configured as standard I/O (P1_MODE.y = 0), the result of a CPU write to Px_REG is immediately visible on the pin. When a pin is configured as a special-function signal (P1_MODE.y = 1), the associated on-chip peripheral or off-chip component controls the pin. The CPU can still write to P1_REG, but the pin is unaffected until it is switched back to its standard I/O function.
This feature allows software to configure a pin as standard I/O (clear P1_MODE.y), initialize or overwrite the pin value, then configure the pin as a special-function signal (set P1_MODE.y). In this way, initialization, fault recovery, exception handling, etc., can be done without changing the operation of the associated peripheral.
T1CONTROL 1F90H Timer 1 Control
This register enables/disables timer 1, controls whether it counts up or down, selects the clock source and direction, and determines the clock prescaler setting.
T2CONTROL 1F94H Timer 2 Control
This register enables/disables timer 2, controls whether it counts up or down, selects the clock source and direction, and determines the clock prescaler setting.
TIMER1 1F92H Timer 1 Value
This register contains the current value of timer 1.
TIMER2 1F96H Timer 2 Value
This register contains the current value of timer 2.
Mnemonic Address Description

10.3 TIMER/COUNTER FUNCTIONAL OVERVIEW
The EPA has two 16-bit up/down timer/counters, timer 1 and timer 2, which can be clocked in- ternally or externally. Each is called a timer if it is clocked internally and a counter if it is clocked externally. Figure 10-2 illustrates the timer/counter structure.
T2CLK
T2DIR
T2CONTROL.6
T1CONTROL.2:0
T1CONTROL.6
T1CLK
T1DIR
T1CONTROL.6
Disable prescaler if quadrature clocking is selected. †

The timer/counters can be used as time bases for input captures, output compares, and pro- grammed interrupts (software timers). When a counter increments from FFFEH to FFFFH or dec- rements from 0001H to 0000H, the counter-overflow interrupt pending bit is set. This bit can optionally cause an interrupt. The clock source, direction-control source, count direction, and res- olution of the input capture or output compare are all programmable (see “Programming the Tim- ers” on page 10-15). The maximum count rate is one-half the internal clock rate, or f/4 (see “Internal Timing” on page 2-7). This provides a minimum resolution for an input capture or out- put compare of 160 ns (at f = 25 MHz) for 8XC196NP and 80 ns (at f = 50 MHz) for the 80C196NU.
4 p × rescaler_divisor
where:
prescaler_divisor is the clock prescaler divisor from the TxCONTROL registers (see “Timer 1 Control (T1CONTROL) Register” on page 10-16 and “Timer 2 Control (T2CONTROL) Register” on page 10-17).
f is the internal operating frequency. See “Internal Timing” on page 2-7 for details.
Timer 2 can be used in cascade mode. In this mode, the timer 1 overflow output is used as the timer 2 clock input. Either the direction control bit of the timer 2 control register or the direction control assigned to timer 1 controls the count direction. This method, called cascading, can pro- vide a slow clock for idle mode timeout control or for slow pulse-width modulation (PWM) ap- plications (see “Generating a Low-speed PWM Output” on page 10-12).
Both timer 1 and timer 2 can be used in quadrature clocking mode. This mode uses the TxCLK and TxDIR pins as quadrature inputs, as shown in Figure 10-3. External quadrature-encoded sig- nals (two signals at the same frequency that differ in phase by 90°) are input, and the timer incre- ments or decrements by one count on each rising edge and each falling edge. Because the TxCLK and TxDIR inputs are sampled by the internal phase clocks, transitions must be separated by at least two state times for proper operation. The count is clocked by PH2, which is PH1 delayed by one-half period. The sequence of the signal edges and levels controls the count direction. Refer to Figure 10-4 and Table 10-3 for sequencing information.
A typical source of quadrature-encoded signals is a shaft-angle decoder, shown in Figure 10-3. Its output signals X and Y are input to TxCLK and TxDIR, which in turn output signals X_internal and Y_internal. These signals are used in Figure 10-4 and Table 10-3 to describe the direction of the shaft.
resolution = · f

PH2
PH1
Y
D Q D Q D Q
D Q D Q D Q
Figure 10-3. Quadrature Mode Interface
Table 10-3. Quadrature Mode Truth Table

PH2
COUNT x x + 1 x + 2 x + 3 x + 4 x + 5 x + 6 x + 5 x + 4 x + 3 x + 2 x + 1
10.4 EPA CHANNEL FUNCTIONAL OVERVIEW
The EPA has four programmable capture/compare channels that can perform the following tasks.
Each EPA channel has a control register, EPAx_CON (capture/compare channel); an event-time register, EPAx_TIME (capture/compare channel); and a timer input (Figure 10-5). The control register selects the timer, the mode, and either the event to be captured or the event that is to occur. The event-time register holds the captured timer value in capture mode and the event time in com- pare mode. See “Programming the Capture/Compare Channels” on page 10-18 for configuration information.
TxCLK · TxDIR

External clocking (TxCLK) with up to 6-bit prescaler Quadrature clocking through TxCLK and TxDIR Internal clocking with up to 6-bit prescaler Clock on TIMER1 overflow
TIMER2
TGL
Mode Selection †Remap
† EPA1 and 3 only. If enabled for EPA1, EPA0 shares the EPA1 pin. If enabled for EPA3, EPA2 shares the EPA3 pin.
10.4.1 Operating in Capture Mode
In capture mode, when a valid event occurs on the pin, the value of the selected timer is captured into a buffer. The timer value is then transferred from the buffer to the EPAx_TIME register, which sets the EPA interrupt pending bit as shown in Figure 10-6. If enabled, an interrupt is gen- erated. If a second event occurs before the CPU reads the first timer value in EPAx_TIME, the current timer value is loaded into the buffer and held there. After the CPU reads the EPAx_TIME register, the contents of the capture buffer are automatically transferred into EPAx_TIME and the EPA interrupt pending bit is set.

EPA Interrupt Pending Bit
If a third event occurs before the CPU reads the event-time register, the overwrite bit (EPAx_CON.0) determines how the EPA will handle the event. If the bit is clear, the EPA ignores the third event. If the bit is set, the third event time overwrites the second event time in the capture buffer. Both situations set the overrun interrupt pending bit, and if the interrupt is enabled, they generate an overrun interrupt. Table 10-4 summarizes the possible actions when a valid event oc- curs.

Table 10-4. Action Taken when a Valid Edge Occurs
Status of Capture Buffer
Overwrite Bit (EPAx_CON.0)
Action taken when a valid edge occurs
0 empty Edge is captured and event time is loaded into the capture buffer and EPAx_TIME register.
0 full New data is ignored — no capture, EPA interrupt, or transfer occurs; OVRx interrupt pending bit is set.
1 empty Edge is captured and event time is loaded into the capture buffer and EPAx_TIME register.
1 full Old data is overwritten in the capture buffer; OVRx interrupt pending bit is set.
An input capture event does not set the interrupt pending bit until the captured time value actually moves from the capture buffer into the EPAx_TIME register. If the buffer contains data and the PTS is used to service the interrupts, then two PTS interrupts occur almost back-to-back (that is, with one instruction executed between the interrupts).
Overruns occur when an EPA input transitions at a rate that cannot be handled by the EPA inter- rupt service routine. If no overrun handling strategy is in place, and if the following three condi- tions exist, a situation may occur where both the capture buffer and the EPAx_TIME register contain data, and no EPA interrupt is generated.
The input frequency at which this occurs depends on the length of the interrupt service routine as well as other factors. Unless the interrupt service routine includes a check for overruns, this situ- ation will remain the same until the device is reset or the EPAx_TIME register is read. The act of reading EPAx_TIME allows the buffered time value to be moved into EPAx_TIME. This clears the buffer and allows another event to be captured. Remember that the act of the transferring the buffer contents to the EPAx_TIME register is what actually sets the EPAx interrupt pending bit and generates the interrupt.
& EPAx_TIME

Any one of the following methods can be used to prevent or recover from an EPA overrun situa- tion.
When the selected timer value matches the event-time value, the action specified in the control register occurs (i.e., the pin is set, cleared, or toggled). If the re-enable bit (EPAx_CON.3) is set, the action reoccurs on every timer match. If the re-enable bit is cleared, the action does not reoc- cur until a new value is written to the event-time register. See “Programming the Capture/Com- pare Channels” on page 10-18 for configuration information.
In compare mode, you can use the EPA to produce a pulse-width modulated (PWM) output. The following sections describe four possible methods.
You can generate a low-speed, pulse-width modulated output with a single EPA channel and a standard interrupt service routine. Configure the EPA channel as follows: compare mode, toggle output, and the compare function re-enabled. Select standard interrupt service, enable the EPA interrupt, and globally enable interrupts with the EI instruction. When the assigned timer/counter value matches the value in the event-time register, the EPA toggles the output pin and generates an interrupt. The interrupt service routine loads a new value into EPAx_TIME.

The maximum output frequency depends upon the total interrupt latency and the interrupt-service execution times used by your system. As additional EPA channels and the other functions of the microcontroller are used, the maximum PWM frequency decreases because the total interrupt la- tency and interrupt-service execution time increases. To determine the maximum, low-speed PWM frequency in your system, calculate your system's worst-case interrupt latency and worst- case interrupt-service execution time, and then add them together. The worst-case interrupt la- tency is the total latency of all the interrupts (both normal and PTS) used in your system. The worst-case interrupt-service execution time is the total execution time of all interrupt service rou- tines and PTS routines.
Assume a system with a single EPA channel, a single enabled interrupt, and the following inter- rupt service routine.
;If EPA0-3 interrupt is generated EPA0-3_ISR:
PUSHA LD EPAx_CON, #toggle_command ADD EPAx_TIME, TIMERx, [next_duty_ptr]; Load next event time POPA RET
The worst-case interrupt latency for a single-interrupt system is 56 state times for external stack usage and 54 state times for internal stack usage (see “Standard Interrupt Latency” on page 6-8). To determine the execution time for an interrupt service routine, add up the execution time of the instructions (Table A-9).
The total execution time for the ISR that services interrupts EPA3:0 is 79 state times for external stack usage or 71 state times for internal stack usage. Therefore, a single capture/compare channel 0–3 can be updated every 125 state times assuming internal stack usage (54 + 71). Each PWM period requires two updates (one setting and one clearing), so the execution time for a PWM pe- riod equals 250 state times. When the input frequency on XTAL1 is 25 MHz and the phase-locked loop is disabled on the 80C196NU, the PWM period is 20 µs and the maximum PWM frequency is 50 kHz.
You can generate a medium-speed, pulse-width modulated output with a single EPA channel and the PTS set up in PWM toggle mode. “PWM Toggle Mode Example” on page 6-27 describes how to configure the EPA and PTS. Once started, this method requires no CPU intervention unless you need to change the output frequency. The method uses a single timer/counter. The timer/counter is not interrupted during this process, so other EPA channels can also use it if they do not reset it.

The maximum output frequency depends upon the total interrupt latency and interrupt-service ex- ecution time. As additional EPA channels and the other functions of the microcontroller are used, the maximum PWM frequency decreases because the total interrupt latency and interrupt-service execution time increases. To determine the maximum, medium-speed PWM frequency in your system, calculate your system's worst-case interrupt latency and worst-case interrupt-service ex- ecution time, and then add them together. The worst-case interrupt latency is the total latency of all the interrupts (both normal and PTS) used in your system. The worst-case interrupt-service execution time is the total execution time of all interrupt service routines and PTS cycles.
Assume a system with a single EPA channel, a single enabled interrupt, and PTS service. Also assume that the PTS is initialized and that the duty cycle and frequency are fixed. The worst-case interrupt latency for a single-interrupt system with PTS service is 43 state times (see “PTS Inter- rupt Latency” on page 6-9). The PTS cycle execution time in PWM toggle mode is 15 state times (Table 6-4 on page 6-10). Therefore, a single capture/compare channel can be updated every 58 state times (43 + 15). Each PWM period requires two updates (one setting and one clearing), so the execution time for a PWM period equals 116 state times. When the input frequency on XTAL1 is 25 MHz and the phase-locked loop is disabled on the 80C196NU, the PWM period is 9.27 µs and the maximum PWM frequency is 107.8 kHz.
You can generate a high-speed, pulse-width modulated output with a pair of EPA channels and the PTS set up in PWM remap mode. “PWM Remap Mode Example” on page 6-32 describes how to configure the EPA and PTS. The remap bit (bit 8) must be set in EPA1_CON (to pair EPA0 and EPA1) or EPA3_CON (to pair EPA2 and EPA3). One channel must be configured to set the out- put; the other, to clear it. At the set (or clear) time, the PTS reads the old time value from EPAx_TIME, adds to it the PWM period constant, and returns the new value to EPAx_TIME. Set and clear times can be programmed to differ by as little as one timer count, resulting in very nar- row pulses. Once started, this method requires no CPU intervention unless you need to change the output frequency. The method uses a single timer/counter. The timer/counter is not interrupted during this process, so other EPA channels can also use it if they do not reset it.
To determine the maximum, high-speed PWM frequency in your system, calculate your system's worst-case interrupt latency and then double it. The worst-case interrupt latency is the total la- tency of all the interrupts (both normal and PTS) used in your system.
Assume a system that uses a pair of remapped EPA channels (i.e., EPA0 and 1 or EPA3 and 4), two enabled interrupts, and PTS service. Also assume that the PTS is initialized and that the duty cycle and frequency are fixed. The worst-case interrupt latency for a single-interrupt system with PTS service is 43 state times (see “PTS Interrupt Latency” on page 6-9). In this mode, the maxi- mum period equals twice the PTS latency. Therefore, the execution time for a PWM period equals 86 state times. When the input frequency on XTAL1 is 25 MHz and the phase-locked loop is dis- abled on the 80C196NU, the PWM period is 6.88 µs and the maximum PWM frequency is 145.3 kHz.

10.4.2.4 Generating the Highest-speed PWM Output
You can generate a highest-speed, pulse-width modulated output with a pair of EPA channels and a dedicated timer/counter. The first channel toggles the output when the timer value matches EPAx_TIME, and at some later time, the second channel toggles the output again and resets the timer/counter. This restarts the cycle. No interrupts are required, resulting in the highest possible speed. Software must calculate and load the appropriate EPAx_TIME values and load them at the correct time in the cycle in order to change the frequency or duty cycle.
With this method, the resolution of the EPA (selected by the TxCONTROL registers; see Figure 10-8 on page 10-16 and Figure 10-9 on page 10-17) determines the maximum PWM output fre- quency. (Resolution is the minimum time required between consecutive captures or compares.) When the input frequency on XTAL1 is 25 MHz and the phase-locked loop is disabled on the 80C196NU, a 160 ns resolution results in a maximum PWM of 6.25 MHz.
This section discusses configuring the port pins for the EPA and the timer/counters; describes how to program the timers and the capture/compare channels; and explains how to enable the EPA interrupts.
Before you can use the EPA, you must configure the pins of port 1 to serve as the special-function signals for the EPA and, optionally, for the timer/counter clock source and direction control sig- nals. See “Bidirectional Ports 1–4” on page 7-1 for information about configuring the port pins.
Table 10-1 on page 10-2 lists the pins associated with the EPA and the timer/counters. Pins that are not being used for an EPA channel or timer/counter can be configured as standard I/O.
The control registers for the timers are T1CONTROL (Figure 10-8) and T2CONTROL (Figure 10-9). Write to these registers to configure the timers. Write to the TIMER1 and TIMER2 regis- ters (see Table 10-2 on page 10-3 for addresses) to load a specific timer value.

The timer 1 control (T1CONTROL) register determines the clock source, counting direction, and count rate for timer 1.
7 CE Counter Enable
This bit enables or disables the timer. From reset, the timers are disabled and not free running.
0 = disables timer 1 = enables timer
This bit determines the timer counting direction, in selected modes (see mode bits, M2:0).
0 = count down 1 = count up
5:3 M2:0 EPA Clock Direction Mode Bits
These bits determine the timer clocking source and direction control source.
M2 M1 M0 Clock Source Direction Source
0 0 0 f/4 UD bit (T1CONTROL.6) X 0 1 T1CLK pin† UD bit (T1CONTROL.6) 0 1 0 f/4 T1DIR pin 0 1 1 T1CLK pin† T1DIR pin 1 1 1 quadrature clocking using T1CLK and T1DIR † If an external clock is selected, the timer counts on both the rising and falling edges of the clock.
2:0 P2:0 EPA Clock Prescaler Bits
These bits determine the clock prescaler value.
P2 P1 P0 Prescaler Divisor Resolution†
0 0 0 divide by 1 (disabled) 160 ns 0 0 1 divide by 2 320 ns 0 1 0 divide by 4 640 ns 0 1 1 divide by 8 1.28 µs 1 0 0 divide by 16 2.56 µs 1 0 1 divide by 32 5.12 µs 1 1 0 divide by 64 10.24 µs 1 1 1 divide by 128 (NU only) 20.48 µs † At f = 25 MHz. Use the formula on page 10-6 to calculate the resolution at other frequencies.
Bit Number · Bit Mnemonic Function · 6 UD Up/Down

The timer 2 control (T2CONTROL) register determines the clock source, counting direction, and count rate for timer 2.
7 CE Counter Enable
This bit enables or disables the timer. From reset, the timers are disabled and not free running.
0 = disables timer 1 = enables timer
This bit determines the timer counting direction, in selected modes (see mode bits, M2:0).
0 = count down 1 = count up
5:3 M2:0 EPA Clock Direction Mode Bits.
These bits determine the timer clocking source and direction source
M2 M1 M0 Clock Source Direction Source
0 0 0 f/4 UD bit (T2CONTROL.6) X 0 1 T2CLK pin† UD bit (T2CONTROL.6) 0 1 0 f/4 T2DIR pin 0 1 1 T2CLK pin† T2DIR pin 1 0 0 timer 1 overflow UD bit (T2CONTROL.6) 1 1 0 timer 1 same as timer 1 quadrature clocking using T2CLK and T2DIR † If an external clock is selected, the timer counts on both the rising and falling edges of the clock.
2:0 P2:0 EPA Clock Prescaler Bits
These bits determine the clock prescaler value.
P2 P1 P0 Prescaler Resolution†
0 0 0 divide by 1 (disabled) 160 ns 0 0 1 divide by 2 320 ns 0 1 0 divide by 4 640 ns 0 1 1 divide by 8 1.28 µs 1 0 0 divide by 16 2.56 µs 1 0 1 divide by 32 5.12 µs 1 1 0 divide by 64 10.24 µs 1 1 1 divide by 128 (NU only) 20.48 µs † At f = 25 MHz. Use the formula on page 10-6 to calculate the resolution at other frequencies.
Bit Number · Bit Mnemonic Function · 6 UD Up/Down

The EPAx_CON register controls the function of its assigned capture/compare channel. The reg- isters for EPA0 and EPA2 are identical. The registers for EPA1 and EPA3 have an additional bit, the remap bit (RM), which is used to enable and disable remapping for high-speed PWM gener- ation (see “Generating a High-speed PWM Output” on page 10-14). This added bit (bit 8) re- quires an additional byte, so EPA1_CON and EPA3_CON must be addressed as words, while the others can be addressed as bytes.
To program a compare event, write to EPAx_CON (Figure 10-10) to configure the EPA cap- ture/compare channel and then load the event time into EPAx_TIME. To program a capture event, you need only write to EPAx_CON. Table 10-5 shows the effects of various combinations of EPAx_CON bit settings.
TB CE MODE RE — ROT ON/RT Operation 7 6 5 4 3 2 1 0
X 0 0 0 — 0 — 0 None
X 0 0 1 — 0 X X Capture on falling edges
X 0 1 0 — 0 X X Capture on rising edges
X 0 1 1 — 0 X X Capture on both edges
X 0 X 1 — 0 1 X Reset opposite timer
X 0 1 X — 0 1 X Reset opposite timer
TB CE MODE RE — ROT ON/RT Operation 7 6 5 4 3 2 1 0
X 1 0 0 X 0 — 0 None
X 1 0 1 X 0 X X Clear output pin
X 1 1 0 X 0 X X Set output pin
X 1 1 1 X 0 X X Toggle output pin
X 1 X X X 0 0 1 Reset same timer
X 1 X X X 0 1 1 Reset opposite timer
Capture Mode · Compare Mode

EPAx_CON x = 0–3
Table 10-2 on page 10-3
The EPA control (EPAx_CON) registers control the functions of their assigned capture/compare channels. The registers for EPA0 andEPA2 are identical. The registers for EPA1 and EPA3 have an additional bit, the remap bit. This added bit (bit 8) requires an additional byte, so EPA1_CON and EPA3_CON must be addressed as words, while the others can be addressed as bytes.
x = 1, 3 — RM
x = 0, 2 TB CE M1 M0 RE — ROT ON/RT
15:9† — Reserved; always write as zeros.
8† RM Remap Feature
The remap feature applies to the compare mode of the EPA1 and EPA3 only.
When the remap feature of EPA1 is enabled, EPA capture/compare channel 0 shares output pin EPA1 with EPA capture/compare channel 1. When the remap feature of EPA3 is enabled, EPA capture/compare channel 2 shares output pin EPA3 with EPA capture/compare channel 3.
0 = remap feature disabled 1 = remap feature enabled
7 TB Time Base Select
Specifies the reference timer.
0 = timer 1 is the reference timer and timer 2 is the opposite timer 1 = timer 2 is the reference timer and timer 1 is the opposite timer
A compare event (clearing, setting, or toggling an output pin; and/or resetting either timer) occurs when the reference timer matches the time programmed in the event-time register.
When a capture event (falling edge, rising edge, or an edge change on the EPAx pin) occurs, the reference timer value is saved in the EPA event- time register (EPAx_TIME).
6 CE Compare Enable
Determines whether the EPA channel operates in capture or compare mode.
0 = capture mode 1 = compare mode
† These bits apply to the EPA1_CON and EPA3_CON registers only.
Bit Number · Bit Mnemonic Function

Table 10-2 on page 10-3
EPAx_CON (Continued) x = 0–3
The EPA control (EPAx_CON) registers control the functions of their assigned capture/compare channels. The registers for EPA0 andEPA2 are identical. The registers for EPA1 and EPA3 have an additional bit, the remap bit. This added bit (bit 8) requires an additional byte, so EPA1_CON and EPA3_CON must be addressed as words, while the others can be addressed as bytes.
x = 1, 3 — RM
x = 0, 2 TB CE M1 M0 RE — ROT ON/RT
5:4 M1:0 EPA Mode Select
In capture mode, specifies the type of event that triggers an input capture. In compare mode, specifies the action that the EPA executes when the reference timer matches the event time.
M1 M0 Capture Mode Event
0 0 no capture 0 1 capture on falling edge 1 0 capture on rising edge 1 1 capture on either edge
M1 M0 Compare Mode Action
0 0 no output 0 1 clear output pin 1 0 set output pin 1 1 toggle output pin
Re-enable applies to the compare mode only. It allows a compare event to continue to execute each time the event-time register (EPAx_TIME) matches the reference timer rather than only upon the first time match.
0 = compare function is disabled after a single event 1 = compare function always enabled
2 — Reserved; always write as zero.
† These bits apply to the EPA1_CON and EPA3_CON registers only.
Bit Number · Bit Mnemonic Function · 3 RE Re-enable

Table 10-2 on page 10-3
EPAx_CON (Continued) x = 0–3
The EPA control (EPAx_CON) registers control the functions of their assigned capture/compare channels. The registers for EPA0 andEPA2 are identical. The registers for EPA1 and EPA3 have an additional bit, the remap bit. This added bit (bit 8) requires an additional byte, so EPA1_CON and EPA3_CON must be addressed as words, while the others can be addressed as bytes.
x = 1, 3 — RM
x = 0, 2 TB CE M1 M0 RE — ROT ON/RT
1 ROT Reset Opposite Timer
Controls different functions for capture and compare modes.
In Capture Mode:
0 = causes no action 1 = resets the opposite timer
In Compare Mode:
Selects the timer that is to be reset if the RT bit is set.
0 = selects the reference timer for possible reset 1 = selects the opposite timer for possible reset
The TB bit (bit 7) selects which is the reference timer and which is the opposite timer.
0 ON/RT Overwrite New/Reset Timer
The ON/RT bit functions as overwrite new in capture mode and reset timer in compare mode.
In Capture Mode (ON):
An overrun error is generated when an input capture occurs while the event-time register (EPAx_TIME) and its buffer are both full. When an overrun occurs, the ON bit determines whether old data is overwritten or new data is ignored:
0 = ignores new data 1 = overwrites old data in the buffer
In Compare Mode (RT):
0 = disables the reset function 1 = resets the ROT-selected timer
† These bits apply to the EPA1_CON and EPA3_CON registers only.
Bit Number · Bit Mnemonic Function

The EPA generates four individual event interrupts, EPA3:0, from the four capture/compare chan- nels and two timer interrupts, OVRTM1 and OVRTM2, from timer 1 and timer 2. These inter- rupts are directly mapped into the two 8-bit interrupt pending registers (INT_PEND and INT_PEND1). The four separate capture overrun interrupts from EPA3:0 are multiplexed and mapped into two bits in INT_PEND1. The capture overrun interrupts from EPA0 and EPA1 are multiplexed and mapped into OVR0_1 (bit 4) of INT_PEND1; the capture overrun interrupts from EPA2 and EPA3 are multiplexed and mapped into OVR2_3 (bit 5) of INT_PEND1. To en- able the interrupts, set the corresponding bits in the the two 8-bit interrupt mask registers (INT_MASK and INT_MASK1). To enable the individual sources of the capture overrun inter- rupts OVR0_1 and OVR2_3, set the corresponding bits in the EPA mask register (EPA_MASK). (Chapter 6, “Standard and PTS Interrupts,” discusses the interrupts in greater detail.)
The EPA interrupt mask (EPA_MASK) register enables or disables (masks) the multiplexed EPA3:0 overrun interrupts (OVR3:0).
7, 5, 3, 1 — Reserved; for compatibility with future devices, write zeros to these bits.
Setting this bit enables the corresponding source as a shared overrun interrupt source. The shared overrun interrupts (OVR0_1 and OVR2_3) are enabled by setting their interrupt enable bits in the interrupt mask 1 (INT_MASK1) register.
10.7 DETERMINING EVENT STATUS
In compare mode, an interrupt pending bit is set each time a match occurs on an enabled event (even if the interrupt is specifically masked in the mask register). In capture mode, an interrupt pending bit is set each time a programmed event is captured and the event time moves from the capture buffer to the EPAx_TIME register. If the capture buffer is full when an event occurs, an overrun interrupt pending bit is set.
Timer overflows and capture overruns also set interrupt pending bits. You can mask the interrupts by clearing bits in EPA_MASK (Figure 10-11), INT_MASK, and INT_MASK1. If an interrupt is masked, software can still poll the interrupt pending registers to determine whether an event has occurred.
Bit Number · Bit Mnemonic Function

When hardware detects a pending EPA3:0 overrun interrupt (OVR3:0), it sets the corresponding bit in the EPA interrupt pending (EPA_PEND) register. OVR0 and OVR1 are multiplexed to share one bit (OVR0_1) in the INT_PEND1 register. Similarly, OVR2 and OVR3 are multiplexed to share another bit (OVR2_3) in the INT_PEND1 register.
7, 5, 3, 1 Reserved. These bits are undefined.
6, 4, 2, 0 Any set bit indicates that the corresponding overrun interrupt source is pending.
† This register was called EPA_STAT in previous documentation for the 8XC196NP.
The EPA interrupt pending register, EPA_PEND, has the same bit structure as the EPA_MASK register. EPA_PEND is similar to an interrupt pending register in that it shows the status of the individual capture/compare overrun interrupts. The bits in EPA_PEND can be polled to deter- mine the exact source of an OVR0_1 or OVR2_3 interrupt. However, hardware does not clear status bits in this register when it vectors to the interrupt service routine for an interrupt pair (OVR0_1, OVR2_3) so the user’s code must clear the register. Instead it clears the OVR0_1 or OVR2_3 bit in the INT_MASK register. Also, software cannot generate an interrupt by setting a bit in EPA_PEND.
The multiplexed overrun interrupts should normally be serviced by interrupt service routines be- cause the PTS cannot determine the exact source of the interrupt. When an OVR0_1 or OVR2_3 occurs, the user’s software service routine can poll the bits of the EPA_PEND register, which has a bit for each overrun source, to determine which of the four capture/compare channels caused the interrupt. The individual sources can be masked by bits in the EPA_MASK register.
Bit Number Function

The three programming examples provided in this section demonstrate the use of the EPA channel for a compare event, for a capture event, and for generation of a PWM signal. The programs dem- onstrate the detection of events by a polling scheme, by interrupts, and by the PTS. All three ex- amples were created using ApBUILDER, an interactive application program available through Intel Literature Fulfillment. These sample program were written in the C programming language. ASM versions are also available from ApBUILDER.
This example C program demonstrates an EPA compare event. It sets up EPA channel 0 to toggle its output pin whenever timer 1 is zero. This program uses no interrupts; a polling scheme detects the EPA event. The program initializes EPA channel 0 for a compare event.
#pragma model(EX) #include
#define COMPARE 0x40 #define RE_ENABLE 0x08 #define TOGGLE_PIN 0x30 #define USE_TIMER1 0x00 #define EPA0_INT_BIT 7
void init_epa0() { epa0_con = COMPARE ¦ TOGGLE_PIN ¦ RE_ENABLE ¦ USE_TIMER1; epa0_time = 0; setbit(p1_reg, 0); /* int reg */ clrbit(p1_dir, 0); /* make output pin */ setbit(p1_mode, 0);/* select EPA mode */ }
void init_timer1() { t1control = COUNT_ENABLE ¦ COUNT_UP ¦ CLOCK_INTERNAL ¦ DIVIDE_BY_1; }

void poll_epa0() { if(checkbit(int_pend, EPA0_INT_BIT))
{ /* Insert user code for event channel 0 here. */ /* Since this event is absolute and re-enabled, no polling is neccessary.*/ clrbit(int_pend, EPA0_INT_BIT);
void main(void) { /* Initialize the timers before using the epa */ init_timer1(); init_epa0(); /* EPA events can be serviced by polling int_pend or epa_pend. */ while(1)
{ poll_epa0(); } }
This example C program demonstrates an EPA capture event. It sets up EPA channel 0 to capture edges (rising and falling) on the EPA0 pin. The program also shows how to set up an the EPA interrupt. You can add your own code for the interrupt service routine.
#pragma model(EX) #include
#define COUNT_ENABLE 0x80 #define COUNT_UP 0x40 #define CLOCK_INTERNAL 0x00 #define DIVIDE_BY_1 0x00 #define CAPTURE 0x00 #define BOTH_EDGE 0x30 #define USE_TIMER1 0x00 #define EPA0_INT_BIT 7
void init_epa0() { epa0_con = CAPTURE ¦
BOTH_EDGE ¦ USE_TIMER1; setbit(p1_reg, 0); /* int reg */ setbit(p1_dir, 0); /* make input pin */ setbit(p1_mode, 0);/* select EPA mode */ setbit(int_mask, EPA0_INT_BIT);/* unmask EPA interrupts */ }
#pragma interrupt(epa0_interrupt=EPA0_INT_BIT) void epa0_interrupt() { unsigned int time_value;
} }

time_value = epa0_time; /* must read to prevent overrun */ } void init_timer1() { t1control = COUNT_ENABLE ¦ COUNT_UP ¦ CLOCK_INTERNAL ¦ DIVIDE_BY_1; }
void main(void) { unsigned int time_value;
/* Initialize the timers and interrupts before using the EPA */ init_timer1(); init_epa0(); enable(); /* Globally enable interrupts */ while(1); /* loop forever, wait for interrupts to occur */ }
This example C program demonstrates the generation of a PWM signal using the EPA’s PWM toggle mode (see “PWM Modes” on page 6-26) and shows how to service the interrupts with the PTS. The PWM signal in this example has a 50% duty cycle.
#pragma model(EX) #include #define PTS_BLOCK_BASE 0x98
/* Create typedef template for the PWM_TOGGLE mode control block.*/ typedef struct PWM_toggle_ptscb_t {
unsigned char unused; unsigned char ptscon; void *pts_ptr; unsigned int constant1; unsigned int constant2; } PWM_toggle_ptscb;
/* This locates the PTS block mode control block in register ram. This */ /* control block may be located at any quad-word boundary. */
register PWM_toggle_ptscb PWM_toggle_CB_3; #pragma locate(PWM_toggle_CB_3=PTS_BLOCK_BASE)
/* The PTS vector must contain the address of the PTS control block.*/ #pragma pts(PWM_toggle_CB_3=0x3)
/* Sample PTS control block initialization sequence.*/

void Init_PWM_toggle_PTS3(void) { disable(); /* disable all interrupts */ disable_pts(); /* disable the PTS interrupts */
PWM_toggle_CB_3.constant2 = 127; PWM_toggle_CB_3.constant1 = 127; PWM_toggle_CB_3.pts_ptr = (void *)&EPA0_TIME; PWM_toggle_CB_3.ptscon = 0x42;
/* Sample code that could be used to generate a PWM with an EPA channel.*/
setbit(p1_reg, 0x1); /* init output */ clrbit(p1_dir, 0x1); /* set to output */ setbit(p1_mode, 0x1); /* set special function*/ setbit(ptssel, 0x8); setbit(int_mask, 0x0) }
void main(void) { Init_PWM_toggle_PTS3(); epa1_con = 0x78; /* toggle, timer1, compare, re-enable */ epa1_timer = 127; t1control = 0xC2; /* enable timer, up 1 microsecond @ 16 MHz */ enable_pts(); while(1); }






The 8XC196NP and 80C196NU have several basic requirements for operation within a system. This chapter describes options for providing the basic requirements and discusses other hardware considerations.
Table 11-1 lists the signals that are required for the device to function and Figure 11-1 shows the connections for a minimum configuration.
A level-sensitive reset input to and open-drain system reset output from the micro- controller. Either a falling edge on RESET# or an internal reset turns on a pull-down transistor connected to the RESET# pin for 16 state times. In the powerdown, standby, and idle modes, asserting RESET# causes the chip to reset and return to normal operating mode. After a device reset, the first instruction fetch is from FF2080H (or F2080H in external memory). For the 80C196NP and 80C196NU, the program and special-purpose memory locations (FF2000–FF2FFFH) reside in external memory. For the 83C196NP, these locations can reside either in external memory or in internal ROM.
RPD I Return from Powerdown
Timing pin for the return-from-powerdown circuit.
If your application uses powerdown mode, connect a capacitor† between RPD and VSS if either of the following conditions is true.
The capacitor causes a delay that enables the oscillator and PLL circuitry to stabilize before the internal CPU and peripheral clocks are enabled.
The capacitor is not required if your application uses powerdown mode and if both of the following conditions are true.
If your application does not use powerdown mode, leave this pin unconnected.
† Calculate the value of the capacitor using the formula found on page 12-11.
VCC PWR Digital Supply Voltage
Connect each VCC pin to the digital supply voltage.
VSS GND Digital Circuit Ground
Connect each VSS pin to ground through the lowest possible impedance path.
Signal · Name Type Description · RESET# I/O Reset

XTAL1 I Input Crystal/Resonator or External Clock Input
Input to the on-chip oscillator, internal phase-locked loop circuitry (80C196NU), and the internal clock generators. The internal clock generators provide the peripheral clocks, CPU clock, and CLKOUT signal. When using an external clock source instead of the on-chip oscillator, connect the clock input to XTAL1. The external clock signal must meet the VIH specification for XTAL1 (see datasheet).
XTAL2 O Inverted Output for the Crystal/Resonator
Output of the on-chip oscillator inverter. Leave XTAL2 floating when the design uses a external clock source instead of the on-chip oscillator.
For predictable performance, it is important to tie unused inputs to VCC or VSS. Otherwise, they can float to a mid-voltage level and draw excessive current. Unused interrupt inputs may generate spurious interrupts if left unconnected.
Chapter 7, “I/O Ports,” contains information about initializing and configuring the ports. Table 11-2 lists the sections, with page numbers, that contain the information for each port.
Port Where to Find Configuration Information
Ports 1–4 “Bidirectional Port Pin Configurations” on page 7-7 and “Bidirectional Port Considerations” on page 7-9
EPORT “Configuring EPORT Pins” on page 7-17
Signal · Name Type Description

20 pF 20 pF (Note 1)
VCC (Note 2) 0.01 µF
4.7 µF +
EA#
NMI
RPD
8XC196 Device VCC
.22 µF
BHE#
RD#
WR#
ONCE
INST
ALE
Notes: 1. See the datasheet for the oscillator frequency range (FOSC) and the crystal manufacturer's datasheet for recommended load capacitors. 2. The number of VCC and VSS pins varies with package type (see datasheet). Be sure to connect all VCC pins to the supply voltage and all VSS pins to ground. 3. Connect the capacitor to RPD when using powerdown mode and the internal oscillator or phase-locked loop (NU only) circuitry. Otherwise, RPD may float. 4. No connection is required.

When power is first applied to the device, RESET# must remain continuously low for at least one state time after the power supply is within tolerance and the oscillator/clock has stabilized; oth- erwise, operation might be unpredictable. Similarly, when powering down a system, RESET# should be brought low before VCC is removed; otherwise, an inadvertent write to an external lo- cation might occur. Carefully evaluate the possible effect of power-up and power-down sequenc- es on a system.
The fast rise and fall times of high-speed CMOS logic often produce noise spikes on the power supply lines and outputs. To minimize noise, it is important to follow good design and board lay- out techniques. We recommend liberal use of decoupling capacitors and transient absorbers. Add 0.01 µF bypass capacitors between VCC and each VSS pin to reduce noise (Figure 11-2). Place the capacitors as close to the device as possible. Use the shortest possible path to connect VSS lines to ground and each other.
SS V
SS V
V SS
V SS
V SS
+5 V 5 V
+5 V 5 V
† Use 0.01 µF bypass capacitors for maximum decoupling.
† Use 0.01 µF bypass capacitors for maximum decoupling.

Multilayer printed circuit boards with separate VCC and ground planes also help to minimize noise. For more information on noise protection, refer to AP-125, Designing Microcontroller Sys- tems for Noisy Environments and AP-711, EMI Design Techniques for Microcontrollers in Auto- motive Applications.
The on-chip oscillator circuit (Figure 11-3) consists of a crystal-controlled, positive reactance os- cillator. In this application, the crystal operates in a parallel resonance mode. The feedback resis- tor, Rf, consists of paralleled n-channel and p-channel FETs controlled by the internal powerdown signal. In powerdown mode, Rf acts as an open and the output drivers are disabled, which disables the oscillator. Both the XTAL1 and XTAL2 pins have built-in electrostatic discharge (ESD) pro- tection.
Oscillator Enable# (from powerdown circuitry)
Figure 11-3. On-chip Oscillator Circuit

Figure 11-4 shows the connections between the external crystal and the device. When designing an external oscillator circuit, consider the effects of parasitic board capacitance, extended oper- ating temperatures, and crystal specifications. Consult the manufacturer’s datasheet for perfor- mance specifications and required capacitor values. With high-quality components, 20 pF load capacitors (CL) are usually adequate for frequencies above 1 MHz.
Noise spikes on the XTAL1 or XTAL2 pin can cause a miscount in the internal clock-generating circuitry. Capacitive coupling between the crystal oscillator and traces carrying fast-rising digital signals can introduce noise spikes. To reduce this coupling, mount the crystal oscillator and ca- pacitors near the device and use short, direct traces to connect to XTAL1, XTAL2, and VSS. To further reduce the effects of noise, use grounded guard rings around the oscillator circuitry and ground the metallic crystal case.
XTAL2
In cost-sensitive applications, you may choose to use a ceramic resonator instead of a crystal os- cillator. Ceramic resonators may require slightly different load capacitor values and circuit con- figurations. Consult the manufacturer’s datasheet for the requirements.
8XC196 Device · Quartz Crystal

11.5 USING AN EXTERNAL CLOCK SOURCE
To use an external clock source, apply a clock signal to XTAL1 and let XTAL2 float (Figure 11-5). To ensure proper operation, the external clock source must meet the minimum high and low times (TXHXX and TXLXX) and the maximum rise and fall transition times (TXLXH and TXHXL) (Figure 11-6). The longer the rise and fall times, the higher the probability that external noise will affect the clock generator circuitry and cause unreliable operation. See the datasheet for required XTAL1 voltage drive levels and actual specifications.
4.7 kن
4.7 kن
XTAL1 External Clock Input
XTAL1 External Clock Input
XTAL2
† Required if TTL driver is used. Not needed if CMOS driver is used.
† Required if TTL driver is used. Not needed if CMOS driver is used.
T XHXX
T XLXH
T XHXL
0.7 V CC + 0.5 V
0.7 V CC + 0.5 V
T XLXX
0.3 V CC – 0.5 V
0.3 V CC – 0.5 V XTAL1
T XLXL
Figure 11-6. External Clock Drive Waveforms
At power-on, the interaction between the internal amplifier and its feedback capacitance (i.e., the Miller effect) may cause a load of up to 100 pF at the XTAL1 pin if the signal at XTAL1 is weak (such as might be the case during start-up of the external oscillator). This situation will go away when the XTAL1 input signal meets the VIL and VIH specifications (listed in the datasheet). If these specifications are met, the XTAL1 pin capacitance will not exceed 20 pF.

Reset forces the device into a known state. As soon as RESET# is asserted, the I/O pins, the con- trol pins, and the registers are driven to their reset states. (Table B-5 on page B-13 lists the reset states of the pins. See Table C-2 on page C-2 for the reset values of the SFRs.) The device re- mains in its reset state until RESET# is deasserted. When RESET# is deasserted, the bus control- ler fetches the chip configuration bytes (CCBs), loads them into the chip configuration registers (CCRs), and then fetches the first instruction. Figure 11-7 shows the reset-sequence timing.
CLKOUT
ALE
RD#
NP
CS0#
NU
t CS5:1#
201AH
CCB1
AD7:0
00H
18H CCB0
1AH
00H
20H Strong. Drv.
Bus parameters defined by CCB0 (bus width, multiplexed or demultiplexed mode, number of wait states) take effect here (at start of second bus cycle). BUSCON0 is changed here by value of CCB0.

The following events will reset the device (see Figure 11-8):
The following paragraphs describe each of these reset methods in more detail.
RESET#
~200 Ω
CLR
Q
Q1
SET
† See the datasheet for minimum and maximum RRST values.
11.6.1 Generating an External Reset
To reset the device, hold the RESET# pin low for at least one state time after the power supply is within tolerance and the oscillator has stabilized. When RESET# is first asserted, the device turns on a pull-down transistor (Q1) for 16 state times. This enables the RESET# signal to function as the system reset.

The simplest way to reset the device is to insert a capacitor between the RESET# pin and VSS, as shown in Figure 11-9. The device has an internal pull-up resistor (RRST) shown in Figure 11-8. RESET# should remain asserted for at least one state time after VCC and XTAL1 have stabilized and met the operating conditions specified in the datasheet. A capacitor of 4.7 µF or greater should provide sufficient reset time, as long as VCC rises quickly.
RESET#
4.7 µF
4.7 µF
Other devices in the system may not be reset because the capacitor will keep the voltage above VIL. Since RESET# is asserted for only 16 state times, it may be necessary to lengthen and buffer the system-reset pulse. Figure 11-10 shows an example of a system-reset circuit. In this example, D2 creates a wired-OR gate connection to the reset pin. An internal reset, system power-up, or SW1 closing will generate the system-reset signal.
(2) D2
D1
4.7 kΩ
SW1

11.6.2 Issuing the Reset (RST) Instruction
The RST instruction (opcode FFH) resets the device by pulling RESET# low for 16 state times. It also clears the processor status word (PSW), sets the extended and master program counters (EPC/PC) to FF2080H, and resets the special function registers (SFRs). See Table C-2 on page C-2 for the reset values of the SFRs.
The device resets itself if an illegal key operand is used with the idle/powerdown (IDLPD) com- mand. The legal keys are “1” for idle mode, “2” for powerdown mode, and “3” for standby mode (NU only). If any other value is used, the device executes a reset sequence. (See Appendix A for a description of the IDLPD command.)






The 8XC196NP and 80C196NU provide the following power saving modes: idle, standby (80C196NU only), and powerdown. They also provide an on-circuit emulation (ONCE) mode that electrically isolates the device from the other system components. This chapter describes each mode and explains how to enter and exit each. (Refer to Appendix A for descriptions of the instructions discussed in this chapter, to Appendix B for descriptions of signal status during each mode, and to Appendix C for details about the registers.)
Table 12-1 lists the signals and Table 12-2 lists the registers that are mentioned in this chapter.
P2.7 CLKOUT O Clock Output
Output of the internal clock generator. The CLKOUT frequency is ½ the internal operating frequency (f). CLKOUT has a 50% duty cycle.
CLKOUT is multiplexed with P2.7.
EXTINT3 EXTINT2 EXTINT1 EXTINT0
In normal operating mode, a rising edge on EXTINTx sets the EXTINTx interrupt pending bit. EXTINTx is sampled during phase 2 (CLKOUT high). The minimum high time is one state time.
In standby and powerdown modes, asserting the EXTINTx signal for at least 50 ns causes the device to resume normal operation. The interrupt need not be enabled, but the pin must be configured as a special-function input (see “Bidirectional Port Pin Configurations” on page 7-7). If the EXTINTx interrupt is enabled, the CPU executes the interrupt 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.
— ONCE I On-circuit Emulation
Holding ONCE high during the rising edge of RESET# places the device into on-circuit emulation (ONCE) mode. This mode puts all pins into a high-impedance state, thereby isolating the device from other components in the system. The value of ONCE is latched when the RESET# pin goes inactive. While the device is in ONCE mode, you can debug the system using a clip-on emulator. To exit ONCE mode, reset the device by pulling the RESET# signal low. To prevent accidental entry into ONCE mode, connect the ONCE pin to VSS.
Port Pin Signal · Name Type Description · I External Interrupts

— PLLEN2:1 (80C196NU only)
I Phase Lock Loop 1 and 2 Enable
These input pins are used to enable the on-chip clock multiplier feature and select either the doubled or quadrupled clock speed.
device will enter into an unsupported test mode.
— RESET# I/O Reset
A level-sensitive reset input to and open-drain system reset output from the microcontroller. Either a falling edge on RESET# or an internal reset turns on a pull-down transistor connected to the RESET# pin for 16 state times. In the powerdown, standby, and idle modes, asserting RESET# causes the chip to reset and return to normal operating mode. After a device reset, the first instruction fetch is from FF2080H (or F2080H in external memory). For the 80C196NP and 80C196NU, the program and special-purpose memory locations (FF2000–FF2FFFH) reside in external memory. For the 83C196NP, these locations can reside either in external memory or in internal ROM.
— RPD I Return from Powerdown
Timing pin for the return-from-powerdown circuit.
If your application uses powerdown mode, connect a capacitor† between RPD and VSS if either of the following conditions is true.
The capacitor causes a delay that enables the oscillator and PLL circuitry to stabilize before the internal CPU and peripheral clocks are enabled.
The capacitor is not required if your application uses powerdown mode and if both of the following conditions are true.
If your application does not use powerdown mode, leave this pin unconnected. † Calculate the value of the capacitor using the formula found on page 12-11.
CCR0 2018H Chip Configuration 0 Register
Bit 0 of this register enables and disables standby and powerdown mode.
INT_MASK 0008H Interrupt Mask
Bits 3 and 4 of this register enable and disable (mask) the external interrupts, EXTINT0 and EXTINT1.
Port Pin Signal · Name Type Description · Mnemonic Address Description

Table 12-2. Operating Mode Control and Status Registers (Continued)
INT_MASK1 0013H Interrupt Mask 1
Bits 5 and 6 of this register enable and disable (mask) the external interrupts, EXTINT2 and EXTINT3.
INT_PEND 0009H Interrupt Pending
Bits 3 and 4 of this register are set to indicate a pending external interrupt, EXTINT0 and EXTINT1.
INT_PEND1 0012H Interrupt Pending 1
Bits 5 and 6 of this register are set to indicate a pending external interrupt, EXTINT2 and EXTINT3.
1FD3H 1FDAH Port x Direction
Each bit of Px_DIR controls the direction of the corresponding pin. Clearing a bit configures a pin as a complementary output; setting a bit configures a pin as an input or open-drain output. (Open- drain outputs require external pull-ups.)
1FD1H 1FD8H Port x Mode
Each bit of Px_MODE controls whether the corresponding pin functions as a standard I/O port pin or as a special-function signal. Setting a bit configures a pin as a special-function signal; clearing a bit configures a pin as a standard I/O port pin.
1FD5H 1FDCH Port x Data Output
For an input, set the corresponding Px_REG bit.
For an output, write the data to be driven out by each pin to the corresponding bit of Px_REG. When a pin is configured as standard I/O (Px_MODE.y = 0), the result of a CPU write to Px_REG is immediately visible on the pin. When a pin is configured as a special-function signal (Px_MODE.y = 1), the associated on-chip peripheral or off-chip component controls the pin. The CPU can still write to Px_REG, but the pin is unaffected until it is switched back to its standard I/O function.
This feature allows software to configure a pin as standard I/O (clear Px_MODE.y), initialize or overwrite the pin value, then configure the pin as a special-function signal (set Px_MODE.y). In this way, initialization, fault recovery, exception handling, etc., can be done without changing the operation of the associated peripheral.
Each power-saving mode conserves power by disabling portions of the internal clock circuitry (Figure 12-1 and Figure 12-2). The following paragraphs describe each mode in detail.
Mnemonic Address Description

XTAL1
XTAL2
Peripheral Clocks (PH1, PH2)
CPU Clocks (PH1, PH2)
Disable Clocks (Idle, Powerdown)

F XTAL1
XTAL1
F XTAL1
2F XTAL1 4F XTAL1
XTAL2
Disable Clocks (Standby, Powerdown)
PLLEN2
Peripheral Clocks (PH1, PH2)
CPU Clocks (PH1, PH2)
Disable Clocks (Idle, Standby, Powerdown)
12.3 IDLE MODE
In idle mode, the device’s power consumption decreases to approximately 40% of normal con- sumption. Internal logic holds the CPU clocks at logic zero, causing the CPU to stop executing instructions. Neither the phased-locked loop circuitry (80C196NU only), the peripheral clocks, nor CLKOUT are affected, so the special-function registers (SFRs) and register RAM retain their data and the peripherals and interrupt system remain active. Table B-5 on page B-13 lists the val- ues of the pins during idle mode.

The device enters idle mode after executing the IDLPD #1 instruction. Any enabled interrupt source, either internal or external, or a hardware reset can cause the device to exit idle mode. When an interrupt occurs, the CPU clocks restart and the CPU executes the corresponding inter- rupt service or PTS routine. When the routine is complete, the CPU fetches and then executes the instruction that follows the IDLPD #1 instruction.
In standby mode, the device’s power consumption decreases to approximately 10% of normal consumption. Internal logic holds the CPU and peripheral clocks at logic zero, which causes the CPU to stop executing instructions, the system bus control signals to become inactive, and the peripherals to turn off. The phase-locked loop (PLL) circuitry and the on-chip oscillator continue to operate. Table B-5 on page B-13 lists the values of the pins during standby mode.
Setting the PD bit in the chip-configuration register 0 (CCR0.0) enables both standby and pow- erdown modes. Clearing it disables both modes. CCR0 is loaded from the chip configuration byte (CCB0) when the device is reset.
Before entering standby mode, complete the following tasks:
After completing these tasks, execute the IDLPD #3 instruction to enter standby mode.

12.4.3 Exiting Standby Mode
The device will exit standby mode when a transition on an external interrupt pin (EXTINT3:0) or a hardware reset occurs. The interrupts need not be enabled for them to bring the device out of standby, but the pin must be configured as a special-function input (see “Bidirectional Port Pin Configurations” on page 7-7).
When an external interrupt brings the device out of standby mode, the corresponding pending bit is set in the interrupt pending register. If the interrupt is enabled, the device executes the interrupt service routine, then fetches and executes the instruction following the IDLPD #3 instruction. If the interrupt is disabled (masked), the device fetches and executes the instruction following the IDLPD #3 instruction and the pending bit remains set until the interrupt is serviced or software clears it.
Powerdown mode places the device into a very low power state by disabling the internal oscilla- tor, the phase-locked loop circuitry (80C196NU only), and clock generators. Internal logic holds the CPU and peripheral clocks at logic zero, which causes the CPU to stop executing instructions, the system bus-control signals to become inactive, the CLKOUT signal to become high, and the peripherals to turn off. Power consumption drops into the microwatt range (refer to the datasheet for exact specifications). ICC is reduced to device leakage. Table B-5 on page B-13 lists the values of the pins during powerdown mode. If VCC is maintained above the minimum specification, the special-function registers (SFRs) and register RAM retain their data.
Setting the PD bit in the chip-configuration register 0 (CCR0.0) enables both standby and pow- erdown modes. Clearing it disables both modes. CCR0 is loaded from the chip configuration byte (CCB0) when the device is reset.
Before entering powerdown, complete the following tasks:

After completing these tasks, execute the IDLPD #2 instruction to enter powerdown mode.
The device will exit powerdown mode when either of the following events occurs:
The device will exit powerdown if RESET# is asserted. If the phase-locked loop circuitry is en- abled or if the design uses an external clock input signal rather than the on-chip oscillator, RESET# must remain low for at least 16 state times. If the design uses the on-chip oscillator, then RESET# must be held low until the oscillator and phase-locked loop circuitry have stabilized.
The final way to exit powerdown mode is to assert an external interrupt signal (EXTINT3:0) for at least one state time. Although EXTINT3:0 are normally sampled inputs, the powerdown cir- cuitry uses them as level-sensitive inputs. The interrupts need not be enabled to bring the device out of powerdown, but the pin must be configured as a special-function input (see “Bidirectional Port Pin Configurations” on page 7-7). Figure 12-3 shows the power-up and powerdown se- quence when using an external interrupt to exit powerdown.
When an external interrupt brings the device out of powerdown mode, the corresponding pending bit is set in the interrupt pending register. If the interrupt is enabled, the device executes the in- terrupt service routine, then fetches and executes the instruction following the IDLPD #2 instruc- tion. If the interrupt is disabled (masked), the device fetches and executes the instruction following the IDLPD #2 instruction and the pending bit remains set until the interrupt is serviced or software clears the pending bit.

XTAL1
CLKOUT
PH1
RPD
Figure 12-3. Power-up and Powerdown Sequence When Using an External Interrupt
When using an external interrupt signal to exit powerdown mode, we recommend that you con- nect the external component shown in Figure 12-4 to the RPD pin. The discharging of the capac- itor causes a delay that allows the oscillator and phase-locked loop circuitry to stabilize before the internal CPU and peripheral clocks are enabled.
MCS® 96 Microcontroller
Figure 12-4. External RC Circuit

During normal operation (before entering powerdown mode), an internal pull-up holds the RPD pin at VCC. When an external interrupt signal is asserted, the internal oscillator circuitry is enabled and turns on a weak internal pull-down. The resistance of the internal pull-down should be approximately 10 kΩ. This weak pull-down causes the external capacitor (C1) to begin dis- charging at a typical rate of 200 µA. When the RPD pin voltage drops below the threshold voltage (about 2.5 V for 5 V operation and 1.6 V for 3 V operation), the internal phase clocks are enabled and the device resumes code execution.
At this time, a Schmitt-triggered detection circuit prompted by the switching voltage levels strongly drives a logic one, quickly pulling the RPD pin back up to VCC (see recovery time in Fig- ure 12-5). The time constant (RC) follows an exponential charging curve. However, since there is no external resistor on the RPD pin, the time constant goes to zero and the recovery time is instantaneous.
Vc Vcc 1 e
t τ ⁄ ( ) ] τ RC1 0 = = ( ) ; – [ =
Vc Vcc =
where:
VC = Charging capacitor voltage
With the resistance of the discharge path designed into the silicon via the internal pull-down, the selection of an external capacitor (C1) can be critical. Ideally, you want to select a component that will produce a sufficient discharge time to permit the internal oscillator circuitry to stabilize. Be- cause many factors can influence the discharge time requirement, you should always fully char- acterize your design under worst-case conditions to verify proper operation.

200 µA C1 Discharge
2 4 6 8 10 12 14 16 18 20 22
Figure 12-5. Typical Voltage on the RPD Pin While Exiting Powerdown
When selecting the capacitor, determine the worst-case discharge time needed for the oscillator to stabilize, then use this formula to calculate an appropriate value for C1.
Vt =
where:
C1 is the capacitor value, in farads
TDIS is the worst-case discharge time, in seconds
I is the discharge current, in amperes
Vt is the threshold voltage

For example, assume that the oscillator needs at least 12.5 ms to discharge (TDIS = 12.5 ms), Vt is 2.5 V, and the discharge current is 200 µA. The minimum C1 capacitor size is 1 µF.
0.0125 ( ) 0.0002 ( )
2.5 1 µF = =
When using an external oscillator, the value of C1 can be very small, allowing rapid recovery from powerdown. For example, a 100 pF capacitor discharges in 1.25 µs.
C1 Vt ×
I 1.0 10 10 – × ( ) 2.5 ( )
0.0002 1.25 µs = = =
On-circuit emulation (ONCE) mode isolates the device from other components in the system to allow printed-circuit-board testing or debugging with a clip-on emulator. During ONCE mode, all pins except XTAL1, XTAL2, VSS, and VCC are weakly pulled high or low. During ONCE mode, RESET# must be held high or the device will exit ONCE mode and enter the reset state.
Holding the ONCE signal high during the rising edge of RESET# causes the device to enter ONCE mode. The ONCE signal is latched when RESET# goes inactive. Internally, the ONCE pin is tied to a medium-strength pull-down. To prevent accidental entry into ONCE mode, connect the ONCE pin to VSS.
Exit ONCE mode by asserting the RESET# signal. Normal operations resume when RESET# goes high.
For the 80C196NU only, holding PLLEN1 low while PLLEN2 is held high causes the device to enter an unsupported test mode. Table 12-3 shows the proper PLLEN1 and PLLEN2 connections for valid clock modes.

Table 12-3. 80C196NU Clock Modes
0 0 Clock-multiplier circuitry disabled.
0 1 Reserved.
unsupported test mode.
1 0 Doubled; clock doubling circuitry enabled. Internal clock is twice the XTAL1 input.
1 1 Quadrupled; clock quadrupling circuitry enabled. Internal clock is four times the XTAL1 input.
PLLEN2 PLLEN1 Mode






The device can interface with a variety of external memory devices. Six chip-selects can be indi- vidually programmed for bus width, the number of wait states, and a multiplexed or demulti- plexed address/data bus. Other features of the external memory interface include ready control for inserting additional wait states, a bus-hold protocol that enables external devices to take con- trol of the bus, and two write-control modes for writing words and bytes to memory. These fea- tures provide a great deal of flexibility when interfacing with external memory devices.
In addition to describing the signals and registers related to external memory, this chapter discuss- es the process of fetching the chip configuration bytes and configuring the external bus. It also provides examples of external memory configurations and chip-select setup.
The address that external devices see is different from the address that the device generates inter- nally. Internally, the device has 24 address lines, but only the lower 20 address lines (A19:0) are implemented with external pins. The absence of the upper four address bits at the external pins causes different internal addresses to have the same external address. For example, the internal addresses FF2080H, 7F2080H, and 0F2080H all appear at the 20 external pins as F2080H. The upper nibble of the internal address has no effect on the external address.
The address seen by an external device also depends on the number of address lines that the ex- ternal system uses. If the address on the external pins (A19:0) is F2080H, and only A17:0 are con- nected to the external device, the external device sees 32080H. The upper four address lines (A19:16) are implemented by the EPORT. Table 13-1 shows how the external address depends on the number of EPORT lines used to address the external device.
EPORT Lines Connected to the
Internal Address Address on the
A16 xF2080H F2080H 12080H
A17:16 xF2080H F2080H 32080H
A18:16 xF2080H F2080H 72080H
A19:16 xF2080H F2080H F2080H

Table 13-2 describes the external memory interface signals. For some signals, the pin has an al- ternate function (shown in the Multiplexed With column). In some cases the alternate function is a port signal (e.g., P2.7). Chapter 7, “I/O Ports,” describes how to configure a pin for its I/O port function and for its special function. In other cases, the signal description includes instructions for selecting the alternate function.
Name Type Description Multiplexed
A15:0 I/O System Address Bus
These address lines provide address bits 15–0 during the entire external memory cycle during both multiplexed and demultiplexed bus modes.
A19:16 I/O Address Lines 16–19
These address lines provide address bits 16–19 during the entire external memory cycle, supporting extended addressing of the 1 Mbyte address space.
AD15:0 I/O Address/Data Lines
The function of these pins depend on the bus size and mode. When a bus access is not occurring, these pins revert to their I/O port function. 16-bit Multiplexed Bus Mode: AD15:0 drive address bits 0–15 during the first half of the bus cycle and drive or receive data during the second half of the bus cycle. 8-bit Multiplexed Bus Mode: AD15:8 drive address bits 8–15 during the entire bus cycle. AD7:0 drive address bits 0–7 during the first half of the bus cycle and either drive or receive data during the second half of the bus cycle. 16-bit Demultiplexed Mode: AD15:0 drive or receive data during the entire bus cycle.
8-bit Demultiplexed Mode: AD7:0 drive or receive data during the entire bus cycle. AD15:8 drive the data that is currently on the high byte of the internal bus.
With

Table 13-2. External Memory Interface Signals (Continued)
Name Type Description Multiplexed
ALE O Address Latch Enable
This active-high output signal is asserted only during external memory cycles. ALE signals the start of an external bus cycle and indicates that valid address information is available on the system address/data bus (A19:16 and AD15:0 for a multiplexed bus; A19:0 for a demultiplexed bus). ALE differs from ADV# in that it does not remain active during the entire bus cycle.
An external latch can use this signal to demultiplex address bits 0–15 from the address/data bus in multiplexed mode.
BHE# O Byte High Enable†
During 16-bit bus cycles, this active-low output signal is asserted for word reads and writes and high-byte reads and writes to external memory. BHE# indicates that valid data is being transferred over the upper half of the system data bus. Use BHE#, in conjunction with A0, to determine which memory byte is being transferred over the system bus:
BHE# A0 Byte(s) Accessed
0 0 both bytes 0 1 high byte only 1 0 low byte only
† The chip configuration register 0 (CCR0) determines whether this pin functions as BHE# or WRH#. CCR0.2 = 1 selects BHE#; CCR0.2 = 0 selects WRH#.
BREQ# O Bus Request
This active-low output signal is asserted during a hold cycle when the bus controller has a pending external memory cycle.
The device can assert BREQ# at the same time as or after it asserts HLDA#. Once it is asserted, BREQ# remains asserted until HOLD# is removed.
You must enable the bus-hold protocol before using this signal (see “Enabling the Bus-hold Protocol” on page 13-32).
CLKOUT O Clock Output
Output of the internal clock generator. The CLKOUT frequency is ½ the internal operating frequency (f). CLKOUT has a 50% duty cycle.
CS5:0# O Chip-select Lines 0–5
The active-low output CSx# is asserted during an external memory cycle when the address to be accessed is in the range programmed for chip select x. If the external memory address is outside the range assigned to the six chip selects, no chip-select output is asserted and the bus configuration defaults to the CS5# values.
Immediately following reset, CS0# is automatically assigned to the range FF2000–FF20FFH (F2000–F20FFH if external).
With

Name Type Description Multiplexed
EA# I External Access
This input determines whether memory accesses to special-purpose and program memory partitions (FF2000–FF2FFFH) are directed to internal or external memory. These accesses are directed to internal memory if EA# is held high and to external memory if EA# is held low. For an access to any other memory location, the value of EA# is irrelevant.
EA# is not latched and can be switched dynamically during normal operating mode. Be sure to thoroughly consider the issues, such as different access times for internal and external memory, before using this dynamic switching capability.
On devices with no internal nonvolatile memory, always connect EA# to VSS.
EA# is not implemented on the 80C196NU.
HLDA# O Bus Hold Acknowledge
This active-low output indicates that the CPU has released the bus as the result of an external device asserting HOLD#.
HOLD# I Bus Hold Request
An external device uses this active-low input signal to request control of the bus. This pin functions as HOLD# only if the pin is configured for its special function (see “Bidirectional Port Pin Configurations” on page 7-7) and the bus-hold protocol is enabled. Setting bit 7 of the window selection register (WSR) enables the bus-hold protocol.
INST O Instruction Fetch
This active-high output signal is valid only during external memory bus cycles. When high, INST indicates that an instruction is being fetched from external memory. The signal remains high during the entire bus cycle of an external instruction fetch. INST is low for data accesses, including interrupt vector fetches and chip configuration byte reads. INST is low during internal memory fetches.
Read-signal output to external memory. RD# is asserted only during external memory reads.
READY I Ready Input
This active-high input signal is used to lengthen external memory cycles for slow memory by generating wait states in addition to the wait states that are generated internally.
When READY is high, CPU operation continues in a normal manner with wait states inserted as programmed in CCR0 or the chip-select x bus control register. READY is ignored for all internal memory accesses.
With · RD# O Read

Table 13-2. External Memory Interface Signals (Continued)
Name Type Description Multiplexed
WR# O Write†
This active-low output indicates that an external write is occurring. This signal is asserted only during external memory writes.
† The chip configuration register 0 (CCR0) determines whether this pin functions as WR# or WRL#. CCR0.2 = 1 selects WR#; CCR0.2 = 0 selects WRL#.
WRH# O Write High†
During 16-bit bus cycles, this active-low output signal is asserted for high-byte writes and word writes to external memory. During 8-bit bus cycles, WRH# is asserted for all write operations.
† The chip configuration register 0 (CCR0) determines whether this pin functions as BHE# or WRH#. CCR0.2 = 1 selects BHE#; CCR0.2 = 0 selects WRH#.
WRL# O Write Low†
During 16-bit bus cycles, this active-low output signal is asserted for low-byte writes and word writes. During 8-bit bus cycles, WRL# is asserted for all write operations.
† The chip configuration register 0 (CCR0) determines whether this pin functions as WR# or WRL#. CCR0.2 = 1 selects WR#; CCR0.2 = 0 selects WRL#.
The chip-select unit provides six outputs, CS5:0#, for selecting an external device during an ex- ternal bus cycle. During an external memory access, a chip-select output CSx# is asserted if the address falls within the address range assigned to that chip-select. The bus width, the number of wait states, and multiplexed or demultiplexed address/data lines are programmed independently for each of the six chip-selects. If the external address is outside the range of the six chip-selects, the chip-select 5 bus control register determines the wait states, bus width, and multiplexing, and no chip-select is asserted. Table 13-3 lists the chip-select registers.
With

Register Mnemonic Address Description
1F40H 1F48H 1F50H 1F58H 1F60H 1F68H
This 16-bit register holds the upper 12 bits of the base address of the address range assigned to CSx#.
1F42H 1F4AH 1F52H 1F5AH 1F62H 1F6AH
This register determines the size of the address range (256 bytes–1 Mbyte).
1F44H 1F4CH 1F54H 1F5CH 1F64H 1F6CH
This register determines the bus configuration for external accesses to the address range assigned to CSx#. The bus parameters are 8- or 16-bit bus width, multiplexed or demultiplexed address/data lines, and the number of wait states inserted into each bus cycle.
Figure 13-1 illustrates the device’s calculation of a chip-select output CSx# for a given external memory address. The 12 most-significant bits of the external address are compared (XORed) bit- wise with the 12 least-significant bits (BASE19:8) of the ADDRCOMx register. If all of the bits match, CSx# is asserted. Additionally, if some bits do not match, CSx# is still asserted if, for each non-matching bit in ADDRCOMx, the corresponding bit in ADDRMSKx is cleared. The 12 least- significant bits are named MASK19:8 for their function in masking bits BASE19:8.
External Address ADDRCOMx ADDRMSKx
0 7 8 19 0 11 12 15 0 11 12 15
bit x bit x

13.3.1 Defining Chip-select Address Ranges
This section describes the ADDRCOMx and ADDRMSKx registers and how to set them up for a desired address range. The ADDRCOMx register (Figure 13-2) and ADDRMSKx register (Fig- ure 13-3) control the assertion of each chip-select output CSx#. The BASE19:8 bits in the ADDRCOMx register determine the base address of the address range. The MASK19:8 bits in the ADDRMSKx register determine the size of the address range.
ADDRCOMx x = 0–5
The address compare (ADDRCOMx) register specifies the base (lowest) address of the address range. The base address of a 2n-byte address range must be on a 2n-byte boundary.
BASE15 BASE14 BASE13 BASE12 BASE11 BASE10 BASE9 BASE8
15:12 — Reserved; for compatibility with future devices, write zeros to these bits.
11:0 BASE19:8 Base Address Bits
These bits are the 12 most-significant bits of the base address of the address range assigned to chip-select x.
Table 13-4. ADDRCOMx Addresses and Reset Values
Register Address Reset Value
ADDRCOM1 1F48H X000H
ADDRCOM2 1F50H X000H
ADDRCOM3 1F58H X000H
ADDRCOM4 1F60H X000H
ADDRCOM5 1F68H X000H
Table 13-4 · Bit Number · Bit Mnemonic Function

ADDRMSKx x = 0–5
The address mask (ADDRMSKx) register, together with the address compare register, defines the address range that is assigned to the chip-select x output, CSx#. The address mask register determines the size of the address range, which must be 2n bytes, where n = 8, 9, . . , 20. For a 2n- byte address range, calculate n1 = 20 – n, and set the n1 most-significant bits of MASK19:8 in the address mask register.
MASK15 MASK14 MASK13 MASK12 MASK11 MASK10 MASK9 MASK8
15:12 — Reserved; for compatibility with future devices, write zeros to these bits.
11:0 MASK19:8 Address Mask Bits
For a 2n-byte address range, set the n1 most-significant bits of MASK19:8, where n1 = 20 – n.
Table 13-5. ADDRMSKx Addresses and Reset Values
Register Address Reset Value
ADDRMSK1 1F4AH XFFFH
ADDRMSK2 1F52H XFFFH
ADDRMSK3 1F5AH XFFFH
ADDRMSK4 1F62H XFFFH
ADDRMSK5 1F6AH XFFFH
Table 13-5 · Bit Number · Bit Mnemonic Function

Observe the following restrictions in choosing an address range for a chip-select output:
Address- Range Size 1 Mbyte 512 Kbyte 256 Kbyte 512 bytes 256 bytes
80000H 40000H 00200H 00100H
FFD00H FFF00H
For an address range satisfying these restrictions, set up the ADDRCOMx and ADDRMSKx reg- isters as follows:
For example, assume that chip-select output x is to be assigned to a 32-Kbyte address range with base address E0000H. The address range size is 32 × 1024 = 215, and n1 = 20 –15 = 5. To set up the registers, write the 12 most-significant bits of E0000H to BASE19:8 in the ADDRCOMx reg- ister, and set the 5 most-significant bits of MASK19:8 in the ADDRMSKx register:
Base Addresses · ADDRCOMx = 0E00H · ADDRMSKx = 0F80H

“Example of a Chip-select Setup” on page 13-12 shows another example of setting up the chip- select unit.
For each chip-select output address range, the bus control register BUSCONx (Figure 13-4) de- termines the wait states, the bus width, and the address/data multiplexing.
BUSCONx x = 0–5
For the address range assigned to chip-select x, the bus control (BUSCONx) register specifies the number of wait states, the bus width, and the address/data multiplexing for all external bus cycles that access address range x.
7 DEMUX Address/Data Multiplexing
This bit specifies the address/data multiplexing on AD15:0 for all external accesses to the address range assigned to chip-select x output.
0 = multiplexed 1 = demultiplexed
6 BW16 Bus Width
This bit specifies the bus width for all external accesses to the address range assigned to chip-select x output.
0 = 8 bits 1 = 16 bits
5:2 — Reserved; for compatibility with future devices, write zeros to these bits.
1:0 WS1:0 Wait States
These bits specify the number of wait states for all external accesses to the address range assigned to chip-select x output.
WS1 WS0 Wait States
0 1 1 1 0 2 1 1 3
Table 13-7 · Bit Number · Bit Mnemonic Function

Table 13-7. BUSCONx Addresses and Reset Values
Register Address Reset Value
BUSCON1 1F4CH 00H
BUSCON2 1F54H 00H
BUSCON3 1F5CH 00H
BUSCON4 1F64H 00H
BUSCON5 1F6CH 00H
13.3.3 Chip-select Unit Initial Conditions
A chip reset produces the following initial conditions for the chip-select unit:
The first lines of your program should perform two tasks:
When initializing the chip-select parameters (or modifying them at any time), it is important to avoid a condition in which two chip-selects outputs have overlapping address ranges and different bus-parameter values (wait states, bus width, and multiplexing). Accessing a location in such an overlapping address range can cause unpredictable results.

Use the following sequence to initialize the chip-select registers after reset:
1.1. Clear ADDRMSK0.
1.2. Write to ADDRCOM0 to establish the desired base address.
1.3. Write to ADDRMSK0 to establish the desired address range.
1.4. Write the desired bus-parameter values to BUSCON0.
2.1. Load ADDRMSKx with 0FFFH.
2.2. Write to ADDRCOMx to establish the desired base address.
2.3. Write to ADDRMSKx to establish the desired address range.
2.4. Write the desired bus-parameter values to BUSCONx.
2.5. Repeat steps 2.1–2.4 for x = 2–5.
This section shows an example of setting up the chip-select unit and provides details of the chip- select output calculation. This example shows how to set up the chip-select registers for the sys- tem shown in Figure 13-5. For each address range, the BUSCONx register (see Figure 13-4) spec- ifies the address/data multiplexing (bit 7), the bus width (bit 6), and the number of wait states (bits 1, 0). Table 13-8 lists the characteristics of the three chip-select outputs and the corresponding contents of BUSCONx.

8K×8
CS0# CS2#
CE#
CE#
AD15:0
AD7:0
AD15:0
D15:0
D7:0
0 WS 80000–FFFFFH
0 WS 7E000–7FFFFH
WE# OE# WE# OE#
RD# WR#
82510 UART
AD7:0
D7:0
3 WS 01E00–01EFFH
CS1#
CE#
Figure 13-5. Example System for Setting Up Chip-select Outputs
Table 13-8. BUSCONx Registers for the Example System
Multiplexing Bus Width Wait States Contents of
0 Demultiplexed 16 bits 0 C0H
1 Demultiplexed 8 bits 3 83H
2 Demultiplexed 8 bits 0 80H
The location and size of an address range are specified by the ADDRCOMx register and the ADDRMSKx register (see Figure 13-2 and Figure 13-3). The 8-Kbyte SRAM is assigned to ad- dress range 7E000–7FFFFH and uses chip-select output 2. The 12 most-significant bits of the base address (7E000H) are written to the BASE19:8 bits in the ADDRCOM2 register, which then contains 07E0H.
The address range for CS2# is 8 Kbytes or 213 bytes (n = 13). The number of bits to be set in MASK19:8 of ADDRMSK2 is 20 – n = 7. After the 7 most-significant bits of MASK19:8 are set, ADDRMSK2 contains 0FE0H. Results for CS0# and CS1# are found similarly (see Table 13-9).

Number of Bits to Set in
Size of Address Range
0 80000–FFFFFH 512 Kbytes = 219 bytes n1 = 20 – 19 = 1 0800H 0800H
1 01E00–01EFFH 256 bytes = 28 bytes n1 = 20 – 8 = 12 001EH 0FFFH
2 7E000–7FFFFH 8 Kbytes = 213 bytes n1 = 20 – 13 = 7 07E0H 0FE0H
Two chip configuration registers (CCRs) have bits that set parameters for chip operation and ex- ternal bus cycles. The CCRs cannot be accessed by code. They are loaded from the chip config- uration bytes (CCBs), which have internal addresses FF2018H (CCB0) and FF201AH (CCB1). If the CCBs are stored in external memory, their external addresses depend on the number of EPORT lines used in the external system (see “Internal and External Addresses” on page 13-1).
When the device returns from reset, the bus controller fetches the CCBs and loads them into the CCRs. From this point, these CCR bit values define the chip configuration until the device is reset again. The CCR bits are described in Figures 13-6 and 13-7. The remainder of this section de- scribes the state of the chip following reset and the process of fetching the CCBs.

CCR0 no direct access†
The chip configuration 0 (CCR0) register enables or disables powerdown and standby (80C196NU only) modes and selects the write-control mode. It also contains the bus-control parameters for fetching chip configuration byte 1.
7:6 1 To guarantee device operation, write ones to these bits.
5:4 WS1:0 Wait States
These two bits control the number of wait states that are used for an external fetch of CCB1.
0 0 zero wait states 0 1 one wait state 1 0 two wait states 1 1 three wait states
3 DEMUX Select Demultiplexed Bus
Selects the demultiplexed bus mode for an external fetch of CCB1:
0 = multiplexed — address and data are multiplexed on AD15:0. 1 = demultiplexed — data only on AD15:0.
2 BHE# Write-control Mode
Selects the write-control mode, which determines the functions of the BHE#/WRH# and WR#/WRL# pins for external bus cycles:
0 = write strobe mode: the BHE#/WRH# pin operates as WRH#, and the WR#/WRL# pin operates as WRL#. 1 = standard write-control mode: the BHE#/WRH# pin operates as BHE#, and the WR#/WRL# pin operates as WR#.
1 BW16 Buswidth Control
Selects the bus width for an external fetch of CCB1:
0 = 8-bit bus 1 = 16-bit bus
0 PD Powerdown Enable
Enables or disables the IDLPD #2 and IDLPD #3 instructions. When enabled, the IDLPD #2 instruction causes the microcontroller to enter powerdown mode and for the 80C196NU only, the IDLPD #3 instruction causes the microcontroller to enter standby mode.
0 = disable powerdown and standby modes 1 = enable powerdown and standby modes
If your design uses powerdown or standby mode, set this bit when you program the CCBs. If it does not, clearing this bit when you program the CCBs will prevent accidental entry into powerdown and standby mode†. (Chapter 12, “Special Operating Modes,” discusses powerdown and standby modes.)
† The CCRs are loaded with the contents of the chip configuration bytes (CCBs) after a device reset.
The CCBs reside in nonvolatile memory at addresses FF2018H (CCB0) and FF201AH (CCB1).
Bit Number · Bit Mnemonic Function

CCR1 no direct access†
The chip configuration 1 (CCR1) register selects the 16-bit or 24-bit addressing mode and (for the 8XC196NP only) controls whether the internal ROM is mapped into two address ranges, FF2000– FF2FFFH and 002000–002FFFH, or into FF2000–FF2FFFH only.
8XC196NP 1 1 0 1 1 REMAP MODE64 —
80C196NU 1 1 DM 1 1 — MODE64 —
7:6 1 To guarantee device operation, write ones to these bits.
5†† DM Deferred Mode
Enables the deferred bus-cycle mode. If the 80C196NU is using a demulti- plexed bus and deferred mode is enabled, a delay of 2t occurs in the first bus cycle following a chip-select output change and the first write cycle following a read cycle. (See “Deferred Bus-cycle Mode (80C196NU Only)” on page 13-40.)
0 = deferred bus-cycle mode disabled 1 = deferred bus-cycle mode enabled
4:3 1 To guarantee device operation, write ones to these bits.
2†† REMAP Internal ROM Mapping
Controls the internal ROM mapping.
0 = ROM maps to FF2000–FF2FFFH only 1 = ROM maps to FF2000–FF2FFFH and 002000–002FFFH
1 MODE64 Addressing Mode
Selects 64-Kbyte or 1-Mbyte addressing.
0 = selects 1-Mbyte addressing 1 = selects 64-Kbyte addressing
0 — Reserved; for compatibility with future devices, write zero to this bit.
† The CCRs are loaded with the contents of the chip configuration bytes (CCBs) after a device reset. The CCBs reside in nonvolatile memory at addresses FF2018H (CCB0) and FF201AH (CCB1).
†† Bit 5 is reserved on the 8XC196NP device and bit 2 is reserved on the 80C196NU device. For
compatibility with future devices, write zeros to these bits.
Upon leaving the reset state, the device is configured for normal operation. This section describes the state of the chip following reset and summarizes the steps in the configuration process.
Bit Number · Bit Mnemonic Function

Following reset, the chip automatically fetches the two chip configuration bytes.
If the CCBs are stored in external ROM, chip-select output 0 (CS0#) should be connected to that device. Chip-select output 0 is initialized for the address range FF2000–FF20FFH, which in- cludes the CCB locations. Following the CCB fetches, the device fetches the instruction at FF2080H.
The device uses the following bus control parameters for the CCB0 fetch:
CCB0 can be fetched over a 16-bit bus, even though BW16 defaults to 8 bits for the CCB0 fetch. The upper address lines A19:8 and AD15:8 are strongly driven during the CCB0 fetch because an 8-bit bus is assumed. Therefore, if you have a 16-bit data bus, write the value 20H to FF2019H to avoid contention on AD15:8. Lines A19:0 are driven in the multiplexed mode. You can access the memory using A19:0 and use AD15:0 for data only.
CCB0 itself contains bits that specify DEMUX, BW16, WS0, and WS1. These values are used to control the CCB1 fetch, and following the fetch, they are stored in the chip-select output 0 bus control register, BUSCON0 (see “Chip-select Unit Initial Conditions” on page 13-11). The bits in CCB0 and CCB1 are described in “Chip Configuration Registers and Chip Configuration Bytes” on page 13-14.

After RESET# is deasserted, the following pins are initialized:
Following reset, you should set the stack pointer and initialize the chip-select outputs using the procedure in “Example of a Chip-select Setup” on page 13-12.
The external bus can operate with a 16-bit or 8-bit data bus and with a multiplexed or demulti- plexed address/data bus. Figure 13-8 shows the external bus signals during operation in the four combinations of bus width and multiplexing.

A19:16 (EPORT)
A19:16 (EPORT)
Driven with the data currently on the internal bus.
AD15:0
AD7:0
8-bit Demultiplexed Bus 16-bit Demultiplexed Bus
A19:16 (EPORT)
A19:16 (EPORT)
AD15:8
AD15:0
AD7:0 8XC196 Device
Figure 13-8. Multiplexing and Bus Width Options

A design can incorporate external devices that operate with different bus widths and multiplex- ing. The bus parameters used during a particular bus cycle are determined by the chip-select out- put that is assigned to the address being accessed. Figure 13-9 shows the address and data bus configurations for the four combinations of bus width and multiplexing. For detailed waveforms, see “16-bit Bus Timings” on page 13-22 and “System Bus AC Timing Specifications” on page 13-36.
ALE
A19:0 Address
A19:0 Address
AD15:0 Data
AD15:8 Driven†
AD7:0 Data
16-bit Demultiplexed Bus 8-bit Demultiplexed Bus
A19:0 Address
A19:0 Address
AD15:0 Data
AD15:8 Address
16-bit Multiplexed Bus 8-bit Multiplexed Bus
† AD15:8 drive the data currently on the high byte of the internal bus.
In an 8- or 16-bit demultiplexed mode (top of Figure 13-8 and Figure 13-9), the external device receives the address from A19:0. In a 16-bit system, the data is on AD15:0. In an 8-bit system, the data is on AD7:0. AD15:8 drive the data currently on the high byte of the internal bus.
In multiplexed mode (bottom half of Figure 13-8 and Figure 13-9), both A19:0 and AD15:0 drive the address. A19:0 drive the address throughout the entire bus cycle. For a 16-bit bus width, AD15:0 drive the address for the first half of the bus cycle and drive or receive data during the second half. In the 8-bit case, AD15:8 drive the address during the entire bus cycle.
Address · Data Address

In multiplexed mode, with the full address on the bus for only half of the cycle, the external de- vice has less time to receive it and to respond. As a result, for the same bus-cycle length (4t) a multiplexed system requires a faster external device (unless wait states are added to the bus cy- cle). Although the multiplexed mode has this disadvantage, it is useful for compatibility with de- vices designed for multiplexed operation.
In a 16-bit system (left side of Figure 13-8 and Figure 13-9) one data word can be transferred over AD15:0 in a single bus cycle. In an 8-bit system, one data word is transferred as two bytes over AD7:0 in successive bus cycles, and AD15:8 drive the upper eight address bits for the entire bus cycle.
The flexibility of the chip-select unit enables you to specify the bus width, the number of wait states, and a multiplexed or demultiplexed bus for each of the six chip-select outputs. The system in Figure 13-5 on page 13-13 illustrates a mixture of 8-bit and 16-bit devices with different num- bers of wait states.
Figure 13-10 shows a 16-bit system in demultiplexed mode. The flash memory receives the ad- dress on A18:1; data is transferred on AD15:0. Using the WR# signal as shown, this system writes words and not single bytes to the memory. (Using WRL# and WRH#, you can write single bytes on a 16-bit bus.

CS#
CS#
AD15:0
AD15:0
AD15:0
D15:0
D15:0
WE# OE# WE# OE#
RD# WR#
Figure 13-10. 16-bit External Devices in Demultiplexed Mode
13.5.2 16-bit Bus Timings
Figure 13-11 shows idealized 16-bit external-bus timings for the 8XC196NP. The signals are di- vided into two groups: signals for a demultiplexed bus (top) and signals for a multiplexed bus (bottom). Several bus signals are omitted from the figure to focus on a comparison of multiplexed and demultiplexed buses. The timing parameters are addressed in “Comparison of Multiplexed and Demultiplexed Buses” on page 13-26. Comprehensive timing specifications for both the 8XC196NP and the 80C196NU are shown in Figures 13-20 through 13-23.
CLKOUT and ALE are the same in multiplexed and demultiplexed buses. The CLKOUT period is twice the internal oscillator period (2t). The bus cycles shown here, which have no wait states, require two CLKOUT periods (two state times).
The rising edge of the address latch enable (ALE) indicates that the device is driving an address onto the bus (A19:16 and AD15:0). The device presents a valid address before ALE falls. In a multiplexed system, the ALE signal is used to strobe a transparent latch (such as a 74AC373), which captures the address from AD15:0 and holds it while the bus controller puts data onto AD15:0.
8XC196 Flash 256K×16 · Flash 256K×16

CLKOUT
ALE
RD#
T RLDV
T AVDV
T RHDZ
AD15:0
T WLWH
WR#
T QVWH
AD15:0
CLKOUT
ALE
Address A19:16
RD#
T AVDV
T RHDZ
AD15:0
T WLWH
WR#
T QVWH
AD15:0
Data Address Data Address

Figure 13-12 shows idealized 8-bit timings for the 8XC196NP. One cycle is required for an 8-bit read or write. A 16-bit access requires two cycles. The first cycle accesses the lower byte, and the second cycle accesses the upper byte. Except for requiring an extra cycle to write the bytes sep- arately, the timings are the same as on the 16-bit bus, and the comparison between the multiplexed and demultiplexed cases is also the same. The demultiplexed bus can accommodate slower mem- ory devices than the multiplexed bus can.

CLKOUT
ALE
Address A19:0
High Address High Address
Data AD7:0
AD7:0
CLKOUT
ALE
Address A19:16 Address
AD7:0
Data Low Address Data
AD15:8 High Address High Address
AD7:0
Data Low Address Data Low Address
AD15:8 High Address High Address

This section compares the timings for multiplexed and demultiplexed buses. A 16-bit bus is used for the comparison. “8-bit Bus Timings” on page 13-24 compares the 8-bit and 16-bit buses.
In a multiplexed system, where AD15:0 carry both address and data, bus activities are time-com- pressed in comparison with a demultiplexed system, where the address and data have separate lines (A19:0 and AD15:0). The compression is reflected in differences in specifications for the demultiplexed and multiplexed bus. Table 13-10 lists several bus specifications and their values for demultiplexed and multiplexed buses. The data shows that the demultiplexed bus can accom- modate slower memory devices. (See “System Bus AC Timing Specifications” on page 13-36 for a complete list of AC timing definitons.)
Bus Spec. Description Demultiplexed Bus (ns)† Multiplexed Bus (ns)†
Max. time from RD# asserted to valid input data on the bus. 2t – 25 t – 20
T AVDV
Max. time from A19:0 and CSx# valid to valid input data on the bus. 4t – 50 3t – 40
Max. time from RD# deasserted until data bus is at high impedance. t t
Minimum time that WR# is asserted. 2t – 10 t – 5
Minimum time from valid data on the bus to WR# deasserted. 3t – 33 t – 15
† Consult the device datasheet for the latest specifications.
An external device can use the READY input to request wait states in addition to the wait states that are generated internally by the 8XC196Nx device. When an address is placed on the bus for an external bus cycle, the external device can pull the READY signal low to indicate it is not ready. In response, the bus controller inserts wait states to lengthen the bus cycle until the external device raises the READY signal. Each wait state adds one CLKOUT period (i.e., one state time or 2t) to the bus cycle.
The READY signal is effective for all bus cycles, including the CCB0 fetch (which has three in- ternal wait states). Bits WS0 and WS1 in CCB0 specify the wait states for the CCB1 fetch. There- after, the WS0 and WS1 bits in the BUSCONx registers control the wait states, and the READY signal can be used to insert additional wait states. (See “Controlling Wait States, Bus Width, and Bus Multiplexing” on page 13-10.)

When selecting infinite wait states, be sure to add external hardware to count wait states and re- lease READY within a specified period of time. Otherwise, a defective external device could tie up the address/data bus indefinitely.
Setup and hold timings must be met when using the READY signal to insert wait states into a bus cycle (see Table 13-11 and Figures 13-13 through 13-15). Because a decoded, valid address is used to generate the READY signal, the setup time is specified relative to the address being valid. This specification, TAVYV, indicates how much time the external device has to decode the address and assert READY after the address is valid. The READY signal must be held valid until the TCLYX timing specification is met. Typically, this is a minimum of 0 ns from the time CLKOUT goes low. Do not exceed the maximum TCLYX specification or additional (unwanted) wait states might be added. In all cases, refer to the datasheets for the current specifications for TAVYV and TCLYX.
TAVDV Address Valid to Input Data Valid
Maximum time the memory device has to output valid data after the device outputs a valid address.
TAVYV Address Valid to READY Setup
Maximum time the memory system has to assert READY after the device outputs the address to guarantee that at least one wait state will occur.
TCHYX READY Hold after CLKOUT High
If maximum specification is exceeded, additional wait states will occur.
TCLYX READY Hold after CLKOUT Low
Minimum hold time is always 0 ns. If maximum specification is exceeded, additional wait states will occur.
TLHLH ALE Cycle Time
Minimum time between ALE pulses.
TRLDV RD# Low to Input Data Valid
Maximum time the memory system has to output valid data after the device asserts RD#.
TRLRH RD# Low to RD# High
RD# pulse width.
TQVWH Data Valid to WR# High
Time between data being valid on the bus and WR# going inactive. Memory devices must meet this specification.
TWLWH WR# Low to WR# High
WR# pulse width.
Symbol Definition






13.7 BUS-HOLD PROTOCOL
The 8XC196Nx supports a bus-hold protocol that allows external devices to gain control of the address/data bus. The protocol uses three signals, all of which are port 2 special functions: HOLD#/P2.5 (bus-hold request), HLDA#/P2.6 (bus-hold acknowledge), and BREQ#/P2.3 (bus request). When an external device wants to use the 8XC196Nx bus, it asserts the HOLD# signal. HOLD# is sampled while CLKOUT is low. The 8XC196Nx responds by releasing the bus and asserting HLDA#. During this hold time, the address/data bus floats, and signals CSx#, ALE, RD#, WR#/WRL#, BHE#/WRH#, and INST are weakly held in their inactive states. Figure 13-16 shows the timing for bus-hold protocol, and Table 13-12 on page 13-31 lists the timing pa- rameters and their definitions. Refer to the datasheet for timing parameter values.


Table 13-12. HOLD#, HLDA# Timing Definitions

THAHAX HLDA# High to Address No Longer Float
THALBZ HLDA# Low to BHE#, INST, RD#, WR#, WRL#, WRH# Weakly Driven
THAHBV HLDA# High to BHE#, INST, RD#, WR#, WRL#, WRH# valid
TCLLH Clock Falling to ALE Rising; Use to derive other timings.
When the external device is finished with the bus, it relinquishes control by driving HOLD# high. In response, the 8XC196Nx deasserts HLDA# and resumes control of the bus.

If the 8XC196Nx has a pending external bus cycle while it is in hold (another device has control of the bus), it asserts BREQ# to request control of the bus. After the external device responds by releasing HOLD#, the 8XC196Nx exits hold and then deasserts BREQ# and HLDA#.
To use the bus-hold protocol, you must configure P2.3/BREQ#, P2.5/HOLD#, and P2.6/HLDA# to operate as special-function signals. BREQ# and HLDA# are active-low outputs; HOLD# is an active-low input.
You must also set the hold enable bit (HLDEN) in the window selection register (WSR.7) to en- able the bus-hold protocol. Once the bus-hold protocol has been selected, the port functions of P2.3, P2.5, and P2.6 cannot be selected without resetting the device. (During the time that the pins are configured to operate as special-function signals, their special-function values can be read from the P2_PIN.x bits.) However, the hold function can be dynamically enabled and disabled as described in “Disabling the Bus-hold Protocol.”
To disable hold requests, clear WSR.7. The 8XC196Nx does not take control of the bus immedi- ately after HLDEN is cleared. Instead, it waits for the current hold request to finish and then dis- ables the bus-hold feature and ignores any new requests until the bit is set again.
Sometimes it is important to prevent another device from taking control of the bus while a block of code is executing. One way to protect a code segment is to clear WSR.7 and then execute a JBC instruction to check the status of the HLDA# signal. The JBC instruction prevents the RALU from executing the protected block until current hold requests are serviced and the hold feature is disabled. This is illustrated in the following code:
DI ;Disable interrupts to prevent ;code interruption PUSH WSR ;Disable hold requests and LDB WSR,#1FH ;window Port 2 WAIT: JBC P2_PIN,6, WAIT ;Check the HLDA# signal. If set, ;add protected instruction here POP WSR ;Enable hold requests EI ;Enable interrupts
When an external device asserts HOLD#, the 8XC196Nx finishes the current bus cycle and then asserts HLDA#. The time it takes the device to assert HLDA# after the external device asserts HOLD# is called hold latency (see Figure 13-16 on page 13-31). Table 13-13 lists the maximum hold latency for each type of bus cycle.

Table 13-13. Maximum Hold Latency
Bus Cycle Type Maximum Hold Latency
Internal execution or idle mode 1.5
16-bit external execution 2.5 + 1 per wait state
8-bit external execution 2.5 + 2 per wait state
While HOLD# is asserted, the 8XC196Nx continues executing code until it needs to access the external bus. If executing from internal memory, it continues until it needs to perform an external memory cycle. If executing from external memory, it continues executing until the queue is emp- ty or until it needs to perform an external data cycle. As soon as it needs to access the external bus, the 8XC196Nx asserts BREQ# and waits for the external device to deassert HOLD#. After asserting BREQ#, the 8XC196Nx cannot respond to any interrupt requests, including NMI, until the external device deasserts HOLD#. One state time after HOLD# goes high, the 8XC196Nx deasserts HLDA# and, with no delay, resumes control of the bus.
If the 8XC196Nx is reset while in hold, bus contention can occur. For example, a CPU-only de- vice would try to fetch the chip configuration byte from external memory after RESET# was brought high. Bus contention would occur because both the external device and the 8XC196Nx would attempt to access memory. One solution is to use the RESET# signal as the system reset; then all bus masters (including the 8XC196Nx) are reset at once. Chapter 11, “Minimum Hard- ware Considerations,” shows system reset circuit examples.
The device has two write-control modes: the standard mode, which uses the WR# and BHE# sig- nals, and the write strobe mode, which uses the WRL# and WRH# signals. Otherwise, the two modes are identical. The modes are selected by chip configuration register 0 (Figure 13-6 on page 13-15.)
Figure 13-17 shows the waveforms of the asserted write-control signals in the two modes. Note that only BHE# is valid throughout the bus cycle.
(state times)

Standard Mode Write Strobe Mode
ALE
WR#
WRL#
Active for low- or high-byte write. Active for low-byte write.
WRH#
Active for high-byte write. Active for high-byte write.
Table 13-14 compares the values of the write-control signals for write operations in the standard mode and the write strobe mode. The table lists values of WR# and BHE# and values of WRL# and WRH# for 8-bit and 16-bit writes on an 8-bit and 16-bit bus.
Standard (CCR0.2 = 1)
Write Strobe (CCR0.2 = 0)
Low Byte 0 0 1 0 0
High Byte 1 0
0
Low Byte 0 0 1 0 1
High Byte 1 0 0 1 0
0
To select the standard write-control mode, set CCR0.2. In standard mode, the WR#/WRL# pin operates as WR#, and the BHE#/WRH# pin operates as BHE#. WR# is asserted for every external memory write. BHE# is asserted for word accesses (read and write) and for byte accesses to odd addresses. BHE# can be used to select the bank of memory that stores the high (odd) byte. Figure 13-10 on page 13-22 illustrates use of the standard mode in a 16-bit system. In this example, WR# writes words to the 16-bit flash memory. To write individual bytes, you can use the decoding logic in Figure 13-18 or use the write strobe mode.

To write single bytes on a 16-bit bus requires separate low-byte and high-byte write signals (WRL# and WRH#). Figure 13-18 shows a sample circuit that combines WR#, BHE#, and ad- dress bit 0 (A0) to produce these signals. This additional logic is unnecessary, however. In the write strobe mode, WRL# and WRH# are available at the device’s external pins.
WRH#
WR#
WRL#
Figure 13-18. Decoding WRL# and WRH#
The write strobe mode eliminates the need to externally decode high-byte and low-byte write sig- nals to external 16-bit memory on a 16-bit bus. When the write strobe mode is selected, the WR#/WRL# pin operates as WRL#, and the BHE#/WRH# pin operates as WRH#. In the 16-bit bus mode, WRL# is asserted for all low-byte writes (even addresses) and all word writes, and WRH# is asserted for all high-byte writes (odd addresses) and all word writes. In the 8-bit bus mode, WRH# and WRL# are asserted for both even and odd addresses (see Table 13-14).

Figure 13-19 illustrates the use of the write strobe mode in a mixed 8-bit and 16-bit system with two flash memories and one SRAM. The WRL# signal, which is generated for all 8-bit writes (Table 13-14), is used to write bytes to the SRAM. Note that the RD# signal is sufficient for sin- gle-byte reads on a 16-bit bus. Both bytes are put onto the data bus and the memory controller discards the unwanted byte.
CE# A17:0
CE#
CE#
A18:1 A18:1
AD15:8
AD15:8
D7:0
8XC196 Flash 256K×8 High
8K×8
AD7:0
AD7:0
AD7:0
D7:0
D7:0
OE# WE# OE# WE#
OE# WE#
RD# WRH#
WRL#
Figure 13-19. A System with 8-bit and 16-bit Buses
13.9 SYSTEM BUS AC TIMING SPECIFICATIONS
Refer to the latest datasheet for the AC timings to make sure your system meets specifications. The major external bus timing specifications are shown in Figure 13-20 through 13-23.
Flash 256K×8 Low








13.9.1 Deferred Bus-cycle Mode (80C196NU Only)
The 80C196NU offers a deferred bus cycle mode. This bus mode (enabled by CCR1.5; see Figure 13-7 on page 13-16) reduces bus contention when using the 80C196NU in demultiplexed mode with slow memories. As shown in Figure 13-24, a delay of 2t occurs in the first bus cycle follow- ing a chip-select output change and the first write cycle following a read cycle.



Each symbol consists of two pairs of letters prefixed by “T” (for time). The characters in a pair indicate a signal and its condition, respectively. Symbols represent the time between the two sig- nal/condition points. For example, TLLRL is the time between signal L (ALE) condition L (Low) and signal R (RD#) condition L (Low). Table 13-15 defines the signal and condition codes.
Signals Conditions
A† Address H HOLD# S CSx# H High
B BHE# HA HLDA# W WR#, WRH#, WRL# L Low
C CLKOUT L ALE X XTAL1 V Valid
D Data Q Data Out Y READY X No Longer Valid
G Buswidth R RD# Z Floating
† Address bus (demultiplexed mode) or address/data bus (multiplexed mode)
Table 13-16 defines the AC timing specifications that the memory system must meet and those that the device will provide.
The External Memory System Must Meet These Specifications
TAVDV Address Valid to Input Data Valid
Maximum time the memory device has to output valid data after the device outputs a valid address.
TCHDV CLKOUT High to Input Data Valid
Maximum time the memory system has to output valid data after CLKOUT rises.
TCLDV CLKOUT Low to Input Data Valid
Maximum time the memory system has to output valid data after CLKOUT falls.
TQVWH Data Valid to WR# High
Time between data being valid on the bus and WR# going inactive.
TRHDZ RD# High to Input Data Float
Time after RD# is inactive until the memory system must float the bus. If this timing is not met, bus contention will occur.
TRLDV RD# Low to Input Data Valid
Maximum time the memory system has to output valid data after the device asserts RD#.
TSLDV CSx# Valid to Input Data Valid
Maximum time the memory device has to output valid data after the device outputs a valid chip- select output.
Symbol Definition

Table 13-16. AC Timing Definitions (Continued)
The 8XC196Nx Meets These Specifications
Frequency of the signal input on the XTAL1 pin times the clock multiplier (x). For the 8XC196NP, x is always 1; for the 80C196NU, x is 1, 2, or 4, depending on the clock mode. The internal bus speed of the device is ½ f.
t Operating period (1/f)
All AC Timings are referenced to t.
TAVLL Address Setup to ALE Low
Length of time ADDRESS is valid before ALE falls. Use this specification when designing the external latch.
TAVRL Address Setup to RD# Low
Length of time ADDRESS is valid before RD# falls.
TAVWL Address Setup to WR# Low
Length of time ADDRESS is valid before WR# falls.
TCHCL CLKOUT High Period
Needed in systems that use CLKOUT as clock for external devices.
TCHWL CLKOUT High to WR# Low
Time between CLKOUT going high and WR# going active.
TCLCL CLKOUT Cycle Time
Normally 2t.
TCLLH CLKOUT Falling to ALE Rising
Use to derive other timings.
TLHLH ALE Cycle Time
Minimum time between ALE pulses.
TLHLL ALE High Period
Use this specification when designing the external latch.
TLLAX Address Hold after ALE Low
Length of time ADDRESS is valid after ALE falls. Use this specification when designing the external latch.
TLLCH ALE Falling to CLKOUT Rising
Use to derive other timings.
TLLRL ALE Low to RD# Low
Length of time after ALE falls before RD# is asserted. Could be needed to ensure proper memory decoding takes place before a device is enabled.
TLLWL ALE Low to WR# Low
Length of time after ALE falls before WR# is asserted. Could be needed to ensure proper memory decoding takes place before a device is enabled.
Symbol Definition · f Operating frequency

The 8XC196Nx Meets These Specifications (Continued)
TRHAX (Multiplexed Mode) AD15:8/CSx# Hold after RD# High
Minimum time the high byte of the address in 8-bit mode will be valid after RD# inactive.
(Demultiplexed Mode) A19:0/CSx# Hold after RD# High
Minimum time the address will be valid after RD# inactive.
TRHBX BHE#, INST Hold after RD# High
Minimum time these signals will be valid after RD# inactive.
TRHLH RD# High to ALE Rising
Time between RD# going inactive and the next ALE. Useful in calculating time between RD# inactive and next address valid.
TRHRL RD# High to RD# Low
Minimum RD# inactive time.
TRHSH A19:0/CSx# Hold after RD# High
Minimum time the address and chip-select output are held after RD# inactive.
TRLAZ RD# Low to Address Float
Used to calculate when the device stops driving address on the bus.
TRLCH RD# Low to CLKOUT High
Maximum time between RD# being asserted and CLKOUT going high.
TRLCL RD# Low to CLKOUT Low
Length of time from RD# asserted to CLKOUT falling edge.
TRLRH RD# Low to RD# High
RD# pulse width.
TWHAX (Multiplexed Mode) AD15:8/CSx# Hold after WR# High
Minimum time the high byte of the address in 8-bit mode will be valid after WR# inactive.
(Demultiplexed Mode) A19:0/CSx# Hold after WR# High
Minimum time the address will be valid after WR# inactive.
TWHBX BHE#, INST Hold after WR# High
Minimum time these signals will be valid after WR# inactive.
TWHLH WR# High to ALE High
Time between WR# going inactive and next ALE. Also used to calculate WR# inactive and next Address valid.
TWHQX Data Hold after WR# High
Length of time after WR# rises that the data stays valid on the bus.
Symbol Definition

Table 13-16. AC Timing Definitions (Continued)
The 8XC196Nx Meets These Specifications (Continued)
TWHSH A19:0/CSx# Hold after WR# High
Minimum time the address and chip-select output are held after WR# inactive.
TWLCH WR# Low to CLKOUT High
Minimum and maximum time between WR# being asserted and CLKOUT going high.
TWLCL WR# Low to CLKOUT Low
Minimum and maximum time between WR# being asserted and CLKOUT going low.
TWLWH WR# Low to WR# High
WR# pulse width.
Symbol Definition






This appendix provides reference information for the instruction set of the family of MCS® 96 microcontrollers. It defines the processor status word (PSW) flags, describes each instruction, shows the relationships between instructions and PSW flags, and shows hexadecimal opcodes, instruction lengths, and execution times. It includes the following tables.

Opcode x0 x1 x2 x3 x4 x5 x6 x7
0x SKIP CLR NOT NEG XCH
1x CLRB NOTB NEGB XCHB
bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7
4x AND 3op ADD 3op
di im in ix di im in ix
5x ANDB 3op ADDB 3op
di im in ix di im in ix
6x AND 2op ADD 2op
di im in ix di im in ix
7x ANDB 2op ADDB 2op
di im in ix di im in ix
di im in ix di im in ix
di im in ix di im in ix
di im in ix di im in ix
di im in ix di im in ix
Cx ST BMOV ST STB CMPL STB
di in ix di in ix
Dx JNST JNH JGT JNC JNVT JNV JGE JNE
Ex DJNZ DJNZW TIJMP BR/EBR
Fx RET ECALL PUSHF POPF PUSHA POPA IDLPD TRAP

Table A-1. Opcode Map (Right Half)
Opcode x8 x9 xA xB xC xD xE xF
0x SHR SHL SHRA XCH
1x SHRB SHLB SHRAB XCHB
EST
ESTB
ESTB
bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7
4x SUB 3op MULU 3op (Note 2)
di im in ix di im in ix
5x SUBB 3op MULUB 3op (Note 2)
di im in ix di im in ix
6x SUB 2op MULU 2op (Note 2)
di im in ix di im in ix
7x SUBB 2op MULUB 2op (Note 2)
di im in ix di im in ix
8x CMP DIVU (Note 2)
di im in ix di im in ix
9x CMPB DIVUB (Note 2)
di im in ix di im in ix
di im in ix di im in ix
di im in ix di im in ix
Cx PUSH POP BMOVI POP
di im in ix di in ix
Dx JST JH JLE JC JVT JV JLT JE
ELDB
ELDB
DPTS EPTS (Note 1) LCALL
CLRC SETC DI EI CLRVT NOP signed MUL/DIV

C The carry flag is set to indicate an arithmetic carry from the MSB of the ALU or the state of the last bit shifted out of an operand. If a subtraction operation generates a borrow, the carry flag is cleared.
C Value of Bits Shifted Off
1 ≥ ½ LSB
Normally, the result is rounded up if the carry flag is set. The sticky bit flag allows a finer resolution in the rounding decision.
C ST Value of Bits Shifted Off
0 0 = 0
0 1 > 0 and < ½ LSB
1 1 > ½ LSB and < 1 LSB
N The negative flag is set to indicate that the result of an operation is negative. The flag is correct even if an overflow occurs. For all shift operations and the NORML instruction, the flag is set to equal the most-significant bit of the result, even if the shift count is zero.
ST The sticky bit flag is set to indicate that, during a right shift, a “1” has been shifted into the carry flag and then shifted out. This bit is undefined after a multiply operation. The sticky bit flag can be used with the carry flag to allow finer resolution in rounding decisions. See the description of the carry (C) flag for details.
V The overflow flag is set to indicate that the result of an operation is too large to be represented correctly in the available space.
For shift operations, the flag is set if the most-significant bit of the operand changes during the shift. For divide operations, the quotient is stored in the low-order half of the destination operand and the remainder is stored in the high-order half. The overflow flag is set if the quotient is outside the range for the low-order half of the destination operand. (Chapter 4, “Programming Considerations,” defines the operands and possible values for each.)
DIVB Short-Integer < –128 or > +127 (< 81H or > 7FH)
DIV Integer < –32768 or > +32767 (< 8001H or > 7FFFH)
DIVUB Byte > 255 (FFH)
DIVU Word > 65535 (FFFFH)
VT The overflow-trap flag is set when the overflow flag is set, but it is cleared only by the CLRVT, JVT, and JNVT instructions. This allows testing for a possible overflow at the end of a sequence of related arithmetic operations, which is generally more efficient than testing the overflow flag after each operation.
Z The zero flag is set to indicate that the result of an operation was zero. For multiple-precision calculations, the zero flag cannot be set by the instructions that use the carry bit from the previous calculation (e.g., ADDC, SUBC). However, these instructions can clear the zero flag. This ensures that the zero flag will reflect the result of the entire operation, not just the last calculation. For example, if the result of adding together the lower words of two double words is zero, the zero flag would be set. When the upper words are added together using the ADDC instruction, the flag remains set if the result is zero and is cleared if the result is not zero.
Mnemonic Description

Table A-3 shows the effect of the PSW flags or a specified condition on conditional jump instruc- tions. Table A-4 defines the symbols used in Table A-6 to show the effect of each instruction on the PSW flags.
Table A-3. Effect of PSW Flags or Specified Conditions on Conditional Jump Instructions
Instruction Jumps to Destination if Continues if
DJNZ decremented byte ≠ 0 decremented byte = 0
DJNZW decremented word ≠ 0 decremented word = 0
JBC specified register bit = 0 specified register bit = 1
JBS specified register bit = 1 specified register bit = 0
JNH C = 0 OR Z = 1 C = 1 AND Z = 0
JH C = 1 AND Z = 0 C = 0 OR Z = 1
JGT N = 0 AND Z = 0 N = 1 OR Z = 1
JLE N = 1 OR Z = 1 N = 0 AND Z = 0
JST ST = 1 ST = 0
JNV V = 0 V = 1
JV V = 1 V = 0
JNVT VT = 0 VT = 1 (clears VT)
JVT VT = 1 (clears VT) VT = 0
JE Z = 1 Z = 0
Table A-4. PSW Flag Setting Symbols
The instruction sets or clears the flag, as appropriate.
— The instruction does not modify the flag.
↓ The instruction may clear the flag, if it is appropriate, but cannot set it.
↑ The instruction may set the flag, if it is appropriate, but cannot clear it.
1 The instruction sets the flag.
0 The instruction clears the flag.
? The instruction leaves the flag in an indeterminate state.
Symbol Description

Table A-5 defines the variables that are used in Table A-6 to represent the instruction operands.
aa A 2-bit field within an opcode that selects the basic addressing mode used. This field is present only in those opcodes that allow addressing mode options. The field is encoded as follows:
00 register-direct 01 immediate 10 indirect 11 indexed
baop A byte operand that is addressed by any addressing mode.
bbb A 3-bit field within an opcode that selects a specific bit within a register.
bitno A 3-bit field within an opcode that selects one of the eight bits in a byte.
breg A byte register in the internal register file. When it could be unclear whether this variable refers to a source or a destination register, it is prefixed with an S or a D. The value must be in the range of 00–FFH.
cadd An address in the program code.
Dbreg† A byte register in the lower register file that serves as the destination of the instruction operation.
disp Displacement. The distance between the end of an instruction and the target label.
Dlreg† A 32-bit register in the lower register file that serves as the destination of the instruction operation. Must be aligned on an address that is evenly divisible by 4. The value must be in the range of 00–FCH.
Dwreg† A word register in the lower register file that serves as the destination of the instruction operation. Must be aligned on an address that is evenly divisible by 2. The value must be in the range of 00–FEH.
lreg A 32-bit register in the lower register file. Must be aligned on an address that is evenly divisible by 4. The value must be in the range of 00–FCH.
ptr2_reg A double-pointer register, used with the EBMOVI instruction. Must be aligned on an address that is evenly divisible by 8. The value must be in the range of 00–F8H.
preg A pointer register. Must be aligned on an address that is evenly divisible by 4. The value must be in the range of 00–FCH.
Sbreg† A byte register in the lower register file that serves as the source of the instruction operation.
Slreg† A 32-bit register in the lower register file that serves as the source of the instruction operation. Must be aligned on an address that is evenly divisible by 4. The value must be in the range of 00–FCH.
Swreg† A word register in the lower register file that serves as the source of the instruction operation. Must be aligned on an address that is evenly divisible by 2. The value must be in the range of 00–FEH.
treg A 24-bit register in the lower register file. Must be aligned on an address that is evenly divisible by 4. The value must be in the range of 00–FCH.
waop A word operand that is addressed by any addressing mode.
w2_reg A double-word register in the lower register file. Must be aligned on an address that is evenly divisible by 4. The value must be in the range of 00–FCH. Although w2_reg is similar to lreg, there is a distinction: w2_reg consists of two halves, each containing a 16-bit address; lreg is indivisible and contains a 32-bit number.
wreg A word register in the lower register file. When it could be unclear whether this variable refers to a source or a destination register, it is prefixed with an S or a D. Must be aligned on an address that is evenly divisible by 2. The value must be in the range of 00–FEH.
xxx The three high-order bits of displacement.
†The D or S prefix is used only when it could be unclear whether a variable refers to a destination or a
source register.
Variable Description

Table A-6. Instruction Set
Mnemonic Operation Instruction Format
ADD WORDS. Adds the source and destination word operands and stores the sum into the destination operand.
(DEST) ← (DEST) + (SRC)
Z N C V VT ST
↑ —
ADD WORDS. Adds the two source word operands and stores the sum into the destination operand.
ADD Dwreg, Swreg, waop
(010001aa) (waop) (Swreg) (Dwreg)
↑ —
ADD BYTES. Adds the source and destination byte operands and stores the sum into the destination operand.
(DEST) ← (DEST) + (SRC)
Z N C V VT ST
↑ —
ADD BYTES. Adds the two source byte operands and stores the sum into the destination operand.
ADDB Dbreg, Sbreg, baop
(010101aa) (baop) (Sbreg) (Dbreg)
Z N C V VT ST
↑ —
ADDC ADD WORDS WITH CARRY. Adds the source and destination word operands and the carry flag (0 or 1) and stores the sum into the destination operand.
(DEST) ← (DEST) + (SRC) + C
Z N C V VT ST
↓ ↑ —

Mnemonic Operation Instruction Format
ADDCB ADD BYTES WITH CARRY. Adds the source and destination byte operands and the carry flag (0 or 1) and stores the sum into the destination operand.
(DEST) ← (DEST) + (SRC) + C
Z N C V VT ST
↓ ↑ —
LOGICAL AND WORDS. ANDs the source and destination word operands and stores the result into the destination operand. The result has ones in only the bit positions in which both operands had a “1” and zeros in all other bit positions.
(DEST) ← (DEST) AND (SRC)
Z N C V VT ST
0 0 — —
LOGICAL AND WORDS. ANDs the two source word operands and stores the result into the destination operand. The result has ones in only the bit positions in which both operands had a “1” and zeros in all other bit positions.
AND Dwreg, Swreg, waop
(010000aa) (waop) (Swreg) (Dwreg)
Z N C V VT ST
0 0 — —
LOGICAL AND BYTES. ANDs the source and destination byte operands and stores the result into the destination operand. The result has ones in only the bit positions in which both operands had a “1” and zeros in all other bit positions.
(DEST) ← (DEST) AND (SRC)
Z N C V VT ST
0 0 — —

Table A-6. Instruction Set (Continued)
Mnemonic Operation Instruction Format
LOGICAL AND BYTES. ANDs the two source byte operands and stores the result into the destination operand. The result has ones in only the bit positions in which both operands had a “1” and zeros in all other bit positions.
ANDB Dbreg, Sbreg, baop
(010100aa) (baop) (Sbreg) (Dbreg)
Z N C V VT ST
0 0 — —
BMOV BLOCK MOVE. Moves a block of word data from one location in memory to another. The source and destination addresses are calculated using the indirect with autoin- crement addressing mode. A long register (PTRS) addresses the source and destination pointers, which are stored in adjacent word registers. The source pointer (SRCPTR) is the low word and the destination pointer (DSTPTR) is the high word of PTRS. A word register (CNTREG) specifies the number of transfers. The blocks of data can be located anywhere in page 00H of register RAM, but should not overlap. Because the source (SRCPTR) and destination (DSTPTR) pointers are 16 bits wide, this instruction uses nonextended data moves. It cannot operate across page boundaries. For example, SRCPTR cannot point to a location on page 05 while DSTPTR points to page 00. SRCPTR and DSTPTR will operate from the page defined by EP_REG. EP_REG should be set to 00H to select page 00H (see “Accessing Data” on page 5-23). (The 80C196NU forces EP_REG to 00H.)
COUNT ← (CNTREG) LOOP: SRCPTR ← (PTRS) DSTPTR ← (PTRS + 2) (DSTPTR) ← (SRCPTR) (PTRS) ← SRCPTR + 2 (PTRS + 2) ← DSTPTR + 2 COUNT ← COUNT – 1 if COUNT ≠ 0 then go to LOOP
—

Mnemonic Operation Instruction Format
BMOVI INTERRUPTIBLE BLOCK MOVE. Moves a block of word data from one location in memory to another. The instruction is identical to BMOV, except that BMOVI is interruptible. The source and destination addresses are calculated using the indirect with autoincrement addressing mode. A long register (PTRS) addresses the source and destination pointers, which are stored in adjacent word registers. The source pointer (SRCPTR) is the low word and the destination pointer (DSTPTR) is the high word of PTRS. A word register (CNTREG) specifies the number of transfers. The blocks of data can be located anywhere in page 00H of register RAM, but should not overlap. Because the source (SRCPTR) and destination (DSTPTR) pointers are 16 bits wide, this instruction uses nonexteneded data moves. It cannot operate across page boundaries. (If you need to cross page boundaries, use the EBMOVI instruction.) PTSSRC and PTSDST will operate from the page defined by EP_REG. EP_REG should be set to 00H to select page 00H (see “Accessing Data” on page 5-23). (The 80C196NU forces EP_REG to 00H.)
COUNT ← (CNTREG) LOOP: SRCPTR ← (PTRS) DSTPTR ← (PTRS + 2) (DSTPTR) ← (SRCPTR) (PTRS) ← SRCPTR + 2 (PTRS + 2) ← DSTPTR + 2 COUNT ← COUNT – 1 if COUNT ≠ 0 then go to LOOP
—
BR BRANCH INDIRECT. Continues execution at the address specified in the operand word register.
PC ← (DEST)
—

Table A-6. Instruction Set (Continued)
Mnemonic Operation Instruction Format
CLR CLEAR WORD. Clears the value of the operand.
(DEST) ← 0
Z N C V VT ST
1 0 0 0 — —
CLRB CLEAR BYTE. Clears the value of the operand.
(DEST) ← 0
Z N C V VT ST
1 0 0 0 — —
CLRC CLEAR CARRY FLAG. Clears the carry flag.
(11111000) PSW Flag Settings
— — 0 — — —
CLRVT CLEAR OVERFLOW-TRAP FLAG. Clears the overflow-trap flag.
VT ← 0
Z N C V VT ST
— 0 —
CMP COMPARE WORDS. Subtracts the source word operand from the destination word operand. The flags are altered, but the operands remain unaffected. If a borrow occurs, the carry flag is cleared; otherwise, it is set.
(DEST) – (SRC)
Z N C V VT ST
↑ —

Mnemonic Operation Instruction Format
CMPB COMPARE BYTES. Subtracts the source byte operand from the destination byte operand. The flags are altered, but the operands remain unaffected. If a borrow occurs, the carry flag is cleared; otherwise, it is set.
(DEST) – (SRC)
Z N C V VT ST
↑ —
CMPL COMPARE LONG. Compares the magnitudes of two double-word (long) operands. The operands are specified using the direct addressing mode. The flags are altered, but the operands remain unaffected. If a borrow occurs, the carry flag is cleared; otherwise, it is set.
(DEST) – (SRC)
Z N C V VT ST
—
DEC DECREMENT WORD. Decrements the value of the operand by one.
(DEST) ← (DEST) –1
Z N C V VT ST
↑ —
DECB DECREMENT BYTE. Decrements the value of the operand by one.
(DEST) ← (DEST) –1
Z N C V VT ST
↑ —

Table A-6. Instruction Set (Continued)
Mnemonic Operation Instruction Format
DI DISABLE INTERRUPTS. Disables interrupts. Interrupt calls cannot occur after this instruction.
Interrupt Enable (PSW.1) ← 0
—
DIV DIVIDE INTEGERS. Divides the contents of the destination long-integer operand by the contents of the source integer word operand, using signed arithmetic. It stores the quotient into the low-order word of the destination (i.e., the word with the lower address) and the remainder into the high-order word. The following two statements are performed concurrently.
(11111110) (100011aa) (waop) (lreg)
(low word DEST) ← (DEST) / (SRC) (high word DEST) ← (DEST) MOD (SRC)
— — — ↑ —
DIVB DIVIDE SHORT-INTEGERS. Divides the contents of the destination integer operand by the contents of the source short-integer operand, using signed arithmetic. It stores the quotient into the low-order byte of the destination (i.e., the word with the lower address) and the remainder into the high- order byte. The following two statements are performed concurrently.
(11111110) (100111aa) (baop) (wreg)
(low byte DEST) ← (DEST) / (SRC) (high byte DEST) ← (DEST) MOD (SRC)
— — — ↑ —

Mnemonic Operation Instruction Format
DIVU DIVIDE WORDS, UNSIGNED. Divides the contents of the destination double-word operand by the contents of the source word operand, using unsigned arithmetic. It stores the quotient into the low-order word (i.e., the word with the lower address) of the destination operand and the remainder into the high-order word. The following two statements are performed concurrently.
(low word DEST) ← (DEST) / (SRC) (high word DEST) ← (DEST) MOD (SRC)
— — — ↑ —
DIVUB DIVIDE BYTES, UNSIGNED. This instruction divides the contents of the destination word operand by the contents of the source byte operand, using unsigned arithmetic. It stores the quotient into the low-order byte (i.e., the byte with the lower address) of the destination operand and the remainder into the high-order byte. The following two statements are performed concurrently.
(low byte DEST) ← (DEST) / (SRC) (high byte DEST) ← (DEST) MOD (SRC)
— — — ↑ —
DJNZ DECREMENT AND JUMP IF NOT ZERO. Decrements the value of the byte operand by 1. If the result is 0, control passes to the next sequential instruction. If the result is not 0, the instruction adds to the program counter the offset between the end of this instruction and the target label, effecting the jump. The offset must be in the range of –128 to +127.
(COUNT) ← (COUNT) –1 if (COUNT) ≠ 0 then
PC ← PC + 8-bit disp end_if
—

Table A-6. Instruction Set (Continued)
Mnemonic Operation Instruction Format
DJNZW DECREMENT AND JUMP IF NOT ZERO WORD. Decrements the value of the word operand by 1. If the result is 0, control passes to the next sequential instruction. If the result is not 0, the instruction adds to the program counter the offset between the end of this instruction and the target label, effecting the jump. The offset must be in the range of –128 to +127
(COUNT) ← (COUNT) –1 if (COUNT) ≠ 0 then
PC ← PC + 8-bit disp end_if
—
DPTS DISABLE PERIPHERAL TRANSACTION SERVER (PTS). Disables the peripheral transaction server (PTS).
PTS Disable (PSW.2) ← 0
—

Mnemonic Operation Instruction Format
EBMOVI EXTENDED INTERRUPTABLE BLOCK MOVE. Moves a block of word data from one memory location to another. This instruction allows you to move blocks of up to 64K words between any two locations in the 16-Mbyte address space. This instruction is inter- ruptable.
The source and destination addresses are calculated using the extended indirect with autoincrement addressing mode. A quad- word register (PTRS) addresses the 24-bit source and destination pointers, which are stored in adjacent double-word registers. The source pointer (SRCPTR) is the low double- word and the destination pointer is the high double-word of PTRS. A word register (CNTREG) specifies the number of transfers. The blocks of data can reside anywhere in memory, but should not overlap.
For 20-bit addresses, the offset must be in the range of +524287 to –524288.
COUNT ← (CNTREG) LOOP: SRCPTR ← (PTRS) DSTPTR ← (PTRS + 2) (DSTPTR) ← (SRCPTR) (PTRS) ← SRCPTR + 2 (PTRS + 2) ← DSTPTR + 2 COUNT ← COUNT 1 if COUNT ≠ 0 then go to LOOP
—
EBR EXTENDED BRANCH INDIRECT. Continues execution at the address specified in the operand word register. This instruction is an unconditional indirect jump to anywhere in the 16-Mbyte address space.
EBR shares its opcode (E3) with the BR instruction. To differentiate between the two, the compiler sets the least-significant bit of the EBR instruction. For example: EBR [50] becomes E351 when compiled.
Z N C V VT ST
—

Table A-6. Instruction Set (Continued)
Mnemonic Operation Instruction Format
ECALL EXTENDED CALL. Pushes the contents of the program counter (the return address) onto the stack, then adds to the program counter the offset between the end of this instruction and the target label, effecting the call. The operand may be any address in the address space.
(1111 0001) (disp-low) (disp-high) (disp-ext)
This instruction is an unconditional relative call to anywhere in the 16-Mbyte address space. It functions only in extended addressing mode.
SP ← SP – 4 (SP) ← PC PC ← PC + 24-bit disp
—
EI ENABLE INTERRUPTS. Enables interrupts following the execution of the next statement. Interrupt calls cannot occur immediately following this instruction.
Interrupt Enable (PSW.1) ← 1
—
EJMP EXTENDED JUMP. Adds to the program counter the offset between the end of this instruction and the target label, effecting the jump. The operand may be any address in the entire address space. The offset must be in the range of +8,388,607 to –8,388,608 for 24-bit addresses.
(11100110) (disp-low) (disp-high) (disp-ext)
This instruction is an unconditional, relative jump to anywhere in the 16-Mbyte address space. It functions only in extended addressing mode.
PC ←PC + 24-bit disp
— ?

Mnemonic Operation Instruction Format
ELD EXTENDED LOAD WORD. Loads the value of the source word operand into the destination operand.
This instruction allows you to move data from anywhere in the 16-Mbyte address space into the lower register file.
—
ELDB EXTENDED LOAD BYTE. Loads the value of the source byte operand into the destination operand.
This instruction allows you to move data from anywhere in the 16-Mbyte address space into the lower register file.
—
EPTS ENABLE PERIPHERAL TRANSACTION SERVER (PTS). Enables the peripheral transaction server (PTS).
PTS Enable (PSW.2) ← 1
—

Table A-6. Instruction Set (Continued)
Mnemonic Operation Instruction Format
EST EXTENDED STORE WORD. Stores the value of the source (leftmost) word operand into the destination (rightmost) operand.
This instruction allows you to move data from the lower register file to anywhere in the 16- Mbyte address space.
—
ESTB EXTENDED STORE BYTE. Stores the value of the source (leftmost) byte operand into the destination (rightmost) operand.
This instruction allows you to move data from the lower register file to anywhere in the 16- Mbyte address space.
—
EXT SIGN-EXTEND INTEGER INTO LONG- INTEGER. Sign-extends the low-order word of the operand throughout the high-order word of the operand.
if DEST.15 = 1 then
(high word DEST) ← 0FFFFH else
(high word DEST) ← 0 end_if
0 0 — —

Mnemonic Operation Instruction Format
EXTB SIGN-EXTEND SHORT-INTEGER INTO INTEGER. Sign-extends the low-order byte of the operand throughout the high-order byte of the operand.
if DEST.7 = 1 then
(high byte DEST) ← 0FFH else
(high byte DEST) ← 0 end_if
0 0 — —
IDLPD IDLE/POWERDOWN. Depending on the 8-bit value of the KEY operand, this instruction causes the device
The bus controller completes any prefetch cycle in progress before the CPU stops or resets.
if KEY = 1 then
enter idle else if KEY = 2 then
enter powerdown else if KEY = 3 then
enter standby (NU only) else
KEY = 1 or 2 (NP)
or 1, 2, or 3 (NU)
—
KEY = any value other than 1 or 2 (NP) or 1, 2, or 3 (NU)
0

Table A-6. Instruction Set (Continued)
Mnemonic Operation Instruction Format
INC INCREMENT WORD. Increments the value of the word operand by 1.
Z N C V VT ST
↑ 0
INCB INCREMENT BYTE. Increments the value of the byte operand by 1.
Z N C V VT ST
↑ —
JBC JUMP IF BIT IS CLEAR. Tests the specified bit. If the bit is set, control passes to the next sequential instruction. If the bit is clear, this instruction adds to the program counter the offset between the end of this instruction and the target label, effecting the jump. The offset must be in the range of –128 to +127.
if (specified bit) = 0 then
PC ← PC + 8-bit disp
—
JBS JUMP IF BIT IS SET. Tests the specified bit. If the bit is clear, control passes to the next sequential instruction. If the bit is set, this instruction adds to the program counter the offset between the end of this instruction and the target label, effecting the jump. The offset must be in the range of –128 to +127.
if (specified bit) = 1 then
PC ← PC + 8-bit disp
—

Mnemonic Operation Instruction Format
JC JUMP IF CARRY FLAG IS SET. Tests the carry flag. If the carry flag is clear, control passes to the next sequential instruction. If the carry flag is set, this instruction adds to the program counter the offset between the end of this instruction and the target label, effecting the jump. The offset must be in the range of –128 to +127.
if C = 1 then
PC ← PC + 8-bit disp
—
JE JUMP IF EQUAL. Tests the zero flag. If the flag is clear, control passes to the next sequential instruction. If the zero flag is set, this instruction adds to the program counter the offset between the end of this instruction and the target label, effecting the jump. The offset must be in the range of –128 to +127.
if Z = 1 then
PC ← PC + 8-bit disp
—
JGE JUMP IF SIGNED GREATER THAN OR EQUAL. Tests the negative flag. If the negative flag is set, control passes to the next sequential instruction. If the negative flag is clear, this instruction adds to the program counter the offset between the end of this instruction and the target label, effecting the jump. The offset must be in the range of –128 to +127.
if N = 0 then
PC ← PC + 8-bit disp
—

Table A-6. Instruction Set (Continued)
Mnemonic Operation Instruction Format
JGT JUMP IF SIGNED GREATER THAN. Tests both the zero flag and the negative flag. If either flag is set, control passes to the next sequential instruction. If both flags are clear, this instruction adds to the program counter the offset between the end of this instruction and the target label, effecting the jump. The offset must be in the range of –128 to +127.
if N = 0 AND Z = 0 then
PC ← PC + 8-bit disp
—
JH JUMP IF HIGHER (UNSIGNED). Tests both the zero flag and the carry flag. If either the carry flag is clear or the zero flag is set, control passes to the next sequential instruction. If the carry flag is set and the zero flag is clear, this instruction adds to the program counter the offset between the end of this instruction and the target label, effecting the jump. The offset must be in range of –128 to +127.
if C = 1 AND Z = 0 then
PC ← PC + 8-bit disp
—
JLE JUMP IF SIGNED LESS THAN OR EQUAL. Tests both the negative flag and the zero flag. If both flags are clear, control passes to the next sequential instruction. If either flag is set, this instruction adds to the program counter the offset between the end of this instruction and the target label, effecting the jump. The offset must be in the range of –128 to +127.
if N = 1 OR Z = 1 then
PC ← PC + 8-bit disp
—

Mnemonic Operation Instruction Format
JLT JUMP IF SIGNED LESS THAN. Tests the negative flag. If the flag is clear, control passes to the next sequential instruction. If the negative flag is set, this instruction adds to the program counter the offset between the end of this instruction and the target label, effecting the jump. The offset must be in the range of –128 to +127.
if N = 1 then
PC ← PC + 8-bit disp
—
JNC JUMP IF CARRY FLAG IS CLEAR. Tests the carry flag. If the flag is set, control passes to the next sequential instruction. If the carry flag is clear, this instruction adds to the program counter the offset between the end of this instruction and the target label, effecting the jump. The offset must be in the range of –128 to +127.
if C = 0 then
PC ← PC + 8-bit disp
—
JNE JUMP IF NOT EQUAL. Tests the zero flag. If the flag is set, control passes to the next sequential instruction. If the zero flag is clear, this instruction adds to the program counter the offset between the end of this instruction and the target label, effecting the jump. The offset must be in the range of –128 to +127.
if Z = 0 then
PC ← PC + 8-bit disp
—

Table A-6. Instruction Set (Continued)
Mnemonic Operation Instruction Format
JNH JUMP IF NOT HIGHER (UNSIGNED). Tests both the zero flag and the carry flag. If the carry flag is set and the zero flag is clear, control passes to the next sequential instruction. If either the carry flag is clear or the zero flag is set, this instruction adds to the program counter the offset between the end of this instruction and the target label, effecting the jump. The offset must be in range of –128 to +127.
if C = 0 OR Z = 1 then
PC ← PC + 8-bit disp
—
JNST JUMP IF STICKY BIT FLAG IS CLEAR. Tests the sticky bit flag. If the flag is set, control passes to the next sequential instruction. If the sticky bit flag is clear, this instruction adds to the program counter the offset between the end of this instruction and the target label, effecting the jump. The offset must be in range of –128 to +127.
if ST = 0 then
PC ← PC + 8-bit disp
—
JNV JUMP IF OVERFLOW FLAG IS CLEAR. Tests the overflow flag. If the flag is set, control passes to the next sequential instruction. If the overflow flag is clear, this instruction adds to the program counter the offset between the end of this instruction and the target label, effecting the jump. The offset must be in range of –128 to +127.
if V = 0 then
PC ← PC + 8-bit disp
—

Mnemonic Operation Instruction Format
JNVT JUMP IF OVERFLOW-TRAP FLAG IS CLEAR. Tests the overflow-trap flag. If the flag is set, this instruction clears the flag and passes control to the next sequential instruction. If the overflow-trap flag is clear, this instruction adds to the program counter the offset between the end of this instruction and the target label, effecting the jump. The offset must be in range of –128 to +127.
if VT = 0 then
PC ← PC + 8-bit disp
— 0 —
JST JUMP IF STICKY BIT FLAG IS SET. Tests the sticky bit flag. If the flag is clear, control passes to the next sequential instruction. If the sticky bit flag is set, this instruction adds to the program counter the offset between the end of this instruction and the target label, effecting the jump. The offset must be in range of –128 to +127.
if ST = 1 then
PC ← PC + 8-bit disp
—
JV JUMP IF OVERFLOW FLAG IS SET. Tests the overflow flag. If the flag is clear, control passes to the next sequential instruction. If the overflow flag is set, this instruction adds to the program counter the offset between the end of this instruction and the target label, effecting the jump. The offset must be in range of –128 to +127.
if V = 1 then
PC ← PC + 8-bit disp
—

Table A-6. Instruction Set (Continued)
Mnemonic Operation Instruction Format
JVT JUMP IF OVERFLOW-TRAP FLAG IS SET. Tests the overflow-trap flag. If the flag is clear, control passes to the next sequential instruction. If the overflow-trap flag is set, this instruction clears the flag and adds to the program counter the offset between the end of this instruction and the target label, effecting the jump. The offset must be in range of –128 to +127.
if VT = 1 then
PC ← PC + 8-bit disp
— 0 —
LCALL LONG CALL. Pushes the contents of the program counter (the return address) onto the stack, then adds to the program counter the offset between the end of this instruction and the target label, effecting the call. The offset must be in the range of –32,768 to +32,767.
—
LD LOAD WORD. Loads the value of the source word operand into the destination operand.
(DEST) ← (SRC)
Z N C V VT ST
—

Mnemonic Operation Instruction Format
LDB LOAD BYTE. Loads the value of the source byte operand into the destination operand.
(DEST) ← (SRC)
Z N C V VT ST
—
LDBSE LOAD BYTE SIGN-EXTENDED. Sign- extends the value of the source short- integer operand and loads it into the destination integer operand.
(low byte DEST) ← (SRC)
if DEST.15 = 1 then
(high word DEST) ← 0FFH else
(high word DEST) ← 0 end_if
—
LDBZE LOAD BYTE ZERO-EXTENDED. Zero- extends the value of the source byte operand and loads it into the destination word operand.
(low byte DEST) ← (SRC) (high byte DEST) ← 0
—
LJMP LONG JUMP. Adds to the program counter the offset between the end of this instruction and the target label, effecting the jump. The offset must be in the range of –32,768 to +32,767.
— ?

Table A-6. Instruction Set (Continued)
Mnemonic Operation Instruction Format
MULTIPLY INTEGERS. Multiplies the source and destination integer operands, using signed arithmetic, and stores the 32-bit result into the destination long-integer operand. The sticky bit flag is undefined after the instruction is executed.
(11111110) (011011aa) (waop) (lreg)
Z N C V VT ST
— ?
MULTIPLY INTEGERS. Multiplies the two source integer operands, using signed arithmetic, and stores the 32-bit result into the destination long-integer operand. The sticky bit flag is undefined after the instruction is executed.
MUL lreg, wreg, waop
(11111110) (010011aa) (waop) (wreg) (lreg)
NOTE: (8XC196NU only.) A destination address in the range 00H–0FH enables the multiply-accumulate function. When set, bit 3 of the destination address causes the accumulator to be cleared before the results of the multiply are added to the contents of the accu- mulator. For example, if the desti- nation address is 08H, the accumulator is cleared and then the results of the multiply are added. However, if the destination address is 00H, the results of the multiply are added to the current contents of the accumulator.
Z N C V VT ST
— ?
MULTIPLY SHORT-INTEGERS. Multiplies the source and destination short-integer operands, using signed arithmetic, and stores the 16-bit result into the destination integer operand. The sticky bit flag is undefined after the instruction is executed.
(11111110) (011111aa) (baop) (wreg)
Z N C V VT ST
— ?

Mnemonic Operation Instruction Format
MULTIPLY SHORT-INTEGERS. Multiplies the two source short-integer operands, using signed arithmetic, and stores the 16-bit result into the destination integer operand. The sticky bit flag is undefined after the instruction is executed.
MULB wreg, breg, baop
(11111110) (010111aa) (baop) (breg) (wreg)
Z N C V VT ST
— ?
MULTIPLY WORDS, UNSIGNED. Multiplies the source and destination word operands, using unsigned arithmetic, and stores the 32- bit result into the destination double-word operand. The sticky bit flag is undefined after the instruction is executed.
(DEST) ← (DEST) × (SRC)
Z N C V VT ST
— ?
MULTIPLY WORDS, UNSIGNED. Multiplies the two source word operands, using unsigned arithmetic, and stores the 32-bit result into the destination double-word operand. The sticky bit flag is undefined after the instruction is executed.
MULU lreg, wreg, waop
(010011aa) (waop) (wreg) (lreg)
NOTE: (8XC196NU only.) A destination address in the range 00H–0FH enables the multiply-accumulate function. When set, bit 3 of the destination address causes the accumulator to be cleared before the results of the multiply are added to the contents of the accu- mulator. For example, if the desti- nation address is 08H, the accumulator is cleared and then the results of the multiply are added. However, if the destination address is 00H, the results of the multiply are added to the current contents of the accumulator.
Z N C V VT ST
— ?

Table A-6. Instruction Set (Continued)
Mnemonic Operation Instruction Format
MULTIPLY BYTES, UNSIGNED. Multiplies the source and destination operands, using unsigned arithmetic, and stores the word result into the destination operand. The sticky bit flag is undefined after the instruction is executed.
(DEST) ← (DEST) × (SRC)
Z N C V VT ST
— ?
MULTIPLY BYTES, UNSIGNED. Multiplies the two source byte operands, using unsigned arithmetic, and stores the word result into the destination operand. The sticky bit flag is undefined after the instruction is executed.
MULUB wreg, breg, baop
(010111aa) (baop) (breg) (wreg)
Z N C V VT ST
— ?
NEG NEGATE INTEGER. Negates the value of the integer operand.
Z N C V VT ST
↑ —
NEGB NEGATE SHORT-INTEGER. Negates the value of the short-integer operand.
Z N C V VT ST
↑ —
NOP NO OPERATION. Does nothing. Control passes to the next sequential instruction. NOP
(11111101) PSW Flag Settings
—

Mnemonic Operation Instruction Format
NORML NORMALIZE LONG-INTEGER. Normalizes the source (leftmost) long-integer operand. (That is, it shifts the operand to the left until its most significant bit is “1” or until it has performed 31 shifts). If the most significant bit is still “0” after 31 shifts, the instruction stops the process and sets the zero flag. The instruction stores the actual number of shifts performed in the destination (rightmost) operand.
(COUNT) ← 0 do while
(DEST) ← (DEST) × 2 (COUNT) ← (COUNT) + 1 end_while
? 0 — — —
NOT COMPLEMENT WORD. Complements the value of the word operand (replaces each “1” with a “0” and each “0” with a “1”).
Z N C V VT ST
0 0 — —
NOTB COMPLEMENT BYTE. Complements the value of the byte operand (replaces each “1” with a “0” and each “0” with a “1”).
Z N C V VT ST
0 0 — —

Table A-6. Instruction Set (Continued)
Mnemonic Operation Instruction Format
OR LOGICAL OR WORDS. ORs the source word operand with the destination word operand and replaces the original destination operand with the result. The result has a “1” in each bit position in which either the source or destination operand had a “1”.
(DEST) ← (DEST) OR (SRC)
Z N C V VT ST
0 0 — —
ORB LOGICAL OR BYTES. ORs the source byte operand with the destination byte operand and replaces the original destination operand with the result. The result has a “1” in each bit position in which either the source or destination operand had a “1”.
(DEST) ← (DEST) OR (SRC)
Z N C V VT ST
0 0 — —
POP POP WORD. Pops the word on top of the stack and places it at the destination operand.
Z N C V VT ST
—

Mnemonic Operation Instruction Format
POPA POP ALL. This instruction is used instead of POPF, to support the eight additional interrupts. It pops two words off the stack and places the first word into the INT_MASK1/WSR register pair and the second word into the PSW/INT_MASK register-pair. This instruction increments the SP by 4. Interrupt calls cannot occur immediately following this instruction.
INT_MASK1/WSR ← (SP) SP ← SP + 2 PSW/INT_MASK ← (SP) SP ← SP + 2
POPF POP FLAGS. Pops the word on top of the stack and places it into the PSW. Interrupt calls cannot occur immediately following this instruction.
(PSW) ← (SP) SP ← SP + 2
Z N C V VT ST
PUSH PUSH WORD. Pushes the word operand onto the stack.
Z N C V VT ST
—

Table A-6. Instruction Set (Continued)
Mnemonic Operation Instruction Format
PUSHA PUSH ALL. This instruction is used instead of PUSHF, to support the eight additional interrupts. It pushes two words — PSW/INT_MASK and INT_MASK1/WSR — onto the stack.
This instruction clears the PSW, INT_MASK, and INT_MASK1 registers and decrements the SP by 4. Interrupt calls cannot occur immediately following this instruction.
SP ← SP – 2 (SP) ← PSW/INT_MASK PSW/INT_MASK ← 0 SP ← SP – 2 (SP) ← INT_MASK1/WSR INT_MASK1 ← 0
0
PUSHF PUSH FLAGS. Pushes the PSW onto the top of the stack, then clears it. Clearing the PSW disables interrupt servicing. Interrupt calls cannot occur immediately following this instruction.
SP ← SP – 2 (SP) ← PSW/INT_MASK PSW/INT_MASK ← 0
0
RET RETURN FROM SUBROUTINE. Pops the PC off the top of the stack.
64-Kbyte mode: 1-Mbyte mode: PC ← (SP) PC ← (SP) SP ← SP + 2 SP ← SP + 4
—

Mnemonic Operation Instruction Format
RST RESET SYSTEM. Initializes the PSW to zero, the EPC/PC to FF2080H, and the pins and SFRs to their reset values. Executing this instruction causes the RESET# pin to be pulled low for 16 state times.
SFR ← Reset Status Pin ← Reset Status PSW ← 0 EPC/PC ← FF2080H
0
SCALL SHORT CALL. Pushes the contents of the program counter (the return address) onto the stack, then adds to the program counter the offset between the end of this instruction and the target label, effecting the call. The offset must be in the range of –1024 to +1023.
—
SETC SET CARRY FLAG. Sets the carry flag.
(11111001) PSW Flag Settings
— — 1 — — —

Table A-6. Instruction Set (Continued)
Mnemonic Operation Instruction Format
SHL SHIFT WORD LEFT. Shifts the destination word operand to the left as many times as specified by the count operand. The count may be specified either as an immediate value in the range of 0 to 15 (0FH), inclusive, or as the content of any register (10H – 0FFH) with a value in the range of 0 to 31 (1FH), inclusive. The right bits of the result are filled with zeros. The last bit shifted out is saved in the carry flag.
Temp ← (COUNT) do while Temp ≠ 0
C ← High order bit of (DEST) (DEST) ← (DEST) × 2 Temp ← Temp – 1 end_while
↑ —
SHLB SHIFT BYTE LEFT. Shifts the destination byte operand to the left as many times as specified by the count operand. The count may be specified either as an immediate value in the range of 0 to 15 (0FH), inclusive, or as the content of any register (10H – 0FFH) with a value in the range of 0 to 31 (1FH), inclusive. The right bits of the result are filled with zeros. The last bit shifted out is saved in the carry flag.
Temp ← (COUNT) do while Temp ≠ 0
C ← High order bit of (DEST) (DEST) ← (DEST) × 2 Temp ← Temp – 1 end_while
↑ —

Mnemonic Operation Instruction Format
SHLL SHIFT DOUBLE-WORD LEFT. Shifts the destination double-word operand to the left as many times as specified by the count operand. The count may be specified either as an immediate value in the range of 0 to 15 (0FH), inclusive, or as the content of any register (10H – 0FFH) with a value in the range of 0 to 31 (1FH), inclusive. The right bits of the result are filled with zeros. The last bit shifted out is saved in the carry flag.
Temp ← (COUNT) do while Temp ≠ 0
C ← High order bit of (DEST) (DEST) ← (DEST) × 2 Temp ← Temp – 1 end_while
↑ —
SHR LOGICAL RIGHT SHIFT WORD. Shifts the destination word operand to the right as many times as specified by the count operand. The count may be specified either as an immediate value in the range of 0 to 15 (0FH), inclusive, or as the content of any register (10H – 0FFH) with a value in the range of 0 to 31 (1FH), inclusive. The left bits of the result are filled with zeros. The last bit shifted out is saved in the carry flag.
Temp ← (COUNT) do while Temp ≠ 0
C ← Low order bit of (DEST) (DEST) ← (DEST)/2 Temp ← Temp – 1 end_while
In this operation, DEST/2 rep- resents unsigned division. PSW Flag Settings
0 0 —

Table A-6. Instruction Set (Continued)
Mnemonic Operation Instruction Format
SHRA ARITHMETIC RIGHT SHIFT WORD. Shifts the destination word operand to the right as many times as specified by the count operand. The count may be specified either as an immediate value in the range of 0 to 15 (0FH), inclusive, or as the content of any register (10H – 0FFH) with a value in the range of 0 to 31 (1FH), inclusive. If the original high order bit value was “0,” zeros are shifted in. If the value was “1,” ones are shifted in. The last bit shifted out is saved in the carry flag.
Temp ← (COUNT) do while Temp ≠ 0
C ← Low order bit of (DEST) (DEST) ← (DEST)/2 Temp ← Temp – 1 end_while
In this operation, DEST/2 rep- resents signed division. PSW Flag Settings
0 —
SHRAB ARITHMETIC RIGHT SHIFT BYTE. Shifts the destination byte operand to the right as many times as specified by the count operand. The count may be specified either as an immediate value in the range of 0 to 15 (0FH), inclusive, or as the content of any register (10H – 0FFH) with a value in the range of 0 to 31 (1FH), inclusive. If the original high order bit value was “0,” zeros are shifted in. If the value was “1,” ones are shifted in. The last bit shifted out is saved in the carry flag.
Temp ← (COUNT) do while Temp ≠ 0
C = Low order bit of (DEST) (DEST) ← (DEST)/2 Temp ← Temp – 1 end_while
In this operation, DEST/2 rep- resents signed division. PSW Flag Settings
0 —

Mnemonic Operation Instruction Format
SHRAL ARITHMETIC RIGHT SHIFT DOUBLE- WORD. Shifts the destination double-word operand to the right as many times as specified by the count operand. The count may be specified either as an immediate value in the range of 0 to 15 (0FH), inclusive, or as the content of any register (10H – 0FFH) with a value in the range of 0 to 31 (1FH), inclusive. If the original high order bit value was “0,” zeros are shifted in. If the value was “1,” ones are shifted in.
Temp ← (COUNT) do while Temp ≠ 0
C ← Low order bit of (DEST) (DEST) ← (DEST)/2 Temp ← Temp – 1 end_while
In this operation, DEST/2 rep- resents signed division. PSW Flag Settings
0 —
SHRB LOGICAL RIGHT SHIFT BYTE. Shifts the destination byte operand to the right as many times as specified by the count operand. The count may be specified either as an immediate value in the range of 0 to 15 (0FH), inclusive, or as the content of any register (10H – 0FFH) with a value in the range of 0 to 31 (1FH), inclusive. The left bits of the result are filled with zeros. The last bit shifted out is saved in the carry flag.
Temp ← (COUNT) do while Temp ≠ 0
C ← Low order bit of (DEST) (DEST) ← (DEST)/2 Temp ← Temp–1 end_while
In this operation, DEST/2 rep- resents unsigned division. PSW Flag Settings
0 0 —

Table A-6. Instruction Set (Continued)
Mnemonic Operation Instruction Format
SHRL LOGICAL RIGHT SHIFT DOUBLE-WORD. Shifts the destination double-word operand to the right as many times as specified by the count operand. The count may be specified either as an immediate value in the range of 0 to 15 (0FH), inclusive, or as the content of any register (10H – 0FFH) with a value in the range of 0 to 31 (1FH), inclusive. The left bits of the result are filled with zeros. The last bit shifted out is saved in the carry flag.
Temp ← (COUNT) do while Temp ≠ 0
C ← Low order bit of (DEST) (DEST) ← (DEST)/2) Temp ← Temp – 1 end_while
In this operation, DEST/2 rep- resents unsigned division. PSW Flag Settings
0 0 —
SJMP SHORT JUMP. Adds to the program counter the offset between the end of this instruction and the target label, effecting the jump. The offset must be in the range of –1024 to +1023, inclusive.
PC ← PC + 11-bit disp
—
SKIP TWO BYTE NO-OPERATION. Does nothing. Control passes to the next sequential instruction. This is actually a two-byte NOP in which the second byte can be any value and is simply ignored.
—

Mnemonic Operation Instruction Format
ST STORE WORD. Stores the value of the source (leftmost) word operand into the destination (rightmost) operand.
(DEST) ← (SRC)
Z N C V VT ST
—
STB STORE BYTE. Stores the value of the source (leftmost) byte operand into the destination (rightmost) operand.
(DEST) ← (SRC)
Z N C V VT ST
—
SUBTRACT WORDS. Subtracts the source word operand from the destination word operand, stores the result in the destination operand, and sets the carry flag as the complement of borrow.
(DEST) ← (DEST) – (SRC)
Z N C V VT ST
↑ —
SUBTRACT WORDS. Subtracts the first source word operand from the second, stores the result in the destination operand, and sets the carry flag as the complement of borrow.
SUB Dwreg, Swreg, waop
(010010aa) (waop) (Swreg) (Dwreg)
Z N C V VT ST
↑ —

Table A-6. Instruction Set (Continued)
Mnemonic Operation Instruction Format
SUBTRACT BYTES. Subtracts the source byte operand from the destination byte operand, stores the result in the destination operand, and sets the carry flag as the complement of borrow.
(DEST) ← (DEST) – (SRC)
Z N C V VT ST
↑ —
SUBTRACT BYTES. Subtracts the first source byte operand from the second, stores the result in the destination operand, and sets the carry flag as the complement of borrow.
SUBB Dbreg, Sbreg, baop
(010110aa) (baop) (Sbreg) (Dbreg)
Z N C V VT ST
↑ —
SUBC SUBTRACT WORDS WITH BORROW. Subtracts the source word operand from the destination word operand. If the carry flag was clear, SUBC subtracts 1 from the result. It stores the result in the destination operand and sets the carry flag as the complement of borrow.
(DEST) ← (DEST) – (SRC) – (1–C)
Z N C V VT ST
↓ ↑ —
SUBCB SUBTRACT BYTES WITH BORROW. Subtracts the source byte operand from the destination byte operand. If the carry flag was clear, SUBCB subtracts 1 from the result. It stores the result in the destination operand and sets the carry flag as the complement of borrow.
(DEST) ← (DEST) – (SRC) – (1–C)
Z N C V VT ST
↓ ↑ —

Mnemonic Operation Instruction Format
TIJMP TABLE INDIRECT JUMP. Causes execution to continue at an address selected from a table of addresses.
(11100010) [INDEX] (#MASK) (TBASE)
The first word register, TBASE, contains the 16-bit address of the beginning of the jump table. TBASE can be located in RAM up to FEH without windowing or above FFH with windowing. The jump table itself can be placed at any nonreserved memory location on a word boundary in page FFH.
The second word register, INDEX, contains the 16-bit address that points to a register containing a 7-bit value. This value is used to calculate the offset into the jump table. Like TBASE, INDEX can be located in RAM up to FEH without windowing or above FFH with windowing. Note that the 16-bit address contained in INDEX is absolute; it disregards any windowing that may be in effect when the TIJMP instruction is executed.
The byte operand, #MASK, is 7-bit immediate data to mask INDEX. #MASK is ANDed with INDEX to determine the offset (OFFSET). OFFSET is multiplied by two, then added to the base address (TBASE) to determine the destination address (DEST X) in page FFH.
[INDEX] AND #MASK = OFFSET (2 × OFFSET) + TBASE = DEST X PC ← (DEST X)
—
PSW Flag Settings

Table A-6. Instruction Set (Continued)
Mnemonic Operation Instruction Format
TRAP SOFTWARE TRAP. This instruction causes an interrupt call that is vectored through location FF2010H. The operation of this instruction is not affected by the state of the interrupt enable flag (I) in the PSW. Interrupt calls cannot occur immediately following this instruction.
—
XCH EXCHANGE WORD. Exchanges the value of the source word operand with that of the destination word operand.
(00000100) (waop) (wreg) direct (00001011) (waop) (wreg) indexed
Z N C V VT ST
—
XCHB EXCHANGE BYTE. Exchanges the value of the source byte operand with that of the destination byte operand.
(00010100) (baop) (breg) direct (00011011) (baop) (breg) indexed
Z N C V VT ST
—

Mnemonic Operation Instruction Format
XOR LOGICAL EXCLUSIVE-OR WORDS. XORs the source word operand with the destination word operand and stores the result in the destination operand. The result has ones in the bit positions in which either operand (but not both) had a “1” and zeros in all other bit positions.
(DEST) ← (DEST) XOR (SRC)
Z N C V VT ST
0 0 — —
XORB LOGICAL EXCLUSIVE-OR BYTES. XORs the source byte operand with the destination byte operand and stores the result in the destination operand. The result has ones in the bit positions in which either operand (but not both) had a “1” and zeros in all other bit positions.
(DEST) ← (DEST) XOR (SRC)
Z N C V VT ST
0 0 — —
Table A-7 lists the instruction opcodes, in hexadecimal order, along with the corresponding in- struction mnemonics.

Table A-7. Instruction Opcodes
Hex Code Instruction Mnemonic
01 CLR
02 NOT
03 NEG
05 DEC
06 EXT
07 INC
08 SHR
09 SHL
0A SHRA
0C SHRL
0D SHLL
0E SHRAL
0F NORML
11 CLRB
12 NOTB
13 NEGB
15 DECB
16 EXTB
17 INCB
18 SHRB
19 SHLB
1A SHRAB
20–27 SJMP
28–2F SCALL
30–37 JBC
38–3F JBS
40 AND Direct (3 ops)
41 AND Immediate (3 ops)
42 AND Indirect (3 ops)
43 AND Indexed (3 ops)

Hex Code Instruction Mnemonic
44 ADD Direct (3 ops)
45 ADD Immediate (3 ops)
46 ADD Indirect (3 ops)
47 ADD Indexed (3 ops)
48 SUB Direct (3 ops)
49 SUB Immediate (3 ops)
4A SUB Indirect (3 ops)
4B SUB Indexed (3 ops)
4C MULU Direct (3 ops)
4D MULU Immediate (3 ops)
4E MULU Indirect (3 ops)
4F MULU Indexed (3 ops)
50 ANDB Direct (3 ops)
51 ANDB Immediate (3 ops)
52 ANDB Indirect (3 ops)
53 ANDB Indexed (3 ops)
54 ADDB Direct (3 ops)
55 ADDB Immediate (3 ops)
56 ADDB Indirect (3 ops)
57 ADDB Indexed (3 ops)
58 SUBB Direct (3 ops)
59 SUBB Immediate (3 ops)
5A SUBB Indirect (3 ops)
5B SUBB Indexed (3 ops)
5C MULUB Direct (3 ops)
5D MULUB Immediate (3 ops)
5E MULUB Indirect (3 ops)
5F MULUB Indexed (3 ops)
60 AND Direct (2 ops)
61 AND Immediate (2 ops)
62 AND Indirect (2 ops)
63 AND Indexed (2 ops)
64 ADD Direct (2 ops)
65 ADD Immediate (2 ops)
66 ADD Indirect (2 ops)
67 ADD Indexed (2 ops)
68 SUB Direct (2 ops)
69 SUB Immediate (2 ops)
6A SUB Indirect (2 ops)
6B SUB Indexed (2 ops)
6C MULU Direct (2 ops)

Table A-7. Instruction Opcodes (Continued)
Hex Code Instruction Mnemonic
6D MULU Immediate (2 ops)
6E MULU Indirect (2 ops)
6F MULU Indexed (2 ops)
70 ANDB Direct (2 ops)
71 ANDB Immediate (2 ops)
72 ANDB Indirect (2 ops)
73 ANDB Indexed (2 ops)
74 ADDB Direct (2 ops)
75 ADDB Immediate (2 ops)
76 ADDB Indirect (2 ops)
77 ADDB Indexed (2 ops)
78 SUBB Direct (2 ops)
79 SUBB Immediate (2 ops)
7A SUBB Indirect (2 ops)
7B SUBB Indexed (2 ops)
7C MULUB Direct (2 ops)
7D MULUB Immediate (2 ops)
7E MULUB Indirect (2 ops)
7F MULUB Indexed (2 ops)

Hex Code Instruction Mnemonic

Table A-7. Instruction Opcodes (Continued)
Hex Code Instruction Mnemonic
C5 CMPL
CD BMOVI
D0 JNST
D1 JNH
D2 JGT
D3 JNC
D4 JNVT
D5 JNV
D4 JNVT
D5 JNV
D6 JGE
D7 JNE
D8 JST
D9 JH
DA JLE
DB JC
DC JVT
DD JV
DE JLT
DF JE
E0 DJNZ
E1 DJNZW
E2 TIJMP
E3 BR Indirect, 64-Kbyte mode
EBR Indirect, 1-Mbyte mode

Hex Code Instruction Mnemonic
E7 LJMP
EC DPTS
ED EPTS
EE Reserved (Note 1)
F0 RET
F1 ECALL
F2 PUSHF
F3 POPF
F4 PUSHA
F5 POPA
F6 IDLPD
F7 TRAP
F8 CLRC
F9 SETC
FA DI
FB EI
FC CLRVT
FD NOP
FE DIV/DIVB/MUL/MULB (Note 2)
NOTES: 1. This opcode is reserved, but it does not generate an unimplemented opcode interrupt. 2. Signed multiplication and division are two-byte instructions. For each signed instruction, the first byte is “FE” and the second is the opcode of the corresponding unsigned instruction. For example, the opcode for MULU (3 operands) direct is “4C,” so the opcode for MUL (3 oper- ands) direct is “FE 4C.”
Table A-8 lists instructions along with their lengths and opcodes for each applicable addressing mode. A dash (—) in any column indicates “not applicable.”

Table A-8. Instruction Lengths and Hexadecimal Opcodes
Direct Immediate Indirect (Note 1)
Indexed (Notes 1, 2)
Length Opcode Length Opcode Length Opcode Length
ADD (2 ops) 3 64 4 65 3 66 4/5 67
ADD (3 ops) 4 44 5 45 4 46 5/6 47
ADDB (2 ops) 3 74 3 75 3 76 4/5 77
ADDB (3 ops) 4 54 4 55 4 56 5/6 57
ADDC 3 A4 4 A5 3 A6 4/5 A7
ADDCB 3 B4 3 B5 3 B6 4/5 B7
CLR 2 01 —
CLRB 2 11 —
CMP 3 88 4 89 3 8A 4/5 8B
CMPB 3 98 3 99 3 9A 4/5 9B
CMPL 3 C5 —
DEC 2 05 —
DECB 2 15 —
EXT 2 06 —
EXTB 2 16 —
INC 2 07 —
INCB 2 17 —
SUB (2 ops) 3 68 4 69 3 6A 4/5 6B
SUB (3 ops) 4 48 5 49 4 4A 5/6 4B
SUBB (2 ops) 3 78 3 79 3 7A 4/5 7B
SUBB (3 ops) 4 58 4 59 4 5A 5/6 5B
SUBC 3 A8 4 A9 3 AA 4/5 AB
SUBCB 3 B8 3 B9 3 BA 4/5 BB
NOTES: 1. Indirect normal and indirect autoincrement share the same opcodes, as do short- and long-indexed modes. Because word registers always have even addresses, the address can be expressed in the upper seven bits; the least-significant bit determines the addressing mode. Indirect normal and short- indexed modes make the second byte of the instruction even (LSB = 0). Indirect autoincrement and long-indexed modes make the second byte odd (LSB = 1). 2. For indexed instructions, the first column lists instruction lengths as S/L, where S is the short-indexed instruction length and L is the long-indexed instruction length. 3. For the SCALL and SJMP instructions, the three least-significant bits of the opcode are concatenated with the eight bits to form an 11-bit, 2’s complement offset.
Arithmetic (Group I) · Mnemonic · S/L Opcode

Direct Immediate Indirect (Note 1)
Indexed (Notes 1, 2)
Length Opcode Length Opcode Length Opcode Length
DIV 4 FE 8C 5 FE 8D 4 FE 8E 5/6 FE 8F
DIVB 4 FE 9C 4 FE 9D 4 FE 9E 5/6 FE 9F
DIVU 3 8C 4 8D 3 8E 4/5 8F
DIVUB 3 9C 3 9D 3 9E 4/5 9F
MUL (2 ops) 4 FE 6C 5 FE 6D 4 FE 6E 5/6 FE 6F
MUL (3 ops) 5 FE 4C 6 FE 4D 5 FE 4E 6/7 FE 4F
MULB (2 ops) 4 FE 7C 4 FE 7D 4 FE 7E 5/6 FE 7F
MULB (3 ops) 5 FE 5C 5 FE 5D 5 FE 5E 6/7 FE 5F
MULU (2 ops) 3 6C 4 6D 3 6E 4/5 6F
MULU (3 ops) 4 4C 5 4D 4 4E 5/6 4F
MULUB (2 ops) 3 7C 3 7D 3 7E 4/5 7F
MULUB (3 ops) 4 5C 4 5D 4 5E 5/6 5F
Direct Immediate Indirect (Note 1)
Indexed (Notes 1, 2)
Length Opcode Length Opcode Length Opcode Length
AND (2 ops) 3 60 4 61 3 62 4/5 63
AND (3 ops) 4 40 5 41 4 42 5/6 43
ANDB (2 ops) 3 70 3 71 3 72 4/5 73
ANDB (3 ops) 4 50 4 51 4 52 5/6 53
NEG 2 03 —
NEGB 2 13 —
NOT 2 02 —
NOTB 2 12 —
OR 3 80 4 81 3 82 4/5 83
ORB 3 90 3 91 3 92 4/5 93
XOR 3 84 4 85 3 86 4/5 87
XORB 3 94 3 95 3 96 4/5 97
NOTES: 1. Indirect normal and indirect autoincrement share the same opcodes, as do short- and long-indexed modes. Because word registers always have even addresses, the address can be expressed in the upper seven bits; the least-significant bit determines the addressing mode. Indirect normal and short- indexed modes make the second byte of the instruction even (LSB = 0). Indirect autoincrement and long-indexed modes make the second byte odd (LSB = 1). 2. For indexed instructions, the first column lists instruction lengths as S/L, where S is the short-indexed instruction length and L is the long-indexed instruction length. 3. For the SCALL and SJMP instructions, the three least-significant bits of the opcode are concatenated with the eight bits to form an 11-bit, 2’s complement offset.

Table A-8. Instruction Lengths and Hexadecimal Opcodes (Continued)
Direct Immediate Indirect (Note 1)
Indexed (Notes 1, 2)
Length Opcode Length Opcode Length Opcode Length
POP 2 CC — — 2 CE 3/4 CF
POPA 1 F5 —
POPF 1 F3 —
PUSH 2 C8 3 C9 2 CA 3/4 CB
PUSHA 1 F4 —
PUSHF 1 F2 —
NOTES: 1. Indirect normal and indirect autoincrement share the same opcodes, as do short- and long-indexed modes. Because word registers always have even addresses, the address can be expressed in the upper seven bits; the least-significant bit determines the addressing mode. Indirect normal and short- indexed modes make the second byte of the instruction even (LSB = 0). Indirect autoincrement and long-indexed modes make the second byte odd (LSB = 1). 2. For indexed instructions, the first column lists instruction lengths as S/L, where S is the short-indexed instruction length and L is the long-indexed instruction length. 3. For the SCALL and SJMP instructions, the three least-significant bits of the opcode are concatenated with the eight bits to form an 11-bit, 2’s complement offset.
Stack · Mnemonic · S/L Opcode

Direct Immediate Extended-indirect Extended-
Length Opcode Length Opcode Length Opcode Length Opcode
EBMOVI — 3 E4 — —
ELD — 3 E8 6 E9
ELDB — 3 EA 6 EB
EST — 3 1C 6 1D
ESTB — 3 1E 6 1F
Direct Immediate Indirect (Note 1)
Indexed (Notes 1, 2)
Length Opcode Length Opcode Length Opcode Length
BMOV — 3 C1 — —
BMOVI — 3 CD — —
LD 3 A0 4 A1 3 A2 4/5 A3
LDB 3 B0 3 B1 3 B2 4/5 B3
LDBSE 3 BC 3 BD 3 BE 4/5 BF
LDBZE 3 AC 3 AD 3 AE 4/5 AF
ST 3 C0 — — 3 C2 4/5 C3
STB 3 C4 — — 3 C6 4/5 C7
XCH 3 04 — 4/5 0B
XCHB 3 14 — 4/5 1B
NOTES: 1. Indirect normal and indirect autoincrement share the same opcodes, as do short- and long-indexed modes. Because word registers always have even addresses, the address can be expressed in the upper seven bits; the least-significant bit determines the addressing mode. Indirect normal and short- indexed modes make the second byte of the instruction even (LSB = 0). Indirect autoincrement and long-indexed modes make the second byte odd (LSB = 1). 2. For indexed instructions, the first column lists instruction lengths as S/L, where S is the short-indexed instruction length and L is the long-indexed instruction length. 3. For the SCALL and SJMP instructions, the three least-significant bits of the opcode are concatenated with the eight bits to form an 11-bit, 2’s complement offset.

Table A-8. Instruction Lengths and Hexadecimal Opcodes (Continued)
Direct Immediate Extended-indirect Extended-
Length Opcode Length Opcode Length Opcode Length Opcode
EBR — 2 E3 — —
EJMP — 4 E6
Direct Immediate Indirect (Note 1)
Indexed (Notes 1, 2)
Length Opcode Length Opcode Length Opcode Length
BR — 2 E3 — —
LJMP —/3 E7
SJMP (Note 3) — 2/— 20–27
TIJMP 4 E2 4 E2 — — —/4 E2
Direct Immediate Extended-indirect Extended-
Length Opcode Length Opcode Length Opcode Length Opcode
ECALL — 4 F1
Direct Immediate Indirect (Note 1)
Length Opcode Length Opcode Length Opcode Length Opcode
LCALL — 3 EF
RET — 1 F0 — —
SCALL (Note 3) — 2 28–2F
TRAP 1 F7 —
NOTES: 1. Indirect normal and indirect autoincrement share the same opcodes, as do short- and long-indexed modes. Because word registers always have even addresses, the address can be expressed in the upper seven bits; the least-significant bit determines the addressing mode. Indirect normal and short- indexed modes make the second byte of the instruction even (LSB = 0). Indirect autoincrement and long-indexed modes make the second byte odd (LSB = 1). 2. For indexed instructions, the first column lists instruction lengths as S/L, where S is the short-indexed instruction length and L is the long-indexed instruction length. 3. For the SCALL and SJMP instructions, the three least-significant bits of the opcode are concatenated with the eight bits to form an 11-bit, 2’s complement offset.

Direct Immediate Indirect Indexed (Notes 1, 2)
Length Opcode Length Opcode Length Opcode Length
DJNZ — 3/— E0
DJNZW — 3/— E1
JBC — 3/— 30–37
JBS — 3/— 38–3F
JC — 2/— DB
JE — 2/— DF
JGE — 2/— D6
JGT — 2/— D2
JH — 2/— D9
JLE — 2/— DA
JLT — 2/— DE
JNC — 2/— D3
JNE — 2/— D7
JNH — 2/— D1
JNST — 2/— D0
JNV — 2/— D5
JNVT — 2/— D4
JST — 2/— D8
JV — 2/— DD
JVT — 2/— DC
NOTES: 1. Indirect normal and indirect autoincrement share the same opcodes, as do short- and long-indexed modes. Because word registers always have even addresses, the address can be expressed in the upper seven bits; the least-significant bit determines the addressing mode. Indirect normal and short- indexed modes make the second byte of the instruction even (LSB = 0). Indirect autoincrement and long-indexed modes make the second byte odd (LSB = 1). 2. For indexed instructions, the first column lists instruction lengths as S/L, where S is the short-indexed instruction length and L is the long-indexed instruction length. 3. For the SCALL and SJMP instructions, the three least-significant bits of the opcode are concatenated with the eight bits to form an 11-bit, 2’s complement offset.
Conditional Jump · Mnemonic · S/L Opcode

Table A-8. Instruction Lengths and Hexadecimal Opcodes (Continued)
Direct Immediate Indirect Indexed
Length Opcode Length Opcode Length Opcode Length Opcode
NORML 3 0F —
SHL 3 09 —
SHLB 3 19 —
SHLL 3 0D —
SHR 3 08 —
SHRA 3 0A —
SHRAB 3 1A —
SHRAL 3 0E —
SHRB 3 18 —
SHRL 3 0C —
Direct Immediate Indirect Indexed
Length Opcode Length Opcode Length Opcode Length Opcode
CLRC 1 F8 —
CLRVT 1 FC —
DI 1 FA —
EI 1 FB —
IDLPD — — 1 F6 —
NOP 1 FD —
RST 1 FF —
SETC 1 F9 —
SKIP 2 00 —
Direct Immediate Indirect Indexed
Length Opcode Length Opcode Length Opcode Length Opcode
DPTS 1 EC —
EPTS 1 ED —
NOTES: 1. Indirect normal and indirect autoincrement share the same opcodes, as do short- and long-indexed modes. Because word registers always have even addresses, the address can be expressed in the upper seven bits; the least-significant bit determines the addressing mode. Indirect normal and short- indexed modes make the second byte of the instruction even (LSB = 0). Indirect autoincrement and long-indexed modes make the second byte odd (LSB = 1). 2. For indexed instructions, the first column lists instruction lengths as S/L, where S is the short-indexed instruction length and L is the long-indexed instruction length. 3. For the SCALL and SJMP instructions, the three least-significant bits of the opcode are concatenated with the eight bits to form an 11-bit, 2’s complement offset.

Table A-9 lists instructions alphabetically within groups, along with their execution times, ex- pressed in state times.
Mnemonic Direct Immed.
Normal Autoinc. Short Long
Reg. Mem. Reg. Mem. Reg. Mem. Reg. Mem.
ADD (2 ops) 4 5 6 8 7 9 6 8 7 9
ADD (3 ops) 5 6 7 10 8 11 7 10 8 11
ADDB (2 ops) 4 4 6 8 7 9 6 8 7 9
ADDB (3 ops) 5 5 7 10 8 11 7 10 8 11
ADDC 4 5 6 8 7 9 6 8 7 9
ADDCB 4 4 6 8 7 9 6 8 7 9
CLR 3 —
CLRB 3 —
CMP 4 5 6 8 7 9 6 8 7 9
CMPB 4 4 6 8 7 9 6 8 7 9
CMPL 7 —
DEC 3 —
DECB 3 —
EXT 4 —
EXTB 4 —
INC 3 —
INCB 3 —
SUB (2 ops) 4 5 6 8 7 9 6 8 7 9
SUB (3 ops) 5 6 7 10 8 11 7 10 8 11
SUBB (2 ops) 4 4 6 8 7 9 6 8 7 9
SUBB (3 ops) 5 5 7 10 8 11 7 10 8 11
SUBC 4 5 6 8 7 9 6 8 7 9
SUBCB 4 4 6 8 7 9 6 8 7 9
Arithmetic (Group I) · Indirect Indexed

Table A-9. Instruction Execution Times (in State Times) (Continued)
Mnemonic Direct Immed.
Normal Autoinc. Short Long
Reg. Mem. Reg. Mem. Reg. Mem. Reg. Mem.
DIV 26 27 28 31 29 32 29 32 30 33
DIVB 18 18 20 23 21 24 21 24 22 25
DIVU 24 25 26 29 27 30 27 30 28 31
DIVUB 16 16 18 21 19 22 19 22 20 23
MUL (2 ops) 16 17 18 21 19 22 19 22 20 23
MUL (3 ops) 16 17 18 21 19 22 19 22 20 23
MULB (2 ops) 12 12 14 17 15 18 15 18 16 19
MULB (3 ops) 12 12 14 17 15 18 15 18 16 19
MULU (2 ops) 14 15 16 19 17 19 17 20 18 21
MULU (3 ops) 14 15 16 19 17 19 17 20 18 21
MULUB (2 ops) 10 10 12 15 13 15 12 16 14 17
MULUB (3 ops) 10 10 12 15 13 15 12 16 14 17
Mnemonic Direct Immed.
Normal Autoinc. Short Long
Reg. Mem. Reg. Mem. Reg. Mem. Reg. Mem.
AND (2 ops) 4 5 6 8 7 9 6 8 7 9
AND (3 ops) 5 6 7 10 8 11 7 10 8 11
ANDB (2 ops) 4 4 6 8 7 9 6 8 7 9
ANDB (3 ops) 5 5 7 10 8 11 7 10 8 11
NEG 3 —
NEGB 3 —
NOT 3 —
NOTB 3 —
OR 4 5 6 8 7 9 6 8 7 9
ORB 4 4 6 8 7 9 6 8 7 9
XOR 4 5 6 8 7 9 6 8 7 9
XORB 4 4 6 8 7 9 6 8 7 9

Mnemonic Direct Immed.
Normal Autoinc. Short Long
Reg. Mem. Reg. Mem. Reg. Mem. Reg. Mem.
POP 8 — 10 12 11 13 11 13 12 14
POPA 12 —
POPF 7 —
PUSH 6 7 9 12 10 13 10 13 11 14
PUSHA 12 —
PUSHF 6 —
Mnemonic Direct Immed.
Normal Autoinc. Short Long
Reg. Mem. Reg. Mem. Reg. Mem. Reg. Mem.
POP 11 — 13 15 14 16 14 16 15 17
POPA 18 —
POPF 10 —
PUSH 8 9 11 14 12 15 12 15 13 16
PUSHA 18 —
PUSHF 8 —

Table A-9. Instruction Execution Times (in State Times) (Continued)
EBMOVI register/register 8 + 14 per word + 16 per interrupt memory/register 8 + 17 per word + 16 per interrupt memory/memory 8 + 20 per word + 16 per interrupt
BMOV register/register 6 + 8 per word memory/register 6 + 11 per word memory/memory 6 + 14 per word
BMOVI register/register 7 + 8 per word + 14 per interrupt memory/register 7 + 11 per word + 14 per interrupt memory/memory 7 + 14 per word + 14 per interrupt
Mnemonic Direct Immed.
Extended-indexed Normal Autoinc.
ELD — — 6 9 8 11 8 11
ELDB — — 6 9 8 11 8 11
EST — — 6 9 8 11 8 11
ESTB — — 6 9 8 11 8 11
Mnemonic Direct Immed.
Normal Autoinc. Short Long
Reg. Mem. Reg. Mem. Reg. Mem. Reg. Mem.
LD 4 5 5 8 6 8 6 9 7 10
LDB 4 4 5 8 6 8 6 9 7 10
LDBSE 4 4 5 8 6 8 6 9 7 10
LDBZE 4 4 5 8 6 8 6 9 7 10
ST 4 — 5 8 6 9 6 9 7 10
STB 4 — 5 8 6 8 6 9 7 10
XCH 5 — 8 13 9 14
XCHB 5 — 8 13 9 14

Mnemonic Direct Immed. Extended-indirect
Extended-indexed Normal Autoinc.
EJMP — — — — 8
Mnemonic Direct Immed.
Normal Autoinc. Short Long
LJMP — — — — — 7
SJMP — — — — 7 —
TIJMP
— — 15 18 21
Mnemonic Direct Immed.
Extended-indexed Normal Autoinc.
1-Mbyte mode — 16
Mnemonic Direct Immed.
Normal Autoinc. Short Long
1-Mbyte mode 64-Kbyte mode — 15 11
1-Mbyte mode 64-Kbyte mode — — 16 11 — — —
1-Mbyte mode 64-Kbyte mode — 15 11
1-Mbyte mode 64-Kbyte mode 19 16 —

Table A-9. Instruction Execution Times (in State Times) (Continued)
Mnemonic Direct Immed.
Extended-indexed Normal Autoinc.
1-Mbyte mode — 22
Mnemonic Direct Immed.
Normal Autoinc. Short Long
1-Mbyte mode 64-Kbyte mode — 18 13
1-Mbyte mode 64-Kbyte mode — — 22 14 — — —
1-Mbyte mode 64-Kbyte mode — 18 13
1-Mbyte mode 64-Kbyte mode 25 18 —
Call (Memory) · Extended-indirect · Indirect Indexed

DJNZ 5 (jump not taken), 9 (jump taken)
DJNZW 6 (jump not taken), 10 (jump taken)
JBC 5 (jump not taken), 9 (jump taken)
JBS 5 (jump not taken), 9 (jump taken)
JC 4 (jump not taken), 8 (jump taken)
JE 4 (jump not taken), 8 (jump taken)
JGE 4 (jump not taken), 8 (jump taken)
JGT 4 (jump not taken), 8 (jump taken)
JH 4 (jump not taken), 8 (jump taken)
JLE 4 (jump not taken), 8 (jump taken)
JLT 4 (jump not taken), 8 (jump taken)
JNC 4 (jump not taken), 8 (jump taken)
JNE 4 (jump not taken), 8 (jump taken)
JNH 4 (jump not taken), 8 (jump taken)
JNST 4 (jump not taken), 8 (jump taken)
JNV 4 (jump not taken), 8 (jump taken)
JNVT 4 (jump not taken), 8 (jump taken)
JST 4 (jump not taken), 8 (jump taken)
JV 4 (jump not taken), 8 (jump taken)
JVT 4 (jump not taken), 8 (jump taken)
NORML 8 + 1 per shift (9 for 0 shift)
SHL 6 + 1 per shift (7 for 0 shift)
SHLB 6 + 1 per shift (7 for 0 shift)
SHLL 7 + 1 per shift (8 for 0 shift)
SHR 6 + 1 per shift (7 for 0 shift)
SHRA 6 + 1 per shift (7 for 0 shift)
SHRAB 6 + 1 per shift (7 for 0 shift)
SHRAL 7 + 1 per shift (8 for 0 shift)
SHRB 6 + 1 per shift (7 for 0 shift)
SHRL 7 + 1 per shift (8 for 0 shift)

Table A-9. Instruction Execution Times (in State Times) (Continued)
Mnemonic Direct Immed.
Normal Autoinc. Short Long
CLRVT 2 — — — — —
DI 2 — — — — —
EI 2 — — — — —
IDLPD
Valid key Invalid key
12 28 — —
RST 4 — — — — —
SETC 2 — — — — —
SKIP 3 — — — — —
PTS
Mnemonic Direct Immed.
Normal Autoinc. Short Long
EPTS 2 — — — — —
Special · Indirect Indexed · Indirect Indexed



Signal Descriptions



This appendix provides reference information for the pin functions of the 8XC196NP and 80C196NU.
Table B-1 lists the signals for the 8XC196NP and 80C196NU, grouped by function. A diagram of each package that is currently available shows the pin location of each signal.
Address & Data Processor Control Input/Output Bus Control & Status
A19:0 EA# (NP only) EPORT3:0 ALE
NMI P1.4/T1CLK BREQ#
Power & Ground ONCE P1.5/T1DIR CLKOUT
VCC PLLEN1 (NU only) P1.6/T2CLK CS5:0#
VSS PLLEN2 (NU only) P1.7/T2DIR HOLD#
RPD P2.1/RXD INST
XTAL1 P2.7:2 RD#
XTAL2 P3.7:0 READY
P4.2:0/PWM2:0 WR#/WRL#
P4.3
B-1

A17 / EPORT.1
A18 / EPORT.2
A19 / EPORT.3
WR# / WRL#
AD0
AD1
AD2
AD3
AD4
AD5
AD6
AD7
AD8
AD9
AD10
AD11
AD12
AD13
AD14
AD15
V SS
V SS
100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51
RD# BHE# / WRH# ALE INST READY RPD ONCE VSS VCC VSS A8 A9 A10 A11 A12 A13 A14 A15 NC VSS XTAL1 XTAL2 VSS NC P2.7 / CLKOUT
A0 A1 V CC
V SS
A2 A3 A4 A5 A6 A7 V CC
V SS
NC NC P3.0 / CS0# P3.1 / CS1# P3.2 / CS2# P3.3 / CS3#
View of component as mounted on PC board
VSS P3.4 / CS4# P3.5 / CS5# P3.6 / EXTINT2
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
P1.0 / EPA0
P1.1 / EPA1
P1.2 / EPA2
P1.3 / EPA3
P1.4 / T1CLK
P1.5 / T1DIR
P1.6 / T2CLK
V SS
P1.7 / T2DIR
P4.0 / PWM0
P4.1 / PWM1
P4.2 / PWM2
P4.3
V SS
P2.0 / TXD
P2.1 / RXD
P2.2 / EXTINT0
P2.3 / BREQ#
P2.4 / EXTINT1
P2.5 / HOLD#
P2.6 / HLDA#
Figure B-1. 8XC196NP 100-lead SQFP Package
B-2
x8XC196NP

A16 / EPORT.0
A17 / EPORT.1
AD1
AD2
AD3
AD4
AD5
AD6
AD7
AD8
V SS
AD9
AD10
AD11
AD12
AD13
AD14
AD15
100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81
VSS A18 / EPORT.2 A19 / EPORT.3 WR# / WRL# RD# BHE# / WRH# ALE INST READY RPD ONCE VSS VCC VSS A8 A9 A10 A11 A12 A13 A14 A15 VSS XTAL1 XTAL2 VSS P2.7 / CLKOUT NC P2.6 / HLDA# P2.5 / HOLD#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51
NMI EA#
A0 A1 V CC
V SS
A2 A3 A4 A5 A6 A7 V CC
V SS
NC P3.0 / CS0# P3.1 / CS1# P3.2 / CS2# P3.3 / CS3#
View of component as mounted on PC board
VSS P3.4 / CS4# P3.5 / CS5# P3.6 / EXTINT2
P1.0 / EPA0
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
P1.2 / EPA2
P1.3 / EPA3
P1.4 / T1CLK
P1.5 / T1DIR
P1.6 / T2CLK
V SS
P1.7 / T2DIR
P4.0 / PWM0
P4.1 / PWM1
P4.2 / PWM2
P4.3
V SS
P2.0 / TXD
P2.1 / RXD
P2.2 / EXTINT0
P2.3 / BREQ#
P2.4 / EXTINT1
Figure B-2. 8XC196NP 100-lead QFP Package
B-3
x8XC196NP

A17 / EPORT.1
A18 / EPORT.2
A19 / EPORT.3
WR# / WRL#
AD0
AD1
AD2
AD3
AD4
AD5
AD6
AD7
AD8
AD9
AD10
AD11
AD12
AD13
AD14
AD15
V SS
V SS
100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51
RD# BHE# / WRH# ALE INST READY RPD ONCE PLLEN2 VCC VSS A8 A9 A10 A11 A12 A13 A14 A15 NC VSS XTAL1 XTAL2 VSS VCC P2.7 / CLKOUT
NC
A0 A1 V CC
V SS
A2 A3 A4 A5 A6 A7 V CC
V SS
NC PLLEN1 P3.0 / CS0# P3.1 / CS1# P3.2 / CS2# P3.3 / CS3#
View of component as mounted on PC board
VSS P3.4 / CS4# P3.5 / CS5# P3.6 / EXTINT2
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
P1.0 / EPA0
P1.1 / EPA1
P1.2 / EPA2
P1.3 / EPA3
P1.4 / T1CLK
P1.5 / T1DIR
P1.6 / T2CLK
V SS
P1.7 / T2DIR
P4.0 / PWM0
P4.1 / PWM1
P4.2 / PWM2
P4.3
V SS
P2.0 / TXD
P2.1 / RXD
P2.2 / EXTINT0
P2.3 / BREQ#
P2.4 / EXTINT1
P2.5 / HOLD#
P2.6 / HLDA#
Figure B-3. 80C196NU 100-lead SQFP Package
B-4
x8XC196NU

A16 / EPORT.0
A17 / EPORT.1
AD1
AD2
AD3
AD4
AD5
AD6
AD7
AD8
V SS
AD9
AD10
AD11
AD12
AD13
AD14
AD15
100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81
VSS A18 / EPORT.2 A19 / EPORT.3 WR# / WRL# RD# BHE# / WRH# ALE INST READY RPD ONCE PLLEN2 VCC VSS A8 A9 A10 A11 A12 A13 A14 A15 VSS XTAL1 XTAL2 VSS P2.7 / CLKOUT VCC P2.6 / HLDA# P2.5 / HOLD#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51
NMI
NC
A0 A1 V CC
V SS
A2 A3 A4 A5 A6 A7 V CC
VSS PLLEN1 P3.0 / CS0# P3.1 / CS1# P3.2 / CS2# P3.3 / CS3#
View of component as mounted on PC board
VSS P3.4 / CS4# P3.5 / CS5# P3.6 / EXTINT2
P1.0 / EPA0
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
P1.2 / EPA2
P1.3 / EPA3
P1.4 / T1CLK
P1.5 / T1DIR
P1.6 / T2CLK
V SS
P1.7 / T2DIR
P4.0 / PWM0
P4.1 / PWM1
P4.2 / PWM2
P4.3
V SS
P2.0 / TXD
P2.1 / RXD
P2.2 / EXTINT0
P2.3 / BREQ#
P2.4 / EXTINT1
Figure B-4. 80C196NU 100-lead QFP Package
B-5
x8XC196NU

Table B-2 defines the columns used in Table B-3, which describes the signals.
Name Lists the signals, arranged alphabetically. Many pins have two functions, so there are more entries in this column than there are pins. Every signal is listed in this column.
Type Identifies the pin function listed in the Name column as an input (I), output (O), bidirectional (I/O), power (PWR), or ground (GND).
Description Briefly describes the function of the pin for the specific signal listed in the Name column. Also lists the alternate fuction that are multiplexed with the signal (if applicable).
A15:0 I/O System Address Bus
These address lines provide address bits 0–15 during the entire external memory cycle during both multiplexed and demultiplexed bus modes.
A19:16 I/O Address Lines 16–19
These address lines provide address bits 16–19 during the entire external memory cycle, supporting extended addressing of the 1 Mbyte address space.
AD15:0 I/O Address/Data Lines
The function of these pins depend on the bus size and mode. When a bus access is not occurring, these pins revert to their I/O port function. 16-bit Multiplexed Bus Mode: AD15:0 drive address bits 0–15 during the first half of the bus cycle and drives or receives data during the second half of the bus cycle. 8-bit Multiplexed Bus Mode: AD15:8 drive address bits 8–15 during the entire bus cycle. AD7:0 drive address bits 0–7 during the first half of the bus cycle and either drive or receive data during the second half of the bus cycle. 16-bit Demultiplexed Mode: AD15:0 drive or receive data during the entire bus cycle. 8-bit Demultiplexed Mode: AD7:0 drive or receive data during the entire bus cycle. AD15:8 drive the data that is currently on the high byte of the internal bus.
Column Heading Description · Name Type Description

Table B-3. Signal Descriptions (Continued)
ALE O Address Latch Enable
This active-high output signal is asserted only during external memory cycles. ALE signals the start of an external bus cycle and indicates that valid address information is available on the system address/data bus (A19:16 and AD15:0 for a multiplexed bus; A19:0 for a demultiplexed bus). ALE differs from ADV# in that it does not remain active during the entire bus cycle.
An external latch can use this signal to demultiplex address bits 0–15 from the address/data bus in multiplexed mode.
BHE# O Byte High Enable†
During 16-bit bus cycles, this active-low output signal is asserted for word reads and writes and high-byte reads and writes to external memory. BHE# indicates that valid data is being transferred over the upper half of the system data bus. Use BHE#, in conjunction with A0, to determine which memory byte is being transferred over the system bus:
BHE# A0 Byte(s) Accessed
0 0 both bytes 0 1 high byte only 1 0 low byte only
BHE# is multiplexed with WRH#.
† The chip configuration register 0 (CCR0) determines whether this pin functions as BHE# or WRH#. CCR0.2 = 1 selects BHE#; CCR0.2 = 0 selects WRH#.
BREQ# O Bus Request
This active-low output signal is asserted during a hold cycle when the bus controller has a pending external memory cycle.
The device can assert BREQ# at the same time as or after it asserts HLDA#. Once it is asserted, BREQ# remains asserted until HOLD# is removed.
You must enable the bus-hold protocol before using this signal (see “Enabling the Bus-hold Protocol” on page 13-32).
BREQ# is multiplexed with P2.3.
CLKOUT O Clock Output
Output of the internal clock generator. The CLKOUT frequency is ½ the internal operating frequency (f). CLKOUT has a 50% duty cycle.
CLKOUT is multiplexed with P2.7.
CS5:0# O Chip-select Lines 0–5
The active-low output CSx# is asserted during an external memory cycle when the address to be accessed is in the range programmed for chip select x. If the external memory address is outside the range assigned to the six chip selects, no chip-select output is asserted and the bus configuration defaults to the CS5# values.
Immediately following reset, CS0# is automatically assigned to the range FF2000–FF20FFH (F2000–F20FFH if external).
CS5:0# is multiplexed with P3.5:0
Name Type Description

EA# (NP only) I External Access
This input determines whether memory accesses to special-purpose and program memory partitions (FF2000–FF2FFFH) are directed to internal or external memory. These accesses are directed to internal memory if EA# is held high and to external memory if EA# is held low. For an access to any other memory location, the value of EA# is irrelevant.
EA# is not latched and can be switched dynamically during normal operating mode. Be sure to thoroughly consider the issues, such as different access times for internal and external memory, before using this dynamic switching capability.
On devices with no internal nonvolatile memory, always connect EA# to VSS.
EA# is not implemented on the 80C196NU.
EPA3:0 I/O Event Processor Array (EPA) Input/Output pins
These are the high-speed input/output pins for the EPA capture/compare channels. For high-speed PWM applications, the outputs of two EPA channels (either EPA0 and EPA1 or EPA2 and EPA3) can be remapped to produce a PWM waveform on a shared output pin (see “Generating a High-speed PWM Output” on page 10-14).
EPA3:0 are multiplexed with P1.3:0.
EPORT.3:0 I/O Extended Addressing Port
On the 8XC196NP, this is a 4-bit, bidirectional, memory-mapped I/O port.
On the 8XC196NU, this is a 4-bit, bidirectional, standard I/O port.
EPORT.3:0 are multiplexed with A19:16.
EXTINT3:0 I External Interrupts
In normal operating mode, a rising edge on EXTINTx sets the EXTINTx interrupt pending bit. EXTINTx is sampled during phase 2 (CLKOUT high). The minimum high time is one state time.
In standby and powerdown modes, asserting the EXTINTx signal for at least 50 ns causes the device to resume normal operation. The interrupt need not be enabled, but the pin must be configured as a special-function input (see “Bidirectional Port Pin Configurations” on page 7-7). If the EXTINTx interrupt is enabled, the CPU executes the interrupt 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.
EXTINT0 is multiplexed with P2.2, EXTINT1 is multiplexed with P2.4, EXTINT2 is multiplexed with P3.6, and EXTINT3 is multiplexed with P3.7.
HLDA# O Bus Hold Acknowledge
This active-low output indicates that the CPU has released the bus as the result of an external device asserting HOLD#.
HLDA# is multiplexed with P2.6.
Name Type Description

Table B-3. Signal Descriptions (Continued)
HOLD# I Bus Hold Request
An external device uses this active-low input signal to request control of the bus. This pin functions as HOLD# only if the pin is configured for its special function (see “Bidirectional Port Pin Configurations” on page 7-7) and the bus- hold protocol is enabled. Setting bit 7 of the window selection register (WSR) enables the bus-hold protocol.
HOLD# is multiplexed with P2.5.
INST O Instruction Fetch
This active-high output signal is valid only during external memory bus cycles. When high, INST indicates that an instruction is being fetched from external memory. The signal remains high during the entire bus cycle of an external instruction fetch. INST is low for data accesses, including interrupt vector fetches and chip configuration byte reads. INST is low during internal memory fetches.
NMI I Nonmaskable Interrupt
In normal operating mode, a rising edge on NMI generates a nonmaskable interrupt. NMI has the highest priority of all prioritized interrupts. Assert NMI for greater than one state time to guarantee that it is recognized.
ONCE I On-circuit Emulation
Holding ONCE high during the rising edge of RESET# places the device into on-circuit emulation (ONCE) mode. This mode puts all pins into a high- impedance state, thereby isolating the device from other components in the system. The value of ONCE is latched when the RESET# pin goes inactive. While the device is in ONCE mode, you can debug the system using a clip-on emulator. To exit ONCE mode, reset the device by pulling the RESET# signal low. To prevent accidental entry into ONCE mode, connect the ONCE pin to VSS. P1.7:0 I/O Port 1
This is a standard, bidirectional port that is multiplexed with individually selectable special-function signals.
Port 1 is multiplexed as follows: P1.0/EPA0, P1.1/EPA1, P1.2/EPA2, P1.3/EPA3, P1.4/T1CLK, P1.5/T1DIR, P1.6/T2CLK, and P1.7/T2DIR.
P2.7:0 I/O Port 2
This is a standard bidirectional port that is multiplexed with individually selectable special-function signals.
Port 2 is multiplexed as follows: P2.0/TXD, P2.1/RXD, P2.2/EXTINT0, P2.3/BREQ#, P2.4/EXTINT1, P2.5/HOLD#, P2.6/HLDA#, and P2.7/CLKOUT.
P3.7:0 I/O Port 3
This is an 8-bit, bidirectional, standard I/O port.
Port 3 is multiplexed as follows: P3.0/CS0#, P3.1/CS1#, P3.2/CS2#, P3.3/CS3#, P3.4/CS4#, P3.5/CS5#, P3.6/EXTINT2, and P3.7/EXTINT3.
P4.3:0 I/O Port 4
This is a 4-bit, bidirectional, standard I/O port with high-current drive capability.
Port 4 is multiplexed as follows: P4.0/PWM0, P4.1/PWM1, and P4.2/PWM2. P4.3 is not multiplexed.
Name Type Description

PLLEN2:1 (NU only)
I Phase-locked Loop 1 and 2 Enable
These input pins are used to enable the on-chip clock multiplier feature and select either the doubled or quadrupled clock speed as follows:
0 0 standard mode; clock multiplier circuitry disabled. Internal clock equals the XTAL1 input frequency. 0 1 Reserved† 1 0 doubled mode; clock multiplier circuitry enabled. Internal clock is twice the XTAL1 input frequency. 1 1 quadrupled mode; clock multiplier circuitry enabled. Internal clock is four times the XTAL1 input frequency.
† This reserved combination causes the device to enter an unsupported test mode.
PWM2:0 O Pulse Width Modulator Outputs
These are PWM output pins with high-current drive capability. The duty cycle and frequency-pulse-widths are programmable.
PWM2:0 are multiplexed with P4.2:0.
Read-signal output to external memory. RD# is asserted only during external memory reads.
READY I Ready Input
This active-high input signal is used to lengthen external memory cycles for slow memory by generating wait states in addition to the wait states that are generated internally.
When READY is high, CPU operation continues in a normal manner with wait states inserted as programmed in CCR0 or the chip-select x bus control register. READY is ignored for all internal memory accesses.
A level-sensitive reset input to and open-drain system reset output from the microcontroller. Either a falling edge on RESET# or an internal reset turns on a pull-down transistor connected to the RESET# pin for 16 state times. In the powerdown, standby, and idle modes, asserting RESET# causes the chip to reset and return to normal operating mode. After a device reset, the first instruction fetch is from FF2080H (or F2080H in external memory). For the 80C196NP and 80C196NU, the program and special-purpose memory locations (FF2000–FF2FFFH) reside in external memory. For the 83C196NP, these locations can reside either in external memory or in internal ROM.

Table B-3. Signal Descriptions (Continued)
RPD I Return from Powerdown
Timing pin for the return-from-powerdown circuit.
If your application uses powerdown mode, connect a capacitor† between RPD and VSS if either of the following conditions are true.
The capacitor causes a delay that enables the oscillator and PLL circuitry to stabilize before the internal CPU and peripheral clocks are enabled.
The capacitor is not required if your application uses powerdown mode and if both of the following conditions are true.
If your application does not use powerdown mode, leave this pin unconnected.
† Calculate the value of the capacitor using the formula found on page 12-11.
RXD I/O Receive Serial Data
In modes 1, 2, and 3, RXD receives serial port input data. In mode 0, it functions as either an input or an open-drain output for data.
RXD is multiplexed with P2.1.
T1CLK I Timer 1 External Clock
External clock for timer 1. Timer 1 increments (or decrements) on both rising and falling edges of T1CLK. Also used in conjunction with T1DIR for quadrature counting mode.
External clock for the serial I/O baud-rate generator input (program selectable).
T1CLK is multiplexed with P1.4.
T2CLK I Timer 2 External Clock
External clock for timer 2. Timer 2 increments (or decrements) on both rising and falling edges of T2CLK. Also used in conjunction with T2DIR for quadrature counting mode.
T2CLK is multiplexed with P1.6.
T1DIR I Timer 1 External Direction
External direction (up/down) for timer 1. Timer 1 increments when T1DIR is high and decrements when it is low. Also used in conjunction with T1CLK for quadrature counting mode.
T1DIR is multiplexed with P1.5.
T2DIR I Timer 2 External Direction
External direction (up/down) for timer 2. Timer 2 increments when T2DIR is high and decrements when it is low. Also used in conjunction with T2CLK for quadrature counting mode.
T2DIR is multiplexed with P1.7.
TXD O Transmit Serial Data
In serial I/O modes 1, 2, and 3, TXD transmits serial port output data. In mode 0, it is the serial clock output.
TXD is multiplexed with P2.0.
Name Type Description · and

VCC PWR Digital Supply Voltage
Connect each VCC pin to the digital supply voltage.
VSS GND Digital Circuit Ground
Connect each VSS pin to ground through the lowest possible impedance path.
WR# O Write†
This active-low output indicates that an external write is occurring. This signal is asserted only during external memory writes.
WR# is multiplexed with WRL#.
† The chip configuration register 0 (CCR0) determines whether this pin functions as WR# or WRL#. CCR0.2 = 1 selects WR#; CCR0.2 = 0 selects WRL#.
WRH# O Write High†
During 16-bit bus cycles, this active-low output signal is asserted for high-byte writes and word writes to external memory. During 8-bit bus cycles, WRH# is asserted for all write operations.
WRH# is multiplexed with BHE#.
† The chip configuration register 0 (CCR0) determines whether this pin functions as BHE# or WRH#. CCR0.2 = 1 selects BHE#; CCR0.2 = 0 selects WRH#.
WRL# O Write Low†
During 16-bit bus cycles, this active-low output signal is asserted for low-byte writes and word writes. During 8-bit bus cycles, WRL# is asserted for all write operations.
WRL# is multiplexed with WR#.
† The chip configuration register 0 (CCR0) determines whether this pin functions as WR# or WRL#. CCR0.2 = 1 selects WR#; CCR0.2 = 0 selects WRL#.
XTAL1 I Input Crystal/Resonator or External Clock Input
Input to the on-chip oscillator, internal phase-locked loop circuitry (80C196NU), and the internal clock generators. The internal clock generators provide the peripheral clocks, CPU clock, and CLKOUT signal. When using an external clock source instead of the on-chip oscillator, connect the clock input to XTAL1. The external clock signal must meet the VIH specification for XTAL1 (see datasheet).
XTAL2 O Inverted Output for the Crystal/Resonator
Output of the on-chip oscillator inverter. Leave XTAL2 floating when the design uses a external clock source instead of the on-chip oscillator.
Name Type Description

B.3 DEFAULT CONDITIONS
Table B-5 lists the default functions of the I/O and control pins of the 8XC196NP and 80C196NU with their values during various operating conditions. Table B-4 defines the symbols used to rep- resent the pin status. Refer to the DC Characteristics table in the datasheet for actual specifica- tions for VOL, VIL, VOH, and VIH.
Symbol Definition Symbol Definition
0 Voltage less than or equal to VOL, VIL MD0 Medium pull-down
1 Voltage greater than or equal to VOH, VIH MD1 Medium pull-up
HiZ High impedance WK0 Weak pull-down
LoZ0 Low impedance; strongly driven low WK1 Weak pull-up
LoZ1 Low impedance; strongly driven high ODIO Open-drain I/O
and Standby (NU only)
P1.3:0 EPA3:0 WK1 WK1 (Note 1) (Note 1) (Note 1) —
P1.4 T1CLK WK1 WK1 (Note 1) (Note 1) (Note 1) —
P1.5 T1DIR WK1 WK1 (Note 1) (Note 1) (Note 1) —
P1.6 T2CLK WK1 WK1 (Note 1) (Note 1) (Note 1) —
P1.7 T2DIR WK1 WK1 (Note 1) (Note 1) (Note 1) —
P2.0 TXD WK1 WK1 (Note 1) (Note 1) (Note 1) —
P2.1 RXD WK1 WK1 (Note 1) (Note 1) (Note 1) —
P2.2 EXTINT0 WK1 WK1 (Note 1) (Note 1) (Note 1) —
P2.3 BREQ# WK1 WK1 (Note 1) (Note 1) (Note 1) —
P2.4 EXTINT1 WK1 WK1 (Note 1) (Note 1) (Note 1) —
P2.5 HOLD# WK1 WK1 (Note 1) (Note 1) Force 0 —
P2.6 HLDA# WK1 WK1 (Note 1) (Note 1) 0 —
CLKOUT
(Note 1) (Note 2) (Note 1) —
P3.0 CS0# WK1 1 (NP only) 0 (NU only) (Note 3) (Note 3) (Note 4) —
P3.5:1 CS5:1# WK1 WK1 (Note 3) (Note 3) (Note 4) —
P3.6 EXTINT2 WK1 WK1 (Note 1) (Note 1) (Note 1) —
P3.7 EXTINT3 WK1 WK1 (Note 1) (Note 1) (Note 1) —
P4.2:0 PWM2:0 WK1 WK1 (Note 1) (Note 1) (Note 1) —

and Standby (NU only)
P4.3 — WK1 WK1 (Note 1) (Note 1) (Note 1) —
EPORT.3:0 A19:16 WK1 1 (Note 5) (Note 5) (Note 6) (Note 8)
— A15:0 WK1 LoZ0 (Note 7) (Note 7) HiZ LoZ0
— AD15:0 WK1 LoZ0 (Note 7) (Note 7) HiZ LoZ0
— ALE WK0 0 (Note 9) (Note 9) WK0 LoZ0
— BHE# WK1 1 (Note 10) (Note 10) WK1 LoZ1
— EA# (NP only)
HiZ —
— INST WK0 0 (Note 9) (Note 9) WK0 LoZ0
— ONCE MD0 MD0 MD0 MD0 MD0 —
— PLLEN1 (NU only)
HiZ —
— PLLEN2 (NU only)
— RD# WK1 1 (Note 10) (Note 10) WK1 LoZ1
— RESET# 0 WK1 WK1 WK1 WK1 —
— RPD LoZ1 —
— WR# WK1 1 (Note 10) (Note 10) WK1 LoZ1
XTAL1 — Osc input,
XTAL2 — Osc output,
HiZ Osc output, LoZ0/1
NOTE: 1. If Px_MODE.y = 0, then port is as programmed. If Px_MODE.y = 1, then as specified by the associ- ated peripheral. 2. If P2_MODE.7 = 0, then port is as programmed. If P2_MODE.7 = 1, then 1. 3. Used as chip select: If HLDA# = 0, then WK1. If HLDA# = 1, then LoZ1. Used as port: then port is as programmed. 4. Used as chip select: WK1. Used as port: then port is as programmed. 5. When used as extended address: If HLDA# = 1, then 0. If HLDA# = 0, then HiZ When used as EPORT, then port value. 6. When used as extended address, then HiZ. When used as EPORT, then port value. 7. If HLDA# = 1, then LoZ0. If HLDA# = 0, then HiZ. 8. When used as extended address: then previous address. When used as EPORT: then port value. 9. If HLDA# = 1, then LoZ0. If HLDA# = 0, then WK0. 10. If HLDA# = 1, then LoZ1. If HLDA# = 0, then WK1. 11. The values in this column are valid until user code configures the specific signal (i.e., until Px_MODE is written).




REGISTERS
This appendix provides reference information about the device registers. Table C-1 lists the mod- ules and major components of the device with their related configuration and status registers. Ta- ble C-2 lists the registers, arranged alphabetically by mnemonic, along with their names, addresses, and reset values. Following the tables, individual descriptions of the registers are ar- ranged alphabetically by mnemonic.
Chip Configuration Chip-select Units
CPU (x = 0, 2)
EPA (x = 0–3)
CCR0 ADDRCOMx ACC_0x (80C196NU) EPA_MASK
CCR1 ADDRMSKx ACC_STAT (80C196NU) EPA_PEND
ZERO_REG
Extended Port I/O Ports
(x = 1–4) Interrupts Memory Control
EP_DIR Px_DIR INT_MASK WSR
EP_MODE Px_MODE INT_MASK1 WSR1 (80C196NU)
PWM (x = 0–2) PTS Serial Port Timers (x = 1–2)
CON_REG0 PTSSEL SBUF_RX TIMERx
PWMx_CONTROL PTSSRV SBUF_TX TxCONTROL
SP_CON
SP_STATUS

Register Mnemonic Register Name Hex Address
ACC_00 (NU) Accumulator 0 000CH 0000
ACC_02 (NU) Accumulator 2 000EH 0000
ACC_STAT (NU) Accumulator Control and Status 000BH 0000 0000
ADDRCOM0 Address Compare 0 1F40H 0000 1111 0010 0000
ADDRCOM1 Address Compare 1 1F48H XXXX 0000 0000 0000
ADDRCOM2 Address Compare 2 1F50H XXXX 0000 0000 0000
ADDRCOM3 Address Compare 3 1F58H XXXX 0000 0000 0000
ADDRCOM4 Address Compare 4 1F60H XXXX 0000 0000 0000
ADDRCOM5 Address Compare 5 1F68H XXXX 0000 0000 0000
ADDRMSK0 Address Mask 0 1F42H XXXX 1111 1111 1111
ADDRMSK1 Address Mask 1 1F4AH XXXX 1111 1111 1111
ADDRMSK2 Address Mask 2 1F52H XXXX 1111 1111 1111
ADDRMSK3 Address Mask 3 1F5AH XXXX 1111 1111 1111
ADDRMSK4 Address Mask 4 1F62H XXXX 1111 1111 1111
ADDRMSK5 Address Mask 5 1F6AH XXXX 1111 1111 1111
BUSCON0 Bus Control 0 1F44H 0000 0011
BUSCON1 Bus Control 1 1F4CH 0000 0000
BUSCON2 Bus Control 2 1F54H 0000 0000
BUSCON3 Bus Control 3 1F5CH 0000 0000
BUSCON4 Bus Control 4 1F64H 0000 0000
BUSCON5 Bus Control 5 1F6CH 0000 0000
CCR0 Chip Configuration 0 FF2018H XXXX XXXX
CCR1 Chip Configuration 1 FF201AH XXXX XXXX
CON_REG0 PWM Clock Prescaler Control 0 1FB6H 1111 1110
EP_DIR Extended Port I/O Direction 1FE3H 1111 1111
EP_MODE Extended Port Mode 1FE1H 1111 1111
EP_PIN Extended Port Pin Input 1FE7H XXXX XXXX
EP_REG Extended Port Data Output 1FE5H XXXX 0000
EPA_MASK EPA Mask 1F9CH 1010 1010
EPA_PEND EPA Pending 1F9EH 1010 1010
EPA0_CON EPA Capture/Comp 0 Control 1F80H 0000 0000
EPA1_CON EPA Capture/Comp 1 Control 1F84H 0000
Binary Reset Value · High Low

Table C-2. Register Name, Address, and Reset Status (Continued)
Register Mnemonic Register Name Hex Address
EPA2_CON EPA Capture/Comp 2 Control 1F88H 0000 0000
EPA3_CON EPA Capture/Comp 3 Control 1F8CH 0000
EPA0_TIME EPA Capture/Comp 0 Time 1F82H 0000
EPA1_TIME EPA Capture/Comp 1 Time 1F86H 0000
EPA2_TIME EPA Capture/Comp 2 Time 1F8AH 0000
EPA3_TIME EPA Capture/Comp 3 Time 1F8EH 0000
INT_MASK Interrupt Mask 0008H 0000 0000
INT_MASK1 Interrupt Mask 1 0013H 0000 0000
INT_PEND Interrupt Pending 0009H 0000 0000
INT_PEND1 Interrupt Pending 1 0012H 0000 0000
ONES_REG Ones Register 0002H 1111
P1_DIR Port 1 I/O Direction 1FD2H 1111 1111
P1_MODE Port 1 Mode 1FD0H 0000 0000
P1_PIN Port 1 Pin Input 1FD6H XXXX XXXX
P1_REG Port 1 Data Output 1FD4H 1111 1111
P2_DIR Port 2 I/O Direction 1FD3H 1111 1111
P2_MODE Port 2 Mode 1FD1H 1000 0000
P2_PIN Port 2 Pin Input 1FD7H XXXX XXXX
P2_REG Port 2 Data Output 1FD5H 1111 1111
P3_DIR Port 3 I/O Direction 1FDAH 1111 1111
P3_MODE Port 3 Mode 1FD8H 0000 0001
P3_PIN Port 3 Pin Input 1FDEH XXXX XXXX
P3_REG Port 3 Data Output 1FDCH 1111 1111
P4_DIR Port 4 I/O Direction 1FDBH 1111 1111
P4_MODE Port 4 Mode 1FD9H 0000 0000
P4_PIN Port 4 Pin Input 1FDFH XXXX XXXX
P4_REG Port 4 Data Output 1FDDH 1111 1111
PSW Program Status Word
PTSSEL PTS Select 0004H 0000
PTSSRV PTS Service 0006H 0000
PWM0_CONTROL PWM 0 Control 1FB0H 0000 0000
PWM1_CONTROL PWM 1 Control 1FB2H 0000 0000
PWM2_CONTROL PWM 2 Control 1FB4H 0000 0000
SBUF_RX Serial Port Receive Buffer 1FB8H 0000 0000
Binary Reset Value · High Low

Register Mnemonic Register Name Hex Address
SBUF_TX Serial Port Transmit Buffer 1FBAH 0000 0000
SP Stack Pointer 0018H XXXX
SP_BAUD Serial Port Baud Rate 1FBCH 0000
SP_CON Serial Port Control 1FBBH 0000 0000
SP_STATUS Serial Port Status 1FB9H 0000 1011
T1CONTROL Timer 1 Control 1F90H 0000 0000
T2CONTROL Timer 2 Control 1F94H 0000 0000
TIMER1 Timer 1 Value 1F92H 0000
TIMER2 Timer 2 Value 1F96H 0000
WSR Window Selection 0014H 0000 0000
WSR1 (NU) Window Selection 1 0015H 0000 0000
ZERO_REG Zero Register 0000H 0000
Binary Reset Value · High Low

ACC_0x
ACC_0x x = 0, 2 (80C196NU)
The 32-bit accumulator register (ACC_0x) resides at locations 0C–0FH. You can read from or write to the accumulator register as two words at locations 0CH and 0EH.
Accumulator Value (word 1, high byte)
ACC_02 Accumulator Value (word 1, low byte)
Accumulator Value (word 0, high byte)
ACC_00 Accumulator Value (word 0, low byte)
15:0 Accumulator Value
You can read this register to determine the current value of the accumulator. You can write to this register to clear or preload a value into the accumulator.
Register Address Reset Value
ACC_02 000EH 00H
Table C-3 · Bit Number Function

ACC_STAT (80C196NU)
The accumulator control and status (ACC_STAT) register enables and disables fractional and saturation modes and contains three status flags that indicate the status of the accumulator’s contents.
80C196NU FME SME — — — STOVF OVF STSAT
7 FME Fractional Mode Enable
Set this bit to enable fractional mode. (See Table C-4.) In this mode, the result of a signed multiplication instruction is shifted left by one bit before it is added to the contents of the accumulator.
For unsigned multiplication, this bit is ignored.
6 SME Saturation Mode Enable
Set this bit to enable saturation mode. (See Table C-4.) In this mode, the result of a signed multiplication operation is not allowed to overflow or underflow.
For unsigned multiplication, this bit is ignored.
5:3 — Reserved; for compatibility with future devices, write zeros to these bits.
2 STOVF Sticky Overflow Flag
For unsigned multiplication, this bit is set if a carry out of bit 31 occurs.
Unless saturation mode is enabled, this bit is set for signed multiplication to indicate that the sign bit of the accumulator and the sign bit of the addend are equal, but the sign bit of the result is the opposite. (See Table C-4.)
Software can clear this flag; hardware does not clear it.
1 OVF Overflow Flag
This bit indicates that an overflow occurred during the preceding accumu- lation. (See Table C-4.)
This flag is dynamic; it can change after each accumulation.
0 STSAT Sticky Saturation Flag
This bit indicates that a saturation has occurred during accumulation with saturation mode enabled. (See Table C-4.)
Software can clear this flag; hardware does not clear it.
Bit Number · Bit Mnemonic Function

ACC_STAT
Table C-4. Effect of SME and FME Bit Combinations
0 0 Sets the OVF and STOVF flags if the sign bits of the accumulator and the addend (the number to be added to the contents of the accumulator) are equal, but the sign bit of the result is the opposite.
0 1 Shifts the addend (the number to be added to the contents of the accumulator) left by one bit before adding it to the accumulator. Sets the OVF and STOVF flags if the sign bits of the accumulator and the addend are equal, but the sign bit of the result is the opposite.
1 0 Accumulates a signed integer value up or down to saturation and sets the STSAT flag. Positive saturation changes the accumulator value to 7FFFFFFFH; negative saturation changes the accumulator value to 80000000H. Accumulation proceeds normally after saturation, which means that the accumulator value can increase from a negative saturation or decrease from a positive saturation.
1 1 Shifts the addend (the number to be added to the contents of the accumulator) left by one bit before adding it to the accumulator. Accumulates a signed integer value up or down to saturation and sets the STSAT flag. Positive saturation changes the accumulator value to 7FFFFFFFH; negative saturation changes the accumulator value to 80000000H. Accumu- lation proceeds normally after saturation, which means that the accumulator value can increase from a negative saturation or decrease from a positive saturation.
SME FME Description

ADDRCOMx x = 0–5
The address compare (ADDRCOMx) register specifies the base (lowest) address of the address range. The base address of a 2n-byte address range must be on a 2n-byte boundary.
BASE15 BASE14 BASE13 BASE12 BASE11 BASE10 BASE9 BASE8
15:12 — Reserved; for compatibility with future devices, write zeros to these bits.
11:0 BASE19:8 Base Address Bits
These bits are the 12 most-significant bits of the base address of the address range assigned to chip-select x.
Register Address Reset Value
ADDRCOM1 1F48H X000H
ADDRCOM2 1F50H X000H
ADDRCOM3 1F58H X000H
ADDRCOM4 1F60H X000H
ADDRCOM5 1F68H X000H
Table C-5 · Bit Number · Bit Mnemonic Function

ADDRMSKx
ADDRMSKx x = 0–5
The address mask (ADDRMSKx) register, together with the address compare register, defines the address range that is assigned to the chip-select x output, CSx#. The address mask register determines the size of the address range, which must be 2n bytes, where n = 8, 9, . . , 20. For a 2n- byte address range, calculate n1 = 20 – n, and set the n1 most-significant bits of MASK19:8 in the address mask register.
MASK15 MASK14 MASK13 MASK12 MASK11 MASK10 MASK9 MASK8
15:12 — Reserved; for compatibility with future devices, write zeros to these bits.
11:0 MASK19:8 Address Mask Bits
For a 2n-byte address range, set the n1 most-significant bits of MASK19:8, where n1 = 20 – n.
Register Address Reset Value
ADDRMSK1 1F4AH XFFFH
ADDRMSK2 1F52H XFFFH
ADDRMSK3 1F5AH XFFFH
ADDRMSK4 1F62H XFFFH
ADDRMSK5 1F6AH XFFFH
Table C-6 · Bit Number · Bit Mnemonic Function

BUSCONx x = 0–5
For the address range assigned to chip-select x, the bus control (BUSCONx) register specifies the number of wait states, the bus width, and the address/data multiplexing for all external bus cycles that access address range x.
7 DEMUX Address/Data Multiplexing
This bit specifies the address/data multiplexing on AD15:0 for all external accesses to the address range assigned to chip-select output x.
0 = multiplexed 1 = demultiplexed
6 BW16 Bus Width
This bit specifies the bus width for all external accesses to the address range assigned to chip-select output x.
0 = 8 bits 1 = 16 bits
5:2 — Reserved; for compatibility with future devices, write zeros to these bits.
1:0 WS1:0 Wait States
These bits specify the number of wait states for all external accesses to the address range assigned to chip-select output x.
WS1 WS0 Wait States
0 1 1 1 0 2 1 1 3
Register Address Reset Value
BUSCON1 1F4CH 00H
BUSCON2 1F54H 00H
BUSCON3 1F5CH 00H
BUSCON4 1F64H 00H
BUSCON5 1F6CH 00H
Table C-7 · Bit Number · Bit Mnemonic Function

CCR0
CCR0 no direct access†
The chip configuration 0 (CCR0) register enables or disables powerdown and standby (80C196NU only) modes and selects the write-control mode. It also contains the bus-control parameters for fetching chip configuration byte 1.
7:6 1 To guarantee device operation, write ones to these bits.
5:4 WS1:0 Wait States
These two bits control the number of wait states that are used for an external fetch of CCB1.
0 0 zero wait states 0 1 one wait state 1 0 two wait states 1 1 three wait states
3 DEMUX Select Demultiplexed Bus
Selects the demultiplexed bus mode for an external fetch of CCB1:
0 = multiplexed — address and data are multiplexed on AD15:0. 1 = demultiplexed — data only on AD15:0.
2 BHE# Write-control Mode
Selects the write-control mode, which determines the functions of the BHE#/WRH# and WR#/WRL# pins for external bus cycles:
0 = write strobe mode: the BHE#/WRH# pin operates as WRH#, and the WR#/WRL# pin operates as WRL#. 1 = standard write-control mode: the BHE#/WRH# pin operates as BHE#, and the WR#/WRL# pin operates as WR#.
1 BW16 Buswidth Control
Selects the bus width for an external fetch of CCB1:
0 = 8-bit bus 1 = 16-bit bus
0 PD Powerdown Enable
Enables or disables the IDLPD #2 and IDLPD #3 instructions. When enabled, the IDLPD #2 instruction causes the microcontroller to enter powerdown mode and for the 80C196NU only, the IDLPD #3 instruction causes the microcontroller to enter standby mode.
0 = disable powerdown and standby modes 1 = enable powerdown and standby modes
If your design uses powerdown or standby mode, set this bit when you program the CCBs. If it does not, clearing this bit when you program the CCBs will prevent accidental entry into powerdown and standby mode†. (Chapter 12, “Special Operating Modes,” discusses powerdown and standby modes.)
† The CCRs are loaded with the contents of the chip configuration bytes (CCBs) after a device reset.
The CCBs reside in nonvolatile memory at addresses FF2018H (CCB0) and FF201AH (CCB1).
Bit Number · Bit Mnemonic Function

CCR1 no direct access†
The chip configuration 1 (CCR1) register selects the 16-bit or 24-bit addressing mode and (for the 8XC196NP only) controls whether the internal ROM is mapped into two address ranges, FF2000– FF2FFFH and 002000–002FFFH, or into FF2000–FF2FFFH only.
8XC196NP 1 1 0 1 1 REMAP MODE64 —
80C196NU 1 1 DM 1 1 — MODE64 —
7:6 1 To guarantee device operation, write ones to these bits.
5†† DM Deferred Mode
Enables the deferred bus-cycle mode. If the 80C196NU is using a demulti- plexed bus and deferred mode is enabled, a delay of 2t occurs in the first bus cycle following a chip-select output change and the first write cycle following a read cycle. (See “Deferred Bus-cycle Mode (80C196NU Only)” on page 13-40.)
0 = deferred bus-cycle mode disabled 1 = deferred bus-cycle mode enabled
4:3 1 To guarantee device operation, write ones to these bits.
2†† REMAP Internal ROM Mapping
Controls the internal ROM mapping.
0 = ROM maps to FF2000–FF2FFFH only 1 = ROM maps to FF2000–FF2FFFH and 002000–002FFFH
1 MODE64 Addressing Mode
Selects 64-Kbyte or 1-Mbyte addressing.
0 = selects 1-Mbyte addressing 1 = selects 64-Kbyte addressing
0 — Reserved; for compatibility with future devices, write zero to this bit.
† The CCRs are loaded with the contents of the chip configuration bytes (CCBs) after a device reset. The CCBs reside in nonvolatile memory at addresses FF2018H (CCB0) and FF201AH (CCB1).
†† Bit 5 is reserved on the 8XC196NP device and bit 2 is reserved on the 80C196NU device. For
compatibility with future devices, write zeros to these bits.
Bit Number · Bit Mnemonic Function

CON_REG0
The control (CON_REG0) register controls the clock prescaler for the three pulse-width modulators (PWM0–PWM2).
8XC196NP — CLK0†
80C196NU — CLK1 CLK0
7:1 (NP) 7:2 (NU) — Reserved; for compatibility with future devices, write zeros to these bits.
0 (NP) CLK0 Enable PWM Clock Prescaler
This bit controls the PWM output period by enabling or disabling the clock prescaler (divide-by-two) on the three pulse-width modulators (PWM0– PWM2).
0 = disable; PWM output period is 512 state times 1 = enable; PWM output period is 1024 state times
1:0 (NU) CLK1:0 Enable PWM Clock Prescaler
These bits control the PWM output period on the three pulse-width modulators (PWM0–PWM2).
0 0 disable clock prescaler 0 1 enable divide-by-two prescaler; PWM output period is 1024 state times 1 X enable divide-by-four prescaler; PWM output period is 2048 state times
† This bit was called SLOW_PWM in earlier documentation for the 8XC196NP.
Bit Number · Bit Mnemonic Function

In I/O mode, each bit of the extended port I/O direction (EP_DIR) register controls the direction of the corresponding pin. Clearing a bit configures a pin as a complementary output; setting a bit configures a pin as either an input or an open-drain output. (Open-drain outputs require external pull-ups).
Any pin that is configured for its extended-address function is forced to the complementary output mode except during reset, hold, idle, powerdown, and standby. (Standby mode is available only on the 80C196NU.)
7:4 — Reserved; always write as ones.
3:0 PIN3:0 Extended Address Port Pin x Direction
This bit configures EPORT.x as a complementary output or an input/open-drain output.
0 = complementary output 1 = input or an open-drain output
Bit Number · Bit Mnemonic Function

EP_MODE
Each bit of the extended port mode (EP_MODE) register controls whether the corresponding pin functions as a standard I/O port pin or as an extended-address signal. Setting a bit configures a pin as an extended-address signal; clearing a bit configures a pin as a standard I/O port pin.
7:4 — Reserved; always write as zeros.
3:0 PIN3:0 Extended Address Port Pin x Mode
This bit determines the mode of EPORT.x:
0 = standard I/O port pin 1 = extended-address signal
Bit Number · Bit Mnemonic Function

Each bit of the extended port input (EP_PIN) register reflects the current state of the corresponding pin, regardless of the pin configuration.
7:4 — Reserved; always write as zeros.
3:0 PIN3:0 Extended Address Port Pin x Input
This bit contains the current state of EPORT.x.
Bit Number · Bit Mnemonic Function

EP_REG
Each bit of the extended port data output (EP_REG) register contains data to be driven out by the corresponding pin. When a pin is configured as standard I/O (EP_MODE.x = 0), the result of a CPU write to EP_REG is immediately visible on the pin.
During nonextended data accesses, EP_REG contains the value of the memory page that is to be accessed. For compatibility with software tools, clear the EP_REG bit for any EPORT pin that is configured as an extended-address signal (EP_MODE.x set).
80C196NU Only: For nonextended data accesses, the 80C196NU forces the page address to 00H. You cannot change pages by modifying EP_REG.
7:4 — Reserved; always write as zeros.
3:0 PIN3:0 Extended Address Port Pin x Output
If EPORT.x is to be used as an output, write the data that it is to drive out.
If EPORT.x is to be used as an input, set this bit.
For the 8XC196NP, if EPORT.x is to be used as an address line, write the correct value for the memory page to be accessed by nonextended instructions.
The 80C196NU forces the page address to 00H. You cannot change pages by modifying EP_REG
Bit Number · Bit Mnemonic Function

The EPA interrupt mask (EPA_MASK) register enables or disables (masks) the multiplexed EPA3:0 overrun interrupts (OVR3:0).
7, 5, 3, 1 — Reserved; for compatibility with future devices, write zeros to these bits.
Setting this bit enables the corresponding source as a shared overrun interrupt source. The shared overrun interrupts (OVR0_1 and OVR2_3) are enabled by setting their interrupt enable bits in the interrupt mask 1 (INT_MASK1) register.
Bit Number · Bit Mnemonic Function

EPA_PEND
When hardware detects a pending EPA3:0 overrun interrupt (OVR3:0), it sets the corresponding bit in the EPA interrupt pending (EPA_PEND) register. OVR0 and OVR1 are multiplexed to share one bit (OVR0_1) in the INT_PEND1 register. Similarly, OVR2 and OVR3 are multiplexed to share another bit (OVR2_3) in the INT_PEND1 register.
7, 5, 3, 1 Reserved. These bits are undefined.
6, 4, 2, 0 Any set bit indicates that the corresponding overrun interrupt source is pending.
Bit Number Function

EPAx_CON x = 0–3
The EPA control (EPAx_CON) registers control the functions of their assigned capture/compare channels. The registers for EPA0 andEPA2 are identical. The registers for EPA1 and EPA3 have an additional bit, the remap bit. This added bit (bit 8) requires an additional byte, so EPA1_CON and EPA3_CON must be addressed as words, while the others can be addressed as bytes.
x = 1, 3 — RM
x = 0, 2 TB CE M1 M0 RE — ROT ON/RT
15:9† — Reserved; always write as zeros.
8† RM Remap Feature
The remap feature applies to the compare mode of the EPA1 and EPA3 only.
When the remap feature of EPA1 is enabled, EPA capture/compare channel 0 shares output pin EPA1 with EPA capture/compare channel 1. When the remap feature of EPA3 is enabled, EPA capture/compare channel 2 shares output pin EPA3 with EPA capture/compare channel 3.
0 = remap feature disabled 1 = remap feature enabled
7 TB Time Base Select
Specifies the reference timer.
0 = timer 1 is the reference timer and timer 2 is the opposite timer 1 = timer 2 is the reference timer and timer 1 is the opposite timer
A compare event (clearing, setting, or toggling an output pin; and/or resetting either timer) occurs when the reference timer matches the time programmed in the event-time register.
When a capture event (falling edge, rising edge, or an edge change on the EPAx pin) occurs, the reference timer value is saved in the EPA event- time register (EPAx_TIME).
6 CE Compare Enable
Determines whether the EPA channel operates in capture or compare mode.
0 = capture mode 1 = compare mode
† These bits apply to the EPA1_CON and EPA3_CON registers only.
Table C-8 · Bit Number · Bit Mnemonic Function

EPAx_CON
EPAx_CON (Continued) x = 0–3
The EPA control (EPAx_CON) registers control the functions of their assigned capture/compare channels. The registers for EPA0 andEPA2 are identical. The registers for EPA1 and EPA3 have an additional bit, the remap bit. This added bit (bit 8) requires an additional byte, so EPA1_CON and EPA3_CON must be addressed as words, while the others can be addressed as bytes.
x = 1, 3 — RM
x = 0, 2 TB CE M1 M0 RE — ROT ON/RT
5:4 M1:0 EPA Mode Select
In capture mode, specifies the type of event that triggers an input capture. In compare mode, specifies the action that the EPA executes when the reference timer matches the event time.
M1 M0 Capture Mode Event
0 0 no capture 0 1 capture on falling edge 1 0 capture on rising edge 1 1 capture on either edge
M1 M0 Compare Mode Action
0 0 no output 0 1 clear output pin 1 0 set output pin 1 1 toggle output pin
Re-enable applies to the compare mode only. It allows a compare event to continue to execute each time the event-time register (EPAx_TIME) matches the reference timer rather than only upon the first time match.
0 = compare function is disabled after a single event 1 = compare function always enabled
2 — Reserved; always write as zero.
† These bits apply to the EPA1_CON and EPA3_CON registers only.

EPAx_CON (Continued) x = 0–3
The EPA control (EPAx_CON) registers control the functions of their assigned capture/compare channels. The registers for EPA0 andEPA2 are identical. The registers for EPA1 and EPA3 have an additional bit, the remap bit. This added bit (bit 8) requires an additional byte, so EPA1_CON and EPA3_CON must be addressed as words, while the others can be addressed as bytes.
x = 1, 3 — RM
x = 0, 2 TB CE M1 M0 RE — ROT ON/RT
1 ROT Reset Opposite Timer
Controls different functions for capture and compare modes.
In Capture Mode:
0 = causes no action 1 = resets the opposite timer
In Compare Mode:
Selects the timer that is to be reset if the RT bit is set.
0 = selects the reference timer for possible reset 1 = selects the opposite timer for possible reset
The TB bit (bit 7) selects which is the reference timer and which is the opposite timer.
0 ON/RT Overwrite New/Reset Timer
The ON/RT bit functions as overwrite new in capture mode and reset timer in compare mode.
In Capture Mode (ON):
An overrun error is generated when an input capture occurs while the event-time register (EPAx_TIME) and its buffer are both full. When an overrun occurs, the ON bit determines whether old data is overwritten or new data is ignored:
0 = ignores new data 1 = overwrites old data in the buffer
In Compare Mode (RT):
0 = disables the reset function 1 = resets the ROT-selected timer
† These bits apply to the EPA1_CON and EPA3_CON registers only.
Table C-8 · Bit Number · Bit Mnemonic Function

EPAx_CON
Table C-8. EPAx_CON Addresses and Reset Values
Register Address Reset Value
EPA1_CON 1F84H 0000H
EPA2_CON 1F88H 00H
EPA3_CON 1F8CH 0000H

EPAx_TIME x = 0–3
The EPA time (EPAx_TIME) registers are the event-time registers for the EPA channels. In capture mode, the value of the reference timer is captured in EPAx_TIME when an input transition occurs. Each event-time register is buffered, allowing the storage of two capture events at once. In compare mode, the EPA triggers a compare event when the reference timer matches the value in EPAx_TIME. EPAx_TIME is not buffered for compare mode.
EPA Timer Value (high byte)
EPA Timer Value (low byte)
15:0 EPA Time Value
When an EPA channel is configured for capture mode, this register contains the value of the reference timer when the specified event occurred.
When an EPA channel is configured for compare mode, write the compare event time to this register.
Register Address Reset Value
EPA1_TIME 1F86H 0000H
EPA2_TIME 1F8AH 0000H
EPA3_TIME 1F8EH 0000H
Table C-9 · Bit Number Function

INT_MASK
The interrupt mask (INT_MASK) register enables or disables (masks) individual interrupt requests. (The EI and DI instructions enable and disable servicing of all maskable interrupts.) INT_MASK is the low byte of the processor status word (PSW); therefore, PUSHF or PUSHA saves this register on the stack and POPF or POPA restores it.
7:3 1:0 Setting a bit enables the corresponding interrupt.
The standard interrupt vector locations are as follows:
Bit Mnemonic Interrupt Standard Vector EPA0 EPA Capture/Compare Channel 0 FF200EH RI SIO Receive FF200CH TI SIO Transmit FF200AH EXTINT1 EXTINT1 pin FF2008H EXTINT0 EXTINT0 pin FF2006H OVRTM2 Timer 2 Overflow/Underflow FF2002H OVRTM1 Timer 1 Overflow/Underflow FF2000H
2 Reserved; for compatibility with future devices, write zero to this bit.
Bit Number Function

The interrupt mask 1 (INT_MASK1) register enables or disables (masks) individual interrupt requests. (The EI and DI instructions enable and disable servicing of all maskable interrupts.) INT_MASK1 can be read from or written to as a byte register. PUSHA saves this register on the stack and POPA restores it.
7:0 Setting a bit enables the corresponding interrupt.
The standard interrupt vector locations are as follows:
Bit Mnemonic Interrupt Standard Vector NMI Nonmaskable Interrupt FF203EH EXTINT3 EXTINT3 pin FF203CH EXTINT2 EXTINT2 pin FF203AH OVR2_3† EPA Capture Channel 2 or 3 Overrun FF2038H OVR0_1† EPA Capture Channel 0 or 1 Overrun FF2036H EPA3 EPA Capture/Compare Channel 3 FF2034H EPA2 EPA Capture/Compare Channel 2 FF2032H EPA1 EPA Capture/Compare Channel 1 FF2030H
† An overrun on the EPA capture/compare channels can generate the multiplexed capture overrun interrupts. The EPA_MASK and EPA_PEND registers decode these multiplexed interrupts. Write to EPA_MASK to enable the interrupt sources; read EPA_PEND to determine which source caused the interrupt.
Bit Number Function

INT_PEND
When hardware detects a pending interrupt, it sets the corresponding bit in the interrupt pending (INT_PEND or INT_PEND1) registers. When the vector is taken, the hardware clears the pending bit. Software can generate an interrupt by setting the corresponding interrupt pending bit.
7:3 1:0 Any set bit indicates that the corresponding interrupt is pending. The interrupt bit is cleared when processing transfers to the corresponding interrupt vector.
The standard interrupt vector locations are as follows:
Bit Mnemonic Interrupt Standard Vector EPA0 EPA Capture/Compare Channel 0 FF200EH RI SIO Receive FF200CH TI SIO Transmit FF200AH EXTINT1 EXTINT1 pin FF2008H EXTINT0 EXTINT0 pin FF2006H OVRTM2 Timer 2 Overflow/Underflow FF2002H OVRTM1 Timer 1 Overflow/Underflow FF2000H
2 Reserved. This bit is undefined.
Bit Number Function

When hardware detects a pending interrupt, it sets the corresponding bit in the interrupt pending (INT_PEND or INT_PEND1) registers. When the vector is taken, the hardware clears the pending bit. Software can generate an interrupt by setting the corresponding interrupt pending bit.
7:0 Any set bit indicates that the corresponding interrupt is pending. The interrupt bit is cleared when processing transfers to the corresponding interrupt vector.
The standard interrupt vector locations are as follows:
Bit Mnemonic Interrupt Standard Vector NMI Nonmaskable Interrupt FF203EH EXTINT3 EXTINT3 pin FF203CH EXTINT2 EXTINT2 pin FF203AH OVR2_3† EPA Capture Channel 2 or 3 Overrun FF2038H OVR0_1† EPA Capture Channel 0 or 1 Overrun FF2036H EPA3 EPA Capture/Compare Channel 3 FF2034H EPA2 EPA Capture/Compare Channel 2 FF2032H EPA1 EPA Capture/Compare Channel 1 FF2030H
† An overrun on the EPA capture/compare channels can generate the multiplexed capture overrun interrupts. The EPA_MASK and EPA_PEND registers decode these multiplexed interrupts. Write to EPA_MASK to enable the interrupt sources; read EPA_PEND to determine which source caused the interrupt.
Bit Number Function

ONES_REG
The two-byte ones register (ONES_REG) is always equal to FFFFH. It is useful as a fixed source of all ones for comparison operations.
15:0 One
These bits are always equal to FFFFH.
One (high byte) · One (low byte) · Bit Number Function

Px_DIR x = 1–4
Each pin of port x can operate in any of the standard I/O modes of operation: complementary output, open-drain output, or high-impedance input. The port x I/O direction (Px_DIR) register determines the I/O direction for each port x pin. The register settings for an open-drain output or a high-impedance input are identical. An open-drain output configuration requires an external pull-up. A high-impedance input configuration requires that the corresponding bit in Px_REG be set.
x = 1–3 PIN7 PIN6 PIN5 PIN4 PIN3 PIN2 PIN1 PIN0
x = 4 — PIN3 PIN2 PIN1 PIN0
7:0 PIN7:0 Port x Pin y Direction
This bit selects the Px.y direction:
0 = complementary output (output only) 1 = input or open-drain output (input, output, or bidirectional Open- drain outputs require external pull-ups.
Register Address Reset Value
P2_DIR 1FD3H FFH
P3_DIR 1FDAH FFH
P4_DIR 1FDBH FFH
Table C-10 · Bit Number · Bit Mnemonic Function

Px_MODE
Px_MODE x = 1–4
Each bit of the port x mode (Px_MODE) register controls whether the corresponding pin functions as a standard I/O port pin or as a special-function signal.
x = 1–3 PIN7 PIN6 PIN5 PIN4 PIN3 PIN2 PIN1 PIN0
x = 4 — PIN3 PIN2 PIN1 PIN0
7:0 PIN7:0 Port x Pin y Mode
This bit determines the mode of the corresponding port pin:
0 = standard I/O port pin 1 = special-function signal
Table C-12 lists the special-function signals for each pin.
Register Address Reset Value
P2_MODE 1FD1H 80H
P3_MODE 1FD8H 01H
P4_MODE 1FD9H 00H
Table C-12. Special-function Signals for Ports 1–4
Port 1 Port 2 Port 3 Port 4
P1.1 EPA1 P2.1 RXD P3.1 CS1# P4.1 PWM1
P1.2 EPA2 P2.2 EXTINT0 P3.2 CS2# P4.2 PWM2
P1.3 EPA3 P2.3 BREQ# P3.3 CS3# P4.3 —
P1.4 T1CLK P2.4 EXTINT1 P3.4 CS4#
P1.5 T1DIR P2.5 HOLD# P3.5 CS5#
P1.6 T2CLK P2.6 HLDA# P3.6 EXTINT2
P1.7 T2DIR P2.7 CLKOUT P3.7 EXTINT3

Px_PIN x = 1–4
Each bit of the port x pin input (Px_PIN) register reflects the current state of the corresponding pin, regardless of the pin configuration.
x = 1–3 PIN7 PIN6 PIN5 PIN4 PIN3 PIN2 PIN1 PIN0
x = 4 — PIN3 PIN2 PIN1 PIN0
Bit Number Bit Mnemonic Function
7:0 PIN7:0 Port x Pin y Input Value
This bit contains the current state of Px.y.
Register Address Reset Value
P2_PIN 1FD7H XXH
P3_PIN 1FDEH XXH
P4_PIN 1FDFH XXH
Table C-13

Px_REG
Px_REG x = 1–4
For an input, set the corresponding port x data ouput (Px_REG) register bit.
For an output, write the data to be driven out by each pin to the corresponding bit of Px_REG. When a pin is configured as standard I/O (Px_MODE.y = 0), the result of a CPU write to Px_REG is immediately visible on the pin. When a pin is configured as a special-function signal (Px_MODE.y = 1), the associated on-chip peripheral or off-chip component controls the pin. The CPU can still write to Px_REG, but the pin is unaffected until it is switched back to its standard I/O function.
This feature allows software to configure a pin as standard I/O (clear Px_MODE.y), initialize or overwrite the pin value, then configure the pin as a special-function signal (set Px_MODE.y). In this way, initialization, fault recovery, exception handling, etc., can be done without changing the operation of the associated peripheral.
x = 1–3 PIN7 PIN6 PIN5 PIN4 PIN3 PIN2 PIN1 PIN0
x = 4 — PIN3 PIN2 PIN1 PIN0
Bit Number Bit Mnemonic Function
7:0 PIN7:0 Port x Pin y Output
To use Px.y for output, write the desired output data to this bit. To use Px.y for input, set this bit.
Register Address Reset Value
P2_REG 1FD5H FFH
P3_REG 1FDCH FFH
P4_REG 1FDDH FFH
Table C-14

PSW no direct access
The processor status word (PSW) actually consists of two bytes. The high byte is the status word, which is described here; the low byte is the INT_MASK register. The status word 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 a user’s program.
The status word portion of the PSW cannot be accessed directly. To access the status word, push the value onto the stack (PUSHF), then pop the value to a register (POP test_reg). The PUSHF and PUSHA instructions save the PSW in the system stack and then clear it; POPF and POPA restore it.
See INT_MASK on page C-25
7 Z Zero Flag
This flag is set to indicate that the result of an operation was zero. For multiple-precision calculations, the zero flag cannot be set by the instruc- tions that use the carry bit from the previous calculation (e.g., ADDC, SUBC). However, these instructions can clear the zero flag. This ensures that the zero flag will reflect the result of the entire operation, not just the last calculation. For example, if the result of adding together the lower words of two double words is zero, the zero flag would be set. When the upper words are added together using the ADDC instruction, the flag remains set if the result is zero and is cleared if the result is not zero.
6 N Negative Flag
This flag is set to indicate that the result of an operation is negative. The flag is correct even if an overflow occurs. For all shift operations and the NORML instruction, the flag is set to equal the most-significant bit of the result, even if the shift count is zero.
5 V Overflow Flag
This flag is set to indicate that the result of an operation is too large to be represented correctly in the available space. For shift operations (SHL, SHLB, and SHLL), the flag is set if the most-significant bit of the operand changes during the shift. For divide operations, the quotient is stored in the low-order half of the destination operand and the remainder is stored in the high-order half. The overflow flag is set if the quotient is outside the range for the low-order half of the destination operand. (Chapter 4, “Programming Considerations,” defines the operands and possible values for each. See the PSW flag descriptions in Appendix A for details.)
Bit Number · Bit Mnemonic Function

PSW
PSW (Continued) no direct access
The processor status word (PSW) actually consists of two bytes. The high byte is the status word, which is described here; the low byte is the INT_MASK register. The status word 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 a user’s program.
The status word portion of the PSW cannot be accessed directly. To access the status word, push the value onto the stack (PUSHF), then pop the value to a register (POP test_reg). The PUSHF and PUSHA instructions save the PSW in the system stack and then clear it; POPF and POPA restore it.
See INT_MASK on page C-25
4 VT Overflow-trap Flag
This flag is set when the overflow flag is set, but it is cleared only by the CLRVT, JVT, and JNVT instructions. This allows testing for a possible overflow at the end of a sequence of related arithmetic operations, which is generally more efficient than testing the overflow flag after each operation.
3 C Carry Flag
This flag is set to indicate an arithmetic carry or the last bit shifted out of an operand. It is cleared if a subtraction operation generates a borrow. Normally, the result is rounded up if the carry flag is set. The sticky bit flag allows a finer resolution in the rounding decision. (See the PSW flag descriptions in Appendix A for details.)
2 PSE PTS Enable
This bit globally enables or disables the peripheral transaction server (PTS). The EPTS instruction sets this bit; DPTS clears it.
1 = enable PTS 0 = disable PTS
1 I Interrupt Disable (Global)
This bit globally enables or disables the servicing of all maskable interrupts. The bits in INT_MASK and INT_MASK1 individually enable or disable the interrupts. The EI instruction sets this bit; DI clears it.
1 = enable interrupt servicing 0 = disable interrupt servicing
0 ST Sticky Bit Flag
This flag is set to indicate that, during a right shift, a “1” was shifted into the carry flag and then shifted out. It can be used with the carry flag to allow finer resolution in rounding decisions.
Bit Number · Bit Mnemonic Function

The PTS select (PTSSEL) register selects either a PTS microcode routine or a standard interrupt service routine for each interrupt request. Setting a bit selects a PTS microcode routine; clearing a bit selects a standard interrupt service routine. When PTSCOUNT reaches zero, hardware clears the corresponding PTSSEL bit. The PTSSEL bit must be set manually to re-enable the PTS channel.
EPA0 RI TI EXTINT1 EXTINT0 — OVRTM2 OVRTM1
15, 2 Reserved; for compatibility with future devices, write zero to this bit.
14:3 1:0 Setting a bit causes the corresponding interrupt to be handled by a PTS microcode routine.
The PTS interrupt vector locations are as follows:
Bit Mnemonic Interrupt PTS Vector EXTINT3 EXTINT3 pin FF205CH EXTINT2 EXTINT2 pin FF205AH OVR2_3† EPA Capture Channel 2 or 3 Overrun FF2058H OVR0_1† EPA Capture Channel 0 or 1 Overrun FF2056H EPA3 EPA Capture/Compare Channel 3 FF2054H EPA2 EPA Capture/Compare Channel 2 FF2052H EPA1 EPA Capture/Compare Channel 1 FF2050H EPA0 EPA Capture/Compare Channel 0 FF204EH RI SIO Receive FF204CH TI SIO Transmit FF204AH EXTINT1 EXTINT1 pin FF2048H EXTINT0 EXTINT0 pin FF2046H OVRTM2 Timer 2 Overflow/ Underflow FF2042H OVRTM1 Timer 1 Overflow/ Underflow FF2040H
† PTS service is not recommended because the PTS cannot determine the source of shared interrupts.
Bit Number Function

PTSSRV
The PTS service (PTSSRV) register is used by the hardware to indicate that the final PTS interrupt has been serviced by the PTS routine. When PTSCOUNT reaches zero, hardware clears the corre- sponding PTSSEL bit and sets the PTSSRV bit, which requests the end-of-PTS interrupt. When the end-of-PTS interrupt is called, hardware clears the PTSSRV bit. The PTSSEL bit must be set manually to re-enable the PTS channel.
EPA0 RI TI EXTINT1 EXTINT0 — OVRTM1 OVRTM2
15, 2 Reserved. These bits are undefined.
14:3 1:0 A bit is set by hardware to request an end-of-PTS interrupt for the corresponding interrupt through its standard interrupt vector.
The standard interrupt vector locations are as follows.
Bit Mnemonic Interrupt Standard Vector EXTINT3 EXTINT3 Pin FF203CH EXTINT2 EXTINT2 Pin FF203AH OVR2_3† EPA Capture Channel 2 or 3 Overrun FF2038H OVR0_1† EPA Capture Channel 0 or 1 Overrun FF2036H EPA3 EPA Capture/Compare Channel 3 FF2034H EPA2 EPA Capture/Compare Channel 2 FF2032H EPA1 EPA Capture/Compare Channel 1 FF2030H EPA0 EPA Capture/Compare Channel 0 FF200EH RI SIO Receive FF200CH TI SIO Transmit FF200AH EXTINT1 EXTINT1 pin FF2008H EXTINT0 EXTINT0 pin FF2006H OVRTM2 Timer 2 Overflow/Underflow FF2002H OVRTM1 Timer 1 Overflow/Underflow FF2000H
† PTS service is not recommended for multiplexed interrupts. This bit is cleared when both corresponding interrupt pending bits are cleared in EPA_PEND.
Bit Number Function

PWMx_CONTROL x = 0–2
The PWM control (PWMx_CONTROL) register determines the duty cycle of the PWM x channel. A zero loaded into this register causes the PWM to output a low continuously (0% duty cycle). An FFH in this register causes the PWM to have its maximum duty cycle (99.6% duty cycle).
7:0 PWM Duty Cycle
This register controls the PWM duty cycle. A zero loaded into this register causes the PWM to output a low continuously (0% duty cycle). An FFH in this register causes the PWM to have its maximum duty cycle (99.6% duty cycle).
Register Address Reset Value
PWM1_CONTROL 1FB2H 00H
PWM2_CONTROL 1FB4H 00H
Table C-15 · PWM Duty Cycle · Bit Number Function

SBUF_RX
The serial port receive buffer (SBUF_RX) register contains data received from the serial port. The serial port receiver is buffered and can begin receiving a second data byte before the first byte is read. Data is held in the receive shift register until the last data bit is received, then the data byte is loaded into SBUF_RX. If data in the shift register is loaded into SBUF_RX before the previous byte is read, the overflow error bit is set (SP_STATUS.2). The data in SBUF_RX will always be the last byte received, never a combination of the last two bytes.
7:0 Data Received
This register contains the last byte of data received from the serial port.
Data Received · Bit Number Function

The serial port transmit buffer (SBUF_TX) register contains data that is ready for transmission. In modes 1, 2, and 3, writing to SBUF_TX starts a transmission. In mode 0, writing to SBUF_TX starts a transmission only if the receiver is disabled (SP_CON.3=0).
7:0 Data to Transmit
This register contains a byte of data to be transmitted by the serial port.
Data to Transmit · Bit Number Function

SP
The system’s stack pointer (SP) can point anywhere in an internal or external memory page; it must be word aligned and must always be initialized before use. The stack pointer is decremented before a PUSH and incremented after a POP, so the stack pointer should be initialized to two bytes (in 64- Kbyte mode) or four bytes (in 1-Mbyte mode) above the highest stack location. If stack operations are not being performed, locations 18H and 19H may be used as standard registers.
Stack Pointer (high byte)
Stack Pointer (low byte)
15:0 Stack Pointer
This register makes up the system’s stack pointer.
Bit Number Function

The serial port baud rate (SP_BAUD) register selects the serial port baud rate and clock source. The most-significant bit selects the clock source. The lower 15 bits represent BAUD_VALUE, an unsigned integer that determines the baud rate.
The maximum BAUD_VALUE is 32,767 (7FFFH). In asynchronous modes 1, 2, and 3, the minimum BAUD_VALUE is 0000H when using the internal clock source (f) and 0001H when using T1CLK. In synchronous mode 0, the minimum BAUD_VALUE is 0001H for transmissions and 0002H for receptions.
BV7 BV6 BV5 BV4 BV3 BV2 BV1 BV0
15 CLKSRC Serial Port Clock Source
This bit determines whether the serial port is clocked from an internal or an external source.
0 = signal on the T1CLK pin (external source) 1 = internal operating frequency (f)
14:0 BV14:0 Baud Rate
These bits constitute the BAUD_VALUE.
Use the following equations to determine the BAUD_VALUE for a given baud rate.
Baud Rate 2 × 1 – = T1CLK
Asynchronous modes 1, 2, and 3:
Baud Rate 16 × 1 – = T1CLK
Baud Rate 8 ×
† For mode 0 receptions, the BAUD_VALUE must be 0002H or greater. Otherwise, the resulting data in the receive shift register will be incorrect.

SP_BAUD
Table C-16. SP_BAUD Values When Using the Internal Clock at 25 MHz
SP_BAUD Register Value (Note 1) % Error
Mode 0 Mode 1, 2, 3 Mode 0 Mode 1, 2, 3
4800 8A2BH 8144H 0 0.16
2400 9457H 828AH 0 0
1200 A8AFH 8515H 0 0
300 (Note 2) 9457H (Note 2) 0
Baud Rate

The serial port control (SP_CON) register selects the communications mode and enables or disables the receiver, parity checking, and nine-bit data transmission. For the 80C196NU, it also enables or disables the divide-by-two prescaler.
8XC196NP — — PAR TB8 REN PEN M1 M0
80C196NU — PRS PAR TB8 REN PEN M1 M0
7 — Reserved; for compatibility with future devices, write zero to this bit.
6† PRS Prescale
This bit enables the divide-by-two prescaler.
0 = disable the prescaler 1 = enable the prescaler
5 PAR Parity Selection Bit
Selects even or odd parity.
0 = even parity 1 = odd parity
4 TB8 Transmit Ninth Data Bit
This is the ninth data bit that will be transmitted in mode 2 or 3. This bit is cleared after each transmission, so it must be set before SBUF_TX is written. When SP_CON.2 is set, this bit takes on the even parity value.
3 REN Receive Enable
Setting this bit enables the receiver function of the RXD pin. When this bit is set, a high-to-low transition on the pin starts a reception in mode 1, 2, or 3. In mode 0, this bit must be clear for transmission to begin and must be set for reception to begin. Clearing this bit stops a reception in progress and inhibits further receptions.
2 PEN Parity Enable
In modes 1 and 3, setting this bit enables the parity function. This bit must be cleared if mode 2 is used. When this bit is set, TB8 takes the parity value on transmissions. With parity enabled, SP_STATUS.7 becomes the receive parity error bit.
1:0 M1:0 Mode Selection
These bits select the communications mode.
M1 M0 0 0 mode 0 0 1 mode 1 1 0 mode 2 1 1 mode 3
† This bit is reserved on the 8XC196NP. For compatibility with future devices, write zero to this bit.
Bit Number · Bit Mnemonic Function

SP_STATUS
The serial port status (SP_STATUS) register contains bits that indicate the status of the serial port.
7 RPE/RB8 Received Parity Error/Received Bit 8
RPE is set if parity is disabled (SP_CON.2 = 0) and the ninth data bit received is high.
RB8 is set if parity is enabled (SP_CON.2 = 1) and a parity error occurred.
Reading SP_STATUS clears this bit.
6 RI Receive Interrupt
This bit is set when the last data bit is sampled. Reading SP_STATUS clears this bit.
This bit need not be clear for the serial port to receive data.
5 TI Transmit Interrupt
This bit is set at the beginning of the stop bit transmission. Reading SP_STATUS clears this bit.
4 FE Framing Error
This bit is set if a stop bit is not found within the appropriate period of time. Reading SP_STATUS clears this bit.
3 TXE SBUF_TX Empty
This bit is set if the transmit buffer is empty and ready to accept up to two bytes. It is cleared when a byte is written to SBUF_TX.
2 OE Overrun Error
This bit is set if data in the receive shift register is loaded into SBUF_RX before the previous bit is read. Reading SP_STATUS clears this bit.
1:0 — Reserved. These bits are undefined.
Bit Number · Bit Mnemonic Function

The timer 1 control (T1CONTROL) register determines the clock source, counting direction, and count rate for timer 1.
7 CE Counter Enable
This bit enables or disables the timer. From reset, the timers are disabled and not free running.
0 = disables timer 1 = enables timer
This bit determines the timer counting direction, in selected modes (see mode bits, M2:0).
0 = count down 1 = count up
5:3 M2:0 EPA Clock Direction Mode Bits
These bits determine the timer clocking source and direction control source.
M2 M1 M0 Clock Source Direction Source
0 0 0 f/4 UD bit (T1CONTROL.6) X 0 1 T1CLK pin† UD bit (T1CONTROL.6) 0 1 0 f/4 T1DIR pin 0 1 1 T1CLK pin† T1DIR pin 1 1 1 quadrature clocking using T1CLK and T1DIR
† If an external clock is selected, the timer counts on both the rising and falling edges of the clock.
2:0 P2:0 EPA Clock Prescaler Bits
These bits determine the clock prescaler value.
P2 P1 P0 Prescaler Divisor Resolution†
0 0 0 divide by 1 (disabled) 160 ns 0 0 1 divide by 2 320 ns 0 1 0 divide by 4 640 ns 0 1 1 divide by 8 1.28 µs 1 0 0 divide by 16 2.56 µs 1 0 1 divide by 32 5.12 µs 1 1 0 divide by 64 10.24 µs 1 1 1 divide by 128 (NU only) 20.48 µs
† At f = 25 MHz. Use the formula on page 10-6 to calculate the resolution at other frequencies.
Bit Number · Bit Mnemonic Function · 6 UD Up/Down

T2CONTROL
The timer 2 control (T2CONTROL) register determines the clock source, counting direction, and count rate for timer 2.
7 CE Counter Enable
This bit enables or disables the timer. From reset, the timers are disabled and not free running.
0 = disables timer 1 = enables timer
This bit determines the timer counting direction, in selected modes (see mode bits, M2:0).
0 = count down 1 = count up
5:3 M2:0 EPA Clock Direction Mode Bits.
These bits determine the timer clocking source and direction source
M2 M1 M0 Clock Source Direction Source
0 0 0 f/4 UD bit (T2CONTROL.6) X 0 1 T2CLK pin† UD bit (T2CONTROL.6) 0 1 0 f/4 T2DIR pin 0 1 1 T2CLK pin† T2DIR pin 1 0 0 timer 1 overflow UD bit (T2CONTROL.6) 1 1 0 timer 1 same as timer 1 quadrature clocking using T2CLK and T2DIR † If an external clock is selected, the timer counts on both the rising and falling edges of the clock.
2:0 P2:0 EPA Clock Prescaler Bits
These bits determine the clock prescaler value.
P2 P1 P0 Prescaler Resolution†
0 0 0 divide by 1 (disabled) 160 ns 0 0 1 divide by 2 320 ns 0 1 0 divide by 4 640 ns 0 1 1 divide by 8 1.28 µs 1 0 0 divide by 16 2.56 µs 1 0 1 divide by 32 5.12 µs 1 1 0 divide by 64 10.24 µs 1 1 1 divide by 128 (NU only) 20.48 µs † At f = 25 MHz. Use the formula on page 10-6 to calculate the resolution at other frequencies.
Bit Number · Bit Mnemonic Function · 6 UD Up/Down

TIMERx x = 1–2
This register contains the value of timer x. This register can be written, allowing timer x to be initialized to a value other than zero.
Timer Value (high byte)
Timer Value (low byte)
15:0 Timer
Read the current timer x value from this register or write a new timer x value to this register.
Register Address Reset Value
TIMER2 1F96H 0000H
Table C-17 · Bit Number Function

WSR
The window selection register (WSR) has two functions. One bit enables and disables the bus-hold protocol. The remaining bits select windows. Windows map sections of RAM into the top of the lower register file, in 32-, 64-, or 128-byte increments. PUSHA saves this register on the stack and POPA restores it.
7 HLDEN HOLD#, HLDA# Protocol Enable
This bit enables and disables the bus-hold protocol (see Chapter 13, “Interfacing with External Memory”). It has no effect on windowing.
1 = enable 0 = disable
6:0 W6:0 Window Selection
These bits specify the window size and window number. See Table 5-8 on page 5-15 or Table 5-9 on page 5-15.
WSR Direct Address WSR Direct Address WSR Direct Address
ADDRCOM0† 1F40H 7AH 00E0H 3DH 00C0H 1EH 00C0H
ADDRCOM1† 1F48H 7AH 00E8H 3DH 00C8H 1EH 00C8H
ADDRCOM2† 1F50H 7AH 00F0H 3DH 00D0H 1EH 00D0H
ADDRCOM3† 1F58H 7AH 00F8H 3DH 00D8H 1EH 00D8H
ADDRCOM4† 1F60H 7BH 00E0H 3DH 00E0H 1EH 00E0H
ADDRCOM5† 1F68H 7BH 00E8H 3DH 00E8H 1EH 00E8H
ADDRMSK0† 1F42H 7AH 00E2H 3DH 00C2H 1EH 00C2H
ADDRMSK1† 1F4AH 7AH 00EAH 3DH 00CAH 1EH 00CAH
ADDRMSK2† 1F52H 7AH 00F2H 3DH 00D2H 1EH 00D2H
ADDRMSK3† 1F5AH 7AH 00FAH 3DH 00DAH 1EH 00DAH
ADDRMSK4† 1F62H 7BH 00E2H 3DH 00E2H 1EH 00E2H
ADDRMSK5† 1F6AH 7BH 00EAH 3DH 00EAH 1EH 00EAH
† Must be addressed as a word.

Table C-18. WSR Settings and Direct Addresses for Windowable SFRs (Continued)
WSR Direct Address WSR Direct Address WSR Direct Address
BUSCON2 1F54H 7AH 00F4H 3DH 00D4H 1EH 00D4H
BUSCON3 1F5CH 7AH 00FCH 3DH 00DCH 1EH 00DCH
BUSCON4 1F64H 7BH 00E4H 3DH 00E4H 1EH 00E4H
BUSCON5 1F6CH 7BH 00ECH 3DH 00ECH 1EH 00ECH
CON_REG0 1FB6H 7DH 00F6H 3EH 00F6H 1FH 00B6H
EP_DIR 1FE3H 7FH 00E3H 3FH 00E3H 1FH 00E3H
EP_MODE 1FE1H 7FH 00E1H 3FH 00E1H 1FH 00E1H
EP_PIN 1FE7H 7FH 00E7H 3FH 00E7H 1FH 00E7H
EP_REG 1FE5H 7FH 00E5H 3FH 00E5H 1FH 00E5H
EPA_MASK† 1F9CH 7CH 00FCH 3EH 00DCH 1FH 009CH
EPA0_CON 1F80H 7CH 00E0H 3EH 00C0H 1FH 0080H
EPA1_CON† 1F84H 7CH 00E4H 3EH 00C4H 1FH 0084H
EPA3_CON† 1F8CH 7CH 00ECH 3EH 00CCH 1FH 008CH
EPA0_TIME† 1F82H 7CH 00E2H 3EH 00C2H 1FH 0082H
EPA1_TIME† 1F86H 7CH 00E6H 3EH 00C6H 1FH 0086H
EPA2_TIME† 1F8AH 7CH 00EAH 3EH 00CAH 1FH 008AH
EPA3_TIME† 1F8EH 7CH 00EEH 3EH 00CEH 1FH 008EH
P1_MODE 1FD0H 7EH 00F0H 3FH 00D0H 1FH 00D0H
P1_PIN 1FD6H 7EH 00F6H 3FH 00D6H 1FH 00D6H
P1_REG 1FD4H 7EH 00F4H 3FH 00D4H 1FH 00D4H
P2_DIR 1FD3H 7EH 00F3H 3FH 00D3H 1FH 00D3H
P2_MODE 1FD1H 7EH 00F1H 3FH 00D1H 1FH 00D1H
P2_PIN 1FD7H 7EH 00F7H 3FH 00D7H 1FH 00D7H
P2_REG 1FD5H 7EH 00F5H 3FH 00D5H 1FH 00D5H
P3_DIR 1FDAH 7EH 00FAH 3FH 00DAH 1FH 00DAH
P3_MODE 1FD8H 7EH 00F8H 3FH 00D8H 1FH 00D8H
P3_PIN 1FDEH 7EH 00FEH 3FH 00DEH 1FH 00DEH
P3_REG 1FDCH 7EH 00FCH 3FH 00DCH 1FH 00DCH
† Must be addressed as a word.

WSR
Table C-18. WSR Settings and Direct Addresses for Windowable SFRs (Continued)
WSR Direct Address WSR Direct Address WSR Direct Address
P4_MODE 1FD9H 7EH 00F9H 3FH 00D9H 1FH 00D9H
P4_PIN 1FDFH 7EH 00FFH 3FH 00DFH 1FH 00DFH
P4_REG 1FDDH 7EH 00FDH 3FH 00DDH 1FH 00DDH
PWM0_CONTROL 1FB0H 7DH 00F0H 3EH 00F0H 1FH 00B0H
PWM1_CONTROL 1FB2H 7DH 00F2H 3EH 00F2H 1FH 00B2H
PWM2_CONTROL 1FB4H 7DH 00F4H 3EH 00F4H 1FH 00B4H
SBUF_RX 1FB8H 7DH 00F8H 3EH 00F8H 1FH 00B8H
SBUF_TX 1FBAH 7DH 00FAH 3EH 00FAH 1FH 00BAH
SP_BAUD 1FBCH 7DH 00FCH 3EH 00FCH 1FH 00BCH
SP_CON 1FBBH 7DH 00FBH 3EH 00FBH 1FH 00BBH
SP_STATUS 1FB9H 7DH 00F9H 3EH 00F9H 1FH 00B9H
T1CONTROL 1F90H 7CH 00F0H 3EH 00D0H 1FH 0090H
T2CONTROL 1F94H 7CH 00F4H 3EH 00D4H 1FH 0094H
TIMER1† 1F92H 7CH 00F2H 3EH 00D2H 1FH 0092H
TIMER2† 1F96H 7CH 00F6H 3EH 00D6H 1FH 0096H
† Must be addressed as a word.

WSR1 (80C196NU)
Window selection 1 (WSR1) register selects a 32- or 64-byte segment of the upper register file or peripheral SFRs to be windowed into the middle of the lower register file, below any window selected by the WSR.
80C196NU — W6 W5 W4 W3 W2 W1 W0
7 — Reserved; always write as zero.
6:0 W6:0 Window Selection
These bits specify the window size and window number. See Table 5-8 on page 5-15 or Table 5-9 on page 5-15.
WSR1 Direct Address WSR1 Direct Address
ADDRCOM1 † 1F48H 7AH 0068H 3DH 0048H
ADDRCOM2 † 1F50H 7AH 0070H 3DH 0050H
ADDRCOM3 † 1F58H 7AH 0078H 3DH 0058H
ADDRCOM4 † 1F60H 7BH 0060H 3DH 0060H
ADDRCOM5 † 1F68H 7BH 0068H 3DH 0068H
ADDRMSK0 † 1F42H 7AH 0062H 3DH 0042H
ADDRMSK1 † 1F4AH 7AH 006AH 3DH 004AH
ADDRMSK2 † 1F52H 7AH 0072H 3DH 0052H
ADDRMSK3 † 1F5AH 7AH 007AH 3DH 005AH
ADDRMSK4 † 1F62H 7BH 0062H 3DH 0062H
ADDRMSK5 † 1F6AH 7BH 006AH 3DH 006AH
BUSCON0 1F44H 7AH 0064H 3DH 0044H
BUSCON1 1F4CH 7AH 006CH 3DH 004CH
BUSCON2 1F54H 7AH 0074H 3DH 0054H
BUSCON3 1F5CH 7AH 007CH 3DH 005CH
BUSCON4 1F64H 7BH 0064H 3DH 0064H
† Must be addressed as a word.

WSR1
Table C-19. WSR1 Settings and Direct Addresses for Windowable SFRs (Continued)
WSR1 Direct Address WSR1 Direct Address
CON_REG0 1FB6H 7DH 0076H 3EH 0076H
EP_DIR 1FE3H 7FH 0063H 3FH 0063H
EP_MODE 1FE1H 7FH 0061H 3FH 0061H
EP_PIN 1FE7H 7FH 0067H 3FH 0067H
EP_REG 1FE5H 7FH 0065H 3FH 0065H
EPA_MASK † 1F9CH 7CH 007CH 3EH 005CH
EPA_PEND 1F9EH 7CH 007EH 3EH 005EH
EPA0_CON 1F80H 7CH 0060H 3EH 0040H
EPA0_TIME † 1F82H 7CH 0062H 3EH 0042H
EPA1_CON † 1F84H 7CH 0064H 3EH 0044H
EPA1_TIME † 1F86H 7CH 0066H 3EH 0046H
EPA2_CON 1F88H 7CH 0068H 3EH 0048H
EPA2_TIME † 1F8AH 7CH 006AH 3EH 004AH
EPA3_CON † 1F8CH 7CH 006CH 3EH 004CH
EPA3_TIME † 1F8EH 7CH 006EH 3EH 004EH
P1_DIR 1FD2H 7EH 0072H 3FH 0052H
P1_MODE 1FD0H 7EH 0070H 3FH 0050H
P1_PIN 1FD6H 7EH 0076H 3FH 0056H
P1_REG 1FD4H 7EH 0074H 3FH 0054H
P2_DIR 1FD3H 7EH 0073H 3FH 0053H
P2_MODE 1FD1H 7EH 0071H 3FH 0051H
P2_PIN 1FD7H 7EH 0077H 3FH 0057H
P2_REG 1FD5H 7EH 0075H 3FH 0055H
P3_DIR 1FDAH 7EH 007AH 3FH 005AH
P3_MODE 1FD8H 7EH 0078H 3FH 0058H
P3_PIN 1FDEH 7EH 007EH 3FH 005EH
P3_REG 1FDCH 7EH 007CH 3FH 005CH
P4_DIR 1FDBH 7EH 007BH 3FH 005BH
P4_MODE 1FD9H 7EH 0079H 3FH 0059H
P4_PIN 1FDFH 7EH 007FH 3FH 005FH
P4_REG 1FDDH 7EH 007DH 3FH 005DH
† Must be addressed as a word.

Table C-19. WSR1 Settings and Direct Addresses for Windowable SFRs (Continued)
WSR1 Direct Address WSR1 Direct Address
PWM1_CONTROL 1FB2H 7DH 0072H 3EH 0072H
PWM2_CONTROL 1FB4H 7DH 0074H 3EH 0074H
SBUF_RX 1FB8H 7DH 0078H 3EH 0078H
SBUF_TX 1FBAH 7DH 007AH 3EH 007AH
SP_BAUD 1FBCH 7DH 007CH 3EH 007CH
SP_CON 1FBBH 7DH 007BH 3EH 007BH
SP_STATUS 1FB9H 7DH 0079H 3EH 0079H
T1CONTROL 1F90H 7CH 0070H 3EH 0050H
T2CONTROL 1F94H 7CH 0074H 3EH 0054H
TIMER1 † 1F92H 7CH 0072H 3EH 0052H
TIMER2 † 1F96H 7CH 0076H 3EH 0056H
† Must be addressed as a word.

ZERO_REG
The two-byte zero register (ZERO_REG) is always equal to zero. It is useful as a fixed source of the constant zero for comparisons and calculations.
15:0 Zero
This register is always equal to zero.
Zero (high byte) · Zero (low byte) · Bit Number Function






This glossary defines acronyms, abbreviations, and terms that have special meaning in this man- ual. (Chapter 1 discusses notational conventions and general terminology.)
1-Mbyte mode The addressing mode that allows code to reside anywhere in the 1-Mbyte addressing space.
64-Kbyte mode The addressing mode that allows code to reside only in page FFH.
accumulator A register or storage location that forms the result of an arithmetic or logical operation.
The 80C196NU has enhanced multiplication instruc- tions that use a new 32-bit accumulator for multiply- accumulate operations.
ALU Arithmetic-logic unit. The part of the RALU that processes arithmetic and logical operations.
assert The act of making a signal active (enabled). The polarity (high or low) 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.
bit A binary digit.
BIT A single-bit operand that can take on the Boolean values, “true” and “false.”
byte Any 8-bit unit of data.
BYTE An unsigned, 8-bit variable with values from 0 through 28–1.
CCBs Chip configuration bytes. The chip configuration registers (CCRs) are loaded with the contents of the CCBs after a device reset.
CCRs Chip configuration registers. Registers that define the environment in which the device will be operating. The chip configuration registers are loaded with the contents of the CCBs after a device reset.
Glossary-1

chip-select unit The integrated module that selects an external memory device during an external bus cycle.
clear The “0” value of a bit or the act of giving it a “0” value. See also set.
deassert The act of making a signal inactive (disabled). The polarity (high or low) is defined by the signal name. Active-low signals are designated by a pound symbol (#) suffix; active-high signals have no suffix. To deassert RD# is to drive it high; to deassert ALE is to drive it low.
demultiplexed bus The configuration in which the device uses separate lines for address and data (address on A19:0; data on AD15:0 for a 16-bit bus or AD7:0 for an 8-bit bus). See also multiplexed bus.
doping The process of introducing a periodic table Group III or Group V element into a Group IV element (e.g., silicon). A Group III impurity (e.g., indium or gallium) results in a p-type material. A Group V impurity (e.g., arsenic or antimony) results in an n- type material.
double-word Any 32-bit unit of data.
DOUBLE-WORD An unsigned, 32-bit variable with values from 0 through 232–1.
EDAR Extended data address register used by the EPORT.
EPA Event processor array. An integrated peripheral that provides high-speed input/output capability.
EPC Extended program counter used by the EPORT.
EPORT Extended addressing port. The port that provides the additional address lines to support extended addressing.
ESD Electrostatic discharge.
external address A 20-bit address is presented on the device pins. The address decoded by an external device depends on how many of these address lines the external system uses. See also internal address.
far constants Constants that can be accessed only with extended instructions. See also near constants.
Glossary-2

far data Data that can be accessed only with extended instruc- tions. See also near data.
FET Field-effect transistor.
f Lowercase “f” represents the frequency of the internal clock. For the 8XC196NP, f is always equal to FXTAL1 (the input frequency on XTAL1). For the 80C196NU, which employs a phase-locked loop with clock multiplier circuitry, f is equal to either FXTAL1, 2FXTAL1, or 4FXTAL1. The multiplier depends on the clock mode, which is controlled by the PLLEN1 and PLLEN2 input pins. (Figure 2-4 on page 2-8 illustrates the clock circuitry of the 80C196NU.)
fractional mode A mode of the multiply-accumulate function in which the multiplier result is shifted left one bit before being written to the accumulator. This left shift eliminates the extra sign bit when both operands are signed, leaving a correctly signed result.
hold latency The time it takes the microcontroller to assert HLDA# after an external device asserts HOLD#.
input leakage Current leakage from an input pin to power or ground.
integer Any member of the set consisting of the positive and negative whole numbers and zero.
INTEGER A 16-bit, signed variable with values from –215
through +215–1.
internal address The 24-bit address that the microcontroller generates. See also external address.
interrupt controller The module responsible for handling interrupts that are to be serviced by interrupt service routines that you provide. Also called the programmable interrupt controller (PIC).
interrupt latency The total delay between the time that an interrupt is generated (not acknowledged) and the time that the device begins executing the interrupt service routine or PTS routine.
interrupt service routine A software routine that you provide to service a standard interrupt. See also PTS routine.
interrupt vector A location in special-purpose memory that holds the starting address of an interrupt service routine.
Glossary-3

ISR See interrupt service routine.
LONG-INTEGER A 32-bit, signed variable with values from –231
through +231–1.
LSB Least-significant bit of a byte or least-significant byte of a word.
MAC See multiply-accumulate.
maskable interrupts All interrupts except unimplemented opcode, software trap, and NMI. Maskable interrupts can be disabled (masked) by the individual mask bits in the interrupt mask registers, and their servicing can be disabled by the global interrupt enable bit. Each maskable interrupt can be assigned to the PTS for processing.
MSB Most-significant bit of a byte or most-significant byte of a word.
multiplexed bus The configuration in which the device uses both A19:0 and AD15:0 for address and also uses AD15:0 for data. See also demultiplexed bus.
multiply-accumulate An operation performed by the 8XC196NU’s enhanced multiplication instructions. The result of the operation is stored in a dedicated, 32-bit accumulator.
n-channel FET A field-effect transistor with an n-type conducting path (channel).
n-type material Semiconductor material with introduced impurities (doping) causing it to have an excess of negatively charged carriers.
near constants Constants that can be accessed with nonextended instructions. Constants in page 00H are near constants (EP_REG = 00H is assumed). See also far constants.
near data Data that can be accessed with nonextended instruc- tions. Data in page 00H is near data (EP_REG = 00H is assumed). See also far data.
nonmaskable interrupts Interrupts that cannot be masked (disabled) and cannot be assigned to the PTS for processing. The nonmaskable interrupts are unimplemented opcode, software trap, and NMI.
Glossary-4

nonvolatile memory Read-only memory that retains its contents when power is removed. Many MCS® 96 microcontrollers are available with either masked ROM, EPROM, or OTPROM. Consult the Automotive Products or Embedded Microcontrollers databook to determine which type of memory is available for a specific device.
npn transistor A transistor consisting of one part p-type material and two parts n-type material.
p-channel FET A field-effect transistor with a p-type conducting path.
p-type material Semiconductor material with introduced impurities (doping) causing it to have an excess of positively charged carriers.
PC Program counter.
phase-locked loop A component of the clock generation circuitry. The phase-locked loop (PLL) and the two input pins (PLLEN1 and PLLEN2) combine to enable the device to attain its maximum operating frequency with an external clock whose frequency is either equal to, one-half, or one-fourth that maximum frequency or with an external oscillator whose frequency is either one-half or one-fourth that maximum frequency.
PIC Programmable interrupt controller. The module responsible for handling interrupts that are to be serviced by interrupt service routines that you provide. Also called simply the interrupt controller.
PLL See phase-locked loop.
prioritized interrupt Any maskable interrupt or nonmaskable NMI. Two of the nonmaskable interrupts (unimplemented opcode and software trap) are not prioritized; they vector directly to the interrupt service routine when executed.
program memory A partition of memory where instructions can be stored for fetching and execution.
protected instruction An instruction that prevents an interrupt from being acknowledged until after the next instruction executes. The protected instructions are DI, EI, DPTS, EPTS, POPA, POPF, PUSHA, and PUSHF.
Glossary-5

PSW Processor status word. The high byte of the PSW is the status byte, which contains one bit that globally enables or disables servicing of all maskable interrupts, one bit that enables or disables the PTS, and six Boolean flags that reflect the state of the current program. The low byte of the PSW is the INT_MASK register. A push or pop instruction saves or restores both bytes (PSW + INT_MASK).
PTS Peripheral transaction server. The microcoded hardware interrupt processor.
PTSCB See PTS control block.
PTS control block A block of data required for each PTS interrupt. The microcode executes the proper PTS routine based on the contents of the PTS control block.
PTS cycle The microcoded response to a single PTS interrupt request.
PTS interrupt Any maskable interrupt that is assigned to the PTS for interrupt processing.
PTS mode A microcoded response that enables the PTS to complete a specific task quickly. These tasks include transferring a single byte or word, transferring a block of bytes or words, and generating PWM outputs.
PTS routine The entire microcoded response to multiple PTS interrupt requests. The PTS routine is controlled by the contents of the PTS control block.
PTS transfer The movement of a single byte or word from the source memory location to the destination memory location.
PTS vector A location in special-purpose memory that holds the starting address of a PTS control block.
QUAD-WORD An unsigned, 64-bit variable with values from 0 through 264–1. The QUAD-WORD variable is supported only as the operand for the EBMOVI instruction.
RALU Register arithmetic-logic unit. A part of the CPU that consists of the ALU, the PSW, the master PC, the microcode engine, a loop counter, and six registers.
Glossary-6

reserved memory A memory location that is reserved for factory use or for future expansion. Do not use a reserved memory location except to initialize it with FFH.
sampled inputs All input pins, with the exception of RESET#, are sampled inputs. The input pin is sampled one state time before the read buffer is enabled. Sampling occurs during PH1 (while CLKOUT is low) and resolves the value (high or low) of the pin before it is presented to the internal bus. If the pin value changes during the sample time, the new value may or may not be recorded during the read.
RESET# is a level-sensitive input. EXTINTx is normally a sampled input; however, the powerdown circuitry uses EXTINTx as a level-sensitive input during powerdown mode.
saturation mode Saturation occurs when the result of two positive numbers generates a negative sign bit or the result of two negative numbers generates a positive sign bit. Saturation mode prevents an underflow or overflow of the accumulated value.
set The “1” value of a bit or the act of giving it a “1” value. See also clear.
SFR Special-function register.
SHORT-INTEGER An 8-bit, signed variable with values from –27
through +27–1.
sign extension A method for converting data to a larger format by filling the upper bit positions with the value of the sign. This conversion preserves the positive or negative value of signed integers.
sink current Current flowing into a device to ground. Always a positive value.
source current Current flowing out of a device from VCC. Always a negative value.
SP Stack pointer.
special interrupt Any of the three nonmaskable interrupts (unimple- mented opcode, software trap, or NMI).
Glossary-7

special-purpose memory A partition of memory used for storing the interrupt vectors, PTS vectors, chip configuration bytes, and several reserved locations.
standard interrupt Any maskable interrupt that is assigned to the interrupt controller for processing by an interrupt service routine.
state time (or state) The basic time unit of the device; the combined period of the two internal timing signals, PH1 and PH2. (The internal clock generator produces PH1 and PH2 by halving the frequency of the signal on XTAL1. The rising edges of the active-high PH1 and PH2 signals generate CLKOUT, the output of the internal clock generator.) Because the device can operate at many frequencies, this manual defines time requirements in terms of state times rather than in specific units of time.
t Lowercase “t” represents the period of the internal clock. For the NP, t is the reciprocal of FXTAL1 (1/FXTAL1, where FXTAL1 is the input frequency on XTAL1). For the 80C196NU, which employs a phased-lock loop with clock multiplier circuitry, t is the reciprocal of either FXTAL1, 2FXTAL1, or 4FXTAL1. The multiplier depends on the clock mode, which is controlled by the PLLEN1 and PLLEN2 input pins. (Figure 2-4 on page 2-8 illustrates the clock circuitry of the 80C196NU.)
UART Universal asynchronous receiver and transmitter. A part of the serial I/O port.
WDT See watchdog timer.
word Any 16-bit unit of data.
WORD An unsigned, 16-bit variable with values from 0 through 216–1.
zero extension A method for converting data to a larger format by filling the upper bit positions with zeros.
Glossary-8




SIO port, 8-8 BAUD_VALUE, 8-11, C-42 BHE#, 13-3, B-7
See also port 2, BREQ#, HLDA#,
HOLD# software protection, 13-32 timing parameters, 13-30 Byte accesses
during bus hold, 13-30 See also write-control signals BIT, defined, 4-2 Bit-test instructions, A-21 Block diagram
and write-control signals, 13-34 BYTE, defined, 4-2
address/data bus, 7-11 clock circuitry, 2-7 core, 2-3 core and peripherals, 2-2 EPA, 10-2 EPORT, 7-13 I/O ports, 7-1, 7-5, 7-11, 7-13, 7-15 SIO port, 8-1, 10-2 Block transfer mode‚ See PTS BMOV instruction, A-2, A-9, A-51, A-56 BMOVI instruction, A-3, A-9, A-10, A-51, A-56 BR (indirect) instruction, A-2, A-10, A-51, A-57,
C Call instructions, A-57, A-64, A-65 Carry (C) flag, 4-5, A-4, A-5, A-11, A-22, A-23,
A-24, A-25, A-36 Cascading timers, 10-6 CCBs, 5-6, 5-7, 11-8, 13-11, 13-14
fetching, 13-14, 13-17, 13-26 CCR0, 12-2 CCRs, 5-7, 11-8, 12-6, 12-7, 13-14 Chip configuration, See CCBs, CCRs Chip select, 13-1
address-range size, 13-9 base address, 13-9 conditions after reset, 13-11 example, 13-9, 13-12 initializing, 13-11, 13-17 overlapping ranges, 13-9, 13-11 overview, 2-6 registers, 13-11–13-12 Clear, defined, 1-3 CLKOUT, 12-1, 13-3, 13-18, 13-22, B-7
A-64 BREQ#, 13-3, 13-30, B-7 Bulletin board system (BBS), 1-9 Bus contention, See address/data bus, contention Bus controller, 2-5 Bus width, 13-5
8- and 16-bit comparison, 13-18–13-22 and write-control signals, 13-34 CCB0 fetch, 13-17 control bit, 13-11, 13-17 selecting, 13-1 BUSCON0, C-49, C-52 BUSCON1, C-50, C-52 BUSCON2, C-50, C-52 BUSCON3, C-50, C-52 BUSCON4, C-50, C-52 BUSCON5, C-50, C-53 BUSCONx, 13-10, 13-11, 13-26
and HOLD#, 13-30 and internal timing, 2-8 and interrupts, 6-6 and READY, 13-27 considerations, 7-10 reset status, 7-4 Clock
external, 11-7 generator, 11-7 internal, and idle mode, 12-5, 12-6, 12-7 modes (80C196NU), 12-13 phases, internal, 2-9 slow, 10-6 CLR instruction, A-2, A-11, A-47, A-53, A-60 CLRB instruction, A-2, A-11, A-47, A-53, A-60 CLRC instruction, A-3, A-11, A-52, A-59, A-67 CLRVT instruction, A-3, A-11, A-52, A-59, A-67
example, 13-12 Bus-hold protocol, 13-1, 13-30–13-33
and code execution, 13-33 and interrupts, 13-33 and reset, See reset disabling, 13-32 enabling, 13-32 hold latency, 13-32 regaining bus control, 13-33
Baud-rate generator · signals, 13-30 · Index-2

CMP instruction, A-3, A-11, A-49, A-53, A-60 CMPB instruction, A-3, A-12, A-50, A-53, A-60 CMPL instruction, A-2, A-12, A-51, A-53, A-60 Code execution, 2-4, 2-5 Code fetches, 5-25 CompuServe forums, 1-10 Conditional jump instructions, A-5 CON_REG0, C-50, C-53 Constants, near, 5-24 CPU, 2-3 CS5:0#, B-7
DIVU instruction, A-3, A-14, A-49, A-54, A-61 DIVUB instruction, A-3, A-14, A-50, A-54, A-61 DJNZ instruction, A-2, A-5, A-14, A-51, A-58,
A-66 DJNZW instruction, A-2, A-5, A-15, A-51, A-58,
A-66 Documents, related, 1-5–1-8 DOUBLE-WORD, defined, 4-3 DPTS instruction, A-3, A-15, A-52, A-59, A-67
during bus hold, 13-30 Customer service, 1-8
after reset, 13-18 EBMOVI instruction, 4-5, A-2, A-16, A-51, A-56 EBR (indirect) instruction, 4-5, A-2, A-16, A-51,
A-57, A-64 ECALL instruction, 4-5, A-2, A-17, A-52, A-57,
far, 5-24 fetches, 5-26 near, 5-24 types, 4-1–4-5
A-64, A-65 EDAR, 7-13 EE opcode, and unimplemented opcode interrupt,
A-3, A-52 EI instruction, 6-10, A-3, A-17, A-52, A-59, A-67 EJMP instruction, 4-5, A-2, A-17, A-52, A-57,
addressing restrictions, 4-1 converting between, 4-4 defined, 4-1 iC-96, 4-1 PLM-96, 4-1 signed and unsigned, 4-1, 4-4 values permitted, 4-1 Data instructions, A-56, A-63 Datasheets
A-64 ELD instruction, 4-5, A-3, A-18, A-52, A-56, A-63 ELDB instruction, 4-5, A-3, A-18, A-52, A-56,
and PTS, 10-11 block diagram, 10-2 capture data overruns, 10-21, C-22 capture/compare modules, 10-8
online, 1-10 ordering, 1-7 Deassert, defined, 1-3 DEC instruction, A-2, A-12, A-47, A-53, A-60 DECB instruction, A-2, A-12, A-47, A-53, A-60 DEMUX bit, 13-11, 13-17 Device
programming, 10-18 choosing capture or compare mode, 10-19,
programming, 10-18 configuring pins, 10-2 controlling the clock source and direction,
minimum hardware configuration, 11-1 reset, 11-8, 11-9, 11-10, 11-11, 13-33 signal descriptions, B-6 DI instruction, A-3, A-13, A-52, A-59, A-67 Digital-to-analog converter, 9-10 Direct addressing, 4-7, 4-11, 5-11
10-16, 10-17, C-46, C-47 determining event status, 10-22 enabling a timer/counter, 10-16, 10-17, C-46,
C-47 enabling remapping for PWM, 10-19, C-20 re-enabling the compare event, 10-20, C-21 resetting the timer in compare mode, 10-21,
and register RAM, 5-11 and windows, 5-13, 5-21 DIV instruction, A-13, A-52, A-54, A-61 DIVB instruction, A-13, A-52, A-54, A-61
C-20 compare modules · Index-3

resetting the timers, 10-21, C-22 selecting the capture/compare event, 10-20,
EST instruction, 4-6, A-3, A-19, A-47, A-56, A-63 ESTB instruction, 4-6, A-3, A-19, A-47, A-56,
C-21 selecting the time base, 10-19, C-20 selecting up or down counting, 10-16, 10-17,
A-63 Event, 10-1 Event processor array‚ See EPA EXT instruction, A-2, A-19, A-47, A-53, A-60 EXTB instruction, A-2, A-20, A-47, A-53, A-60 Extended address lines, 5-1 Extended addressing, 2-4, 2-11, 4-11, 5-1, 5-23
C-46, C-47 signals, 10-2 using for PWM, 6-26, 6-32 See also port 1, port 6, PWM, timer/counters EPA0_CON, C-50, C-53 EPA0_TIME, C-50, C-53 EPA1_CON, 10-19, C-20, C-50, C-53 EPA1_TIME, C-50, C-53 EPA2_CON, C-50, C-53 EPA2_TIME, C-50, C-53 EPA3:0, B-8 EPA3_CON, 10-19, C-20, C-50, C-53 EPA3_TIME, C-50, C-53 EPA_MASK, C-50, C-53 EPA_PEND, C-50, C-53 EPAx_CON, 10-3
code execution, 4-5 instructions, 4-5, 4-6, 5-24 port‚ See EPORT program counter, 2-6 External memory, 5-2
fetching code, 5-25 flash, example in 1-Mbyte mode, 5-31 RAM, example in 1-Mbyte mode, 5-31 RAM, example in 64-Kbyte mode, 5-27, 5-29 EXTINT, 6-3
and idle mode, 12-6 and powerdown mode, 12-6, 12-8 hardware considerations, 12-9 EXTINT3:0, B-8 EXTINTx, 12-1
settings and operations, 10-18 EPAx_TIME, 10-3 EPC, 2-6, 5-23, 5-25, 7-13 EPORT, 2-6, 2-11, 5-1, 5-23, 7-11
and external address, 13-1 block diagram, 7-13 complementary output mode, 7-14 configuration register settings, 7-17 configuring pins, 7-17
and inhibiting interrupts, 6-7 Flash memory, See external memory, flash Floating point library, 4-5 Formulas
for extended address, 7-17 for I/O, 7-17 considerations, 7-18, 7-19 input buffers, 7-19 input mode, 7-16 logic tables, 7-16 open-drain output mode, 7-14 operation, 7-12 output enable, 7-14 overview, 7-1 pins, 7-11 reset, 7-14 SFRs, 7-12 structure, 7-15 EPORT.3:0, B-8 EPTS instruction, 6-10, A-3, A-18, A-52, A-59,
capacitor size (powerdown circuit), 12-11 clock period (t), 2-9 PH1 and PH2 frequency, 2-9 PWM duty cycle, 6-26 PWM frequency, 6-26 state time, 2-9 FPAL-96, 4-5 Frequency (f), 2-9 FXTAL1, 2-9
A-67 ESD protection, 7-4, 7-14, 11-5
addressing modes, 4-6 · Index-4

device considerations, 11-1–11-11 device reset, 11-8, 11-9, 11-10, 11-11 interrupt processor, 2-6, 6-1 minimum configuration, 11-1 NMI considerations, 6-6 noise protection, 11-4 reset instruction, 4-14 SIO port considerations, 8-6 HLDA#, 13-4, 13-30, B-8 HLDEN bit, 5-14, 13-32 Hold latency, See bus-hold protocol HOLD#, 13-4, 13-30, B-9
and PSW flags, A-5 code execution, 2-4, 2-5 conventions, 1-3 differences, 4-5 execution times, A-60–A-61 lengths, A-53–A-60 opcode map, A-2–A-3 opcodes, A-47–A-52 overview, 4-1–4-5 protected instructions, 6-7 reference, A-1–A-3 See also RISM INTEGER, defined, 4-3 Interrupts, 6-1–6-36
considerations, 7-9 Hypertext manuals and datasheets, downloading,
and bus-hold, See bus-hold protocol controller, 2-6, 6-1 end-of-PTS, 6-18 inhibiting, 6-7 latency, 6-7–6-9, 6-23
after reset, 13-18 Idle mode, 2-12, 12-5–12-6, 12-7
calculating, 6-8 pending registers‚ See EPA_PEND,
entering, 12-6 exiting, 12-6, 12-7 timeout control, 10-6 IDLPD instruction, A-2, A-20, A-52, A-59, A-67
EPA_PEND1, INT_PEND, INT_PEND1 priorities, 6-4, 6-5
IDLPD #1, 12-6 IDLPD #2, 12-8 IDLPD #3, 12-6 illegal operand, 11-9, 11-11 Immediate addressing, 4-7 INC instruction, A-2, A-21, A-47, A-53, A-60 INCB instruction, A-2, A-21, A-47, A-53, A-60 Indexed addressing, 4-11
modifying, 6-13–6-15 procedures, PLM-96, 4-13 processing, 6-2 programming, 6-10–6-15 selecting PTS or standard service, 6-10 service routine
processing, 6-14 sources, 6-5 unused inputs, 11-2 vectors, 5-7, 6-1, 6-5
and register RAM, 5-11 and windows, 5-21 Indirect addressing, 4-7
memory locations, 5-6, 5-7 Italics, defined, 1-4
and register RAM, 5-11 with autoincrement, 4-8 Input pins
J JBC instruction, A-2, A-5, A-21, A-47, A-58, A-66 JBS instruction, A-3, A-5, A-21, A-47, A-58, A-66 JC instruction, A-3, A-5, A-22, A-51, A-58, A-66 JE instruction, A-3, A-5, A-22, A-51, A-58, A-66 JGE instruction, A-2, A-5, A-22, A-51, A-58, A-66 JGT instruction, A-2, A-5, A-23, A-51, A-58, A-66 JH instruction, A-3, A-5, A-23, A-51, A-58, A-66 JLE instruction, A-3, A-5, A-23, A-51, A-58, A-66 JLT instruction, A-3, A-5, A-24, A-51, A-58, A-66
level-sensitive, B-6 sampled, B-6 INST, 13-4, B-9
after reset, 13-18 Instruction fetch
reset location, 5-2 See also 1-Mbyte mode, 64-Kbyte mode Instruction set, 4-1
additions, 4-5–4-6 · Index-5

JNC instruction, A-2, A-5, A-24, A-51, A-58,
Miller effect, 11-7 Mode 0, SIO, 8-4, 8-5 Mode 1, SIO, 8-5, 8-6 Mode 2, SIO, 8-5, 8-7, 8-8 Mode 3, SIO, 8-5, 8-7, 8-8 MODE64 bit, 5-23 MUL instruction, 3-1, A-29, A-52, A-54, A-61 MULB instruction, A-29, A-30, A-52, A-54, A-61 Multiplication instructions
A-66 JNE instruction, A-2, A-5, A-24, A-51, A-58, A-66 JNH instruction, A-2, A-5, A-25, A-51, A-58,
A-66 JNST instruction, A-2, A-5, A-25, A-51, A-58,
A-66 JNV instruction, A-2, A-5, A-25, A-51, A-58,
A-66 JNVT instruction, A-2, A-5, A-26, A-51, A-58,
multiply/accumulate example code, 3-2 See also MUL instruction, MULU instruction Multiprocessor communications
A-66 JST instruction, A-3, A-5, A-26, A-51, A-58, A-66 Jump instructions, A-64
SIO port, 8-7, 8-8 MULU instruction, 3-1, A-3, A-30, A-48, A-49,
conditional, A-5, A-58, A-66 unconditional, A-57 JV instruction, A-3, A-5, A-26, A-51, A-58, A-66 JVT instruction, A-3, A-5, A-27, A-51, A-58, A-66
A-52, A-54, A-61 MULUB instruction, A-3, A-31, A-48, A-49,
L Latency‚ See bus-hold protocol‚ interrupts LCALL instruction, A-3, A-27, A-52, A-57, A-65 LD instruction, A-2, A-27, A-50, A-56, A-63 LDB instruction, A-2, A-28, A-50, A-56, A-63 LDBSE instruction, A-3, A-28, A-50, A-56, A-63 LDBZE instruction, A-3, A-28, A-50, A-56, A-63 Level-sensitive input, B-6 Literature, 1-11 LJMP instruction, A-2, A-28, A-52, A-57, A-64 Logical instructions, A-54, A-61 LONG-INTEGER, defined, 4-4 Lookup tables, software protection, 4-14
N Naming conventions, 1-3–1-4 NEG instruction, A-2, A-31, A-47, A-54, A-61 Negative (N) flag, A-4, A-5, A-22, A-23, A-24 NEGB instruction, A-2, A-31, A-47, A-54, A-61 NMI, 6-3, 6-4, 6-6, B-9
and bus-hold protocol, 13-33 hardware considerations, 6-6 Noise, reducing, 7-1, 7-4, 11-4, 11-5, 11-6 Nonextended addressing, 5-23 NOP instruction, 4-14, A-3, A-31, A-52, A-59,
A-67 two-byte‚ See SKIP instruction NORML instruction, 4-5, A-3, A-32, A-47, A-59,
M Manual contents, summary, 1-1 Manuals, online, 1-10 Math features, 3-1–3-6 Measurements, defined, 1-5 Memory bus, 2-5 Memory configuration, examples, 5-27–5-32 Memory controller, 2-3, 2-5 Memory map, 5-3
A-66 NOT instruction, A-2, A-32, A-47, A-54, A-61 Notational conventions, 1-3–1-4 NOTB instruction, A-2, A-32, A-47, A-54, A-61 Numbers, conventions, 1-4
Example of 1-Mbyte mode, 5-32 Example of 64-Kbyte mode, 5-28, 5-30 Memory, external, 13-1–13-45
entering, 12-12 exiting, 12-12 Opcodes, A-47
interface signals, 13-2 Memory, reserved, 5-6, 5-7 Microcode engine, 2-3
EE, and unimplemented opcode interrupt,
A-3, A-52 FE, and signed multiply and divide, A-3
Index-6

map, A-2 reserved, A-3, A-52 Operand types, See data types Operands, addressing, 4-12 Operating modes, 2-12
page number and EPORT, 5-23 Parameters, passing to subroutines, 4-13 Parity, 8-6, 8-7 PC (program counter), 2-4, 5-23
extended, 2-6, 5-23, 5-25, 7-13 master, 2-4, 2-5 slave, 2-5, 2-6 Period (t), 2-9 Peripherals, internal, 2-11 Pin diagrams, B-1 PLLEN2:1, 2-9, 12-2, B-10 PLM-96
See also 1-Mbyte mode, 64-Kbyte mode OR instruction, A-2, A-33, A-49, A-54, A-61 ORB instruction, A-2, A-33, A-49, A-54, A-61 Oscillator
and powerdown mode, 12-7 external crystal, 11-6 on-chip, 11-5 Overflow (V) flag, A-4, A-5, A-25, A-26 Overflow-trap (VT) flag, A-4, A-5, A-11, A-26,
conventions, 4-11, 4-12, 4-13 interrupt procedures, 4-13 POP instruction, A-3, A-33, A-51, A-55, A-62 POPA instruction, A-2, A-34, A-52, A-55, A-62 POPF instruction, A-2, A-34, A-52, A-55, A-62 Port 1, 2-11, B-9
See also port 1 P1_DIR, C-50, C-53 P1_MODE, C-50, C-53 P1_PIN, C-50, C-53 P1_REG, C-50, C-53 P2.2 considerations, 12-9 P2.7:0, B-9
considerations, 7-9 input buffer, 7-4 logic tables, 7-6 operation, 7-1, 7-3 overview, 7-1 SFRs, 7-3 See also EPA Port 2, 2-11, B-9
See also port 2 P2_DIR, C-50, C-53 P2_MODE, C-50, C-53 P2_PIN, C-50, C-53 P2_REG, C-50, C-53 P3.7:0, B-9
considerations, 7-9 operation, 7-1, 7-3 overview, 7-1 P2.2 considerations, 7-9 P2.4 considerations, 7-9 P2.5 considerations, 7-9 P2.7 considerations, 7-10 P2.7 reset status, 7-4, 7-10 SFRs, 7-3 See also SIO port Port 3
See also port 3 P3_DIR, C-50, C-53 P3_MODE, C-50, C-53 P3_PIN, C-50, C-53 P3_REG, C-50, C-53 P4.3:0, B-9
See also port 4 P4_DIR, C-51, C-53 P4_MODE, C-51, C-53 P4_PIN, C-51, C-53 P4_REG, C-51, C-53 Pages (memory), 5-1, 5-2
considerations, 7-10 operation, 7-1, 7-3 overview, 7-1 SFRs, 7-3 Port 4
considerations, 7-10 operation, 7-1, 7-3, 7-10 overview, 7-1 SFRs, 7-3 Port, serial‚ See SIO port Ports, general-purpose I/O, 2-11
page 00H, 5-3, 5-22 page 0FH, 5-2 page FFH, 5-2, 5-25
accessing, 5-22 · Index-7

Power consumption, reducing, 2-12, 12-7 Powerdown mode, 2-12, 12-7–12-12
clock prescaler, 9-4 D/A converter, 9-10 duty cycle, 9-5 enabling outputs, 9-9 generating, 10-15 generating analog outputs, 9-9 modes, 6-26–6-36 output period, 9-3 overview, 9-1 programming duty cycle, 9-5 remap mode, 6-32 toggle mode, 6-27 typical waveforms, 9-5 waveform, 6-27 with dedicated timer/counter, 10-15 See also EPA‚ PTS PWM0, 9-9 PWM0_CONTROL, C-51, C-54 PWM1, 9-9 PWM1_CONTROL, C-51, C-54 PWM2, 9-9 PWM2:0, 9-9, B-10 PWM2_CONTROL, C-51, C-54
circuitry, external, 12-11 controlling, 13-15 disabling, 12-6, 12-7 enabling, 12-7 entering, 12-6, 12-7 exiting, 12-8, 12-11
with EXTINT, 12-8–12-12 with RESET#, 12-8 Prefetch queue, 2-5, 5-23 Priority encoder, 6-4 Priority, instruction fetch versus data fetch, 5-23 Processor status word‚ See PSW Product information, ordering, 1-6 Program counter‚ See PC Program memory, 5-2, 5-5, 5-25 PSW, 2-4, 4-13, 6-12, C-25
flags, and instructions, A-5 PTS, 2-4, 2-6, 6-1
and EPA, 6-26–6-36 block transfer mode, 6-23 control block, See PTSCB cycle execution time, 6-10 cycle, defined, 6-23 instructions, A-59, A-67 interrupt latency, 6-9 interrupt processing flow, 6-2 PWM modes, 6-26–6-36 PWM remap mode, 6-32 PWM toggle mode, 6-27, 10-13, 10-14, 10-15 routine, defined, 6-1 single transfer mode, 6-20 vectors, memory locations, 5-6, 5-7 See also PWM PTSCB, 6-1, 6-4, 6-7, 6-18, 6-23
R RALU, 2-4–2-5, 5-11 RAM, internal
register RAM, 5-11 RD#, 13-4, 13-36, B-10
during bus hold, 13-30 READY, 13-4, 13-26–13-30, B-10
after reset, 13-18 for CCB fetches, 13-17 timing requirements, 13-27 Ready control, 13-26–13-30 REAL variables, 4-5 Register bits
memory locations, 5-7 PTSSEL, 6-7, 6-10, 6-18 PTSSRV, 6-7, 6-18 Pulse-width modulator, See PWM PUSH instruction, A-3, A-34, A-51, A-55, A-62 PUSHA instruction, A-2, A-35, A-52, A-55, A-62 PUSHF instruction, A-2, A-35, A-52, A-55, A-62 PWM, 6-26, 9-1
naming conventions, 1-4 reserved, 1-4 Register file, 2-3, 5-9
and cascading timer/counters, 10-6 block diagram, 9-1 calculating duty cycle, 6-26 calculating frequency, 6-26
and windows, 5-10, 5-13 lower, 5-10, 5-11, 5-13 upper, 5-10, 5-11
Index-8

See also windows Register RAM
SP_STATUS, 8-4, 8-14 T1CONTROL, 10-4 T2CONTROL, 10-4 TIMER1, 10-4 TIMER2, 10-4 using, 4-12 WSR, 6-14 WSR1, 5-15 REMAP bit
and idle mode, 12-5 and powerdown mode, 12-7 Registers
ACC_0x, 3-4 ACC_STAT, 3-5 allocating, 4-12 EPA_MASK, 10-3 EPA_PEND, 10-3 EP_DIR, 7-12, 7-14, 7-16, 7-17 EP_MODE, 7-12, 7-14, 7-16, 7-17, 7-18 EP_PIN, 7-12, 7-14, 7-16, 7-17 EP_REG, 7-12, 7-16, 7-17, 7-18
See ROM, internal (83C196NP) Reserved bits, defined, 1-4 Reserved memory, See memory, reserved Reset, 11-9, 13-14, 13-16
and bus-hold protocol, 13-33 and CCB fetches, 5-7 and chip select, 13-11 and operating mode selection, 5-23 circuit diagram, 11-10 status
considerations, 7-18 INT_MASK, 6-3, 6-10, 6-14, 8-2, 10-3, 12-2 INT_MASK1, 6-3, 6-10, 6-14, 10-3, 12-3 INT_PEND, 6-3, 6-4, 6-15, 8-2, 10-3, 12-3 INT_PEND1, 6-4, 6-15, 10-3, 12-3 naming conventions, 1-4 P1_DIR, 10-3 P1_MODE, 10-4
CLKOUT/P2.7, 7-4, 7-10 with illegal IDLPD operand, 11-11 with RESET# pin, 11-9 with RST instruction, 11-9, 11-11 RESET#, 11-1, 12-2, B-10
considerations, 7-9 P1_PIN, 10-4 P1_REG, 10-4 P2_DIR, 8-3, 12-3 P2_MODE, 8-3, 12-3
and CCB fetch, 11-8 and device reset, 11-8, 11-9, 11-10, 13-33 and ONCE mode, 12-12 and powerdown mode, 12-8 pins after deassertion, 13-18 Resonator, ceramic, 11-6 RET instruction, A-2, A-35, A-52, A-57, A-64,
considerations, 7-9, 7-10 P2_PIN, 8-2, 8-3 P2_REG, 8-3, 12-3
considerations, 7-10 P3_DIR, 12-3 P3_MODE, 12-3 P3_REG, 12-3 PSW, 6-4, 6-14 PTSCON, 6-19 PTSCOUNT, 6-18 PTSSEL, 6-4 PTSSRV, 6-4 Px_DIR, 7-2, 7-6, 7-7, 7-8 Px_MODE, 7-2, 7-6, 7-7, 7-8 Px_PIN, 7-2, 7-4, 7-6 Px_REG, 7-2, 7-6, 7-7, 7-8 RALU, 2-4 SBUF_RX, 8-3 SBUF_TX, 8-3 SP_BAUD, 8-3, 8-11, 8-12, 8-13 SP_CON, 8-3, 8-9
A-65 ROM, internal (83C196NP), 5-2, 5-5, 5-22, 5-25
REMAP bit, 5-22 RPD, 12-2, B-11 RST instruction, 4-14, 11-9, 11-11, A-3, A-36,
and SIO port mode 0, 8-4, 8-5 and SIO port modes 1, 2, and 3, 8-6
S Sampled input, B-6 SBUF_RX, C-51, C-54 SBUF_TX, C-51, C-54 SCALL instruction, A-3, A-36, A-47, A-53, A-57,
Index-9

Serial I/O port‚ See SIO port Set, defined, 1-3 SETC instruction, A-3, A-36, A-52, A-59, A-67 SFRs
SFRs, 8-2 signals, 8-2 status, 8-13–8-15 transmit interrupt (TI) flag, 8-15 transmitter, 8-1 See also mode 0‚ mode 1‚ mode 2‚ mode 3‚
and idle mode, 12-5 and powerdown mode, 12-7 CPU, 5-12
port 2 SJMP instruction, A-2, A-41, A-47, A-53, A-57,
table of, 5-12 peripheral, 5-7
A-64 SKIP instruction, A-2, A-41, A-47, A-59, A-67 Software
and windows, 5-13 table of, 5-8 reserved, 4-12, 5-9 with indirect or indexed operations, 4-12, 5-9 with read-modify-write instructions, 5-7 Shift instructions, A-59, A-66 SHL instruction, A-3, A-37, A-47, A-59, A-66 SHLB instruction, A-3, A-37, A-47, A-59, A-66 SHLL instruction, A-3, A-38, A-47, A-59 SHORT-INTEGER, defined, 4-2 SHR instruction, A-3, A-38, A-47, A-59, A-66 SHRA instruction, A-3, A-39, A-47, A-59, A-66 SHRAB instruction, A-3, A-39, A-47, A-59, A-66 SHRAL instruction, A-3, A-40, A-47, A-59, A-66 SHRB instruction, A-3, A-40, A-47, A-59, A-66 SHRL instruction, A-3, A-41, A-47, A-59, A-66 Signals
addressing modes, 4-11 conventions, 4-11–4-13 device reset, 11-11 interrupt service routines, 6-14 linking subroutines, 4-13 protection, 4-14, 13-32 trap interrupt, 6-4, 6-5, 6-7 SP_BAUD, C-51, C-54 SP_CON, 8-9, C-51, C-54 Special instructions, A-59, A-67 Special operating modes
SFRs, 12-2 Special-purpose memory, 5-2, 5-5, 5-6 SP_STATUS, 8-14, C-51, C-54 ST instruction, A-2, A-42, A-51, A-56, A-63 Stack instructions, A-55, A-62 Stack pointer, 5-11, 13-11
descriptions, B-6–B-12 naming conventions, 1-4 Single transfer mode‚ See PTS SIO port, 2-11, 8-1
and subroutine call, 5-11 initializing, 5-12 Standby mode, 12-6 State time, defined, 2-9 STB instruction, A-2, A-42, A-51, A-56, A-63 Sticky bit (ST) flag, 4-5, A-4, A-5, A-25, A-26 SUB instruction, A-3, A-42, A-48, A-53, A-60 SUBB instruction, A-3, A-43, A-48, A-49, A-53,
9-bit data‚ See mode 2‚ mode 3 block diagram, 8-1, 10-2 calculating baud rate, 8-12 enabling interrupts, 8-13 enabling parity, 8-8 framing error, 8-14 half-duplex considerations, 8-6 interrupts, 8-5, 8-8, 8-15 mode 0, 8-4–8-5 mode 1, 8-5, 8-6 mode 2, 8-5, 8-6, 8-7 mode 3, 8-5, 8-6, 8-7 multiprocessor communications, 8-7, 8-8 overrun error, 8-14 programming, 8-8 receive interrupt (RI) flag, 8-15 receiver, 8-1 selecting baud rate, 8-8–8-12
A-60 SUBC instruction, A-3, A-43, A-50, A-53, A-60 SUBCB instruction, A-3, A-43, A-50, A-53, A-60 Subroutines
linking, 4-13 nested, 5-12
Index-10

T1DIR, 10-2, B-11 T2CLK, 10-2, B-11 T2CONTROL, C-51, C-54 T2DIR, 10-2, B-11 Technical support, 1-11 Terminology, 1-3 TIJMP instruction, A-2, A-44, A-51, A-57, A-64 Timer/counters, 2-11, 10-5, 10-6
for CCB0 fetch, 13-17 Window selection register‚ See WSR, WSR1 Windows, 5-1, 5-13–5-21
addressing, 5-18 and addressing modes, 5-21 base address, 5-16, 5-18 examples, 5-18–5-21 nonwindowable locations, 5-19 selecting, 5-14 setting up with linker loader, 5-19 table of, 5-15, 5-17 Word accesses, and write-control signals, 13-34 WORD, defined, 4-3 World Wide Web, 1-11 WR#, 13-5, B-12
and PWM, 10-12, 10-13, 10-14, 10-15 cascading, 10-6 configuring pins, 10-2 count rate, 10-6 resolution, 10-6 SFRs, 10-3 See also EPA TIMER1, C-51, C-54 TIMER2, C-51, C-54 Timing
after reset, 13-18 during bus hold, 13-30 See also write-control signals WRH#, 13-3, 13-5, 13-33, 13-35, B-12
HLDA#, 13-30 HOLD#, 13-30 instruction execution, A-60–A-61 internal, 2-7, 2-9 interrupt latency, 6-7–6-10, 6-23 PTS cycles, 6-10 READY, 13-27 SIO port mode 0, 8-5 SIO port mode 1, 8-6 SIO port mode 2, 8-7 SIO port mode 3, 8-7 TRAP instruction, 6-5, A-2, A-45, A-52, A-57,
See also write-control signals Write strobe mode
example, 13-36 Write-control modes, 13-1, 13-33–13-36
byte writes and word writes, 13-35 standard, 13-33 Write-control signals, 13-33, 13-34
decoding logic, 13-34 WRL#, 13-5, 13-33, 13-35, B-12
A-64, A-65 TRAP interrupt, 6-4 TXD, 8-2, B-11
See also write-control signals WS0 and WS1, 13-11, 13-26 WSR, 5-14, 13-32 WSR1, 5-12, 5-13, 5-15, 5-18
and SIO port mode 0, 8-4
X X, defined, 1-5 x, defined, 1-4 XCH instruction, A-2, A-3, A-45, A-47, A-56,
6-7 Units of measure, defined, 1-5 Universal asynchronous receiver and transmitter‚
A-63 XCHB instruction, A-2, A-3, A-45, A-47, A-56,
A-63 XOR instruction, A-2, A-46, A-49, A-54, A-61 XORB instruction, A-2, A-46, A-49, A-50, A-54,
and Miller effect, 11-7
See UART · Index-11

and SIO baud rate, 8-12, 8-13 hardware connections, 11-6, 11-7 XTAL2, 11-2, B-12
hardware connections, 11-6, 11-7
Z Zero (Z) flag, A-4, A-5, A-22, A-23, A-24, A-25,
Index-12
Owners and our team usually reply within a day — and your question helps the next person too.
Be the first to ask — other owners or our team will answer.