Intel Microscope Magnifier 8XC196MC User Manual

8XC196MC, 8XC196MD,  
8XC196MH Microcontroller  
Users Manual  
Download from Www.Somanuals.com. All Manuals Search And Download.  
We Value Your Opinion  
Dear Intel Customer:  
We have updated the information that was provided in the 1992 version of the 8XC196MC Users  
Manual, added information about the 8XC196MD and 8XC196MH, and corrected known errata.  
We hope these changes make it easier for you to use our products. Your feedback will help us to  
provide the information you need. We’ll use your responses to guide us in developing other man-  
uals and new versions of this one.  
Does the manual contain the information that you need? If not, what’s missing?  
What do you like the most about this manual?  
What do you like the least about this manual?  
How would you rate the overall quality? (1=awful, 2=average, 3=better than average) _________  
Name  
Title  
Company  
Address  
City, State or Country  
Zip Code or Postal Code  
Phone  
Fax  
Intel products used  
Type of application  
Please fax this form to (602)554-7436 or mail it to  
Marcia Bethel, Glenn Dotson, Robin Manelis, and Sue Ranta  
Technical Information Developers  
Intel Corporation, Mail Stop CH6-224  
5000 W. Chandler Blvd.  
Chandler, AZ 85226  
Download from Www.Somanuals.com. All Manuals Search And Download.  
-2  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC,  
8XC196MD, 8XC196MH  
Microcontroller  
User’s Manual  
August 2004  
Order Number 272181-003  
Download from Www.Somanuals.com. All Manuals Search And Download.  
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  
© INTEL CORPORATION, 1996  
Download from Www.Somanuals.com. All Manuals Search And Download.  
CONTENTS  
CHAPTER 1  
GUIDE TO THIS MANUAL  
1.1  
1.2  
1.3  
1.4  
MANUAL CONTENTS................................................................................................... 1-1  
NOTATIONAL CONVENTIONS AND TERMINOLOGY ................................................ 1-3  
RELATED DOCUMENTS .............................................................................................. 1-5  
ELECTRONIC SUPPORT SYSTEMS........................................................................... 1-8  
World Wide Web .....................................................................................................1-11  
TECHNICAL SUPPORT .............................................................................................. 1-11  
PRODUCT LITERATURE............................................................................................ 1-11  
1.4.4  
1.5  
1.6  
CHAPTER 2  
ARCHITECTURAL OVERVIEW  
2.1  
2.2  
2.3  
2.3.1  
2.3.2  
2.3.3  
TYPICAL APPLICATIONS............................................................................................. 2-1  
MICROCONTROLLER FEATURES.............................................................................. 2-1  
FUNCTIONAL OVERVIEW............................................................................................ 2-2  
CPU Control ..............................................................................................................2-4  
Register File ..............................................................................................................2-4  
Register Arithmetic-logic Unit (RALU) .......................................................................2-4  
2.3.3.1  
2.3.3.2  
2.3.4  
2.3.5  
Code Execution ....................................................................................................2-5  
Instruction Format ................................................................................................2-5  
Memory Interface Unit ...............................................................................................2-6  
Interrupt Service ........................................................................................................2-6  
2.4  
2.5  
2.5.1  
2.5.2  
2.5.3  
2.5.4  
2.5.5  
2.5.6  
2.5.7  
2.5.8  
INTERNAL TIMING........................................................................................................ 2-7  
INTERNAL PERIPHERALS........................................................................................... 2-8  
I/O Ports ....................................................................................................................2-9  
Serial I/O (SIO) Port ..................................................................................................2-9  
Event Processor Array (EPA) and Timer/Counters .................................................2-10  
Pulse-width Modulator (PWM) ................................................................................2-10  
Frequency Generator ..............................................................................................2-10  
Waveform Generator ..............................................................................................2-10  
Analog-to-digital Converter .....................................................................................2-11  
Watchdog Timer ......................................................................................................2-11  
SPECIAL OPERATING MODES ................................................................................. 2-11  
Reducing Power Consumption ...............................................................................2-11  
Testing the Printed Circuit Board ............................................................................2-11  
Programming the Nonvolatile Memory ....................................................................2-12  
2.6  
2.6.1  
2.6.2  
2.6.3  
iii  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
CHAPTER 3  
PROGRAMMING CONSIDERATIONS  
3.1  
3.1.1  
OVERVIEW OF THE INSTRUCTION SET.................................................................... 3-1  
BIT Operands ............................................................................................................3-2  
BYTE Operands ........................................................................................................3-2  
SHORT-INTEGER Operands ....................................................................................3-2  
WORD Operands ......................................................................................................3-2  
INTEGER Operands .................................................................................................3-3  
DOUBLE-WORD Operands ......................................................................................3-3  
LONG-INTEGER Operands ......................................................................................3-4  
Converting Operands ................................................................................................3-4  
Conditional Jumps ....................................................................................................3-4  
3.1.2  
3.1.3  
3.1.4  
3.1.5  
3.1.6  
3.1.7  
3.1.8  
3.1.9  
3.1.10 Floating Point Operations .........................................................................................3-4  
3.2  
ADDRESSING MODES................................................................................................. 3-5  
Direct Addressing ......................................................................................................3-6  
Immediate Addressing ..............................................................................................3-6  
Indirect Addressing ...................................................................................................3-6  
3.2.1  
3.2.2  
3.2.3  
3.2.3.1  
3.2.3.2  
3.2.4  
3.2.4.1  
3.2.4.2  
3.2.4.3  
Indirect Addressing with Autoincrement ...............................................................3-7  
Indirect Addressing with the Stack Pointer ...........................................................3-7  
Indexed Addressing ..................................................................................................3-7  
Short-indexed Addressing ....................................................................................3-7  
Long-indexed Addressing ....................................................................................3-8  
Zero-indexed Addressing .....................................................................................3-8  
3.3  
3.3.1  
3.3.2  
3.4  
3.4.1  
3.4.2  
3.4.3  
ASSEMBLY LANGUAGE ADDRESSING MODE SELECTIONS.................................. 3-9  
Direct Addressing ......................................................................................................3-9  
Indexed Addressing ..................................................................................................3-9  
SOFTWARE STANDARDS AND CONVENTIONS ....................................................... 3-9  
Using Registers .........................................................................................................3-9  
Addressing 32-bit Operands ...................................................................................3-10  
Linking Subroutines ................................................................................................3-10  
SOFTWARE PROTECTION FEATURES AND GUIDELINES .................................... 3-11  
3.5  
CHAPTER 4  
MEMORY PARTITIONS  
4.1  
4.1.1  
4.1.2  
4.1.3  
4.1.4  
MEMORY PARTITIONS ................................................................................................ 4-1  
External Devices (Memory or I/O) .............................................................................4-1  
Program and Special-purpose Memory ....................................................................4-1  
Program Memory ......................................................................................................4-2  
Special-purpose Memory ..........................................................................................4-3  
Reserved Memory Locations ...............................................................................4-3  
Interrupt and PTS Vectors ....................................................................................4-3  
Security Key .........................................................................................................4-4  
Chip Configuration Bytes (CCBs) .........................................................................4-4  
Special-function Registers (SFRs) ............................................................................4-4  
4.1.4.1  
4.1.4.2  
4.1.4.3  
4.1.4.4  
4.1.5  
iv  
Download from Www.Somanuals.com. All Manuals Search And Download.  
CONTENTS  
4.1.5.1  
4.1.5.2  
4.1.6  
4.1.6.1  
4.1.6.2  
4.1.6.3  
Memory-mapped SFRs ........................................................................................4-5  
Peripheral SFRs ...................................................................................................4-5  
Register File ..............................................................................................................4-9  
General-purpose Register RAM .........................................................................4-10  
Stack Pointer (SP) ..............................................................................................4-10  
CPU Special-function Registers (SFRs) .............................................................4-11  
4.2  
4.2.1  
4.2.2  
4.2.2.1  
4.2.2.2  
WINDOWING............................................................................................................... 4-12  
Selecting a Window ................................................................................................4-13  
Addressing a Location Through a Window .............................................................4-14  
32-byte Windowing Example ..............................................................................4-16  
64-byte Windowing Example ..............................................................................4-16  
128-byte Windowing Example ............................................................................4-16  
Unsupported Locations Windowing Example .....................................................4-16  
Using the Linker Locator to Set Up a Window ....................................................4-17  
Windowing and Addressing Modes .........................................................................4-19  
4.2.2.3  
4.2.2.4  
4.2.2.5  
4.2.3  
CHAPTER 5  
STANDARD AND PTS INTERRUPTS  
5.1  
5.2  
5.3  
5.3.1  
5.3.1.1  
5.3.1.2  
5.3.1.3  
5.3.2  
OVERVIEW OF INTERRUPTS...................................................................................... 5-1  
INTERRUPT SIGNALS AND REGISTERS ................................................................... 5-3  
INTERRUPT SOURCES AND PRIORITIES.................................................................. 5-4  
Special Interrupts ......................................................................................................5-6  
Unimplemented Opcode ......................................................................................5-6  
Software Trap .......................................................................................................5-6  
NMI .......................................................................................................................5-6  
External Interrupt Pin ................................................................................................5-6  
Multiplexed Interrupt Sources ...................................................................................5-7  
End-of-PTS Interrupts ...............................................................................................5-9  
5.3.3  
5.3.4  
5.4  
5.4.1  
5.4.2  
INTERRUPT LATENCY................................................................................................. 5-9  
Situations that Increase Interrupt Latency ................................................................5-9  
Calculating Latency .................................................................................................5-10  
5.4.2.1  
5.4.2.2  
5.5  
5.5.1  
5.5.2  
Standard Interrupt Latency .................................................................................5-10  
PTS Interrupt Latency ........................................................................................5-11  
PROGRAMMING THE INTERRUPTS......................................................................... 5-12  
Modifying Interrupt Priorities ...................................................................................5-18  
Determining the Source of an Interrupt ...................................................................5-20  
INITIALIZING THE PTS CONTROL BLOCKS............................................................. 5-24  
Specifying the PTS Count .......................................................................................5-25  
Selecting the PTS Mode .........................................................................................5-27  
Single Transfer Mode ..............................................................................................5-27  
Block Transfer Mode ...............................................................................................5-30  
A/D Scan Mode .......................................................................................................5-32  
5.6  
5.6.1  
5.6.2  
5.6.3  
5.6.4  
5.6.5  
5.6.5.1  
5.6.5.2  
5.6.5.3  
A/D Scan Mode Cycles ......................................................................................5-35  
A/D Scan Mode Example 1 ................................................................................5-35  
A/D Scan Mode Example 2 ................................................................................5-37  
v
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
5.6.6  
5.6.6.1  
5.6.6.2  
5.6.6.3  
5.6.6.4  
Serial I/O Modes .....................................................................................................5-37  
Synchronous SIO Transmit Mode Example .......................................................5-43  
Synchronous SIO Receive Mode Example ........................................................5-47  
Asynchronous SIO Transmit Mode Example .....................................................5-50  
Asynchronous SIO Receive Mode Example ......................................................5-55  
CHAPTER 6  
I/O PORTS  
6.1  
6.2  
6.2.1  
6.2.2  
6.3  
6.3.1  
6.3.2  
6.3.3  
6.3.4  
I/O PORTS OVERVIEW ................................................................................................ 6-1  
INPUT-ONLY PORTS 1 (MC, MD ONLY) AND 0.......................................................... 6-2  
Standard Input-only Port Operation ..........................................................................6-3  
Standard Input-only Port Considerations ..................................................................6-4  
BIDIRECTIONAL PORTS 1 (MH ONLY), 2, 5, AND 7 (MD ONLY)............................... 6-4  
Bidirectional Port Operation ......................................................................................6-6  
Bidirectional Port Pin Configurations .........................................................................6-9  
Bidirectional Port Pin Configuration Example .........................................................6-11  
Bidirectional Port Considerations ............................................................................6-12  
BIDIRECTIONAL PORTS 3 AND 4 (ADDRESS/DATA BUS)...................................... 6-14  
Bidirectional Ports 3 and 4 (Address/Data Bus) Operation .....................................6-15  
Using Ports 3 and 4 as I/O ......................................................................................6-16  
Design Considerations for Ports 3 and 4 ................................................................6-16  
STANDARD OUTPUT-ONLY PORT 6 ....................................................................... 6-16  
Output-only Port Operation .....................................................................................6-17  
Configuring Output-only Port Pins ..........................................................................6-17  
6.4  
6.4.1  
6.4.2  
6.4.3  
6.5  
6.5.1  
6.5.2  
CHAPTER 7  
SERIAL I/O (SIO) PORT  
7.1  
7.2  
7.3  
7.3.1  
7.3.1.1  
7.3.1.2  
7.3.2  
7.3.2.1  
SERIAL I/O (SIO) PORT FUNCTIONAL OVERVIEW ................................................... 7-1  
SERIAL I/O PORT SIGNALS AND REGISTERS .......................................................... 7-2  
SERIAL PORT MODES................................................................................................. 7-4  
Synchronous Modes (Modes 0 and 4) ......................................................................7-5  
Mode 0 .................................................................................................................7-5  
Mode 4 .................................................................................................................7-6  
Asynchronous Modes (Modes 1, 2, and 3) ...............................................................7-7  
Mode 1 .................................................................................................................7-7  
Mode 2 .................................................................................................................7-8  
Mode 3 .................................................................................................................7-9  
Mode 2 and 3 Timings ..........................................................................................7-9  
Multiprocessor Communications ..........................................................................7-9  
7.3.2.2  
7.3.2.3  
7.3.2.4  
7.3.2.5  
7.4  
7.4.1  
7.4.2  
7.4.3  
7.4.4  
PROGRAMMING THE SERIAL PORT........................................................................ 7-10  
Configuring the Serial Port Pins ..............................................................................7-10  
Programming the Control Register ..........................................................................7-10  
Programming the Baud Rate and Clock Source .....................................................7-12  
Enabling the Serial Port Interrupts ..........................................................................7-14  
vi  
Download from Www.Somanuals.com. All Manuals Search And Download.  
CONTENTS  
7.4.5  
Determining Serial Port Status ................................................................................7-15  
CHAPTER 8  
FREQUENCY GENERATOR  
8.1  
8.2  
8.2.1  
8.2.2  
8.2.3  
FUNCTIONAL OVERVIEW............................................................................................ 8-1  
PROGRAMMING THE FREQUENCY GENERATOR ................................................... 8-3  
Configuring the Output ..............................................................................................8-3  
Programming the Frequency ....................................................................................8-3  
Determining the Current Value of the Down-counter ................................................8-4  
APPLICATION EXAMPLE............................................................................................. 8-4  
8.3  
CHAPTER 9  
WAVEFORM GENERATOR  
9.1  
9.2  
9.3  
WAVEFORM GENERATOR FUNCTIONAL OVERVIEW.............................................. 9-1  
WAVEFORM GENERATOR SIGNALS AND REGISTERS........................................... 9-3  
WAVEFORM GENERATOR OPERATION.................................................................... 9-4  
Timebase Generator .................................................................................................9-4  
Phase Driver Channels .............................................................................................9-5  
Control and Protection Circuitry ................................................................................9-5  
Register Buffering and Synchronization ....................................................................9-6  
Operating Modes ......................................................................................................9-7  
9.3.1  
9.3.2  
9.3.3  
9.3.4  
9.3.5  
9.3.5.1  
9.3.5.2  
9.4  
9.4.1  
9.4.2  
9.4.3  
9.4.4  
Center-aligned Modes ..........................................................................................9-9  
Edge-Aligned Modes ..........................................................................................9-10  
PROGRAMMING THE WAVEFORM GENERATOR................................................... 9-12  
Configuring the Outputs ..........................................................................................9-12  
Controlling the Protection Circuitry and EXTINT Interrupt Generation ....................9-15  
Specifying the Carrier Period and Duty Cycle .........................................................9-16  
Specifying the Operating Mode and Dead Time and Starting the Counter .............9-17  
DETERMINING THE WAVEFORM GENERATOR’S STATUS ................................... 9-19  
ENABLING THE WAVEFORM GENERATOR INTERRUPTS..................................... 9-19  
DESIGN CONSIDERATIONS...................................................................................... 9-20  
Dead Time and Duty Cycle .....................................................................................9-20  
EXTINT Interrupts and Protection Circuitry .............................................................9-21  
PROGRAMMING EXAMPLE....................................................................................... 9-21  
9.5  
9.6  
9.7  
9.7.1  
9.7.2  
9.8  
CHAPTER 10  
PULSE-WIDTH MODULATOR  
10.1 PWM FUNCTIONAL OVERVIEW................................................................................ 10-1  
10.2 PWM SIGNALS AND REGISTERS ............................................................................. 10-2  
10.3 PWM OPERATION...................................................................................................... 10-3  
10.4 PROGRAMMING THE FREQUENCY AND PERIOD.................................................. 10-4  
10.5 PROGRAMMING THE DUTY CYCLE......................................................................... 10-6  
10.5.1 Sample Calculations ...............................................................................................10-7  
vii  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
10.5.2 Reading the Current Value of the Down-counter ....................................................10-7  
10.5.3 Enabling the PWM Outputs .....................................................................................10-8  
10.5.4 Generating Analog Outputs ..................................................................................10-10  
CHAPTER 11  
EVENT PROCESSOR ARRAY (EPA)  
11.1 EPA FUNCTIONAL OVERVIEW ................................................................................. 11-1  
11.2 EPA AND TIMER/COUNTER SIGNALS AND REGISTERS....................................... 11-2  
11.3 TIMER/COUNTER FUNCTIONAL OVERVIEW........................................................... 11-5  
11.3.1 Cascade Mode (Timer 2 Only) ................................................................................11-7  
11.3.2 Quadrature Clocking Modes ...................................................................................11-7  
11.4 EPA CHANNEL FUNCTIONAL OVERVIEW............................................................... 11-9  
11.4.1 Operating in Capture Mode ...................................................................................11-10  
11.4.1.1 EPA Overruns ..................................................................................................11-12  
11.4.1.2 Preventing EPA Overruns ................................................................................11-13  
11.4.2 Operating in Compare Mode .................................................................................11-13  
11.4.2.1 Generating a Low-speed PWM Output ............................................................11-13  
11.4.2.2 Generating the Highest-speed PWM Output ....................................................11-14  
11.5 PROGRAMMING THE EPA AND TIMER/COUNTERS............................................. 11-15  
11.5.1 Configuring the EPA and Timer/Counter Signals ..................................................11-15  
11.5.2 Programming the Timers .......................................................................................11-15  
11.5.3 Programming the Capture/Compare Channels .....................................................11-18  
11.5.4 Programming the Compare-only Channels ...........................................................11-22  
11.6 ENABLING THE EPA INTERRUPTS ........................................................................ 11-23  
11.7 DETERMINING EVENT STATUS.............................................................................. 11-24  
CHAPTER 12  
ANALOG-TO-DIGITAL (A/D) CONVERTER  
12.1 A/D CONVERTER FUNCTIONAL OVERVIEW........................................................... 12-1  
12.2 A/D CONVERTER SIGNALS AND REGISTERS ........................................................ 12-2  
12.3 A/D CONVERTER OPERATION ................................................................................. 12-3  
12.4 PROGRAMMING THE A/D CONVERTER.................................................................. 12-4  
12.4.1 Programming the A/D Test Register .......................................................................12-5  
12.4.2 Programming the A/D Result Register (for Threshold Detection Only) ...................12-5  
12.4.3 Programming the A/D Time Register ......................................................................12-6  
12.4.4 Programming the A/D Command Register ..............................................................12-7  
12.4.5 Enabling the A/D Interrupt .......................................................................................12-8  
12.5 DETERMINING A/D STATUS AND CONVERSION RESULTS.................................. 12-9  
12.6 DESIGN CONSIDERATIONS.................................................................................... 12-10  
12.6.1 Designing External Interface Circuitry ...................................................................12-10  
12.6.1.1 Minimizing the Effect of High Input Source Resistance ....................................12-11  
12.6.1.2 Suggested A/D Input Circuit .............................................................................12-12  
12.6.1.3 Analog Ground and Reference Voltages .........................................................12-12  
viii  
Download from Www.Somanuals.com. All Manuals Search And Download.  
CONTENTS  
12.6.1.4 Using Mixed Analog and Digital Inputs ............................................................12-13  
12.6.2 Understanding A/D Conversion Errors ..................................................................12-13  
CHAPTER 13  
MINIMUM HARDWARE CONSIDERATIONS  
13.1 MINIMUM CONNECTIONS ......................................................................................... 13-1  
13.1.1 Unused Inputs .........................................................................................................13-2  
13.1.2 I/O Port Pin Connections ........................................................................................13-2  
13.2 APPLYING AND REMOVING POWER....................................................................... 13-4  
13.3 NOISE PROTECTION TIPS........................................................................................ 13-4  
13.4 THE ON-CHIP OSCILLATOR CIRCUITRY ................................................................. 13-5  
13.5 USING AN EXTERNAL CLOCK SOURCE.................................................................. 13-7  
13.6 RESETTING THE DEVICE.......................................................................................... 13-8  
13.6.1 Generating an External Reset ...............................................................................13-10  
13.6.2 Issuing the Reset (RST) Instruction ......................................................................13-12  
13.6.3 Issuing an Illegal IDLPD Key Operand .................................................................13-12  
13.6.4 Generating Wait States .........................................................................................13-12  
13.6.5 Enabling the Watchdog Timer ...............................................................................13-12  
CHAPTER 14  
SPECIAL OPERATING MODES  
14.1 SPECIAL OPERATING MODE SIGNALS AND REGISTERS..................................... 14-1  
14.2 REDUCING POWER CONSUMPTION ....................................................................... 14-3  
14.3 IDLE MODE................................................................................................................. 14-4  
14.4 POWERDOWN MODE................................................................................................ 14-5  
14.4.1 Enabling and Disabling Powerdown Mode ..............................................................14-5  
14.4.2 Entering Powerdown Mode .....................................................................................14-6  
14.4.3 Exiting Powerdown Mode .......................................................................................14-6  
14.4.3.1 Driving the V Pin Low ......................................................................................14-6  
pp  
14.4.3.2 Generating a Hardware Reset ...........................................................................14-6  
14.4.3.3 Asserting the External Interrupt Signal ...............................................................14-7  
14.4.3.4 Selecting R and C ...........................................................................................14-8  
1
1
14.5 ONCE MODE............................................................................................................. 14-10  
14.6 RESERVED TEST MODES....................................................................................... 14-11  
CHAPTER 15  
INTERFACING WITH EXTERNAL MEMORY  
15.1 EXTERNAL MEMORY INTERFACE SIGNALS AND REGISTERS ............................ 15-1  
15.2 CHIP CONFIGURATION REGISTERS AND CHIP CONFIGURATION BYTES ......... 15-5  
15.3 BUS WIDTH AND MULTIPLEXING........................................................................... 15-10  
15.3.1 Timing Requirements for BUSWIDTH ...................................................................15-13  
15.3.2 16-bit Bus Timings ................................................................................................15-14  
15.3.3 8-bit Bus Timings ..................................................................................................15-16  
ix  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
15.4 WAIT STATES (READY CONTROL)......................................................................... 15-17  
15.5 BUS-CONTROL MODES........................................................................................... 15-21  
15.5.1 Standard Bus-control Mode ..................................................................................15-22  
15.5.2 Write Strobe Mode ................................................................................................15-25  
15.5.3 Address Valid Strobe Mode ..................................................................................15-27  
15.5.4 Address Valid with Write Strobe Mode ..................................................................15-30  
15.6 SYSTEM BUS AC TIMING SPECIFICATIONS......................................................... 15-31  
15.6.1 Explanation of AC Symbols ..................................................................................15-33  
15.6.2 AC Timing Definitions ...........................................................................................15-33  
CHAPTER 16  
PROGRAMMING THE NONVOLATILE MEMORY  
16.1 PROGRAMMING METHODS...................................................................................... 16-1  
16.2 OTPROM MEMORY MAP........................................................................................... 16-2  
16.3 SECURITY FEATURES............................................................................................... 16-3  
16.3.1 Controlling Access to Internal Memory ...................................................................16-3  
16.3.1.1 Controlling Access to the OTPROM During Normal Operation ..........................16-4  
16.3.1.2 Controlling Access to the OTPROM During Programming Modes .....................16-4  
16.3.2 Controlling Fetches from External Memory .............................................................16-6  
16.4 PROGRAMMING PULSE WIDTH ............................................................................... 16-8  
16.5 MODIFIED QUICK-PULSE ALGORITHM.................................................................... 16-9  
16.6 PROGRAMMING MODE PINS.................................................................................. 16-11  
16.7 ENTERING PROGRAMMING MODES..................................................................... 16-13  
16.7.1 Selecting the Programming Mode .........................................................................16-13  
16.7.2 Power-up and Power-down Sequences ................................................................16-14  
16.7.2.1 Power-up Sequence .........................................................................................16-14  
16.7.2.2 Power-down Sequence ....................................................................................16-14  
16.8 SLAVE PROGRAMMING MODE............................................................................... 16-15  
16.8.1 Reading the Signature Word and Programming Voltages ....................................16-15  
16.8.2 Slave Programming Circuit and Memory Map ......................................................16-16  
16.8.3 Operating Environment .........................................................................................16-17  
16.8.4 Slave Programming Routines ...............................................................................16-19  
16.8.5 Timing Mnemonics ................................................................................................16-24  
16.9 AUTO PROGRAMMING MODE ................................................................................ 16-25  
16.9.1 Auto Programming Circuit and Memory Map ........................................................16-25  
16.9.2 Operating Environment .........................................................................................16-27  
16.9.3 Auto Programming Routine ...................................................................................16-27  
16.9.4 Auto Programming Procedure ..............................................................................16-29  
16.9.5 ROM-dump Mode .................................................................................................16-30  
16.10 PCCB AND UPROM PROGRAMMING (8XC196MH ONLY) .................................... 16-30  
16.11 RUN-TIME PROGRAMMING .................................................................................... 16-32  
x
Download from Www.Somanuals.com. All Manuals Search And Download.  
CONTENTS  
APPENDIX A  
INSTRUCTION SET REFERENCE  
APPENDIX B  
SIGNAL DESCRIPTIONS  
B.1  
B.2  
B.3  
B.4  
SIGNAL NAME CHANGES........................................................................................... B-1  
FUNCTIONAL GROUPINGS OF SIGNALS ................................................................. B-1  
SIGNAL DESCRIPTIONS........................................................................................... B-12  
DEFAULT CONDITIONS............................................................................................ B-22  
APPENDIX C  
REGISTERS  
GLOSSARY  
INDEX  
xi  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
FIGURES  
Figure  
Page  
8XC196Mx Block Diagram ...........................................................................................2-3  
2-1  
2-2  
2-3  
2-4  
4-1  
4-2  
4-3  
5-1  
5-2  
5-3  
5-4  
5-5  
5-6  
5-7  
5-8  
5-9  
5-10  
5-11  
5-12  
5-13  
5-14  
5-15  
5-16  
5-17  
5-18  
5-19  
5-20  
5-21  
5-22  
5-23  
5-24  
5-25  
5-26  
5-27  
5-28  
6-1  
Block Diagram of the Core ...........................................................................................2-3  
Clock Circuitry ..............................................................................................................2-7  
Internal Clock Phases ..................................................................................................2-8  
Register File Memory Map ...........................................................................................4-9  
Windowing..................................................................................................................4-12  
Window Selection (WSR) Register.............................................................................4-13  
Flow Diagram for PTS and Standard Interrupts ...........................................................5-2  
Waveform Generator Protection Circuitry.....................................................................5-7  
Flow Diagram for the OVRTM Interrupt........................................................................5-8  
Standard Interrupt Response Time ............................................................................5-11  
PTS Interrupt Response Time....................................................................................5-11  
PTS Select (PTSSEL) Register..................................................................................5-14  
Interrupt Mask (INT_MASK) Register.........................................................................5-15  
Interrupt Mask 1 (INT_MASK1) Register....................................................................5-16  
Peripheral Interrupt Mask (PI_MASK) Register..........................................................5-17  
Interrupt Pending (INT_PEND) Register ....................................................................5-21  
Interrupt Pending 1 (INT_PEND1) Register ...............................................................5-22  
Peripheral Interrupt Pending (PI_PEND) Register .....................................................5-23  
PTS Control Blocks ....................................................................................................5-25  
PTS Service (PTSSRV) Register ...............................................................................5-26  
PTS Mode Selection Bits (PTSCON Bits 7:5) ............................................................5-27  
PTS Control Block — Single Transfer Mode..............................................................5-28  
PTS Control Block — Block Transfer Mode ...............................................................5-31  
PTS Control Block – A/D Scan Mode.........................................................................5-33  
PTS Control Block 1 – Serial I/O Mode......................................................................5-38  
PTS Control Block 2 – Serial I/O Mode......................................................................5-41  
Synchronous SIO Transmit Mode Timing...................................................................5-43  
Synchronous SIO Transmit Mode — End-of-PTS Interrupt Routine Flowchart..........5-46  
Synchronous SIO Receive Timing..............................................................................5-47  
Synchronous SIO Receive Mode — End-of-PTS Interrupt Routine Flowchart...........5-50  
Asynchronous SIO Transmit Timing...........................................................................5-51  
Asynchronous SIO Transmit Mode — End-of-PTS Interrupt Routine Flowchart........5-54  
Asynchronous SIO Receive Timing............................................................................5-55  
Asynchronous SIO Receive Mode — End-of-PTS Interrupt Routine Flowchart.........5-58  
Standard Input-only Port Structure...............................................................................6-3  
Bidirectional Port Structure...........................................................................................6-8  
Address/Data Bus (Ports 3 and 4) Structure..............................................................6-15  
Output-only Port .........................................................................................................6-18  
Port 6 Output Configuration (WG_OUTPUT) Register...............................................6-18  
SIO Block Diagram.......................................................................................................7-1  
Typical Shift Register Circuit for Mode 0 ......................................................................7-5  
Mode 0 Timing..............................................................................................................7-6  
Serial Port Frames for Mode 1 .....................................................................................7-8  
6-2  
6-3  
6-4  
6-5  
7-1  
7-2  
7-3  
7-4  
xii  
Download from Www.Somanuals.com. All Manuals Search And Download.  
CONTENTS  
Page  
FIGURES  
Figure  
7-5  
7-6  
7-7  
7-8  
8-1  
8-2  
8-3  
8-4  
8-5  
9-1  
9-2  
9-3  
9-4  
9-5  
9-6  
9-7  
Serial Port Frames in Mode 2 and 3.............................................................................7-9  
Serial Port Control (SPx_CON) Register....................................................................7-10  
Serial Port x Baud Rate (SPx_BAUD) Register.........................................................7-12  
Serial Port Status (SPx_STATUS) Register...............................................................7-15  
Frequency Generator Block Diagram...........................................................................8-1  
Frequency (FREQ_GEN) Register...............................................................................8-3  
Frequency Generator Count (FREQ_CNT) Register....................................................8-4  
Infrared Remote Control Application Block Diagram....................................................8-5  
Data Encoding Example...............................................................................................8-5  
Waveform Generator Block Diagram............................................................................9-2  
Dead-time Generator Circuitry......................................................................................9-5  
Protection Circuitry.......................................................................................................9-6  
Center-aligned Modes — Counter Operation...............................................................9-9  
Center-aligned Modes — Output Operation...............................................................9-10  
Edge-aligned Modes — Counter Operation ...............................................................9-11  
Edge-aligned Modes — Output Operation .................................................................9-11  
WG Output Configuration (WG_OUTPUT) Register ..................................................9-13  
Waveform Generator Protection (WG_PROTECT) Register......................................9-15  
Waveform Generator Reload (WG_RELOAD) Register.............................................9-16  
Phase Compare (WG_COMPx) Register...................................................................9-17  
Waveform Generator Control (WG_CONTROL) Register..........................................9-18  
Waveform Generator Counter (WG_COUNTER) Register ........................................9-19  
Effect of Dead Time on Duty Cycle ............................................................................9-20  
PWM Block Diagram ..................................................................................................10-2  
PWM Output Waveforms............................................................................................10-4  
PWM Period (PWM_PERIOD) Register.....................................................................10-6  
PWM Control (PWMx_CONTROL) Register ..............................................................10-7  
PWM Count (PWM_COUNT) Register.......................................................................10-8  
Waveform Generator Output Configuration (WG_OUTPUT) Register.......................10-9  
D/A Buffer Block Diagram.........................................................................................10-10  
PWM to Analog Conversion Circuitry .......................................................................10-10  
EPA Block Diagram....................................................................................................11-2  
EPA Timer/Counters ..................................................................................................11-6  
Quadrature Mode Interface ........................................................................................11-8  
Quadrature Mode Timing and Count..........................................................................11-9  
A Single EPA Capture/Compare Channel................................................................11-10  
EPA Simplified Input-capture Structure....................................................................11-11  
Valid EPA Input Events ............................................................................................11-11  
Timer 1 Control (T1CONTROL) Register .................................................................11-16  
Timer 2 Control (T2CONTROL) Register .................................................................11-17  
9-8  
9-9  
9-10  
9-11  
9-12  
9-13  
9-14  
10-1  
10-2  
10-3  
10-4  
10-5  
10-6  
10-7  
10-8  
11-1  
11-2  
11-3  
11-4  
11-5  
11-6  
11-7  
11-8  
11-9  
11-10 EPA Control (EPAx_CON) Registers .......................................................................11-19  
11-11 EPA Compare Control (COMPx_CON) Registers....................................................11-22  
12-1  
12-2  
A/D Converter Block Diagram ....................................................................................12-1  
A/D Test (AD_TEST) Register....................................................................................12-5  
xiii  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
FIGURES  
Figure  
Page  
A/D Result (AD_RESULT) Register — Write Format.................................................12-6  
12-3  
12-4  
12-5  
12-6  
12-7  
12-8  
12-9  
A/D Time (AD_TIME) Register ...................................................................................12-7  
A/D Command (AD_COMMAND) Register ................................................................12-8  
A/D Result (AD_RESULT) Register — Read Format.................................................12-9  
Idealized A/D Sampling Circuitry..............................................................................12-10  
Suggested A/D Input Circuit .....................................................................................12-12  
Ideal A/D Conversion Characteristic.........................................................................12-15  
12-10 Actual and Ideal A/D Conversion Characteristics.....................................................12-16  
12-11 Terminal-based A/D Conversion Characteristic .......................................................12-18  
13-1  
13-2  
13-3  
13-4  
13-5  
13-6  
13-7  
13-8  
13-9  
Minimum Hardware Connections ...............................................................................13-3  
Power and Return Connections .................................................................................13-4  
On-chip Oscillator Circuit............................................................................................13-5  
External Crystal Connections.....................................................................................13-6  
External Clock Connections .......................................................................................13-7  
External Clock Drive Waveforms................................................................................13-7  
Reset Timing Sequence.............................................................................................13-8  
General Configuration Register (GEN_CON)............................................................13-9  
Internal Reset Circuitry.............................................................................................13-10  
13-10 Minimum Reset Circuit .............................................................................................13-11  
13-11 Example of a System Reset Circuit..........................................................................13-11  
14-1  
14-2  
14-3  
14-4  
15-1  
15-2  
15-3  
15-4  
15-5  
15-6  
15-7  
15-8  
15-9  
Clock Control During Power-saving Modes................................................................14-4  
Power-up and Power-down Sequence When Using an External Interrupt.................14-7  
External RC Circuit.....................................................................................................14-8  
Typical Voltage on the VPP Pin While Exiting Powerdown.........................................14-9  
Chip Configuration 0 (CCR0) Register .......................................................................15-7  
Chip Configuration 1 (CCR1) Register .......................................................................15-9  
Multiplexing and Bus Width Options.........................................................................15-11  
BUSWIDTH Timing Diagram (8XC196MC, MD) ......................................................15-12  
BUSWIDTH Timing Diagram (8XC196MH)..............................................................15-12  
Timings for 16-bit Buses...........................................................................................15-15  
Timings for 8-bit Buses.............................................................................................15-17  
READY Timing Diagram — One Wait State (8XC196MC, MD) ...............................15-19  
READY Timing Diagram — One Wait State (8XC196MH).......................................15-20  
15-10 Standard Bus Control ...............................................................................................15-22  
15-11 Decoding WRL# and WRH#.....................................................................................15-22  
15-12 8-bit System with Flash and RAM ............................................................................15-23  
15-13 16-bit System with Dynamic Bus Width....................................................................15-24  
15-14 Write Strobe Mode ...................................................................................................15-25  
15-15 16-bit System with Writes to Byte-wide RAMs .........................................................15-26  
15-16 Address Valid Strobe Mode......................................................................................15-27  
15-17 Comparison of ALE and ADV# Bus Cycles..............................................................15-27  
15-18 8-bit System with Flash ............................................................................................15-28  
15-19 16-bit System with EPROM......................................................................................15-29  
15-20 Timings of Address Valid with Write Strobe Mode ...................................................15-30  
xiv  
Download from Www.Somanuals.com. All Manuals Search And Download.  
CONTENTS  
Page  
FIGURES  
Figure  
15-21 16-bit System with RAM ...........................................................................................15-31  
15-22 System Bus Timing ..................................................................................................15-32  
16-1  
16-2  
16-3  
16-4  
16-5  
16-6  
16-7  
16-8  
16-9  
Unerasable PROM (USFR) Register..........................................................................16-7  
Programming Pulse Width (PPW) Register................................................................16-8  
Modified Quick-pulse Algorithm................................................................................16-10  
Pin Functions in Programming Modes......................................................................16-11  
Slave Programming Circuit.......................................................................................16-16  
Chip Configuration Registers (CCRs).......................................................................16-18  
Address/Command Decoding Routine .....................................................................16-20  
Program Word Routine.............................................................................................16-21  
Program Word Waveform.........................................................................................16-22  
16-10 Dump Word Routine.................................................................................................16-23  
16-11 Dump Word Waveform.............................................................................................16-24  
16-12 Auto Programming Circuit ........................................................................................16-26  
16-13 Auto Programming Routine......................................................................................16-28  
16-14 PCCB and UPROM Programming Circuit ................................................................16-31  
16-15 Run-time Programming Code Example....................................................................16-33  
B-1  
B-2  
B-3  
B-4  
B-5  
B-6  
B-7  
B-8  
8XC196MC 64-lead Shrink DIP (SDIP) Package........................................................ B-3  
8XC196MC 84-lead PLCC Package ........................................................................... B-4  
8XC196MC 80-lead Shrink EIAJ/QFP Package.......................................................... B-5  
8XC196MD 84-lead PLCC Package ........................................................................... B-7  
8XC196MD 80-lead Shrink EIAJ/QFP Package.......................................................... B-8  
8XC196MH 64-lead Shrink DIP (SDIP) Package...................................................... B-10  
8XC196MH 84-lead PLCC Package ......................................................................... B-11  
8XC196MH 80-lead Shrink EIAJ/QFP Package........................................................ B-12  
xv  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
TABLES  
Table  
Page  
Handbooks and Product Information............................................................................1-6  
1-1  
1-2  
1-3  
1-4  
1-5  
2-1  
2-2  
3-1  
3-2  
3-3  
4-1  
4-2  
4-3  
4-4  
4-5  
4-6  
4-7  
4-8  
4-9  
4-10  
4-11  
4-12  
5-1  
5-2  
5-3  
5-4  
5-5  
5-6  
5-7  
5-8  
5-9  
5-10  
5-11  
5-13  
5-14  
5-15  
5-16  
6-1  
6-2  
6-3  
6-4  
6-5  
6-6  
6-7  
Application Notes, Application Briefs, and Article Reprints ..........................................1-6  
®
MCS 96 Microcontroller Datasheets (Commercial/Express)......................................1-7  
®
MCS 96 Microcontroller Datasheets (Automotive) .....................................................1-7  
®
MCS 96 Microcontroller Quick References ................................................................1-8  
Features of the 8XC196Mx Product Family..................................................................2-2  
State Times at Various Frequencies ............................................................................2-8  
Operand Type Definitions.............................................................................................3-1  
Equivalent Operand Types for Assembly and C Programming Languages .................3-2  
Definition of Temporary Registers................................................................................3-6  
Memory Map ...............................................................................................................4-2  
Special-purpose Memory Addresses............................................................................4-3  
Memory-mapped SFRs ................................................................................................4-5  
Peripheral SFRs — 8XC196MC...................................................................................4-6  
Peripheral SFRs — 8XC196MD...................................................................................4-7  
Peripheral SFRs — 8XC196MH...................................................................................4-8  
Register File Memory Addresses ..............................................................................4-10  
CPU SFRs..................................................................................................................4-11  
Selecting a Window of Peripheral SFRs.....................................................................4-13  
Selecting a Window of the Upper Register File..........................................................4-14  
Windows.....................................................................................................................4-15  
Windowed Base Addresses .......................................................................................4-15  
Interrupt Signals ...........................................................................................................5-3  
Interrupt and PTS Control and Status Registers ..........................................................5-3  
Interrupt Sources, Vectors, and Priorities.....................................................................5-5  
Execution Times for PTS Cycles................................................................................5-12  
Single Transfer Mode PTSCB....................................................................................5-30  
Block Transfer Mode PTSCB .....................................................................................5-30  
A/D Scan Mode Command/Data Table......................................................................5-34  
Command/Data Table (Example 1)............................................................................5-36  
A/D Scan Mode PTSCB (Example 1).........................................................................5-36  
Command/Data Table (Example 2)............................................................................5-37  
A/D Scan Mode PTSCB (Example 2).........................................................................5-37  
SSIO Transmit Mode PTSCBs...................................................................................5-45  
SSIO Receive Mode PTSCBs....................................................................................5-48  
ASIO Transmit Mode PTSCBs...................................................................................5-52  
ASIO Receive Mode PTSCBs....................................................................................5-56  
Device I/O Ports ...........................................................................................................6-1  
Standard Input-only Port Pins ......................................................................................6-2  
Input-only Port Registers..............................................................................................6-3  
Bidirectional Port Pins ..................................................................................................6-5  
Bidirectional Port Control and Status Registers ...........................................................6-6  
Logic Table for Bidirectional Ports in I/O Mode............................................................6-9  
Logic Table for Bidirectional Ports in Special-function Mode .......................................6-9  
xvi  
Download from Www.Somanuals.com. All Manuals Search And Download.  
CONTENTS  
Page  
TABLES  
Table  
6-8  
6-9  
Control Register Values for Each Configuration.........................................................6-11  
Port Configuration Example .......................................................................................6-11  
Port Pin States After Reset and After Example Code Execution................................6-12  
Ports 3 and 4 Pins......................................................................................................6-14  
Ports 3 and 4 Control and Status Registers ...............................................................6-14  
Logic Table for Ports 3 and 4 as Open-drain I/O........................................................6-16  
Standard Output-only Port Pins..................................................................................6-17  
Output-only Port Control Register ..............................................................................6-17  
Serial Port Signals........................................................................................................7-2  
Serial Port Control and Status Registers......................................................................7-2  
SPx_BAUD Values When Using XTAL1 at 16 MHz...................................................7-14  
Frequency Generator Signal ........................................................................................8-2  
Frequency Generator Control and Status Registers ...................................................8-2  
Waveform Generator Signals.......................................................................................9-3  
Waveform Generator Control and Status Registers....................................................9-3  
Operation in Center-aligned and Edge-aligned Modes ................................................9-8  
Register Updates..........................................................................................................9-8  
Output Configuration ..................................................................................................9-12  
PWM Signals..............................................................................................................10-2  
PWM Control and Status Registers............................................................................10-3  
PWM Output Frequencies (FPWM)...............................................................................10-5  
PWM Output Alternate Functions...............................................................................10-8  
EPA Channels............................................................................................................11-1  
EPA and Timer/Counter Signals.................................................................................11-2  
EPA Control and Status Registers .............................................................................11-3  
Quadrature Mode Truth Table....................................................................................11-8  
Action Taken When a Valid Edge Occurs ................................................................11-12  
Example EPA Control Register Settings for Channels 1, 3, or 5..............................11-18  
A/D Converter Pins.....................................................................................................12-2  
A/D Control and Status Registers...............................................................................12-2  
Minimum Required Signals.........................................................................................13-1  
I/O Port Configuration Guide ......................................................................................13-2  
Selecting the Watchdog Reset Interval (8XC196MH only)......................................13-13  
Operating Mode Control Signals ................................................................................14-1  
Operating Mode Control and Status Registers...........................................................14-2  
External Memory Interface Signals.............................................................................15-1  
External Memory Interface Registers .........................................................................15-4  
Register Settings for Configuring External Memory Interface Signals........................15-5  
BUSWIDTH Signal Timing Definitions......................................................................15-13  
READY Signal Timing Definitions.............................................................................15-20  
Bus-control Modes ...................................................................................................15-21  
AC Timing Symbol Definitions..................................................................................15-33  
External Memory Systems Must Meet These Specifications....................................15-33  
Microcontroller Meets These Specifications.............................................................15-34  
6-10  
6-11  
6-12  
6-13  
6-14  
6-15  
7-1  
7-2  
7-3  
8-1  
8-2  
9-1  
9-2  
9-3  
9-4  
9-5  
10-1  
10-2  
10-3  
10-4  
11-1  
11-2  
11-3  
11-4  
11-5  
11-6  
12-1  
12-2  
13-1  
13-2  
13-3  
14-1  
14-2  
15-1  
15-2  
15-3  
15-4  
15-5  
15-6  
15-7  
15-8  
15-9  
xvii  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
TABLES  
Table  
Page  
87C196Mx OTPROM Memory Map ..........................................................................16-3  
16-1  
16-2  
16-3  
16-4  
16-5  
16-6  
16-7  
16-8  
16-9  
Memory Protection for Normal Operating Mode.........................................................16-4  
Memory Protection Options for Programming Modes ................................................16-5  
UPROM Programming Values and Locations for Slave Mode...................................16-7  
Example PPW_VALUE Calculations..........................................................................16-9  
Pin Descriptions .......................................................................................................16-11  
PMODE Values ........................................................................................................16-13  
Device Signature Word and Programming Voltages................................................16-16  
Slave Programming Mode Memory Map..................................................................16-17  
16-10 Timing Mnemonics ...................................................................................................16-24  
16-11  
16-12  
16-13  
A-1  
A-1  
A-2  
A-3  
A-4  
A-5  
A-6  
A-7  
A-8  
A-9  
B-1  
B-2  
B-3  
B-4  
B-5  
8XC196MC/MD Auto Programming Memory Map ..................................................16-27  
8XC196MH Auto Programming Memory Map.........................................................16-27  
PCCB and UPROM Programming Values...............................................................16-32  
Opcode Map (Left Half) ............................................................................................... A-2  
Opcode Map (Right Half)............................................................................................. A-3  
Processor Status Word (PSW) Flags.......................................................................... A-4  
Effect of PSW Flags or Specified Conditions on Conditional Jump Instructions......... A-5  
PSW Flag Setting Symbols ......................................................................................... A-5  
Operand Variables ...................................................................................................... A-6  
Instruction Set ............................................................................................................. A-7  
Instruction Opcodes .................................................................................................. A-41  
Instruction Lengths and Hexadecimal Opcodes........................................................ A-47  
Instruction Execution Times (in State Times)............................................................ A-52  
Signal Name Changes ................................................................................................ B-1  
8XC196MC Signals Arranged by Functional Categories............................................. B-2  
8XC196MD Signals Arranged by Functional Categories............................................. B-6  
8XC196MH Signals Arranged by Functional Categories............................................. B-9  
Description of Columns of Table B-6......................................................................... B-13  
Signal Descriptions.................................................................................................... B-13  
Definition of Status Symbols ..................................................................................... B-23  
8XC196MC and MD Default Signal Conditions......................................................... B-23  
8XC196MH Default Signal Conditions....................................................................... B-25  
Modules and Related Registers ..................................................................................C-1  
Register Name, Address, and Reset Status................................................................C-2  
COMPx_TIME Addresses and Reset Values............................................................ C-17  
EPAx_CON Addresses and Reset Values................................................................ C-20  
EPAx_TIME Addresses and Reset Values................................................................ C-21  
Px_DIR Addresses and Reset Values....................................................................... C-30  
Px_MODE Addresses and Reset Values.................................................................. C-31  
Special-function Signals for Ports 1, 2, 5, 6............................................................... C-32  
Px_PIN Addresses and Reset Values....................................................................... C-33  
Px_REG Addresses and Reset Values..................................................................... C-34  
Output Configuration ................................................................................................. C-65  
WSR Settings and Direct Addresses for Windowable SFRs..................................... C-68  
B-6  
B-7  
B-8  
B-9  
C-1  
C-2  
C-3  
C-4  
C-5  
C-6  
C-7  
C-8  
C-9  
C-10  
C-11  
C-12  
xviii  
Download from Www.Somanuals.com. All Manuals Search And Download.  
1
Guide to This Manual  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
CHAPTER 1  
GUIDE TO THIS MANUAL  
This manual describes the 8XC196MC, 8XC196MD, and 8XC196MH embedded microcontrol-  
lers. 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 com-  
plete your design.  
1.1 MANUAL CONTENTS  
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 — 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 4 — Memory Partitions — describes the addressable memory space of the device. It  
describes the memory partitions and explains how to use windows to increase the amount of  
memory that can be accessed with register-direct instructions.  
Chapter 5 — Standard and PTS Interrupts — describes the interrupt control circuitry, priority  
scheme, and timing for standard and peripheral transaction server (PTS) interrupts. It also ex-  
plains interrupt programming and control.  
Chapter 6 — I/O Ports — describes the input/output ports and explains how to configure the  
ports for input, output, or special functions.  
Chapter 7 — Serial I/O (SIO) Port — describes the 8XC196MH’s asynchronous/synchronous  
serial I/O (SIO) port and explains how to program it.  
Chapter 8 Frequency Generator — describes the 8XC196MD’s frequency generator and ex-  
plains how to configure it. For additional information and application examples, consult AP-483,  
Application Examples Using the 8XC196MC/MD Microcontroller (order number 272282).  
1-1  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Chapter 9 Waveform Generator — describes the waveform generator and explains how to  
configure it. For additional information and application examples, consult AP-483, Application  
Examples Using the 8XC196MC/MD Microcontroller (order number 272282).  
Chapter 10 — Pulse-width Modulator — provides a functional overview of the pulse width  
modulator (PWM) modules, describes how to program them, and provides sample circuitry for  
converting the PWM outputs to analog signals.  
Chapter 11 — 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 12 — Analog-to-digital (A/D) Converter — provides an overview of the analog-to-  
digital (A/D) converter and describes how to program the converter, read the conversion results,  
and interface with external circuitry.  
Chapter 13 — Minimum Hardware Considerations — describes options for providing the ba-  
sic requirements for device operation within a system, discusses other hardware considerations,  
and describes device reset options.  
Chapter 14 — Special Operating Modes — provides an overview of the idle, powerdown,  
and on-circuit emulation (ONCE) modes and describes how to enter and exit each mode.  
Chapter 15 — Interfacing with External Memory — lists the external memory signals and de-  
scribes the registers that control the external memory interface. It discusses the bus width and  
memory configurations, the bus-hold protocol, write-control modes, and internal wait states and  
ready control. Finally, it provides timing information for the system bus.  
Chapter 16 — Programming the Nonvolatile Memory — provides recommended circuits, the  
corresponding memory maps, and flow diagrams. It also provides procedures for auto program-  
ming.  
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 3,  
“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.  
1-2  
Download from Www.Somanuals.com. All Manuals Search And Download.  
GUIDE TO THIS MANUAL  
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.  
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  
instructions  
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.  
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.  
1-3  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
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  
register names  
reserved 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 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.  
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.  
1-4  
Download from Www.Somanuals.com. All Manuals Search And Download.  
GUIDE TO THIS MANUAL  
units of measure  
The following abbreviations are used to represent units of measure:  
A
amps, amperes  
DCV  
direct current volts  
Kbytes kilobytes  
kHz  
k  
mA  
kilohertz  
kilo-ohms  
milliamps, milliamperes  
Mbytes megabytes  
MHz  
ms  
mW  
ns  
megahertz  
milliseconds  
milliwatts  
nanoseconds  
picofarads  
pF  
W
watts  
V
volts  
µA  
µF  
µs  
microamps, microamperes  
microfarads  
microseconds  
microwatts  
µW  
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.  
1.3 RELATED DOCUMENTS  
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).  
1-5  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 1-1. Handbooks and Product Information  
Title and Description  
Intel Embedded Quick Reference Guide  
Order Number  
272439  
240691  
240952  
240897  
Solutions for Embedded Applications Guide  
Data on Demand fact sheet  
Data on Demand annual subscription (6 issues; Windows* version)  
Complete set of Intel handbooks on CD-ROM.  
Handbook Set — handbooks and product overview  
231003  
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.  
Automotive Products †  
231792  
270648  
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.  
Embedded Microcontrollers †  
270646  
296467  
210830  
240800  
272326  
Datasheets and architecture descriptions for Intel’s three industry-standard micro-  
controllers, the MCS 48, MCS 51, and MCS 96 microcontrollers.  
Peripheral Components †  
Comprehensive information on Intel’s peripheral components, including  
datasheets, application notes, and technical briefs.  
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.  
Packaging †  
Detailed information on the manufacturing, applications, and attributes of a variety  
of semiconductor packages.  
Development Tools Handbook  
Information on third-party hardware and software tools that support Intel’s  
embedded microcontrollers.  
Included in handbook set (order number 231003)  
Table 1-2. Application Notes, Application Briefs, and Article Reprints  
Title  
Order Number  
AB-71, Using the SIO on the 8XC196MH (application brief)  
AP-125, Designing Microcontroller Systems for Electrically Noisy Environments †††  
AP-155, Oscillators for Microcontrollers †††  
272594  
210313  
230659  
270056  
AR-375, Motor Controllers Take the Single-Chip Route (article reprint)  
Included in Automotive Products handbook (order number 231792)  
†† Included in Embedded Applications handbook (order number 270648)  
††† Included in Automotive Products and Embedded Applications handbooks  
1-6  
Download from Www.Somanuals.com. All Manuals Search And Download.  
GUIDE TO THIS MANUAL  
Table 1-2. Application Notes, Application Briefs, and Article Reprints (Continued)  
Title  
Order Number  
AP-406, MCS® 96 Analog Acquisition Primer †††  
AP-445, 8XC196KR Peripherals: A User’s Point of View †  
270365  
270873  
270968  
AP-449, A Comparison of the Event Processor Array (EPA) and High Speed  
Input/Output (HSIO) Unit †  
AP-475, Using the 8XC196NT ††  
AP-477, Low Voltage Embedded Design ††  
272315  
272324  
272282  
272595  
272324  
272680  
AP-483, Application Examples Using the 8XC196MC/MD Microcontroller  
AP-700, Intel Fuzzy Logic Tool Simplifies ABS Design †  
AP-711, EMI Design Techniques for Microcontrollers in Automotive Applications  
AP-715, Interfacing an I2C Serial EEPROM to an MCS® 96 Microcontroller  
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-3. MCS 96 Microcontroller Datasheets (Commercial/Express)  
Title  
Order Number  
8XC196KR/KQ/JR/JQ Commercial/Express CHMOS Microcontroller †  
8XC196KT Commercial CHMOS Microcontroller †  
87C196KT/87C196KS 20 MHz Advanced 16-Bit CHMOS Microcontroller †  
8XC196MC Industrial Motor Control Microcontroller †  
87C196MD Industrial Motor Control CHMOS Microcontroller †  
8XC196NP Commercial CHMOS 16-Bit Microcontroller †  
8XC196NT CHMOS Microcontroller with 1-Mbyte Linear Address Space †  
270912  
272266  
272513  
272323  
270946  
272459  
272267  
272644  
80C196NU Commercial CHMOS 16-Bit Microcontroller  
Included in Embedded Microcontrollers handbook (order number 270646)  
®
Table 1-4. MCS 96 Microcontroller Datasheets (Automotive)  
Title and Description  
Order Number  
87C196CA/87C196CB 20 MHz Advanced 16-Bit CHMOS Microcontroller with  
Integrated CAN 2.0 †  
272405  
87C196JT 20 MHz Advanced 16-Bit CHMOS Microcontroller †  
87C196JV 20 MHz Advanced 16-Bit CHMOS Microcontroller †  
272529  
272580  
270827  
87C196KR/KQ, 87C196JV/JT, 87C196JR/JQ Advanced 16-Bit CHMOS  
Microcontroller †  
87C196KT/87C196KS Advanced 16-Bit CHMOS Microcontroller †  
87C196KT/KS 20 MHz Advanced 16-Bit CHMOS Microcontroller †  
Included in Automotive Products handbook (order number 231792)  
270999  
272513  
1-7  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
This Page Left Intentionally Blank  
1-8  
Download from Www.Somanuals.com. All Manuals Search And Download.  
GUIDE TO THIS MANUAL  
This Page Left Intentionally Blank  
1-9  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
This Page Left Intentionally Blank  
1-10  
Download from Www.Somanuals.com. All Manuals Search And Download.  
GUIDE TO THIS MANUAL  
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.  
1.5 TECHNICAL SUPPORT  
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  
916-356-7599  
U.S. and Canada  
U.S. and Canada  
U.S. and Canada  
916-356-6100 (fax)  
1.6 PRODUCT LITERATURE  
You can order product literature from the following Intel literature centers.  
1-800-548-4725  
708-296-9333  
U.S. and Canada  
U.S. (from overseas)  
Europe (U.K.)  
Germany  
44(0)1793-431155  
44(0)1793-421333  
44(0)1793-421777  
81(0)120-47-88-32  
France  
Japan (fax only)  
1-11  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
2
Architectural  
Overview  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
CHAPTER 2  
ARCHITECTURAL OVERVIEW  
The 16-bit 8XC196MC, 8XC196MD, and 8XC196MH 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.  
NOTE  
This manual describes a family of microcontrollers. For brevity, the name  
8XC196Mx is used when the discussion applies to all family members. When  
information applies to specific microcontrollers, individual product names are  
used.  
2.1 TYPICAL APPLICATIONS  
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).  
2.2 MICROCONTROLLER FEATURES  
Table 2-1 lists the features of each member of the 8XC196Mx family.  
2-1  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 2-1. Features of the 8XC196Mx Product Family  
OTPROM/ Register  
SIO  
Ports  
(Note 3) (Note 4)  
PWM  
Channels  
External  
Interrupt  
Pins  
ROM  
Bytes  
RAM  
Bytes  
I/O  
Pins Pins  
EPA  
A/D  
Channels  
Device  
Pins  
(Note 1)  
(Note 2)  
8XC196MH  
8XC196MH  
8XC196MH  
8XC196MC  
8XC196MC  
8XC196MC  
8XC196MD  
8XC196MD  
NOTES:  
84  
80  
64  
84  
80  
64  
84  
80  
32 K  
32 K  
32 K  
16 K  
16 K  
16 K  
16 K  
16 K  
744  
744  
744  
488  
488  
488  
488  
488  
52  
52  
50  
53  
53  
49  
64  
64  
6
6
2
2
2
0
0
0
0
0
8
8
7
8
8
7
9
9
8
1
1
1
1
1
1
1
1
8
6
8
8
13  
13  
12  
14  
14  
8
7
12  
12  
1. Nonvolatile memory is optional. The second character of the device name indicates the presence and  
type of nonvolatile memory. 80C196Mx = none; 83C196Mx = ROM; 87C196Mx = OTPROM.  
2. Register RAM amounts include the 24 bytes allocated to core SFRs and the stack pointer.  
3. The 8XC196MC and 8XC196MD have no serial I/O ports, but have PTS modes that allow asynchro-  
nous or synchronous serial communication.  
4. The number of PWM channels includes the outputs from the PWM peripheral and the waveform gen-  
erator. For the 8XC196MD, it also includes the output from the frequency generator.  
2.3 FUNCTIONAL OVERVIEW  
Figure 2-1 shows the major blocks within the microcontroller. The core of the microcontroller  
(Figure 2-2) consists of the central processing unit (CPU) and memory controller. The CPU con-  
tains the register file and the register arithmetic-logic unit (RALU). A 16-bit internal bus connects  
the CPU to both the memory controller and the interrupt controller. An extension of this bus con-  
nects the CPU to the internal peripheral modules. In addition, an 8-bit internal bus transfers in-  
struction bytes from the memory controller to the instruction register in the RALU.  
2-2  
Download from Www.Somanuals.com. All Manuals Search And Download.  
ARCHITECTURAL OVERVIEW  
Optional  
ROM  
Interrupt  
Controller  
Core  
Clock and  
Power Mgmt.  
PTS  
I/O  
EPA  
PWM  
WG  
A/D  
WDT  
FG  
SIO  
Note:  
The frequency generator is unique to the 8XC196MD.  
The serial I/O port is unique to the 8XC196MH.  
A2798-02  
Figure 2-1. 8XC196Mx Block Diagram  
Memory Controller  
Prefetch Queue  
Slave PC  
CPU  
Register File  
RALU  
Microcode  
Engine  
Register  
RAM  
Address Register  
Data Register  
ALU  
Master PC  
PSW  
CPU SFRs  
Bus Controller  
Registers  
A2797-01  
Figure 2-2. Block Diagram of the Core  
2-3  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
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 4, “Memory Partitions,” for more  
information about the register file and windowing.) CPU instructions move from the 4-byte  
prefetch queue in the memory controller into the RALU’s instruction register. The microcode en-  
gine decodes the instructions and then generates the sequence of events that cause desired func-  
tions to occur.  
2.3.2 Register File  
The register file is divided into an upper and a lower file. In the lower register file, the lowest 24  
bytes are allocated to the CPU’s special-function registers (SFRs) and the stack pointer, while the  
remainder is available as general-purpose register RAM. The upper register file 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 3-5). 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 4, “Memory Partitions,” for more information about the register file and windowing.  
2.3.3 Register Arithmetic-logic Unit (RALU)  
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 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.  
2-4  
Download from Www.Somanuals.com. All Manuals Search And Download.  
ARCHITECTURAL OVERVIEW  
The RALU uses the upper- and lower-word registers together for the 32-bit instructions and as  
temporary registers for many instructions. These registers have their own shift logic and are used  
for operations that require logical shifts, including 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.  
2.3.3.1  
Code Execution  
The RALU performs most calculations for the microcontroller, but it does not use an accumula-  
tor. Instead it operates directly on the lower register file, which essentially provides 256 accumu-  
lators. Because data does not flow through a single accumulator, the microcontroller’s code  
executes faster and more efficiently.  
2.3.3.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 microprocessor requires four instructions to accomplish the same operation. The fol-  
lowing example shows the equivalent code for an 80C186 microprocessor.  
MOV AX, FACTOR_1  
MUL FACTOR_2  
;move FACTOR_1 into accumulator (AX)  
;(AX)FACTOR1  
;multiply FACTOR_2 and AX  
;(DX:AX)(AX)×(FACTOR_2)  
;move lower byte into RESULT  
;(RESULT)(AX)  
MOV RESULT, AX  
MOV RESULT+2, DX  
;move upper byte into RESULT+2  
;(RESULT+2)(DX)  
2-5  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
2.3.4 Memory Interface Unit  
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 4, “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.  
NOTE  
When using a logic analyzer to debug code, remember that instructions are  
preloaded into the prefetch queue and are not necessarily executed  
immediately after they are fetched.  
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.  
2.3.5 Interrupt Service  
The microcontroller’s flexible interrupt-handling system has two main components: the program-  
mable interrupt controller and the peripheral transaction server (PTS). The programmable inter-  
rupt controller 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, manage multiple analog-to-digital (A/D) conversions, and can generate pulse-width mod-  
ulated (PWM) signals. The 8XC196MC and 8XC196MD have additional modes that allow  
asynchronous or synchronous serial communication. PTS interrupts have a higher priority than  
standard interrupts and may temporarily suspend interrupt service routines. See Chapter 5, “Stan-  
dard and PTS Interrupts,” for more information.  
2-6  
Download from Www.Somanuals.com. All Manuals Search And Download.  
ARCHITECTURAL OVERVIEW  
2.4 INTERNAL TIMING  
The clock circuitry (Figure 2-3) receives an input clock signal on XTAL1 provided by an external  
crystal or oscillator 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.  
.
Disable Clock Input  
(Powerdown)  
FXTAL1  
Divide-by-two  
XTAL1  
Circuit  
Disable Clocks  
(Powerdown)  
XTAL2  
Peripheral Clocks (PH1, PH2)  
Clock  
Generators  
CLKOUT  
Disable  
Oscillator  
CPU Clocks (PH1, PH2)  
(Powerdown)  
Disable Clocks  
(Idle, Powerdown)  
NOTE: The CLKOUT pin is unique to the 8XC196MC and MD.  
A3115-02  
Figure 2-3. Clock Circuitry  
The rising edges of PH1 and PH2 generate the internal CLKOUT signal (Figure 2-4). The clock  
circuitry routes separate internal clock signals to the CPU and the peripherals to provide flexibil-  
ity in power management. (“Reducing Power Consumption” on page 14-3 describes the power  
management modes.) The 8XC196MC and 8XC196MD microcontrollers output the CLKOUT  
signal on the CLKOUT pin. Because of the complex logic in the clock circuitry, the signal on the  
CLKOUT pin is a delayed version of the internal CLKOUT signal. This delay varies with tem-  
perature and voltage.  
The 8XC196MH microcontroller has no CLKOUT pin. If your 8XC196MH design requires a  
system clock, we recommend that you use an external oscillator and add external logic to generate  
the system clock signal.  
2-7  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
XTAL1  
T
T
XTAL1  
XTAL1  
1 State Time  
1 State Time  
PH1  
PH2  
CLKOUT  
Phase 1  
Phase 2  
Phase 1  
Phase 2  
A0114-04  
Figure 2-4. Internal Clock Phases  
The combined period of phase 1 and phase 2 of the internal CLKOUT signal defines the basic  
time unit known as a state time or state. Table 2-2 lists state time durations at various frequencies.  
Table 2-2. State Times at Various Frequencies  
FXTAL1  
(Frequency Input to the  
Divide-by-two Circuit)  
State Time  
8 MHz  
12 MHz  
16 MHz  
250 ns  
167 ns  
125 ns  
The following formulas calculate the frequency of PH1 and PH2, the duration of a state time, and  
the duration of a clock period (TXTAL1).  
FXTAL1  
------------------  
2
2
1
------------------  
------------------  
PH1 (in MHz) =  
= PH2  
State Time (in µs) =  
T XTAL1  
=
FXTAL1  
FXTAL1  
Because the microcontroller can operate at many frequencies, this manual defines time require-  
ments (such as instruction execution times) in terms of state times rather than specific measure-  
ments. Datasheets list AC characteristics in terms of clock periods (TXTAL1 or TOSC).  
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.  
2-8  
Download from Www.Somanuals.com. All Manuals Search And Download.  
ARCHITECTURAL OVERVIEW  
2.5.1 I/O Ports  
The 8XC196Mx microcontrollers have seven I/O ports, ports 0–6. The 8XC196MD has an addi-  
tional port, port 7. 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 con-  
figured to serve as a standard I/O pin. Ports 3 and 4 are exceptions; they are controlled at the port  
level, not at the pin level. When the bus controller needs to use the address/data bus, it takes con-  
trol of the ports. When the address/data bus is idle, you can use the ports for I/O.  
Port 0 is an input-only port that is also the analog input for the A/D converter. On the 8XC196MH,  
port 0 provides two pins for the EPA. On the 8XC196MC and 8XC196MD, port 1 is also an input-  
only port that provides analog inputs for the A/D converter. On the 8XC196MH, port 1 is a bidi-  
rectional port that shares pins with the serial I/O port.  
Port 2 is a standard, bidirectional I/O port that provides pins for the EPA and timers. Port 7, which  
is unique to the 8XC196MD, is a standard, bidirectional I/O port that provides additional pins for  
the EPA and also provides pins for the frequency generator. Ports 3, 4, and 5 are memory-mapped,  
bidirectional I/O ports. Ports 3 and 4 serve as the external address/data bus, while port 5 provides  
bus-control signals. Port 6 is a standard, output-only port that provides pins for the pulse-width  
modulator and waveform generator. Chapter 6, “I/O Ports,” describes the I/O ports in more detail.  
2.5.2 Serial I/O (SIO) Port  
The 8XC196MH microcontroller has a two-channel serial I/O port that shares pins with ports 1  
and 2. (The 8XC196MC and 8XC196MD have no serial I/O ports, but have PTS modes that allow  
asynchronous or synchronous serial communication. See Chapter 5, “Standard and PTS Inter-  
rupts,” for more information.) The serial I/O (SIO) port is an asynchronous/synchronous port that  
includes a universal asynchronous receiver and transmitter (UART). The UART has two synchro-  
nous modes (modes 0 and 4) and three asynchronous modes (modes 1, 2, and 3) for both trans-  
mission and reception. The asynchronous modes are full duplex, meaning that they can transmit  
and receive data simultaneously. The receiver is buffered, so the reception of a second byte can  
begin before the first byte is read. The transmitter is also buffered, allowing continuous transmis-  
sions. The SIO port has two channels (channels 0 and 1) with identical signals and registers. See  
Chapter 7, “Serial I/O (SIO) Port,” for details.  
2-9  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
2.5.3 Event Processor Array (EPA) and Timer/Counters  
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 11, “Event Processor Array (EPA),” for additional information on the  
EPA and timer/counters.  
2.5.4 Pulse-width Modulator (PWM)  
The output waveform from each PWM channel is a variable duty-cycle pulse. Several types of  
motors require a PWM waveform for most efficient operation. When filtered, the PWM wave-  
form produces a DC level that can change in 256 steps by varying the duty cycle. The number of  
steps per PWM period is also programmable (8 bits). See Chapter 10, “Pulse-width Modulator,”  
for more information.  
2.5.5 Frequency Generator  
The 8XC196MD has a peripheral not found on other 8XC196Mx microcontrollers — the fre-  
quency generator. This peripheral produces a waveform with a fixed duty cycle (50%) and a pro-  
grammable frequency (ranging from 4 kHz to 1 MHz with a 16 MHz input clock). See Chapter  
8, “Frequency Generator,” for details.  
2.5.6 Waveform Generator  
A waveform generator simplifies the task of generating synchronized, pulse-width modulated  
(PWM) outputs. This waveform generator is optimized for motion control applications such as  
driving 3-phase AC induction motors, 3-phase DC brushless motors, or 4-phase stepping motors.  
The waveform generator can produce three independent pairs of complementary PWM outputs,  
which share a common carrier period, dead time, and operating mode. Once it is initialized, the  
waveform generator operates without CPU intervention unless you need to change a duty cycle.  
See Chapter 9, “Waveform Generator,” for more information.  
2-10  
Download from Www.Somanuals.com. All Manuals Search And Download.  
ARCHITECTURAL OVERVIEW  
2.5.7 Analog-to-digital Converter  
The analog-to-digital (A/D) converter converts an analog input voltage to a digital equivalent.  
Resolution is either 8 or 10 bits; sample and convert times are programmable. Conversions can  
be performed on the analog ground and reference voltage, and the results can be used to calculate  
gain and zero-offset errors. The internal zero-offset compensation circuit enables automatic zero-  
offset adjustment. The A/D also has a threshold-detection mode, which can be used to generate  
an interrupt when a programmable threshold voltage is crossed in either direction. The A/D scan  
mode of the PTS facilitates automated A/D conversions and result storage. See Chapter 12, “An-  
alog-to-digital (A/D) Converter,” for more information.  
2.5.8 Watchdog Timer  
The watchdog timer is a 16-bit internal timer that resets the microcontroller if the software fails  
to operate properly. See Chapter 13, “Minimum Hardware Considerations,” for more informa-  
tion.  
2.6 SPECIAL OPERATING MODES  
In addition to the normal execution mode, the microcontroller operates in several special-purpose  
modes. Idle and powerdown modes conserve power when the microcontroller is inactive. On-  
circuit emulation (ONCE) mode electrically isolates the microcontroller from the system, and  
several other modes provide programming options for nonvolatile memory. See Chapter 14,  
“Special Operating Modes,” for more information about idle, powerdown, and ONCE modes, and  
see Chapter 16, “Programming the Nonvolatile Memory,” for details about programming options.  
2.6.1 Reducing Power Consumption  
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 microcontroller out of idle mode.  
In powerdown mode, all internal clocks are frozen at logic state zero and the internal oscillator is  
shut off. The register file and most peripherals retain their data if VCC is maintained. Power con-  
sumption drops into the µW range.  
2.6.2 Testing the Printed Circuit Board  
The on-circuit emulation (ONCE) mode electrically isolates the microcontroller from the system.  
By invoking the ONCE mode, you can test the printed circuit board while the microcontroller is  
soldered onto the board.  
2-11  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
2.6.3 Programming the Nonvolatile Memory  
MCS 96 microcontrollers that have internal OTPROM provide several programming options:  
Slave programming allows a master EPROM programmer to program and verify one or  
more slave MCS 96 microcontrollers. Programming vendors and Intel distributors typically  
use this mode to program a large number of microcontrollers with a customer’s code and  
data.  
Auto programming allows an MCS 96 microcontroller to program itself with code and data  
located in an external memory device. Customers typically use this low-cost method to  
program a small number of microcontrollers after development and testing are complete.  
Run-time programming allows you to program individual nonvolatile memory locations  
during normal code execution, under complete software control. Customers typically use  
this mode to download a small amount of information to the microcontroller after the rest of  
the array has been programmed. For example, you might use run-time programming to  
download a unique identification number to a security device.  
ROM dump mode allows you to dump the contents of the microcontroller’s nonvolatile  
memory to a tester or to a memory device (such as flash memory or RAM).  
Chapter 16, “Programming the Nonvolatile Memory,” provides recommended circuits, the corre-  
sponding memory maps, and flow diagrams. It also provides procedures for auto programming.  
2-12  
Download from Www.Somanuals.com. All Manuals Search And Download.  
3
Programming  
Considerations  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
CHAPTER 3  
PROGRAMMING CONSIDERATIONS  
®
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.  
3.1 OVERVIEW OF THE INSTRUCTION SET  
The instruction set supports a variety of operand types likely to be useful in control applications  
(see Table 3-1).  
NOTE  
The operand-type variables are shown in all capitals to avoid confusion. For  
example, a BYTE is an unsigned 8-bit variable in an instruction, while a byte is  
any 8-bit unit of data (either signed or unsigned).  
Table 3-1. Operand Type Definitions  
No. of  
Bits  
Addressing  
Restrictions  
Operand Type  
BIT  
Signed  
Possible Values  
1
8
8
No  
No  
True (1) or False (0)  
As components of bytes  
BYTE  
0 through 28–1 (0 through 255)  
None  
None  
SHORT-INTEGER  
Yes  
–27 through +27–1  
(–128 through +127)  
WORD  
16  
16  
32  
No  
Yes  
No  
0 through 216–1  
(0 through 65,535)  
Even byte address  
Even byte address  
INTEGER  
–215 through +215–1  
(–32,768 through +32,767)  
DOUBLE-WORD  
(Note 1)  
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)  
LONG-INTEGER  
(Note 1)  
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)  
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 3-9.  
3-1  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 3-2 lists the equivalent operand-type names for both C programming and assembly lan-  
guage.  
Table 3-2. Equivalent Operand Types for Assembly and C Programming Languages  
Operand Types  
Assembly Language Equivalent  
C Programming Language Equivalent  
BYTE  
BYTE  
BYTE  
unsigned char  
char  
SHORT-INTEGER  
WORD  
WORD  
WORD  
LONG  
LONG  
unsigned int  
int  
INTEGER  
DOUBLE-WORD  
LONG-INTEGER  
unsigned long  
long  
3.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.  
3.1.2 BYTE Operands  
8
A BYTE is an unsigned, 8-bit variable that can take on values from 0 through 255 (2 –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.  
3.1.3 SHORT-INTEGER Operands  
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-  
INTEGER set the overflow flags in the processor status word (PSW). The numeric result is the  
same as the result of the equivalent operation on BYTE variables. There are no alignment restric-  
tions on SHORT-INTEGERs, so they may be placed anywhere in the address space.  
3.1.4 WORD Operands  
16  
A WORD is an unsigned, 16-bit variable that can take on values from 0 through 65,535 (2 –1).  
Arithmetic and relational operators can be applied to WORD operands, but the result must be 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.  
3-2  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PROGRAMMING CONSIDERATIONS  
WORDs must be aligned at even byte boundaries in the address space. The least-significant byte  
of the WORD is in the even byte address, and the most-significant byte is in the next higher (odd)  
address. The address of a WORD is that of its least-significant byte (the even byte address).  
WORD operations to odd addresses are not guaranteed to operate in a consistent manner.  
3.1.5 INTEGER Operands  
15  
An INTEGER is a 16-bit, signed variable that can take on values from –32,768 (–2 ) through  
15  
+32,767 (+2 –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.  
3.1.6 DOUBLE-WORD Operands  
A DOUBLE-WORD is an unsigned, 32-bit variable that can take on values from 0 through  
32  
4,294,967,295 (2 –1). The architecture directly supports DOUBLE-WORD 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  
ADDC REG2,REG4  
; (2-operand addition)  
SUB REG1,REG3  
SUBC REG2,REG4  
; (2-operand subtraction)  
3-3  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
3.1.7 LONG-INTEGER Operands  
A LONG-INTEGER is a 32-bit, signed variable that can take on values from –2,147,483,648  
31  
31  
(– 2 ) through +2,147,483,647 (+2 –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 3-3.  
3.1.8 Converting Operands  
The instruction set supports conversions between the operand types. The LDBZE (load byte, zero  
extended) instruction converts a BYTE to a WORD. CLR (clear) converts a WORD to a  
DOUBLE-WORD by 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.  
3.1.9 Conditional Jumps  
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.  
3.1.10 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.  
3-4  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PROGRAMMING CONSIDERATIONS  
3.2 ADDRESSING MODES  
The instruction set uses four basic addressing modes:  
direct  
immediate  
indirect (with or without autoincrement)  
indexed (short-, long-, or zero-indexed)  
The stack pointer 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.  
An instruction can contain only one immediate, indirect, or indexed reference; any remaining op-  
erands 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 3-9 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 3-3.  
Oseg at 1ch  
AL:  
BL:  
CL:  
DL:  
AX:  
BX:  
CX:  
DX:  
DSB 1  
DSB 1  
DSB 1  
DSB 1  
DSW 1  
DSW 1  
DSW 1  
DSW 1  
THISVAR: DSW 1  
3-5  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 3-3. Definition of Temporary Registers  
Temporary Register  
Description  
AX  
BX  
CX  
DX  
word-aligned 16-bit register; AH is the high byte of AX and AL is the low byte  
word-aligned 16-bit register; BH is the high byte of BX and BL is the low byte  
word-aligned 16-bit register; CH is the high byte of CX and CL is the low byte  
word-aligned 16-bit register; DH is the high byte of DX and DL is the low byte  
3.2.1 Direct Addressing  
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 4, “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  
ADDB AL,BL,CL  
MULB AX,BL  
INCB CL  
; AX BX + CX  
; AL BL + CL  
; AX AX × BL  
; CL CL + 1  
3.2.2 Immediate Addressing  
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  
PUSH #1234H  
; AX AX + 340  
; SP SP - 2  
; MEM_WORD(SP) 1234H  
; AL AX/10  
DIVB AX,#10  
; AH AX MOD 10  
3.2.3 Indirect Addressing  
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:  
LD  
AX,[BX]  
; AX MEM_WORD(BX)  
3-6  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PROGRAMMING CONSIDERATIONS  
ADDB AL,BL,[CX]  
POP [AX]  
; AL BL + MEM_BYTE(CX)  
; MEM_WORD(AX) MEM_WORD(SP)  
; SP SP + 2  
3.2.3.1  
Indirect Addressing with Autoincrement  
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]+  
PUSH [AX]+  
; AL BL + MEM_BYTE(CX)  
; CX CX + 1  
; SP SP - 2  
; MEM_WORD(SP) MEM_WORD(AX)  
; AX AX + 2  
3.2.3.2  
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  
3.2.4 Indexed Addressing  
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.  
3.2.4.1  
Short-indexed Addressing  
In a short-indexed instruction, you specify the offset as an 8-bit constant and the base address as  
an indirect address register (a WORD). The following instructions use short-indexed addressing.  
LD  
AX,12H[BX]  
; AX MEM_WORD(BX + 12H)  
×
MULB AX,BL,3[CX]  
; AX BL MEM_BYTE(CX + 3)  
3-7  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
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 12H (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 ad-  
dressing 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 struc-  
ture.  
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.  
LD  
AX,2[SP]  
3.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  
AND AX,BX,TABLE[CX]  
ST AX,TABLE[BX]  
ADDB AL,BL,LOOKUP[CX]  
AX,TABLE[BX]  
; AX MEM_WORD(TABLE + BX)  
; AX BX AND MEM_WORD(TABLE + CX)  
; MEM_WORD(TABLE + BX) AX  
; 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.  
3.2.4.3  
Zero-indexed Addressing  
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.  
LD  
LD  
LD  
AX,THISVAR[0]  
AX,THISVAR[ZERO_REG]  
AX,THISVAR  
The following instructions also use zero-indexed addressing:  
ADD AX,1234H[ZERO_REG]  
POP 5678H[ZERO_REG]  
; AX AX + MEM_WORD(1234H)  
; MEM_WORD(5678H) MEM_WORD(SP)  
; SP SP + 2  
3-8  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PROGRAMMING CONSIDERATIONS  
3.3 ASSEMBLY LANGUAGE ADDRESSING MODE SELECTIONS  
The assembly language simplifies the choice of addressing modes. Use these features wherever  
possible.  
3.3.1 Direct Addressing  
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.  
3.3.2 Indexed Addressing  
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.  
3.4 SOFTWARE STANDARDS AND CONVENTIONS  
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.  
3.4.1 Using Registers  
The 256-byte lower register file contains the CPU special-function registers and the stack pointer.  
The remainder of the lower register file and all of the upper register file is available for your use.  
Peripheral special-function registers (SFRs) and memory-mapped SFRs reside in higher memory.  
The peripheral SFRs can be windowed into the lower register 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 “Special-  
function Registers (SFRs)” on page 4-4 and “Register File” on page 4-9 for more information.  
3-9  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
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 bytes beginning  
at address 1CH as temporary storage and treats the remaining area in the register file as a segment  
of memory that is allocated as required.  
NOTE  
Using any SFR as a base or index register for indirect or indexed operations  
can cause unpredictable results because external events can change the  
contents of SFRs. Also, because some SFRs are cleared when read, consider  
the implications of using an SFR as an operand in a read-modify-write  
instruction (e.g., XORB).  
3.4.2 Addressing 32-bit Operands  
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.  
3.4.3 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 into 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 executes at run-time, the stack will contain the parameters in the following  
order:  
param3  
low word of param2  
high word of param2  
undefined;param1  
return address  
Stack Pointer  
3-10  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PROGRAMMING CONSIDERATIONS  
If a procedure returns a value to the calling code (as opposed to modifying more global variables),  
the result is returned in the temporary storage space (TMPREG0, in this example) starting at 1CH.  
TMPREG0 is viewed as either an 8-, 16-, or 32bit variable, depending on the type of the proce-  
dure.  
The standard calling convention adopted by the C programming language has several key fea-  
tures:  
Procedures can always assume that the eight bytes of register file memory starting at 1CH  
can be used as temporary storage within the body of the procedure.  
Code that calls a procedure must assume that the procedure modifies the eight bytes of  
register file memory starting at 1CH.  
Code that calls a procedure must assume that the procedure modifies the processor status  
word (PSW) condition flags because procedures do not save and restore the PSW.  
Function results from procedures are always returned in the variable TMPREG0.  
The C programming language allows the 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.  
3.5 SOFTWARE PROTECTION FEATURES AND GUIDELINES  
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. The watchdog timer (WDT) can also reset the device in the event of a hardware or software  
error.  
We recommend that you fill unused areas of code with NOPs and 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.  
3-11  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
When using the watchdog timer (WDT) for software protection, we recommend that you reset the  
WDT from only one place in code, reducing the chance of an undesired WDT reset. The section  
of code that resets the WDT should monitor the other code sections for proper operation. This can  
be done by checking variables to make sure they are within reasonable values. Simply using a  
software timer to reset the WDT every 10 milliseconds will provide protection only for cata-  
strophic failures.  
3-12  
Download from Www.Somanuals.com. All Manuals Search And Download.  
4
Memory  
Partitions  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
CHAPTER 4  
MEMORY PARTITIONS  
This chapter describes the address space, its major partitions, and a windowing technique for ac-  
cessing the upper register file and peripheral SFRs with register-direct instructions.  
4.1 MEMORY PARTITIONS  
Table 4-1 is a memory map of the 8XC196Mx devices. The remainder of this section describes  
the partitions.  
4.1.1 External Devices (Memory or I/O)  
Several partitions are assigned to external devices (see Table 4-1). Data can be stored in any part  
of this memory. Chapter 15, “Interfacing with External Memory,” describes the external memory  
interface and shows examples of external memory configurations. These partitions can also be  
used to interface with external peripherals connected to the address/data bus.  
4.1.2 Program and Special-purpose Memory  
Internal nonvolatile memory is an optional component of the 8XC196Mx devices. Various devic-  
es are available with masked ROM, EPROM, QROM, or OTPROM. Please consult the  
datasheets in the Embedded Microcontrollers databook for details.  
If present, the nonvolatile memory occupies the special-purpose memory and program memory  
partitions (locations 2000H and above; see Table 4-1 on page 4-2). The EA# signal controls ac-  
cess to these memory partitions. Accesses to these partitions are directed to internal memory if  
EA# is held high and to external memory if EA# is held low. For devices without internal non-  
volatile memory, the EA# signal must be tied low. EA# is latched at reset.  
4-1  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 4-1. Memory Map  
Device and  
Hex Address  
Range  
Description  
Addressing Modes  
MC, MD  
MH  
FFFF  
6000  
FFFF External device (memory or I/O) connected to the  
A000 address/data bus  
Indirect or indexed  
Indirect or indexed  
Indirect or indexed  
Indirect or indexed  
5FFF  
2080  
9FFF Program memory (internal nonvolatile or external  
2080 memory); see Note 1.  
207F  
2000  
207F Special-purpose memory (internal nonvolatile or  
2000 external memory)  
1FFF  
1FE0  
1FFF  
Memory-mapped SFRs  
1FE0  
1FDF  
1F00  
1FDF  
Indirect, indexed, or  
windowed direct  
Peripheral SFRs  
1F00  
1EFF  
0200  
1EFF External device (memory or I/O) connected to the  
0300 address/data bus (future SFR expansion; see Note 2)  
Indirect or indexed  
01FF  
0100  
02FF  
Indirect, indexed, or  
windowed direct  
Upper register file (general-purpose register RAM)  
0100  
00FF  
0000  
00FF Lower register file (general-purpose register RAM,  
0000 stack pointer, and CPU SFRs)  
Direct, indirect, or indexed  
NOTES:  
1. After a reset, the device fetches its first instruction from 2080H.  
2. The content or function of these locations may change in future device revisions, in which case a pro-  
gram that relies on a location in this range might not function properly.  
4.1.3 Program Memory  
Program memory occupies a memory partition beginning at 2080H. (See Table 4-1 for the ending  
address for each device.) This entire partition is available for storing executable code and data.  
The EA# signal controls access to program memory. Accesses to this address range are directed  
to internal memory if EA# is held high and to external memory if EA# is held low. For devices  
without internal nonvolatile memory, the EA# signal must be tied low. EA# is latched at reset.  
NOTE  
We recommend that you write FFH (the opcode for the RST instruction) to  
unused program memory locations. This causes a device reset if a program  
unintentionally begins to execute in unused memory.  
4-2  
Download from Www.Somanuals.com. All Manuals Search And Download.  
MEMORY PARTITIONS  
4.1.4 Special-purpose Memory  
Special-purpose memory resides in locations 2000–207FH (Table 4-2). It contains several re-  
served memory locations, the chip configuration bytes (CCBs), and vectors for both peripheral  
transaction server (PTS) and standard interrupts. Accesses to this address range are directed to  
internal memory if EA# is held high and to external memory if EA# is held low. For devices with-  
out internal nonvolatile memory, the EA# signal must be tied low. EA# is latched at reset.  
Table 4-2. Special-purpose Memory Addresses  
Hex Address  
Description  
207F  
205E  
Reserved (each byte must contain FFH)  
205D  
2040  
PTS vectors  
203F  
2030  
Upper interrupt vectors  
Security key  
202F  
2020  
201F  
201E  
201D  
201C  
201B  
201A  
2019  
2018  
Reserved (must contain 20H)  
Reserved (must contain FFH)  
Reserved (must contain 20H)  
Reserved (must contain FFH)  
Reserved (must contain 20H)  
CCB1  
Reserved (must contain 20H)  
CCB0  
2017  
2014  
Reserved (each byte must contain FFH)  
Lower interrupt vectors  
2013  
2000  
4.1.4.1  
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. The function or contents of these locations may  
change in future revisions; software that uses reserved locations may not function properly. Al-  
ways initialize reserved locations to the values listed in Table 4-2.  
4.1.4.2  
Interrupt and PTS Vectors  
The upper and lower interrupt vectors contain the addresses of the interrupt service routines. The  
peripheral transaction server (PTS) vectors contain the addresses of the PTS control blocks. See  
Chapter 5, “Standard and PTS Interrupts,” for more information on interrupt and PTS vectors.  
4-3  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
4.1.4.3  
Security Key  
The security key prevents unauthorized programming access to the nonvolatile memory. See  
Chapter 16, “Programming the Nonvolatile Memory,” for details.  
4.1.4.4  
Chip Configuration Bytes (CCBs)  
The chip configuration bytes (CCBs) specify the operating environment. They specify the bus  
width, bus-control mode, and wait states. They also control powerdown mode, the watchdog tim-  
er, and nonvolatile memory protection.  
The CCBs 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 pro-  
grammed once when the user program is compiled and are not redefined during normal operation.  
“Chip Configuration Registers and Chip Configuration Bytes” on page 15-5 describes the CCBs  
and CCRs.  
For devices with customer-programmable nonvolatile memory, the CCBs are loaded for normal  
operation, but the PCCBs are loaded into the CCRs if the device is entering programming modes.  
See Chapter 16, “Programming the Nonvolatile Memory,” for details.  
4.1.5 Special-function Registers (SFRs)  
These devices have both memory-mapped SFRs and peripheral SFRs. The memory-mapped  
SFRs must be accessed using indirect or indexed addressing modes, and they cannot be win-  
dowed. The peripheral SFRs are physically located in the on-chip peripherals, and they can be  
windowed (see “Windowing” on page 4-12). Do not use reserved SFRs; write zeros to them or  
leave them in their default state. When read, reserved bits and reserved SFRs return undefined  
values.  
NOTE  
Using any SFR as a base or index register for indirect or indexed operations  
can cause unpredictable results because external events can change the  
contents of SFRs. Also, because some SFRs are cleared when read, consider  
the implications of using an SFR as an operand in a read-modify-write  
instruction (e.g., XORB).  
4-4  
Download from Www.Somanuals.com. All Manuals Search And Download.  
MEMORY PARTITIONS  
4.1.5.1  
Memory-mapped SFRs  
Locations 1FE0–1FFFH contain memory-mapped SFRs (see Table 4-3). Locations in this range  
that are omitted from the table are reserved. The memory-mapped SFRs must be accessed with  
indirect or indexed addressing modes, and they cannot be windowed. If you read a location in this  
range through a window, the SFR appears to contain FFH (all ones). If you write a location in  
this range through a window, the write operation has no effect on the SFR.  
The memory-mapped SFRs are accessed through the memory controller, so instructions that op-  
erate on these SFRs execute as they would from external memory with zero wait states.  
Table 4-3. Memory-mapped SFRs  
Ports 3, 4, 5, UPROM SFRs  
Hex Address High (Odd) Byte Low (Even) Byte  
1FFE  
1FFC  
• • •  
P4_PIN  
P4_REG  
• • •  
P3_PIN  
P3_REG  
• • •  
1FF6  
1FF4  
1FF2  
1FF0  
P5_PIN  
P5_REG  
P5_DIR  
P5_MODE  
USFR  
Reserved  
Reserved  
Reserved  
4.1.5.2  
Peripheral SFRs  
Locations 1F00–1FDFH provide access to the peripheral SFRs. Table 4-6 on page 4-8, Table 4-6  
on page 4-8, and Table 4-6 on page 4-8 list the peripheral SFRs of the 8XC196MC, 8XC196MD,  
and 8XC196MH, respectively. Locations that are omitted from the tables are reserved. The pe-  
ripheral SFRs are I/O control registers; they are physically located in the on-chip peripherals.  
These peripheral SFRs can be windowed and they can be addressed either as words or bytes, ex-  
cept as noted in the tables.  
The peripheral SFRs are accessed directly, without using the memory controller, so instructions  
that operate on these SFRs execute as they would if they were operating on the register file.  
4-5  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 4-4. Peripheral SFRs — 8XC196MC  
Port 2 SFRs EPA and Timer SFRs  
High (Odd) Byte High (Odd) Byte Low (Even) Byte  
1FDEH Reserved  
Address  
Low (Even) Byte  
Reserved  
• • •  
Address  
1F7EH TIMER2 (H)  
1F7CH Reserved  
1F7AH TIMER1 (H)  
1F78H Reserved  
1F76H Reserved  
1F74H Reserved  
1F72H T1RELOAD (H)  
1F70H Reserved  
TIMER2 (L)  
T2CONTROL  
TIMER1 (L)  
T1CONTROL  
Reserved  
• • •  
• • •  
1FD6H Reserved  
1FD4H Reserved  
1FD2H Reserved  
1FD0H Reserved  
P2_PIN  
P2_REG  
P2_DIR  
P2_MODE  
Reserved  
Waveform Generator SFRs  
High (Odd) Byte Low (Even) Byte  
1FCEH Reserved WG_PROTECT  
T1RELOAD (L)  
Reserved  
Address  
• • •  
• • •  
• • •  
1FCCH WG_CONTROL(H) WG_CONTROL(L)  
1FCAH WG_COUNTER(H) WG_COUNTER(L)  
1F66H COMP3_TIME (H) COMP3_TIME (L)  
1F64H Reserved COMP3_CON  
1F62H COMP2_TIME (H) COMP2_TIME (L)  
1F60H Reserved COMP2_CON  
1F5EH COMP1_TIME (H) COMP1_TIME (L)  
1F5CH Reserved COMP1_CON  
1F5AH COMP0_TIME (H) COMP0_TIME (L)  
1FC8H WG_RELOAD (H)  
1FC6H WG_COMP3 (H)  
1FC4H WG_COMP2 (H)  
1FC2H WG_COMP1 (H)  
1FC0H WG_OUTPUT (H)  
WG_RELOAD (L)  
WG_COMP3 (L)  
WG_COMP2 (L)  
WG_COMP1 (L)  
WG_OUTPUT (L)  
Peripheral Interrupt and PWM SFRs  
Address High (Odd) Byte Low (Even) Byte  
1FBEH Reserved  
1FBCH Reserved  
1F58H Reserved  
1F56H Reserved  
COMP0_CON  
Reserved  
PI_PEND  
PI_MASK  
• • •  
• • •  
• • •  
1F4EH EPA3_TIME (H)  
1F4CH Reserved  
1F4AH EPA2_TIME (H)  
1F48H Reserved  
1F46H EPA1_TIME (H)  
1F44H Reserved  
1F42H EPA0_TIME (H)  
1F40H Reserved  
EPA3_TIME (L)  
EPA3_CON  
EPA2_TIME (L)  
EPA2_CON  
EPA1_TIME (L)  
EPA1_CON  
EPA0_TIME (L)  
EPA0_CON  
• • •  
• • •  
• • •  
1FB6H Reserved  
1FB4H Reserved  
1FB2H Reserved  
1FB0H Reserved  
PWM_COUNT  
PWM_PERIOD  
PWM1_CONTROL  
PWM0_CONTROL  
A/D SFRs  
High (Odd) Byte  
Address  
Low (Even) Byte  
AD_TEST  
1FAEH AD_TIME  
1FACH Reserved  
AD_COMMAND  
AD_RESULT (L)  
P0_PIN  
1FAAH AD_RESULT (H)  
1FA8H P1_PIN  
1FA6H Reserved  
Reserved  
• • •  
• • •  
• • •  
1F80H Reserved  
Reserved  
Must be addressed as a word.  
4-6  
Download from Www.Somanuals.com. All Manuals Search And Download.  
MEMORY PARTITIONS  
Table 4-5. Peripheral SFRs — 8XC196MD  
Ports 2 and 7 SFRs EPA and Timer SFRs  
High (Odd) Byte  
Address  
Low (Even) Byte  
Reserved  
Reserved  
Reserved  
Reserved  
P2_PIN  
Address  
High (Odd) Byte  
Low (Even) Byte  
TIMER2 (L)  
1FDEH Reserved  
1FDCH Reserved  
1FDAH Reserved  
1FD8H Reserved  
1FD6H P7_PIN  
1FD4H P7_REG  
1FD2H P7_DIR  
1FD0H P7_MODE  
1F7EH TIMER2 (H)  
1F7CH Reserved  
T2CONTROL  
TIMER1 (L)  
1F7AH TIMER1 (H)  
1F78H Reserved  
T1CONTROL  
Reserved  
1F76H Reserved  
P2_REG  
1F74H Reserved  
Reserved  
P2_DIR  
1F72H T1RELOAD (H)  
T1RELOAD (L)  
Reserved  
P2_MODE  
1F70H Reserved  
Waveform Generator SFRs  
1F6EH COMP5_TIME (H)  
1F6CH Reserved  
1F6AH COMP4_TIME (H)  
COMP5_TIME (L)  
COMP5_CON  
COMP4_TIME (L)  
COMP4_CON  
COMP3_TIME (L)  
COMP3_CON  
COMP2_TIME (L)  
COMP2_CON  
COMP1_TIME (L)  
COMP1_CON  
COMP0_TIME (L)  
COMP0_CON  
EPA5_TIME (L)  
EPA5_CON  
Address  
High (Odd) Byte  
Low (Even) Byte  
1FCEH Reserved  
WG_PROTECT  
1FCCH WG_CONTROL(H) WG_CONTROL(L)  
1FCAH WG_COUNTER(H) WG_COUNTER(L)  
1F68H Reserved  
1F66H COMP3_TIME (H)  
1F64H Reserved  
1F62H COMP2_TIME (H)  
1FC8H WG_RELOAD (H)  
1FC6H WG_COMP3 (H)  
1FC4H WG_COMP2 (H)  
1FC2H WG_COMP1 (H)  
1FC0H WG_OUTPUT (H)  
WG_RELOAD (L)  
WG_COMP3 (L)  
WG_COMP2 (L)  
WG_COMP1 (L)  
WG_OUTPUT (L)  
1F60H Reserved  
1F5EH COMP1_TIME (H)  
1F5CH Reserved  
1F5AH COMP0_TIME (H)  
Periph. Int., Freq. Gen., and PWM SFRs  
Address  
High (Odd) Byte  
Low (Even) Byte  
PI_PEND  
1F58H Reserved  
1FBEH Reserved  
1FBCH Reserved  
1FBAH Reserved  
1FB8H Reserved  
1FB6H Reserved  
1FB4H Reserved  
1FB2H Reserved  
1FB0H Reserved  
1F56H EPA5_TIME (H)  
1F54H Reserved  
1F52H EPA4_TIME (H)  
PI_MASK  
FREQ_CNT  
EPA4_TIME (L)  
EPA4_CON  
FREQ_GEN  
1F50H Reserved  
PWM_COUNT  
PWM_PERIOD  
PWM1_CONTROL  
PWM0_CONTROL  
1F4EH EPA3_TIME (H)  
1F4CH Reserved  
1F4AH EPA2_TIME (H)  
EPA3_TIME (L)  
EPA3_CON  
EPA2_TIME (L)  
EPA2_CON  
1F48H Reserved  
A/D SFRs  
High (Odd) Byte  
1F46H EPA1_TIME (H)  
1F44H Reserved  
1F42H EPA0_TIME (H)  
EPA1_TIME (L)  
EPA1_CON  
Address  
Low (Even) Byte  
AD_TEST  
1FAEH AD_TIME  
1FACH Reserved  
EPA0_TIME (L)  
EPA0_CON  
AD_COMMAND  
AD_RESULT (L)  
P0_PIN  
1F40H Reserved  
1FAAH AD_RESULT (H)  
1FA8H P1_PIN  
• • •  
• • •  
• • •  
1F80H Reserved  
Reserved  
Must be addressed as a word.  
4-7  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 4-6. Peripheral SFRs — 8XC196MH  
Port 0 and 2 SFRs Port 1 SFRs  
High (Odd) Byte High (Odd) Byte  
1F9EH P1_PIN  
Address  
Low (Even) Byte  
Reserved  
Reserved  
P0_PIN  
Address  
Low (Even) Byte  
Reserved  
Reserved  
Reserved  
Reserved  
• • •  
1FDEH Reserved  
1FDCH Reserved  
1FDAH Reserved  
1FD8H Reserved  
1FD6H Reserved  
1FD4H Reserved  
1FD2H Reserved  
1FD0H Reserved  
1F9CH P1_REG  
1F9AH P1_DIR  
1F98H P1_MODE  
Reserved  
P2_PIN  
• • •  
• • •  
Serial I/O Port SFRs  
High (Odd) Byte Low (Even) Byte  
P2_REG  
P2_DIR  
Address  
P2_MODE  
1F8EH Reserved  
Reserved  
Waveform Generator SFRs  
1F8CH SP1_BAUD(H)  
1F8AH SP1_CON  
1F88H SP1_STATUS  
1F86H Reserved  
SP1_BAUD (L)  
SBUF1_TX  
SBUF1_RX  
Reserved  
Address  
High (Odd) Byte  
Low (Even) Byte  
1FCEH Reserved  
WG_PROTECT  
1FCCH WG_CONTROL(H) WG_CONTROL (L)  
1FCAH WG_COUNTER(H) WG_COUNTER (L)  
1F84H SP0_BAUD (H)  
1F82H SP0_CON  
1F80H SP0_STATUS  
SP0_BAUD (L)  
SBUF0_TX  
SBUF0_RX  
1FC8H WG_RELOAD (H)  
1FC6H WG_COMP3 (H)  
1FC4H WG_COMP2 (H)  
1FC2H WG_COMP1 (H)  
1FC0H WG_OUTPUT (H)  
WG_RELOAD (L)  
WG_COMP3 (L)  
WG_COMP2 (L)  
WG_COMP1 (L)  
WG_OUTPUT (L)  
EPA and Timer SFRs  
High (Odd) Byte  
Address  
Low (Even) Byte  
TIMER2 (L)  
T2CONTROL  
TIMER1 (L)  
T1CONTROL  
• • •  
1F7EH TIMER2 (H)  
1F7CH Reserved  
1F7AH TIMER1 (H)  
1F78H Reserved  
Peripheral Interrupt and PWM SFRs  
Address High (Odd) Byte Low (Even) Byte  
1FBEH Reserved  
PI_PEND  
1FBCH Reserved  
1FBAH Reserved  
1FB8H Reserved  
1FB6H Reserved  
1FB4H Reserved  
1FB2H Reserved  
1FB0H Reserved  
PI_MASK  
• • •  
1F72H T1RELOAD (H)  
• • • • • •  
• • •  
Reserved  
T1RELOAD (L)  
• • •  
Reserved  
PWM_COUNT  
PWM_PERIOD  
PWM1_CONTROL  
PWM0_CONTROL  
1F62H COMP2_TIME(H) COMP2_TIME(L)  
1F60H Reserved COMP2_CON  
1F5EH COMP1_TIME(H) COMP1_TIME(L)  
1F5CH Reserved COMP1_CON  
1F5AH COMP0_TIME(H) COMP0_TIME(L)  
A/D SFRs  
High (Odd) Byte  
Address  
Low (Even) Byte  
AD_TEST  
1F58H Reserved  
• • • • • •  
1F4EH COMP3_TIME(H) COMP3_TIME(L)  
COMP0_CON  
• • •  
1FAEH AD_TIME  
1FACH Reserved  
AD_COMMAND  
AD_RESULT (L)  
1FAAH AD_RESULT (H)  
1F4CH Reserved  
COMP3_CON  
• • •  
Reset Control SFR  
High (Odd) Byte  
1FA8H Reserved  
• • •  
• • •  
Address  
Low (Even) Byte  
Reserved  
• • •  
1F46H EPA1_TIME (H)  
1F44H Reserved  
1F42H EPA0_TIME (H)  
1F40H Reserved  
EPA1_TIME (L)  
EPA1_CON  
EPA0_TIME (L)  
EPA0_CON  
• • •  
• • •  
1FA0H Reserved  
Must be addressed as a word.  
GEN_CON  
4-8  
Download from Www.Somanuals.com. All Manuals Search And Download.  
MEMORY PARTITIONS  
4.1.6 Register File  
The register file (Figure 4-1) is divided into an upper register file and a lower register file. The  
upper register file consists of general-purpose register RAM. The lower register file contains gen-  
eral-purpose register RAM along with the stack pointer (SP) and the CPU special-function regis-  
ters (SFRs).  
Table 4-1 on page 4-2 lists the register file memory addresses. The RALU accesses the lower reg-  
ister file directly, without the use of the memory controller. It also accesses a windowed location  
directly (see “Windowing” on page 4-12). The upper register file and the peripheral SFRs can be  
windowed. Registers in the lower register file and registers being windowed can be accessed with  
register-direct addressing.  
NOTE  
The register file must not contain code. An attempt to execute an instruction  
from a location in the register file causes the memory controller to fetch the  
instruction from external memory.  
Address  
02FFH (MH)  
General-purpose  
Register RAM  
0200H  
01FFH (MC, MD)  
Address  
0100H  
00FFH  
02FFH  
General-purpose  
Register RAM  
Upper  
Register File  
001AH  
0019H  
0018H  
0017H  
0000H  
0100H  
00FFH  
Stack Pointer  
CPU SFRs  
Lower  
Register File  
0000H  
A3066-02  
Figure 4-1. Register File Memory Map  
4-9  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 4-7. Register File Memory Addresses  
Device and Hex  
Address Range  
Description  
Addressing Modes  
MC, MD  
MH  
01FF  
0100  
02FF  
0100  
Upper register file (register RAM)  
Lower register file (register RAM)  
Lower register file (stack pointer)  
Lower register file (CPU SFRs)  
Indirect, indexed, or windowed direct  
Direct, indirect, or indexed  
Direct, indirect, or indexed  
Direct, indirect, or indexed  
00FF  
001A  
00FF  
001A  
0019  
0018  
0019  
0018  
0017  
0000  
0017  
0000  
4.1.6.1  
General-purpose Register RAM  
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 register-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 register-direct addressing to access this memory. (See Chapter 3, “Programming  
Considerations,” for a discussion of addressing modes.) Windowing can provide for fast context  
switching of interrupt tasks and faster program execution. (See “Windowing” on page 4-12.) PTS  
control blocks and the stack are most efficient when located in the upper register file.  
4.1.6.2  
Stack Pointer (SP)  
Memory locations 0018H and 0019H contain the stack pointer (SP). The SP contains the address  
of the stack. The SP must point to a word (even) address that is two bytes greater than the desired  
starting address. Before the CPU executes a subroutine call or interrupt service routine, it decre-  
ments the SP by two and 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) instruction at the end of  
the subroutine or interrupt service routine, the CPU loads (POPs) the contents of the top of the  
stack (that is, the return address) into the program counter and increments the SP by two.  
Subroutines may be nested. That is, each subroutine may call other subroutines. The CPU pushes  
the contents of the program counter onto the stack each time it executes a subroutine call. The  
stack grows downward as entries are added. The only limit to the nesting depth is the amount of  
available memory. As the CPU returns from each nested subroutine, it pops the address off the  
top of the stack, and the next return address moves to the top of the stack.  
4-10  
Download from Www.Somanuals.com. All Manuals Search And Download.  
MEMORY PARTITIONS  
Your program must load a word-aligned (even) address into the stack pointer. Select an address  
that is two bytes greater than the desired starting address because the CPU automatically decre-  
ments the stack pointer before it pushes the first byte of the return address onto the stack. Remem-  
ber that the stack grows downward, so allow sufficient room for the maximum number of stack  
entries. The stack must be located in either the internal register file or external RAM. The stack  
can be used most efficiently when it is located in the register file.  
The following example initializes the top of the upper register file (8XC196MC, MD) as the  
stack. (For the 8XC196MH, the immediate value would be #300H.)  
LD  
SP, #200H  
;Load stack pointer  
The following example shows how to allow the linker locator to determine where the stack fits  
in the memory map that you specify.  
LD  
SP, #STACK  
4.1.6.3  
CPU Special-function Registers (SFRs)  
Locations 0000–0017H in the lower register file are the CPU SFRs (Table 4-8). Appendix C de-  
scribes the CPU SFRs.  
Table 4-8. CPU SFRs  
Address High (Odd) Byte Low (Even) Byte  
0016H  
0014H  
0012H  
0010H  
000EH  
000CH  
000AH  
0008H  
0006H  
0004H  
0002H  
0000H  
Reserved  
Reserved  
Reserved  
WSR  
INT_MASK1  
Reserved  
INT_PEND1  
Reserved  
Reserved  
Reserved  
Reserved  
Reserved  
Reserved  
WATCHDOG  
INT_MASK  
PTSSRV (L)  
PTSSEL (L)  
ONES_REG (L)  
ZERO_REG (L)  
INT_PEND  
PTSSRV (H)  
PTSSEL (H)  
ONES_REG (H)  
ZERO_REG (H)  
NOTE  
Using any SFR as a base or index register for indirect or indexed operations  
can cause unpredictable results because external events can change the  
contents of SFRs. Also, because some SFRs are cleared when read, consider  
the implications of using an SFR as an operand in a read-modify-write  
instruction (e.g., XORB).  
4-11  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
4.2 WINDOWING  
Windowing expands the amount of memory that is accessible with register-direct addressing.  
Register-direct addressing can access the lower register file with short, fast-executing instruc-  
tions. With windowing, register-direct addressing can also access the upper register file and pe-  
ripheral SFRs.  
Windowing maps a segment of higher memory (the upper register file or peripheral SFRs) into  
the lower register file. The window selection register (WSR) selects a 32-, 64-, or 128-byte seg-  
ment of higher memory to be windowed into the top of the lower register file space. Figure 4-2  
illustrates a 128-byte window.  
02FFH  
01FFH  
128-byte Window  
(WSR = 13H)  
128-byte Window  
(WSR = 13H)  
0180H  
00FFH  
0080H  
WSR Window in  
Lower Register File  
WSR Window in  
Lower Register File  
0000H  
8XC196MC,MD  
8XC196MH  
A3062-01  
Figure 4-2. Windowing  
NOTE  
Memory-mapped SFRs must be accessed using indirect or indexed addressing  
modes; they cannot be accessed through a window. Reading a memory-  
mapped SFR through a window returns FFH (all ones), and writing to a  
memory-mapped SFR through a window has no effect.  
4-12  
Download from Www.Somanuals.com. All Manuals Search And Download.  
MEMORY PARTITIONS  
4.2.1 Selecting a Window  
The window selection register (Figure 4-3) selects a window to be mapped into the top of the low-  
er register file.  
Table 4-9 provides a quick reference of WSR values for windowing the peripheral SFRs. Table  
4-10 on page 4-14 lists the WSR values for windowing the upper register file.  
Address:  
Reset State:  
0014H  
00H  
WSR  
The window selection register (WSR) maps 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
0
W6  
W5  
W4  
W3  
W2  
W1  
W0  
Bit  
Bit  
Function  
Number Mnemonic  
7
Reserved; for compatibility with future devices, write zero to this bit.  
Window Selection  
6:0  
W6:0  
These bits specify the window size and number. See Table 4-9 on page  
4-13 or Table 4-10 on page 4-14. See Table 4-9 for peripheral SFR windows  
or Table 4-10 for upper register file windows.  
Figure 4-3. Window Selection (WSR) Register  
Table 4-9. Selecting a Window of Peripheral SFRs  
WSR Value for  
WSR Value for  
WSR Value for  
Peripherals  
32-byte Window 64-byte Window 128-byte Window  
(00E0–00FFH)  
(00C0–00FFH)  
(0080–00FFH)  
Port 2  
Waveform generator  
7EH  
3FH  
Port 7 (MD only)  
Peripheral interrupts  
Pulse-width modulator  
A/D converter  
1FH  
7DH  
Frequency generator (MD only)  
Reset control (MH only)  
3EH  
3DH  
Port 1 (MH only)  
Serial I/O port (MH only)  
7CH  
7BH  
Timer 1–2  
EPA compare 2–3 (MC)  
EPA compare 0–5 (MD)  
EPA compare 0–2 (MH)  
1EH  
EPA capture/compare 0–3 (MC)  
EPA compare 0–1 (MC)  
EPA capture/compare 0–5 (MD)  
EPA capture/compare 0–1 (MH)  
EPA compare 3 (MH)  
7AH  
4-13  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 4-10. Selecting a Window of the Upper Register File  
WSR Value  
for 32-byte Window  
(00E0–00FFH)  
WSR Value  
for 64-byte Window  
(00C0–00FFH)  
WSR Value  
for 128-byte Window  
(0080–00FFH)  
Register RAM  
Locations  
8XC196MH Only  
02E0–02FFH  
02C0–02DFH  
02A0–02BFH  
0280–029FH  
0260–027FH  
0240–025FH  
0220–023FH  
0200–021FH  
57H  
56H  
55H  
54H  
53H  
52H  
51H  
50H  
2BH  
2AH  
29H  
28H  
15H  
14H  
8XC196MC, 8XC196MD, and 8XC196MH  
01E0–01FFH  
01C0–01DFH  
01A0–01BFH  
0180–019FH  
0160–017FH  
0140–015FH  
0120–013FH  
0100–011FH  
4FH  
4EH  
4DH  
4CH  
4BH  
4AH  
49H  
48H  
27H  
26H  
25H  
24H  
13H  
12H  
4.2.2 Addressing a Location Through a Window  
After you have selected the desired window, you need to know the windowed direct address of  
the memory location (the address in the lower register file). Calculate the windowed direct ad-  
dress as follows:  
1. Subtract the base address of the area to be remapped (from Table 4-11 on page 4-15) from  
the address of the desired location. This gives you the offset of that particular location.  
2. Add the offset to the base address of the window (from Table 4-12 on page 4-15). The  
result is the windowed direct address.  
Appendix C includes a table of the windowable SFRs with the WSR values and windowed direct  
addresses for each window size. Examples beginning on page 4-16 explain how to determine the  
WSR value and windowed direct address for any windowable location. An additional example  
shows how to set up a window by using the linker locator.  
4-14  
Download from Www.Somanuals.com. All Manuals Search And Download.  
MEMORY PARTITIONS  
Table 4-11. Windows  
WSR Value for  
128-byte  
Window  
(0080–00FFH)  
WSR Value  
for 32-byte Window  
WSR Value  
for 64-byte Window  
(00C0–00FFH)  
Base  
Address  
(00E0–00FFH)  
Peripheral SFRs  
1FE0H  
1FC0H  
1FA0H  
1F80H  
1F60H  
1F40H  
1F20H  
1F00H  
02E0H  
02C0H  
02A0H  
0280H  
0260H  
0240H  
0220H  
0200H  
01E0H  
01C0H  
01A0H  
0180H  
0160H  
0140H  
0120H  
0100H  
7FH (Note)  
7EH  
7DH  
7CH  
7BH  
7AH  
79H  
3FH (Note)  
3EH  
1FH (Note)  
1EH  
3DH  
3CH  
2BH  
78H  
57H  
56H  
55H  
54H  
2AH  
15H  
53H  
52H  
29H  
51H  
50H  
28H  
14H  
4FH  
4EH  
4DH  
4CH  
4BH  
4AH  
49H  
27H  
26H  
13H  
25H  
48H  
24H  
12H  
NOTE: Locations 1FE0–1FFFH contain memory-mapped SFRs that cannot be accessed through a  
window. Reading these locations through a window returns FFH; writing these locations  
through a window has no effect.  
Table 4-12. Windowed Base Addresses  
WSR Windowed Base Address  
Window Size  
(Base Address in Lower Register File)  
32-byte  
64-byte  
128-byte  
00E0H  
00C0H  
0080H  
4-15  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Appendix C includes a table of the windowable SFRs with the WSR values and direct addresses  
for each window size. The following examples explain how to determine the WSR value and di-  
rect address for any windowable location. An additional example shows how to set up a window  
by using the linker locator.  
4.2.2.1  
32-byte Windowing Example  
Assume that you wish to access location 014BH (a location in the upper register file used for gen-  
eral-purpose register RAM) with register-direct addressing through a 32-byte window. Table 4-11  
on page 4-15 shows that you need to write 4AH to the window selection register. It also shows  
that the base address of the 32-byte memory area is 0140H. To determine the offset, subtract that  
base address from the address to be accessed (014BH – 0140H = 000BH). Add the offset to the  
base address of the window in the lower register file (00E0H, from Table 4-12). The direct ad-  
dress is 00EBH (000BH + 00E0H).  
4.2.2.2  
64-byte Windowing Example  
Assume that you wish to access the WG_CONTROL register (location 1FCCH) with register-di-  
rect addressing through a 64-byte window. Table 4-11 shows that you need to write 3FH to the  
window selection register. It also shows that the base address of the 64-byte memory area is  
1FC0H. To determine the offset, subtract that base address from the address to be accessed  
(1FCCH – 1FC0H = 000CH). Add the offset to the base address of the window in the lower reg-  
ister file (00C0H, from Table 4-12). The direct address is 00CCH (000CH + 00C0H).  
4.2.2.3  
128-byte Windowing Example  
Assume that you wish to access location 1F42H (the EPA0_TIME register) with register-direct  
addressing through a 128-byte window. Table 4-11 shows that you need to write 1EH to the win-  
dow selection register. It also shows that the base address of the 128-byte memory area is 1F00H.  
To determine the offset, subtract that base address from the address to be accessed (1F42H –  
1F00H = 0042H). Add the offset to the base address of the window in the lower register file  
(0080H, from Table 4-12). The direct address is 00C2H (0042H + 0080H).  
4.2.2.4  
Unsupported Locations Windowing Example  
Assume that you wish to access location 1FF1H (the P5_MODE register, a memory-mapped  
SFR) with register-direct addressing through a 128-byte window. This location is in the range of  
addresses (1FE0–1FFFH) that cannot be windowed. Although you could set up the window by  
writing 1FH to the WSR, reading this location through the window would return FFH (all ones)  
and writing to it would not change the contents. However, you could access the peripheral SFRs  
in the range of 1F80–1FDFH with their windowed direct addresses.  
4-16  
Download from Www.Somanuals.com. All Manuals Search And Download.  
MEMORY PARTITIONS  
4.2.2.5  
Using the Linker Locator to Set Up a Window  
In this example, the linker locator is used to set up a window. The linker locator locates the 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  
public function1  
extrn ?WSR  
;Main module for linker  
;Must declare ?WSR as external  
wsr equ  
14h:byte  
sp  
equ  
18h:word  
oseg  
var1:  
var2:  
var3:  
dsw 1  
dsw 1  
dsw 1  
;Allocate variables in an  
;overlayable segment  
cseg  
function1:  
ldb  
push wsr  
;Prolog code for wsr  
;Prolog code for wsr  
wsr, #?WSR  
add var1, var2, var3  
;Use the variables as registers  
;
;
;
ldb wsr, [sp]  
add sp, #2  
ret  
;Epilog code for wsr  
;Epilog code for wsr  
end  
******** mod2 **************  
public function2  
extrn ?WSR  
wsr equ  
14h:byte  
18h:word  
sp  
equ  
oseg  
var1:  
var2:  
var3:  
dsw 1  
dsw 1  
dsw 1  
cseg  
function2:  
push wsr  
;Prolog code for wsr  
4-17  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
ldb  
wsr, #?WSR  
;Prolog code for wsr  
add var1, var2, var3  
;
;
;
ldb wsr, [sp]  
add sp, #2  
ret  
;Epilog code for wsr  
;Epilog code for wsr  
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-01ffh) windowsize(32)  
The above linker controls tell the linker to use registers 0100–01FFH 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  
------  
001AH  
0006H  
00E0H  
0006H  
0006H  
1F74H  
0011H  
0011H  
DF5EH  
ALIGNMENT  
---------  
MODULE NAME  
-----------  
**RESERVED*  
*** GAP ***  
0000H  
001AH  
0020H  
0100H  
0106H  
010CH  
2080H  
2091H  
20A2H  
STACK  
WORD  
OVRLY  
OVRLY  
WORD  
WORD  
MOD2  
MOD1  
*** GAP ***  
*** GAP ***  
CODE  
CODE  
BYTE  
BYTE  
MOD2  
MOD1  
This listing shows the disassembled code:  
2080H  
2082H  
2085H  
2089H  
208CH  
2090H  
2091H  
2093H  
2096H  
209AH  
209DH  
20A1H  
;C814  
| PUSH WSR  
;B14814  
;44E4E2E0  
;B21814  
;65020018  
;F0  
| LDB  
| ADD  
| LDB  
| ADD  
| RET  
WSR,#48H  
E0H,E2H,E4H  
WSR,[SP]  
SP,#02H  
;C814  
| PUSH WSR  
;B14814  
;44EAE8E6  
;B21814  
;65020018  
;F0  
| LDB  
| ADD  
| LDB  
| ADD  
| RET  
WSR,#48H  
E6H,E8H,EAH  
WSR,[SP]  
SP,#02H  
4-18  
Download from Www.Somanuals.com. All Manuals Search And Download.  
MEMORY PARTITIONS  
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.  
4.2.3 Windowing and Addressing Modes  
Once windowing is enabled, the windowed locations can be accessed both through the window  
using direct (8-bit) addressing and by the usual 16-bit addressing. The lower register file locations  
that are covered by the window are always accessible by indirect or indexed operations. To re-  
enable direct access to the entire lower register file, clear the WSR. To enable direct access to a  
particular location in the lower register file, you can select a smaller window that does not cover  
that location.  
When windowing is enabled:  
a register-direct instruction that uses an address within the lower register file actually  
accesses the window in the upper register file;  
an indirect, indexed, or zero-register instruction that uses an address within either the lower  
register file or the upper register file accesses the actual location in memory.  
The following sample code illustrates the difference between register-direct and indexed address-  
ing when using windowing.  
PUSHA  
LDB WSR, #12H  
; pushes the contents of WSR onto the stack  
; select window 12H, a 128-byte block  
; The next instruction uses register-direct addr  
; mem_word(40H)mem_word(40H) + mem_word(380H)  
; The next two instructions use indirect addr  
; mem_word(40H)mem_word(40H) + mem_word(80H +0)  
; mem_word(40H)mem_word(40H) + mem_word(380H +0)  
; reloads the previous contents into WSR  
ADD 40H, 80H  
ADD 40H, 80H[0]  
ADD 40H, 380H[0]  
POPA  
4-19  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
5
Standard and PTS  
Interrupts  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
CHAPTER 5  
STANDARD AND PTS INTERRUPTS  
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 sev-  
en PTS modes, four of which are used with the EPA to provide a software serial I/O channel for  
both synchronous and asynchronous transfers and receptions. It also explains interrupt program-  
ming and control.  
5.1 OVERVIEW OF INTERRUPTS  
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 4,  
“Memory Partitions”) contain the interrupt service routines’ addresses. The peripheral transac-  
tion server (PTS), a microcoded hardware interrupt processor, provides high-speed, low-over-  
head interrupt handling; it does not modify the stack or the PSW. You can configure most  
interrupts (except NMI, trap, and unimplemented opcode) to be serviced by the PTS instead of  
the interrupt controller.  
The PTS supports seven 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; manage multiple analog-to-dig-  
ital (A/D) conversions; and transmit and receive serial data in either asynchronous or synchro-  
nous mode (MC, MD only). PTS interrupts have a higher priority than standard interrupts 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 5-24). When a PTS interrupt occurs,  
the priority encoder selects the appropriate vector and fetches the PTS control block (PTSCB).  
5-1  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Interrupt Pending or PTSSRV Bit Set  
NMI  
Pending  
?
Yes  
No  
No  
INT_MASK.x  
= 1?  
Return  
Yes  
PTS  
Enabled?  
No  
No  
No  
Interrupts  
Enabled  
?
Return  
Yes  
Yes  
PTSSEL.x  
Bit = 1?  
Priority  
Encoder  
Yes  
Highest Priority Interrupt  
Priority  
Encoder  
Yes  
No  
Highest Priority PTS Interrupt  
PTSSRV.x  
= 1?  
Reset INT_PEND.x  
Bit  
Reset PTSSRV.x  
Bit  
Reset INT_PEND.x  
Bit  
Execute 1 PTS Cycle  
(Microcoded)  
Decrement  
PTSCOUNT  
PUSH PC  
on Stack  
LJMP to  
ISR  
No  
Return  
PTSCOUNT  
= 0?  
Execute Interrupt  
Service Routine  
Yes  
Clear PTSSEL.x Bit  
POP PC  
from Stack  
Set PTSSRV.x Bit  
Return  
Return  
A0320-02  
Figure 5-1. Flow Diagram for PTS and Standard Interrupts  
5-2  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
Figure 5-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.  
5.2 INTERRUPT SIGNALS AND REGISTERS  
Table 5-1 describes the external interrupt signals and Table 5-2 describes the control and status  
registers for both the interrupt controller and PTS.  
Table 5-1. Interrupt Signals  
Port Pin  
Interrupt Signal Type  
EXTINT I  
Description  
External Interrupt  
This programmable interrupt is controlled by the  
WG_PROTECT register. This register controls whether the  
interrupt is edge triggered or sampled and whether a rising  
edge/high level or falling edge/low level activates the  
interrupt.  
In powerdown mode, asserting the EXTINT signal for at least  
50 ns causes the device to resume normal operation. The  
interrupt need not be enabled. If the EXTINT 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.  
Table 5-2. Interrupt and PTS Control and Status Registers  
Address Description  
0008H  
Mnemonic  
INT_MASK  
Interrupt Mask Registers  
INT_MASK1  
0013H  
These registers enable/disable each maskable interrupt (that is,  
each interrupt except unimplemented opcode, software trap, and  
NMI).  
INT_PEND  
0009H  
0012H  
Interrupt Pending Registers  
INT_PEND1  
The bits in this register are set by hardware to indicate that an  
interrupt is pending.  
PI_MASK  
1FBCH  
Peripheral Interrupt Mask  
The bits in this register enable and disable (mask) the timer 1 and 2  
overflow/underflow interrupt requests, the waveform generator  
interrupt request (MC, MD), the EPA compare-only channel 5  
interrupt request (MD), and the serial port error interrupts (MH).  
5-3  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 5-2. Interrupt and PTS Control and Status Registers (Continued)  
Mnemonic Address Description  
PI_PEND 1FBEH Peripheral Interrupt Pending  
Any bit set indicates a pending interrupt request.  
No direct access Processor Status Word  
This register contains one bit that globally enables or disables  
PSW  
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  
PTSSRV  
0004H, 0005H  
0006H, 0007H  
PTS Select Register  
This register selects either a PTS routine or a standard interrupt  
service routine for each of the maskable interrupt requests.  
PTS Service Register  
The bits in this register are set by hardware to request an end-of-  
PTS interrupt.  
5.3 INTERRUPT SOURCES AND PRIORITIES  
Table 5-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.  
5-4  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
Table 5-3. Interrupt Sources, Vectors, and Priorities  
Interrupt Controller  
Service  
PTS Service  
Interrupt Source  
Mnemonic  
Nonmaskable Interrupt  
EXTINT Pin  
NMI  
INT15  
203EH  
203CH  
30  
14  
EXTINT  
INT14  
PTS14  
205CH  
29  
WF Gen (MC)  
PI  
WF Gen & EPA Comp 5 (MD) PI †  
INT13  
203AH  
2038H  
2036H  
2034H  
13  
12  
11  
10  
PTS13  
205AH  
28  
27  
26  
25  
WG  
Waveform Generator (MH)  
Reserved (MC)  
EPA Cap/Comp 5 (MD)  
SIO0 & 1 Receive Err (MH)  
Reserved (MC)  
EPA5  
SPI †  
INT12  
INT11  
INT10  
PTS12  
PTS11  
PTS10  
2058H  
2056H  
2054H  
EPA Compare 4 (MD)  
SIO1 Receive (MH)  
Reserved (MC)  
COMP4  
RI1  
EPA Cap/Comp 4 (MD)  
SIO0 Receive (MH)  
EPA Compare 3 (MC, MD)  
EPA4  
RI0  
COMP3  
TI1  
INT09  
INT08  
2032H  
2030H  
09  
08  
PTS09  
PTS08  
2052H  
2050H  
24  
23  
SIO1 Transmit (MH)  
EPA Cap/Comp 3 (MC, MD)  
SIO0 Transmit (MH)  
EPA3  
TI0  
Unimplemented Opcode  
Software TRAP Instruction  
EPA Compare 2 (MC, MD)  
EPA Compare 3 (MH)  
EPA Cap/Comp 2 (MC, MD)  
EPA Compare 2 (MH)  
EPA Compare 1  
2012H  
2010H  
COMP2  
COMP3  
EPA2  
INT07  
INT06  
200EH  
200CH  
07  
06  
PTS07  
PTS06  
204EH  
204CH  
22  
21  
COMP2  
COMP1  
EPA1  
INT05  
INT04  
INT03  
INT02  
INT01  
INT00  
200AH  
2008H  
2006H  
2004H  
2002H  
2000H  
05  
04  
03  
02  
01  
00  
PTS05  
PTS04  
PTS03  
PTS02  
PTS01  
PTS00  
204AH  
2048H  
2046H  
2044H  
2042H  
2040H  
20  
19  
18  
17  
16  
15  
EPA Capture/Compare 1  
EPA Compare 0  
COMP0  
EPA0  
EPA Capture/Compare 0  
A/D Conversion Complete  
AD_DONE  
OVRTM †  
Timer 1 or 2 Overflow  
PTS service is not useful for multiplexed interrupts because the PTS cannot readily determine the  
source of these interrupts.  
5-5  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
5.3.1 Special Interrupts  
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.  
5.3.1.1  
Unimplemented Opcode  
If the CPU attempts to execute an unimplemented opcode, an indirect vector through location  
2012H occurs. This prevents random software execution during hardware and software failures.  
The interrupt vector should contain the starting address of an error routine that will not further  
corrupt an already erroneous situation. The unimplemented opcode interrupt prevents other inter-  
rupt requests from being acknowledged until after the next instruction is executed.  
5.3.1.2  
Software Trap  
The TRAP instruction (opcode F7H) causes an interrupt call that is vectored through location  
2010H. The TRAP instruction provides a single-instruction interrupt that is useful when debug-  
ging software or generating software interrupts. The TRAP instruction prevents other interrupt  
requests from being acknowledged until after the next instruction is executed.  
5.3.1.3  
NMI  
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 203EH.  
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 system does not use the NMI interrupt, connect the NMI pin to VSS to prevent spurious  
interrupts.  
5.3.2 External Interrupt Pin  
The protection circuitry in the waveform generator (Figure 5-2) monitors the external interrupt  
(EXTINT) signal. When it detects a valid event on the input, it sumultaneously disables the wave-  
form generator outputs and generates an EXTINT interrupt request. Bits 2 and 3 in the waveform  
generator protection (WG_PROTECT) register (Figure 9-9 on page 9-15) select the type of ex-  
ternal event that will generate an interrupt request: a falling or rising edge or a low or high level.  
5-6  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
When the level-sensitive event is selected, the external interrupt signal must remain asserted for  
at least 24 TXTAL1 (24/FXTAL1) to be recognized as a valid interrupt. When the signal is asserted,  
the level sampler samples the level of the signal three times during a 24 TXTAL1 period. When a  
valid level occurs, the level sampler generates a a single output pulse. The output pulse generates  
the EXTINT interrupt request. The level-sensitive mode is useful in noisy environments, where  
a noise spike might cause an unintentional interrupt request.  
When an edge-triggered event is selected, the input must remain asserted for at least two TXTAL1  
(2/FXTAL1) to be recognized as a valid interrupt. When a valid transition occurs, the transition de-  
tector generates a single output pulse. The output pulse generates the EXTINT interrupt request.  
ES, IT  
EXTINT  
Interrupt  
Request  
DP  
EO Bit  
Register  
Falling  
Rising  
00  
01  
Pulse  
Transition  
Detector  
R
Q
S
OD#  
EXTINT  
FXTAL1  
Low  
10  
11  
Level  
Sampler  
High  
CPU Write EO  
CPU Read EO  
CPU Bus  
A2661-01  
Figure 5-2. Waveform Generator Protection Circuitry  
5.3.3 Multiplexed Interrupt Sources  
The PI (MD), OVRTM (Mx), and SPI (MH) interrupts have multiple sources (see Table 5-3 on  
page 5-5). An individual source will generate the interrupt only if software enables both the in-  
terrupt source and multiplexed interrupt. To enable the multiplexed interrupt, set the appropriate  
bit in the interrupt mask register (Figures 5-7 and 5-8). To enable an interrupt source, set the ap-  
propriate bit in the PI_MASK register (Figure 5-9 on page 5-17). Figure 5-3 shows the flow for  
the timer interrupt.  
NOTE  
Although the PI interrupt on the 8XC196MC has a single source (the  
waveform generator), software must still enable both the source interrupt  
(WG) in the PI_PEND register and the PI interrupt in the INT_MASK register.  
5-7  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
The interrupt service routine should read the PI_PEND (Figure 5-12 on page 5-23) register to de-  
termine the source of the interrupt. Before executing the return instruction, the interrupt service  
routine should check to see if any of the other interrupt sources are pending. Generally, PTS in-  
terrupt service is not useful for multiplexed interrupts because the PTS cannot readily determine  
the interrupt source.  
Timer x  
Overflows  
Set OVRTMx  
bit in PI_PEND  
Is OVRTMx  
bit set in  
PI_MASK  
?
OVRTM bit  
is not set  
in INT_PEND  
No  
Yes  
Set OVRTM  
bit in INT_PEND  
Is OVRTM  
bit set in  
INT_MASK  
?
No  
OVRTM interrupt  
is not generated  
Yes  
Generate  
OVRTM interrupt  
Read PI_PEND  
to see which  
timer overflowed  
A3254-01  
Figure 5-3. Flow Diagram for the OVRTM Interrupt  
5-8  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
5.3.4 End-of-PTS Interrupts  
When the PTSCOUNT register decrements to zero at the end of a single transfer, block transfer,  
A/D scan, or serial I/O routine, hardware clears the corresponding bit in the PTSSEL register,  
(Figure 5-6 on page 5-14) which disables PTS service for that interrupt. It also sets the corre-  
sponding 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 inter-  
rupt service routine that is stored in the memory location pointed to by the standard interrupt vec-  
tor. For example, the PTS services the EPA0 interrupt if PTSSEL.2 is set. The interrupt vectors  
through 2044H, but the corresponding end-of-PTS interrupt vectors through 2004H, the standard  
EPA0 interrupt vector. When the end-of-PTS interrupt vectors to the interrupt service routine,  
hardware clears the PTSSRV bit. The end-of-PTS interrupt service routine should reinitialize the  
PTSCB, if required, and set the appropriate PTSSEL bit to re-enable PTS interrupt service.  
5.4 INTERRUPT LATENCY  
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.  
5.4.1 Situations that Increase Interrupt Latency  
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:  
the signed prefix opcode (FE) for the two-byte, signed multiply and divide instructions  
any of these eight protected instructions: DI, EI, DPTS, EPTS, POPA, POPF, PUSHA,  
PUSHF (see Appendix A for descriptions of these instructions)  
any of the read-modify-write instructions: AND, ANDB, OR, ORB, XOR, XORB  
Both the unimplemented opcode interrupt and the software trap interrupt prevent other interrupt  
requests from being acknowledged until after the next instruction is executed.  
5-9  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
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 5-4 on page  
5-12 for PTS cycle execution times.  
5.4.2 Calculating Latency  
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:  
Time for the current instruction to finish execution (4 state times).  
— If this is a protected instruction, the instruction that follows it must also execute before  
the interrupt can be acknowledged. Add the execution time of the instruction that  
follows a protected instruction.  
Time for the next instruction to execute. (The longest instruction, NORML, takes 39 state  
times. However, the BMOV instruction could actually take longer if it is transferring a large  
block of data. If your code contains routines that transfer large blocks of data, you may get a  
more accurate worst-case value if you use the BMOV instruction in your calculation instead  
of NORML. See Appendix A for instruction execution times.)  
For standard interrupts only, the response time to get the vector and force the call.  
— 11 state times for an internal stack or 13 for an external stack (assuming a zero-wait-  
state bus)  
5.4.2.1  
Standard Interrupt Latency  
The worst-case delay for a standard interrupt is 56 state times (4 + 39 + 11 + 2) if the stack is in  
external memory (Figure 5-4). This delay time does not include the time needed to execute the  
first instruction in the interrupt service routine or to execute the instruction following a protected  
instruction.  
5-10  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
39  
11  
2
12  
6
4
3
2
1
If Stack  
External  
Ending  
Instruction  
End  
"NORML"  
Call is  
Forced  
If Stack  
External  
"NORML"  
Execution  
EXTINT  
"PUSHA"  
Interrupt Routine  
Pending  
Interrupt  
Set  
Cleared  
56 State Times  
Response  
Time  
A0136-02  
Figure 5-4. Standard Interrupt Response Time  
PTS Interrupt Latency  
5.4.2.2  
The maximum delay for a PTS interrupt is 43 state times (4 + 39) as shown in Figure 5-5. This  
delay time does not include the added delay if a protected instruction is being executed or if a PTS  
request is already in progress. See Table 5-4 for execution times for PTS cycles.  
4
3
2
1
39  
Ending  
Instruction  
End  
"NORML"  
Vector to PTS  
Control Block  
"NORML"  
PTS  
Execution  
EXTINT  
PTS  
PTS Interrupt Routine  
Pending  
Interrupt  
Set  
Cleared  
Latency Time  
43 State Times  
Response Time  
A0142-01  
Figure 5-5. PTS Interrupt Response Time  
5-11  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 5-4. Execution Times for PTS Cycles  
PTS Mode Execution Time (in State Times)  
Single transfer mode  
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  
Block transfer mode  
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)  
A/D scan mode  
register/register†  
register/memory†  
21  
25  
ASIO receive mode (MC, MD only)  
Majority disabled  
24 + 2 (if parity enabled)  
Majority enabled  
36 + sample time (second sample)  
36 + 7 + sample time (third sample)  
36 + 2 (if parity enabled)  
ASIO transmit mode (MC, MD only)  
SSIO receive mode (MC, MD only)  
29 + 3 (if parity enabled)  
29 (receive data bit)  
21 (no reception)  
SSIO transmit mode (MC, MD only)  
30 (transmit data bit)  
20 (no transmission)  
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 4-1 on page 4-2 for address information.  
5.5 PROGRAMMING THE INTERRUPTS  
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 5-6). The bits in the interrupt  
mask registers, INT_MASK and INT_MASK1, enable or disable (mask) individual interrupts  
(see Figures 5-7 and 5-8). For the multiplexed interrupt sources, bits in the PI_MASK register  
(Figure 5-9 on page 5-17) enable or disable (mask) the individual interrupt sources. With the ex-  
ception of the nonmaskable interrupt (NMI) bit (INT_MASK1.7), setting a bit enables the corre-  
sponding interrupt source and clearing a bit disables 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.  
5-12  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
When you assign an interrupt to the PTS, you must set up a PTS control block (PTSCB) for each  
interrupt source (see “Initializing the PTS Control Blocks” on page 5-24) 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.  
NOTE  
The DI (disable interrupts) instruction does not disable PTS service. However,  
it does disable service for the end-of-PTS interrupt request. If an interrupt  
request occurs while interrupts are disabled, the corresponding pending bit is  
set in the INT_PEND or INT_PEND1 register.  
PTS service is not useful for multiplexed interrupts because the PTS cannot  
readily determine the source of these interrupts.  
5-13  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
PTSSEL  
Address:  
Reset State:  
0004H  
0000H  
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.  
15  
8
0
8XC196MC  
8XC196MD  
8XC196MH  
EXTINT  
EPA2  
PI  
COMP3  
AD  
EPA3  
7
COMP2  
COMP1  
EPA1  
COMP0  
EPA0  
OVRTM  
15  
8
7
EXTINT  
EPA2  
PI  
EPA5  
EPA1  
COMP4  
COMP0  
EPA4  
EPA0  
COMP3  
AD  
EPA3  
0
COMP2  
COMP1  
OVRTM  
15  
7
8
EXTINT  
WG  
SPI  
RI1  
RI0  
TI1  
AD  
TI0  
0
COMP3 COMP2 COMP1  
EPA1  
COMP0  
EPA0  
OVRTM  
Bit  
Number  
Function  
Reserved; for compatibility with future devices, write zero to this bit.  
15  
14: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  
EXTINT  
PTS Vector  
205CH  
205AH  
205AH  
2058H  
2058H  
2056H  
2056H  
2054H  
2054H  
Bit Mnemonic  
TI0 (MH)  
PTS Vector  
2050H  
204EH  
204EH  
204CH  
204CH  
204AH  
2048H  
2046H  
2044H  
2042H  
2040H  
PI (MC, MD)††  
WG (MH)  
COMP2 (MC,MD)  
COMP3 (MH)  
EPA2 (MC, MD)  
COMP2 (MH)  
COMP1  
EPA1  
COMP0  
EPA0  
AD  
OVRTM††  
EPA5 (MD)  
SPI (MH)††  
COMP4 (MD)  
RI1 (MH)  
EPA4 (MD)  
RI0 (MH)  
COMP3 (MC, MD) 2052H  
TI1 (MH)  
2052H  
EPA3 (MC, MD)  
2050H  
††  
PTS service is not useful for multiplexed interrupts because the PTS cannot readily  
determine the source of these interrupts.  
On the 8XC196MC device bits 10–12 are reserved. For compatibility with future devices, write zeros  
to these bits.  
Figure 5-6. PTS Select (PTSSEL) Register  
5-14  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
Address:  
Reset State:  
0008H  
00H  
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). PUSHF or PUSHA saves the contents of this register  
onto the stack and then clears this register. Interrupt calls cannot occur immediately following this  
instruction. POPF or POPA restores it.  
7
0
MC, MD  
MH  
COMP2  
EPA2  
COMP1  
EPA1  
EPA1  
COMP0  
COMP0  
EPA0  
EPA0  
AD  
AD  
OVRTM  
7
0
COMP3 COMP2 COMP1  
OVRTM  
Bit  
Number  
Function  
7:0  
Setting a bit enables the corresponding interrupt.  
The standard interrupt vector locations are as follows:  
Bit Mnemonic  
COMP2 (MC, MD) EPA Compare-only Channel 2  
Interrupt  
Standard Vector  
200EH  
COMP3 (MH)  
EPA2 (MC, MD)  
COMP2 (MH)  
COMP1  
EPA Compare-only Channel 3  
EPA Capture/Compare Channel 2  
EPA Compare Channel 2  
200EH  
200CH  
200EH  
200AH  
EPA Compare Channel 1  
EPA1  
COMP0  
EPA Capture/Compare Channel 1  
EPA Compare Channel 0  
2008H  
2006H  
EPA0  
AD  
OVRTM†  
EPA Capture/Compare Channel 0  
A/D Conversion Complete  
Overflow/Underflow Timer  
2004H  
2002H  
2000H  
Both timer 1 and timer 2 can generate the multiplexed overflow/underflow interrupt. Write  
to PI_MASK to enable the interrupt sources; read PI_PEND to determine which source  
caused the interrupt.  
Figure 5-7. Interrupt Mask (INT_MASK) Register  
5-15  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
INT_MASK1  
Address:  
Reset State:  
0013H  
00H  
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
7
7
0
8XC196MC  
8XC196MD  
8XC196MH  
NMI  
NMI  
NMI  
EXTINT  
EXTINT  
EXTINT  
PI  
PI  
COMP4  
RI1  
COMP3  
COMP3  
TI1  
EPA3  
EPA3  
TI0  
0
0
EPA5  
SPI  
EPA4  
RI0  
WG  
Bit  
Number  
Function  
7:0†  
Setting a bit enables the corresponding interrupt.  
The standard interrupt vector locations are as follows:  
Bit Mnemonic  
NMI  
EXTINT  
PI (MC, MD)††  
WG (MH)  
EPA5 (MD)  
SPI (MH)†††  
COMP4 (MD)  
RI1 (MH)  
Interrupt  
Nonmaskable Interrupt  
EXTINT pin  
Multiplexed Peripheral Interrupt  
Waveform Generator  
EPA Capture/Compare Channel 5  
Serial Port  
EPA Compare Channel 4  
SIO 1 Receive  
Standard Vector  
203EH  
203CH  
203AH  
203AH  
2038H  
2038H  
2036H  
2036H  
EPA4 (MD)  
RI0 (MH)  
EPA Capture/Compare Channel 4  
SIO 0 Receive  
2034H  
2034H  
COMP3 (MC, MD) EPA Compare Channel 3  
2032H  
TI1 (MH)  
SIO 1 Transmit  
2032H  
EPA3 (MC, MD)  
EPA Capture/Compare Channel 3  
2030H  
TI0 (MH)  
SIO 0 Transmit  
2030H  
††  
The waveform generator and the EPA compare-only channel 5 can generate this  
interrupt. Write to PI_MASK to enable the interrupt sources; read PI_PEND to  
determine which source caused the interrupt.  
††† SIO 0 and SIO 1 can generate this interrupt. Write to PI_MASK to enable the interrupt  
sources; read PI_PEND to determine which source caused the interrupt.  
On the 8XC196MC device bits 4–3 are reserved. For compatibility with future devices, write zeros to  
these bits.  
Figure 5-8. Interrupt Mask 1 (INT_MASK1) Register  
5-16  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
Address:  
Reset State:  
1FBCH  
AAH  
PI_MASK  
The peripheral interrupt mask (PI_MASK) register enables or disables (masks) interrupt requests  
associated with the peripheral interrupt (PI), the serial port interrupt (SPI), and the overflow/underflow  
timer interrupt (OVRTM).  
7
7
7
0
WG  
WG  
SP0  
OVRTM2  
OVRTM2  
OVRTM2  
OVRTM1  
8XC196MC  
8XC196MD  
8XC196MH  
0
COMP5  
SP1  
OVRTM1  
0
OVRTM1  
Bit  
Number  
Bit  
Mnemonic  
Function  
7, 5, 3, 1  
6
Reserved; for compatibility with future devices, write zeros to these bits.  
Reserved; for compatibility with future devices, write zero to this bit.  
— (MC)  
COMP5 (MD) EPA Compare Channel 5  
Setting this bit enables the EPA compare channel 5 interrupt.  
The EPA compare channel 5 and the waveform generator interrupts are  
associated with the peripheral interrupt (PI). Setting INT_MASK1.5  
enables PI.  
SP1 (MH)  
Serial Port 1 Error  
Setting this bit enables the serial port 1 error interrupt.  
The serial port 1 and serial port 0 error interrupts are associated with the  
serial port interrupt (SPI). Setting INT_MASK1.4 enables SPI.  
4
WG (MC, MD) Waveform Generator  
Setting this bit enables the waveform generator interrupt.  
The waveform generator and the EPA compare channel 5 interrupts are  
associated with the peripheral interrupt (PI). Setting INT_MASK1.5  
enables PI.  
SP0 (MH)  
OVRTM2  
Serial Port 0 Error  
Setting this bit enables the serial port 0 error interrupt.  
The serial port 0 and serial port 1 error interrupts are associated with the  
serial port interrupt (SPI). Setting INT_MASK1.4 enables SPI.  
2
Timer 2 Overflow/Underflow  
Setting this bit enables the timer 2 overflow/underflow interrupt.  
The timer 2 and timer 1 overflow/underflow interrupts are associated with  
the overflow/underflow timer interrupt (OVRTM). Setting INT_MASK.0  
enables OVRTM.  
Figure 5-9. Peripheral Interrupt Mask (PI_MASK) Register  
5-17  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
PI_MASK (Continued)  
Address:  
Reset State:  
1FBCH  
AAH  
The peripheral interrupt mask (PI_MASK) register enables or disables (masks) interrupt requests  
associated with the peripheral interrupt (PI), the serial port interrupt (SPI), and the overflow/underflow  
timer interrupt (OVRTM).  
7
7
7
0
WG  
WG  
SP0  
OVRTM2  
OVRTM2  
OVRTM2  
OVRTM1  
8XC196MC  
8XC196MD  
8XC196MH  
0
COMP5  
SP1  
OVRTM1  
0
OVRTM1  
Bit  
Number  
Bit  
Mnemonic  
Function  
0
OVRTM1  
Timer 1 Overflow/Underflow  
Setting this bit enables the timer 1 overflow/underflow interrupt.  
The timer 1 and timer 2 overflow/underflow interrupts are associated with  
the overflow/underflow timer interrupt (OVRTM). Setting INT_MASK.0  
enables OVRTM.  
Figure 5-9. Peripheral Interrupt Mask (PI_MASK) Register (Continued)  
5.5.1 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 EXTINT (priority 14), from interrupting an A/D conversion-complete inter-  
rupt service routine (priority 01).  
SERIAL_RI_ISR:  
PUSHA  
; Save PSW, INT_MASK, INT_MASK1, & WSR  
; (this disables all interrupts)  
; Enable EXTINT only  
LDB INT_MASK1, #01000000B  
EI  
; Enable interrupt servicing  
; Service the AD_DONE interrupt  
POPA  
RET  
; Restore PSW, INT_MASK, INT_MASK1, &  
; WSR registers  
CSEG AT 02002H  
DCW AD_DONE_ISR  
; fill in interrupt table  
END  
5-18  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
Note that location 2002H in the interrupt vector table must be loaded with the value of the label  
AD_DONE_ISR before the interrupt request occurs and that the A/D conversion complete inter-  
rupt must be enabled for this routine to execute.  
This routine, like all interrupt service routines, is handled in the following manner:  
1. After the hardware detects and prioritizes an interrupt request, it generates and executes an  
interrupt call. This pushes the program counter onto the stack and then loads it with the  
contents of the vector corresponding to the highest priority, pending, unmasked interrupt.  
The hardware will not allow another interrupt call until after the first instruction of the  
interrupt service routine is executed.  
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.  
3. The LDB INT_MASK1 instruction enables those interrupts that you choose to allow to  
interrupt the service routine. In this example, only EXTINT can interrupt the receive  
interrupt service routine. By enabling or disabling interrupts, the software establishes its  
own interrupt servicing priorities.  
4. The EI instruction re-enables interrupt processing and inhibits interrupt calls until after the  
next instruction executes.  
5. The actual interrupt service routine executes within the priority structure established by  
the software.  
6. At the end of the service routine, the POPA instruction restores the original contents of the  
PSW, INT_MASK, INT_MASK1, and WSR registers; any changes made to these  
registers during the interrupt service routine are overwritten. Because interrupt calls  
cannot occur immediately following a POPA instruction, the last instruction (RET) will  
execute before another interrupt call can occur.  
Notice that the “preamble” and exit code for this routine do not save or restore register RAM. The  
interrupt service routine is assumed to allocate its own private set of registers from the lower reg-  
ister file. The general-purpose register RAM in the lower register file makes this quite practical.  
In addition, the RAM in the upper register file is available via windowing (see “Windowing” on  
page 4-12).  
5-19  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
5.5.2 Determining the Source of an Interrupt  
When hardware detects an interrupt, it sets the corresponding bit in the INT_PEND or  
INT_PEND1 register (Figures 5-10 and 5-11 ). It sets the bit even if the individual interrupt is  
disabled (masked). Hardware clears the pending bit when the program vectors to the interrupt ser-  
vice routine. The interrupt service routine can read INT_PEND and INT_PEND1 to determine  
which interrupts are pending.  
Software can generate an interrupt by setting a bit in INT_PEND or INT_PEND1 register. We  
recommend the use of the read-modify-write instructions, such as AND and OR, to modify these  
registers.  
ANDB INT_PEND, #11111110B  
ORB INT_PEND, #00000001B  
; Clears the OVRTM pending bit  
; Sets the OVRTM 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.  
The PI (MD), SPI (MH), and OVRTM (Mx) interrupts have multiple sources. Read PI_PEND  
(Figure 5-12 on page 5-23) to determine which source generated the interrupt request. Reading  
PI_PEND clears all the bits. PI_PEND is a read-only register.  
5-20  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
Address:  
Reset State:  
0009H  
00H  
INT_PEND  
When hardware detects an interrupt request, 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
MC, MD  
MH  
COMP2  
EPA2  
COMP1  
EPA1  
EPA1  
COMP0  
COMP0  
EPA0  
EPA0  
AD  
AD  
OVRTM  
7
0
COMP3 COMP2 COMP1  
OVRTM  
Bit  
Number  
Function  
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  
COMP2 (MC, MD) EPA Compare Channel 2  
Interrupt  
Standard Vector  
200EH  
COMP3 (MH)  
EPA2 (MC, MD)  
COMP2 (MH)  
COMP1  
EPA Compare Channel 3  
EPA Capture/Compare Channel 2  
EPA Compare Channel 2  
200EH  
200CH  
200EH  
EPA Compare Channel 1  
200AH  
EPA1  
EPA Capture/Compare Channel 1  
2008H  
COMP0  
EPA Compare Channel 0  
2006H  
EPA0  
AD  
OVRTM†  
EPA Capture/Compare Channel 0  
A/D Conversion Complete  
Overflow/Underflow Timer  
2004H  
2002H  
2000H  
Timer 1 and timer 2 can generate the multiplexed overflow/underflow interrupt. Write to  
PI_MASK to enable the interrupt sources; read PI_PEND to determine which source  
caused the interrupt.  
Figure 5-10. Interrupt Pending (INT_PEND) Register  
5-21  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
INT_PEND1  
Address:  
Reset State:  
0012H  
00H  
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
7
7
0
8XC196MC  
8XC196MD  
8XC196MH  
NMI  
NMI  
NMI  
EXTINT  
EXTINT  
EXTINT  
PI  
PI  
COMP4  
RI1  
COMP3  
COMP3  
TI1  
EPA3  
EPA3  
TI0  
0
0
EPA5  
SPI  
EPA4  
RI0  
WG  
Bit  
Number  
Function  
7:0†  
Setting a bit enables the corresponding interrupt.  
The standard interrupt vector locations are as follows:  
Bit Mnemonic  
NMI  
EXTINT  
PI (MC, MD)††  
WG (MH)  
EPA5 (MD)  
SPI (MH)†††  
COMP4 (MD)  
RI1 (MH)  
Interrupt  
Nonmaskable Interrupt  
EXTINT pin  
Multiplexed Peripheral Interrupt  
Waveform Generator  
EPA Capture/Compare Channel 5  
Serial Port  
EPA Compare Channel 4  
SIO 1 Receive  
Standard Vector  
203EH  
203CH  
203AH  
203AH  
2038H  
2038H  
2036H  
2036H  
EPA4 (MD)  
RI0 (MH)  
EPA Capture/Compare Channel 4  
SIO 0 Receive  
2034H  
2034H  
COMP3 (MC, MD) EPA Compare Channel 3  
2032H  
TI1 (MH)  
SIO 1 Transmit  
2032H  
EPA3 (MC, MD)  
TI0 (MH)  
EPA Capture/Compare Channel 3  
SIO 0 Transmit  
2030H  
2030H  
††  
On the 8XC196MD, the waveform generator and the EPA compare channel 5 can  
generate this interrupt. Write to PI_MASK to enable the interrupt sources; read  
PI_PEND to determine which source caused the interrupt. On the 8XC196MC, the  
waveform generator is the sole source for this interrupt.  
††† SIO 0 and SIO 1 can generate this interrupt. Write to PI_MASK to enable the interrupt  
sources; read PI_PEND to determine which source caused the interrupt.  
On the 8XC196MC device bits 4–3 are reserved. These bits are undefined.  
Figure 5-11. Interrupt Pending 1 (INT_PEND1) Register  
5-22  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
Address:  
Reset State:  
1FBEH  
AAH  
PI_PEND  
When hardware detects a pending peripheral or timer interrupt, it sets the corresponding bit in the  
interrupt pending (INT_PEND or INT_PEND1) registers and the peripheral interrupt pending  
(PI_PEND) register. When the vector is taken, the hardware clears the INT_PEND/INT_PEND1  
pending bit. Reading this register clears all the PI_PEND bits. Software can generate an interrupt by  
setting a PI_PEND bit.  
7
0
WG  
WG  
SP0  
OVRTM2  
OVRTM2  
OVRTM2  
OVRTM1  
8XC196MC  
8XC196MD  
8XC196MH  
7
7
0
COMP5  
SP1  
OVRTM1  
0
OVRTM1  
Bit  
Number  
Bit  
Mnemonic  
Function  
7, 5, 3, 1  
6
Reserved. These bits are undefined.  
Reserved. This bit is undefined.  
— (MC)  
COMP5 (MD) EPA Compare Channel 5  
When set, this bit indicates a pending EPA compare channel 5 interrupt.  
The EPA compare channel 5 and the waveform generator interrupts are  
associated with the peripheral interrupt (PI). Setting INT_MASK1.5  
enables PI. Setting PI_MASK.6 enables COMP5.  
SP1 (MH)  
Serial Port 1 Error  
When set, this bit indicates a pending serial port 1 error interrupt.  
The serial port 1 and 0 error interrupts are associated with the serial port  
interrupt (SPI). Setting INT_MASK1.4 enables SPI. Setting PI_MASK.6  
enables SP1.  
4
WG (MC, MD) Waveform Generator  
When set, this bit indicates a pending waveform generator interrupt.  
The waveform generator and the EPA compare channel 5 interrupts are  
associated with the peripheral interrupt (PI). Setting INT_MASK1.5  
enables PI. Setting PI_MASK.5 enables WG.  
SP0 (MH)  
Serial Port 0 Error  
When set, this bit indicates a pending serial port 0 error interrupt.  
The serial port 0 and 1 error interrupts are associated with the serial port  
interrupt (SPI). Setting INT_MASK1.4 enables SPI. Setting PI_MASK.4  
enables SP0.  
Figure 5-12. Peripheral Interrupt Pending (PI_PEND) Register  
5-23  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
PI_PEND (Continued)  
Address:  
Reset State:  
1FBEH  
AAH  
When hardware detects a pending peripheral or timer interrupt, it sets the corresponding bit in the  
interrupt pending (INT_PEND or INT_PEND1) registers and the peripheral interrupt pending  
(PI_PEND) register. When the vector is taken, the hardware clears the INT_PEND/INT_PEND1  
pending bit. Reading this register clears all the PI_PEND bits. Software can generate an interrupt by  
setting a PI_PEND bit.  
7
0
WG  
WG  
SP0  
OVRTM2  
OVRTM2  
OVRTM2  
OVRTM1  
8XC196MC  
8XC196MD  
8XC196MH  
7
7
0
COMP5  
SP1  
OVRTM1  
0
OVRTM1  
Bit  
Number  
Bit  
Mnemonic  
Function  
2
0
OVRTM2  
Timer 2 Overflow/Underflow  
When set, this bit indicates a pending timer 2 overflow/underflow interrupt.  
The timer 2 and timer 1 overflow/underflow interrupts are associated with  
the overflow/underflow timer interrupt (OVRTM). Setting INT_MASK.0  
enables OVRTM. Setting PI_MASK.2 enables OVRTM2.  
OVRTM1  
Timer 1 Overflow/Underflow  
When set, this bit indicates a pending timer 1 overflow/underflow interrupt.  
The timer 1 and timer 2 overflow/underflow interrupts are associated with  
the overflow/underflow timer interrupt (OVRTM). Setting INT_MASK.0  
enables OVRTM. Setting PI_MASK.0 enables OVRTM1.  
Figure 5-12. Peripheral Interrupt Pending (PI_PEND) Register (Continued)  
5.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.  
5-24  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
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 4-3). Figure 5-13 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).  
Single  
Transfer  
Block  
Transfer  
A/D Scan  
Mode  
SIO #1†  
SIO #2†  
Unused  
Unused  
Unused  
Unused  
PTSVEC1 (H)  
PTSVEC1 (L)  
BAUD (H)  
Unused  
PTSBLOCK  
PTSDST (H)  
PTSDST (L)  
PTSSRC (H)  
PTSSRC (L)  
PTSCON  
Unused  
SAMPTIME  
DATA (H)  
PTSDST(H)  
PTSDST (L)  
PTSSRC (H)  
PTSSRC (L)  
PTSCON  
PTSPTR2 (H)  
PTSPTR2 (L)  
PTSPTR1 (H)  
PTSPTR1 (L)  
PTSCON  
BAUD (L)  
DATA (L)  
EPAREG (H)  
EPAREG (L)  
PTSCON  
PTSCON1  
PORTMASK  
PORTREG (H)  
PORTREG (L)  
PTSVECT  
PTSCOUNT  
PTSCOUNT  
PTSCOUNT  
PTSCOUNT  
8XC196MC and MD only.  
Figure 5-13. PTS Control Blocks  
5.6.1 Specifying the PTS Count  
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 corre-  
sponding PTSSEL bit and sets the PTSSRV bit (Figure 5-6), which requests an end-of-PTS inter-  
rupt. 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.  
5-25  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
PTSSRV  
Address:  
Reset State:  
0006H  
0000H  
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.  
15  
8
8XC196MC  
8XC196MD  
8XC196MH  
EXTINT  
EPA2  
PI  
COMP3  
AD  
EPA3  
7
0
COMP2  
COMP1  
EPA1  
COMP0  
EPA0  
OVRTM  
15  
8
7
EXTINT  
EPA2  
PI  
EPA5  
EPA1  
COMP4  
COMP0  
EPA4  
EPA0  
COMP3  
AD  
EPA3  
0
COMP2  
COMP1  
OVRTM  
15  
7
8
EXTINT  
WG  
SPI  
RI1  
RI0  
TI1  
AD  
TI0  
0
COMP3 COMP2 COMP1  
EPA1  
COMP0  
EPA0  
OVRTM  
Bit  
Number  
Function  
15  
Reserved. This bit is undefined.  
14:0†  
A bit is set by hardware to request an end-of-PTS interrupt for the corresponding interrupt  
through its standard interrupt vector.  
The PTS interrupt vector locations are as follows:  
Bit Mnemonic  
EXTINT  
PTS Vector  
205CH  
205AH  
205AH  
2058H  
2058H  
2056H  
2056H  
2054H  
2054H  
Bit Mnemonic  
TI0 (MH)  
PTS Vector  
2050H  
204EH  
204EH  
204CH  
204CH  
204AH  
2048H  
2046H  
2044H  
2042H  
2040H  
PI (MC, MD)††  
WG (MH)  
COMP2 (MC,MD)  
COMP3 (MH)  
EPA2 (MC, MD)  
COMP2 (MH)  
COMP1  
EPA1  
COMP0  
EPA0  
AD  
OVRTM††  
EPA5 (MD)  
SPI (MH)††  
COMP4 (MD)  
RI1 (MH)  
EPA4 (MD)  
RI0 (MH)  
COMP3 (MC, MD) 2052H  
TI1 (MH)  
2052H  
EPA3 (MC, MD)  
2050H  
††  
PTS service is not useful for multiplexed interrupts because the PTS cannot readily  
determine the source of these interrupts.  
On the 8XC196MC device bits 10–12 are reserved. These bits are undefined.  
Figure 5-14. PTS Service (PTSSRV) Register  
5-26  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
5.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 5-15). 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 5-4 on page 5-12 lists the cycle  
execution times for each PTS mode.  
Address: PTSPCB + 1  
PTSCON  
The PTS control (PTSCON) register selects the PTS mode and sets up control functions for that  
mode.  
7
0
M2  
M1  
M0  
Bit  
Number  
Bit  
Mnemonic  
Function  
7:5  
M2:0  
PTS Mode  
These bits select the PTS mode:  
M2  
0
M1  
0
M0  
0
block transfer  
0
0
0
1
1
0
serial receive (MC, MD only)  
reserved  
0
1
1
1
0
0
1
0
1
serial transmit (MC, MD only)  
single transfer  
reserved  
1
1
0
A/D scan  
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.  
Figure 5-15. PTS Mode Selection Bits (PTSCON Bits 7:5)  
5.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  
the EPA to move captured time values from the event-time register to internal RAM for further  
processing. See AP-483, Application Examples Using the 8XC196MC/MD Microcontroller, for  
application examples with code. Figure 5-16 shows the PTS control block for single transfer  
mode.  
5-27  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
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).  
7
0
0
8
0
8
0
0
0
Unused  
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
7
Unused  
15  
7
PTSDST (H)  
PTSDST (L)  
PTSSRC (H)  
PTSSRC (L)  
PTSCON  
PTS Destination Address (high byte)  
PTS Destination Address (low byte)  
PTS Source Address (high byte)  
PTS Source Address (low byte)  
15  
7
7
M2  
M1  
M0  
BW  
SU  
DU  
SI  
DI  
7
PTSCOUNT  
Consecutive Byte or Word Transfers  
Register  
Location  
PTSCB + 4 PTS Destination Address  
Function  
PTSDST  
Write the destination memory location to this register. A valid address is  
any unreserved memory location; 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; however, it must point to an even address  
if word transfers are selected.  
Figure 5-16. PTS Control Block — Single Transfer Mode  
5-28  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
PTS Single Transfer Mode Control Block (Continued)  
Register  
Location  
Function  
PTSCON  
PTSCB + 1 PTS Control Bits  
M2:0  
PTS Mode  
M2  
M1  
M0  
1
0
0
single transfer mode  
BW  
Byte/Word Transfer  
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.  
Figure 5-16. PTS Control Block — Single Transfer Mode (Continued)  
The PTSCB in Table 5-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.  
5-29  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 5-5. Single Transfer Mode PTSCB  
Unused  
Unused  
PTSDST (H) = 60H  
PTSDST (L) = 00H  
PTSSRC (H) = 00H  
PTSSRC (L) = 20H  
PTSCON = 85H (Mode = 100, BW = 0, SI/SU = 0, DI/DU = 1)  
PTSCOUNT = 09H  
5.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-483, Application Examples Using the 8XC196MC/MD Mi-  
crocontroller, for application examples with code. Figure 5-17 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 5-4 on  
page 5-12 for execution times of PTS cycles.  
The PTSCB in Table 5-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.  
Table 5-6. Block Transfer Mode PTSCB  
Unused  
PTSBLOCK = 05H  
PTSDST (H) = 60H  
PTSDST (L) = 00H  
PTSSRC (H) = 00H  
PTSSRC (L) = 20H  
PTSCON = 17H (Mode = 000; DI, SI, DU, BW = 1; SU = 0)  
PTSCOUNT = 03H  
5-30  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
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).  
7
0
0
8
0
8
0
0
0
Unused  
0
0
0
0
0
0
0
0
7
PTSBLOCK  
PTSDST (H)  
PTSDST (L)  
PTSSRC (H)  
PTSSRC (L)  
PTSCON  
PTS Block Size  
15  
7
PTS Destination Address (high byte)  
PTS Destination Address (low byte)  
PTS Source Address (high byte)  
PTS Source Address (low byte)  
15  
7
7
M2  
M1  
M0  
BW  
SU  
DU  
SI  
DI  
7
PTSCOUNT  
Consecutive Block Transfers  
Register  
Location  
Function  
PTSBLOCK PTSCB + 6 PTS Block Size  
Specifies the number of bytes or words in each block. Valid values are  
1–32, inclusive.  
PTSDST  
PTSSRC  
PTSCB + 4 PTS Destination Address  
Write the destination memory location to this register. A valid address is  
any unreserved memory location; however, it must point to an even  
address if word transfers are selected.  
PTSCB + 2 PTS Source Address  
Write the source memory location to this register. A valid address is any  
unreserved memory location; however, it must point to an even address  
if word transfers are selected.  
Figure 5-17. PTS Control Block — Block Transfer Mode  
5-31  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
PTS Block Transfer Mode Control Block (Continued)  
Register  
Location  
Function  
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  
BW  
SU  
Byte/Word Transfer  
0 = word transfer  
1 = byte transfer  
Update PTSSRC  
0 = reload original PTS source address after each block  
transfer is complete  
1 = retain current PTS source address after each block transfer  
is complete  
DU  
SI  
Update PTSDST  
0 = reload original PTS destination address after each block  
transfer is complete  
1 = retain current PTS destination address after each block  
transfer is complete  
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 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.  
Figure 5-17. PTS Control Block — Block Transfer Mode (Continued)  
5.6.5 A/D Scan Mode  
In the A/D scan mode, the PTS causes the A/D converter to perform multiple conversions on one  
or more channels and then stores the results in a table in memory. Figure 5-19 shows the PTS con-  
trol block for A/D scan mode.  
5-32  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
PTS A/D Scan Mode Control Block  
In A/D scan mode, the PTS causes the A/D converter to perform multiple conversions on one or more  
channels and then stores the results. The control block contains pointers to both the AD_RESULT  
register (PTSPTR1) and a table of A/D conversion commands and results (PTSPTR2), a control  
register (PTSCON), and an A/D conversion count (PTSCOUNT).  
7
0
Unused  
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
7
0
8
0
8
0
0
0
Unused  
15  
7
PTSPTR2 (H)  
PTSPTR2 (L)  
PTSPTR1 (H)  
PTSPTR1 (L)  
PTSCON  
Pointer 2 Value (high byte)  
Pointer 2 Value (low byte)  
Pointer 1 Value (high byte)  
Pointer 1 Value (low byte)  
15  
7
7
M2  
M1  
M0  
0
UPDT  
0
1
0
7
PTSCOUNT  
Consecutive A/D Conversions  
Register  
Location  
PTSCB + 4 Pointer 2 Value  
Function  
PTSPTR2  
This register contains the address of the A/D result register  
(AD_RESULT).  
PTSPTR1  
PTSCON  
PTSCB + 2 Pointer 1 Value  
This register contains the address of the table of A/D conversion  
commands and results.  
PTSCB + 1 PTS Control Bits  
M2:0 PTS Mode  
These bits select the PTS mode.  
M2  
M1  
M0  
1
1
0
A/D Scan Mode  
UPDT Update  
0 = reload original PTSPTR1 value after each A/D scan  
1 = retain current PTSPTR1 value after each A/D scan  
Figure 5-18. PTS Control Block – A/D Scan Mode  
5-33  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
PTS A/D Scan Mode Control Block (Continued)  
PTSCOUNT PTSCB + 0 Consecutive A/D Conversions  
Defines the number of A/D conversions that will be completed during the  
A/D scan routine. Each cycle consists of the PTS transferring the A/D  
conversion results into the command/data table, and then loading a new  
command into the AD_COMMAND register. Maximum number is 255.  
Figure 5-18. PTS Control Block – A/D Scan Mode (Continued)  
To use the A/D scan mode, you must first set up a command/data table in memory (Table 5-7).  
The command/data table contains A/D commands that are interleaved with blank memory loca-  
tions. The PTS stores the conversion results in these blank locations. Only the amount of available  
memory limits the table size; it can reside in internal or external RAM.  
Table 5-7. A/D Scan Mode Command/Data Table  
Address  
Contents  
XXXX + AH  
XXXX + 8H  
XXXX + 6H  
XXXX + 4H  
XXXX + 2H  
XXXX  
A/D Result 2  
Unused  
Unused  
Unused  
A/D Command 3†  
A/D Result 1  
A/D Command 2  
A/D Result 0††  
A/D Command 1  
Write 0000H to prevent a new conversion at the end of the  
routine.  
††  
Result of the A/D conversion that initiated the PTS routine.  
To initiate A/D scan mode, enable the A/D conversion complete interrupt and assign it to the PTS.  
Software must initiate the first conversion. When the A/D finishes the first conversion and gen-  
erates an A/D conversion complete interrupt, the interrupt vectors to the PTSCB and initiates the  
A/D scan routine. The PTS stores the conversion results, loads a new command into  
AD_COMMAND, and then decrements the number in PTSCOUNT. As each additional conver-  
sion complete interrupt occurs, the PTS repeats the A/D scan cycle; it stores the conversion re-  
sults, loads the next conversion command into the AD_COMMAND register, and decrements  
PTSCOUNT. The routine continues until PTSCOUNT decrements to zero. When this occurs,  
hardware clears the enable bit in the PTSSEL register, which disables PTS service, and sets the  
PTSSRV bit, which requests an end-of-PTS interrupt.  
The interrupt service routine could process the conversion results and then re-enable PTS service  
for the A/D conversion complete interrupt. Because the lower six bits of the AD_RESULT regis-  
ter contain status information, the end-of-PTS interrupt service routine could shift the results data  
to the right six times to leave only the conversion results in the memory locations. See AP-483,  
Application Examples Using the 8XC196MC/MD Microcontroller, for application examples with  
code.  
5-34  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
5.6.5.1  
A/D Scan Mode Cycles  
Software must start the first A/D conversion. After the A/D conversion complete interrupt ini-  
tiates the PTS routine, the following actions occur.  
1. The PTS reads the first command (from address XXXX), stores it in a temporary location,  
and increments the PTSPTR1 register twice. PTSPTR1 now points to the first blank  
location in the command/data table (address XXXX + 2).  
2. The PTS reads the AD_RESULT register, stores the results of the first conversion into  
location XXXX + 2 in the command/data table, and increments the PTSPTR1 register  
twice. PTSPTR1 now points to XXXX + 4.  
3. The PTS loads the command from the temporary location into the AD_COMMAND  
register. This completes the first A/D scan cycle and initiates the next A/D conversion.  
4. If UPDT (PTSCON.3) is clear, the original address is reloaded into the PTSPTR1 register.  
The next cycle uses the same command and overwrites previous data. If UPDT is set, the  
updated address remains in PTSPTR1 and the next cycle uses a new command and stores  
the conversion results at the new address.  
5. PTSCOUNT is decremented and the CPU returns to regular program execution. When the  
next A/D conversion complete interrupt occurs, the cycle repeats. When PTSCOUNT  
reaches zero, hardware clears the corresponding PTSSEL bit and sets the PTSSRV bit,  
which requests the end-of-PTS interrupt.  
5.6.5.2  
A/D Scan Mode Example 1  
The command/data table shown in Table 5-8 sets up a series of A/D conversions, beginning with  
channel 7 and ending with channel 4. Each table entry is a word (two bytes). Table 5-9 shows the  
corresponding PTSCB.  
Software starts a conversion on channel 7. Upon completion of the conversion, the A/D conver-  
sion complete interrupt initiates the A/D scan mode routine. Step 1 stores the channel 6 command  
in a temporary location and increments PTSPTR1 to 3002H. Step 2 stores the result of the channel  
7 conversion in location 3002H and increments PTSPTR1 to 3004H. Step 3 loads the channel 6  
command from the temporary location into the AD_COMMAND register to start the next con-  
5-35  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
version. Step 4 updates PTSPTR1 (PTSPTR1 now points to 3004H) and step 5 decrements  
PTSCOUNT to 3. The next cycle begins by storing the channel 5 command in the temporary lo-  
cation. During the last cycle (PTSCOUNT = 1), the dummy command is loaded into the  
AD_COMMAND register and no conversion is performed. PTSCOUNT is decremented to zero  
and the end-of-PTS interrupt is requested.  
Table 5-8. Command/Data Table (Example 1)  
Address  
Contents  
300EH  
300CH  
300AH  
3008H  
3006H  
3004H  
3002H  
3000H  
AD_RESULT for ACH4  
Unused  
Unused  
Unused  
Unused  
0000H (Dummy command)  
AD_RESULT for ACH5  
AD_COMMAND for ACH4  
AD_RESULT for ACH6  
AD_COMMAND for ACH5  
AD_RESULT for ACH7  
AD_COMMAND for ACH6  
Table 5-9. A/D Scan Mode PTSCB (Example 1)  
Unused  
Unused  
PTSPTR2 (H) = 1FH  
PTSPTR2 (L) = AAH  
PTSPTR1 (H) = 30H  
PTSPTR1 (L) = 00H  
PTSCON = CBH (Mode = 110, UPDT = 1)  
PTSCOUNT = 04H  
5-36  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
5.6.5.3  
A/D Scan Mode Example 2  
Table 5-11 sets up a series of ten PTS cycles, each of which reads a single A/D channel and stores  
the result in a single location (3002H). The UPDT bit (PTSCON.3) is cleared so that original con-  
tents of PTSPTR1 are restored after the cycle. The command/data table is shown in Table 5-10.  
Table 5-10. Command/Data Table (Example 2)  
Address  
Contents  
3002H  
3000H  
AD_RESULT for ACHx  
Unused  
AD_COMMAND for ACHx  
Table 5-11. A/D Scan Mode PTSCB (Example 2)  
Unused  
Unused  
PTSPTR2 (H) = 1FH  
PTSPTR2 (L) = AAH  
PTSPTR1 (H) = 30H  
PTSPTR1 (L) = 00H  
PTSCON = C3H (Mode = 110, UPDT = 0)  
PTSCOUNT = 0AH  
Software starts a conversion on channel x. When the conversion is finished and the A/D conver-  
sion complete interrupt is generated, the A/D scan mode routine begins. The PTS reads the com-  
mand in location 3000H and stores it in a temporary location. Then it increments PTSPTR1 twice  
and stores the value of the AD_RESULT register in location 3002H. The final step is to copy the  
conversion command from the temporary location to the AD_COMMAND register. The CPU  
could process or move the conversion results data from the table before the next conversion com-  
pletes and a new PTS cycle begins. When the next cycle begins, PTSPTR1 again points to 3000H  
and the repeats the events of the first cycle. The value of the AD_RESULT register is written to  
location 3002H and the command at location 3000H is re-executed.  
5.6.6 Serial I/O Modes  
The 8XC196MH has a two-channel serial I/O port. The 8XC196MC and MD have no serial I/O  
ports, but the serial I/O modes of the PTS provide a software serial I/O channel for both synchro-  
nous and asynchronous transfers and receptions. There are four basic modes of operation: syn-  
chronous transmit, synchronous receive, asynchronous transmit, and asynchronous receive. A  
standard I/O port signal is configured to function as either the transmit data (TXD) or receive data  
(RXD) signal and an EPA channel sets the baud rate. You may configure any port 2 signal (MC  
and MD) or P7.3:0 (MD) as TXD or RXD. In the synchronous modes, an EPA channel can either  
generate the serial clock (SCK) signal or input an external clock signal. Up to 16 bits may be  
5-37  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
transmitted or received including the parity and stop bits in the asynchronous modes. The serial  
I/O modes require two PTS control blocks to configure all options (see Figures 5-19 and 5-20).  
These blocks need not be contiguous, but they must each be located in register RAM on a quad-  
word boundary. See AP-483, Application Examples Using the 8XC196MC/MD Microcontroller,  
for application examples with code.  
PTS Serial I/O Mode Control Block 1  
(8XC196MC, MD)  
The PTS control block 1 contains pointers to both the second PTS control block (PTSVEC) and the  
EPA time register that sets the baud rate (EPAREG). It also contains a 16-bit value that is used to  
calculate the baud rate, a control register (PTSCON), and a consecutive PTS cycle count  
(PTSCOUNT).  
15  
8
0
8
0
8
0
0
0
PTSVEC (H)  
PTSVEC (L)  
BAUD (H)  
SIO PTSCB2 Base Address Pointer (high byte)  
SIO PTSCB2 Base Address Pointer (low byte)  
Baud Value (high byte)  
7
15  
7
BAUD (L)  
Baud Value (low byte)  
15  
7
EPAREG (H)  
EPAREG (L)  
PTSCON  
EPA Time Register Address (high byte)  
EPA Time Register Address (low byte)  
7
M2  
M1  
M0  
SA1  
0
0
SA0  
MAJ  
7
PTSCOUNT  
Consecutive PTS Cycles  
Register  
Location  
Function  
PTSVEC  
PTSCB1 + 6  
SIO PTSCB2 Base Address Pointer  
This register contains the base address of the second PTS  
control block for serial I/O mode.  
Figure 5-19. PTS Control Block 1 – Serial I/O Mode  
5-38  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
PTS Serial I/O Mode Control Block 1 (Continued)  
(8XC196MC, MD)  
Register  
BAUD  
Location  
Function  
PTSCB1 + 4  
Baud Value  
This register contains the 16-bit value that the PTS uses to  
generate the desired baud rate. Use the following formula to  
calculate the value to load into the BAUD register.  
FXTAL1  
----------------------------------------------------------------------------------------------------------------  
Baud_value =  
Multiplier (Baud_rate × EPA_prescale)  
where:  
Baud_value  
is a 16-bit integer that is loaded into the  
BAUD register  
FXTAL1  
is the input frequency on XTAL1, in MHz  
Multiplier  
is the number 4 in asynchronous modes and  
the number 8 in synchronous modes  
Baud_rate  
is the desired baud rate, in bits per second  
EPA_prescale is the EPA timer prescale number, 1–64  
EPA Time Register Address  
EPAREG  
PTSCON  
PTSCB1 + 2  
PTSCB1 + 2  
This register contains the 16-bit address of the EPAx_TIME or  
COMPx_TIME register.  
PTS Control Bits  
M2:0  
PTS Mode  
M2  
0
0
M1  
0
1
M0  
1
1
SIO Receive Mode  
SIO Transmit Mode  
SA1:0 Asynchronous, Synchronous Mode Select  
SA1 SA0†  
0
0
enables the asynchronous serial I/O  
modes  
1
1
enables the synchronous serial I/O  
modes  
Always write the same value to both bits.  
MAJ  
Majority Sampling  
0 = disable majority sampling in asynchronous receive  
mode; always clear in all other modes  
1= enable majority sampling in asynchronous receive  
mode  
Figure 5-19. PTS Control Block 1 – Serial I/O Mode (Continued)  
5-39  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
PTS Serial I/O Mode Control Block 1 (Continued)  
(8XC196MC, MD)  
Register  
Location  
Function  
PTSCOUNT PTSCB1 + 0  
Consecutive PTS Cycles  
Defines the number of bits to be transmitted or received,  
including parity and stop bits, but not the start bit. For  
asynchronous modes, program a number that is between 1–16.  
For synchronous modes, program a number that is twice the  
number of bits to be transmitted or received (2–32). PTSCOUNT  
is decremented at the end of each PTS cycle. When it reaches  
zero, hardware clears the corresponding PTSSEL bit and sets  
the PTSSRV bit, which requests the end-of-PTS interrupt.  
Figure 5-19. PTS Control Block 1 – Serial I/O Mode (Continued)  
5-40  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
PTS Serial I/O Mode Control Block 2  
(8XC196MC, MD)  
The PTS control block 2 contains pointers to both the port register (PORTREG) and the data register  
(DATA). It also contains a 16-bit value that is used to calculate the sample time for asynchronous  
receptions when majority sampling is selected (SAMPTIME), a control register (PTSCON1), and a 16-  
bit value that is used to select the port signal that functions as the TXD or RXD signal (PORTMASK).  
7
0
Unused  
0
0
0
0
0
0
0
0
7
0
8
0
0
0
SAMPTIME  
Sample Time Value  
Data Register (high byte)  
Data Register (low byte)  
15  
7
DATA (H)  
DATA (L)  
7
PTSCON1 (Synch)  
PTSCON1 (Asynch)  
PORTMASK  
PORTREG (H)  
PORTREG (L)  
0
0
0
0
0
0
0
0
0
0
TRC  
FE  
0
7
RPAR  
PEN  
TPAR  
7
0
Port Mask Register  
15  
7
0
0
Port Address Pointer (high byte)  
Port Address Pointer (low byte)  
Register  
Location  
Function  
SAMPTIME PTSCB2 + 6  
Sample Time Value  
This register controls the time between samples during  
asynchronous receive mode when majority sampling is selected.  
Use the following formula to calulate the value to load into the  
SAMPTIME register.  
TSAM × FXTAL1  
------------------------------------------  
Sample_time =  
where:  
9  
2
Sample_time is an integer, 1–31, that is loaded into the  
SAMPTIME register  
TSAM  
is the desired time between samples, in µs  
is the input frequency on XTAL1, in MHz  
FXTAL1  
Figure 5-20. PTS Control Block 2 – Serial I/O Mode  
5-41  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
PTS Serial I/O Mode Control Block 2 (Continued)  
(8XC196MC, MD)  
Register  
DATA  
Location  
PTSCB2 + 4  
Function  
Data Register  
This 16-bit register holds the data to be transmitted or the data  
that has been received. During transmit mode, the least-  
significant bit (bit 0) is transmitted first. Data shifts to the right  
with each successive transmission. During receive mode, the  
first bit is loaded into the most-significant bit (bit 15). Data shifts  
to the right with each successive reception.  
PTSCON1  
PTSCB2 + 3  
PTS Control Bits  
Synchronous Mode  
TRC  
Transmit/Receive Control  
0 = transmit or receive data during even numbered  
PTS cycles  
1 = transmit or receive data during odd numbered PTS  
cycles  
Initialize this bit at the start of every transmission or  
reception.  
Asynchronous Mode  
RPAR  
Receive Parity Control and Status  
Initialize this bit as indicated before beginning a  
reception.  
0 = TPAR bit is set to select even parity  
1 = TPAR bit is cleared to select odd parity  
If this bit is set at the end of a reception, a parity error  
has occurred.  
PEN  
FE  
Parity Enable  
0 = disble parity  
1 = enable parity  
Framing Error Flag  
0 = stop bit was 1  
1 = stop bit was 0  
Clear this bit at the start of every reception.  
Transmit Parity Control  
TPAR  
0 = even parity  
1 = odd parity  
Figure 5-20. PTS Control Block 2 – Serial I/O Mode (Continued)  
5-42  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
PTS Serial I/O Mode Control Block 2 (Continued)  
(8XC196MC, MD)  
Register  
Location  
Function  
PORTMASK PTSCB2 + 2  
Port Mask Register  
Select the port signal that will function as the transmit data (TXD)  
or receive data (RXD) signal by setting the corresponding bit.  
Clear all other bits to mask those signals.  
PORTREG  
PTSCB2 + 0  
Port Address Pointer  
This 16-bit register contains the address of the port that will be  
used to transmit or receive data.  
Figure 5-20. PTS Control Block 2 – Serial I/O Mode (Continued)  
Synchronous SIO Transmit Mode Example  
5.6.6.1  
In synchronous serial I/O (SSIO) transmit mode, an EPA channel controls the transmission baud  
rate by generating or capturing a serial clock signal (SCK). To generate the SCK signal, configure  
the EPA channel in compare mode and set the output-pin toggle option. Whenever a match occurs  
between the EPA event-time register and a timer register, the EPA channel toggles SCK and gen-  
erates an interrupt. If an external source will provide the SCK signal, configure the EPA channel  
in capture mode with capture on either edge set. In this case, the EPA channel generates an inter-  
rupt whenever the SCK input toggles. On every other EPA interrupt, the PTS shifts a data bit out  
onto a port pin that is configured to function as the Transmit Data signal (TXD). PTSCON1 (Fig-  
ure 5-19 on page 5-38) controls whether the transmission occurs on even or odd PTS cycles. Be-  
cause transmissions occur only on a rising or falling clock edge, two PTS cycles occur for every  
one data bit transmission (Figure 5-21). It takes 16 PTS cycles to transmit eight data bits. In SSIO  
transmit mode, only data bits can be transmitted; parity and stop bits are not included.  
End-of-PTS  
Conventional  
16 PTS Serviced Interrupts  
Interrupt  
Interrupts  
SCK  
TXD  
(Port pin)  
Bit 0  
LSB  
Bit 1  
Bit 2  
Bit 3  
Bit 4  
Bit 5  
Bit 6  
Bit 7  
MSB  
A3120-01  
Figure 5-21. Synchronous SIO Transmit Mode Timing  
5-43  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
If the SCK signal is generated by the EPA channel, the first PTS cycle must be started manually.  
Initialize the TXD port pin and the SCK signal to the system-required logic level before  
starting a transmission.  
Add the contents of the timer register to the Baud_value (Figure 5-19 on page 5-38) and  
store the result into the EPA time register. This sets up the timing for the first interrupt and  
causes the first bit transmission to occur at the proper baud rate.  
The following example uses EPA0 to control the baud rate and output the SCK signal and P2.2  
to output the data (TXD). It sets up a synchronous serial I/O PTS routine that transmits 16 bytes  
with eight data bits at 9600 baud. This example uses several user-defined registers. T_COUNT  
defines the number of bytes to transfer and TXDDONE is a flag that is set when all bytes are  
transferred.  
1. Disable the interrupts and the PTS.  
— Use the DI instruction to disable all standard interrupts and the DPTS instruction to  
disable the PTS.  
2. Set-up the stack pointer.  
3. Reset all interrupt mask registers.  
— Clear INT_MASK, INT_MASK1and PI_MASK.  
4. Initialize P2.0 to function as the EPA0 output (SCK) and P2.2 to function as TXD.  
— Clear P2_DIR (selects output).  
— Set P2_MODE.0 (selects special function).  
— Clear P2_MODE.2 (selects LSIO function).  
— Set P2_REG bits 0 and 2 (initializes TXD and SCK outputs to “1”).  
5. Initialize and enable the timer. Select up counting, internal clock, and prescaler disabled.  
— Set T1CONTROL bits 6 and 7 (Figure 11-8 on page 11-16).  
6. Initialize the PTSCB as shown in Table 5-13.  
5-44  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
Table 5-13. SSIO Transmit Mode PTSCBs  
PTSCB1  
PTSCB2  
PTSVEC (H) = pointer to PTSCB2  
PTSVEC (L) = pointer to PTSCB2  
BAUD (H) = 00H (9600 baud at 16 MHz)  
BAUD (L) = D0H (9600 baud at 16 MHz)  
EPAREG (H) = 1FH (EPA0_TIME)  
EPAREG (L) = 42H (EPA0_TIME)  
PTSCON = 72H (SSIO transmit mode)  
PTSCOUNT = 10H (8 data bits x 2)  
Unused  
SAMPTIME = unused  
DATA (H) = unused  
DATA (L) = nnH (8 data bits)  
PTSCON1 = 02H (transmit data on odd PTS cycles)  
PORTMASK = 04H (P2.2 = TXD)  
PORTREG (H) = 1FH (P2_REG)  
PORTREG (L) = D4H (P2_REG)  
7. Enable EPA0 interrupt.  
— Set INT_MASK.2.  
8. Load the number of bytes to transmit into the user_defined transmit count register  
(T_COUNT) and clear the user-defined transfer-done flag (TXDDONE).  
— LD T_COUNT, #16  
— CLRB TXDDONE  
9. Select PTS service for EPA0.  
— Set PTSSEL.2.  
10. Set-up EPA0 as a compare-only channel.  
— Set EPA0_CON.6 (Figure 11-10 on page 11-19).  
11. Start the operation of the EPA0 channel by writing the time of the first interrupt to  
EPA0_TIME. To set-up the correct value, add the baud_value (0D0H) to the current  
TIMER1 value and store the result in EPA0_TIME. The baud_value determines the time  
to the first PTS interrupt and the first transition on SCK. The PTS transmits the first data  
bit on first transition of SCK in this example. The baud_value of 0D0H selects a baud rate  
of 9600.  
12. Enable the PTS and conventional interrupts.  
— Use the EI instruction to enable all standard interrupts and the EPTS instruction to  
enable the PTS.  
13. The transmission will begin. Data is shifted out with the least-significant (rightmost) bit  
first. Each time a timer match occurs between EPA0_TIME and TIMER1, the EPA0  
channel generates an interrupt and toggles the SCK signal. The PTS outputs the next bit of  
data on the pin configured as TXD on odd PTS cycles. When PTSCOUNT decrements to  
zero, the PTS calls the end-of-PTS interrupt (Figure 5-22). The interrupt service routine  
should disable the EPA channel because the final PTS cycle loads the next SCK toggle  
5-45  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
time into the event-time register. If this toggle occurs, the clock polarity will change  
because of the odd number of toggles and erroneous data may be output. The interrupt  
service routine should also load the next data byte, reload the PTSCOUNT and PTSCON1  
registers, select PTS service for EPA0, reload both the EPA0_CONTROL and  
EPA0_TIME registers.  
14. To determine when all bytes have been transmitted, create a loop routine to check the  
status of the TXDDONE flag.  
End-Of-PTS Interrupt  
Save Critical Data  
Disable EPA Channel  
Clear Interrupt Request Bit  
T_COUNT = T_COUNT - 1  
Y
T_COUNT = 0?  
N
Set-up next data transfer  
- Load next data byte into DATA register  
- Reload PTSCOUNT and PTSCON1 registers  
- Select PTS service for EPA channel  
- Re-initialize the EPA channel  
TXDDONE = 1  
- Re-initialize the EPA timer to initiate first bit transfer  
Load Critical Data  
Return  
A3274-01  
Figure 5-22. Synchronous SIO Transmit Mode — End-of-PTS Interrupt Routine Flowchart  
5-46  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
5.6.6.2  
Synchronous SIO Receive Mode Example  
In synchronous serial I/O (SSIO) receive mode, an EPA channel controls the reception baud rate  
by generating or capturing a serial clock signal (SCK). To generate the SCK signal, configure the  
EPA channel in compare mode and set the output-pin toggle option. Whenever a match occurs  
between the EPA event-time register and a timer register, the EPA channel toggles SCK and gen-  
erates an interrupt. If an external source will provide the SCK signal, configure the EPA channel  
in capture mode with capture on either edge set. In this case, the EPA channel generates an inter-  
rupt whenever the SCK input toggles. On every other EPA interrupt, the PTS inputs a data bit  
from a port pin that is configured to function as the Receive Data signal (RXD). PTSCON1 (Fig-  
ure 5-19 on page 5-38) controls whether the reception occurs on even or odd PTS cycles. Because  
receptions occur only on a rising or falling clock edge, two PTS cycles occur for every one data  
bit reception (Figure 5-23). It takes 16 PTS cycles to receive eight data bits. SSIO receptions do  
not include parity or stop bits.  
End-of-PTS  
Conventional  
16 PTS Serviced Interrupts  
Interrupt  
Interrupts  
SCK  
Input Data Sampled on Rising Clock Edge  
RXD  
Bit 0  
LSB  
Bit 1  
Bit 2  
Bit 3  
Bit 4  
Bit 5  
Bit 6  
Bit 7  
MSB  
(Port pin)  
A3121-01  
Figure 5-23. Synchronous SIO Receive Timing  
If the SCK signal is generated by the EPA channel, the first PTS cycle must be started manually.  
Initialize the RXD port pin and the SCK signal to the system-required logic level before  
starting a reception.  
Add the contents of the timer register to the Baud_value (Figure 5-19 on page 5-38) and  
store the result into the EPA time register. This sets up the timing for the first interrupt and  
causes the first interrupt to occur at the proper baud rate.  
5-47  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
The following example uses EPA0 to capture the SCK signal and P2.3 to receive the data (RXD).  
It sets up a synchronous serial I/O PTS routine that receives 16 bytes with eight data bits. Because  
this example uses an external serial clock input, the TIMER1 and BAUD registers are not used.  
The external clock source controls the baud rate. This example uses several user-defined regis-  
ters. R_COUNT defines the number of bytes to receive and RXDDONE is a flag that is set when  
all bytes are received.  
1. Disable the interrupts and the PTS.  
— Use the DI instruction to disable all standard interrupts and the DPTS instruction to  
disable the PTS.  
2. Set-up the stack pointer.  
3. Reset all interrupt mask registers.  
— Clear INT_MASK, INT_MASK1and PI_MASK.  
4. Initialize P2.0 to function as the EPA0 input (SCK) and P2.3 to function as RXD.  
— Set P2_DIR bits 0 and 3 (selects input).  
— Set P2_MODE.0 (selects special function).  
— Clear P2_MODE.3 (selects LSIO function).  
— Set P2_REG bits 0 and 3 (initializes SCK and RXD input to “1”).  
5. Initialize the PTSCB as shown in Table 5-14.  
Table 5-14. SSIO Receive Mode PTSCBs  
PTSCB1  
PTSCB2  
PTSVEC (H) = pointer to PTSCB2  
PTSVEC (L) = pointer to PTSCB2  
BAUD (H) = unused  
Unused  
SAMPTIME = unused  
DATA (H) = unused  
BAUD (L) = unused  
DATA (L) = 00H (clear register to receive data)  
PTSCON1 = 00H (receive data on even PTS cycles)  
PORTMASK = 08H (P2.3 = RXD)  
PORTREG (H) = 1FH (P2_REG)  
PORTREG (L) = D4H (P2_REG)  
EPAREG (H) = 1FH (EPA0_TIME)  
EPAREG (L) = 42H (EPA0_TIME)  
PTSCON = 32H (SSIO receive mode)  
PTSCOUNT = 10H (8 data bits x 2)  
6. Enable EPA0 interrupt.  
— Set INT_MASK.2.  
7. Load the number of bytes to transmit into the user_defined transmit count register  
(R_COUNT) and clear the user-defined reception-done flag (RXDDONE).  
— LD R_COUNT, #16  
— CLRB RXDDONE  
5-48  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
8. Select PTS service for EPA0.  
— Set PTSSEL.2.  
9. Set-up EPA0 to capture on both rising and falling edges.  
— Set EPA0_CON bits 4 and 5 (Figure 11-10 on page 11-19).  
10. Enable the PTS and conventional interrupts.  
— Use the EI instruction to enable all standard interrupts and the EPTS instruction to  
enable the PTS.  
11. Toggle the SCK input to start the reception. Data is shifted into the most-significant  
(leftmost) bit first and shifts right with each successive bit received. The EPA generates an  
interrupt each time that the SCK input toggles. The PTS receives the next bit of data on the  
pin configured as RXD on even PTS cycles. When PTSCOUNT decrements to zero, the  
PTS calls the end-of-PTS interrupt (Figure 5-24). The interrupt service routine should  
disable the EPA channel, clear the DATA register, reload the PTSCOUNT and PTSCON1  
registers, reload EPA0_CON, and select PTS service for EPA0. If the EPA were generating  
the SCK signal, the end-of-PTS interrupt service routine would also have to reload the  
EPA0_TIME register.  
12. To determine when all bytes have been transmitted, create a loop routine to check the  
status of the RXDDONE flag.  
5-49  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
End-Of-PTS Interrupt  
Save Critical Data  
Disable EPA Channel  
Clear Interrupt Request Bit  
Save Received Data  
R_COUNT = R_COUNT - 1  
Y
R_COUNT = 0?  
N
Set-up next data reception  
- Clear DATA register  
- Reload PTSCOUNT and PTSCON1 registers  
- Select PTS service for EPA channel  
- Re-initialize the EPA channel  
RXDDONE = 1  
Load Critical Data  
Return  
A3275-01  
Figure 5-24. Synchronous SIO Receive Mode — End-of-PTS Interrupt Routine Flowchart  
5.6.6.3 Asynchronous SIO Transmit Mode Example  
In asynchronous serial I/O (ASIO) transmit mode, an EPA channel controls the transmission baud  
rate by generating an interrupt whenever a match occurs between the EPA event-time register and  
a timer register. The PTS shifts a data bit out onto a port pin that is configured to function as the  
Transmit Data signal (TXD) when the selected EPA channel generates a compare interrupt (Fig-  
ure 5-25). In ASIO transmit mode, the PTS automatically transmits up to 16 bits (data + 1 optional  
parity + 1 stop bit). The maximum number of data bits is 14 with parity, or 15 without.  
5-50  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
End-of-PTS  
Conventional  
Interrupt  
10 PTS Serviced Interrupts  
Interrupts  
Software Clears TXD  
LSB  
MSB  
Parity  
Bit 0  
Bit 1  
Bit 2  
Bit 3  
Bit 4  
Bit 5  
Bit 6  
Bit 7  
Start  
Stop  
TXD  
(Port pin)  
1 Bit Time  
Optional  
Parity Bit  
A3119-01  
Figure 5-25. Asynchronous SIO Transmit Timing  
The first PTS cycle must be started manually by generating a start bit and then setting up the tim-  
ing for the first EPA interrupt.  
Initialize the TXD port pin to one before starting a transmission.  
Write a zero to the TXD port pin to start the transmission. The PTS uses this as the start bit.  
Add the contents of the timer register to the Baud_value (Figure 5-19 on page 5-38) and  
store the result into the EPA time register. This sets up the timing for the first interrupt and  
causes the first bit transmission to occur at the proper baud rate.  
The following example uses P2.0 to output the data (TXD) and EPA0 to control the baud rate. It  
sets up an asynchronous serial I/O PTS routine that transmits 16 bytes with eight data bits, one  
parity bit, and one stop bit at 9600 baud. This example uses several user-defined registers.  
T_COUNT defines the number of bytes to transfer and TXDDONE is a flag that is set when all  
bytes are transferred.  
1. Disable the interrupts and the PTS.  
— Use the DI instruction to disable all standard interrupts and the DPTS instruction to  
disable the PTS.  
2. Set-up the stack pointer.  
3. Reset all interrupt mask registers.  
— Clear INT_MASK, INT_MASK1and PI_MASK.  
4. Initialize P2.0 to function as TXD.  
— Clear P2_DIR.0 (selects output).  
— Clear P2_MODE.0 (selects LSIO function).  
— Set P2_REG.0 (initializes TXD output to “1”).  
5-51  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
5. Initialize and enable the timer; select up counting, internal clock, and prescaler disabled.  
— Set T1CONTROL bits 6 and 7 (Figure 11-8 on page 11-16).  
6. Initialize the PTSCB as shown in Table 5-15.  
Table 5-15. ASIO Transmit Mode PTSCBs  
PTSCB1  
PTSCB2  
PTSVEC (H) = pointer to PTSCB2  
PTSVEC (L) = pointer to PTSCB2  
BAUD (H) = 01H (9600 baud at 16 MHz)  
BAUD (L) = A0H (9600 baud at 16 MHz)  
EPAREG (H) = 1FH (EPA0_TIME)  
EPAREG (L) = 42H (EPA0_TIME)  
PTSCON = 60H (ASIO transmit mode)  
Unused  
SAMPTIME = unused  
DATA (H) = unused  
DATA (L) = nnH (8 data bits)  
PTSCON1 = 21H (enable odd parity)  
PORTMASK = 01H (P2.0 = TXD)  
PORTREG (H) = 1FH (P2_REG)  
PORTREG (L) = D4H (P2_REG)  
PTSCOUNT = 0AH (8 data bits, 1 parity, & 1 stop  
bit)  
7. Enable EPA0 interrupt.  
— Set INT_MASK.2.  
8. Load the number of bytes to transmit into the user_defined transmit count register  
(T_COUNT) and clear the user-defined transfer-done flag (TXDDONE).  
— LD T_COUNT, #16  
— CLRB TXDDONE  
9. Select PTS service for EPA0.  
— Set PTSSEL.2.  
10. Set-up the transmission start bit.  
— Clear P2.0.  
11. Set-up EPA0 as a compare-only channel.  
— Set EPA0_CON.6 (Figure 11-10 on page 11-19).  
12. Start the operation of the EPA0 channel by writing the time of the first interrupt to  
EPA0_TIME. To set-up the correct value, add the baud_value (1A0H) to the current  
TIMER1 value and store the result in EPA0_TIME. The baud_value determines the time  
to the first PTS interrupt. When the interrupt occurs, the PTS transmits the first data bit.  
The baud_value of 1A0H selects a baud rate of 9600.  
13. Enable the PTS and conventional interrupts.  
— Use the EI instruction to enable all standard interrupts and the EPTS instruction to  
enable the PTS.  
5-52  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
14. The transmission will begin. Data is shifted out with the least-significant (rightmost) bit  
first. Each time a timer match occurs between EPA0_TIME and TIMER1, the EPA0  
channel generates an interrupt and the PTS outputs the next bit of data on the pin  
configured as TXD. When PTSCOUNT decrements to zero, the PTS calls the end-of-PTS  
interrupt (Figure 5-26). The interrupt service routine should load the next data byte, reload  
the PTSCOUNT and PTSCON1 registers, clear the TXD bit to create the start bit for the  
next word to be transmitted, select PTS service for EPA0, and reload both the  
EPA0_CONTROL and EPA0_TIME registers.  
15. To determine when all bytes have been transmitted, create a loop routine to check the  
status of the TXDDONE flag.  
5-53  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
End-Of-PTS Interrupt  
Save Critical Data  
Is PTS  
N
Cycle Completed?  
Y
Disable EPA Channel  
Clear Interrupt Request Bit  
T_COUNT = T_COUNT - 1  
Y
T_COUNT = 0?  
N
Set-up next data transfer  
- Load next data byte into DATA register  
- Reload PTSCOUNT and PTSCON1 registers  
- Create start bit (clear TXD)  
- Select PTS service for EPA channel  
- Re-initialize the EPA channel  
TXDDONE = 1  
- Re-initialize the EPA timer to initiate first bit transfer  
Load Critical Data  
Return  
A3276-01  
Figure 5-26. Asynchronous SIO Transmit Mode — End-of-PTS Interrupt Routine Flowchart  
5-54  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
5.6.6.4  
Asynchronous SIO Receive Mode Example  
In asynchronous serial I/O (ASIO) receive mode, an EPA channel is set up to capture the falling  
edge when the data start bit toggles on a port pin that is configured to function as the Receive Data  
signal (RXD). When the capture occurs, the EPA generates a conventional interrupt which starts  
the asynchronous receive process. This conventional interrupt service routine would be the same  
as the end-of-PTS interrupt service routine. It changes the EPA channel to the compare mode and  
sets the time of the next compare to 1.5 bit times and enables the PTS. At exactly 1.5 bit times  
from the beginning of the start bit, the first PTS cycle samples the input data on RXD and shifts  
it into the DATA register (Figure 5-27). If majority sampling is enabled, an additional sample oc-  
curs. If the two samples differ, a third sample occurs to determine which of the first two samples  
is correct. The SAMPTIME register (Figure 5-19 on page 5-38) controls the time between sam-  
ples. Majority sampling causes a substantial increase in PTS cycle execution time (Table 5-4 on  
page 5-12).  
End-of-PTS  
Conventional  
Conventional  
Interrupt  
10 PTS Serviced Interrupts  
Interrupt  
Interrupts  
LSB  
Bit 0  
1.5 Bit Times  
MSB  
Bit 7  
RXD  
(Port pin)  
Parity  
Bit 1  
Bit 2  
Bit 3  
Bit 4  
Bit 5  
Bit 6  
Start  
Stop  
Optional  
Parity Bit  
A3118-01  
Figure 5-27. Asynchronous SIO Receive Timing  
The first PTS cycle must be started manually.  
Initialize the RXD port pin and the SCK signal to the system-required logic level before  
starting a reception.  
Add the contents of the timer register to the Baud_value (Figure 5-19 on page 5-38) and  
store the result into the EPA time register. This sets up the timing for the first interrupt and  
causes the first interrupt to occur at the proper baud rate.  
The following example uses EPA0 to capture the start bit and P2.0 to receive the data (RXD). It  
sets up an asynchronous serial I/O PTS routine that receives 16 bytes each with eight data bits and  
a parity bit. This example uses several user-defined registers. R_COUNT defines the number of  
bytes to receive and RXDDONE is a flag that is set when all bytes are received.  
1. Disable the interrupts and the PTS.  
— Use the DI instruction to disable all standard interrupts and the DPTS instruction to  
disable the PTS.  
5-55  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
2. Set-up the stack pointer.  
3. Reset all interrupt mask registers.  
— Clear INT_MASK, INT_MASK1and PI_MASK.  
4. Initialize P2.0 to function as the RXD signal.  
— Set P2_DIR.0 (selects input).  
— Clear P2_MODE.0 (selects LSIO function).  
— Set P2_REG.0 (initializes RXD input to “1”).  
5. Initialize and enable the timer; select up counting, internal clock, and prescaler disabled.  
— Set T1CONTROL bits 6 and 7 (Figure 11-8 on page 11-16).  
6. Initialize the PTSCB as shown in Table 5-16.  
Table 5-16. ASIO Receive Mode PTSCBs  
PTSCB1  
PTSCB2  
PTSVEC (H) = pointer to PTSCB2  
PTSVEC (L) = pointer to PTSCB2  
BAUD (H) = 01H  
Unused  
SAMPTIME = 01H  
DATA (H) = 00H (clear register to receive data)  
DATA (L) = 00H (clear register to receive data)  
PTSCON1 = 60H (enable odd parity)  
PORTMASK = 01H (P2.0 = RXD)  
PORTREG (H) = 1FH (P2_PIN)  
BAUD (L) = ) A0H  
EPAREG (H) = 1FH (EPA0_TIME)  
EPAREG (L) = 42H (EPA0_TIME)  
PTSCON = 21H (SSIO receive mode, majority  
sampling)  
PTSCOUNT = 0AH (receive 8 data bits, 1 parity bit)  
PORTREG (L) = D6H (P2_PIn)  
7. Enable EPA0 interrupt.  
— Set INT_MASK.2.  
8. Load the number of bytes to transmit into the user_defined transmit count register  
(R_COUNT) and clear the user-defined reception-done flag (RXDDONE).  
— LD R_COUNT, #16  
— CLRB RXDDONE  
9. Select PTS service for EPA0.  
— Set PTSSEL.2.  
10. Set-up EPA0 to capture on falling edges.  
— Set EPA0_CON.4 (Figure 11-10 on page 11-19).  
5-56  
Download from Www.Somanuals.com. All Manuals Search And Download.  
STANDARD AND PTS INTERRUPTS  
11. Enable the PTS and conventional interrupts.  
— Use the EI instruction to enable all standard interrupts and the EPTS instruction to  
enable the PTS.  
12. Toggle the RXD input to start the reception. The EPA will generate a conventional  
interrupt. This interrupt service routine should be the same as the end-of-PTS rountine.  
The service routine can determine if this is a start reception interrupt or a end-of-PTS  
interrupt by reading the EPA0_CON register. If the register is set to capture mode, then  
this is the start reception interrupt.  
The interrupt service routine contains the following steps.  
1. Reconfigure the EPA channel to compare mode.  
— Set EPA0_CON.6 (selects compare mode).  
2. Initialize the first PTS cycle time by writing the time of the first interrupt to EPA0_TIME.  
To set-up the correct value, multiply the baud_value (1A0H) by 1.5, add the product to the  
current TIMER1 value, and store the result in EPA0_TIME. The baud_value determines  
the time to the first PTS interrupt. When the interrupt occurs, the PTS transmits the first  
data bit. The baud_value of 1A0H selects a baud rate of 9600. In this example, the value  
added to the current TIMER1 value is 270H.  
3. Select PTS service for EPA0.  
— Set PTSSEL.2.  
4. The PTS routine begins sampling the data every 1.5 bit times. When PTSCOUNT  
decrements to zero, the PTS calls the end-of-PTS interrupt (Figure 5-28). The interrupt  
service routine should check to see if a framing or parity error occurred (Figure 5-19 on  
page 5-38), clear the DATA registers to prepare for the next reception, reload the  
PTSCOUNT and PTSCON1 registers, and reconfigure the EPA channel to select capture  
on falling edge mode. Note that PTS service is not enabled for the EPA channel at this time  
because the next interrupt must be a conventional interrupt.  
5. To determine when all bytes have been transmitted, create a loop routine to check the  
status of the RXDDONE flag.  
5-57  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
End-Of-PTS Interrupt  
Save Critical Data  
Y
Start Bit?  
N
Disable EPA Channel  
Clear Interrupt Request Bit  
Y
Y
Y
Start Bit Error?  
N
Framing Error?  
N
Initialize  
EPA Channel  
Parity Error?  
N
Set Time To First  
Bit Sample  
Save Received Data  
RXDDONE = 3  
R_COUNT = R_COUNT - 1  
Enable PTS Service  
for EPA Channel  
Y
R_COUNT = 0?  
N
Set-up next data reception  
- Clear DATA register  
- Reload PTSCOUNT and PTSCON1 registers  
- Select PTS service for EPA channel  
- Re-initialize the EPA channel  
RXDDONE = 1  
Load Critical Data  
Return  
A3277-01  
Figure 5-28. Asynchronous SIO Receive Mode — End-of-PTS Interrupt Routine Flowchart  
5-58  
Download from Www.Somanuals.com. All Manuals Search And Download.  
6
I/O Ports  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
CHAPTER 6  
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.  
6.1 I/O PORTS OVERVIEW  
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 6-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.  
Table 6-1. Device I/O Ports  
Port  
Port 0  
Bits  
Type  
Direction  
Associated Peripheral(s)  
A/D converter (MC, MD)  
A/D converter, EPA (MH)  
8
Standard  
Input-only  
A/D converter, EPA (MC, MD)  
5 (MC)  
8 (MD)  
Standard  
Input-only  
P1.7:6 are digital input-only  
channels for the 8XC196MD.  
Port 1  
4 (MH)  
8
Standard  
Standard  
Bidirectional SIO  
EPA and timers (MC, MD)  
Port 2  
Bidirectional  
EPA and timers, SIO (MH)  
Port 3  
Port 4  
Port 5  
Port 6  
8
8
8
8
Memory-mapped  
Memory-mapped  
Memory-mapped  
Standard  
Bidirectional Address/data bus  
Bidirectional Address/data bus  
Bidirectional Bus control  
Output-only PWM, waveform generator  
EPA, frequency generator  
Port 7 (MD)  
8
Standard  
Bidirectional  
P7.6:4 are low-speed input/output pins  
only; they have no peripheral functions.  
6-1  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
6.2 INPUT-ONLY PORTS 1 (MC, MD ONLY) AND 0  
Port 0 is an eight-bit, high-impedance, input-only port that provides analog and digital inputs. The  
input-only pins can be read as digital inputs; most of them are also inputs to the A/D converter.  
The input-only ports differ from the other standard ports in that their pins can be used only as in-  
puts to the digital or analog circuitry. On the 8XC196MC and 8XC196MD, port 1 is an input-only  
port that serves the same purpose as port 0. The 8XC196MC implements five pins, while the  
8XC196MD implements all eight.  
8XC196MH: On the 8XC196MH, port 1 is a standard bidirectional port that shares pins with the  
serial I/O port. (See “Bidirectional Ports 1 (MH Only), 2, 5, and 7 (MD Only)” on page 6-4.)  
Because port 0 (and port 1 of the 8XC196MC, MD) is permanently configured as an input-only  
port, it has no configuration registers. Its single register, Px_PIN, can be read to determine the  
current state of the pin. The register is byte-addressable and can be windowed. (See “Windowing”  
on page 5-16)  
Table 6-2 lists the standard input-only port pins and Table 6-3 describes the Px_PIN status regis-  
ter.  
Table 6-2. Standard Input-only Port Pins  
Special-function  
Signal(s)  
Special-function  
Signal Type  
Associated  
Peripheral  
Port Pin  
P0.5:0  
P0.6  
ACH5:0  
Input  
A/D converter  
ACH6  
Input  
Input  
Input  
Input  
Input  
Input  
Input  
Input  
Input  
Input  
Input  
Input  
A/D converter  
EPA  
T1CLK (MH)  
ACH7  
A/D converter  
EPA  
P0.7  
T1DIR (MH)  
ACH8  
P1.0 (MC, MD)  
P1.1 (MC, MD)  
A/D converter  
A/D converter  
A/D converter  
EPA  
ACH9  
ACH10  
T1CLK  
ACH11  
T1DIR  
ACH12  
ACH13  
P1.2 (MC, MD)  
P1.3 (MC, MD)  
A/D converter  
EPA  
P1.4 (MC, MD)  
P1.5 (MD)  
A/D converter  
A/D converter  
P1.6 (MD)  
P1.7 (MD)  
6-2  
Download from Www.Somanuals.com. All Manuals Search And Download.  
I/O PORTS  
Table 6-3. Input-only Port Registers  
Address Description  
1FA8H (MC, MD) Each bit of P0_PIN reflects the current state of the corresponding  
Mnemonic  
P0_PIN  
1FDAH (MH) port 0 pin.  
P1_PIN (MC, MD) 1FA9H (MC, MD) Each bit of P1_PIN reflects the current state of the corresponding  
port 1 pin.  
6.2.1 Standard Input-only Port Operation  
Figure 6-1 is a schematic of an input-only port pin. Transistors Q1 and Q2 serve as electrostatic  
discharge (ESD) protection devices; they are referenced to VREF and ANGND. Transistor Q3 is  
an additional ESD protection device; it is referenced to VSS (digital ground). Resistor R1 limits  
current flow through Q3 to acceptable levels. At this point, the input signal is sent to the analog  
multiplexer and to the digital level-translation buffer. The level-translation buffer converts the in-  
put signals to work with the VCC and VSS digital voltage levels used by the CPU core. This buffer  
is Schmitt-triggered for improved noise immunity. The signals are latched in the P0_PIN or  
P1_PIN register and are output onto the internal bus when P0_PIN or P1_PIN is read.  
Internal Bus  
Vcc  
VREF  
VREF  
To Analog MUX  
PORT 0  
Data Register  
Level  
Translation  
Buffer  
Q1  
Buffer  
P0_PIN  
Input Pin  
150 to 200 Ohms  
Q
D
R1  
LE  
Q3  
Q2  
Read Port  
PH1 Clock  
Vss  
Vss  
Vss  
ANGND ANGND  
A0236-01  
Figure 6-1. Standard Input-only Port Structure  
6-3  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
6.2.2 Standard Input-only Port Considerations  
Port 0 and 1 pins are unique in that they may individually be used as digital inputs and analog  
inputs at the same time. However, reading the port induces noise into the A/D converter, decreas-  
ing the accuracy of any conversion in progress. We strongly recommend that you not read the  
port while an A/D conversion is in progress. To reduce noise, the P0_PIN or P1_PIN register is  
clocked only when the port is read.  
These port pins are powered by the analog reference voltage (VREF) and analog ground (ANGND)  
pins. If the port pins are to function as either analog or digital inputs, the VREF and ANGND pins  
must provide power. If the voltage applied to the analog input exceeds VREF or ANGND by more  
than 0.5 volts, current will be driven through Q1 or Q2 into the reference circuitry, decreasing the  
accuracy of all analog conversions.  
The port pin is sampled one state time before the read buffer is enabled. Sampling occurs during  
phase 1 (while CLKOUT is low) and resolves the value of the pin before it is presented to the  
internal bus. To ensure that the value is recognized, it must be valid 45 ns before the rising edge  
of CLKOUT and must remain valid until CLKOUT falls. If the pin value changes during the sam-  
ple time, the new value may or may not be recorded.  
As a digital input, a pin acts as a high-impedance input. However, as an analog input, a pin must  
provide current for a short time to charge the internal sample capacitor when a conversion begins.  
This means that if a conversion is taking place on a port pin, its input characteristics change mo-  
mentarily.  
6.3 BIDIRECTIONAL PORTS 1 (MH ONLY), 2, 5, AND 7 (MD ONLY)  
Although the bidirectional ports are very similar in both circuitry and configuration, port 5 differs  
from the others in some ways. Port 5, a memory-mapped port, uses a standard CMOS input buffer  
because of the high speeds required for system control functions. The remaining bidirectional  
ports use Schmitt-triggered input buffers for improved noise immunity.  
NOTE  
Ports 3 and 4 are significantly different from the other bidirectional ports. See  
“Bidirectional Ports 3 and 4 (Address/Data Bus)” on page 6-14 for details on  
the structure and operation of these ports.  
Table 6-4 lists the bidirectional port pins with their special-function signals and associated periph-  
erals.  
6-4  
Download from Www.Somanuals.com. All Manuals Search And Download.  
I/O PORTS  
Table 6-4. Bidirectional Port Pins  
Special-function Special-function  
Associated  
Peripheral  
Port Pin  
Signal(s)  
Signal Type  
P1.0 (MH) TXD0  
P1.1 (MH) RXD0  
P1.2 (MH) TXD1  
P1.3 (MH) RXD1  
O
SIO  
SIO  
SIO  
SIO  
EPA  
EPA  
I/O  
O
I/O  
I/O  
I/O  
P2.0  
EPA0  
EPA1 (MC, MD)  
P2.1  
SCLK0# (MH)  
BCLK0 (MH)  
I/O  
I
SIO  
SIO  
EPA2 (MC, MD)  
EPA1 (MH)  
I/O  
I/O  
I/O  
O
EPA  
EPA  
EPA  
EPA  
EPA  
EPA  
EPA  
EPA  
P2.2  
P2.3  
EPA3 (MC, MD)  
COMP3 (MH)  
COMP0  
P2.4  
P2.5  
P2.6  
O
COMP1  
O
COMP2  
O
COMP3 (MC, MD)  
O
P2.7  
SCLK1# (MH)  
BCLK1 (MH)  
I/O  
I
SIO  
SIO  
P5.0  
P5.1  
P5.2  
P5.3  
P5.4  
P5.5  
P5.6  
P5.7  
ALE/ADV#  
INST  
O
O
Bus controller  
Bus controller  
Bus controller  
Bus controller  
Bus controller  
Bus controller  
Bus controller  
Bus controller  
EPA  
WR#/WRL#  
RD#  
O
O
ONCE  
I
BHE#/WRH#  
READY  
O
I
BUSWIDTH  
I
P7.0 (MD) EPA4  
P7.1 (MD) EPA5  
P7.2 (MD) COMP4  
P7.3 (MD) COMP5  
I/O  
I/O  
O
EPA  
EPA  
O
EPA  
P7.4 (MD)  
P7.5 (MD)  
P7.6 (MD)  
I/O  
I/O  
I/O  
O
P7.7 (MD) FREQOUT  
Frequency generator  
6-5  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 6-5 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 for the standard ports are byte-addressable and can be windowed. The port 5 registers  
must be accessed using 16-bit addressing and cannot be windowed. “Bidirectional Port Consid-  
erations” on page 6-12 discusses special considerations for reading P2_REG.7 and P6_REG.7:4.  
Table 6-5. Bidirectional Port Control and Status Registers  
Mnemonic  
Address  
Description  
P1_DIR (MH)  
P2_DIR  
P5_DIR  
1F9BH  
Port x Direction  
1FD2H  
1FF3H  
1FD3H  
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.  
P7_DIR (MD)  
P1_MODE (MH)  
P2_MODE  
P5_MODE  
1F99H  
1FD0H  
1FF1H  
1FD1H  
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.  
P7_MODE (MD)  
0 = standard I/O port pin  
1 = special-function signal  
P1_PIN (MH)  
P2_PIN  
P5_PIN  
1F9FH  
1FD6H  
1FF7H  
1FD7H  
Port x Input  
Each bit of Px_PIN reflects the current state of the corresponding  
pin, regardless of the pin configuration.  
P7_PIN (MD)  
P1_REG (MH)  
P2_REG  
P5_REG  
1F9DH  
1FD4H  
1FF5H  
1FD5H  
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.  
P7_REG (MD)  
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.  
6.3.1 Bidirectional Port Operation  
Figure 6-2 shows the logic for driving the output transistors, Q1 and Q2. Q1 can source at least  
–3 mA at VCC – 0.7 volts. Q2 can sink at least 3 mA at 0.45 volts. (Consult the datasheet for spec-  
ifications.)  
6-6  
Download from Www.Somanuals.com. All Manuals Search And Download.  
I/O PORTS  
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 6-6 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 6-7 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 standard ports  
use Schmitt-triggered buffers for improved noise immunity. Port 5 uses a standard input buffer  
because of the high speeds required for bus control functions. 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.  
NOTE (8XC196MC, MD Only)  
P2.7 is an exception. After reset, P2.7 carries the CLKOUT signal (half the  
crystal input frequency) rather than being held high. When CLKOUT is  
selected, it is always a complementary output.  
6-7  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Internal Bus  
Vcc  
Px_REG  
0
SFDATA  
1
Q1  
I/O Pin  
Px_DIR  
0
Q2  
SFDIR  
1
Vss  
Px_MODE  
Sample  
Latch  
150to 200Ω  
R1  
Px_PIN  
Q
D
LE  
Read Port  
PH1 Clock  
Vcc  
Medium  
Pullup  
300ns Delay  
Q3  
RESET#  
Vcc  
Weak  
RESET#  
R
S
Pullup  
Q
Q4  
Any Write to Px_MODE  
A0238-04  
Figure 6-2. Bidirectional Port Structure  
6-8  
Download from Www.Somanuals.com. All Manuals Search And Download.  
I/O PORTS  
Table 6-6. Logic Table for Bidirectional Ports in I/O Mode  
Open-drain  
Complementary Output  
Output  
Configuration  
Input  
Px_MODE  
Px_DIR  
SFDIR  
SFDATA  
Px_REG  
Q1  
0
0
0
0
0
0
1
1
X
X
X
X
X
X
X
X
0
1
0, 1 (Note 2)  
off  
1
off  
on  
0
on  
off  
1
off  
off  
Q2  
on, off (Note 2)  
X (Note 3)  
Px_PIN  
high impedance (Note 4)  
NOTES:  
1. X = Don’t care.  
2. If Px_REG is cleared, Q2 is on; if Px_REG is set, Q2 is off.  
3. Px_PIN contains the current value on the pin.  
4. During reset and until the first write to Px_MODE, Q4 is on.  
Table 6-7. Logic Table for Bidirectional Ports in Special-function Mode  
Open-drain  
Configuration  
Complementary Output  
Input  
Output  
Px_MODE  
Px_DIR  
SFDIR  
SFDATA  
Px_REG  
Q1  
1
0
1
0
1
1
1
1
0
0
1
0, 1 (Note 2)  
X
1
0
1
1
X
X
1
off  
on  
0
on  
off  
1
off  
off  
Q2  
on, off (Note 2)  
X (Note 3)  
off  
Px_PIN  
high impedance (Note 4)  
NOTES:  
1. X = Don’t care.  
2. If Px_REG is cleared, Q2 is on; if Px_REG is set, Q2 is off.  
3. Px_PIN contains the current value on the pin.  
4. During reset and until the first write to Px_MODE, Q4 is on.  
6.3.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:  
complementary output (output only)  
high-impedance input or open-drain output (input, output, or bidirectional)  
6-9  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
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:  
1. Write to Px_DIR to establish the individual pins as either inputs or outputs. (Outputs will  
drive the data that you specify in step 3.)  
— 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.)  
2. Write to Px_MODE to select either I/O or special-function mode. Writing to Px_MODE  
(regardless of the value written) turns off the weak pull-ups. Even if the entire port is to be  
used as I/O (its default configuration after reset), you must write to Px_MODE to ensure  
that the weak pull-ups are turned off.  
— 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.  
3. Write to Px_REG.  
— 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 6-8 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.  
6-10  
Download from Www.Somanuals.com. All Manuals Search And Download.  
I/O PORTS  
Table 6-8. Control Register Values for Each Configuration  
Desired Pin Configuration  
Standard I/O Signal  
Configuration Register Settings  
Px_DIR Px_MODE†  
Px_REG  
Complementary output, driving 0  
0
0
1
1
1
0
0
0
0
0
0
1
0
1
1
Complementary output, driving 1  
Open-drain output, strongly driving 0  
Open-drain output, high impedance  
Input  
Special-function signal  
Px_DIR Px_MODE†  
Px_REG  
Complementary output, output value controlled by peripheral  
Open-drain output, output value controlled by peripheral  
0
1
1
1
1
1
X
X
1
Input  
During reset and until the first write to Px_MODE, the pins are weakly held high.  
6.3.3 Bidirectional Port Pin Configuration Example  
Assume that you wish to configure the pins of a bidirectional port as shown in Table 6-9.  
Table 6-9. Port Configuration Example  
Port Pin(s)  
Px.0, Px.1  
Configuration  
high-impedance input  
Data  
high impedance  
0
Px.2, Px.3  
Px.4  
open-drain output  
open-drain output  
1 (assuming external pull-up)  
Px.5, Px.6  
Px.7  
complementary output  
complementary output  
0
1
To do so, you could use the following example code segment. Table 6-10 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  
6-11  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 6-10. Port Pin States After Reset and After Example Code Execution  
Resulting Pin States†  
Action or Code  
Px.7  
Px.6  
Px.5  
Px.4  
Px.3  
Px.2  
Px.1  
Px.0  
Reset  
wk1  
1
wk1  
1
wk1  
1
wk1  
wk1  
HZ1  
HZ1  
wk1  
wk1  
HZ1  
0
wk1  
wk1  
HZ1  
0
wk1  
wk1  
HZ1  
HZ1  
wk1  
wk1  
HZ1  
HZ1  
LDB Px_DIR, #00011111B  
LDB Px_MODE, #00000000B  
1
1
1
LDB Px_REG, #10010011B  
1
0
0
wk1 = weakly pulled high, HZ1 = high impedance (actually a “1” with an external pull-up).  
6.3.4 Bidirectional Port Considerations  
This section outlines special considerations for using the pins of these ports.  
Port 1 (8XC196MH)  
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 6-2 on page 6-8). 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 6-2 on page 6-8). 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.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 5  
After reset, the device configures port 5 to match the external system.  
The following paragraphs describe the states of the port 5 pins after  
reset and until your software writes to the P5_MODE register.  
Writing to P5_MODE not only configures the pins but also turns off  
the transistor that weakly holds the pins high (Q4 in Figure 6-2 on  
page 6-8). For this reason, even if port 5 is to be used as it is  
configured at reset, you should still write data into P5_MODE.  
6-12  
Download from Www.Somanuals.com. All Manuals Search And Download.  
I/O PORTS  
P5.0/ALE  
If EA# is high on reset (internal access), the pin is weakly held high  
until your software writes to P5_MODE. If EA# is low on reset  
(external access), either ALE or ADV# is activated as a system  
control pin, depending on the ALE bit of CCR0. In either case, the  
pin becomes a true complementary output.  
P5.1/INST  
This pin remains weakly held high until your software writes config-  
uration data into P5_MODE.  
P5.2/WR#/WRL#  
P5.3/RD#  
This pin remains weakly held high until your software writes config-  
uration data into P5_MODE.  
If EA# is high on reset (internal access), the pin is weakly held high  
until your software writes to P5_MODE. If EA# is low on reset  
(external access), RD# is activated as a system control pin and the  
pin becomes a true complementary output.  
P5.4  
This pin is weakly held high until your software writes to  
P5_MODE. P5.4 is the enable pin for ONCE mode (see Chapter 14,  
“Special Operating Modes”) and one of the enable pins for Intel-  
reserved test modes. Because a low input during reset could cause the  
device to enter ONCE mode or a reserved test mode, exercise  
caution if you use this pin for input. Be certain that your system  
meets the VIH specification (listed in the datasheet) during reset to  
prevent inadvertent entry into ONCE mode or a test mode.  
P5.5/BHE#/WRH#  
P5.6/READY  
This pin is weakly held high until the CCB fetch is completed. At  
that time, the state of this pin depends on the value of the BW0 bit of  
the CCRs. If BW0 is clear, the pin remains weakly held high until  
your software writes to P5_MODE. If BW0 is set, BHE# is activated  
as a system control pin and the pin becomes a true complementary  
output.  
This pin remains weakly held high until the CCB fetch is completed.  
At that time, the state of this pin depends on the value of the IRC0–  
IRC2 bits of the CCRs. If IRC0–IRC2 are all set (111B), READY is  
activated as a system control pin. This prevents the insertion of  
infinite wait states upon the first access to external memory. For any  
other values of IRC0–IRC2, the pin is configured as I/O upon reset.  
NOTE: If IRC0–IRC2 of the CCB are all set (activating READY as  
a system control pin) and P5_MODE.6 is cleared (config-  
uring the pin as I/O), an external memory access may cause  
the processor to lock up.  
P5.7/BUSWIDTH  
This pin remains weakly held high until your software writes config-  
uration data into P5_MODE.  
6-13  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
6.4 BIDIRECTIONAL PORTS 3 AND 4 (ADDRESS/DATA BUS)  
Ports 3 and 4 are eight-bit, bidirectional, memory-mapped I/O ports. They can be addressed only  
with indirect or indexed addressing and cannot be windowed. Ports 3 and 4 provide the multi-  
plexed address/data bus. In programming modes, ports 3 and 4 serve as the programming bus  
(PBUS). Port 5 supplies the bus-control signals.  
During external memory bus cycles, the processor takes control of ports 3 and 4 and automatical-  
ly configures them as complementary output ports for driving address/data or as inputs for read-  
ing data. For this reason, these ports have no mode registers.  
Systems with EA# tied inactive have idle time between external bus cycles. When the address/da-  
ta bus is idle, you can use the ports for I/O. Like port 5, these ports use standard CMOS input  
buffers. However, ports 3 and 4 must be configured entirely as complementary or open-drain  
ports; their pins cannot be configured individually. Systems with EA# tied active cannot use ports  
3 and 4 as standard I/O; when EA# is active, these ports will function only as the address/data bus.  
Table 6-11 lists the port 3 and 4 pins with their special-function signals and associated peripher-  
als. Table 6-12 lists the registers that affect the function and indicate the status of ports 3 and 4.  
Table 6-11. Ports 3 and 4 Pins  
Special-function  
Signal(s)  
Special-function  
Signal Type  
Port Pins  
Associated Peripheral  
AD7:0  
I/O  
I/O  
I/O  
I/O  
Address/data bus, low byte  
Programming bus, low byte  
Address/data bus, high byte  
Programming bus, high byte  
P3.7:0  
PBUS7:0  
AD15:8  
P4.7:0  
PBUS15:8  
Table 6-12. Ports 3 and 4 Control and Status Registers  
Address Description  
1FFEH  
Mnemonic  
P3_PIN  
P4_PIN  
Port x Input  
1FFFH  
Each bit of Px_PIN reflects the current state of the corresponding pin,  
regardless of the pin configuration.  
P3_REG  
P4_REG  
1FFCH  
1FFDH  
Port x Data Output  
Each bit of Px_REG contains data to be driven out by the corresponding  
pin.  
When the device requires access to external memory, it takes control of  
the port and drives the address/data bit onto the pin. The address/data  
bit replaces your output during this time. When the external access is  
completed, the device restores your data onto the pin.  
6-14  
Download from Www.Somanuals.com. All Manuals Search And Download.  
I/O PORTS  
6.4.1 Bidirectional Ports 3 and 4 (Address/Data Bus) Operation  
Figure 6-3 shows the ports 3 and 4 logic. During reset, the active-low level of RESET# turns off  
Q1 and Q2 and turns on transistor Q3, which weakly pulls the pin high. (Q1 can source at least –  
3 mA at VCC –0.7 volts; Q2 can sink at least 3 mA at 0.45 volts; and Q3 can source approximately  
–10 µΑ at VCC –1.0 volts. Consult the datasheet for exact specifications.) During normal opera-  
tion, an internal control signal, BUS CONTROL SELECT, controls the port.  
When the microcontroller needs to access external memory, it clears BUS CONTROL SELECT,  
which selects address/data as the input to the multiplexer. Address/data then drives Q1 and Q2 as  
complementary outputs.  
When external memory access is not required, the microcontroller sets BUS CONTROL SE-  
LECT, which selects Px_REG as the input to the multiplexer. Px_REG then drives Q1 and Q2 as  
open-drain outputs. (Open-drain outputs require external pull-up resistors.) In this configuration,  
a port pin can be used as an input. The signal on the pin is latched in the Px_PIN register. The pins  
can be read, making it easy to see which pins are driven low by the microcontroller and which are  
driven high by external drivers. Table 6-13 is a logic table for ports 3 and 4 as I/O.  
Internal Bus  
VCC  
VCC  
Px_REG  
1
0
Address/Data  
Q1  
Q3  
I/O Pin  
Q2  
BUS CONTROL SELECT  
0 = Address/Data  
1 = I/O  
RESET#  
Px_PIN  
A3116-01  
Figure 6-3. Address/Data Bus (Ports 3 and 4) Structure  
6-15  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 6-13. Logic Table for Ports 3 and 4 as Open-drain I/O  
Configuration  
Px_REG  
Q1  
Open-drain  
0
off  
on  
0
1
off  
off  
Q2  
Px_PIN  
high impedance  
6.4.2 Using Ports 3 and 4 as I/O  
To use a port pin as an output, write the output data to the corresponding Px_REG bit. When the  
device requires access to external memory, it takes control of the port and drives the address/data  
bit onto the pin. The address/data bit replaces your output during this time. When the external ac-  
cess is completed, the device restores your data onto the pin.  
To use a port pin as an input, set the corresponding Px_REG bit to drive the pin to a high-imped-  
ance state. You may then read the pin’s input value in the Px_PIN register. When the device re-  
quires access to external memory, it takes control of the port. You must configure the input source  
to avoid contention on the bus.  
6.4.3 Design Considerations for Ports 3 and 4  
When EA# is active, ports 3 and 4 will function only as the address/data bus. In these circum-  
stances, an instruction that operates on P3_REG or P4_REG causes a bus cycle that reads from  
or writes to the external memory location corresponding to the SFR’s address. (For example, writ-  
ing to P4_REG causes a bus cycle that writes to external memory location 1FFDH.) Because  
P3_REG and P4_REG have no effect when EA# is active, the bus will float during long periods  
of inactivity (such as during a BMOV or TIJMP instruction).  
When EA# is inactive, ports 3 and 4 output the contents of the P3_REG and P4_REG registers,  
which reset to FFH, placing the pins in a high-impedance state. Ports 3 and 4 will float unless you  
either connect external resistors to the pins or write zeros to the P3_REG and P4_REG registers.  
6.5  
STANDARD OUTPUT-ONLY PORT 6  
Port 6 is an output-only port that provides output pins for the waveform generator and pulse-width  
modulator (PWM). The port 6 pins can be configured to operate either as port pins or as output  
pins for the waveform generator or pulse-width modulator. Table 6-2 lists the pins with their spe-  
cial-function signals and associated peripherals.  
6-16  
Download from Www.Somanuals.com. All Manuals Search And Download.  
I/O PORTS  
Table 6-14. Standard Output-only Port Pins  
Special-function  
Signal(s)  
Special-function  
Signal Type  
Associated  
Peripheral  
Port Pin  
P6.0  
P6.1  
P6.2  
P6.3  
P6.4  
P6.5  
P6.6  
P6.7  
WG1#  
Output  
Waveform generator  
Waveform generator  
Waveform generator  
Waveform generator  
Waveform generator  
Waveform generator  
PWM  
WG1  
Output  
Output  
Output  
Output  
Output  
Output  
Output  
WG2#  
WG2  
WG3#  
WG3  
PWM0  
PWM1  
PWM  
Table 6-15. Output-only Port Control Register  
Address Description  
Mnemonic  
WG_OUTPUT 1FC0H  
Port 6 Output Control Register  
This register controls the port 6 pins in I/O mode. Its functions differ when the  
port 6 pins are being used as waveform generator or PWM outputs.  
6.5.1 Output-only Port Operation  
Figure 6-4 shows a simplified circuit schematic for port 6. Port 6 has a single configuration and  
control register, WG_OUTPUT. Transistor Q1 can source at least –200 µA at VCC–0.3 volts. For  
pins P6.0–P6.5, transistor Q2 can sink at least 10 mA at 0.45 volts. For pins P6.6 and P6.7, Q2  
can sink at least 200 µA at 0.3 volts.  
6.5.2 Configuring Output-only Port Pins  
Port 6 has a single configuration register, WG_OUTPUT (Figure 6-5). This register controls the  
pin functions, values, and output polarity. This register can be addressed either as a word or as  
separate bytes, and it can be windowed. The functions of this register are different for configuring  
general-purpose outputs than for configuring waveform generator and PWM outputs.  
6-17  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Internal Bus  
Vcc  
WG_OUTPUT  
Q1  
Output Pin  
Combinational Logic  
Q2  
A2764-01  
Figure 6-4. Output-only Port  
Address:  
Reset State:  
1FC0H  
0000H  
WG_OUTPUT (Port 6)  
The port 6 output configuration (WG_OUTPUT) register controls port 6 functions. If you are using port  
6 for general-purpose outputs, write C0H (for active-high outputs) or 00H (for active-low outputs) to  
the high byte of WG_OUTPUT, and write the desired pin values to the low byte. If you are using port 6  
for waveform generator or PWM outputs, please refer to Chapter 9, “Waveform Generator” or Chapter  
10, “Pulse-width Modulator” for a description of the WG_OUTPUT register functions.  
15  
8
OP1  
D7  
OP0  
D6  
M7  
D4  
M6  
D3  
M5:4  
D2  
M3:2  
D1  
M1:0  
D0  
7
0
D5  
Bit  
Number  
Bit  
Mnemonic  
Function  
15:14  
OP1:0  
Output Polarity  
These bits select the output polarity of the port 6 pins.  
0 = active-low outputs  
1 = active-high outputs  
13  
Reserved; for compatibility with future devices, write zero to this bit.  
Mode  
12:8  
M7:0  
These bits select either the peripheral function or general-purpose  
output function of the port 6 pins. Clear these bits for general-purpose  
output.  
Figure 6-5. Port 6 Output Configuration (WG_OUTPUT) Register  
6-18  
Download from Www.Somanuals.com. All Manuals Search And Download.  
I/O PORTS  
Address:  
Reset State:  
1FC0H  
0000H  
WG_OUTPUT (Port 6) (Continued)  
The port 6 output configuration (WG_OUTPUT) register controls port 6 functions. If you are using port  
6 for general-purpose outputs, write C0H (for active-high outputs) or 00H (for active-low outputs) to  
the high byte of WG_OUTPUT, and write the desired pin values to the low byte. If you are using port 6  
for waveform generator or PWM outputs, please refer to Chapter 9, “Waveform Generator” or Chapter  
10, “Pulse-width Modulator” for a description of the WG_OUTPUT register functions.  
15  
8
OP1  
D7  
OP0  
D6  
M7  
D4  
M6  
D3  
M5:4  
D2  
M3:2  
D1  
M1:0  
D0  
7
0
D5  
Bit  
Number  
Bit  
Mnemonic  
Function  
7:0  
D7:0  
Data  
In general-purpose output mode, these bits hold the values to be driven  
out on the pins. Write the desired values to these bits (bits 7:0  
correspond to pins P6.7:0).  
Figure 6-5. Port 6 Output Configuration (WG_OUTPUT) Register (Continued)  
6-19  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
7
Serial I/O (SIO) Port  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
CHAPTER 7  
SERIAL I/O (SIO) PORT  
A serial input/output (SIO) port provides a means for the system to communicate with external  
devices. The 8XC196MH device has a two-channel serial I/O port that shares pins with ports 1  
and 2. (The 8XC196MC and 8XC196MD devices do not have serial I/O ports.) This chapter de-  
scribes the SIO port and explains how to configure it. Chapter 6, “I/O Ports,” explains how to con-  
figure the port pins for their special functions. Refer to Appendix B for details about the signals  
discussed in this chapter.  
7.1 SERIAL I/O (SIO) PORT FUNCTIONAL OVERVIEW  
The serial I/O port (Figure 7-1) is an asynchronous/synchronous port that includes a universal  
asynchronous receiver and transmitter (UART). The UART has two synchronous modes (modes  
0 and 4) and three asynchronous modes (modes 1, 2, and 3) for both transmission and reception.  
Internal  
Data  
Bus  
RXDx  
TXDx  
SBUFx_RX  
Receive Shift Register  
Transmit Shift Register  
SBUFx_TX  
BCLKx  
0
TI  
Baud Rate  
Generator  
Control Logic  
Interrupts  
RI  
XTAL1  
1
SPx_STATUS  
SPx_CON  
SPx_BAUD  
MSB  
A2774-01  
Figure 7-1. SIO Block Diagram  
The serial port receives data into the receive buffer (SBUFx_RX) and transmits data from the port  
through the transmit buffer (SBUFx_RX). The transmit and receive buffers are separate registers,  
permitting simultaneous reads and writes to both. These buffers support continuous transmissions  
and allow reception of a second byte before the first byte has been read.  
7-1  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
An independent, 15-bit baud-rate generator controls the baud rate of the serial port. Either XTAL1  
or BCLKx can provide the clock signal for modes 0–3. In mode 4, the internal shift clock is output  
on SCLKx# or an external shift clock is input on SCLKx# (in which case the baud-rate generator  
is not used). The baud-rate register (SPx_BAUD) selects the clock source and the baud rate. The  
serial port control register (SPx_CON) register controls whether SCLKx# outputs the internal  
shift clock or inputs an external shift clock.  
7.2 SERIAL I/O PORT SIGNALS AND REGISTERS  
Table 7-1 describes the SIO signals and Table 7-2 describes the control and status registers.  
Table 7-1. Serial Port Signals  
Serial  
Port  
Pin  
Serial Port  
Signal  
Port  
Signal  
Type  
Description  
P1.0 TXD0  
P1.2 TXD1  
O
Transmit Serial Data.  
In modes 1, 2, 3, and 4, TXDx transmits serial port output data. In  
mode 0, it is the serial clock output.  
P1.1 RXD0  
P1.3 RXD1  
I/O  
I/O  
Receive Serial Data.  
In modes 1, 2, 3, and 4, RXDx receives serial port input data. In mode  
0, it functions as an input or an open-drain output for data.  
P2.1 SCLK0#/BCLK0  
P2.7 SCLK1#/BCLK1  
Baud Clock.  
BCLKx can provide an external clock source for the baud-rate  
generator input.  
Shift Clock. In mode 4 only, SCLKx# are bidirectional shift clock  
signals that synchronize the serial data transfer. The DIR bit in the  
SP_CON register controls the direction of SCLKx#:  
DIR = 0 causes SCLKx# to output the internal shift clock.  
DIR = 1 allows an external shift clock to be input on SCLKx#.  
Table 7-2. Serial Port Control and Status Registers  
Address Description  
0013H  
Mnemonic  
INT_MASK1  
Interrupt Mask 1  
Setting the TIx bit enables the transmit interrupt; clearing the bit  
disables (masks) the interrupt.  
Setting the RIx bit enables the receive interrupt; clearing the bit  
disables (masks) the interrupt.  
Setting the SPE bit enables the serial port receive error interrupt.  
7-2  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SERIAL I/O (SIO) PORT  
Table 7-2. Serial Port Control and Status Registers (Continued)  
Address Description  
0012H  
Mnemonic  
INT_PEND1  
Interrupt Pending 1  
When set, the TIx bit indicates a pending transmit interrupt.  
When set, the RIx bit indicates a pending receive interrupt.  
When set, the SPE bit indicates a pending serial port receive error  
interrupt. You must read the PI_PEND register to determine which  
channel generated the interrupt.  
P1_DIR  
1F9BH  
1F99H  
Port 1 Direction  
This register selects the direction of each port 1pin. Set P1_DIR.1  
and P1_DIR.3 to configure RXD0 (P1.1) and RXD1 (P1.3) as high-  
impedance inputs/open-drain outputs, and clear P1_DIR.0 and  
P1_DIR.2 to configure TXD0 (P1.0) and TXD1 (P1.2) as comple-  
mentary outputs.  
P1_MODE  
Port 1 Mode  
This register selects either the general-purpose input/output function  
or the peripheral function for each pin of port 1. Set P1_MODE.3:0  
to configure TXD0 (P1.0), TXD1 (P1.2), RXD0 (P1.1), and RXD1  
(P1.3) for the SIO port.  
P1_PIN  
P1_REG  
P2_DIR  
1F9FH  
1F9DH  
1FD2H  
Port 1 Pin State  
Four bits of this register contain the values of the TXD0 (P1.0),  
RXD0 (P1.1), TXD1 (P1.2), and RXD1 (P1.3) pins. Read P1_PIN to  
determine the current value of the TXDx and RXDx pins.  
Port 1 Output Data  
This register holds data to be driven out on the pins of port 1. Set  
P1_REG.1 and P1_REG.3 for the RXDx pins. Set P1_REG.0 and  
P1_REG.2 for the TXDx pins.  
Port 2 Direction  
This register selects the direction of each port 2 pin. To use BCLKx  
as the baud-rate generator clock source for modes 0–3, or to use  
mode 4 (in which case SCLKx# is the shift clock), set P2_DIR.1 and  
P2_DIR.7 to configure SCLK0#/BCLK0 (P2.1) and SCLK1#/BCLK1  
(P2.7) as high-impedance inputs/open-drain outputs.  
P2_MODE  
1FD0H  
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  
and P2_MODE.7 to configure SCLK0#/BCLK0 (P2.1) and  
SCLK1#/BCLK1 (P2.7) for the SIO port.  
P2_PIN  
1FD6H  
1FD4H  
Port 2 Pin State  
Two bits of this register contain the values of the SCLK0#/BCLK0  
(P2.1) and SCLK1#/BCLK1 (P2.7) pins. Read P2_PIN to determine  
the current value of the pins.  
P2_REG  
Port 2 Output Data  
This register holds data to be driven out on the pins of port 2. Set  
P2_REG.1 and P2_REG.7 for the SCLK0#/BCLK0 (P2.1) and  
SCLK1#/BCLK1 (P2.7) pins.  
7-3  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 7-2. Serial Port Control and Status Registers (Continued)  
Address Description  
1FBCH  
Mnemonic  
PI_MASK  
Peripheral Interrupt Mask  
This register enables and disables multiplexed peripheral interrupts.  
Setting an SPx bit enables a serial port receive error interrupt;  
clearing the bit disables (masks) the interrupt.  
PI_PEND  
1FBEH  
Peripheral Interrupt Pending  
This register indicates pending multiplexed peripheral interrupts.  
When set, an SPx bit indicates a pending serial port receive error  
interrupt.  
SBUF0_RX  
SBUF1_RX  
1F80H  
1F88H  
Serial Port x Receive Buffer  
This register contains data received from the serial port.  
SBUF0_TX  
SBUF1_TX  
1F82H  
1F8AH  
Serial Port x Transmit Buffer  
This register contains data that is ready for transmission. In modes  
1, 2, and 3, writing to SBUFx_TX starts a transmission. In mode 0,  
writing to SBUFx_TX starts a transmission only if the receiver is  
disabled (SPx_CON.3 = 0).  
SP0_BAUD  
SP1_BAUD  
1F84H,1F85H  
1F8CH,1F8DH  
Serial Port x 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.  
SP0_CON  
SP1_CON  
1F83H  
1F8BH  
Serial Port x 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.  
For mode 4, this register also selects the direction (input or output)  
of the SCLKx# signal.  
SP0_STATUS 1F81H  
SP1_STATUS 1F89H  
Serial Port x 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  
SPx_STATUS clears all bits except TXE; writing a byte to  
SBUFx_TX clears the TXE bit.  
7.3 SERIAL PORT MODES  
The serial port has both synchronous and asynchronous operating modes for transmission and re-  
ception. This section describes the operation of each mode.  
7-4  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SERIAL I/O (SIO) PORT  
7.3.1 Synchronous Modes (Modes 0 and 4)  
The 8XC196MH serial port has two synchronous modes, mode 0 and mode 4. Mode 0 is the syn-  
chronous mode available on all the 8XC196 devices that have serial ports. Mode 4 is an enhanced,  
full-duplex synchronous mode.  
7.3.1.1  
Mode 0  
The most common use of mode 0 is to expand the I/O capability of the device with shift registers  
(see Figure 7-2). In this mode, the TXDx pin outputs a set of eight clock pulses, while the RXDx  
pin either transmits or receives data. Data is transferred eight bits at a time with the least-signif-  
icant bit first. Figure 7-3 shows a diagram of the relative timing of these signals. Note that only  
mode 0 uses RXDx as an open-drain output.  
Shift / LOAD#  
VCC  
Clock Inhibit  
Serial In  
Px.x  
74HC05  
15kΩ  
Data  
RXD  
TXD  
Q#  
Shift Register  
74HC165  
Clock  
Inputs  
Microcontroller  
VCC  
Outputs  
Serial  
In B  
Serial In A  
Clock  
Shift Register  
74HC164  
Clear  
Enable#  
Px.x  
A0264-03  
Figure 7-2. Typical Shift Register Circuit for Mode 0  
In mode 0, RXDx must be enabled for receptions and disabled for transmissions. (See “Program-  
ming the Control Register” on page 7-10.) When RXDx is enabled, either a rising edge on the  
RXDx input or clearing the receive interrupt (RI) flag in SPx_STATUS starts a reception. When  
RXDx is disabled, writing to SBUFx_TX starts a transmission.  
Disabling RXDx stops a reception in progress and inhibits further receptions. To avoid a partial  
or undesired complete reception, disable RXDx before clearing the RI flag in SPx_STATUS. This  
can be handled in an interrupt environment by using software flags or in straight-line code by us-  
ing the interrupt pending register to signal the completion of a reception.  
7-5  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
During a reception, the RI flag in SPx_STATUS is set after the stop bit is sampled. The RIx pend-  
ing bit in the interrupt pending register is set immediately before the RI flag is set. During a trans-  
mission, the TI flag is set immediately after the end of the last (eighth) data bit is transmitted. The  
TIx pending bit in the interrupt pending register is generated when the TI flag in SPx_STATUS is  
set.  
TXD  
D0  
D0  
D1  
D1  
D2  
D2  
D3  
D3  
D4  
D4  
D5  
D5  
D6  
D6  
D7  
D7  
RXD (out)  
RXD (in)  
Expanded:  
XTAL1  
TXD  
RXD (out)  
RXD (in)  
D0  
D0  
D1  
D2  
D1  
A0109-02  
Figure 7-3. Mode 0 Timing  
7.3.1.2  
Mode 4  
Mode 4 is an enhanced synchronous mode that is similar to mode 0 in many ways, but there are  
three main differences:  
In mode 0, TXDx inputs or outputs the clock signal and RXDx transmits or receives data. In  
mode 4, TXDx transmits data, RXDx receives data, and the SCLKx# pin inputs or outputs  
the clock signal.  
For mode 4, a direction bit (DIR) was added to the SPx_CON register. This bit controls  
whether SCLKx# outputs the internal shift clock or inputs an external shift clock.  
In mode 0, RXDx must be enabled to start a transmission (because it must transmit the  
data). In mode 4, TXDx transmits the data, so the RXDx status is unrelated to transmissions.  
Writing to SBUFx_TX starts a transmission regardless of whether RXDx is enabled.  
In mode 4, SCLKx# outputs a set of eight clock pulses while TXDx transmits data, or SCLKx#  
accepts a set of eight clock pulses while RXDx receives data. Data is transferred eight bits at a  
time with the least-significant bit first. When SCLKx# is in output mode, its timing is identical to  
that of TXDx shown in Figure 7-3. When SCLKx# is in input mode, the input shift clock signal  
is internally synchronized with the internal clock.  
7-6  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SERIAL I/O (SIO) PORT  
In mode 4, writing to SBUFx_TX starts a transmission regardless of whether RXDx is enabled.  
However, RXDx must be enabled to allow a reception. If RXDx is enabled, either a rising edge  
on the RXDx input or clearing the receive interrupt (RI) flag starts a reception.  
Disabling RXDx stops a reception in progress and inhibits further receptions. To avoid a partial  
or undesired complete reception, disable RXDx before clearing the RI flag. 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 is set one clock bit time after the last data bit is received. The re-  
ceive interrupt signal is generated immediately before the RI flag is set. During a transmission,  
the TI flag is set immediately after the end of the last (eighth) data bit is transmitted. The transmit  
interrupt signal is generated when the TI flag is set.  
7.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 7-9). 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 SBUFx_TX causes the serial  
port to start transmitting data. New data placed in SBUFx_TX is transmitted only after the stop  
bit of the previous data has been sent. A falling edge on the RXDx input causes the serial port to  
begin receiving data if RXDx is enabled. Disabling RXDx stops a reception in progress and in-  
hibits further receptions. (See “Programming the Control Register” on page 7-10.)  
7.3.2.1  
Mode 1  
Mode 1 is the standard asynchronous communications mode. The data frame used in this mode  
(Figure 7-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.  
7-7  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Stop  
Start  
D0  
D1  
D2  
D3  
D4  
D5  
D6  
D7  
Stop  
8 Bits of Data or 7 Bits of Data  
with Parity Bit  
10-bit Frame  
A0245-02  
Figure 7-4. Serial Port Frames for Mode 1  
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 SPx_STATUS are set to indicate  
completed operations. During a reception, both the RI flag and the RIx interrupt pending bit are  
set just before the end of the stop bit. During a transmission, both the TI flag and the TIx 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.  
7.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 7-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 SPx_CON register before writing to SBUFx_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 SBUFx_TX. During receptions, the RI flag and RIx 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 “Mul-  
tiprocessor Communications” on page 7-9.) Parity cannot be enabled in this mode.  
7-8  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SERIAL I/O (SIO) PORT  
Stop  
Start  
D0  
D1  
D2  
D3  
8 Bits of Data  
Programmable 9th Bit  
11-bit Frame  
D4  
D5  
D6  
D7  
D8  
Stop  
A0111-01  
Figure 7-5. Serial Port Frames in Mode 2 and 3  
7.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 SPx_CON.4 (TB8). In mode 3, a  
reception always sets the RIx interrupt pending bit, regardless of the state of the ninth bit. If parity  
is disabled, the SPx_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.  
7.3.2.4  
Mode 2 and 3 Timings  
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 RIx interrupt pending bit are set just after the end of the stop bit. During a transmission,  
the TI flag and the TIx interrupt pending bit are set at the beginning of the stop bit. The ninth bit  
can be used for parity or multiprocessor communications.  
7.3.2.5  
Multiprocessor Communications  
Modes 2 and 3 are provided for multiprocessor communications. In mode 2, the serial port sets  
the RIx interrupt pending bit only when the ninth data bit is set. In mode 3, the serial port sets the  
RIx interrupt pending bit regardless of the value of the ninth bit. The ninth bit is always set in  
address 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.  
7-9  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
7.4 PROGRAMMING THE SERIAL PORT  
To use the SIO port, you must configure the port pins to serve as special-function signals and set  
up the SIO channels.  
7.4.1 Configuring the Serial Port Pins  
Before you can use the serial port, you must configure the associated port pins to serve as special-  
function signals. Table 7-1 on page 7-2 lists the pins associated with the serial port. Table 7-2 on  
page 7-2 lists the port configuration registers, and Chapter 6, “I/O Ports,” explains how to con-  
figure the pins.  
7.4.2 Programming the Control Register  
The SPx_CON register (Figure 7-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.  
Address:  
Reset State:  
1F83H, 1F8BH  
00H  
SPx_CON  
x = 0–1 (8XC196MH)  
The serial port control (SPx_CON) register selects the communications mode and enables or disables  
the receiver, parity checking, and nine-bit data transmission.  
7
0
8XC196MH  
M2  
DIR  
PAR  
TB8  
REN  
PEN  
M1  
M0  
Bit  
Number  
Bit  
Mnemonic  
Function  
7
6
M2  
See description for bits 0 and 1.  
Synchronous Clock Direction  
DIR  
PAR  
TB8  
This bit determines the direction of the clock during synchronous mode.  
0 = output  
1 = input  
5
4
Parity Selection Bit  
This bit selects even or odd parity.  
0 = even parity  
1 = odd parity  
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 SBUFx_TX is  
written. When parity is enabled (SPx_CON.2 = 1), this bit takes on the  
even parity value.  
Figure 7-6. Serial Port Control (SPx_CON) Register  
7-10  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SERIAL I/O (SIO) PORT  
Address:  
Reset State:  
1F83H, 1F8BH  
00H  
SPx_CON (Continued)  
x = 0–1 (8XC196MH)  
The serial port control (SPx_CON) register selects the communications mode and enables or disables  
the receiver, parity checking, and nine-bit data transmission.  
7
0
8XC196MH  
M2  
DIR  
PAR  
TB8  
REN  
PEN  
M1  
M0  
Bit  
Number  
Bit  
Mnemonic  
Function  
3
REN  
Receive Enable  
Setting this bit enables receptions. When this bit is set, a falling edge on  
the RXDx 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. To avoid a partial or undesired reception, clear this bit before  
clearing the RI flag in SPx_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.  
2
PEN  
M1:0  
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 and SPx_STATUS.7 becomes the receive parity  
error bit.  
1:0  
Mode Selection  
These bits along with bit 7 select the communications mode.  
M2  
0
X
M1  
0
0
M0  
0
1
synchronous mode 0  
mode 1  
X
1
0
mode 2  
X
1
1
mode 3  
1
0
0
synchronous mode 4  
Figure 7-6. Serial Port Control (SPx_CON) Register (Continued)  
7-11  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
7.4.3 Programming the Baud Rate and Clock Source  
The SPx_BAUD register (Figure 7-7) selects the clock input for the baud-rate generator and de-  
fines the baud rate for all serial I/O modes. (For mode 4 with SCLKx# configured for input, the  
baud-rate generator is not used.) This register acts as a control register during write operations  
and as a down-counter monitor during read operations.  
WARNING  
Writing to the SPx_BAUD register during a reception or transmission can  
corrupt the received or transmitted data. Before writing to SPx_BAUD, check  
the SPx_STATUS register to ensure that the reception or transmission is  
complete.  
Address:  
Reset State:  
1F84H, 1F8CH  
0000H  
SPx_BAUD  
x = 0–1 (8XC196MH)  
The serial port baud rate x (SPx_BAUD) register selects the serial port x 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 XTAL1 and 0001H when using BCLKx. In synchronous mode 0,  
the minimum BAUD_VALUE is 0001H for transmissions and 0002H for receptions. In synchronous  
mode 4, the minimum BAUD_VALUE is 0001H for both transmissions and receptions.  
15  
8
0
8XC196MH  
CLKSRC  
BV14  
BV6  
BV13  
BV5  
BV12  
BV4  
BV11  
BV3  
BV10  
BV2  
BV9  
BV1  
BV8  
BV0  
7
BV7  
Bit  
Number  
Bit  
Mnemonic  
Function  
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 BCLKx pin (external source)  
1 = input frequency on the XTAL1 pin (internal source)  
Figure 7-7. Serial Port x Baud Rate (SPx_BAUD) Register  
7-12  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SERIAL I/O (SIO) PORT  
Address:  
Reset State:  
1F84H, 1F8CH  
0000H  
SPx_BAUD (Continued)  
x = 0–1 (8XC196MH)  
The serial port baud rate x (SPx_BAUD) register selects the serial port x 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 XTAL1 and 0001H when using BCLKx. In synchronous mode 0,  
the minimum BAUD_VALUE is 0001H for transmissions and 0002H for receptions. In synchronous  
mode 4, the minimum BAUD_VALUE is 0001H for both transmissions and receptions.  
15  
8
0
8XC196MH  
CLKSRC  
BV14  
BV6  
BV13  
BV5  
BV12  
BV4  
BV11  
BV3  
BV10  
BV2  
BV9  
BV1  
BV8  
BV0  
7
BV7  
Bit  
Number  
Bit  
Mnemonic  
Function  
14:0  
BV14:0  
These bits constitute the BAUD_VALUE.  
Use the following equations to determine the BAUD_VALUE for a given  
baud rate.  
Synchronous mode 0:†  
FXTAL1  
BCLKx  
-------------------------------------  
Baud Rate × 2  
---------------------------  
BAUD_VALUE =  
1  
or  
Baud Rate  
Asynchronous modes 1, 2, and 3:  
FXTAL1  
BCLKx  
Baud Rate × 8  
----------------------------------------  
-------------------------------------  
BAUD_VALUE =  
1 or  
Baud Rate × 16  
Synchronous mode 4 (SCLKx# output):  
FXTAL1  
-------------------------------------  
BAUD_VALUE =  
1  
Baud Rate × 4  
For mode 0 receptions, the BAUD_VALUE must be 0002H or greater.  
Otherwise, the resulting data in the receive shift register will be incorrect.  
Figure 7-7. Serial Port x Baud Rate (SPx_BAUD) Register (Continued)  
7-13  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
CAUTION  
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 TXDx. Although these two signals  
are normally synchronized, the internal signal generates one clock before the  
first pulse transmitted by TXDx and this first clock signal is not synchronized  
with TXDx. This clock signal causes the receive shift register to shift in  
whatever data is present on the RXDx 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 XTAL1 at 16 MHz, the maximum baud rates are 2.76 Mbaud (SPx_BAUD = 8002H or  
0002H) for mode 0 and 1.0 Mbaud for modes 1, 2, and 3. Table 7-3 shows the SPx_BAUD values  
for common baud rates when using a 16 MHz XTAL1 clock input. Because of rounding, the  
BAUD_VALUE formula is not exact and the resulting baud rate is slightly different than desired.  
Table 7-3 shows the percentage of error when using the sample SPx_BAUD values. In most cases,  
a serial link will work with up to a 5.0% difference in the receiving and transmitting baud rates.  
Table 7-3. SPx_BAUD Values When Using XTAL1 at 16 MHz  
SPx_BAUD Register Value†  
% Error  
Baud Rate  
Mode 0  
Mode 1, 2, 3  
Mode 0, 4  
Mode 1, 2, 3  
9600  
4800  
2400  
1200  
300  
8340H  
8682H  
8D04H  
9A0AH  
E82BH  
8067H  
80CFH  
81A0H  
8340H  
8D04H  
0.04  
0.02  
0.01  
0
0.16  
0.16  
0.08  
0.04  
0.01  
0
Bit 15 is always set when XTAL1 is selected as the clock source for the baud-rate generator.  
7.4.4 Enabling the Serial Port Interrupts  
Each serial port channel has both a transmit interrupt (TIx) and a receive interrupt (RIx). Each  
channel can also generate a serial port receive error interrupt (SPx). To enable an interrupt, set the  
corresponding mask bit in the interrupt mask register or peripheral interrupt mask register (see  
Table 7-2 on page 7-2) and execute the EI instruction to globally enable servicing of interrupts.  
See Chapter 5, “Standard and PTS Interrupts,” for more information about interrupts.  
7-14  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SERIAL I/O (SIO) PORT  
7.4.5 Determining Serial Port Status  
You can read the SPx_STATUS register (Figure 7-8) to determine the status of the serial port.  
Reading SPx_STATUS clears all bits except TXE. For this reason, we recommend that you copy  
the contents of the SPx_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 or peripheral interrupt pending register (see Table 7-2 on page 7-2)  
to determine the status of the serial port interrupts.  
Address:  
Reset State:  
1F81H, 1F89H  
00H  
SPx_STATUS  
x = 0–1 (8XC196MH)  
The serial port status (SPx_STATUS) register contains bits that indicate the status of serial port x.  
7
0
8XC196MH RPE/RB8  
RI  
TI  
FE  
TXE  
OE  
Bit  
Number  
Bit  
Mnemonic  
Function  
7
RPE/RB8  
Received Parity Error/Received Bit 8  
RPE is set if parity is disabled (SPx_CON.2 = 0) and the ninth data bit  
received is high.  
RB8 is set if parity is enabled (SPx_CON.2 = 1) and a parity error occurred.  
Reading SPx_STATUS clears this bit.  
6
RI  
Receive Interrupt  
This bit is set when the last data bit is sampled. Reading SPx_STATUS  
clears this bit.  
5
TI  
Transmit Interrupt  
This bit is set at the beginning of the stop bit transmission. Reading  
SPx_STATUS clears this bit.  
4
FE  
TXE  
OE  
Framing Error  
This bit is set if a stop bit is not found within the appropriate period of time.  
Reading SPx_STATUS clears this bit.  
3
SBUFx_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 SBUFx_TX.  
2
Overrun Error  
This bit is set if data in the receive shift register is loaded into SBUFx_RX  
before the previous bit is read. Reading SPx_STATUS clears this bit.  
1:0  
Reserved; for compatibility with future devices, write zeros to these bits.  
Figure 7-8. Serial Port Status (SPx_STATUS) Register  
7-15  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
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 SPx_STATUS register is set. When the stop bit is detected, the data  
in the receive shift register is loaded into SBUFx_RX and the receive interrupt (RI) flag is set. If  
this happens before the previous byte in SBUFx_RX is read, the overrun error (OE) bit is set.  
SBUFx_RX always contains the latest byte received; it is never a combination of the last two  
bytes.  
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 SPx_STATUS and the corresponding interrupt pending bit. However, a soft-  
ware write to the RI or TI flag in SPx_STATUS has no effect on the interrupt pending bits and  
does not cause an interrupt. Similarly, reading SPx_STATUS clears the RI and TI flags, but does  
not clear the corresponding interrupt pending bits. The RI and TI flags in the SPx_STATUS and  
the corresponding interrupt pending bits can be set even if the RIx and TIx interrupts are masked.  
The transmitter empty (TXE) bit is set if SBUFx_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 SBUFx_TX. One byte may be writ-  
ten 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.  
7-16  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8
Frequency Generator  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
CHAPTER 8  
FREQUENCY GENERATOR  
The 8XC196MD has a peripheral not found on other 8XC196Mx devices — the frequency gen-  
erator. This peripheral produces a waveform with a fixed duty cycle (50%) and a programmable  
frequency (ranging from 4 kHz to 1 MHz with a 16-MHz input clock). One application for the  
frequency generator is to drive an infrared LED to transmit remote control data and control sig-  
nals.  
This chapter describes the frequency generator and explains how to configure it. For detailed de-  
scriptions of the signals discussed in this chapter, refer to Appendix B, “Signal Descriptions.” For  
additional information and application examples, consult AP-483, Application Examples Using  
the 8XC196MC/MD Microcontroller (order number 272282).  
8.1 FUNCTIONAL OVERVIEW  
The frequency generator (Figure 8-1) has a frequency register, a count register, and an output sig-  
nal. The output signal shares pin P7.7, so you must configure the pin for its frequency generator  
output function.  
8
FREQ_GEN  
8
Port 7  
Control  
8
D
Q#  
Q
Down-  
Counter  
Load  
P7_MODE  
P7_DIR  
P7.7/FREQOUT  
FREQ_CNT  
C
P7_REG  
Count = 0  
A2702-01  
Figure 8-1. Frequency Generator Block Diagram  
8-1  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
The frequency register (FREQ_GEN) controls the output frequency. The frequency generator  
loads the FREQ_GEN value into the counter. The counter counts down until it reaches zero, at  
which time the value is reloaded from the FREQ_GEN register. Each load toggles the D flip-flop,  
producing the 50% duty cycle output. The count register (FREQ_CNT) reflects the current value  
of the down-counter. Table 8-1 describes the frequency generator’s output signal and Table 8-2  
describes the control and status registers.  
Table 8-1. Frequency Generator Signal  
Frequency  
Generator  
Signal  
Frequency  
Generator  
Signal Type  
Port  
Pin  
Description  
P7.7 FREQOUT  
O
Frequency Generator Output  
This signal carries the output of the frequency generator.  
.
Table 8-2. Frequency Generator Control and Status Registers  
Mnemonic  
Address  
Description  
FREQ_GEN  
1FB8H  
Frequency  
The frequency register holds a programmed value that determines the  
output frequency. This value is reloaded into the down-counter each time the  
counter reaches 0.  
FREQ_CNT  
P7_DIR  
1FBAH  
1FD3H  
Count  
The read-only counter register reflects the current counter value.  
Port 7 Direction  
Bit 7 controls the direction of P7.7/FREQOUT. Clear this bit to configure  
FREQOUT as a complementary output.  
P7_MODE  
P7_PIN  
1FD1H  
1FD7H  
1FD5H  
Port 7 Mode  
Bit 7 controls the mode (general-purpose I/O or special-function signal) of  
P7.7/FREQOUT. Set this bit to configure the pin for its FREQOUT function.  
Port 7 Input  
Bit 7 reflects the current state of P7.7/FREQOUT, regardless of its configu-  
ration.  
P7_REG  
Port 7 Data Output  
Bit 7 contains data to be driven out by P7.7/FREQOUT in general-purpose  
I/O mode. In special-function mode, the frequency generator controls the  
pin.  
8-2  
Download from Www.Somanuals.com. All Manuals Search And Download.  
FREQUENCY GENERATOR  
8.2 PROGRAMMING THE FREQUENCY GENERATOR  
This section explains how to configure the frequency generator and determine its status.  
8.2.1 Configuring the Output  
The frequency generator’s output is multiplexed with P7.7, so you must configure it as a special-  
function output signal. To do so, follow this sequence:  
1. Clear bit 7 of P7_DIR.  
2. Set bit 7 of P7_MODE.  
3. Clear bit 7 of P7_REG.  
Refer to Chapter 6, “I/O Ports,” for additional information about configuring port pins.  
8.2.2 Programming the Frequency  
Program the frequency register (Figure 8-2) to control the frequency of the output.  
Address:  
Reset State:  
1FB8H  
00H  
FREQ_GEN  
(8XC196MD)  
The frequency (FREQ_GEN) register holds a programmed value that specifies the output frequency.  
This value is reloaded into the down-counter each time the counter reaches 0.  
7
0
8XC196MD  
Output Frequency  
Bit  
Number  
Function  
7:0  
Output Frequency  
Use the following formula to calculate the FREQ value for the desired output frequency  
and write this value to the frequency register.  
FXTAL1  
--------------------------------------------  
FREQ =  
1  
16 ×  
FREQ_OUT  
where:  
FREQ  
FXTAL1  
FREQ_OUT  
=
=
=
8-bit value to load into FREQ_GEN register  
input frequency on XTAL1 pin, in MHz  
output frequency on FREQOUT pin, in MHz  
Figure 8-2. Frequency (FREQ_GEN) Register  
8-3  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
8.2.3 Determining the Current Value of the Down-counter  
You can read the FREQ_CNT register (Figure 8-3) to determine the current value of the down-  
counter.  
Address:  
Reset State:  
1FBAH  
00H  
FREQ_CNT  
(8XC196MD)  
Read the frequency generator count (FREQ_CNT) register to determine the current value of the  
down-counter.  
7
0
8XC196MD  
Count  
Bit  
Number  
Function  
7:0  
Count  
This register contains the current down-counter value.  
Figure 8-3. Frequency Generator Count (FREQ_CNT) Register  
8.3 APPLICATION EXAMPLE  
One application for the frequency generator is to drive an infrared LED to transmit remote control  
data and control signals (Figure 8-4). In this example, the frequency generator is configured with  
a 40-kHz frequency and is switched on and off by writing to bit 7 of the P7_MODE register. In-  
formation is transmitted serially. Zero is represented by a one-millisecond carrier burst followed  
by a one-millisecond pause; one is represented by a two-millisecond carrier burst followed by a  
two-millisecond pause (Figure 8-5). A photodiode receives the light pulses, and a high-pass filter  
rejects low-frequency ambient light and allows the 40-kHz carrier to pass through. This carrier is  
amplified and detected to reproduce the original pulse sequence.  
8-4  
Download from Www.Somanuals.com. All Manuals Search And Download.  
FREQUENCY GENERATOR  
VCC  
8XC196  
Device  
Output Signal  
Filter and  
Detector  
P7.7  
A2704-02  
Figure 8-4. Infrared Remote Control Application Block Diagram  
40 kHz  
Zero = 2 ms  
One = 4 ms  
A2703-01  
Figure 8-5. Data Encoding Example  
This program example was designed to run on an 8XC196MD demo board. It uses an EPA timer  
(timer 1) and compare channel (COMP3) to provide the timebase for the ones and zeros.  
$debug  
$nolist  
$include (c:\ecm\196mc\mc.inc)  
$list  
;
;***************************************  
; PROGRAM FREQ.A96  
;
; This program transmits a block of data serially  
; by gating the frequency generator on and off.  
;
; The carrier frequency is programmed for 40 kHz.  
; Ones are represented by a long (2 ms) carrier burst  
; followed by a long (2 ms) pause (no carrier).  
; Zeros are represented by a short (1 ms) carrier burst  
8-5  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
; followed by a short (1 ms) pause, thus generating a MFM waveform.  
;
; This program is assembled to run on the MD demo board.  
;
;**************************************  
; CONSTANT AND VARIABLE DECLARATIONS  
;**************************************  
; Program equates  
; This section defines the constants used by this program.  
; They can be changed at assembly time as required.  
;**************************************  
;
zero_time  
zero_pause_time  
one_time  
one_pause_time  
carrier_freq  
buf_size  
equ  
equ  
equ  
equ  
equ  
equ  
equ  
1000  
zero_time  
2000  
one_time  
25  
8
;1 ms  
;2 ms  
;40 KHz  
;size of data buffer (bytes)  
;initial data for buffer  
fill_char  
;
10100011b  
;**************************************  
; SFR equates in a 32-byte window  
; This section defines SFR locations as seen through a window  
; to allow using compact read-modify-write instructions.  
;**************************************  
;
p2_mode_w  
p2_dir_w  
p2_reg_w  
p2_pin_w  
;
p7_mode_w  
p7_dir_w  
p7_reg_w  
p7_pin_w  
;
equ  
equ  
equ  
equ  
0f0H  
0F2H  
0F4H  
0F6H  
;WSR = 7EH 1FD0H  
;WSR = 7EH 1FD2H  
;WSR = 7EH 1FD4H  
;WSR = 7EH 1FD6H  
equ  
equ  
equ  
equ  
0f1H  
0F3H  
0F5H  
0F7H  
;WSR = 7EH 1FD1H  
;WSR = 7EH 1FD3H  
;WSR = 7EH 1FD5H  
;WSR = 7EH 1FD7H  
timer1_w  
comp3_con_w  
comp3_time_w  
;
equ  
equ  
equ  
0FAH  
0E4H  
0E6H  
;WSR = 7BH 1F7AH  
;WSR = 7BH 1F64H  
;WSR = 7BH 1F66H  
;**************************************  
; Other SFR equates  
; This section defines the locations of the frequency generator SFRs.  
;**************************************  
;
freq_gen  
freq_cnt  
;
equ  
equ  
1FB8H  
1FBAH  
;**************************************  
; Variable storage area  
; This section defines the variables used by this program.  
;**************************************  
;
rseg at 30h  
;
rism:  
dsb 13  
;reserved for RISM  
;
rseg at 40h  
8-6  
Download from Www.Somanuals.com. All Manuals Search And Download.  
FREQUENCY GENERATOR  
;
temp:  
dsw 1  
dsw 1  
dsw 1  
dsw 1  
dsb 1  
dsb 1  
dsb 1  
temp1:  
temp2:  
buf_start:  
buf_cnt:  
bit_cnt:  
flag:  
;bit 0 = zero being sent  
;bit 1 = one being sent  
;bit 5 = get next bit  
;bit 6 = get next byte  
;bit 7 = buffer send in progress  
;
xmit_buf:  
shift_reg:  
;
dsb buf_size  
dsb 1  
;block of data to send  
;*****************************  
; MAIN PROGRAM  
;*****************************  
; Define the program location and set up the interrupts and stack.  
;*****************************  
;
cseg at 0e000h  
;RISM user space  
;
start:  
di  
;set up interrupts  
dpts  
andb int_pend1,#10000000b;  
orb int_mask1,#00000010b;unmask compare3  
ld  
sp,#0200h  
;set up stack  
;*****************************  
; Initialize pin P7.7/FREQOUT for I/O and set the pin low.  
;*****************************  
;
ldb wsr,#7EH  
;move SFR;s into window  
andb p7_reg_w,#01111111b ;P7.7 = low  
andb p7_dir_w,#01111111b ;P7.7 comp output  
andb p7_mode_w,#01111111b;P7.7 = I/O  
ldb wsr,zero_reg  
;*****************************  
; This section fills the data buffer with a “fill” character.  
; An application would typically place a block of data here.  
;*****************************  
;
ld  
temp,#xmit_buf  
;initialize buffer data  
ldb temp1,#fill_char  
ldb temp2,#buf_size  
stb temp1,[temp]+  
djnz temp2,fill  
fill:  
;*****************************  
; Start timer 1 with a 1 microsecond clock period,  
; load the carrier frequency into FREQ_GEN, and  
; enable the interrupts.  
;*****************************  
;
ldb temp,#11000010b  
;init EPA timer1  
stb temp,t1control[0] ;1 uS ticks  
ldb temp,#carrier_freq ;load carrier freq  
8-7  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
stb temp,freq_gen[0]  
ei  
;into freq gen  
;enable interrupts  
;
;
;*****************************************  
; Now send buffer out as serial data bytes  
;*****************************************  
; This section issues a 1 millisecond pulse on P2.0  
; for use with an oscilloscope monitor.  
;*****************************************  
;
ld  
ld  
wsr,#7EH  
temp,#0400  
andb p2_reg_w,#11111110b ;strobe p2.0 to sync  
andb p2_dir_w,#11111110b ;scope  
andb p2_mode_w,#11111110b;  
orb p2_reg_w,#00000001b ;set pin high  
djnzw temp,$  
andb p2_reg_w,#11111110b ;set pin low  
ld wsr,zero_reg  
;pause  
;*****************************************  
; Initialize the buffers and flag register that the interrupt routine needs.  
;*****************************************  
;
ld  
ld  
buf_start,#xmit_buf ;pointer reg  
buf_cnt,#buf_size  
;number to send  
ldb flag,#11000000b  
;set “buffer send in progress”  
;and “get next byte” flags  
;
;*****************************************  
; Set the compare module’s interrupt pending bit  
; to start sending the buffer. Loop until the buffer  
; send is complete, then start main program over.  
;*****************************************  
ldb int_pend1,#00000010b;force interrupt  
wait:  
jbs flag,7,wait  
ljmp start  
;loop here until done  
;then start over  
;
;
;*******************************************  
; COMPARE3 INTERRUPT ROUTINE  
;*******************************************  
; This routine executes each time the EPA compare channel times out.  
; The “flag” register identifies the reason for the interrupt request.  
;*******************************************  
;
cseg at 0f120H  
;
;comp3 Int vector demo board  
pusha  
;save cpu status  
jbs flag,1,one_pause  
jbs flag,0,zero_pause  
jbs flag,5,get_bit  
jbs flag,6,get_byte  
sjmp all_done  
;jump if one being sent  
;jump if zero being sent  
;get next bit  
;get next byte  
;if nothing set, done  
;
get_byte:  
andb flag,#10111111b  
ldb shift_reg,[buf_start]+  
ldb bit_cnt,#8  
;clear get byte flag  
;get byte to send into temp  
;# of bits to send per char  
8-8  
Download from Www.Somanuals.com. All Manuals Search And Download.  
FREQUENCY GENERATOR  
cmpb buf_cnt,#0  
jne dec_buf_cnt  
ljmp all_done  
decb buf_cnt  
;see if last byte has been sent  
;no!  
;yes!  
dec_buf_cnt:  
;decrement byte count  
;
get_bit:  
andb flag,#11011111b  
shlb shift_reg,#1  
;clear get bit flag  
;shift MSB into carry flag  
;send a one  
jc  
send_one  
;else send zero  
;
send_zero:  
orb flag,#00000001b  
ldb wsr,#7BH  
;set zero's flag  
;set up EPA  
ldb comp3_con_w,#01000000b  
add comp3_time_w,timer1_w,#zero_time  
ldb wsr,#7EH  
orb p7_mode_w,#10000000b  
ldb wsr,zero_reg  
sjmp done  
;start FREQOUT  
send_one:  
orb flag,#00000010b  
ldb wsr,#7BH  
;set one's flag  
;set up EPA  
ldb comp3_con_w,#01000000b  
add comp3_time_w,timer1_w,#one_time  
ldb wsr,#7EH  
orb p7_mode_w,#10000000b  
ldb wsr,zero_reg  
sjmp done  
;start FREQOUT  
;
zero_pause:  
andb flag,#11111110b  
ldb wsr,#7EH  
;turn off zero flag  
andb p7_mode_w,#01111111b  
ldb wsr,#7BH  
;turn off FREQOUT  
;set up EPA  
ldb comp3_con_w,#01000000b  
add comp3_time_w,timer1_w,#zero_pause_time  
ldb wsr,zero_reg  
sjmp next  
;
one_pause:  
andb flag,#11111101b  
ldb wsr,#7EH  
;turn off one flag  
andb p7_mode_w,#01111111b  
ldb wsr,#7BH  
;turn off FREQOUT  
;set up EPA  
ldb comp3_con_w,#01000000b  
add comp3_time_w,timer1_w,#one_pause_time  
ldb wsr,zero_reg  
;
next:  
decb bit_cnt  
;decrement bit count  
cmpb bit_cnt,#00H  
jne next1  
orb flag,#01000000b  
sjmp done  
;check if 8 bits sent  
;no, get next bit  
;yes, get next byte  
;done for now  
next1:  
orb flag,#00100000b  
sjmp done  
;set get bit flag  
;
all_done:  
done:  
ldb flag,#00H  
popa  
ret  
;clear all flags  
;
end  
8-9  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
9
Waveform Generator  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
CHAPTER 9  
WAVEFORM GENERATOR  
A waveform generator simplifies the task of generating synchronized, pulse-width modulated  
(PWM) outputs. This waveform generator is optimized for motion control applications such as  
driving 3-phase AC induction motors, 3-phase DC brushless motors, or 4-phase stepping motors.  
The waveform generator can produce three independent pairs of complementary PWM outputs  
that share a common carrier period, dead time, and operating mode. Once it is initialized, the  
waveform generator operates without CPU intervention unless you need to change a duty cycle.  
This chapter describes the waveform generator and explains how to configure it. For detailed de-  
scriptions of the signals discussed in this chapter, refer to Appendix B, “Signal Descriptions.” For  
additional information and application examples, consult AP-483, Application Examples Using  
the 8XC196MC/MD Microcontroller (order number 272282).  
9.1 WAVEFORM GENERATOR FUNCTIONAL OVERVIEW  
The waveform generator (Figure 9-1) has three main parts: a timebase generator, phase driver  
channels, and control circuitry. The timebase generator establishes the carrier period, the phase  
driver channels determine the duty cycle, and the control circuitry determines the operating mode  
and controls interrupt generation. The waveform generator’s maximum frequency is 15.625 kHz  
for center-aligned modes and 31.250 kHz for edge-aligned modes.  
There are three independent phases, each of which has two programmable, complementary out-  
puts. A programmable “dead-time” generator prevents the complementary outputs from being ac-  
tive at the same time. The carrier period, dead time, and operating mode are the same for all three  
phases; the duty cycle is independently programmable.  
9-1  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Timebase Generator  
16  
16  
WG_RELOAD  
Buffer  
Update WG_RELOAD  
WG_RELOAD  
16  
WG_COUNTER = 1  
WG Interrupt  
WG_COUNTER = WG_RELOAD  
Reload  
Comparator  
WG_COUNTER  
16  
To Other Phase Driver Channels  
Phase Driver  
One of Three Channels  
P6.0 / WG1#  
Dead-time  
Phase  
&
Comparator  
Output  
Circuitry  
P6.1 / WG1  
16  
16  
16  
WG_COMPx  
Buffer  
Update WG_COMP  
WG_COMPx  
Control  
16  
16  
8
WG_OUTPUT  
Buffer  
WG_OUTPUT  
Update WG_OUTPUT  
Output Control  
16  
8
Mode Control Signals  
and Dead Time  
WG_CONTROL  
WG_PROTECT  
Output Disable  
8
8
Protection  
Circuitry  
EXTINT Interrupt Vector  
EXTINT Input Pin  
A2637-01  
Figure 9-1. Waveform Generator Block Diagram  
9-2  
Download from Www.Somanuals.com. All Manuals Search And Download.  
WAVEFORM GENERATOR  
9.2 WAVEFORM GENERATOR SIGNALS AND REGISTERS  
Table 9-1 describes the waveform generator’s signals, and Table 9-2 briefly describes the control  
and status registers.  
Table 9-1. Waveform Generator Signals  
Waveform  
Port  
Pin  
Generator  
Signal  
Type  
Description  
P6.0  
WG1#  
O
O
O
O
O
O
I
Waveform generator phase 1 negative output.  
Waveform generator phase 1 positive output.  
Waveform generator phase 2 negative output.  
Waveform generator phase 2 positive output.  
Waveform generator phase 3 negative output.  
Waveform generator phase 3 positive output.  
Input to the waveform generator’s protection circuitry.  
P6.1  
P6.2  
P6.3  
P6.4  
P6.5  
WG1  
WG2#  
WG2  
WG3#  
WG3  
EXTINT  
.
Table 9-2. Waveform Generator Control and Status Registers  
Mnemonic  
Address  
Description  
INT_MASK1  
0013H  
Interrupt Mask 1  
The EXTINT bit enables or disables the EXTINT interrupt.  
8XC196MH: The WG bit enables or disables the waveform generator  
interrupt.  
8XC196MC, MD: The PI bit enables or disables the multiplexed peripheral  
interrupt. The corresponding bit in the PI_MASK register enables or disables  
the individual sources of the peripheral interrupt.  
INT_PEND1  
0014H  
Interrupt Pending 1  
Any set bit indicates a pending interrupt request.  
PI_MASK  
(MC, MD)  
1FBCH  
Peripheral Interrupt Mask  
8XC196MC, MD: The WG bit enables or disables the waveform generator  
interrupt as one of the possible sources of the multiplexed peripheral  
interrupt. The PI bit in INT_MASK1 must be set to enable the multiplexed  
peripheral interrupt.  
PI_PEND  
(MC, MD)  
1FBEH  
Peripheral Interrupt Pending  
Any set bit indicates a pending interrupt request.  
WG_COMP1  
WG_COMP2  
WG_COMP3  
1FC2H  
1FC4H  
1FC6H  
Waveform Generator Compare Buffers  
Each phase compare buffer contains a value that is compared with the  
counter value. The action that is performed when a match occurs depends  
on the operating mode.  
9-3  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 9-2. Waveform Generator Control and Status Registers (Continued)  
Mnemonic  
Address  
Description  
WG_CONTROL 1FCCH  
Waveform Generator Control  
The control register determines the waveform generator’s operating mode,  
starts and stops the counter, specifies the dead time for all phases, and  
indicates the current count direction.  
WG_COUNTER 1FCAH  
Waveform Generator Count Value  
The read-only counter register reflects the current counter value.  
WG_OUTPUT  
1FC0H  
Waveform Generator Output Control  
The output control register configures the waveform generator’s outputs and  
selects their active polarity.  
WG_PROTECT 1FCEH  
Waveform Generator Protection  
The protection register enables and disables the protection circuitry and the  
outputs, selects level-sensitive or edge-triggered interrupts, and controls  
which value of the edge or level will trigger an interrupt request.  
8XC196MH only: This register also selects the method for disabling the  
outputs: inactive states or weak pull-ups.  
WG_RELOAD  
1FC8H  
Waveform Generator Reload Value  
The reload register contains a value that is compared with the counter value.  
The actions performed based on this comparison depend on the operating  
mode.  
9.3 WAVEFORM GENERATOR OPERATION  
This section describes the major components of the waveform generator: the timebase generator,  
the phase driver channels, and the control and protection circuitry. It also explains how the buff-  
ered registers are updated and describes the similarities and differences between the center-  
aligned and edge-aligned operating modes. Finally, it describes the two types of interrupt requests  
that the waveform generator can generate and explains how to enable the interrupts.  
9.3.1 Timebase Generator  
The timebase generator establishes the carrier period of the PWM outputs. You specify this period  
by writing a value to the reload register (WG_RELOAD). This value is loaded into the counter  
register (WG_COUNTER) when the system is initialized and periodically (depending on the op-  
erating mode) thereafter. You can read the counter register to determine the current counter value  
and you can write to the reload register to change the reload value at any time.  
The 16-bit timebase counter is clocked every state time. The control register (WG_CONTROL)  
enables and disables the counter, controls the counting mode, and reflects the count direction.  
When the counter is enabled, it continuously counts between 0001H and the reload value. Writing  
0000H to the reload register or clearing the enable bit in the control register stops the counter.  
9-4  
Download from Www.Somanuals.com. All Manuals Search And Download.  
WAVEFORM GENERATOR  
9.3.2 Phase Driver Channels  
The phase driver channels determine the duty cycle of the outputs. You specify the duty cycle by  
writing a value to each phase’s compare register (WG_COMPx). In all operating modes, the out-  
puts are initially asserted, and they remain asserted until the counter value (WG_COUNTER)  
matches the phase’s compare register (WG_COMPx) value. At this point, the outputs are deas-  
serted and remain deasserted until another event occurs. The event that causes the outputs to be  
asserted again depends on the operating mode. (See “Operating Modes” on page 9-7.)  
The dead-time generator circuitry (Figure 9-2) prevents an output and its complement from being  
asserted at the same time. It uses two internal signals, WFG and DT, to generate the nonoverlap-  
ping outputs. The edge-detection circuitry generates the WFG signal, while a 10-bit dead-time  
counter generates the DT signal. When a valid edge is detected, the dead-time counter is loaded  
with the 10-bit dead-time value from the control register and DT is driven low. The counter dec-  
rements once every state time until it reaches zero, at which point the counter stops and DT is  
driven high. The WFG signal is ANDed with DT to produce the WG_EVEN signal; the WFG#  
signal is ANDed with DT to produce the WG_ODD signal. The waveform generator’s outputs  
can be connected to the WG_EVEN and WG_ODD signals. (See “Configuring the Outputs” on  
page 9-12.)  
Output Disable  
From  
Protection Circuit  
10-Bit Value  
WG_CONTROL  
Bits 0 – 9  
To Other  
Channels  
WG_EVEN  
Transition  
Detector  
From  
Phase  
Comparator  
P6.0 / WG1#  
P6.1 / WG1  
10-Bit Counter  
Start/ CNT=0  
Load  
DT  
Output  
Circuitry  
Trigger  
Both  
Edges  
WG_ODD  
WFG  
WFG#  
A2640-01  
Figure 9-2. Dead-time Generator Circuitry  
9.3.3 Control and Protection Circuitry  
The control circuitry contains the control (WG_CONTROL) and output (WG_OUTPUT) regis-  
ters. The control register enables or disables the counter, specifies the count direction, controls  
the operating mode, and specifies the dead time for all three phases. The output register config-  
ures the pins, specifies the output polarity (active high or active low), and controls whether the  
outputs are updated immediately or are synchronized with an event.  
9-5  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
The protection circuitry (Figure 9-3) monitors the EXTINT pin. When it detects a valid event on  
the input, it simultaneously disables the outputs and generates an EXTINT interrupt request. Soft-  
ware can also disable the outputs by clearing the enable outputs (EO) bit in the protection  
(WG_PROTECT) register.  
For the 8XC196MC and 8XC196MD, disabled outputs go to their inactive states based on the  
programmed polarity. The protection circuitry of the 8XC196MH operates in the same way as  
that of the 8XC196MC and 8XC196MD, but it allows you to choose the method used to disable  
the outputs. It can either place outputs in their inactive states, as the other devices do, or it can  
apply weak pull-ups to them. The protection type (PT) bit in the protection register controls the  
method.  
ES, IT  
EXTINT  
Interrupt  
Request  
DP  
EO Bit  
Register  
Falling  
Rising  
00  
01  
Pulse  
Transition  
Detector  
R
Q
S
OD#  
EXTINT  
FXTAL1  
Low  
10  
11  
Level  
Sampler  
High  
CPU Write EO  
CPU Read EO  
CPU Bus  
A2661-01  
Figure 9-3. Protection Circuitry  
9.3.4 Register Buffering and Synchronization  
The WG_RELOAD, WG_COMPx, and WG_OUTPUT registers are buffered; you read and write  
the buffers rather than the registers. The waveform generator updates the registers synchronously  
to prevent erroneous or nonsymmetrical duty cycles.  
When you write to the WG_COMPx buffers while the counter is stopped (either when the counter  
register is zero or when the enable counter bit in the control register is clear), the registers are  
updated one-half state time later.  
9-6  
Download from Www.Somanuals.com. All Manuals Search And Download.  
WAVEFORM GENERATOR  
The WG_RELOAD register is updated when the counter value reaches the reload value. The  
WG_COUNTER register is loaded with the updated WG_RELOAD value, so a new reload value  
takes effect for the next cycle. In mode 3 (and mode 4 for the 8XC196MH), the WG_RELOAD  
register can be updated when an EPA event occurs. This requires you to enable an EPA channel’s  
peripheral function. (See Chapter 11, “Event Processor Array (EPA)” for details.)  
The WG_OUTPUT register contains a synchronization bit that controls whether changes to the  
output signals are reflected immediately or are synchronized with an event. The synchronization  
bit is not buffered, so changes to it take effect immediately. You should initialize the synchroni-  
zation to zero (changes take effect immediately) to ensure that the pins are in the desired states  
when the counter starts.  
9.3.5 Operating Modes  
The waveform generator can operate in a center-aligned or an edge-aligned mode. In the center-  
aligned modes, the counter counts both up and down; in the edge-aligned modes, it counts up  
only. The center-aligned modes generate PWM outputs that are more efficient for driving 3-phase  
AC induction motors, while the edge-aligned modes generate conventional PWM outputs. Cen-  
ter-aligned outputs have less harmonic content than edge-aligned outputs, with effectively twice  
the carrier period.  
The initial condition of the waveform generator is the same for all operating modes. Following a  
system power-up or reset, the counter is stopped, outputs are deasserted, and all registers are  
cleared. Values written to the registers take effect one-half state time later.  
The main differences between center-aligned and edge-aligned modes are the counter’s initial  
value, the count direction, and the conditions that cause a change in the state of the outputs. Table  
9-3 summarizes the operation of the center-aligned and edge-aligned modes.  
9-7  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 9-3. Operation in Center-aligned and Edge-aligned Modes  
Step  
Center-aligned Modes  
Edge-aligned Modes  
1
Load WG_COUNTER with WG_RELOAD.  
Leave outputs deasserted.  
Load WG_COUNTER with 0001H.  
Leave outputs deasserted.  
2
3
When counter is enabled, begin counting down. When counter is enabled, begin counting up.  
Assert outputs when up count begins.  
When WG_COUNTER reaches 1, wait 1 state,  
then begin counting up. Assert outputs when up  
count begins.  
When WG_COUNTER reaches the  
When WG_COUNTER reaches the  
WG_COMPx value during the up count, deassert WG_COMPx value, deassert the corresponding  
the corresponding phase’s outputs and continue phase’s outputs and continue counting up.  
counting up.  
4
5
When WG_COUNTER reaches the  
WG_RELOAD value, begin counting down.  
When WG_COUNTER reaches the  
WG_RELOAD value, update WG_RELOAD and  
go to step 1.  
When WG_COUNTER reaches the  
WG_COMPx value during the down count,  
assert the corresponding phase’s outputs and  
continue counting down.  
6
When WG_COUNTER reaches 1, deassert  
outputs, update WG_RELOAD, and go to step 1.  
The main differences between the center-aligned modes and among the edge-aligned modes are  
the events that control register updates. Table 9-4 lists the events that can cause register updates  
and the registers that are updated in each mode.  
Table 9-4. Register Updates  
Center-aligned Modes  
Edge-aligned Modes  
Mode 3  
Mode 4  
(MH Only)  
Event  
Mode 0  
Mode 1  
Mode 2  
Registers Updated  
Registers Updated  
WG_RELOAD  
WG_COUNTER  
WG_COMPx  
WG_RELOAD  
WG_COUNTER  
WG_COMPx  
WG_RELOAD  
WG_COUNTER  
WG_COMPx  
WG_RELOAD  
WG_COUNTER  
WG_COMPx  
WG_RELOAD  
WG_COUNTER  
WG_COMPx  
WG_COUNTER  
= WG_RELOAD  
WG_OUTPUT†  
WG_OUTPUT†  
WG_OUTPUT†  
WG_OUTPUT†  
WG_OUTPUT†  
WG_COUNTER = 1  
WG_COMPx  
WG_OUTPUT†  
WG_OUTPUT†  
WG_OUTPUT†  
WG_RELOAD  
WG_COUNTER  
WG_COMPx  
WG_OUTPUT†  
EPA event  
WG_OUTPUT†  
The WG_OUTPUT register is updated under these conditions if its synchronization bit is set;  
otherwise, changes take effect immediately.  
9-8  
Download from Www.Somanuals.com. All Manuals Search And Download.  
WAVEFORM GENERATOR  
9.3.5.1  
Center-aligned Modes  
In the center-aligned modes, the counter counts down from the WG_RELOAD value to 1, then  
counts back up from 1 to WG_RELOAD. When you write to the WG_RELOAD register,  
WG_COUNTER is loaded with the reload value. When you set the enable bit in the control reg-  
ister, the counter begins counting down and continues counting until it reaches 1, waits one state  
time, and starts counting up until it reaches WG_RELOAD. At this point, WG_RELOAD is up-  
dated and WG_COUNTER is reloaded with the updated value, so a new reload value takes effect  
for the next cycle. The counter resumes counting down from WG_RELOAD to 1. This produces  
a symmetrical ascending and descending count, illustrated by the triangular wave in Figure 9-4,  
with a period that is twice the WG_RELOAD value. Figure 9-5 shows the operation of outputs  
and interrupts in center-aligned modes.  
WG_RELOAD  
Changed  
Counter  
Enabled  
WG_COUNTER =  
WG_RELOAD  
WG_COUNTER  
Value  
1
0
Carrier Period  
Reset  
Write to WG_RELOAD  
A2636-01  
Figure 9-4. Center-aligned Modes — Counter Operation  
In mode 0, the WG_COMPx and WG_OUTPUT registers are updated only once during the car-  
rier period, when the counter reaches the reload value. In mode 1, these registers are updated  
twice during the carrier period: first when the counter is set to 1, then again when it reaches the  
reload value.  
9-9  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
WG_COMPx  
WG_COUNTER  
1
WG_COUNTER  
=WG_COMPx  
WG Interrupt  
P6.0 / WG1#  
Note:  
Carrier period and duty cycle both  
change since WG_COMP is not changed.  
x
P6.1 / WG1  
Mode 0, OP0 = OP1 = 1, PH1.0 = PH1.1 = PH1.2 = 1  
= Additional interrupt in mode 1 only.  
A2641-01  
Figure 9-5. Center-aligned Modes — Output Operation  
Edge-Aligned Modes  
9.3.5.2  
In the edge-aligned modes, the counter begins at 1 and counts up to the WG_RELOAD value.  
When you write to the WG_RELOAD register, WG_COUNTER is loaded with 0001H. When  
you set the enable bit in the control register, the counter begins counting up and continues count-  
ing until it reaches the WG_RELOAD value or, in mode 3 only, until an EPA event occurs. At  
this point, WG_COUNTER is reloaded with 0001H and WG_RELOAD is updated, so a new re-  
load value takes effect for the next cycle. The counter resumes counting up from 0001H to  
WG_RELOAD. This produces a smoothly ascending count, illustrated by the sawtooth wave in  
Figure 9-6, with a period that is equal to the WG_RELOAD value. Figure 9-7 shows the operation  
of outputs and interrupts in edge-aligned modes.  
In mode 2, the registers are updated only once during the carrier period, when the counter reaches  
the reload value. In mode 3, the registers are also updated when an EPA peripheral function event  
occurs. (You must configure an EPA channel for this function. See Chapter 11, “Event Processor  
Array (EPA)” for information.)  
9-10  
Download from Www.Somanuals.com. All Manuals Search And Download.  
WAVEFORM GENERATOR  
WG_RELOAD  
Updated  
EPA Event  
(Mode 3 Only)  
WG_RELOAD  
Value  
Counter  
Enabled  
WG_COUNTER  
Value  
1
0
Carrier  
Period  
Reset  
Write to WG_RELOAD  
A2639-01  
Figure 9-6. Edge-aligned Modes — Counter Operation  
EPA Event  
WG_COMPx  
WG_COUNTER  
1
Carrier  
Period  
WG_COUNTER  
=WG_COMP  
WG Interrupt  
P6.0 / WG1#  
Note:  
Carrier period and duty cycle both  
change since WG_COMPx is not changed.  
P6.1 / WG1  
Mode 3, OP0 = OP1 = 1, PH1.0 = PH1.1 = PH1.2 = 1  
A2653-01  
Figure 9-7. Edge-aligned Modes — Output Operation  
8XC196MH only: The 8XC196MH device has an additional edge-aligned mode, mode 4. This  
mode prevents the output “jitter” that can occur in mode 3 when an EPA event reloads  
WG_COUNTER, which also causes a change in the duty cycle. In mode 4, an EPA event reloads  
WG_OUTPUT, but WG_COMPx and WG_COUNTER are reloaded only when the counter  
reaches the reload value.  
9-11  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
9.4 PROGRAMMING THE WAVEFORM GENERATOR  
This section explains how to configure the waveform generator and determine its status.  
9.4.1 Configuring the Outputs  
The waveform generator’s outputs are multiplexed with general-purpose output port 6, so you  
must configure them as special-function signals to use them as waveform-generator outputs. The  
WG_OUTPUT register (Figure 9-8) configures the pins, establishes the output polarity, and con-  
trols whether changes to the outputs are synchronized with an event or take effect immediately.  
Four bits of WG_OUTPUT are unrelated to the waveform generator; they configure the outputs  
for the pulse-width modulator (PWM) peripheral, which also shares pins with port 6. The P6 and  
PE6 bits control the P6.6/PWM0 pin, and the P7 and PE7 bits control the P6.7/PWM1 pin. Their  
placement in this register allows you to configure all the port 6 pins with a single write to  
WG_OUTPUT.  
Table 9-5 shows the bit combinations necessary to drive the waveform generator’s outputs high  
or low or to connect them to the WG_EVEN or WG_ODD signal. Note that PHx.2 is always set  
to select the waveform-generator signal function (clearing PHx.2 selects the general-purpose I/O  
port function). The “Output Polarities” column shows the output polarities. The drawings show  
a duty cycle of about 15%, and for these cases, the high portion of the waveforms increases as  
dead time increases.  
,
Table 9-5. Output Configuration  
Output Values  
WGx WGx#  
Output Polarities  
PHx.2 PHx.1 PHx.0  
WGx  
WGx#  
1
1
0
0
0
1
Low  
Low  
Always Low  
Always Low  
Low  
WG_EVEN#  
Always Low  
1
1
1
1
0
1
WG_ODD  
Low  
Always Low  
WG_ODD WG_EVEN  
NOTE: This table assumes active-high outputs (OP1=OP0=1).  
9-12  
Download from Www.Somanuals.com. All Manuals Search And Download.  
WAVEFORM GENERATOR  
Address:  
Reset State:  
1FC0H  
0000H  
WG_OUTPUT (Waveform Generator)  
The waveform generator output configuration (WG_OUTPUT) register controls the configuration of  
the waveform generator and PWM module pins. Both the waveform generator and the PWM module  
share pins with port 6. Having these control bits in a single register enables you to configure all port 6  
pins with a single write to WG_OUTPUT.  
15  
8
OP1  
P7  
OP0  
P6  
SYNC  
PH3.1  
PE7  
PE6  
PH3.2  
PH2.0  
PH2.2  
PH1.1  
PH1.2  
PH1.0  
7
0
PH3.0  
PH2.1  
Bit  
Number  
Bit  
Mnemonic  
Function  
15  
OP1  
Output Polarity  
Selects the output polarity for negative-phase outputs WG1#, WG2#,  
and WG3#.  
0 = active-low outputs  
1 = active-high outputs  
14  
13  
OP0  
Output Polarity  
Selects the output polarity for positive-phase outputs WG1, WG2, and  
WG3.  
0 = active-low outputs  
1 = active-high outputs  
SYNC  
Synchronize  
Selects whether updating the WG_OUTPUT register is synchronized  
with another event or occurs immediately after you change it.  
0 = update WG_OUTPUT immediately  
1 = synchronize WG_OUTPUT update with an event  
To ensure that the outputs are in the desired states when the waveform  
generator starts, you should initially clear this bit, then set it later if you  
want subsequent WG_OUTPUT updates to be synchronized with an  
event. (Table 9-4 on page 9-8 lists the events that update WG_OUTPUT  
in each mode.)  
12  
11  
PE7  
PE6  
P6.7/PWM1 Function  
Selects the port function or the PWM output function of P6.7/PWM1.  
0 = P6.7  
1 = PWM1  
P6.6/PWM0 Function  
Selects the port function or the PWM output function of P6.6/PWM0.  
0 = P6.6  
1 = PWM0  
Figure 9-8. WG Output Configuration (WG_OUTPUT) Register  
9-13  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Address:  
Reset State:  
1FC0H  
0000H  
WG_OUTPUT (Waveform Generator) (Continued)  
The waveform generator output configuration (WG_OUTPUT) register controls the configuration of  
the waveform generator and PWM module pins. Both the waveform generator and the PWM module  
share pins with port 6. Having these control bits in a single register enables you to configure all port 6  
pins with a single write to WG_OUTPUT.  
15  
8
OP1  
P7  
OP0  
P6  
SYNC  
PH3.1  
PE7  
PE6  
PH3.2  
PH2.0  
PH2.2  
PH1.1  
PH1.2  
PH1.0  
7
0
PH3.0  
PH2.1  
Bit  
Number  
Bit  
Mnemonic  
Function  
10  
PH3.2  
Phase 3 Function  
Selects either the port function or the waveform generator output  
function for pins P6.4/WG3# and P6.5/WG3.  
0 = P6.4, P6.5  
1 = WG3#, WG3  
9
8
PH2.2  
PH1.2  
Phase 2 Function  
Selects either the port function or the waveform generator output  
function for pins P6.2/WG2# and P6.3/WG2.  
0 = P6.2, P6.3  
1 = WG2#, WG2  
Phase 1 Function  
Selects either the port function or the waveform generator output  
function for pins P6.0/WG1# and P6.1/WG1.  
0 = P6.0, P6.1  
1 = WG1#, WG1  
7
P7  
P6.7/PWM1 Value  
Write the desired P6.7/PWM1 value to this bit.  
6
P6  
P6.6/PWM0 Value  
Write the desired P6.6/PWM0 value to this bit.  
5:4  
PH3.1:0  
P6.4/WG3#, P6.5/WG3 Value  
Write the desired output values to these bits. See Table 9-5 on page  
9-12.  
3:2  
1:0  
PH2.1:0  
PH1.1:0  
P6.2/WG2#, P6.3/WG2 Values  
Write the desired output values to these bits. See Table 9-5 on page  
9-12.  
P6.0/WG1#, P6.1/WG1 Values  
Write the desired output values to these bits. See Table 9-5 on page  
9-12.  
Figure 9-8. WG Output Configuration (WG_OUTPUT) Register (Continued)  
9-14  
Download from Www.Somanuals.com. All Manuals Search And Download.  
WAVEFORM GENERATOR  
9.4.2 Controlling the Protection Circuitry and EXTINT Interrupt Generation  
The protection register (Figure 9-9) controls the protection circuitry and EXTINT interrupt re-  
quests.  
Address:  
Reset State (MC, MD)  
Reset State (MH):  
1FCEH  
F0H  
WG_PROTECT  
E0H  
The waveform protection (WG_PROTECT) register enables and disables the outputs and the  
protection circuitry. It also selects either level-sensitive or edge-triggered EXTINT interrupts, and  
selects which level or edge will generate an EXTINT interrupt request.  
7
0
0
8XC196MC, MD  
8XC196MH  
ES  
ES  
IT  
IT  
DP  
DP  
EO  
EO  
7
PT  
Bit  
Number  
Bit  
Mnemonic  
Function  
7:5  
Reserved; for compatibility with future devices, write zeros to these bits.  
6†  
PT  
Protection Type  
This bit selects the method used for disabling the outputs.  
0 = inactive states  
1 = weak pull-ups  
3:2  
ES  
IT  
Enable Sampling and Interrupt Type  
The ES bit selects whether the protection circuitry samples the EXTINT  
signal level or detects a signal transition (edge), while the IT bit controls  
which value of the edge or level triggers an interrupt request. The  
possible combinations are as follows.  
ES  
IT  
Event  
0
0
1
1
0
1
0
1
falling edge  
rising edge  
low level  
high level  
1
DP  
EO  
Disable Protection  
This bit enables and disables the protection circuitry.  
0 = enable protection  
1 = disable protection  
0
Enable Outputs  
This bit enables and disables the outputs.  
0 = disable outputs  
1 = enable outputs  
On the 8XC196MC, MD devices, this bit is reserved. For compatibility with future devices, always  
write as zero.  
Figure 9-9. Waveform Generator Protection (WG_PROTECT) Register  
9-15  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
9.4.3 Specifying the Carrier Period and Duty Cycle  
The reload register (WG_RELOAD) and the phase compare registers (WG_COMPx) control the  
carrier period and duty cycle. Write a value to the reload register (Figure 9-10) to establish the  
carrier period. Write a value to each phase compare register to specify the length of time that the  
associated outputs will remain asserted.  
Address:  
Reset State:  
1FC8H  
0000H  
WG_RELOAD  
The waveform generator reload (WG_RELOAD) register and the phase compare registers  
(WG_COMPx) control the carrier period and duty cycle. Write a value to the reload register to  
establish the carrier period.  
Changing the WG_RELOAD value changes both the carrier period and the duty cycle because the  
outputs remain asserted for a constant length of time, while the counter takes longer to cycle. To  
change the carrier period without changing the duty cycle, you must proportionally change both  
WG_RELOAD and WG_COMPx at the same time, immediately after the interrupt.  
15  
0
Reload  
Bit  
Number  
Function  
15:0  
Reload  
This register determines the carrier period.  
Use the following formulas to calculate carrier period and duty cycle.  
multiplier × WG_RELOAD  
--------------------------------------------------------------------  
TCARRIER  
=
FXTAL1  
WG_COMPx  
WG_RELOAD  
-------------------------------------  
Duty Cycle =  
× 100%  
where:  
TCARRIER  
=
=
=
=
=
carrier period, in µs  
FXTAL1  
input frequency on XTAL1 pin, in MHz  
4 for center-aligned modes; 2 for edge-aligned modes  
16-bit WG_RELOAD value WG_COMPx  
16-bit WG_COMPx value WG_RELOAD  
multiplier  
WG_RELOAD  
WG_COMPx  
Figure 9-10. Waveform Generator Reload (WG_RELOAD) Register  
9-16  
Download from Www.Somanuals.com. All Manuals Search And Download.  
WAVEFORM GENERATOR  
Address: 1FC2H,1FC4H,1FC6H  
Reset State: 0000H  
WG_COMPx  
x = 1–3  
The phase compare (WG_COMPx) register controls the duty cycle of each phase. Write a value to  
each phase compare register to specify the length of time that the associated outputs will remain  
asserted.  
Changing the WG_RELOAD value changes both the carrier period and the duty cycle because the  
outputs remain asserted for a constant length of time, while the counter takes longer to cycle. To  
change the carrier period without changing the duty cycle, you must proportionally change both  
WG_RELOAD and WG_COMPx at the same time, immediately after the interrupt.  
15  
0
Compare  
Bit  
Number  
Function  
15:0  
Compare  
These bits determine the length of time that the associated outputs are asserted.  
Use the following formulas to calculate output assertion time and duty cycle.  
multiplier × WG_COMPx  
----------------------------------------------------------------  
TOUTPUT  
=
FXTAL1  
WG_COMPx  
-------------------------------------  
Duty Cycle =  
× 100%  
WG_RELOAD  
where:  
TOUTPUT  
=
=
=
=
=
total time output is asserted, in µs  
FXTAL1  
input frequency on XTAL1 pin, in MHz  
multiplier  
WG_RELOAD  
WG_COMPx  
4 for center-aligned modes; 2 for edge-aligned modes  
16-bit WG_RELOAD value WG_COMPx  
16-bit WG_COMPx value WG_RELOAD  
Figure 9-11. Phase Compare (WG_COMPx) Register  
9.4.4 Specifying the Operating Mode and Dead Time and Starting the Counter  
The control register (Figure 9-12) specifies the dead time and operating mode and enables and  
disables the counters. A read-only bit (CS) indicates the current count direction.  
9-17  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
WG_CONTROL  
Address:  
Reset State (MC, MD):  
Reset State (MH):  
1FCCH  
00C0H  
8000H  
The waveform generator control (WG_CONTROL) register controls the operating mode, dead time,  
and count direction, and enables and disables the counter.  
15  
8
0
M2  
M1  
M0  
CS  
EC  
DT9  
DT1  
DT8  
DT0  
7
DT7  
DT6  
DT5  
DT4  
DT3  
DT2  
Bit  
Bit  
Mnemonic  
Function  
Number  
15  
14:12  
Reserved; for compatibility with future devices, write zero to this bit.  
M2:0  
Operating Mode  
This field controls the waveform generator’s operating mode.  
M2  
M1  
M0  
Mode  
0
0
0
0
1
0
0
1
1
1
0
1
0
1
1
0
1
2
3
4
center-aligned; update registers once  
center-aligned; update registers twice  
edge-aligned; update registers once  
edge-aligned; update registers twice  
(8XC196MH only) edge-aligned; update  
WG_COMPx and WG_COUNTER only when  
WG_COUNTER = WG_RELOAD  
11  
CS  
Counter Status  
This read-only bit indicates whether the counter is counting up or  
counting down.  
0 = down counting  
1 = up counting  
10  
EC  
Enable Counter  
This bit starts and stops the counter.  
0 = disable (stop) counter  
1 = enable (start) counter  
9:0  
DT9:0  
Dead-time  
This field specifies the dead-time for all three phases. Use the following  
formula to calculate the appropriate DT_VALUE.  
TDEAD × FXTAL1  
------------------------------------------  
DT_VALUE =  
2
where:  
TDEAD = dead-time, in µs  
XTAL1 = input frequency on XTAL1 pin, in MHz  
F
Figure 9-12. Waveform Generator Control (WG_CONTROL) Register  
9-18  
Download from Www.Somanuals.com. All Manuals Search And Download.  
WAVEFORM GENERATOR  
9.5 DETERMINING THE WAVEFORM GENERATOR’S STATUS  
Read WG_CONTROL (Figure 9-12 on page 9-18) to determine the current dead-time value,  
counter status, count direction, and operating mode. Read WG_COUNTER (Figure 9-13) to de-  
termine the current counter value.  
Address:  
Reset State (MC, MD):  
Reset State (MH):  
1FCAH  
XXXXH  
0000H  
WG_COUNTER  
You can read the waveform generator counter (WG_COUNTER) register to determine the current  
counter value.  
15  
0
Counter Value  
Bit  
Number  
Function  
15:0  
Counter Value  
This register reflects the current counter value.  
Figure 9-13. Waveform Generator Counter (WG_COUNTER) Register  
9.6 ENABLING THE WAVEFORM GENERATOR INTERRUPTS  
The waveform generator can generate two types of interrupt requests. The WG interrupt request  
is triggered by the counter, while the EXTINT interrupt is triggered by an external event.  
Mode 0 generates a WG interrupt request once per period, when the counter reaches the  
WG_RELOAD value. Mode 1 generates a WG interrupt request twice per period, first when the  
counter reaches 1 and again when it reaches the WG_RELOAD value. The edge-aligned modes  
generate a WG interrupt request once at the end of each period, when the counter is reloaded with  
1.  
The protection circuitry controls the EXTINT interrupt. Two bits in the protection register control  
the type of external event that will generate an interrupt request: a falling or rising edge or a low  
or high level. (See “Controlling the Protection Circuitry and EXTINT Interrupt Generation” on  
page 9-15.)  
The edge detection circuitry requires a signal to remain asserted for at least 2 state times to be  
considered a valid edge. The sample circuitry requires a signal to remain asserted for at least 24  
state times to be considered a valid level. It samples the input level 3 times during this 24-state  
period and recognizes the signal as valid only if it is asserted for each sample. Level sampling is  
useful for environments in which noise spikes might cause unintended interrupts if edge detection  
were used.  
9-19  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
To enable the interrupts, set the corresponding mask bits in the mask register (see Table 9-2 on  
page 9-3) and execute the EI instruction to enable interrupt servicing. You can read the interrupt  
pending register to determine whether there are any pending interrupts. Refer to Chapter 5, “Stan-  
dard and PTS Interrupts” for details.  
9.7 DESIGN CONSIDERATIONS  
This section describes design and programming considerations for using the waveform generator.  
9.7.1 Dead Time and Duty Cycle  
Short dead times have little effect on the duty cycle if the pulse is relatively wide; however, longer  
dead times with narrower pulses can affect the duty cycle (Figure 9-14). No minimum pulse width  
is imposed by the hardware, so it is possible to deassert an output for the entire period if the total  
dead time is greater than the pulse width. For this reason, software should ensure that the pulse  
width is at least 3 × TDEAD  
.
WG_COUNT  
1
Dead Time  
Increased  
Dead Time  
Increased  
WG_COUNT=  
WG_COMP  
Dead Time  
(DT)  
WFG  
P6.0 / WG1#  
=DT x WFG#  
P6.1 / WG1  
=DT x WFG  
No WFG1 Output  
Mode 0, OP0 = OP1 = 1, PH1.0 = PH1.1 = PH1.2 = 1  
= Power Output Driver Enabled  
= Dead Time  
A2660-01  
Figure 9-14. Effect of Dead Time on Duty Cycle  
9-20  
Download from Www.Somanuals.com. All Manuals Search And Download.  
WAVEFORM GENERATOR  
9.7.2 EXTINT Interrupts and Protection Circuitry  
The protection register contains two bits, disable protection (DP) and enable output (EO), that to-  
gether enable and disable the waveform generator’s outputs. The EXTINT event generates a sin-  
gle short pulse that clears the EO bit, so if software sets the EO bit immediately following an  
EXTINT event, the outputs will be disabled only for the time between the EXTINT event and the  
CPU write. The CPU can immediately set the EO bit again, even if the EXTINT signal remains  
asserted.  
9.8 PROGRAMMING EXAMPLE  
This example was designed to run on an 8XC196MC demo board, but it can easily be modified  
for an evaluation board. The program allows you to test the waveform generator’s registers and  
observe their effects on the output waveforms. All variables are defined as words and are masked  
to the appropriate length before they are written to the registers. (This method is not compact, but  
it is easy to code and debug.) When running the program under the reduced instruction set mon-  
itor (RISM) software, you can use the following command to change any variable and immedi-  
ately see the result on the outputs:  
WORD.variable_name  
$debug  
;Program to test WFG peripheral  
;
$nolist  
$include (c:\ecm\196mc\mc.inc)  
$list  
;
; This program allows modifying the WFG input parameters "on the fly"  
; on the MC demo board. This allows you to see what is really going on.  
;
; First, set up the variables that you want to control:  
;
rseg at 40h  
;
mode:  
op0:  
op1:  
sync:  
pe7:  
pe6:  
p7:  
p6:  
ph1:  
ph2:  
dsw 1  
dsw 1  
dsw 1  
dsw 1  
dsw 1  
dsw 1  
dsw 1  
dsw 1  
dsw 1  
dsw 1  
;mode = 0-3  
;P6.0,2,4 polarity--0=low, 1=high  
;P6.1,3,5 polarity--0=low, 1=high  
;0=load now, 1 = synchronized  
;P6.7 0=i/o, 1=PWM  
;P6.6 0=i/o, 1=PWM  
;P6.7 I/O value  
;P6.7 I/O value  
;P6.0,1 config  
;P6.2,3 config  
9-21  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
ph3:  
eo:  
dp:  
it:  
es:  
dsw 1  
dsw 1  
dsw 1  
dsw 1  
dsw 1  
dsw 1  
dsw 1  
dsw 1  
dsw 1  
dsw 1  
dsw 1  
dsw 1  
dsw 1  
dsw 1  
;P6.4,5 config  
;0=disable output, 1=enable output  
;0=enable protection, 1=disable  
;0=falling edge trig, 1=rising edge  
;0=edge, 1=sample  
;0=stop cntr, 1=start  
;10-bit dead time  
ec:  
dead:  
reload:  
comp1:  
comp2:  
comp3:  
temp:  
temp1:  
temp2:  
;
;
;**************************************************  
; first, initialize the values for these variables:  
;**************************************************  
;
cseg at 0e000h  
;demo board RAM  
;
di  
dpts  
ld  
ld  
ld  
ld  
ld  
ld  
ld  
ld  
ld  
ld  
ld  
ld  
ld  
ld  
ld  
ld  
ld  
ld  
ld  
ld  
ld  
ld  
;
sp,#200h  
mode,#0000h  
ec,#0001h  
;mode0  
;enable cntr  
;1.6 us  
;active high  
dead,#0010h  
op0,#0001h  
op1,#0001h  
sync,#0001h  
pe7,#00000h  
pe6,#00000h  
p7,#00000h  
p6,#00000h  
ph1,#0007h  
ph2,#0007h  
ph3,#0007h  
eo,#0001h  
dp,#0001h  
it,#0001h  
es,#0001h  
reload,#1000h  
comp1,#0100h  
comp2,#0200h  
comp3,#0400h  
;active high  
;synchronized WG_OUTPUT load  
;P6.7 in I/O mode  
;P6.6 in I/O mode  
;P6.7 I/O = 0  
;P6.6 I/O = 0  
;wfg both outputs  
;wfg both outputs  
;wfg both outputs  
;enable outputs  
;disable protection  
;rising/high edge trigger  
;24-state trigger  
;1.024 ms mode0  
;64 us  
;128 us  
;256 us  
;************************  
; now initialize the WFG  
;************************  
;
;set up interrupts  
;
ldb temp,#00010000b  
;
stb temp,PI_MASK[0]  
ldb temp,#00100000b  
ldb int_mask1,temp  
;unmask WG interrupt  
;
;
;
9-22  
Download from Www.Somanuals.com. All Manuals Search And Download.  
WAVEFORM GENERATOR  
;load WFG registers  
;
call wgout  
call loadregs  
call protect  
;initialize WG_OUTPUT register  
;initialize reload & compare regs  
;initialize protection  
call wgcon  
;initialize WG_CONTROL  
;
;enable interrupts & loop here  
;
ei  
sjmp $  
;
;****************************************  
; form WG_OUTPUT value from variable data  
;****************************************  
;
wgout:  
ld  
temp,op1  
;get op1  
;mask  
;move bit to correct location  
and temp,#0001h  
shl temp,#15  
ld  
temp1,op0  
;get op0  
;mask  
;move bit to correct location  
;combine  
and temp1,#0001h  
shl temp1,#14  
or  
temp1,temp  
ld  
temp,sync  
;get sync bit  
;mask  
;move to correct location  
;combine  
and temp,#0001h  
shl temp,#13  
or  
temp1,temp  
ld  
temp,pe7  
;get pe7 bit  
;mask  
;move to correct location  
;combine  
and temp,#0001h  
shl temp,#12  
or  
temp1,temp  
ld  
temp,pe6  
;get pe6 bit  
;mask  
;move to correct location  
;combine  
and temp,#0001h  
shl temp,#11  
or  
temp1,temp  
ld  
temp,ph3  
;get ph3 bits  
;mask for ph3.2  
;move  
and temp,#0004h  
shl temp,#8h  
or  
temp1,temp  
;combine  
ld  
temp,ph2  
;get ph2 bits  
;mask for ph2.2  
;move  
and temp,#0004h  
shl temp,#7h  
or  
temp1,temp  
;combine  
ld  
temp,ph1  
;get ph1 bits  
;mask for ph1.2  
;move  
and temp,#0004h  
shl temp,#6h  
or  
temp1,temp  
;combine  
ld  
temp,p7  
;get p7 bit  
and temp,#0001h  
shl temp,#7  
;mask  
;move to correct location  
9-23  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
or  
ld  
temp1,temp  
temp,p6  
;combine  
;get p6 bit  
;mask  
;move to correct location  
;combine  
and temp,#0001h  
shl temp,#6  
or  
temp1,temp  
ld  
temp,ph3  
;get ph3 bits again  
;mask for ph3.0 & 1  
;move  
and temp,#0003h  
shl temp,#4h  
or  
temp1,temp  
;combine1  
ld  
temp,ph2  
;get ph2 bits again  
;mask for ph2.0 & 1  
;move  
and temp,#0003h  
shl temp,#2h  
or  
temp1,temp  
;combine  
ld  
temp,ph1  
;get ph1 bits again  
and temp,#0003h  
;mask for ph3.0 & 1  
;combine, don't need to move  
or  
temp1,temp  
st  
temp1,WG_OUTPUT[0] ;now store it  
ret  
;
;****************************************  
; form WG_CONTROL value  
;****************************************  
;
wgcon:  
ld  
temp,mode  
;get mode  
;mask  
;shift to correct location  
and temp,#0003h  
shl temp,#12  
ld  
temp1,ec  
;start/stop bit  
;mask  
;shift to correct location  
;combine into temp  
and temp1,#0001h  
shl temp1,#10  
or  
temp,temp1  
ld  
temp1,dead  
;get dead time  
and temp1,#03ffh  
;mask to 10 bits  
;combine into temp  
or  
temp,temp1  
st  
temp,WG_CONTROL[0] ;store WG_CONTROL  
ret  
;
;*****************************************  
;load the WG_RELOAD and WG_COMPx registers  
;*****************************************  
;
loadregs: st  
reload,WG_RELOAD[0]  
comp1,WG_COMP1[0]  
comp2,WG_COMP2[0]  
comp3,WG_COMP3[0]  
st  
st  
st  
ret  
;
;*************************  
;load WG_PROTECT options  
;*************************  
;
protect:ldtemp,es  
;get sample control bit  
9-24  
Download from Www.Somanuals.com. All Manuals Search And Download.  
WAVEFORM GENERATOR  
and temp,#0001h  
shl temp,#3  
;mask  
;shift to correct location  
ld  
temp1,it  
;interrupt type bit  
;mask  
;shift to correct location  
;combine into temp  
and temp1,#0001h  
shl temp1,#2  
or  
temp,temp1  
ld  
temp1,dp  
;disable protection bit  
;mask  
;shift to correct location  
;combine into temp  
and temp1,#0001h  
shl temp1,#1  
or  
temp,temp1  
ld  
temp1,eo  
;enable output bit  
;mask  
;combine into temp  
and temp1,#0001h  
or temp,temp1  
stb temp,WG_PROTECT[0];store byte into WG_PROTECT  
ret  
;
;*******************************************  
;interrupt routine for WFG  
;*******************************************  
;
cseg at 0f1a0h  
;demo board PI interrupt  
pusha  
call wgout  
call loadregs  
call protect  
call wgcon  
popa  
;update WG_OUTPUT register  
;update reload & compare regs  
;update protection options  
;update WG_CONTROL  
ret  
end  
9-25  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
10  
Pulse-width  
Modulator  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
CHAPTER 10  
PULSE-WIDTH MODULATOR  
The pulse-width modulator (PWM) module has two output pins, each of which can output a  
PWM signal with a fixed, programmable 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.”  
10.1 PWM FUNCTIONAL OVERVIEW  
The PWM module has two channels, each of which consists of a control register  
(PWMx_CONTROL), a buffer, a comparator, an RS flip-flop, and an output pin. Two other com-  
ponents, an eight-bit counter (PWM_COUNT) and a period register (PWM_PERIOD), are  
shared across the PWM module’s two channels, completing the circuitry (see Figure 10-1).  
10-1  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
8
PWMx_CONTROL  
Load  
Buffer  
8
Bufferx  
8
=
Comparatorx  
8
RS Flip-flopx  
Port 6  
Control  
R
WG_OUT  
Q
Internal  
Clock  
Signal  
Down Counter  
PWM_COUNT  
PWMx  
Output  
P6.x/PWMx  
S
Count  
= 00H  
8
8
PWM_PERIOD  
Load  
Shared Circuitry  
A2761-02  
Figure 10-1. PWM Block Diagram  
10.2 PWM SIGNALS AND REGISTERS  
Table 10-1 describes the PWM’s signals and Table 10-2 briefly describes the control and status  
registers.  
Table 10-1. PWM Signals  
PWM  
Signal  
PWM  
Signal Type  
Port Pin  
Description  
P6.6  
P6.7  
PWM0  
PWM1  
O
O
Pulse-width modulator 0 output with high-drive capability.  
Pulse-width modulator 1 output with high-drive capability.  
10-2  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PULSE-WIDTH MODULATOR  
Table 10-2. PWM Control and Status Registers  
Address Description  
Mnemonic  
PWM0_CONTROL 1FB0H  
PWM1_CONTROL 1FB2H  
PWM Duty Cycle  
This register controls the PWM duty cycle. A zero loaded  
into this register will cause the PWM to output a low  
continuously (0% duty cycle). An FFH in this register will  
cause the PWM to have its maximum duty cycle (99.6%  
duty cycle).  
PWM_PERIOD  
1FB4H  
PWM Period  
This register holds a programmed value that determines  
the output period of the PWM outputs. The value is  
reloaded into the counter each time the count resets to  
FFH.  
PWM_COUNT  
WG_OUTPUT  
1FB6H  
1FC0H  
PWM Counter  
This read-only register contains the current value of the  
decremented counter.  
Waveform Generator Output  
Bits 11 and 12 (PE6 and PE7) determine whether the  
corresponding pin functions as a standard I/O port pin or  
as a PWM output. Bits 6 and 7 (P6 and P7) define the pin  
output when the port pin function is selected.  
PEx Px  
Pin Output  
0
0
1
0
1
X
0
1
PWM Output  
10.3 PWM OPERATION  
The period register (PWM_PERIOD) controls the output frequency of both PWM outputs. Each  
control register (PWMx_CONTROL) controls the duty cycle (the pulsewidth stated as a percent-  
age of the period) of the corresponding PWM output. Each control register contains an 8-bit value  
that is loaded into a buffer when the 8-bit counter rolls over from 00H to FFH. 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.  
10-3  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
The counter counts down to 00H, at which time the PWM output is driven high, the counter value  
is reloaded from the PWM_PERIOD register, 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. You can read the count register (PWM_COUNT)  
to see the current value of the counter. When the counter resets again (i.e., when an overflow oc-  
curs) the output is switched high. (Loading PWMx_CONTROL with 00H forces the output to re-  
main low.) Figure 10-2 shows typical PWM output waveforms.  
NOTE  
The PWMx_CONTROL register value and corresponding duty cycle result, in  
Figure 10-2, are true only when the PWM_PERIOD register value is FFH.  
Duty  
PWM Control  
Output Waveform  
Cycle Register Value  
0%  
10%  
50%  
90%  
99.6%  
00H  
19H  
80H  
E6H  
FFH  
0
0
0
0
0
A0119-02  
Figure 10-2. PWM Output Waveforms  
10.4 PROGRAMMING THE FREQUENCY AND PERIOD  
The input frequency on XTAL1 (FXTAL1) and the contents of the PWM_PERIOD register deter-  
mine the PWM output frequency (FPWM) and period (TPWM). Table 10-3 shows the PWM output  
frequencies for common values of FXTAL1 with a variety of PWM_PERIOD values. Use the fol-  
lowing formulas to calculate the PWM period value for the desired output frequency and write  
the corresponding value to the PWM_PERIOD register.  
512 × (PWM_PERIOD + 1)  
---------------------------------------------------------------------------  
TPWM (in µs)  
=
FXTAL1  
F XTAL1  
---------------------------------------------------------------------------  
FPWM (in MHz) =  
512 × (PWM_PERIOD + 1)  
10-4  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PULSE-WIDTH MODULATOR  
where:  
PWM_PERIOD  
=
=
=
=
8-bit value to load into the PWM_PERIOD register  
input frequency on XTAL1 pin, in MHz  
FXTAL  
1
TPWM  
FPWM  
output period on the PWM output pins, in µs  
output frequency on the PWM output pins, in MHz  
Table 10-3. PWM Output Frequencies (FPWM  
)
XTAL1 Frequency (FXTAL  
)
1
PWM_PERIOD  
8 MHz  
10 MHz  
16 MHz  
00H  
0FH  
1FH  
2FH  
3FH  
4FH  
5FH  
6FH  
7FH  
8FH  
9FH  
AFH  
BFH  
CFH  
DFH  
EFH  
FFH  
15.6 kHz  
976.6 Hz  
488.3 Hz  
325.5 Hz  
244.1 Hz  
195.3 Hz  
162.8 Hz  
139.5 Hz  
122.1 Hz  
108.5 Hz  
97.7 Hz  
88.8 Hz  
81.4 Hz  
75.1 Hz  
69.7 Hz  
65.1 Hz  
61.0 Hz  
19.5 kHz  
1220.7 Hz  
610.3 Hz  
406.9 Hz  
395.2 Hz  
244.1 Hz  
203.4 Hz  
174.4 Hz  
152.6 Hz  
135.6 Hz  
122.1 Hz  
111.0 Hz  
101.7 Hz  
93.9 Hz  
31.2 kHz  
1953.1 Hz  
976.6 Hz  
651.0 Hz  
488.3 Hz  
390.6 Hz  
325.5 Hz  
279.0 Hz  
244.1 Hz  
217.0 Hz  
195.3 Hz  
177.6 Hz  
162.8 Hz  
150.2 Hz  
139.5 Hz  
130.2 Hz  
122.0 Hz  
87.2 Hz  
81.4 Hz  
76.0 Hz  
10-5  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
PWM_PERIOD  
Address:  
Reset State:  
1FB4H  
00H  
The PWM period (PWM_PERIOD) register controls the period of the PWM outputs. It contains a value  
that determines the number of state counts necessary for incrementing the PWM counter. The value  
of PWM_PERIOD is loaded into the PWM period count register whenever the count equals zero.  
7
0
PWM Period  
Bit  
Number  
Function  
7:0  
PWM Period  
This register controls the period of the PWM outputs. The value of PWM_PERIOD is  
loaded into the PWM period count register whenever the count equals zero.  
Figure 10-3. PWM Period (PWM_PERIOD) Register  
10.5 PROGRAMMING THE DUTY CYCLE  
The values written to the PWMx_CONTROL and PWM_PERIOD registers control the width of  
the high pulse, effectively controlling the duty cycle. The 8-bit value written to the control regis-  
ter is loaded into a buffer, and this value is used during the next period. Use the following duty  
cycle formula to calculate a desired duty cycle for given values of PWMx_CONTROL and  
PWM_PERIOD, and then write these values to the appropriate registers.  
PWMx_CONTROL  
------------------------------------------------------  
Duty Cycle (in %)  
=
=
× 100  
PWM_PERIOD + 1  
Duty Cycle × TPWM  
-----------------------------------------------  
Pulsewidth (in µs)  
100  
where:  
PWMx_CONTROL  
PWM_PERIOD  
Pulsewidth  
=
=
=
=
8-bit value to load into the PWMx_CONTROL register  
8-bit value to load into the PWM_PERIOD register  
width of each high pulse  
TPWM  
output period on the PWM pin, in µs  
10-6  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PULSE-WIDTH MODULATOR  
Address:  
Reset State:  
Table 10-2 on page  
PWMx_CONTROL  
x = 0–1  
10-3  
00H  
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  
Bit  
Number  
Function  
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).  
Figure 10-4. PWM Control (PWMx_CONTROL) Register  
10.5.1 Sample Calculations  
For example, assume that FXTAL1 equals 16 MHz and the value written to the PWM_PERIOD reg-  
ister is FFH, thus the desired period of the PWM output waveform is 8.19 ms. If  
PWMx_CONTROL equals 8AH (138 decimal), the pulsewidth is held high for 4.42 ms (and low  
for 3.77 ms) of the total 8.19 ms period, resulting in a duty cycle of approximately 54%.  
10.5.2 Reading the Current Value of the Down-counter  
You can read the PWM_COUNT register to find the current value of the down-counter (see Fig-  
ure 10-5).  
10-7  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Address:  
Reset State:  
1FB6H  
00H  
PWM_COUNT  
(read only)  
The PWM count (PWM_COUNT) register provides the current value of the decremented period  
counter.  
7
0
PWM Count Value  
Bit  
Number  
Function  
7:0  
PWM Count Value  
This register contains the current value of the decremented period counter.  
Figure 10-5. PWM Count (PWM_COUNT) Register  
10.5.3 Enabling the PWM Outputs  
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 determine whether the corresponding pin func-  
tions as a standard I/O port pin or as a PWM output you must make the proper selections by writ-  
ing to the WG_OUTPUT register (see Figure 10-6). Table 10-4 shows the alternate port function  
along with the register setting that selects the PWM output instead of the port function.  
Table 10-4. PWM Output Alternate Functions  
PWM Output  
Alternate Port Function  
PWM Output Enabled When  
PWM0  
PWM1  
P6.6  
P6.7  
WG_OUT.11 = 1  
WG_OUT.12 = 1  
10-8  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PULSE-WIDTH MODULATOR  
Address:  
Reset State:  
1FC0H  
0000H  
WG_OUTPUT (Waveform Generator)  
The waveform generator output configuration (WG_OUTPUT) register controls the configuration of  
the waveform generator and PWM module pins. Both the waveform generator and the PWM module  
share pins with port 6. Having these control bits in a single register enables you to configure all port 6  
pins with a single write to WG_OUTPUT.  
15  
8
OP1  
P7  
OP0  
P6  
SYNC  
PH3.1  
PE7  
PE6  
PH3.2  
PH2.0  
PH2.2  
PH1.1  
PH1.2  
PH1.0  
7
0
PH3.0  
PH2.1  
Bit  
Number  
Bit  
Mnemonic  
Function  
15  
OP1  
Output Polarity  
Output Polarity  
Synchronize  
14  
13  
12  
OP0  
SYNC  
PE7  
P6.7/PWM1 Function  
Selects either the port function or the PWM output function of  
P6.7/PWM1.  
1 = PWM1  
0 = P6.7  
11  
PE6  
P6.6/PWM0 Function  
Selects either the port function or the PWM output function of  
P6.6/PWM0.  
1 = PWM0  
0 = P6.6  
10  
9
PH3.2  
PH2.2  
PH1.2  
P7  
Phase 3 Function  
Phase 2 Function  
Phase 1 Function  
8
7
P6.7/PWM1 Value  
Write the desired P6.7/PWM1 value to this bit.  
6
P6  
P6.6/PWM0 Value  
Write the desired P6.6/PWM0 value to this bit.  
5:4  
3:2  
1:0  
PH3.1:0  
PH2.1:0  
PH1.1:0  
P6.4/WG3# P6.5/WG3 Value  
P6.2/WG2#, P6.3/WG2 Values  
P6.0/WG1#, P6.1/WG1 Values  
Figure 10-6. Waveform Generator Output Configuration (WG_OUTPUT) Register  
10-9  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
10.5.4 Generating Analog Outputs  
PWM modules can generate a rectangular pulse train that varies in duty cycle and period. Filter-  
ing 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 10-7 is a block diagram of the type of circuit needed to create the smooth analog signal.  
®
MCS 96  
Buffer  
to Make  
Output Swing  
Rail  
Filter  
(Passive  
or  
Power  
Amp  
Microcontroller  
Analog  
Output  
PWM  
Active)  
(Optional)  
to  
Rail  
(Optional)  
A2391-01  
Figure 10-7. D/A Buffer Block Diagram  
Figure 10-8 shows a sample circuit used for low output currents (less than 100 µA). Consider  
temperature 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.  
PWM  
-
R
Analog  
Output  
+
®
MCS 96  
Op Amp  
74ACxxx  
Buffer  
C
Microcontroller  
Consider both ripple and response time requirements when selecting R and C.  
A2390-02  
Figure 10-8. PWM to Analog Conversion Circuitry  
10-10  
Download from Www.Somanuals.com. All Manuals Search And Download.  
11  
Event Processor  
Array (EPA)  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
CHAPTER 11  
EVENT PROCESSOR ARRAY (EPA)  
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.  
11.1 EPA FUNCTIONAL OVERVIEW  
The EPA performs input and output functions associated with two timer/counters, timer 1 and  
timer 2 (Figure 11-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 timer/counter value matches the stored value, the EPA can trigger an event:  
a timer reset, an A/D conversion, a waveform generator reload, 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. Table 11-1 lists the capture/compare and compare-only channels for each de-  
vice in the 8XC196Mx family.  
Table 11-1. EPA Channels  
Device  
Capture/Compare Channels  
Compare-only Channels  
8XC196MC  
8XC196MD  
8XC196MH  
EPA3:0  
EPA5:0  
EPA1:0  
COMP3:0  
COMP5:0  
COMP3:0  
11-1  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Timer-counter Unit  
TIMER1  
TIMER2  
Capture/Compare  
EPA0 Interrupt  
Channel 0  
EPA0  
EPAx  
.
.
.
Capture/Compare  
Channel x  
EPAx Interrupt  
COMP0 Interrupt  
Compare-only  
Channel 0  
COMP0  
COMPy  
.
.
.
COMPy Interrupt  
Compare-only  
Channel y  
Notes:  
For the 8XC196MC, x & y = 3.  
For the 8XC196MD, x & y = 5.  
For the 8XC196MH, x = 1 & y = 3.  
A2846-01  
Figure 11-1. EPA Block Diagram  
11.2 EPA AND TIMER/COUNTER SIGNALS AND REGISTERS  
Table 11-2 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 11-3 briefly describes the registers for  
the EPA capture/compare channels, EPA compare-only channels, and timer/counters.  
Table 11-2. EPA and Timer/Counter Signals  
Port Pin  
EPA  
Signal  
Type  
EPA  
Signals  
Description  
8XC196MC 8XC196MD 8XC196MH  
P1.2  
P1.3  
P1.2  
P1.3  
P0.6  
P0.7  
T1CLK  
T1DIR  
I
I
External clock source for timer 1.  
External direction control for timer 1.  
P2.0  
P2.1  
P2.2  
P2.3  
P2.0  
P2.1  
P2.2  
P2.3  
P7.0  
P7.1  
P2.0  
P2.2  
EPA0  
EPA1  
EPA2  
EPA3  
EPA4  
EPA5  
I/O  
High-speed input/output for the  
capture/compare channels.  
11-2  
Download from Www.Somanuals.com. All Manuals Search And Download.  
EVENT PROCESSOR ARRAY (EPA)  
Table 11-2. EPA and Timer/Counter Signals (Continued)  
Port Pin  
EPA  
Signal  
Type  
EPA  
Signals  
Description  
8XC196MC 8XC196MD 8XC196MH  
P2.4  
P2.5  
P2.6  
P2.7  
P2.4  
P2.5  
P2.6  
P2.7  
P7.2  
P7.3  
P2.4  
P2.5  
P2.6  
P2.3  
COMP0  
COMP1  
COMP2  
COMP3  
COMP4  
COMP5  
O
Output of the compare-only channels.  
Table 11-3. EPA Control and Status Registers  
Address  
Mnemonic  
Description  
MC  
MD  
MH  
COMP0_CON  
COMP1_CON  
COMP2_CON  
COMP3_CON  
COMP4_CON  
COMP5_CON  
1F58H  
1F5CH  
1F60H  
1F64H  
1F58H  
1F5CH  
1F60H  
1F64H  
1F68H  
1F6CH  
1F58H  
1F5CH  
1F60H  
1F4CH  
EPAx Compare Control  
These registers control the functions of the  
compare-only channels.  
COMP0_TIME  
COMP1_TIME  
COMP2_TIME  
COMP3_TIME  
COMP4_TIME  
COMP5_TIME  
1F5AH  
1F5EH  
1F62H  
1F66H  
1F5AH  
1F5EH  
1F62H  
1F66H  
1F6AH  
1F6EH  
1F5AH EPAx Compare Time  
1F5EH  
These registers contain the time at which an event  
1F62H  
1F4EH  
is to occur on the compare-only channels.  
EPA0_CON  
EPA1_CON  
EPA2_CON  
EPA3_CON  
EPA4_CON  
EPA5_CON  
1F40H  
1F44H  
1F48H  
1F4CH  
1F40H  
1F44H  
1F48H  
1F4CH  
1F50H  
1F54H  
1F40H  
1F44H  
EPAx Capture/Compare Control  
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.  
EPA0_TIME  
EPA1_TIME  
EPA2_TIME  
EPA3_TIME  
EPA4_TIME  
EPA5_TIME  
1F42H  
1F46H  
1F4AH  
1F4EH  
1F42H  
1F46H  
1F4AH  
1F4EH  
1F52H  
1F56H  
1F42H  
1F46H  
EPAx Capture/Compare Time  
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  
0013H  
0008H  
0013H  
0008H  
0013H  
Interrupt Mask  
The bits in this 8-bit register enable and disable  
(mask) the interrupts associated with the corre-  
sponding bits in the INT_PEND register.  
INT_MASK1  
Interrupt Mask 1  
The bits in this 8-bit register enable and disable  
(mask) the interrupts associated with the corre-  
sponding bits in the INT_PEND1 register.  
11-3  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 11-3. EPA Control and Status Registers (Continued)  
Address  
Mnemonic  
INT_PEND  
Description  
MC  
MD  
MH  
0009H  
0009H  
0009H  
Interrupt Pending  
Any set bit in this 8-bit register indicates a pending  
interrupt request.  
INT_PEND1  
0012H  
0012H  
0012H  
Interrupt Pending 1  
Any set bit in this 8-bit register indicates a pending  
interrupt request.  
P2_DIR  
P7_DIR  
1FD2H  
1FD2H  
1FD3H  
1FD2H 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.)  
P2_MODE  
P7_MODE  
1FD0H  
1FD0H  
1FD1H  
1FD0H Port x Mode  
Each bit of Px_MODE controls whether the corre-  
sponding 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.  
P0_PIN  
P1_PIN  
P2_PIN  
P7_PIN  
1FA8H  
1FA9H  
1FD6H  
1FA8H  
1FA9H  
1FD6H  
1FD7H  
1FDAH Port x Input  
1F9FH  
Each bit of Px_PIN reflects the current state of the  
1FD6H  
corresponding pin, regardless of the pin configu-  
ration.  
P2_REG  
P7_REG  
1FD4H  
1FD4H  
1FD5H  
1FD4H 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.  
11-4  
Download from Www.Somanuals.com. All Manuals Search And Download.  
EVENT PROCESSOR ARRAY (EPA)  
Table 11-3. EPA Control and Status Registers (Continued)  
Address  
Mnemonic  
PI_MASK  
Description  
MC  
MD  
MH  
1FBCH Peripheral Interrupt Mask  
The bits in this register enable and disable (mask)  
1FBCH  
1FBCH  
the timer 1 and 2 overflow/underflow interrupt  
requests, the waveform generator interrupt request  
(MC, MD), the EPA compare-only channel 5  
interrupt request ( MD), and the serial port error  
interrupts (MH).  
PI_PEND  
1FBEH  
1F78H  
1FBEH  
1F78H  
1FBEH Peripheral Interrupt Pending  
Any bit set indicates a pending interrupt request.  
Timer 1 Control  
T1CONTROL  
1F78H  
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.  
T1RELOAD  
1F72H  
1F7CH  
1F72H  
1F7CH  
1F72H  
Timer 1 Reload  
This register contains an initialization value for  
timer 1. A timer 1 overflow or underflows loads the  
T1RELOAD value into the TIMER1 register if both  
quadrature clocking and the reload function are  
enabled (T1CONTROL.5:0 = 1).  
T2CONTROL  
1F7CH 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  
TIMER2  
1F7AH  
1F7EH  
1F7AH  
1F7EH  
1F7AH Timer 1 Value  
This register contains the current value of timer 1.  
1F7EH Timer 2 Value  
This register contains the current value of timer 2.  
11.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 11-2 illustrates the timer/counter structure.  
11-5  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
T2CONTROL.2:0  
3
Timer 2  
Prescaler  
Module  
F
/4  
XTAL1  
Clock  
Overflow/  
Underflow  
Timer 1 Overflow/Underflow  
TIMER2  
Direction  
T2CONTROL.6  
OVRTM  
Interrupt  
T1CONTROL.2:0  
3
Timer 1  
F
/4  
XTAL1  
Prescaler  
Module  
Clock  
T1CLK  
Overflow/  
Underflow  
Quadrature Count  
T1RELOAD  
TIMER1  
Direction  
T1DIR  
T1CONTROL.6  
Quadrature Direction  
A3131-01  
Figure 11-2. EPA Timer/Counters  
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/underflow interrupt pending bit is set. This  
bit can optionally cause an interrupt. The clock source, direction-control source, count direction,  
and resolution of the input capture or output compare are all programmable (see “Programming  
the Timers” on page 11-15). The maximum count rate is one-half the internal clock rate, or  
FXTAL1/4 (see “Internal Timing” on page 2-7). This provides a minimum resolution for an input  
capture or output compare of 250 ns (at 16 MHz).  
4 ×prescaler_divisor  
----------------------------------------------------------  
resolution  
11-6  
=
FXTAL1  
Download from Www.Somanuals.com. All Manuals Search And Download.  
EVENT PROCESSOR ARRAY (EPA)  
where:  
prescaler_divisor  
is the clock prescaler divisor from the TxCONTROL registers (see  
“Timer 1 Control (T1CONTROL) Register” on page 11-16 and  
“Timer 2 Control (T2CONTROL) Register” on page 11-17).  
FXTAL1  
is the input frequency on XTAL1.  
11.3.1 Cascade Mode (Timer 2 Only)  
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 11-13).  
11.3.2 Quadrature Clocking Modes  
Timer 1 can be used in two quadrature clocking modes. Both modes use the T1CLK and T1DIR  
pins as quadrature inputs, as shown in Figure 11-3. External quadrature-encoded signals (two sig-  
nals at the same frequency that differ in phase by 90°) are input, and the timer increments or dec-  
rements by one count on each rising edge and each falling edge. Because the T1CLK and T1DIR  
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 pe-  
riod. The sequence of the signal edges and levels controls the count direction. Refer to Figure  
11-4 and Table 11-4 for sequencing information.  
A typical source of quadrature-encoded signals is a shaft-angle decoder, shown in Figure 11-3.  
Its output signals X and Y are input to T1CLK and T1DIR, which in turn output signals  
X_internal and Y_internal. These signals are used in Figure 11-4 and Table 11-4 to describe the  
direction of the shaft.  
In the default quadrature clocking mode, software must reload the TIMER1 register when timer  
1 overflows or underflows. In mode 2 (T1CONTROL.2:0 = 1), timer 1 automatically loads the  
value from the T1RELOAD register into the TIMER1 register when an overflow or underflow  
occurs. Mode 2 is useful for interfacing to an incremental shaft encoder that turns in only one di-  
rection. For this application, initialize T1RELOAD with a value that is one less than the encoder’s  
resolution. This method allows timer 1 to track the absolute position of the shaft encoder with no  
software overhead.  
11-7  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Increment  
MCS® 96 Microcontroller  
Decrement  
PH2  
PH1  
X
Y
T1CLK  
T1DIR  
D Q  
D Q  
D Q  
D Q  
D Q  
D Q  
X_internal  
Y_internal  
Optical  
Reader  
A1550-01  
Figure 11-3. Quadrature Mode Interface  
Table 11-4. Quadrature Mode Truth Table  
State of X_internal  
State of Y_internal  
(T1DIR)  
Count Direction  
(T1CLK)  
0
1
0
1
0
1
0
1
Increment  
Increment  
Increment  
Increment  
Decrement  
Decrement  
Decrement  
Decrement  
11-8  
Download from Www.Somanuals.com. All Manuals Search And Download.  
EVENT PROCESSOR ARRAY (EPA)  
CLKOUT†  
PH2  
T1CLK  
T1DIR  
COUNT  
x
x + 1  
x + 2  
x + 3  
x + 4  
x + 5  
x + 6  
x + 5  
x + 4  
x + 3  
x + 2  
x + 1  
CLKOUT is available on the 8XC196MC and 8XC196MD only.  
A1549-01  
Figure 11-4. Quadrature Mode Timing and Count  
11.4 EPA CHANNEL FUNCTIONAL OVERVIEW  
The EPA has both programmable capture/compare and compare-only channels. Each cap-  
ture/compare channel can perform the following tasks. (The compare-only channels have the  
same functionality except that they cannot capture an external event.)  
capture the current timer value when a specified transition occurs on the EPA pin  
start an A/D conversion or reload the waveform generator when an event is captured or the  
timer value matches the programmed value in the event-time register  
clear, set, or toggle the EPA pin when the timer value matches the programmed value in the  
event-time register  
generate an interrupt when a capture or compare event occurs  
reset its own base timer in compare mode  
reset the opposite timer in both compare and capture mode  
11-9  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Each EPA channel has a control register, EPAx_CON (capture/compare channels) or  
COMPx_CON (compare-only channels); an event-time register, EPAx_TIME (capture/compare  
channels) or COMPx_TIME (compare-only channels); and a timer input (Figure 11-5). The con-  
trol 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 compare mode. See “Programming the Capture/Compare Channels” on page 11-18 and “Pro-  
gramming the Compare-only Channels” on page 11-22 for configuration information.  
Timer/Counter Unit  
External clocking (T1CLK) with up to 6-bit prescaler  
TIMER1  
TIMER2  
Internal clocking  
with up to 6-bit prescaler  
Quadrature clocking through T1CLK and T1DIR  
Clock on TIMER1 overflow  
EPA Capture/Compare  
Channel x  
Capture  
Buffer  
EPA Pin  
EPAx_TIME  
Compare  
TGL  
Reset Timer  
Reload Waveform  
EPA  
Interrupt  
Generator  
Overwrite  
Mode Control  
EPAx_CON  
††  
Start A/D  
Mode Selection  
††  
EPA0, EPA2, and EPA4.  
EPA1, EPA3, and EPA5  
A0807-01  
Figure 11-5. A Single EPA Capture/Compare Channel  
11.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 11-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.  
11-10  
Download from Www.Somanuals.com. All Manuals Search And Download.  
EVENT PROCESSOR ARRAY (EPA)  
TIMERx  
Event Occurs  
at EPA Pin  
Capture Buffer  
EPA  
Interrupt  
Pending Bit  
Set  
EPAx_TIME  
Read-out Time Value  
A2458-02  
Figure 11-6. EPA Simplified Input-capture Structure  
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. Table 11-5 summarizes the possible actions when a valid event occurs.  
NOTE  
In order for an event to be captured, the signal must be stable for at least two  
state times both before and after the transition occurs (Figure 11-7).  
Event 1  
2 State  
Times  
2 State  
Times  
Event 2  
2 State  
Times  
2 State  
Times  
A3130-01  
Figure 11-7. Valid EPA Input Events  
11-11  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 11-5. Action Taken When a Valid Edge Occurs  
Status of  
Capture Buffer  
& EPAx_TIME  
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
1
full  
New data is ignored — no capture, EPA interrupt, or transfer occurs.  
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.  
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).  
11.4.1.1  
EPA Overruns  
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.  
an input signal with a frequency high enough to cause overruns is present on an enabled  
EPA pin, and  
the overwrite bit is set (EPAx_CON.0 = 1; old data is overwritten on overrun), and  
the EPAx_TIME register is read at the exact instant that the EPA recognizes the captured  
edge as valid.  
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.  
11-12  
Download from Www.Somanuals.com. All Manuals Search And Download.  
EVENT PROCESSOR ARRAY (EPA)  
11.4.1.2  
Preventing EPA Overruns  
Any one of the following methods can be used to prevent or recover from an EPA overrun situa-  
tion.  
Clear EPAx_CON.0  
When the overwrite bit (EPAx_CON.0) is zero, the EPA does not consider the captured  
edge until the EPAx_TIME register is read and the data in the capture buffer is transferred to  
EPAx_TIME. This prevents overruns by ignoring new input capture events when both the  
capture buffer and EPAx_TIME contain valid capture times.  
Check for pending EPAx interrupts before exiting an EPAx ISR  
Another method for avoiding this situation is to check for pending EPA interrupts before  
exiting the EPA interrupt service routine. This is an easy way to detect overruns and addi-  
tional interrupts. It can also save loop time by eliminating the latency necessary to service  
the pending interrupt. However, this method cannot be used with the peripheral transaction  
server (PTS).  
11.4.2 Operating in Compare Mode  
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, an A/D conversion is initiated, or the wave-  
form generator is reloaded). If the re-enable bit (EPAx_CON.3) is set, the action reoccurs on ev-  
ery timer match. If the re-enable bit is cleared, the action does not reoccur until a new value is  
written to the event-time register. See “Programming the Capture/Compare Channels” on page  
11-18 and “Programming the Compare-only Channels” on page 11-22 for configuration informa-  
tion.  
In compare mode, you can use the EPA to produce a pulse-width modulated (PWM) output. The  
following sections describe two possible methods.  
11.4.2.1  
Generating a Low-speed PWM Output  
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.  
11-13  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
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-x interrupt is generated  
EPA0-x_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 5-10).  
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 the EPA interrupts is 79 state times for external  
stack usage or 71 state times for internal stack usage. Therefore, a single capture/compare channel  
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 period  
equals 250 state times. When the input frequency on XTAL1 is 16 MHz, the PWM period is 31.25  
µs and the maximum PWM frequency is 32 kHz.  
11.4.2.2  
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.  
11-14  
Download from Www.Somanuals.com. All Manuals Search And Download.  
EVENT PROCESSOR ARRAY (EPA)  
With this method, the resolution of the EPA (selected by the TxCONTROL registers; see Figure  
11-8 on page 11-16 and Figure 11-9 on page 11-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 16 MHz, a 250 ns resolution results in a maximum PWM  
of 4 MHz.  
11.5 PROGRAMMING THE EPA AND TIMER/COUNTERS  
This section discusses configuring the port pins for the EPA and the timer/counters; describes  
how to program the timers, the capture/compare channels, and the compare-only channels; and  
explains how to enable the EPA interrupts.  
11.5.1 Configuring the EPA and Timer/Counter Signals  
Before you can use the EPA, you must configure the appropriate port signals to serve as the spe-  
cial-function signals for the EPA and, optionally, for the timer/counter clock source and direction  
control signals. See “Bidirectional Ports 1 (MH Only), 2, 5, and 7 (MD Only)” on page 6-4 for  
information about configuring the ports.  
Table 11-2 on page 11-2 lists the signals associated with the EPA and the timer/counters. Signals  
that are not being used for an EPA channel or timer/counter can be configured as standard I/O.  
11.5.2 Programming the Timers  
The control registers for the timers are T1CONTROL (Figure 11-8) and T2CONTROL (Figure  
11-9). Write to these registers to configure the timers. Write to the TIMER1 and TIMER2 regis-  
ters (see Table 11-3 on page 11-3 for addresses) to load a specific timer value.  
11-15  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
T1CONTROL  
Address:  
Reset State:  
1F78H  
00H  
The timer 1 control (T1CONTROL) register determines the clock source, counting direction, and count  
rate for timer 1.  
7
0
CE  
UD  
M2  
M1  
M0  
P2  
P1  
P0  
Bit  
Number  
Bit  
Mnemonic  
Function  
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  
6
UD  
Up/Down  
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
X
0
0
1
0
0
1
1
1
0
1
0
1
1
F
XTAL1/4  
T1CLK pin†  
XTAL1/4  
T1CLK pin†  
UD bit (T1CONTROL.6)  
UD bit (T1CONTROL.6)  
T1DIR pin  
F
T1DIR pin  
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
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
divide by 1 (disabled)  
divide by 2  
divide by 4  
divide by 8  
divide by 16  
divide by 32  
divide by 64  
enable T1RELOAD  
250 ns  
500 ns  
1 µs  
2 µs  
4 µs  
8 µs  
16 µs  
At 16 MHz. Use the formula on page 11-6 to calculate the resolution  
at other frequencies.  
Figure 11-8. Timer 1 Control (T1CONTROL) Register  
11-16  
Download from Www.Somanuals.com. All Manuals Search And Download.  
EVENT PROCESSOR ARRAY (EPA)  
Address:  
Reset State:  
1F7CH  
00H  
T2CONTROL  
The timer 2 control (T2CONTROL) register determines the clock source, counting direction, and count  
rate for timer 2.  
7
0
CE  
UD  
M2  
M1  
M0  
P2  
P1  
P0  
Bit  
Number  
Bit  
Mnemonic  
Function  
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  
6
UD  
Up/Down  
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  
XTAL1/4  
reserved  
reserved  
reserved  
timer 1 overflow  
timer 1 overflow  
reserved  
Direction Source  
0
X
0
0
1
1
1
0
0
1
1
0
1
1
0
1
0
1
0
0
1
F
UD bit (T2CONTROL.6)  
UD bit (T2CONTROL.6)  
same as timer 1  
2:0  
P2:0  
EPA Clock Prescaler Bits  
These bits determine the clock prescaler value.  
P2  
P1  
P0  
Prescaler  
Resolution†  
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
divide by 1 (disabled)  
divide by 2  
divide by 4  
250 ns  
500 ns  
1 µs  
2 µs  
4 µs  
8 µs  
16 µs  
divide by 8  
divide by 16  
divide by 32  
divide by 64  
reserved  
Resolution at 16 MHz. Use the formula on page 11-6 to calculate the  
resolution at other frequencies.  
Figure 11-9. Timer 2 Control (T2CONTROL) Register  
11-17  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
11.5.3 Programming the Capture/Compare Channels  
The EPAx_CON register controls the function of its assigned capture/compare channel. The reg-  
isters are identical with the exception of bit 2. For EPA channels 0, 2, and 4, setting this bit enables  
an EPA event to cause a waveform generator reload. For EPA channels 1, 3, and 5, setting this bit  
enables an EPA event to cause an A/D conversion. To program a compare event, always write to  
EPAx_CON (Figure 11-10) first to configure the EPA capture/compare channel, and then load the  
event time into EPAx_TIME. To program a capture event, you need only write to EPAx_CON.  
Table 11-6 shows the effects of various combinations of EPAx_CON bit settings for channels 1,  
3, or 5.  
Table 11-6. Example EPA Control Register Settings for Channels 1, 3, or 5  
Capture Mode  
WGR  
TB  
CE  
MODE  
RE  
ROT  
ON/RT  
/AD  
Operation  
7
X
X
X
X
X
X
X
6
0
0
0
0
0
0
0
5
0
0
1
1
X
1
0
4
0
1
0
1
1
X
1
3
2
1
X
X
X
1
0
0
None  
X
X
X
X
X
X
X
Capture on falling edges  
X
Capture on rising edges  
X
Capture on both edges  
X
Capture on falling edge and reset opposite timer  
Capture on rising edge and reset opposite timer  
X
1
1
X
Start A/D conversion (EPA1, 3, 5) or reload  
waveform generator (EPA0, 2, 4) on falling edge  
X
0
1
0
1
X
X
Start A/D conversion (EPA1, 3, 5) or reload  
waveform generator (EPA0, 2, 4) on rising edge  
Compare Mode  
WGR  
/AD  
TB  
CE  
MODE  
RE  
ROT  
ON/RT  
0
Operation  
7
X
X
X
X
X
X
X
X
6
1
1
1
1
1
1
1
1
5
0
0
0
1
1
X
X
X
4
0
0
1
0
1
X
X
X
3
X
X
X
X
X
X
X
X
2
0
1
X
X
X
X
0
0
0
None  
Generate interrupt only (software timer)  
Clear output pin  
X
X
X
X
X
1
X
X
X
1
Set output pin  
Toggle output pin  
Reset reference timer  
Reset opposite timer  
1
1
X
X
Start A/D conversion (EPA1, 3, 5) or reload  
waveform generator (EPA0, 2, 4)  
NOTES:  
1. — = bit is not used  
2. X = bit may be used, but has no effect on the described operation. These bits cause other operations  
to occur.  
11-18  
Download from Www.Somanuals.com. All Manuals Search And Download.  
EVENT PROCESSOR ARRAY (EPA)  
Address:  
Reset State:  
See Table 11-3 on page 11-3  
00H  
EPAx_CON  
x = 0–1 (8XC196MH)  
x = 0–3 (8XC196MC)  
x = 0–5 (8XC196MD)  
The EPA control (EPAx_CON) registers control the functions of their assigned capture/compare  
channels.  
7
0
x = 0, 2, 4  
x = 1, 3, 5  
TB  
TB  
CE  
CE  
M1  
M1  
M0  
M0  
RE  
WGR  
AD  
ROT  
ROT  
ON/RT  
7
0
RE  
ON/RT  
Bit  
Number  
Bit  
Mnemonic  
Function  
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 (reloading the waveform generator; starting an A/D  
conversion; 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  
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
1
1
0
1
0
1
no capture  
capture on falling edge  
capture on rising edge  
capture on either edge  
M1  
M0  
Compare Mode Action  
0
0
1
1
0
1
0
1
no output  
clear output pin  
set output pin  
toggle output pin  
Figure 11-10. EPA Control (EPAx_CON) Registers  
11-19  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Address:  
Reset State:  
See Table 11-3 on page 11-3  
00H  
EPAx_CON (Continued)  
x = 0–1 (8XC196MH)  
x = 0–3 (8XC196MC)  
x = 0–5 (8XC196MD)  
The EPA control (EPAx_CON) registers control the functions of their assigned capture/compare  
channels.  
7
0
x = 0, 2, 4  
x = 1, 3, 5  
TB  
TB  
CE  
CE  
M1  
M1  
M0  
M0  
RE  
WGR  
AD  
ROT  
ROT  
ON/RT  
7
0
RE  
ON/RT  
Bit  
Number  
Bit  
Mnemonic  
Function  
3
RE  
Re-enable  
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
WGR  
AD  
Waveform Generator Reload; A/D Conversion  
The function of this bit depends on the EPA channel.  
For EPA capture/compare channels 0, 2, 4:  
The WGR bit allows you to use the EPA activities to cause the reload  
of new values in the waveform generator.  
0 = no action  
1 = enables waveform generator reload  
For EPA capture/compare channels 1, 3, 5:  
The AD bit allows you to use the EPA activities to start an A/D  
conversion that has been previously set up in the A/D control  
registers.  
0 = causes no A/D action  
1 = starts an A/D conversion on an output compare  
Figure 11-10. EPA Control (EPAx_CON) Registers (Continued)  
11-20  
Download from Www.Somanuals.com. All Manuals Search And Download.  
EVENT PROCESSOR ARRAY (EPA)  
Address:  
Reset State:  
See Table 11-3 on page 11-3  
00H  
EPAx_CON (Continued)  
x = 0–1 (8XC196MH)  
x = 0–3 (8XC196MC)  
x = 0–5 (8XC196MD)  
The EPA control (EPAx_CON) registers control the functions of their assigned capture/compare  
channels.  
7
0
x = 0, 2, 4  
x = 1, 3, 5  
TB  
TB  
CE  
CE  
M1  
M1  
M0  
M0  
RE  
WGR  
AD  
ROT  
ROT  
ON/RT  
7
0
RE  
ON/RT  
Bit  
Number  
Bit  
Mnemonic  
Function  
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  
Figure 11-10. EPA Control (EPAx_CON) Registers (Continued)  
11-21  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
11.5.4 Programming the Compare-only Channels  
To program a compare event, you must first write to the COMPx_CON register (Figure 11-11) to  
configure the compare-only channel and then load the event time into COMPx_TIME.  
COMPx_CON has the same bits and settings as EPAx_CON. COMPx_TIME is functionally iden-  
tical to EPAx_TIME.  
See Table 11-3 on  
page 11-3  
00H  
COMPx_CON  
x = 0–3 (8XC196MC, MH)  
x = 0–5 (8XC196MD)  
Address:  
Reset State:  
The EPA compare control (COMPx_CON) registers determine the function of the EPA compare  
channels.  
7
0
0
x = 0, 2, 4  
TB  
TB  
CE  
CE  
M1  
M1  
M0  
M0  
RE  
RE  
WGR  
AD  
ROT  
ROT  
RT  
RT  
7
x = 1, 3, 5  
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 (start of an A/D conversion; 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.  
6
CE  
Compare Enable  
This bit enables the compare function.  
0 = compare function disabled  
1 = compare function enabled  
5:4  
M1:0  
EPA Mode Select  
Specifies the type of compare event.  
M1  
M0  
0
0
1
1
0
1
0
1
no output  
clear output pin  
set output pin  
toggle output pin  
3
RE  
Re-enable  
Allows a compare event to continue to execute each time the event-time  
register (COMPx_TIME) matches the reference timer rather than only  
upon the first time match.  
0 = compare function will drive the output only once  
1 = compare function always enabled  
Figure 11-11. EPA Compare Control (COMPx_CON) Registers  
11-22  
Download from Www.Somanuals.com. All Manuals Search And Download.  
EVENT PROCESSOR ARRAY (EPA)  
See Table 11-3 on  
page 11-3  
00H  
COMPx_CON (Continued)  
x = 0–3 (8XC196MC, MH)  
x = 0–5 (8XC196MD)  
Address:  
Reset State:  
The EPA compare control (COMPx_CON) registers determine the function of the EPA compare  
channels.  
7
0
0
x = 0, 2, 4  
TB  
TB  
CE  
CE  
M1  
M1  
M0  
M0  
RE  
RE  
WGR  
AD  
ROT  
ROT  
RT  
RT  
7
x = 1, 3, 5  
2
WGR  
AD  
A/D Conversion, Waveform Generator Reload  
The function of this bit depends on the EPA channel.  
For EPA capture/compare channels 0, 2, 4:  
The WGR bit allows you to use the EPA activities to cause the reload of  
new values in the waveform generator.  
0 = no action  
1 = enables waveform generator reload  
For EPA capture/compare channels 1, 3, 5:  
The AD bit allows you to use the EPA activities to start an A/D  
conversion that has been previously set up in the A/D control registers.  
0 = causes no A/D action  
1 = starts an A/D conversion on an output compare  
1
0
ROT  
Reset Opposite Timer  
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 state of the TB bit determines which timer is the reference timer and  
which timer is the opposite timer.  
RT  
Reset Timer  
This bit controls whether the timer selected by the ROT bit will be reset.  
1 = resets the timer selected by the ROT bit  
0 = disables the reset function  
Figure 11-11. EPA Compare Control (COMPx_CON) Registers (Continued)  
11.6 ENABLING THE EPA INTERRUPTS  
To enable the interrupts, set the corresponding bits in the INT_MASK register (Figure 5-7 on  
page 5-15). To enable the individual sources of the multiplexed PI (MC, MD), SPI (MH), and  
OVRTM (Mx) interrupts, set the corresponding bits in the PI_MASK register (Figure 5-9 on page  
5-17). Chapter 5, “Standard and PTS Interrupts,” discusses the interrupts in greater detail.  
11-23  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
11.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.  
The pending bits are located in the INT_PEND and INT_PEND1 registers (Figure 5-7 on page  
5-15 and Figure 5-11 on page 5-22). The pending bits for the multiplexed interrupts (those that  
share the PI interrupt) are located in the PI_PEND register (Figure 5-12 on page 5-23). Timer  
overflows/underflows also set interrupt pending bits. Even if an interrupt is masked, software can  
poll the interrupt pending registers to determine whether an event has occurred.  
11-24  
Download from Www.Somanuals.com. All Manuals Search And Download.  
12  
Analog-to-digital  
Converter  
Download from Www.Somanuals.com. All Manuals Search And Download.  
<PageNum>-38  
Download from Www.Somanuals.com. All Manuals Search And Download.  
CHAPTER 12  
ANALOG-TO-DIGITAL (A/D) CONVERTER  
The analog-to-digital (A/D) converter can convert an analog input voltage to a digital value and  
set the A/D interrupt pending bit when it stores the result. It can also monitor a pin and set the  
A/D interrupt pending bit when the input voltage crosses over or under a programmed threshold  
voltage. This chapter describes the A/D converter and explains how to program it.  
12.1 A/D CONVERTER FUNCTIONAL OVERVIEW  
The A/D converter (Figure 12-1) can convert an analog input voltage to an 8- or 10-bit digital  
result and set the A/D interrupt pending bit when it stores the result. It can also monitor an input  
and set the A/D interrupt pending bit when the input voltage crosses over or under the pro-  
grammed threshold voltage.  
Analog Inputs  
Analog Mux  
EPA or PTS  
Command  
VREF  
ANGND  
Control  
Logic  
Successive  
Sample  
and Hold  
Approximation  
A/D  
Converter  
Status  
AD_RESULT  
AD_COMMAND  
AD_TIME  
AD_TEST  
Multiplexed with port inputs  
A2652-02  
Figure 12-1. A/D Converter Block Diagram  
12-1  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
12.2 A/D CONVERTER SIGNALS AND REGISTERS  
Table 12-1 lists the A/D signals and Table 12-2 describes the control and status registers. Al-  
though the analog inputs are multiplexed with I/O port pins, no configuration is necessary.  
Table 12-1. A/D Converter Pins  
A/D Signal  
Port Pin  
A/D Signal  
Description  
Type  
P1.4:0  
P1.5:0  
ACH12:8 (MC)  
ACH13:8 (MD)  
I
Analog inputs. See the “Voltage on Analog Input Pin”  
specification in the datasheet.  
P0.7:0  
ACH7:0  
(MC, MD, MH)  
I
Analog inputs. See the “Voltage on Analog Input Pin”  
specification in the datasheet.  
ANGND  
VREF  
GND  
Reference Ground  
Must be connected for A/D converter and port operation.  
PWR  
Reference Voltage  
Must be connected for A/D converter and port operation.  
Table 12-2. A/D Control and Status Registers  
Address Description  
1FACH  
Mnemonic  
AD_COMMAND  
A/D Command  
This register selects the A/D channel, controls whether the A/D  
conversion starts immediately or is triggered by the EPA, and  
selects the operating mode.  
AD_RESULT  
1FAAH, 1FABH  
A/D Result  
For an A/D conversion, the high byte contains the eight MSBs from  
the conversion, while the low byte contains the two LSBs from a 10-  
bit conversion (undefined for an 8-bit conversion), indicates which  
A/D channel was used, and indicates whether the channel is idle.  
For a threshold-detection, calculate the value for the successive  
approximation register and write that value to the high byte of  
AD_RESULT. Clear the low byte or leave it in its default state.  
AD_TEST  
AD_TIME  
1FAEH  
1FAFH  
A/D Conversion Test  
This register specifies adjustments for zero-offset errors.  
A/D Conversion Time  
This register defines the sample window time and the conversion  
time for each bit.  
INT_MASK  
INT_PEND  
0008H  
0009H  
Interrupt Mask  
The AD bit in this register enables or disables the A/D interrupt. Set  
the AD bit to enable the interrupt request.  
Interrupt Pending  
The AD bit in this register, when set, indicates that an A/D interrupt  
request is pending.  
12-2  
Download from Www.Somanuals.com. All Manuals Search And Download.  
ANALOG-TO-DIGITAL (A/D) CONVERTER  
Table 12-2. A/D Control and Status Registers (Continued)  
Mnemonic  
P0_PIN  
Address  
Description  
1FA8H (MC, MD) Port 0 Pin State  
1FDAH (MH)  
Read P0_PIN to determine the current values of the port 0 pins.  
Reading the port induces noise into the A/D converter, decreasing  
the accuracy of any conversion in progress. We strongly  
recommend that you not read the port while an A/D conversion is in  
progress. To reduce noise, the P0_PIN register is clocked only  
when the port is read.  
P1_PIN (MC,MD) 1FA9H (MC, MD) Port 1 Pin State  
Read P1_PIN to determine the current values of the port 1 pins.  
Reading the port induces noise into the A/D converter, decreasing  
the accuracy of any conversion in progress. We strongly  
recommend that you not read the port while an A/D conversion is in  
progress. To reduce noise, the P1_PIN register is clocked only  
when the port is read.  
12.3 A/D CONVERTER OPERATION  
An A/D conversion converts an analog input voltage to a digital value, stores the result in the  
AD_RESULT register, and sets the A/D interrupt pending bit. An 8-bit conversion provides  
20 mV resolution, while a 10-bit conversion provides 5 mV resolution. An 8-bit conversion takes  
less time than a 10-bit conversion because it has two fewer bits to resolve and the comparator re-  
quires less settling time for 20 mV resolution than for 5 mV resolution.  
You can convert either the voltage on an analog input channel or a test voltage. Converting the  
test inputs allows you to calculate the zero-offset error, and the zero-offset adjustment allows you  
to compensate for it. This feature can reduce or eliminate off-chip compensation hardware. Typ-  
ically, you would convert the test voltages and adjust for the zero-offset error before performing  
conversions on an input channel. The AD_TEST register allows you to program a zero-offset ad-  
justment.  
A threshold-detection compares an input voltage to a programmed reference voltage and sets the  
A/D interrupt pending bit when the input voltage crosses over or under the reference voltage.  
A conversion can be started by a write to the AD_COMMAND register or it can be initiated by  
the EPA, which can provide equally spaced samples or synchronization with external events.  
(See“Programming the EPA and Timer/Counters” on page 11-15.) The A/D scan mode of the pe-  
ripheral transaction server (PTS) allows you to perform multiple conversions and store their re-  
sults. (See “A/D Scan Mode” on page 5-32.)  
12-3  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Once the A/D converter receives the command to start a conversion, a delay time elapses before  
sampling begins. (EPA-initiated conversions begin after the capture/compare event. Immediate  
conversions, those initiated directly by a write to AD_COMMAND, begin within three state  
times after the instruction is completed.) During this sample delay, the hardware clears the suc-  
cessive approximation register and selects the designated multiplexer channel. After the sample  
delay, the device connects the multiplexer output to the sample capacitor for the specified sample  
time. After this sample window closes, it disconnects the multiplexer output from the sample ca-  
pacitor so that changes on the input pin will not alter the stored charge while the conversion is in  
progress. The device then zeros the comparator and begins the conversion.  
The A/D converter uses a successive approximation algorithm to perform the analog-to-digital  
conversion. The converter hardware consists of a 256-resistor ladder, a comparator, coupling ca-  
pacitors, and a 10-bit successive approximation register (SAR) with logic that guides the process.  
The resistive ladder provides 20 mV steps (VREF = 5.12 volts), while capacitive coupling creates  
5 mV steps within the 20 mV ladder voltages. Therefore, 1024 internal reference voltage levels  
are available for comparison against the analog input to generate a 10-bit conversion result. In 8-  
bit conversion mode, only the resistive ladder is used, providing 256 internal reference voltage  
levels.  
The successive approximation conversion compares a sequence of reference voltages to the ana-  
log input, performing a binary search for the reference voltage that most closely matches the in-  
put. The ½ full scale reference voltage is the first tested. This corresponds to a 10-bit result where  
the most-significant bit is zero and all other bits are ones (0111111111B). If the analog input was  
less than the test voltage, bit 10 of the SAR is left at zero, and a new test voltage of ¼ full scale  
(0011111111B) is tried. If the analog input was greater than the test voltage, bit 9 of SAR is set.  
Bit 8 is then cleared for the next test (0101111111B). This binary search continues until 10 (or 8)  
tests have occurred, at which time the valid conversion result resides in the AD_RESULT register  
where it can be read by software. The result is equal to the ratio of the input voltage divided by  
the analog supply voltage. If the ratio is 1.00, the result will be all ones.  
12.4 PROGRAMMING THE A/D CONVERTER  
The following A/D converter parameters are programmable:  
conversion input — input channel  
zero-offset adjustment — no adjustment, plus 2.5 mV, minus 2.5 mV, or minus 5.0 mV  
conversion times — sample window time and conversion time for each bit  
operating mode — 8- or 10-bit conversion or 8-bit high or low threshold detection  
conversion trigger — immediate or EPA starts  
This section describes the A/D converter’s registers and explains how to program them.  
12-4  
Download from Www.Somanuals.com. All Manuals Search And Download.  
ANALOG-TO-DIGITAL (A/D) CONVERTER  
12.4.1 Programming the A/D Test Register  
The AD_TEST register (Figure 12-2) analog specifies an offset voltage to be applied to the resis-  
tor ladder. To use the zero-offset adjustment, first perform two conversions, one on ANGND and  
one on VREF. With the results of these conversions, use a software routine to calculate the zero-  
offset error. Specify the zero-offset adjustment by writing the appropriate value to AD_TEST.  
This offset voltage is added to the resistor ladder and applies to all input channels. “Understand-  
ing A/D Conversion Errors” on page 12-13 describes zero-offset and other errors inherent in A/D  
conversions.  
Address:  
Reset State (MC, MD):  
Reset State (MH):  
1FAEH  
C0H  
AD_TEST  
88H  
The A/D test (AD_TEST) register specifies adjustments for DC offset errors.  
7
0
OFF1  
OFF0  
Bit  
Number  
Bit  
Mnemonic  
Function  
7:5  
Reserved; for compatibility with future devices, write zeros to these bits.  
4
OFF1  
Offset  
This bit , along with OFF0 (bit 2) allows you to set the zero offset point.  
OFF1 OFF0  
0
0
1
1
0
1
0
1
no adjustment  
add 2.5 mV  
subtract 2.5 mV  
subtract 5.0 mV  
3
Reserved; for compatibility with future devices, write zero to this bit.  
See bit 4 (OFF1).  
2
OFF0  
1:0  
Reserved; for compatibility with future devices, write zeros to these bits.  
Figure 12-2. A/D Test (AD_TEST) Register  
12.4.2 Programming the A/D Result Register (for Threshold Detection Only)  
To use the threshold-detection modes, you must first write a value to the high byte of  
AD_RESULT to set the desired reference (threshold) voltage.  
12-5  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
AD_RESULT (Write)  
Address:  
Reset State (MC, MD):  
Reset State (MH):  
1FAAH  
FFC0H  
7FC0H  
The high byte of the A/D result (AD_RESULT) register can be written to set the reference voltage for  
the A/D threshold-detection modes.  
15  
8
0
REFV7  
REFV6  
REFV5  
REFV4  
REFV3  
REFV2  
REFV1  
REFV0  
7
Bit  
Number  
Bit  
Mnemonic  
Function  
15:8  
REFV7:0  
Reference Voltage  
These bits specify the threshold value. This selects a reference voltage  
that is compared with an analog input pin. When the voltage on the  
analog input pin crosses over (detect high) or under (detect low) the  
threshold value, the A/D conversion complete interrupt pending bit is set.  
Use the following formula to determine the value to write to this register  
for a given threshold voltage.  
desired threshold voltage × 256  
----------------------------------------------------------------------------------  
reference voltage =  
V
REF ANGND  
7:0  
Figure 12-3. A/D Result (AD_RESULT) Register — Write Format  
Reserved; for compatibility with future devices, write zeros to these bits.  
12.4.3 Programming the A/D Time Register  
Two parameters, sample time and conversion time, control the time required for an A/D conver-  
sion. The sample time is the length of time that the analog input voltage is actually connected to  
the sample capacitor. If this time is too short, the sample capacitor will not charge completely. If  
the sample time is too long, the input voltage may change and cause conversion errors. The con-  
version time is the length of time required to convert the analog input voltage stored on the sample  
capacitor to a digital value. The conversion time must be long enough for the comparator and cir-  
cuitry to settle and resolve the voltage. Excessively long conversion times allow the sample ca-  
pacitor to discharge, degrading accuracy.  
The AD_TIME register (Figure 12-4) specifies the A/D sample and conversion times. To avoid  
erroneous conversion results, use the TSAM and TCONV specifications on the datasheet to determine  
appropriate values.  
12-6  
Download from Www.Somanuals.com. All Manuals Search And Download.  
ANALOG-TO-DIGITAL (A/D) CONVERTER  
Address:  
Reset State:  
1FAFH  
FFH  
AD_TIME  
The A/D time (AD_TIME) register programs the sample window time and the conversion time for each  
bit. This register programs the speed at which the A/D can run — not the speed at which it can convert  
correctly. Consult the data sheet for recommended values. Initialize the AD_TIME register before  
initializing the AD_COMMAND register. Do not write to this register while a conversion is in progress;  
the results are unpredictable.  
7
0
SAM2  
SAM1  
SAM0  
CONV4  
CONV3  
CONV2  
CONV1  
CONV0  
Bit  
Number  
Bit  
Mnemonic  
Function  
7:5  
SAM2:0  
A/D Sample Time  
These bits specify the sample time. Use the following formula to  
compute the sample time.  
TSAM × FXTAL1 2  
------------------------------------------------  
SAM =  
8
where:  
SAM  
=
=
=
1 to 7  
TSAM  
FXTAL1  
the sample time, in µsec, from the data sheet  
the input frequency on XTAL1, in MHz  
4:0  
CONV4:0  
A/D Convert Time  
These bits specify the conversion time for each bit. Use the following  
formula to compute the conversion time.  
TCONV ×FXTAL1 3  
----------------------------------------------------  
CONV =  
where:  
1  
2 ×B  
CONV= 2 to 31  
TCONV  
FXTAL1  
B
=
=
=
the conversion time, in µsec, from the data sheet  
the input frequency on XTAL1, in MHz  
the number of bits to be converted (8 or 10)  
Figure 12-4. A/D Time (AD_TIME) Register  
12.4.4 Programming the A/D Command Register  
The A/D command register controls the operating mode, the analog input channel, and the con-  
version trigger.  
12-7  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
AD_COMMAND  
Address:  
Reset State:  
1FACH  
80H  
The A/D command (AD_COMMAND) register selects the A/D channel number to be converted,  
controls whether the A/D converter starts immediately or with an EPA command, and selects the  
conversion mode.  
7
0
M1  
M0  
GO  
ACH3  
ACH2  
ACH1  
ACH0  
Bit  
Number  
Bit  
Mnemonic  
Function  
7
Reserved; for compatibility with future devices, write zeros to these bits.  
6:5  
M1:0  
A/D Mode†  
These bits determine the A/D mode.  
M1  
M0  
Mode  
0
0
1
1
0
1
0
1
10-bit conversion  
8-bit conversion  
threshold detect high  
threshold detect low  
4
GO  
A/D Conversion Trigger††  
Writing this bit arms the A/D converter. The value that you write to it  
determines at what point a conversion is to start.  
0 = EPA initiates conversion  
1 = start immediately  
3:0  
ACH3:0  
A/D Channel Selection  
Write the A/D conversion channel number to these bits.  
While a threshold-detection mode is selected for an analog input pin, no other conversion can be  
started. If another value is loaded into AD_COMMAND, the threshold-detection mode is disabled  
and the new command is executed.  
††  
It is the act of writing to the GO bit, rather than its value, that starts a conversion. Even if the GO bit  
has the desired value, you must set it again to start a conversion immediately or clear it again to  
arm it for an EPA-initiated conversion.  
Figure 12-5. A/D Command (AD_COMMAND) Register  
12.4.5 Enabling the A/D Interrupt  
The A/D converter can set the A/D interrupt pending bit when it completes a conversion or when  
the input voltage crosses the threshold value in the selected direction. To enable the interrupt, set  
the corresponding mask bit in the interrupt mask register (see Table 12-2 on page 12-2) and exe-  
cute the EI instruction to globally enable servicing of interrupts. The A/D interrupt can cause the  
PTS to begin a new conversion. See Chapter 5, “Standard and PTS Interrupts,” for details about  
interrupts and a description of using the PTS in A/D scan mode.  
12-8  
Download from Www.Somanuals.com. All Manuals Search And Download.  
ANALOG-TO-DIGITAL (A/D) CONVERTER  
12.5 DETERMINING A/D STATUS AND CONVERSION RESULTS  
You can read the AD_RESULT register (Figure 12-6) to determine the status of the A/D convert-  
er. The AD_RESULT register is cleared when a new conversion is started; therefore, to prevent  
losing data, you must read both bytes before a new conversion starts. If you read AD_RESULT  
before the conversion is complete, the result is not guaranteed to be accurate.  
The conversion result is the ratio of the input voltage to the reference voltage:  
V
IN ANGND  
V
IN ANGND  
------------------------------------------  
------------------------------------------  
RESULT (8-bit) = 255 ×  
RESULT (10-bit) = 1023 ×  
V
REF ANGND  
VREF ANGND  
You can also read the interrupt pending register (see Table 12-2 on page 12-2) to determine the  
status of the A/D interrupt.  
Address:  
Reset State (MC, MD):  
Reset State (MH):  
1FAAH  
FFC0H  
7FC0H  
AD_RESULT (Read)  
The A/D result (AD_RESULT) register consists of two bytes. The high byte contains the eight most-  
significant bits from the A/D converter. The low byte contains the two least-significant bits from a ten-  
bit A/D conversion, indicates the A/D channel number that was used for the conversion, and indicates  
whether a conversion is currently in progress.  
15  
ADRLT9  
8
ADRLT8  
ADRLT0  
ADRLT7  
ADRLT6  
STATUS  
ADRLT5  
ACH3  
ADRLT4  
ACH2  
ADRLT3  
ACH1  
ADRLT2  
7
0
ADRLT1  
ACH0  
Bit  
Number  
Bit  
Mnemonic  
Function  
15:6  
ADRLT9:0  
A/D Result  
These bits contain the A/D conversion result.  
Reserved. This bit is undefined.  
A/D Status  
5
4
STATUS  
Indicates the status of the A/D converter. Up to 8 state times are required  
to set this bit following a start command. When testing this bit, wait at  
least the 8 state times.  
0 = A/D is idle  
1 = A/D conversion is in progress  
3:0  
ACH3:0  
A/D Channel Number  
These bits indicate the A/D channel number that was used for the  
conversion.  
Figure 12-6. A/D Result (AD_RESULT) Register — Read Format  
12-9  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
12.6 DESIGN CONSIDERATIONS  
This section describes considerations for the external interface circuitry and describes the errors  
that can occur in any A/D converter. The datasheet lists the absolute error specification, which  
includes all deviations between the actual conversion process and an ideal converter. However,  
because the various components of error are important in many applications, the datasheet also  
lists the specific error components. This section describes those components. For additional in-  
®
formation and design techniques, consult AP-406, MCS 96 Analog Acquisition Primer (order  
number 270365). Application note AP-406 is also included in the Embedded Microcontrollers  
handbook.  
12.6.1 Designing External Interface Circuitry  
The external interface circuitry to an analog input is highly dependent upon the application and  
can affect the converter characteristics. Factors such as input pin leakage, sample capacitor size,  
and multiplexer series resistance from the input pin to the sample capacitor must be considered  
in the external circuit’s design. These factors are idealized in Figure 12-7.  
Sample  
External  
Internal  
RF  
~2pF  
CS  
RSOURCE  
~1KΩ  
AV  
R1  
V
ILI1  
+
-
Leakage  
A0243-02  
Figure 12-7. Idealized A/D Sampling Circuitry  
During the sample window, the external input circuit must be able to charge the sample capacitor  
(CS) through the series combination of the input source resistance (RSOURCE), the input series re-  
sistance (R1), and the comparator feedback resistance (RF). The total effective series resistance  
(RT) is calculated using the following formula, where AV is the gain of the comparator circuit.  
RF  
----------------  
RT = RSOURCE + R1  
+
A
V + 1  
12-10  
Download from Www.Somanuals.com. All Manuals Search And Download.  
ANALOG-TO-DIGITAL (A/D) CONVERTER  
Typically, the (RF / AV + 1) term is the major contributor to the total resistance and the factor that  
determines the minimum sample time specified in the datasheet.  
12.6.1.1  
Minimizing the Effect of High Input Source Resistance  
Under some conditions, the input source resistance (RSOURCE) can be great enough to affect the  
measurement. You can minimize this effect by increasing the sample time or by connecting an  
external capacitor (CEXT) from the input pin to ANGND. The external signal will charge CEXT to  
the source voltage level. When the channel is sampled, CEXT acts as a low-impedance source to  
charge the sample capacitor (CS). A small portion of the charge in CEXT is transferred to CS, re-  
sulting in a drop of the sampled voltage. The voltage drop is calculated using the following for-  
mula.  
CS  
---------------------------  
Sampled Voltage Drop, % =  
× 100%  
C
EXT + CS  
If CEXT is 0.005 µF or greater, the error will be less than –0.4 LSB in 10-bit conversion mode. The  
use of CEXT in conjunction with RSOURCE forms a low-pass filter that reduces noise input to the  
A/D converter.  
High RSOURCE resistance can also cause errors due to the input leakage (ILI1). ILI1 is typically much  
lower than its specified maximum (consult the datasheet for specifications). The combined effect  
of ILI1 leakage and high RSOURCE resistance is calculated using the following formula.  
RSOURCE × ILI1 × 1024  
-----------------------------------------------------------  
error (LSBs) =  
VREF  
where:  
RSOURCE  
is the input source resistance, in ohms  
is the input leakage, in amperes  
is the reference voltage, in volts  
ILI  
1
VREF  
External circuits with RSOURCE resistance of 1 kilo-ohm or lower and VREF equal to 5.0 volts will  
have a resultant error due to source impedance of 0.6 LSB or less.  
12-11  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
12.6.1.2  
Suggested A/D Input Circuit  
The suggested A/D input circuit shown in Figure 12-8 provides limited protection against over-  
voltage conditions on the analog input. Should the input voltage be driven significantly below  
ANGND or above VREF, diode D2 or D1 will forward bias at about 0.8 volts. The device’s input  
protection begins to turn on at approximately 0.5 volts beyond ANGND or VREF. The 270re-  
sistor limits the current input to the analog input pin to a safe value, less than 1 mA.  
NOTE  
Driving any analog input more than 0.5 volts beyond ANGND or VREF begins  
to activate the input protection devices. This drives current into the internal  
reference circuitry and substantially degrades the accuracy of A/D conversions  
on all channels.  
VREF  
VREF  
D1  
270Ω  
100Ω  
ACHx  
(Optional)  
0.005µF  
D2  
ANGND  
8XC196  
Device  
ANGND  
A0082-03  
Figure 12-8. Suggested A/D Input Circuit  
Analog Ground and Reference Voltages  
12.6.1.3  
Reference supply levels strongly influence the absolute accuracy of the conversion. For this rea-  
son, we recommend that you tie the ANGND pin to the VSS pin as close to the device as possible,  
using a minimum trace length. In a noisy environment, we highly recommend the use of a sepa-  
rate analog ground plane that connects to VSS at a single point as close to the device as possible.  
IREF may vary between 2 mA and 5 mA during a conversion. To minimize the effect of this fluc-  
tuation, mount a 1.0 µF ceramic or tantalum bypass capacitor between VREF and ANGND, as close  
to the device as possible.  
12-12  
Download from Www.Somanuals.com. All Manuals Search And Download.  
ANALOG-TO-DIGITAL (A/D) CONVERTER  
ANGND should be within about ± 50 mV of VSS. VREF should be well regulated and used only  
for the A/D converter. The VREF supply can be between 4.5 and 5.5 volts and must be able to  
source approximately 5 mA (see the datasheet for actual specifications). VREF should be approx-  
imately the same voltage as VCC. VREF and VCC should power up at the same time, to avoid poten-  
tial latch-up conditions on VREF. Large negative current spikes on the ANGND pin relative to VSS  
may cause the analog circuitry to latch up. This is an additional reason to follow careful ground-  
ing practice.  
The analog reference voltage (VREF) is the positive supply to which all A/D conversions are com-  
pared. It is also the supply to port 0 (and port 1 for the MC and MD) if the A/D converter is not  
being used. If high accuracy is not required, VREF can be tied to VCC. If accuracy is important,  
VREF must be very stable. One way to accomplish this is through the use of a precision power sup-  
ply or a separate voltage regulator (usually an IC). These devices must be referenced to ANGND,  
not to VSS, to ensure that VREF tracks ANGND and not VSS.  
12.6.1.4  
Using Mixed Analog and Digital Inputs  
Port 0 (and port 1 for the MC and MD) may be used for both analog and digital input signals at  
the same time. However, reading the port may inject some noise into the analog circuitry. For this  
reason, make certain that an analog conversion is not in progress when the port is read. Refer to  
Chapter 6, “I/O Ports,” for information about using the port as digital inputs.  
12.6.2 Understanding A/D Conversion Errors  
The conversion result is the ratio of the input voltage to the reference voltage.  
V
IN ANGND  
V
IN ANGND  
------------------------------------------  
------------------------------------------  
RESULT (8-bit) = 255 ×  
RESULT (10-bit) = 1023 ×  
V
REF ANGND  
VREF ANGND  
This ratio produces a stair-stepped transfer function when the output code is plotted versus input  
voltage. The resulting digital codes can be taken as simple ratiometric information, or they pro-  
vide information about absolute voltages or relative voltage changes on the inputs.  
The more demanding the application, the more important it is to fully understand the converter’s  
operation. For simple applications, knowing the absolute error of the converter is sufficient.  
However, closing a servo-loop with analog inputs requires a detailed understanding of an A/D  
converter’s operation and errors.  
12-13  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
In many applications, it is less critical to record the absolute accuracy of an input than it is to de-  
tect that a change has occurred. This approach is acceptable as long as the converter is monotonic  
and has no missing codes. That is, increasing input voltages produce adjacent, unique output  
codes that are also increasing. Decreasing input voltages produce adjacent, unique output codes  
that are also decreasing. In other words, there exists a unique input voltage range for each 10-bit  
output code that produces that code only, with a repeatability of typically ± 0.25 LSBs (1.5 mV).  
The inherent errors in an analog-to-digital conversion process are quantizing error, zero-offset er-  
ror, full-scale error, differential nonlinearity, and nonlinearity. All of these are transfer function  
errors related to the A/D converter. In addition, temperature coefficients, VCC rejection, sample-  
hold feedthrough, multiplexer off-isolation, channel-to-channel matching, and random noise  
should be considered. Fortunately, one absolute error specification (listed in datasheets) de-  
scribes the total of all deviations between the actual conversion process and an ideal converter.  
However, the various components of error are important in many applications.  
An unavoidable error results from the conversion of a continuous voltage to an integer digital rep-  
resentation. This error, called quantizing error, is always ± 0.5 LSB. Quantizing error is the only  
error seen in a perfect A/D converter, and it is obviously present in actual converters. Figure 12-9  
shows the transfer function for an ideal 3-bit A/D converter.  
12-14  
Download from Www.Somanuals.com. All Manuals Search And Download.  
ANALOG-TO-DIGITAL (A/D) CONVERTER  
7
FINAL CODE TRANSITION OCCURS  
WHEN THE APPLIED VOLTAGE IS  
EQUAL TO (Vref – 1.5 (LSB)).  
6
5
4
3
2
1
0
ACTUAL CHARACTERISTIC OF  
AN IDEAL A/D CONVERTER  
THE VOLTAGE CHANGE  
BETWEEN THE ADJACENT CODE  
TRANSITIONS (THE “CODE  
WIDTH”) IS = 1 LSB.  
FIRST CODE TRANSITION OCCURS  
WHEN THE APPLIED VOLTAGE IS  
EQUAL TO 1/2 LSB.  
1/2  
1
2
3
4
5
6
6 1/2  
7
8
INPUT VOLTAGE (LSBs)  
A0083-01  
Figure 12-9. Ideal A/D Conversion Characteristic  
Note that the ideal characteristic possesses unique qualities:  
its first code transition occurs when the input voltage is 0.5 LSB;  
its full-scale code transition occurs when the input voltage equals the full-scale reference  
voltage minus 1.5 LSB (VREF – 1.5LSB); and  
its code widths are all exactly one LSB.  
These qualities result in a digitization without zero-offset, full-scale, or linearity errors; in other  
words, a perfect conversion.  
12-15  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
7
6
FULL SCALE ERROR  
IDEAL  
CHARACTERISTIC  
5
4
3
2
1
0
ACTUAL  
CHARACTERISTIC  
ABSOLUTE ERROR  
ZERO OFFSET  
1/2  
1
2
3
4
5
6
6 1/2  
7
8
INPUT VOLTAGE (LSBs)  
A0084-01  
Figure 12-10. Actual and Ideal A/D Conversion Characteristics  
The actual characteristic of a hypothetical 3-bit converter is not perfect. When the ideal charac-  
teristic is overlaid with the actual characteristic, the actual converter is seen to exhibit errors in  
the locations of the first and final code transitions and in code widths, as shown in Figure 12-10.  
The deviation of the first code transition from ideal is called zero-offset error, and the deviation  
of the final code transition from ideal is full-scale error. The deviation of a code width from ideal  
causes two types of errors: differential nonlinearity and nonlinearity. Differential nonlinearity is  
a measure of local code-width error, whereas nonlinearity is a measure of overall code-transition  
error.  
12-16  
Download from Www.Somanuals.com. All Manuals Search And Download.  
ANALOG-TO-DIGITAL (A/D) CONVERTER  
Differential nonlinearity is the degree to which actual code widths differ from the ideal one-LSB  
width. It provides a measure of how much the input voltage may have changed in order to produce  
a one-count change in the conversion result. In the 10-bit converter, the code widths are ideally  
5 mV (VREF / 1024). If such a converter is specified to have a maximum differential nonlinearity  
of 2 LSBs (10 mV), the maximum code width will be no greater than 10 mV larger than ideal, or  
15 mV.  
Because the A/D converter has no missing codes, the minimum code width will always be greater  
than –1 (negative one). The differential nonlinearity error on a particular code width is compen-  
sated for by other code widths in the transfer function, such that 1024 unique steps occur. The  
actual code widths in this converter typically vary from 2.5 mV to 7.5 mV.  
Nonlinearity is the worst-case deviation of code transitions from the corresponding code transi-  
tions of the ideal characteristic. Nonlinearity describes the extent to which differential nonlinear-  
ities can add up to produce an overall maximum departure from a linear characteristic. If the  
differential nonlinearity errors are too large, it is possible for an A/D converter to miss codes or  
to exhibit non-monotonic behavior. Neither behavior is desirable in a closed-loop system. A con-  
verter has no missing codes if there exists for each output code a unique input voltage range that  
produces that code only. A converter is monotonic if every subsequent code change represents an  
input voltage change in the same direction.  
Differential nonlinearity and nonlinearity are quantified by measuring the terminal-based linear-  
ity errors. A terminal-based characteristic results when an actual characteristic is translated and  
scaled to eliminate zero-offset and full-scale error, as shown in Figure 12-11. The terminal-based  
characteristic is similar to the actual characteristic that would result if zero-offset and full-scale  
error were externally trimmed away. In practice, this is done by using input circuits that include  
gain and offset trimming. In addition, VREF could also be closely regulated and trimmed within  
the specified range to affect full-scale error.  
Other factors that affect a real A/D converter system include temperature drift, failure to com-  
pletely reject unwanted signals, multiplexer channel dissimilarities, and random noise. Fortunate-  
ly, these effects are small. Temperature drift is the rate at which typical specifications change with  
a change in temperature. These changes are reflected in the temperature coefficients. Unwanted  
signals come from three main sources: noise on VCC, input signal changes on the channel being  
converted (after the sample window has closed), and signals applied to channels not selected by  
the multiplexer. The effects of these unwanted signals are specified as Vcc rejection, off-isolation,  
and feedthrough, respectively. Finally, multiplexer on-channel resistances differ slightly from one  
channel to the next, which causes channel-to-channel matching errors and repeatability errors.  
Differences in DC leakage current from one channel to another and random noise in general con-  
tribute to repeatability errors.  
12-17  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
7
6
IDEAL FULL-SCALE CODE  
TRANSITION  
IDEAL STRAIGHT LINE  
TRANSFER FUNCTION  
ACTUAL  
FULL-SCALE CODE  
TRANSITION  
5
4
3
2
1
0
DIFFERENTIAL  
NON-LINEARITY  
(POSITIVE)  
TERMINAL BASED  
CHARACTERISTIC  
(corrected for zero-offset  
and full-scale error)  
IDEAL  
CODE WIDTH  
ACTUAL  
CHARACTERISTIC  
NON-LINEARITY  
DIFFERENTIAL  
NON-LINEARITY (NEGATIVE)  
IDEAL CODE WIDTH  
ACTUAL FIRST TRANSITION  
IDEAL FIRST TRANSITION  
1/2  
1
2
3
4
5
6
6 1/2  
7
8
INPUT VOLTAGE (LSBs)  
A0085-01  
Figure 12-11. Terminal-based A/D Conversion Characteristic  
12-18  
Download from Www.Somanuals.com. All Manuals Search And Download.  
13  
Minimum Hardware  
Considerations  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
CHAPTER 13  
MINIMUM HARDWARE CONSIDERATIONS  
The 8XC196MC, MD, and MH have several basic requirements for operation within a system.  
This chapter describes options for providing the basic requirements and discusses other hardware  
considerations.  
13.1 MINIMUM CONNECTIONS  
Table 13-1 lists the signals that are required for the device to function and Figure 13-1 shows the  
connections for a minimum configuration.  
Table 13-1. Minimum Required Signals  
Signal  
Type  
Description  
Name  
ANGND  
GND  
Analog Ground  
ANGND must be connected for A/D converter and port 0 operation (also port 1 on  
the 8XC196MC and MD). ANGND and VSS should be nominally at the same  
potential.  
RESET#  
I/O  
Reset  
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 and  
idle modes, asserting RESET# causes the chip to reset and return to normal  
operating mode. The 8XC196MH provides the option of preventing an internal reset  
from generating a reset on the external pin (see “Resetting the Device” on page  
13-8). After a device reset, the first instruction fetch is from 2080H.  
VCC  
VPP  
PWR  
PWR  
Digital Supply Voltage  
Connect each VCC pin to the digital supply voltage.  
Programming Voltage  
During programming, the VPP pin is typically at +12.5 V (VPP voltage). Exceeding the  
maximum VPP voltage specification can damage the device.  
VPP also causes the device to exit powerdown mode when it is driven low for at least  
50 ns. Use this method to exit powerdown only when using an external clock source  
because it enables the internal phase clocks, but not the internal oscillator.  
On devices with no internal nonvolatile memory, connect VPP to VCC  
Reference Voltage for the A/D Converter  
.
VREF  
PWR  
GND  
This pin also supplies operating voltage to both the analog portion of the A/D  
converter and the logic used to read port 0 (also port 1 in the 8XC196MC and  
8XC196MD).  
VSS  
Digital Circuit Ground  
Connect each VSS pin to ground through the lowest possible impedance path.  
13-1  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 13-1. Minimum Required Signals (Continued)  
Signal  
Name  
Type  
Description  
XTAL1  
I
Input Crystal/Resonator or External Clock Input  
Input to the on-chip oscillator and the internal clock generators. The internal clock  
generators provide the peripheral clocks, CPU clock, and CLKOUT signal (MC/MD  
only). When using an external clock or crystal, instead of the on-chip oscillator,  
connect the clock input to XTAL1. The external clock signal must meet the VIH speci-  
fication 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  
an external clock source instead of the on-chip oscillator.  
13.1.1 Unused Inputs  
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.  
13.1.2 I/O Port Pin Connections  
Tie unused input-only port inputs to VSS as shown in Figure 13-1. Chapter 6, “I/O Ports,” contains  
information about initializing and configuring the ports. Table 13-2 lists the sections, with page  
numbers, that contain the information for each port.  
Table 13-2. I/O Port Configuration Guide  
Port  
Port 0  
Where to Find Configuration Information  
“Standard Input-only Port Considerations” on page 6-4  
Port 1  
“Standard Input-only Port Considerations” on page 6-4 (MC, MD)  
“Bidirectional Port Pin Configurations” on page 6-9 and “Bidirectional Port Considerations”  
on page 6-12 (MH)  
Port 2  
“Bidirectional Port Pin Configurations” on page 6-9 and “Bidirectional Port Considerations”  
on page 6-12  
Ports 3 and 4 “Bidirectional Ports 3 and 4 (Address/Data Bus) Operation” on page 6-15  
Port 5  
“Bidirectional Port Pin Configurations” on page 6-9 and “Bidirectional Port Considerations”  
on page 6-12  
Port 6  
“Configuring Output-only Port Pins” on page 6-17  
Port 7 (MD)  
“Bidirectional Port Pin Configurations” on page 6-9 and “Bidirectional Port Considerations”  
on page 6-12  
13-2  
Download from Www.Somanuals.com. All Manuals Search And Download.  
MINIMUM HARDWARE CONSIDERATIONS  
(Note 1)  
20 pF  
20 pF  
VCC  
XTAL2  
XTAL1  
RESET#  
VCC  
(Note 2)  
0.01 µF  
VCC  
+
4.7 µF  
VSS  
EA#  
NMI  
VCC  
1 M  
BUSWIDTH  
VPP  
(Note 3)  
VCC  
VCC  
+
READY  
1 µF  
VREF  
+
1 µF  
BHE#  
RD#  
ANGND  
Port 5 / Bus Control  
(Note 4)  
WR#  
Input-only  
Port Pins  
(Note 5)  
INST  
ALE  
8XC196 Device  
Notes:  
1. See the datasheet for the oscillator frequency range (FXTAL1) 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  
each VCC pin to the supply voltage and each VSS pin to ground.  
3. Connect the RC network to VPP only if powerdown mode will be used. Otherwise, connect VPP  
to VCC.  
4. No connection is required.  
5. Tie all input-only port pins to VSS.  
A2643-03  
Figure 13-1. Minimum Hardware Connections  
13-3  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
13.2 APPLYING AND REMOVING POWER  
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.  
13.3 NOISE PROTECTION TIPS  
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 and a 1.0 µF capacitor between VREF and  
ANGND to reduce noise (Figure 13-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.  
V
REF  
+
+
V
REF  
8XC196 Device  
1.0 µF  
ANGND  
Analog  
Ground  
Plane  
Digital  
Ground  
Plane  
+5 V  
5 V  
Return  
Power Source  
Use 0.01 µF bypass capacitors for maximum decoupling.  
A0272-02  
Figure 13-2. Power and Return Connections  
13-4  
Download from Www.Somanuals.com. All Manuals Search And Download.  
MINIMUM HARDWARE CONSIDERATIONS  
If the A/D converter will be used, connect VREF to a separate reference supply to minimize noise  
during A/D conversions. Even if the A/D converter will not be used, VREF and ANGND must be  
connected to provide power to port 0. On the 8XC196MC and MD, they also provide power to  
port 1. Refer to “Analog Ground and Reference Voltages” on page 12-12 for a detailed discussion  
of A/D power and ground recommendations.  
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.  
13.4 THE ON-CHIP OSCILLATOR CIRCUITRY  
The on-chip oscillator circuit (Figure 13-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.  
To internal  
circuitry  
V
CC  
Rf  
XTAL2  
XTAL1  
(Input)  
(Output)  
Oscillator Enable#  
(from powerdown circuitry)  
V
SS  
A0076-03  
Figure 13-3. On-chip Oscillator Circuit  
13-5  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Figure 13-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.  
C1  
XTAL1  
®
MCS 96  
Microcontroller  
XTAL2  
C2  
Quartz Crystal  
Note:  
Mount the crystal and capacitors close to the device using  
short, direct traces to XTAL1, XTAL2, and V . When  
ss  
using a crystal, C1=C220 pF. When using a ceramic  
resonator, consult the manufacturer for recommended  
oscillator circuitry.  
A0273-03  
Figure 13-4. External Crystal Connections  
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.  
13-6  
Download from Www.Somanuals.com. All Manuals Search And Download.  
MINIMUM HARDWARE CONSIDERATIONS  
13.5 USING AN EXTERNAL CLOCK SOURCE  
To use an external clock source, apply a clock signal to XTAL1 and let XTAL2 float (Figure  
13-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 13-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.  
V
CC  
4.7 kΩ  
External  
XTAL1  
XTAL2  
Clock Input  
®
MCS 96  
Clock Driver  
No Connection  
Microcontroller  
Required if TTL driver is used. Not needed if CMOS driver is used.  
A0274-03  
Figure 13-5. External Clock Connections  
TXHXL  
TXHXX  
TXLXH  
0.7 VCC + 0.5 V  
0.7 VCC + 0.5 V  
0.3 VCC – 0.5 V  
TXLXL  
TXLXX  
0.3 VCC – 0.5 V  
XTAL1  
A2119-02  
Figure 13-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.  
13-7  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
13.6 RESETTING THE DEVICE  
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. (Tables in Appendix B list the reset states  
of the pins (see Table B-8 on page B-23 for the 8XC196MC and 8XC196MD or Table B-9 on  
page B-25 for the 8XC196MH). See Table C-2 on page C-2 for the reset values of the SFRs.) The  
device remains in its reset state until RESET# is deasserted. When RESET# is deasserted, the bus  
controller fetches the chip configuration bytes (CCBs), loads them into the chip configuration  
registers (CCRs), and then fetches the first instruction.  
Figure 13-7 shows the reset-sequence timing. Depending upon when RESET# is brought high,  
the CLKOUT signal (MC and MD only) may become out of phase with the PH1 internal clock.  
When this occurs, the clock generator immediately resynchronizes CLKOUT as shown in Case 2.  
Internal  
Reset  
RESET#  
Pin  
Case 1  
CLKOUT  
(MC, MD  
Only)  
Case 2  
CLKOUT  
= ADV# Selected  
XTAL1  
Phases Resynchronized  
9 T  
9 T  
XTAL1  
8 T  
ALE  
RD#  
XTAL1  
7 T  
XTAL1  
7 T  
7 T  
XTAL1  
CCB0  
XTAL1  
CCB1  
9 T  
11 T  
XTAL1  
XTAL1  
AD7:0  
AD15:8  
18H  
20H  
1AH  
80H  
20H  
Weak  
Weak  
20H  
Bus parameters defined by CCB0 (ready  
control, bus width, and bus-timing  
modes) take effect here.  
Defaults to an 8-bit bus until the CCBs are loaded. AD15:8 weakly drive address during the CCB fetches.  
For 16-bit systems, write 20H to the high byte of CCB0 and CCB1 (2019H and 201BH) in order to prevent  
bus contention.  
A3088-02  
Figure 13-7. Reset Timing Sequence  
13-8  
Download from Www.Somanuals.com. All Manuals Search And Download.  
MINIMUM HARDWARE CONSIDERATIONS  
The 8XC196MH provides the option of an internal-only reset or an internal reset that is also re-  
flected externally (by the RESET# pin). The GEN_CON register controls whether an internal re-  
set asserts the external RESET# signal and indicates the source of the most recent reset. Figure  
13-8 describes the general configuration register, GEN_CON.  
Address:  
Reset State:  
1FA0H  
00H  
GEN_CON  
(8XC196MH)  
The GEN_CON register controls whether an internal reset asserts the external RESET# signal and  
indicates the source of the most recent reset.  
7
0
8XC196MH  
RSTS  
DR0  
Bit  
Number  
Bit  
Mnemonic  
Function  
7
RSTS  
Reset source (read-only status bit)  
0 = external reset (RESET# pin asserted)  
1 = internal reset (watchdog overflow, illegal IDLPD key, or RST  
instruction)  
6:1  
0
Reserved; for compatibility with future devices, write zeros to these bits.  
DRO  
Disable RESET# out  
0 = an internal reset asserts the RESET# pin.  
1 = an internal reset has no effect on the RESET# pin; the RESET# pin is  
pulled high (inactive).  
Figure 13-8. General Configuration Register (GEN_CON)  
The following events will reset the device (see Figure 13-9):  
an external device pulls the RESET# pin low  
the CPU issues the reset (RST) instruction  
the CPU issues an idle/powerdown (IDLPD) instruction with an illegal key operand  
the watchdog timer (WDT) overflows  
The following paragraphs describe each of these reset methods in more detail.  
13-9  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Internal  
External  
V
CC  
Clock  
Reset State  
Internal  
Reset  
Signal  
Machine  
R
Trigger  
RST  
Count Complete  
CLR  
RESET#  
~200 Ω  
Q
Q1  
GEN_CON.0  
(MH Only)  
SET  
RST Instruction  
WDT Overflow  
IDLPD Invalid Key  
See the datasheet for minimum and maximum RRST values.  
A3086-01  
Figure 13-9. Internal Reset Circuitry  
13.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 13-10. The device has an internal pull-up resistor (RRST) shown in Figure 13-9.  
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.  
13-10  
Download from Www.Somanuals.com. All Manuals Search And Download.  
MINIMUM HARDWARE CONSIDERATIONS  
RESET#  
+
4.7 µF  
®
MCS 96  
Microcontroller  
A0276-02  
Figure 13-10. Minimum Reset Circuit  
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 13-11 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.  
V
CC  
V
CC  
(1)  
D1  
(2)  
R
D2  
4.7 kΩ  
RESET#  
SW1  
®
C
MCS 96  
Schmitt Triggers  
Microcontroller  
System reset signal  
to external circuitry  
Notes:  
1. D1 provides a faster cycle time for repetitive power-on resets.  
2. Optional pull-up for faster recovery.  
A0277-03  
Figure 13-11. Example of a System Reset Circuit  
13-11  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
13.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 master program counter (PC) to 2080H,  
and resets the special function registers (SFRs). See Table C-2 on page C-2 for the reset values  
of the SFRs.  
Putting pull-ups on the address/data bus causes unimplemented areas of memory to be read as  
FFH. If unused internal OTPROM memory is set to FFH, then execution from any unused mem-  
ory locations will reset the device.  
13.6.3 Issuing an Illegal IDLPD Key Operand  
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 and “2” for powerdown mode. If any other value is  
used, the device executes a reset sequence. (See Appendix A for a description of the IDLPD com-  
mand.)  
13.6.4 Generating Wait States  
The 8XC196Mx devices can interface with a variety of external memory devices. With slower  
external devices this requires inserting wait states to lengthen the bus cycle. An external device  
can use the READY input to request wait states in addition to the wait states that are generated  
internally by the 8XC196Mx device. The READY signal must be held valid until the TCLYX (for  
the 8XC196MC, MD) or TLLYX (for the 8XC196MH) timing specification is met. Do not exceed  
the maximum TCLYX (for the 8XC196MC, MD) or TLLYX (for the 8XC196MH) specification or  
additional (unwanted) wait states might be added (see Chapter 15, “Wait States (Ready Control),”  
for a detailed explanation).  
13.6.5 Enabling the Watchdog Timer  
The watchdog timer (WDT) is a 16-bit counter that resets the device when the counter overflows.  
The WDE bit (bit 3) of CCR1 controls whether the watchdog is enabled immediately or is dis-  
abled until the first time it is cleared. Clearing WDE activates the watchdog. Setting WDE makes  
the watchdog timer inactive, but you can activate it by clearing the watchdog register. Once the  
watchdog is activated, only a reset can disable it.  
The 8XC196MC and 8XC196MD allow only one reset interval, 64K state times. This requires  
your software to interrupt itself every 65,535 state times to reset the watchdog. The 8XC196MH  
allows you to choose a longer interval.  
13-12  
Download from Www.Somanuals.com. All Manuals Search And Download.  
MINIMUM HARDWARE CONSIDERATIONS  
You must write two consecutive bytes to the watchdog register (location 0AH) to clear it. For the  
8XC196MC and MD, the first byte must be 1EH and the second must be E1H. For the  
8XC196MH, the first byte must also be 1EH; however, the second byte can be one of four values.  
The second byte determines the reset interval (Table 13-3). Only the values listed in the table are  
valid; an invalid value will not clear the register, so the counter will overflow and the watchdog  
will reset the device. We recommend that you disable interrupts before writing to the watchdog  
register. If an interrupt occurs between the two writes, the watchdog register will not be cleared.  
Table 13-3. Selecting the Watchdog Reset Interval (8XC196MH only)  
First Byte  
Second Byte  
Reset Interval  
64K states  
1EH  
1EH  
1EH  
1EH  
E1H  
A1H  
61H  
21H  
128K states (2 × 64K)  
256K states (4 × 64K)  
512K states (8 × 64K)  
NOTE (8XC196MH Only)  
If the WDE bit of CCR1 is cleared, the watchdog is activated immediately  
after a system power-up or a device reset. You must clear the watchdog register  
within 64K state times after a system power-up or a device reset. At that time,  
you can choose a longer interval for subsequent watchdog resets.  
If enabled, the watchdog continues to run in idle mode. The device must be awakened before the  
end of the reset interval to clear the watchdog; otherwise, the watchdog will reset the device,  
which causes it to exit idle mode.  
13-13  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
14  
Special Operating  
Modes  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
CHAPTER 14  
SPECIAL OPERATING MODES  
The 8XC196MC, MD, and MH provide two power saving modes: idle 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 Ap-  
pendix B for descriptions of signal status during each mode, and to Appendix C for details about  
the registers.)  
14.1 SPECIAL OPERATING MODE SIGNALS AND REGISTERS  
Table 14-1 lists the signals and Table 14-2 lists the registers that are mentioned in this chapter.  
Table 14-1. Operating Mode Control Signals  
Signal  
Port Pin  
Type  
Description  
Name  
P2.7  
CLKOUT  
(MC/MD  
only)  
O
Clock Output  
Output of the internal clock generator. The CLKOUT frequency is ½  
the oscillator input frequency (FXTAL1). CLKOUT has a 50% duty cycle.  
CLKOUT is not implemented on the 8XC196MH.  
External Interrupt  
EXTINT  
I
This programmable interrupt is controlled by the WG_PROTECT  
register. This register controls whether the interrupt is edge triggered  
or sampled and whether a rising edge/high level or falling edge/low  
level activates the interrupt.  
In powerdown mode, asserting the EXTINT signal for at least 50 ns  
causes the device to resume normal operation. The interrupt need not  
be enabled. If the EXTINT 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.  
14-1  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 14-1. Operating Mode Control Signals (Continued)  
Signal  
Name  
Port Pin  
Type  
Description  
P5.4  
ONCE#  
I
On-circuit Emulation  
Holding ONCE# low during the rising edge of RESET# places the  
device into on-circuit emulation (ONCE) mode. This mode puts all  
pins, except XTAL1 and XTAL2, 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 inadvertent entry into ONCE mode,  
either configure this pin as an output or hold it high during reset and  
ensure that your system meets the VIH specification (see datasheet).  
P2.6  
Test-mode  
entry  
I/O  
I/O  
Test-mode entry  
If this pin is held low during reset, the device will enter a reserved test  
mode, so exercise caution if you use this pin for input. If you choose  
to configure this pin as an input, always hold it high during reset and  
ensure that your system meets the VIH specification (see datasheet)  
to prevent inadvertent entry into a test mode.  
RESET#  
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 and idle modes,  
asserting RESET# causes the chip to reset and return to normal  
operating mode. The 8XC196MH provides the option of preventing an  
internal reset from generating a reset on the external pin (see  
“Resetting the Device” on page 13-8). After a device reset, the first  
instruction fetch is from 2080H.  
VPP  
PWR  
Programming Voltage  
During programming, the VPP pin is typically at +12.5 V (VPP voltage).  
Exceeding the maximum VPP voltage specification can damage the  
device.  
VPP also causes the device to exit powerdown mode when it is driven  
low for at least 50 ns. Use this method to exit powerdown only when  
using an external clock source because it enables the internal phase  
clocks, but not the internal oscillator.  
On devices with no internal nonvolatile memory, connect VPP to VCC  
.
Table 14-2. Operating Mode Control and Status Registers  
Address Description  
2018H Chip Configuration 0 Register  
Mnemonic  
CCR0  
Bit 0 of this register enables and disables powerdown mode.  
Interrupt Mask 1  
INT_MASK1  
0013H  
Bit 6 of this 8-bit register enables and disables (masks) the  
external interrupt (EXTINT).  
14-2  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SPECIAL OPERATING MODES  
Table 14-2. Operating Mode Control and Status Registers (Continued)  
Mnemonic  
Address  
Description  
P1_DIR (MH)  
P2_DIR  
P5_DIR  
1F9BH  
Port x Direction  
1FD2H  
1FF3H  
1FD3H  
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.)  
P7_DIR (MD)  
P1_MODE(MH) 1F99H  
Port x Mode  
P2_MODE  
P5_MODE  
P7_MODE(MD) 1FD1H  
1FD0H  
1FF1H  
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.  
P1_REG (MH)  
P2_REG  
P5_REG  
1F9DH  
1FD4H  
1FF5H  
1FD5H  
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.  
P7_REG (MD)  
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.  
14.2 REDUCING POWER CONSUMPTION  
Both power-saving modes conserve power by disabling portions of the internal clock circuitry  
(Figure 14-1). The following paragraphs describe both modes in detail.  
14-3  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Disable Clock Input  
(Powerdown)  
FXTAL1  
Divide-by-two  
Circuit  
XTAL1  
XTAL2  
Disable Clocks  
(Powerdown)  
Peripheral Clocks (PH1, PH2)  
CLKOUT  
Clock  
Generators  
Disable  
Oscillator  
CPU Clocks (PH1, PH2)  
(Powerdown)  
Disable Clocks  
(Idle, Powerdown)  
NOTE: The CLKOUT pin is unique to the 8XC196MC and MD.  
A3115-02  
Figure 14-1. Clock Control During Power-saving Modes  
14.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 peripheral clocks nor CLKOUT are affected, so the special-function reg-  
isters (SFRs) and register RAM retain their data and the peripherals and interrupt system remain  
active. Tables in Appendix B list the values of the pins during idle mode (see Table B-8 on page  
B-23 for the 8XC196MC and 8XC196MD or Table B-9 on page B-25 for the 8XC196MH).  
14-4  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SPECIAL OPERATING MODES  
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.  
NOTE  
If enabled, the watchdog timer continues to run in idle mode. The device must  
be awakened before the counter overflows; otherwise, the timer will reset the  
device. The watchdog timer interval is always 64K state times in the  
8XC196MC and MD, but a longer interval can be selected in the 8XC196MH  
(see “Enabling the Watchdog Timer” on page 13-12).  
To prevent an accidental return to full power, hold the external interrupt pin  
(EXTINT) low while the device is in idle mode.  
14.4 POWERDOWN MODE  
Powerdown mode places the device into a very low power state by disabling the internal oscilla-  
tor 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. Tables in Appendix B list the values of the pins during powerdown mode (see Table B-8  
on page B-23 for the 8XC196MC and 8XC196MD or Table B-9 on page B-25 for the  
8XC196MH). If VCC is maintained above the minimum specification, the special-function regis-  
ters (SFRs) and register RAM retain their data.  
14.4.1 Enabling and Disabling Powerdown Mode  
The PD bit in the chip configuration register 0 (CCR0.0) either enables or disables powerdown  
mode. Because CCR0 cannot be accessed by code, the PD bit value is defined in chip configura-  
tion byte 0 (CCB0.0). Setting the PD bit enables powerdown mode and clearing it disables pow-  
erdown. CCR0 is loaded from CCB0 when the device returns from reset. Refer to “Operating  
Environment” on page 16-17 for descriptions of the methods for programming the CCBs.  
14-5  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
14.4.2 Entering Powerdown Mode  
Before entering powerdown, complete the following tasks:  
Complete all serial port transmissions or receptions. Otherwise, when the device exits  
powerdown, the serial port activity will continue where it left off and incorrect data may be  
transmitted or received.  
Complete all analog conversions. If powerdown occurs during the conversion, the result  
will be incorrect.  
If the watchdog timer (WDT) is enabled, clear the WATCHDOG register just before issuing  
the powerdown instruction. This ensures that the device can exit powerdown cleanly.  
Otherwise, the WDT could reset the device before the oscillator stabilizes. (The WDT  
cannot reset the device during powerdown because the clock is stopped.)  
Put all other peripherals into an inactive state.  
After completing these tasks, execute the IDLPD #2 instruction to enter powerdown mode.  
NOTE  
To prevent an accidental return to full power, hold the external interrupt pin  
(EXTINT) low while the device is in powerdown mode.  
14.4.3 Exiting Powerdown Mode  
The device will exit powerdown mode when any of the following events occurs:  
an external device drives the VPP pin low for at least 50 ns  
a hardware reset is generated  
a transition occurs on the external interrupt pin  
14.4.3.1  
Driving the VPP Pin Low  
If the design uses an external clock input signal rather than the on-chip oscillator, the fastest way  
to exit powerdown mode is to drive the VPP pin low for at least 50 ns. Use this method only when  
using an external clock input because the internal CPU and peripheral clocks will be enabled, but  
the internal oscillator will not.  
14.4.3.2  
Generating a Hardware Reset  
The device will exit powerdown if RESET# is asserted. 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 has sta-  
bilized.  
14-6  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SPECIAL OPERATING MODES  
14.4.3.3  
Asserting the External Interrupt Signal  
The final way to exit powerdown mode is to assert the external interrupt signal (EXTINT) for at  
least 50 ns. Although EXTINT is normally a sampled input, the powerdown circuitry uses it as a  
level-sensitive input. The interrupt 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 Configura-  
tions” on page 6-9). Figure 14-2 shows the power-up and power-down sequence 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  
Internal Powerdown  
Signal  
EXTINT  
V
PP  
Timeout  
(Internal)  
A0078-01  
Figure 14-2. Power-up and Power-down Sequence When Using an External Interrupt  
When using an external interrupt signal to exit powerdown mode, we recommend that you con-  
nect the external RC circuit shown in Figure 14-3 to the VPP pin. The discharging of the capacitor  
causes a delay that allows the oscillator to stabilize before the internal CPU and peripheral clocks  
are enabled.  
14-7  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
V
CC  
8XC196  
Device  
R
1 MTypical  
1
V
PP  
C
1µF Typical  
1
A0279-01  
Figure 14-3. External RC Circuit  
During normal operation (before entering powerdown mode), an internal pull-up holds the  
VPP pin at VCC. When an external interrupt signal is asserted, the internal oscillator circuitry is  
enabled and turns on a weak internal pull-down. This weak pull-down causes the external capac-  
itor (C1) to begin discharging at a typical rate of 200 µA. When the VPP pin voltage drops below  
the threshold voltage (about 2.5 V), the internal phase clocks are enabled and the device resumes  
code execution.  
At this time, the internal pull-up transistor turns on and quickly pulls the pin back up to about  
3.5 V. The pull-up becomes ineffective and the external resistor (R1) takes over and pulls the volt-  
age up to VCC (see recovery time in Figure 14-4). The time constant follows an exponential charg-  
ing curve. If R1 = 1 Mand C1 = 1 µF, the recovery time will be one second.  
14.4.3.4  
Selecting R1 and C1  
The values of R1 and C1 are not critical. Select components that produce a sufficient discharge  
time to permit the internal oscillator circuitry to stabilize. Because many factors can influence the  
discharge time requirement, you should always fully characterize your design under worst-case  
conditions to verify proper operation.  
14-8  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SPECIAL OPERATING MODES  
5
4
EXTINT  
3
200 µA C Discharge  
1
R
x C Recovery  
V
, Volts  
1
1
PP  
Time Constant  
2
Pullup On  
Code Execution Resumes  
1
2
4
6
8
10  
12  
14  
16  
18  
20  
22  
Time, ms  
A0151-01  
Figure 14-4. Typical Voltage on the VPP Pin While Exiting Powerdown  
Select a resistor that will not interfere with the discharge current. In most cases, values between  
200 kand 1 Mshould perform satisfactorily.  
14-9  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
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.  
TDIS × I  
-------------------  
C1  
=
Vt  
where:  
C1  
TDIS  
I
is the capacitor value, in farads  
is the worst-case discharge time, in seconds  
is the discharge current, in amperes  
is the threshold voltage  
V
t
NOTE  
If powerdown is re-entered and exited before C1 charges to VCC, it will take  
less time for the voltage to ramp down to the threshold. Therefore, the device  
will take less time to exit powerdown.  
For example, assume that the oscillator needs at least 12.5 ms to discharge (TDIS = 12.5 ms), V  
t
is 2.5 V, and the discharge current is 200 µA. The minimum C1 capacitor size is 1 µF.  
(0.0125) (0.0002)  
--------------------------------------------------  
= 1 µF  
C 1  
=
2.5  
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.  
(1.0 × 1010) (2.5)  
C1 × Vt  
------------------  
--------------------------------------------------  
= 1.25 µs  
TDIS  
=
=
I
0.0002  
14.5 ONCE MODE  
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.  
14-10  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SPECIAL OPERATING MODES  
Holding the ONCE# signal low during the rising edge of RESET# causes the device to enter  
ONCE mode. To prevent accidental entry into ONCE mode, we highly recommend configuring  
this pin as an output. If you choose to configure this pin as an input, always hold it high during  
reset and ensure that your system meets the VIH specification (see datasheet) to prevent inadvert-  
ent entry into ONCE mode.  
Exit ONCE mode by asserting the RESET# signal and allowing the ONCE# pin to float or be  
pulled high. Normal operations resume when RESET# goes high.  
14.6 RESERVED TEST MODES  
A special test-mode-entry pin (P2.6) is provided for Intel’s in-house testing only. These test  
modes can be entered accidentally if you configure the test-mode-entry pin as an input and hold  
it low during the rising edge of RESET#. To prevent accidental entry into an unsupported test  
mode, we highly recommend configuring the test-mode-entry pin as an output. If you choose to  
configure this pin as an input, always hold it high during reset and ensure that your system meets  
theVIH specification (see datasheet) to prevent inadvertent entry into an unsupported test mode.  
14-11  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
15  
Interfacing with  
External Memory  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
CHAPTER 15  
INTERFACING WITH EXTERNAL MEMORY  
The microcontroller can interface with a variety of external memory devices. It supports either a  
fixed 8-bit data bus width, a fixed 16-bit data bus width, or a dynamic 8-bit/16-bit data bus width;  
internal control of wait states for slow external memory devices; and several bus-control modes.  
These features provide a great deal of flexibility when interfacing with external memory systems.  
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.  
15.1 EXTERNAL MEMORY INTERFACE SIGNALS AND REGISTERS  
Table 15-1 lists the signals and Table 15-2 lists the registers that are mentioned in this chapter.  
Many of the external memory interface signals are multiplexed with standard I/O port signals, as  
shown in the Port Pin column. Table 15-3 gives the port register settings to configure the pins as  
external memory interface signals rather than standard I/O port signals. See Chapter 6, “I/O  
Ports,” to configure the pins as standard I/O port signals.  
Table 15-1. External Memory Interface Signals  
Signal  
Port Pin  
Type  
Description  
Name  
AD15:0  
P4.7:0  
P3.7:0  
I/O  
Address/Data Lines  
These pins provide a multiplexed address and data bus. During the  
address phase of the bus cycle, address bits 0–15 are presented on  
the bus and can be latched using ALE or ADV#. During the data  
phase, 8- or 16-bit data is transferred.  
ADV#  
P5.0  
O
Address Valid  
This active-low output signal is asserted only during external memory  
accesses. ADV# indicates that valid address information is available  
on the system address/data bus. The signal remains low while a valid  
bus cycle is in progress and is returned high as soon as the bus cycle  
completes.  
An external latch can use this signal to demultiplex the address from  
the address/data bus. A decoder can also use this signal to generate  
chip selects for external memory.  
15-1  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 15-1. External Memory Interface Signals (Continued)  
Signal  
Name  
Port Pin  
P5.0  
Type  
Description  
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. 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 the address from  
the address/data bus.  
BHE#  
P5.5  
O
Byte High Enable†  
During 16-bit bus cycles, this active-low output signal is asserted for  
word 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 AD0, to determine  
which memory byte is being transferred over the system bus:  
BHE#  
AD0 Byte(s) Accessed  
0
0
1
0
1
0
both bytes  
high byte only  
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#.  
BUSWIDTH P5.7  
I
Bus Width  
Two chip configuration register bits, CCR0.1 and CCR1.2, along with  
the BUSWIDTH pin, control the data bus width. When both CCR bits  
are set, the BUSWIDTH signal selects the external data bus width.  
When only one CCR bit is set, the bus width is fixed at either 16 or 8  
bits, and the BUSWIDTH signal has no effect.  
CCR0.1 CCR1.2 BUSWIDTH  
0
1
1
1
1
0
1
1
X
X
high  
low  
fixed 8-bit data bus  
fixed 16-bit data bus  
16-bit data bus  
8-bit data bus  
CLKOUT  
(MC, MD)  
O
Clock Output  
Output of the internal clock generator. The CLKOUT frequency is ½  
the oscillator input frequency (FXTAL1). CLKOUT has a 50% duty cycle.  
15-2  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INTERFACING WITH EXTERNAL MEMORY  
Table 15-1. External Memory Interface Signals (Continued)  
Signal  
Name  
Port Pin  
Type  
Description  
EA#  
I
External Access  
This input determines whether memory accesses to special-purpose  
and program memory partitions are directed to internal or external  
memory. (See Table 4-1 on page 4-2 for address ranges of special-  
purpose and program memory partitions.) 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# also controls entry into the programming modes. If EA# is at VPP  
voltage (typically +12.5 V) on the rising edge of RESET#, the micro-  
controller enters a programming mode.  
NOTE: Systems with EA# tied inactive have idle time between  
external bus cycles. When the address/data bus is idle, you  
can use ports 3 and 4 for I/O. Systems with EA# tied active  
cannot use ports 3 and 4 as standard I/O; when EA# is  
active, these ports will function only as the address/data bus.  
EA# is sampled and latched only on the rising edge of RESET#.  
Changing the level of EA# after reset has no effect.  
Always connect EA# to VSS when using a microcontroller that has no  
internal nonvolatile memory.  
INST  
P5.1  
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.  
RD#  
P5.3  
P5.6  
O
I
Read  
Read-signal output to external memory. RD# is asserted only during  
external memory reads.  
READY  
Ready Input  
This active high input along with the chip configuration registers  
determine the number of wait states inserted into the bus cycle. The  
chip configuration registers selects the maximum number of wait  
states (0, 1, 2, 3, or infinite) that can be inserted into the bus cycle.  
While READY is low, wait states are inserted into the bus cycle until  
the programmed number of wait states is reached. If READY is pulled  
high before the programmed number of wait states is reached, no  
additional wait states will be inserted into the bus cycle.  
WR#  
P5.2  
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#.  
15-3  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 15-1. External Memory Interface Signals (Continued)  
Signal  
Name  
Port Pin  
P5.5  
Type  
Description  
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#  
P5.2  
O
Write Low†  
During 16-bit bus cycles, this active-low output signal is asserted for  
low-byte writes and word writes to external memory. 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#.  
Table 15-2. External Memory Interface Registers  
Address Description  
2018H  
Register  
Mnemonic  
CCR0  
Chip Configuration 0  
Controls powerdown mode, bus-control signals, and internal memory  
protection. Three of its bits combine with two bits of CCR1 to control wait  
states and bus width.  
CCR1  
201AH  
1FF3H  
Chip Configuration 1  
Enables the watchdog timer and selects the bus timing mode. Two of its bits  
combine with three bits of CCR0 to control wait states and bus width.  
P5_DIR  
Port 5 Direction  
Each bit of P5_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.)  
P5_MODE  
P5_PIN  
1FF1H  
1FF7H  
Port 5 Mode  
Each bit of P5_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.  
Port 5 Input  
Each bit of P5_PIN reflects the current state of the corresponding pin,  
regardless of the pin configuration.  
15-4  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INTERFACING WITH EXTERNAL MEMORY  
Table 15-2. External Memory Interface Registers (Continued)  
Register  
Mnemonic  
Address  
Description  
P5_REG  
1FF5H  
Port 5 Data Output  
For an input, regardless of the pin’s configuration, set the corresponding  
P5_REG bit.  
For an output, write the data to be driven out by each pin to the corre-  
sponding bit of P5_REG. When a pin is configured as standard I/O  
(P5_MODE.y = 0), the result of a CPU write to P5_REG is immediately  
visible on the pin. When a pin is configured as a special-function signal  
(P5_MODE.y = 1), the associated on-chip peripheral or off-chip component  
controls the pin. The CPU can still write to P5_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  
P5_MODE.y), initialize or overwrite the pin value, then configure the pin as a  
special-function signal (set P5_MODE.y). In this way, initialization, fault  
recovery, exception handling, etc., can be done without changing the  
operation of the associated peripheral.  
Table 15-3. Register Settings for Configuring External Memory Interface Signals  
External Memory Interface  
Port Pin  
Signal Type  
Port Register Settings  
Signal Name  
P5.0  
P5.1  
P5.2  
P5.3  
P5.5  
P5.6  
P5.7  
ALE/ADV#  
O
O
O
O
O
I
P5_DIR = 110X 0000B  
INST  
WR#/WRL#†  
P5_MODE = 111X 1111B  
P5_REG = 11XX XXXXB  
RD#  
BHE#/WRH#†  
READY  
BUSWIDTH (Kx)  
I
The chip configuration register 0 (CCR0), which is loaded at reset from the chip configuration byte 0  
(CCB0, 2018H) during normal operation, determines whether P5.2 functions as BHE# or WRH# and  
whether P5.5 functions as WR# or WRL#. CCR0.2 = 1 selects BHE# and WR#; CCR0.2 = 1 selects  
WRH# and WRL#.  
15.2 CHIP CONFIGURATION REGISTERS AND CHIP CONFIGURATION BYTES  
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 reside in nonvolatile memory at addresses 2018H (CCB0) and  
201AH (CCB1).  
15-5  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
When the microcontroller 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 mi-  
crocontroller is reset again. The CCR bits are described in Figures 15-1 and 15-2. (Refer to Chap-  
ter 16, “Programming the Nonvolatile Memory,” for descriptions of the methods for  
programming the CCBs.)  
15-6  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INTERFACING WITH EXTERNAL MEMORY  
no direct access†  
CCR0  
The chip configuration 0 (CCR0) register controls powerdown mode, bus-control signals, and internal  
memory protection. Three of its bits combine with two bits of CCR1 to control wait states and bus  
width.  
7
0
LOC1  
LOC0  
IRC1  
IRC0  
ALE  
WR  
BW0  
PD  
Bit  
Number  
Bit  
Mnemonic  
Function  
7:6  
LOC1:0  
Lock Bits  
These two bits control read and write access to the OTPROM during  
normal operation. Refer to “Controlling Access to the OTPROM During  
Normal Operation” on page 16-4 for details.  
LOC1 LOC0  
0
0
1
1
0
1
0
1
read and write protect  
read protect only  
write protect only  
no protection  
5:4  
IRC1:0  
Internal Ready Control  
These two bits, along with IRC2 (CCR1.1) and the READY pin determine  
the number of wait states that can be inserted into the bus cycle. While  
READY is held low, wait states are inserted into the bus cycle until the  
programmed number of wait states is reached. If READY is pulled high  
before the programmed number of wait states is reached, no additional  
wait states will be inserted into the bus cycle.  
IRC2 IRC1 IRC0  
0
0
1
1
1
1
1
0
X
1
0
0
1
1
0
1
X
0
1
0
1
zero wait states  
illegal  
illegal  
one wait state  
two wait states  
three wait states  
infinite  
If you choose the infinite wait states option, you must keep P5.6  
configured as the READY signal. Also, be sure to add external hardware  
to count wait states and pull READY high within a specified time.  
Otherwise, a defective external device could tie up the address/data bus  
indefinitely.  
The CCRs are loaded with the contents of the chip configuration bytes (CCBs) after reset, unless the  
microcontroller is entering programming modes (see “Entering Programming Modes” on page 16-13),  
in which case the programming chip configuration bytes (PCCBs) are used. The CCBs reside in  
nonvolatile memory at addresses 2018H (CCB0) and 201AH (CCB1).  
Figure 15-1. Chip Configuration 0 (CCR0) Register  
15-7  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
CCR0 (Continued)  
no direct access†  
The chip configuration 0 (CCR0) register controls powerdown mode, bus-control signals, and internal  
memory protection. Three of its bits combine with two bits of CCR1 to control wait states and bus  
width.  
7
0
LOC1  
LOC0  
IRC1  
IRC0  
ALE  
WR  
BW0  
PD  
Bit  
Number  
Bit  
Mnemonic  
Function  
Address Valid Strobe and Write Strobe  
3
ALE  
These bits define which bus-control signals will be generated during  
external read and write cycles.  
2
WR  
ALE WR  
0
0
1
1
0
1
0
1
address valid with write strobe mode  
(ADV#, RD#, WRL#, WRH#)  
address valid strobe mode  
(ADV#, RD#, WR#, BHE#)  
write strobe mode  
(ALE, RD#, WRL#, WRH#)  
standard bus-control mode  
(ALE, RD#, WR#, BHE#)  
1
BW0  
Buswidth Control  
This bit, along with the BW1 bit (CCR1.2), selects the bus width.  
BW1 BW0  
0
0
1
1
0
1
0
1
illegal  
16-bit only  
8-bit only  
BUSWIDTH pin controlled  
0
PD  
Powerdown Enable  
Controls whether the IDLPD #2 instruction causes the microcontroller to  
enter powerdown mode. If your design uses powerdown 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 mode.  
0 = disable powerdown mode  
1 = enable powerdown mode  
The CCRs are loaded with the contents of the chip configuration bytes (CCBs) after reset, unless the  
microcontroller is entering programming modes (see “Entering Programming Modes” on page 16-13),  
in which case the programming chip configuration bytes (PCCBs) are used. The CCBs reside in  
nonvolatile memory at addresses 2018H (CCB0) and 201AH (CCB1).  
Figure 15-1. Chip Configuration 0 (CCR0) Register (Continued)  
15-8  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INTERFACING WITH EXTERNAL MEMORY  
no direct access†  
CCR1  
The chip configuration 1 (CCR1) register enables the watchdog timer and selects the bus timing  
mode. Two of its bits combine with three bits of CCR0 to control wait states and bus width.  
7
0
1
1
0
1
WDE  
BW1  
IRC2  
0
Bit  
Number  
Bit  
Mnemonic  
Function  
7:6  
1
To guarantee proper operation, write ones to these bits.  
To guarantee proper operation, write zero to this bit.  
To guarantee proper operation, write one to this bit.  
Watchdog Timer Enable  
5
4
3
0
1
WDE  
Selects whether the watchdog timer is always enabled or enabled the  
first time it is cleared.  
0 = always enabled  
1 = enabled first time it is cleared  
2
BW1  
Buswidth Control  
This bit, along with the BW0 bit (CCR0.1), selects the bus width.  
BW1 BW0  
0
0
1
1
0
1
0
1
illegal  
16-bit only  
8-bit only  
BUSWIDTH pin controlled  
The CCRs are loaded with the contents of the chip configuration bytes (CCBs) after reset, unless  
the microcontroller is entering programming modes (see “Entering Programming Modes” on page  
16-13), in which case the programming chip configuration bytes (PCCBs) are used. The CCBs  
reside in nonvolatile memory at addresses 2018H (CCB0) and 201AH (CCB1).  
Figure 15-2. Chip Configuration 1 (CCR1) Register  
15-9  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
CCR1 (Continued)  
no direct access†  
The chip configuration 1 (CCR1) register enables the watchdog timer and selects the bus timing  
mode. Two of its bits combine with three bits of CCR0 to control wait states and bus width.  
7
0
1
1
0
1
WDE  
BW1  
IRC2  
0
Bit  
Number  
Bit  
Mnemonic  
Function  
1
IRC2  
Ready Control  
This bit, along with IRC0 (CCR0.4), IRC1 (CCR0.5), and the READY pin  
determine the number of wait states that can be inserted into the bus  
cycle. While READY is held low, wait states are inserted into the bus  
cycle until the programmed number of wait states is reached. If READY is  
pulled high before the programmed number of wait states is reached, no  
additional wait states will be inserted into the bus cycle.  
IRC2 IRC1 IRC0  
0
0
1
1
1
1
1
0
X
1
0
0
1
1
0
1
X
0
1
0
1
zero wait states  
illegal  
illegal  
one wait state  
two wait states  
three wait states  
infinite  
If you choose the infinite wait states option, you must keep P5.6  
configured as the READY signal. Also, be sure to add external hardware  
to count wait states and pull READY high within a specified time.  
Otherwise, a defective external device could tie up the address/data bus  
indefinitely.  
0
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 reset, unless  
the microcontroller is entering programming modes (see “Entering Programming Modes” on page  
16-13), in which case the programming chip configuration bytes (PCCBs) are used. The CCBs  
reside in nonvolatile memory at addresses 2018H (CCB0) and 201AH (CCB1).  
Figure 15-2. Chip Configuration 1 (CCR1) Register  
15.3 BUS WIDTH AND MULTIPLEXING  
The external bus can operate as either a 16-bit multiplexed address/data bus or as a multiplexed  
16-bit address/8-bit data bus (Figure 15-3).  
15-10  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INTERFACING WITH EXTERNAL MEMORY  
Bus Control  
Bus Control  
8-bit Address  
High  
16-bit Multiplexed  
Address/Data  
AD15:8  
(Port 4)  
AD15:0  
(Ports 4 and 3)  
8-bit Multiplexed  
Address/Data  
AD7:0  
(Port 3)  
8XC196  
8XC196  
16-bit Bus  
8-bit Bus  
A3068-01  
Figure 15-3. Multiplexing and Bus Width Options  
After reset, but before the CCB fetch, the microcontroller is configured for 8-bit bus mode, re-  
gardless of the BUSWIDTH input. The upper address lines (AD15:8) are weakly driven through-  
out the CCB0 and CCB1 bus cycles. To prevent bus contention, neither pull-ups nor pull-downs  
should be used on AD15:8. Also, the upper bytes of the CCB words (locations 2019H and  
201BH) should be loaded with 20H. If the external memory outputs 20H on its high byte, there  
will be no bus contention.  
After the CCBs are loaded into the CCRs, the values of BW0 and BW1 define the data bus width  
as either a fixed 8-bit, a fixed 16-bit, or a dynamic 16-bit/8-bit bus width controlled by the  
BUSWIDTH signal. (The BW0 and BW1 bits are defined in Figures 15-1 and 15-2.)  
If BW0 is clear and BW1 is set, the bus controller is locked into an 8-bit bus mode. In comparing  
an 8-bit bus system to a 16-bit bus system, expect some performance degradation. In a 16-bit bus  
system, a word fetch is done with a single word fetch. However, in an 8-bit bus system, a word  
fetch takes an additional bus cycle because it must be done with two byte fetches.  
If BW0 is set and BW1 is clear, the bus controller is locked into a 16-bit bus mode. If both BW0  
and BW1 are set, the BUSWIDTH signal controls the bus width. The bus is 16 bits wide when  
BUSWIDTH is high, and 8 bits wide when BUSWIDTH is low. The BUSWIDTH signal is sam-  
pled after the address is on the bus, as shown in Figures 15-4 and 15-5.  
15-11  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
T
XTAL1  
XTAL1  
CLKOUT  
ALE  
BUSWIDTH  
AD15:0  
T
(min)  
CLGX  
Valid  
T
AVGV  
Data In  
Address Out  
The CLKOUT pin is available only on the 8XC196MC, MD.  
A3162-01  
Figure 15-4. BUSWIDTH Timing Diagram (8XC196MC, MD)  
T
XTAL1  
XTAL1  
ALE  
T
AVGV  
T
BUSWIDTH  
AD15:0  
LLGV  
(max)  
T
LLGX  
(min)  
Address Out  
Data In  
A3169-01  
Figure 15-5. BUSWIDTH Timing Diagram (8XC196MH)  
15-12  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INTERFACING WITH EXTERNAL MEMORY  
.
Table 15-4. BUSWIDTH Signal Timing Definitions  
Definition  
Symbol  
TAVGV  
Address Valid to BUSWIDTH Setup  
Maximum time the external device has to assert or deassert BUSWIDTH after the microcon-  
troller outputs the address.  
TCLGX  
TLLGV  
TLLGX  
BUSWIDTH Hold after CLKOUT Low  
Minimum time the level of the BUSWIDTH signal must be valid after CLKOUT falls.  
††  
††  
ALE Low to BUSWIDTH Setup  
Maximum time the external device has to assert or deassert BUSWIDTH after ALE falls.  
BUSWIDTH Hold after ALE Low  
Minimum time the level of the BUSWIDTH signal must be valid after ALE falls.  
TXTAL1  
1/FXTAL1  
All AC timings are referenced to TXTAL1  
.
This specification applies to the 8XC196MC, MD microcontrollers only.  
This specification applies to the 8XC196MH microcontroller only.  
††  
The BUSWIDTH signal can be used in numerous applications. For example, a system could store  
code in a 16-bit memory device and data in an 8-bit memory device. The BUSWIDTH signal  
could be tied to the chip-select input of the 8-bit memory device (shown in Figure 15-13 on page  
15-24). When BUSWIDTH is low, it enables 8-bit bus mode and selects the 8-bit memory device.  
When BUSWIDTH is high, it enables 16-bit bus mode and deselects the 8-bit memory device.  
15.3.1 Timing Requirements for BUSWIDTH  
When using BUSWIDTH to dynamically change between 8-bit and 16-bit bus widths, setup and  
hold timings must be met for proper operation (see Figures 15-4 and 15-5, and Table 15-4). Be-  
cause a decoded, valid address is used to generate the BUSWIDTH signal, the setup time is spec-  
ified relative to the address being valid. This specification, TAVGV, indicates how much time an  
external device has to decode the valid address and generate a valid BUSWIDTH signal. As  
shown in Figure 15-5, the 8XC196MH has an additional BUSWIDTH setup timing specification.  
This specification, TLLGV, indicates how much time an external device has to generate a valid  
BUSWIDTH signal after ALE falls.  
BUSWIDTH must be held valid until the minimum hold specification, TCLGX (for 8XC196MC,  
MD) or TLLGX (for 8XC196MH), has been met. Refer to the datasheet for the current TAVGV  
,
TCLGX, and TLLGX specifications.  
15-13  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
15.3.2 16-bit Bus Timings  
When the microcontroller is configured to operate in the 16-bit bus-width mode, lines AD15:0  
form a 16-bit multiplexed address/data bus. Figure 15-6 shows an idealized timing diagram for  
the external read and write cycles. Comprehensive timing specifications are shown in Figure  
15-22 on page 15-32.  
The rising edge of the address latch enable (ALE) signal indicates that the microcontroller is driv-  
ing an address onto the bus (AD15:0). The microcontroller presents a valid address before ALE  
falls. 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.  
For 16-bit read cycles, the bus controller floats the bus and then drives RD# low so that it can  
receive data. The external memory must put data (Data In) onto the bus before the rising edge of  
RD#. The datasheet specifies the maximum time the memory device has to output valid data after  
RD# is asserted (TRLDV). When INST is asserted, it indicates that the read operation is an instruc-  
tion fetch.  
For 16-bit write cycles, the bus controller drives WR# low, then puts data onto the bus. The rising  
edge of WR# signifies that data is valid. At this time, the external system must latch the data.  
15-14  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INTERFACING WITH EXTERNAL MEMORY  
XTAL1  
CLKOUT  
ALE  
Valid  
BUSWIDTH  
AD15:0  
(read)  
Address Out  
Data In  
RD#  
INST  
Valid  
AD15:0  
(write)  
Address Out  
Data Out  
WR#  
The CLKOUT pin is available only on the 8XC196MC, MD.  
A3163-01  
Figure 15-6. Timings for 16-bit Buses  
15-15  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
15.3.3 8-bit Bus Timings  
When the microcontroller is configured to operate in the 8-bit bus mode, lines AD7:0 form a mul-  
tiplexed lower address and data bus. Lines AD15:8 are not multiplexed; the upper address is  
latched and remains valid throughout the bus cycle. Figure 15-7 shows an idealized timing dia-  
gram for the external read and write cycles. 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 ac-  
cesses the upper byte. Except for requiring an extra cycle to write the bytes separately, the timings  
are the same as on the 16-bit bus.  
The ALE signal is used to demultiplex the lower address by strobing a transparent latch (such as  
a 74AC373).  
For 8-bit bus read cycles, after ALE falls, the bus controller floats the bus and drives the RD#  
signal low. The external memory then must put its data on the bus. That data must be valid at the  
rising edge of the RD# signal. To read a data word, the bus controller performs two consecutive  
reads, reading the low byte first, followed by the high byte.  
For 8-bit bus write cycles, after ALE falls, the bus controller outputs data on AD7:0 and then  
drives WR# low. The external memory must latch the data by the time WR# goes high. That data  
will be valid on the bus until slightly after WR# goes high. To write a data word, the bus controller  
performs two consecutive writes, writing the low byte first, followed by the high byte.  
15-16  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INTERFACING WITH EXTERNAL MEMORY  
XTAL1  
CLKOUT  
ALE  
BUSWIDTH  
AD15:8  
Address Out  
Low data in  
Address Out  
AD7:0  
(read)  
Address  
Out  
Address  
High data in  
+1 Out  
RD#  
INST  
AD7:0  
(write)  
Address  
Out  
Address  
Low data out  
High data out  
+1 Out  
WR#  
The CLKOUT pin is available only on the 8XC196MC, MD.  
A3164-01  
Figure 15-7. Timings for 8-bit Buses  
15.4 WAIT STATES (READY CONTROL)  
An external device can use the READY input to lengthen an external bus cycle. When an external  
address is placed on the bus, the external device can pull the READY signal low to indicate it is  
not ready. In response, the microcontroller inserts wait states to lengthen the bus cycle until the  
external device raises the READY signal. Each wait state adds one state time (2TXTAL1) to the bus  
cycle.  
After reset and until CCB1 is fetched, the bus controller always inserts three wait states into bus  
cycles. Then, until P5.6 has been configured to operate as the READY signal, the internal ready  
control bits (IRC2:0) control the wait states.  
15-17  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
After the CCB1 fetch, the internal ready control circuitry allows slow external memory devices  
to increase the length of the read and write bus cycles. If the external memory device is not ready  
for access, it pulls the READY signal low and holds it low until it is ready to complete the oper-  
ation, at which time it releases READY. While READY is low, the bus controller inserts wait  
states into the bus cycle.  
The internal ready control bits, CCR0.5, CCR0.4, and CCR1.1 shown in Figures 15-1 and 15-2,  
define the maximum number of wait states (0, 1, 2, 3, or infinite) that will be inserted into the bus  
cycle. While READY is low, wait states are inserted into the bus cycle until the programmed  
number of wait states is reached. If READY is pulled high before the programmed number of wait  
states is reached, no additional wait states will be inserted into the bus cycle.  
If you choose the infinite wait states option, you must keep P5.6 configured as the READY signal.  
Also, be sure to add external hardware to count wait states and pull READY high within a spec-  
ified 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 Figures 15-8 and 15-9, and Table 15-5). 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. As shown in Figure 15-9, the 8XC196MH has an addi-  
tional READY setup timing specification. This specification, TLLYV, indicates how much time an  
external device has to deassert the READY signal after ALE falls.  
The READY signal must be held low until the minimum TCLYX timing specification is met. Do  
not exceed the maximum TCLYX or TLLYX specification or additional (unwanted) wait states might  
be added. Refer to the datasheets for the current TAVYV , TCLYX, and TLLYX specifications.  
15-18  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INTERFACING WITH EXTERNAL MEMORY  
CLKOUT  
TCLYX  
(max)  
ALE  
READY  
RD#  
T
CLYX (min)  
TAVYV  
Address Out  
Data  
AD15:0  
(read)  
WR#  
AD15:0  
(write)  
Address  
Address Out  
Data Out  
The CLKOUT pin is available only on the 8XC196MC, MD.  
A3165-01  
Figure 15-8. READY Timing Diagram — One Wait State (8XC196MC, MD)  
15-19  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
T
XTAL1  
XTAL1  
T
+ 2T  
XTAL1  
LHLH  
ALE  
T
LLYX (max)  
T
LLYX (min)  
T
LLYV  
READY  
RD#  
16 MHz  
8 MHz  
T
T
+ 2T  
RLRH XTAL1  
AVYV  
T
+ 2T  
XTAL1  
RLDV  
T
+ 2T  
AVDV  
XTAL1  
AD15:0  
(read)  
Address Out  
Data In  
T
+ 2T  
WLWH  
XTAL1  
WR#  
T
+ 2T  
RLDV  
T
XTAL1  
+ 2T  
QVWH  
XTAL1  
AD15:0  
(write)  
Address Out  
Data Out  
Address  
A3167-01  
Figure 15-9. READY Timing Diagram — One Wait State (8XC196MH)  
Table 15-5. READY Signal Timing Definitions  
Definition  
Symbol  
TAVYV  
Address Valid to READY Setup  
Maximum time the external device has to deassert READY after the microcontroller outputs  
the address to guarantee that at least one wait state will occur.  
TCLYX  
READY Hold after CLKOUT Low  
Minimum time the level of the READY signal must be valid after CLKOUT falls.  
TLHLH  
ALE Cycle Time  
Minimum time between ALE pulses.  
This specification applies to the 8XC196MC, MD microcontrollers only.  
This specification applies to the 8XC196MH microcontroller only.  
††  
15-20  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INTERFACING WITH EXTERNAL MEMORY  
Table 15-5. READY Signal Timing Definitions (Continued)  
Definition  
Symbol  
††  
TLLYX  
READY Hold after ALE Low  
Minimum time the level of the READY signal must be valid after ALE falls. If the maximum  
value is exceeded, additional wait states will occur.  
††  
TLLYV  
ALE Low to READY Setup  
Maximum time the external device has to deassert READY after ALE falls.  
TQVWH  
Data Valid to WR# High  
Time between data being valid on the bus and the microcontroller deasserting WR#.  
TRLDV  
RD# Low to Input Data Valid  
Maximum time the memory system has to output valid data after the microcontroller asserts  
RD#.  
TRLRH  
RD# Low to RD# High  
RD# pulse width.  
TWLWH  
WR# Low to WR# High  
WR# pulse width.  
TXTAL1  
1/FXTAL1  
All AC timings are referenced to TXTAL1  
.
This specification applies to the 8XC196MC, MD microcontrollers only.  
This specification applies to the 8XC196MH microcontroller only.  
††  
15.5 BUS-CONTROL MODES  
The ALE and WR bits (CCR0.3 and CCR0.2) define which bus-control signals will be generated  
during external read and write cycles. Table 15-6 lists the four bus-control modes and shows the  
CCR0.3 and CCR0.2 settings for each.  
.
Table 15-6. Bus-control Modes  
CCR0.3  
(ALE)  
CCR0.2  
(WR)  
Bus-control Mode  
Bus-control Signals  
Standard Bus-control Mode  
Write Strobe Mode  
ALE, RD#, WR#, BHE#  
ALE, RD#, WRL#, WRH#  
ADV#, RD#, WR#, BHE#  
ADV#, RD#, WRL#, WRH#  
1
1
0
0
1
0
1
0
Address Valid Strobe Mode  
Address Valid with Write Strobe Mode  
15-21  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
15.5.1 Standard Bus-control Mode  
In the standard bus-control mode, the microcontroller generates the standard bus-control signals:  
ALE, RD#, WR#, and BHE# (see Figure 15-10). ALE is asserted while the address is driven, and  
it can be used to latch the address externally. RD# is asserted for every external memory read, and  
WR# is asserted for every external memory write. When asserted, BHE# selects the bank of mem-  
ory that is addressed by the high byte of the data bus.  
ALE  
WR# or RD#  
BHE#  
ALE  
WR# or RD#  
AD7:0  
Valid  
Addr Low  
Data Out  
AD15:0  
AD15:8  
Address High  
8-bit Bus Cycle  
Addr  
Data Out  
16-bit Bus Cycle  
A3077-01  
Figure 15-10. Standard Bus Control  
When the microcontroller is configured to use a 16-bit bus, separate low- and high-byte write sig-  
nals must be generated for single-byte writes. Figure 15-11 shows a sample circuit that combines  
BHE# and AD0 to produce these signals (WRL# and WRH#). A similar pair of signals for read  
is unnecessary. For a single-byte read with the 16-bit bus, both bytes are placed on the data bus  
and the processor discards the unwanted byte.  
BHE#  
WRH#  
WR#  
WRL#  
74AC  
373  
A0  
AD0  
A3109-03  
Figure 15-11. Decoding WRL# and WRH#  
15-22  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INTERFACING WITH EXTERNAL MEMORY  
Figure 15-12 shows an 8-bit system with both flash and RAM. The flash is the lower half of mem-  
ory, and the RAM is the upper half. This system configuration uses the most-significant address  
bit (AD15) as the chip-select signal and ALE as the address-latch signal.  
CS#  
CS#  
AD15  
AD14:8  
A14:8  
D7:0  
A12:8  
D7:0  
32K×8  
Flash  
8K×8  
RAM  
8XC196  
(28F256)  
A7:0  
74AC  
373  
A7:0  
A7:0  
AD7:0  
ALE  
LE  
OE#  
OE#  
WE#  
RD#  
WR#  
A3140-01  
Figure 15-12. 8-bit System with Flash and RAM  
15-23  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Figure 15-13 shows a system that uses the dynamic bus-width feature. (The CCR bits, BW0 and  
BW1, are set.) Code is executed from the two EPROMs and data is stored in the byte-wide RAM.  
The RAM is in high memory. It is selected by driving AD15 high, which also selects the 8-bit  
bus-width mode by driving the BUSWIDTH signal low.  
BUSWIDTH  
CS#  
CS#  
CS#  
A15  
A14:8  
A14:8  
A12:8  
74AC  
373  
A13:7  
D15:8  
A13:7  
A12:8  
AD15:8  
ALE  
LE  
D7:0  
D7:0  
16K×8  
EPROM  
(High)  
16K×8  
EPROM  
(Low)  
8K×8  
RAM  
8XC196  
LE  
A7:1  
A7:1  
A7:0  
74AC  
373  
A6:0  
A6:0  
A7:0  
AD7:0  
OE#  
OE#  
OE#  
WE#  
RD#  
WR#  
A3087-01  
Figure 15-13. 16-bit System with Dynamic Bus Width  
15-24  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INTERFACING WITH EXTERNAL MEMORY  
15.5.2 Write Strobe Mode  
The write strobe mode eliminates the need to externally decode high- and low-byte writes to an  
external 16-bit RAM or flash device in 16-bit bus mode. When the write strobe mode is selected,  
the microcontroller generates WRL# and WRH# instead of WR# and BHE#. WRL# is asserted  
for all low byte writes (even addresses) and all word writes. 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. Figure 15-14 shows write strobe mode timing.  
ALE  
WRL#  
WRH#  
ALE  
WRL# and WRH#  
AD7:0  
Valid  
Valid  
Address Low  
Data Out  
AD15:0  
AD15:8  
Address High  
8-bit Bus Cycle  
Address  
Data Out  
16-bit Bus Cycle  
A3089-01  
Figure 15-14. Write Strobe Mode  
15-25  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Figure 15-15 shows a 16-bit system with two EPROMs and two RAMs. It is configured to use  
the write strobe mode. ALE latches the address; AD15 is the chip-select signal for the memory  
devices. WRL# is asserted during low byte writes and word writes. WRH# is asserted during high  
byte writes and word writes. Note that the RAM devices do not use AD0. WRL# and WRH# de-  
termine whether the low byte (AD0=0) or high byte (AD0=1) is selected.  
V
CC  
BUSWIDTH  
AD15:8  
CS#  
CS#  
CS#  
CS#  
A15  
74AC  
373  
A14:8  
A13:7  
A12:7  
D15:8  
A12:7  
A13:7  
LE  
D15:8  
ALE  
16K×8  
EPROM  
(High)  
16K×8  
EPROM  
(Low)  
8K×8  
8K×8  
RAM  
(Low)  
RAM  
8XC196  
(High)  
D7:0  
D7:0  
LE  
A7:1  
AD7:0  
74AC  
373  
A6:0  
OE#  
A6:0  
OE#  
A6:0  
OE# WE#  
A6:0  
WE#  
OE#  
RD#  
WRH#  
WRL#  
A3090-01  
Figure 15-15. 16-bit System with Writes to Byte-wide RAMs  
15-26  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INTERFACING WITH EXTERNAL MEMORY  
15.5.3 Address Valid Strobe Mode  
When the address valid strobe mode is selected, the microcontroller generates the address valid  
signal (ADV#) instead of the address latch enable signal (ALE). ADV# is asserted after an exter-  
nal address is valid (see Figure 15-16). This signal can be used to latch the valid address and si-  
multaneously enable an external memory device. (See the examples in Figures 15-18 and 15-19.)  
ADV#  
ADV#  
WR# or RD#  
WR# or RD#  
Addr  
Low  
Data Out  
Valid  
BHE#  
AD7:0  
Address  
Data Out  
Address High  
AD15:0  
AD15:8  
16-bit Bus Cycle  
8-bit Bus Cycle  
A3092-02  
Figure 15-16. Address Valid Strobe Mode  
The difference between ALE and ADV# is that ADV# is asserted for the entire bus cycle, not just  
to latch the address. Figure 15-17 shows the difference between ALE and ADV# for a single read  
or write cycle. Note that for back-to-back bus access, the ADV# function will look identical to  
the ALE function. The difference becomes apparent only when the bus is idle. Because ADV# is  
high during these periods, external memory will be disabled, thus saving power.  
AD15:0  
ADV#  
Address  
Data  
ALE  
RD#, WR#  
Next Bus Cycle  
Bus Idle  
A3093-02  
Figure 15-17. Comparison of ALE and ADV# Bus Cycles  
15-27  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Figure 15-18 and Figure 15-19 show sample circuits that use the address valid strobe mode. Fig-  
ure 15-18 shows a simple 8-bit system with a single flash. It is configured for the address valid  
strobe mode. This system configuration uses the ADV# signal as both the flash chip-select signal  
and the address-latch signal.  
RD#  
OE#  
A14:8  
AD14:8  
D7:0  
32K×8  
Flash  
8XC196  
(28F256)  
A7:0  
74AC  
373  
A7:0  
CS#  
AD7:0  
LE  
ADV#  
A3094-01  
Figure 15-18. 8-bit System with Flash  
15-28  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INTERFACING WITH EXTERNAL MEMORY  
Figure 15-19 shows a 16-bit system with two EPROMs. This system configuration uses the  
ADV# signal as both the EPROM chip-select signal and the address-latch signal.  
V
CC  
BUSWIDTH  
AD15:8  
CS#  
CS#  
A14:8  
A15:8  
74AC  
373  
A13:7  
D15:8  
A13:7  
LE  
ADV#  
8XC196  
AD7:0  
D7:0  
A6:0  
16K×8  
EPROM  
(Low)  
16K×8  
EPROM  
(High)  
LE  
A7:1  
A7:1  
74AC  
373  
A6:0  
OE#  
OE#  
RD#  
A3095-01  
Figure 15-19. 16-bit System with EPROM  
15-29  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
15.5.4 Address Valid with Write Strobe Mode  
When the address valid with write strobe mode is selected, the microcontroller generates the  
ADV#, RD#, WRL#, and WRH# bus-control signals. This mode is used for a simple system us-  
ing an external 16-bit data bus. Figure 15-20 shows the timing. The RD# signal (not shown) is  
similar to WRL# and WRH#. The example system of Figure 15-21 uses address valid with write  
strobe to access byte-wide RAMs with a 16-bit data bus.  
ADV#  
WRL#  
ADV#  
WRL#  
Valid  
Addr  
Low  
Data Out  
Valid  
WRH#  
AD7:0  
Address  
Data Out  
Address High  
8-bit Bus Cycle  
AD15:0  
AD15:8  
16-bit Bus Cycle  
A3096-02  
Figure 15-20. Timings of Address Valid with Write Strobe Mode  
15-30  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INTERFACING WITH EXTERNAL MEMORY  
V
CC  
BUSWIDTH  
AD15:8  
CS#  
CS#  
A13:8  
74AC  
373  
A12:7  
D15:8  
A12:7  
LE  
ADV#  
D7:0  
A6:0  
8K×8  
RAM  
(High)  
8K×8  
RAM  
(Low)  
8XC196  
LE  
A7:1  
74AC  
373  
AD7:0  
A6:0  
WE#  
WE#  
WRH#  
WRL#  
A3097-01  
Figure 15-21. 16-bit System with RAM  
15.6 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 15-22.  
15-31  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
T
XTAL1  
XTAL1  
T
T
CHCL  
T
CLCL  
XHCH  
CLKOUT  
T
T
LLCH  
CLLH  
T
LHLH  
ALE/ADV#  
T
LHLL  
T
RHLH  
T
T
LLRL  
RLRH  
RD#  
T
T
RHDZ  
RLAZ  
T
AVLL  
T
T
RLDV  
T
LLAX  
Address Out  
Data In  
AD15:0  
(read)  
T
AVDV  
T
T
LLWL  
WHLH  
WLWH  
WR#  
T
T
WHQX  
QVWH  
Data Out  
AD15:0  
(write)  
Address Out  
Address Out  
T
T
, T  
WHBX RHBX  
Valid  
BHE#, INST  
, T  
WHAX RHAX  
AD15:8  
(8-bit mode)  
Address Out  
The CLKOUT pin is available only on the 8XC196MC, MD.  
A3166-01  
Figure 15-22. System Bus Timing  
15-32  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INTERFACING WITH EXTERNAL MEMORY  
15.6.1 Explanation of AC Symbols  
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/ADV#) condition L  
(Low), and signal R (RD#) condition L (Low). Table 15-7 defines the signal and condition codes.  
Table 15-7. AC Timing Symbol Definitions  
Signals  
Conditions  
A
Address  
Q
R
W
X
Output Data  
RD#  
H
L
High  
B
BHE#  
Low  
C†  
D
G
CLKOUT  
Input Data  
BUSWIDTH  
ALE/ADV#  
WR#, WRH#, WRL#  
XTAL1  
V
X
Z
Valid  
No Longer Valid  
Floating  
Y
READY  
L
The CLKOUT pin is available only on the 8XC196MC, MD microcontrollers.  
15.6.2 AC Timing Definitions  
Tables 15-8 and 15-9 define the AC timing specifications that the memory system must meet and  
those that the microcontroller will provide.  
Table 15-8. External Memory Systems Must Meet These Specifications  
Symbol  
Definition  
TAVDV  
Address Valid to Input Data Valid  
Maximum time the memory system has to output valid data after the microcontroller outputs a  
valid address.  
TRHDZ  
RD# High to Input Data Float  
Time after the microcontroller deasserts RD# 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 microcontroller asserts  
RD#.  
The CLKOUT pin is available only on the 8XC196MC, MD microcontrollers.  
15-33  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 15-9. Microcontroller Meets These Specifications  
Definition  
Symbol  
TAVLL  
Address Setup to ALE/ADV# Low  
Length of time address is valid before ALE/ADV# falls. Useful when using an external latch to  
demultiplex the address from the address data bus.  
TCHCL  
CLKOUT High CLKOUT Low  
CLKOUT pulse width. Useful when using CLKOUT to clock external devices.  
TCLCL  
CLKOUT Cycle Time  
The period of the CLKOUT signal; equal to 2TXTAL1  
.
TCLLH  
CLKOUT Low to ALE/ADV# High  
TLHLH  
ALE Cycle Time  
Minimum time between two ALE rising edges.  
TLHLL  
ALE High to ALE Low  
ALE pulse width. Useful when using an external latch to demultiplex the address from the  
address data bus.  
TLLAX  
AD15:0 Hold after ALE/ADV# Low  
Length of time address is valid after ALE/ADV# falls. Useful when using an external latch to  
demultiplex the address from the address data bus.  
TLLCH  
ALE/ADV# Low to CLKOUT High  
ALE/ADV# Low to RD# Low  
TLLRL  
Length of time after ALE/ADV# falls before the microcontroller asserts RD#. Maximum time a  
memory system has to decode the address before the microcontroller asserts RD#.  
TLLWL  
ALE/ADV# Low to WR# Low  
Length of time after ALE/ADV# falls before the microcontroller asserts WR#. Maximum time a  
memory system has to decode the address before the microcontroller asserts WR#.  
TQVWH  
Output Data Valid to WR# High  
Length of time output data is valid before the microcontroller deasserts WR#.  
TRHAX  
Address (high byte) Hold after RD# High  
Minimum time the high byte of the address (when using an 8-bit data bus) is valid after the  
microcontroller deasserts RD#.  
TRHBX  
BHE#, INST Hold after RD# High  
Minimum time these signals are valid after the microcontroller deasserts RD#.  
TRHLH  
RD# High to ALE High  
Time between the microcontroller deasserting RD# and the next ALE pulse. Maximum time the  
memory system has to put data on the bus before the next address cycle.  
TRLAZ  
RD# Low to Address Float  
Time after the microcontroller deasserts RD# until it stops driving the address on the bus.  
TRLRH  
RD# Low to RD# High  
RD# pulse width.  
The CLKOUT pin is available only on the 8XC196MC, MD microcontrollers.  
15-34  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INTERFACING WITH EXTERNAL MEMORY  
Table 15-9. Microcontroller Meets These Specifications (Continued)  
Definition  
Symbol  
TWHAX  
Address (high byte) Hold after WR# High  
Minimum time the high byte of the address (when using an 8-bit data bus) is valid after the  
microcontroller deasserts WR#.  
TWHBX  
BHE#, INST Hold after WR# High  
Minimum time these signals are valid after the microcontroller deasserts WR#.  
TWHLH  
WR# High to ALE High  
Time between the microcontroller deasserting WR# and next ALE pulse. Maximum time the  
memory system has to get data off the bus before the next address cycle.  
TWHQX  
Output Data Hold after WR# High  
Length of time output data is valid on the bus after the microcontroller deasserts WR#.  
TWLWH  
WR# Low to WR# High  
WR# pulse width.  
TXHCH  
XTAL1 High to CLKOUT High or Low  
TXTAL1  
1/FXTAL1  
The period of the frequency on the XTAL1 input (FXTAL1). All AC timings are referenced to  
TXTAL1  
.
The CLKOUT pin is available only on the 8XC196MC, MD microcontrollers.  
15-35  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
16  
Programming the  
Nonvolatile Memory  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
CHAPTER 16  
PROGRAMMING THE NONVOLATILE MEMORY  
The 87C196MC and 87C196MD contain 16 Kbytes of one-time-programmable read-only mem-  
ory (OTPROM); the 87C196MH contains 32 Kbytes. OTPROM is similar to EPROM, but it  
comes in an unwindowed package and cannot be erased. You can either program the OTPROM  
yourself or have the factory program it as a quick-turn ROM product (this option may not be  
available for all devices). This chapter provides procedures and guidelines to help you program  
the device. The information is organized as follows.  
overview of programming methods  
OTPROM memory map (page 16-2)  
security features (page 16-3)  
programming pulse width (page 16-8)  
modified quick-pulse algorithm (page 16-9)  
programming mode pins (page 16-11)  
entering programming modes (page 16-13)  
slave programming (page 16-15)  
auto programming (page 16-25)  
PCCB and UPROM programming (8XC196MH only; page 16-30)  
run-time programming (page 16-32)  
16.1 PROGRAMMING METHODS  
You can program the OTPROM by configuring a circuit that allows the device to enter a program-  
ming mode. In programming modes, the device executes an algorithm that resides in the internal  
test ROM.  
Slave programming mode allows you to use an EPROM programmer as a master to  
program several microcontrollers (the slaves). The code and data to be programmed into the  
nonvolatile memory typically resides on a diskette. The EPROM programmer transfers the  
code and data from the diskette to its memory, then manipulates the slave’s pins to define  
the addresses to be programmed and the contents to be written to those addresses. Using this  
16-1  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
mode, you can program and verify single or multiple words in the OTPROM. This mode  
allows you to read the signature word and programming voltages and to program the  
PCCBs and unerasable PROM (UPROM) bits. Programming vendors and Intel distributors  
typically use this mode to program a large number of microcontrollers with a customer’s  
code and data.  
Auto programming mode enables the microcontroller to act as a master to program itself  
with code and data that reside in an external memory device. Using this mode, you can  
program the entire OTPROM array except the UPROM bits and PCCBs. (For the  
8XC196MH, PCCB and UPROM modes allow you to program those locations. For the  
8XC196MC and 8XC196MD, only slave mode allows you to program them.) After  
programming, you can use the ROM-dump mode to write the entire OTPROM array to an  
external memory device to verify its contents. Customers typically use this low-cost method  
to program a small number of microcontrollers after development and testing are complete.  
You can also program individual OTPROM locations without entering a programming mode.  
With this method, called run-time programming, your software controls the number and duration  
of programming pulses. Customers typically use this mode to download small sections of code to  
the microcontroller during software development and testing.  
16.2 OTPROM MEMORY MAP  
The OTPROM contains customer-specified special-purpose and program memory (Table 16-1).  
The 128-byte special-purpose memory partition is used for interrupt vectors, the chip configura-  
tion bytes (CCBs), and the security key. Several locations are reserved for testing or for use in  
future products. Write the value (20H or FFH) indicated in Table 16-1 to each reserved location.  
The remainder of the OTPROM is available for code storage.  
16-2  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PROGRAMMING THE NONVOLATILE MEMORY  
Table 16-1. 87C196Mx OTPROM Memory Map  
Address Range  
(Hex)  
Description  
9FFF (MH)  
2080  
Program memory  
Program memory  
5FFF (MC, MD)  
2080  
207F  
205E  
Reserved (each location must contain FFH)  
PTS vectors  
205D  
2040  
203F  
2030  
Upper interrupt vectors  
202F  
2020  
Security key  
201F  
201C  
Reserved (each location must contain FFH)  
201B  
201A  
2019  
2018  
Reserved (must contain 20H)  
CCB1  
Reserved (must contain 20H)  
CCB0  
2017  
2014  
Reserved (each location must contain FFH)  
Lower interrupt vectors  
2013  
2000  
16.3 SECURITY FEATURES  
Several security features enable you to control access to both internal and external memory. Read  
and write protection bits in the chip configuration register (CCR0), combined with a security key,  
allow various levels of internal memory protection. Two UPROM bits disable fetches of instruc-  
tions and data from external memory. (See Figure 16-1 on page 16-7 for more information.)  
16.3.1 Controlling Access to Internal Memory  
The lock bits in the chip configuration register (CCR0) control access to the OTPROM. The reset  
sequence loads the CCRs from the CCBs for normal operation and from the PCCBs when enter-  
ing programming modes. You can program the CCBs using any of the programming methods, but  
only slave and PCCB programming modes allow you to program the PCCBs.  
NOTE  
The developers have made a substantial effort to provide an adequate program  
protection scheme. However, Intel cannot and does not guarantee that these  
protection methods will always prevent unauthorized access.  
16-3  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
16.3.1.1  
Controlling Access to the OTPROM During Normal Operation  
During normal operation, the lock bits in CCB0 control read and write accesses to the OTPROM.  
Table 16-2 describes the options. You can program the CCBs using any of the programming  
methods.  
Table 16-2. Memory Protection for Normal Operating Mode  
Read Protect  
LOC1 (CCR0.7) LOC0 (CCR0.6)  
Write Protect  
Protection Status  
No protection. Run-time programming is permitted, and the entire  
OTPROM array can be read.  
1
1
1
0
Write protection only. Run-time programming is disabled, but the  
entire OTPROM array can be read.  
Read protection. Run-time programming is disabled. If program  
execution is external, only the interrupt vectors and CCBs can be  
read. The security key is write protected.  
0
0
1
0
Read and write protection. Run-time programming is disabled. If  
program execution is external, only the interrupt vectors and CCBs  
can be read.  
Clearing CCB0.6 enables write protection. With write protection enabled, a write attempt causes  
the bus controller to cycle through the write sequence, but it does not enable VPP or write data to  
the OTPROM. This protects the entire OTPROM array from inadvertent or unauthorized pro-  
gramming.  
Clearing CCB0.7 enables read protection and also write protects the security key to protect it  
from being overwritten. With read protection enabled, the bus controller will not read from pro-  
tected areas of OTPROM. An attempt to load the slave program counter with an external address  
causes the device to reset itself. Because the slave program counter can be as much as four bytes  
ahead of the CPU program counter, the bus controller might prevent code execution from the last  
four bytes of internal memory. The interrupt vectors and CCBs are not read protected because  
interrupts can occur even when executing from external memory.  
16.3.1.2  
Controlling Access to the OTPROM During Programming Modes  
For programming modes, three levels of protection are available:  
prohibit all programming  
prohibit all programming, but permit authorized ROM dumps  
permit authorized ROM dumps, auto programming, and slave programming  
16-4  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PROGRAMMING THE NONVOLATILE MEMORY  
These protection levels are provided by the PCCB0 lock bits, the CCB0 lock bits, and the internal  
security key (Table 16-3). When entering programming modes, the reset sequence loads the  
PCCBs into the chip configuration registers. It also loads CCB0 into internal RAM to provide an  
additional level of security.  
You can program the CCBs using any of the programming methods, but only slave and PCCB  
programming modes permits access to the PCCBs, and only slave and auto programming allow  
you to program the internal security key.  
Table 16-3. Memory Protection Options for Programming Modes  
LOC1  
(CCR0.7)  
LOC0  
(CCR0.6)  
Security Key  
Programmed  
?
Protection Status  
PCCB CCB PCCB CCB  
1
1
1
1
0
1
No  
No protection. All programming modes allowed.  
All programming disabled. ROM-dump permitted with  
matching security key.  
X
X
Yes  
Auto and slave programming permitted with matching  
security key.  
1
0
0
1
0
0
Yes  
X
X
X
All programming unconditionally disabled.  
If you want to prohibit all programming, clear both PCCB0 lock bits. If these bits are cleared,  
they prevent the device from entering any programming mode.  
If you want to prevent programming, but allow ROM dumps, leave the PCCB0 read-protection  
bit (PCCB0.7) unprogrammed and clear the PCCB0 write-protection bit (PCCB0.6). To protect  
against unauthorized reads, program an internal security key. The ROM-dump mode compares  
the internal security key location with an externally supplied security key, regardless of the CCB0  
lock bits. If the security keys match, the routine continues; otherwise, the device enters an endless  
internal loop.  
If you want to allow slave and auto programming as well as ROM dumps, leave both PCCB0 lock  
bits unprogrammed. To protect against unauthorized programming, clear the CCB0 lock bits and  
program an internal security key. After the device enters either slave or auto programming mode,  
the corresponding test ROM routine reads the CCB0 lock bits. If either CCB0 lock bit is enabled,  
the routine compares the internal security key location with an externally supplied security key.  
If the security keys match, the routine continues; otherwise, the device enters an endless internal  
loop.  
16-5  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
You can program the internal security key in either auto or slave programming mode. Once the  
security key is programmed, you must provide a matching key to gain access to any programming  
mode. For auto programming and ROM-dump modes, a matching security key must reside in ex-  
ternal memory. For slave programming mode, you must “program” a matching security key into  
the appropriate OTPROM locations with the program word command. The locations are not ac-  
tually programmed, but the data is compared to the internal security key.  
WARNING  
If you leave the internal security key locations unprogrammed (filled with  
FFFFH), an unauthorized person could gain access to the OTPROM by using  
an external EPROM with an unprogrammed external security key location or  
by using slave programming mode.  
16.3.2 Controlling Fetches from External Memory  
Two UPROM bits disable external instruction fetches and external data fetches. If you program  
the UPROM bits, an attempt to fetch data or instructions from external memory causes a device  
reset. You can program the UPROM bits using slave or UPROM (8XC196MH only) program-  
ming mode.  
Programming the DEI bit prevents the bus controller from executing external instruction fetches.  
An attempt to load the slave program counter with an external address causes the device to reset  
itself. Because the slave program counter can be as much as four bytes ahead of the CPU program  
counter, the bus controller might prevent code execution from the last four bytes of internal mem-  
ory. The automatic reset also gives extra protection against runaway code.  
Programming the DED bit prevents the bus controller from executing external data reads and  
writes. An attempt to access data through the bus controller causes the device to reset itself. Set-  
ting this bit disables ROM-dump mode.  
To program these bits, write the correct value to the location shown in Table 16-4 using slave pro-  
gramming mode. During normal operation, you can determine the values of these bits by reading  
the UPROM special-function register (Figure 16-1).  
16-6  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PROGRAMMING THE NONVOLATILE MEMORY  
Address:  
Reset State (MC, MD):  
Reset State (MH):  
1FF6H  
02H  
XXH  
USFR  
The unerasable PROM (USFR) register contains two bits that disable external fetches of data and  
instructions and another that detects a failed oscillator. These bits can be programmed, but cannot be  
erased.  
WARNING: These bits can be programmed, but can never be erased. Programming these bits makes  
dynamic failure analysis impossible. For this reason, devices with programmed UPROM bits cannot  
be returned to Intel for failure analysis.  
7
0
DEI  
DED  
Bit  
Number  
Bit  
Mnemonic  
Function  
7:4  
Reserved; for compatibility with future devices, write zeros to these bits.  
Disable External Instruction Fetch  
3
DEI  
DED  
Setting this bit prevents the bus controller from executing external  
instruction fetches. Any attempt to load an external address initiates a  
reset.  
2
Disable External Data Fetch  
Setting this bit prevents the bus controller from executing external data  
reads and writes. Any attempt to access data through the bus controller  
initiates a reset.  
1:0  
Reserved; for compatibility with future devices, write zero to these bits.  
Figure 16-1. Unerasable PROM (USFR) Register  
You can verify a UPROM bit to make sure it programmed, but you cannot erase it. For this reason,  
Intel cannot test the bits before shipment. However, Intel does test the features that the UPROM  
bits enable, so the only undetectable defects are (unlikely) defects within the UPROM cells them-  
selves.  
Table 16-4. UPROM Programming Values and Locations for Slave Mode  
To set this bit  
Write this value  
To this location  
DEI  
08H  
04H  
0718H  
0758H  
DED  
16-7  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
16.4 PROGRAMMING PULSE WIDTH  
The programming pulse width is controlled in different ways, depending on the programming  
mode. In slave programming mode, the pulse width is controlled by the PALE# signal. In auto  
programming mode, it is loaded from the external EPROM into the PPW register. In the UPROM  
(8XC196MH only) and PCCB programming modes, the pulse width is controlled by the test-  
ROM routine. (For run-time programming, your software controls the pulse width.)  
To determine the correct PPW_VALUE for the frequency of the device, use the following formula  
and round the result to the next higher integer.  
PPW_VALUE for 8XC196MC, MD = 62.5 × FXTAL1  
PPW_VALUE for 8XC196MH  
= 25 × FXTAL1  
where:  
PPW_VALUE  
FXTAL1  
is a 16-bit word  
is the input frequency on XTAL1, in MHz  
no direct access  
PPW  
The programming pulse width (PPW) register is loaded from the external EPROM (locations 14H and  
15H for the 8XC196MC and MD; locations 4014H and 4015H for the 8XC196MH) in auto programming  
mode. The PPW_VALUE determines the programming pulse width.  
15  
PPW15  
8
PPW14  
PPW6  
PPW13  
PPW5  
PPW12  
PPW4  
PPW11  
PPW3  
PPW10  
PPW2  
PPW9  
PPW1  
PPW8  
PPW0  
7
0
PPW7  
Bit  
Bit  
Function  
Number Mnemonic  
15:0 PPW15:0  
PPW_VALUE  
This value establishes the programming pulse width for auto programming.  
Use the appropriate formula to calculate the PPW_VALUE, then write the  
result to the PPW register. (Table 16-5 shows the calculations and results for  
8 MHz and 16 MHz operation.)  
PPW_VALUE for 8XC196MC, MD = 62.5 ×FXTAL1  
PPW_VALUE for 8XC196MH  
= 25 ×FXTAL1  
Figure 16-2. Programming Pulse Width (PPW) Register  
The examples in Table 16-5 calculate the required minimum pulse width (100 µs for the  
8XC196MH and 250 µs for the 8XC196MC, MD) for an 8-MHz and a 16-MHz crystal.  
16-8  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PROGRAMMING THE NONVOLATILE MEMORY  
Table 16-5. Example PPW_VALUE Calculations  
8XC196MC, MD  
(Two 250-µs pulses required)  
8XC196MH  
(Five 100-µs pulses required)  
FXTAL1  
8 MHz PPW_VALUE = 62.5 × 8 = 504 = 01F4H  
PPW_VALUE = 25 × 8 = 200 = 00C8H  
16 MHz PPW_VALUE = 62.5 × 16 = 1000 = 03F8H PPW_VALUE = 25 × 16 = 400 = 0190H  
16.5 MODIFIED QUICK-PULSE ALGORITHM  
Both the slave and auto programming routines use the modified quick-pulse algorithm (Figure  
16-3). The modified quick-pulse algorithm sends programming pulses to each OTPROM word  
location. After the required number of programming pulses, a verification routine compares the  
contents of the programmed location to the input data. A verification error deasserts the PVER  
signal, but does not stop the programming routine. This process repeats until each OTPROM  
word has been programmed and verified. Intel guarantees lifetime data retention for a device pro-  
grammed with the modified quick-pulse algorithm.  
NOTE  
The 87C196MC, MD devices use two pulses; the 87C196MH uses five.  
16-9  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
From Auto or Slave  
Programming  
Start PPW Timer  
Write Data to  
OTPROM  
Enable Interrupts  
Enter Idle Mode  
Wait for PPW Timer Interrupt  
No  
Required  
Writes Done  
?
Yes  
Compare Programmed  
Locations and Set Flags  
Return  
A0190-03  
Figure 16-3. Modified Quick-pulse Algorithm  
Auto programming repeats the pulse twice (for the 87C196MC, MD) or five times (for the  
87C196MH), using the pulse width you specify in the external EPROM. Slave mode repeats the  
pulse until PROG# is deasserted. In slave programming mode, the PALE# signal controls the  
pulse width. In all cases, the pulse width must be at least 100 µs for successful programming.  
16-10  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PROGRAMMING THE NONVOLATILE MEMORY  
16.6 PROGRAMMING MODE PINS  
Figure 16-4 illustrates the signals used in programming and Table 16-6 describes them. The EA#,  
VPP, and PMODE pins combine to control entry into programming modes. You must configure  
the PMODE (P0.7:4) pins to select the desired programming mode (see Table 16-7 on page  
16-13). Each programming routine configures the port 2 pins to operate as the appropriate spe-  
cial-function signals. Ports 3 and 4 automatically serve as the PBUS during programming.  
V
EA#  
Programming  
Voltage  
P4.7:0  
P3.7:0  
PP  
PBUS  
4
PMODE.3:0  
P0.7:4  
P2.7  
P2.6  
P2.4  
P2.2  
P2.1  
P2.0  
PACT#  
CPVER  
AINC#  
PROG#  
PALE#  
PVER  
8XC196 Device  
A2839-02  
Figure 16-4. Pin Functions in Programming Modes  
Table 16-6. Pin Descriptions  
Special-  
function  
Signal  
Program-  
ming  
Mode  
Port Pin  
Type  
Description  
P0.7:4  
PMODE.3:  
PMODE.0  
I
All  
Programming Mode Select  
Determines the programming mode. PMODE is  
sampled after a device reset and must be static  
while the part is operating. (Table 16-7 on page  
16-13 lists the PMODE values and programming  
modes.)  
P2.0  
P2.1  
PVER  
O
Slave  
Auto  
Programming Verification  
During slave or auto programming, PVER is  
updated after each programming pulse. A high  
output signal indicates successful programming of a  
location, while a low signal indicates a detected  
error.  
PALE#  
I
Slave  
Programming ALE Input  
During slave programming, a falling edge causes  
the device to read a command and address from the  
PBUS.  
16-11  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 16-6. Pin Descriptions (Continued)  
Special-  
function  
Signal  
Program-  
ming  
Mode  
Port Pin  
Type  
Description  
P2.2  
PROG#  
I
Slave  
Programming  
During programming, a falling edge latches data on  
the PBUS and begins programming, while a rising  
edge ends programming. The current location is  
programmed with the same data as long as PROG#  
remains asserted, so the data on the PBUS must  
remain stable while PROG# is active.  
During a word dump, a falling edge causes the  
contents of an OTPROM location to be output on  
the PBUS, while a rising edge ends the data  
transfer.  
P2.4  
AINC#  
I
Slave  
Auto-increment  
During slave programming, this active-low input  
enables the auto-increment feature. (Auto increment  
allows reading or writing of sequential OTPROM  
locations, without requiring address transactions  
across the PBUS for each read or write.) AINC# is  
sampled after each location is programmed or  
dumped. If AINC# is asserted, the address is  
incremented and the next data word is programmed  
or dumped.  
P2.6  
P2.7  
CPVER  
PACT#  
PBUS  
O
O
Slave  
Cumulative Program Verification  
During slave programming, a high signal indicates  
that all locations programmed correctly, while a low  
signal indicates that an error occurred during one of  
the programming operations.  
Auto  
ROM-  
dump  
Programming Active  
During auto programming or ROM-dump, a low  
signal indicates that programming or dumping is in  
progress, while a high signal indicates that the  
operation is complete.  
P4.7:0,  
P3.7:0  
I/O  
Slave  
Address/Command/Data Bus  
During slave programming, ports 3 and 4 serve as a  
bidirectional port with open-drain outputs to pass  
commands, addresses, and data to or from the  
device. Slave programming requires external pull-up  
resistors.  
P4.7:0, (MC,MD) PBUS  
P3.7:0 (MC, MD)  
I/O  
Auto  
ROM-  
dump  
Address/Command/Data Bus  
During auto programming and ROM-dump, ports 3  
and 4 serve as a regular system bus to access  
external memory. For the 8XC196MH, P4.7:4 are  
left unconnected; P1.3:0 serve as the upper address  
lines.  
P1.3:0, (MH)  
P4.3:0, (MH)  
P3.7:0 (MH)  
16-12  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PROGRAMMING THE NONVOLATILE MEMORY  
Table 16-6. Pin Descriptions (Continued)  
Special-  
function  
Signal  
Program-  
ming  
Mode  
Port Pin  
Type  
Description  
EA#  
I
All  
External Access  
Controls program mode entry. If EA# is at VPP  
voltage on the rising edge of RESET#, the device  
enters programming mode.  
EA# is sampled and latched only on the rising edge  
of RESET#. Changing the level of EA# after reset  
has no effect.  
VPP  
I
All  
Programming Voltage  
During programming, the VPP pin is typically at  
+12.5V (VPP voltage). Exceeding the maximum VPP  
voltage specification can damage the device.  
16.7 ENTERING PROGRAMMING MODES  
To execute programs properly, the device must have these minimum hardware connections:  
XTAL1 driven, unused input pins strapped, and power and grounds applied. Follow the operating  
conditions specified in the datasheet. Place the device into programming mode by applying VPP  
voltage (+12.5 V) to EA# during the rising edge of RESET#.  
16.7.1 Selecting the Programming Mode  
The PMODE (P0.7:4) value controls the programming mode. PMODE is sampled on the rising  
edge of RESET#. You must reset the device to switch programming modes. Table 16-7 lists the  
PMODE value for each programming mode. All other PMODE values are reserved.  
Table 16-7. PMODE Values  
PMODE Value  
Programming Mode  
(Hex)  
5
6
Slave programming  
ROM-dump  
9
UPROM programming (MH only)  
Auto programming  
C
D
PCCB programming (MH only)  
16-13  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
16.7.2 Power-up and Power-down Sequences  
When you are ready to begin programming, follow these power-up and power-down procedures.  
WARNING  
Failure to observe these warnings will cause permanent device damage.  
Voltage must not be applied to VPP while VCC is low.  
The VPP voltage must be within 1 volt of VCC while VCC is less than 4.5 volts. VPP must not  
go above 4.5 volts until VCC is at least 4.5 volts.  
The VPP maximum voltage must not be exceeded.  
EA# must reach programming voltage before VPP does so.  
The PMODE pins (P0.7:4) must be in their desired states before RESET# rises.  
All voltages must be within the ranges specified in the datasheet and the oscillator must be  
stable before RESET# rises.  
The power supplies to the VCC, VPP, EA# and RESET# pins must be well regulated and free  
of glitches and spikes.  
All VSS pins must be well grounded.  
16.7.2.1  
Power-up Sequence  
1. Hold RESET# low while VCC stabilizes. Allow VPP and EA# to float during this time.  
2. After VCC and the oscillator stabilize, continue to hold RESET# low and apply VPP voltage  
to EA#.  
3. After EA# stabilizes, apply VPP voltage (+12.5V) to the VPP pin.  
4. Set the PMODE value to select a programming algorithm.  
5. Bring the RESET# pin high.  
6. Complete the selected programming algorithm.  
16.7.2.2  
Power-down Sequence  
1. Assert the RESET# signal and hold it low throughout the powerdown sequence.  
2. Remove the VPP voltage from the VPP pin and allow the pin to float.  
3. Remove the VPP voltage from the EA# pin and allow the pin to float.  
4. Turn off the VCC supply and allow time for it to reach 0 volts.  
16-14  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PROGRAMMING THE NONVOLATILE MEMORY  
16.8 SLAVE PROGRAMMING MODE  
Slave programming mode allows you to program and verify the entire OTPROM array, including  
the PCCBs and UPROM bits, by using an EPROM programmer.  
In this mode, ports 3 and 4 serve as the PBUS, transferring commands, addresses, and data. The  
least-significant bit of the PBUS (P3.0) controls the command (1 = program word; 0 = dump  
word) and the remaining 15 bits contain the address of the word to be programmed or dumped.  
Some port 2 pins provide handshaking signals. The AINC# signal controls whether the address  
is automatically incremented, enabling programming or dumping sequential OTPROM locations.  
This speeds up the programming process, since it eliminates the need to generate and decode each  
sequential address.  
NOTE  
If a glitch or reset occurs during programming of the security key, an unknown  
security key might accidentally be written, rendering the device inaccessible  
for further programming. To prevent this possibility during slave  
programming, program the rest of the OTPROM array before you program the  
CCB security-lock bits (CCB0.6 and CCB0.7).  
16.8.1 Reading the Signature Word and Programming Voltages  
The signature word identifies the device; the programming voltages specify the VPP and VCC volt-  
ages required for programming. This information resides in the test ROM at locations 2070H,  
2072H, and 2073H; however, these locations are remapped to 0070H, 0072H, and 0073H. You  
can use the dump word command in slave programming mode to read the signature word and pro-  
gramming voltages at the locations shown in Table 16-8. The external programmer can use this  
information to determine the device type and operating conditions. You should never write to  
these locations. The voltages are calculated by using the following equation (after converting the  
test ROM value to decimal).  
20 × test ROM value  
-----------------------------------------------------  
Voltage  
=
=
256  
20 × 64  
256  
20 × 160  
256  
------------------  
----------------------  
= 12.5 volts  
VCC (40H)  
= 5 volts  
VPP (0A0H)  
=
16-15  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 16-8. Device Signature Word and Programming Voltages  
Signature Word  
Location Value  
Programming VCC Programming VPP  
Device  
Location  
Value Location Value  
8XC196MC, MD  
8XC196MH  
0070H 8794H  
0070H 87DEH  
0072H  
0072H  
40H  
40H  
0073H 0A0H  
0073H 0A0H  
16.8.2 Slave Programming Circuit and Memory Map  
Figure 16-5 shows the circuit diagram and Table 16-9 shows the memory map for slave program-  
ming mode. The external clock signal can be supplied by either a clock or a crystal. Refer to the  
device datasheet for acceptable clock frequencies.  
CLOCK  
VCC  
XTAL1  
VCC  
10kΩ  
VCC  
VSS  
RESET#  
RESET#  
PBUS  
NMI  
0.1 µF  
P4.7:0  
P3.7:0  
Pullups Required  
P4.7 - P3.0  
EA#  
VPP  
EA#  
VPP  
P2.6  
P2.4  
P2.2  
P2.1  
P2.0  
CPVER  
AINC#  
PROG#  
PALE#  
PVER  
VCC  
VREF  
P0.7/PMODE.3  
P0.6/PMODE.2  
P0.5/PMODE.1  
P0.4/PMODE.0  
ANGND  
87C196 Device  
A0256-03  
Figure 16-5. Slave Programming Circuit  
16-16  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PROGRAMMING THE NONVOLATILE MEMORY  
Table 16-9. Slave Programming Mode Memory Map  
Description Address  
Comments  
OTPROM  
(MH) 2000–9FFFH OTPROM Cells  
(MC, MD) 2000–5FFFH  
DED†  
DEI†  
0758H UPROM Cell  
0718H UPROM Cell  
PCCB  
0218H Test EPROM  
0072H, 0073H Read Only  
0070H Read Only  
Programming voltages (see Table 16-8 on page 16-16)  
Signature word  
These bits program the UPROM cells. Once these bits are programmed, they cannot be erased and  
dynamic failure analysis of the device is impossible.  
16.8.3 Operating Environment  
The chip configuration registers (CCRs) define the system environment. Since the programming  
environment is not necessarily the same as the application environment, the device provides a  
means for specifying different configurations. Specify your application environment in the chip  
configuration bytes (CCBs) located in the OTPROM. Specify your programming environment in  
the programming chip configuration bytes (PCCBs) located in the test ROM.  
Figure 16-6 shows an abbreviated description of the CCRs with the default PCCB environment  
settings. The reset sequence loads the CCRs from the CCBs for normal operation and from the  
PCCBs when entering programming modes. You can program the CCBs using any of the pro-  
gramming methods, but only slave mode allows you to program the PCCBs. Chapter 15, “Inter-  
facing with External Memory,” describes the system configuration options, and “Controlling  
Access to Internal Memory” on page 16-3 describes the memory protection options.  
16-17  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
CCR1, CCR0  
no direct access  
The chip configuration registers (CCRs) control wait states, powerdown mode, and internal memory  
protection. These registers are loaded from the PCCBs during programming modes and from the CCBs  
for normal operation.  
7
0
1
1
0
1
WDE  
ALE  
BW1  
WR  
IRC2  
BW0  
0
7
0
LOC1  
LOC0  
IRC1  
IRC0  
PD  
Bit Mnemonic  
Function  
WDE  
BW1  
IRC2  
Watchdog Timer Enable  
PCCB default is initially disabled (enabled the first time WDT is cleared).  
Buswidth Control  
PCCB default selects BUSWIDTH pin control.  
Internal Ready Control  
PCCB default selects READY pin control.  
LOC1:0  
IRC1:0  
ALE  
Security Bits  
PCCB default selects no protection.  
Internal Ready Control  
PCCB default selects READY pin control.  
Select Address Valid Strobe Mode  
PCCB default selects ALE.  
WR  
Select Write Strobe Mode  
PCCB default selects WR# and BHE#.  
BW0  
PD  
Buswidth Control  
PCCB default selects BUSWIDTH pin control.  
Powerdown Enable  
PCCB default enables powerdown.  
Figure 16-6. Chip Configuration Registers (CCRs)  
16-18  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PROGRAMMING THE NONVOLATILE MEMORY  
16.8.4 Slave Programming Routines  
The slave programming mode algorithm consists of three routines: the address/command decod-  
ing routine, the program word routine, and the dump word routine.  
The address/command decoding routine (Figure 16-7) reads the PBUS and transfers control to  
the program word or dump word routine based on the value of P3.0. A one on P3.0 selects the  
program word command and the remaining bits specify the address. For example, a PBUS value  
of 3501H programs a word of data at location 3500H. A zero on P3.0 selects the dump word com-  
mand and the remaining bits specify the address. For example, a PBUS value of 3500H places  
the word at location 3500H on the PBUS.  
The program word routine (Figure 16-8) checks the CCB security-lock bits. If either security lock  
bit (CCB0.6 or CCB0.7) has been programmed, you must provide a matching security key to gain  
access to the device. Using the program word command, write eight consecutive words to the de-  
vice, starting at location 2020H and continuing to 202FH. The routine stores these eight words in  
an internal register and compares their value with the internal key. If the keys match, the routine  
allows you to program individual or sequential OTPROM locations; otherwise, the device enters  
an endless loop.  
The dump word routine (Figure 16-10) also checks the CCB security-lock bits, but it has no pro-  
vision for security key verification. If the lock bits are unprogrammed, the routine fetches a word  
of data from the OTPROM and writes that data to the PBUS. If either lock bit is programmed, the  
routine performs a write cycle without first getting data from the OTPROM.  
16-19  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
No  
No  
Other  
Modes  
PMODE = 05H  
?
Yes  
PALE#  
(P2.1) = 0  
?
Yes  
Read Data  
From PBUS  
PVER  
(P2.0) = 1  
?
No  
Deassert CPVER  
Assert PVER  
Yes  
PALE#  
(P2.1)= 0  
?
Yes  
No  
Check Address  
Dump Word  
Routine  
No  
P3.0 = 1  
?
Yes  
Program Word  
Routine  
A0193-02  
Figure 16-7. Address/Command Decoding Routine  
16-20  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PROGRAMMING THE NONVOLATILE MEMORY  
From Address/  
Command Decoder  
No  
PROG#  
(P2.2)=0  
?
Yes  
Yes  
Verify  
Security Key  
Lock Bits  
Enabled  
?
Read Data  
from PBUS  
No  
Execute Modified  
Quick-Pulse Algorithm  
then Return  
Keys  
Match  
?
Yes  
No  
Loop  
Forever  
Deassert  
PVER (P2.0 = 0)  
No  
Programming  
Verifies  
?
Read Data  
from PBUS  
Yes  
Assert PVER  
(P2.0 = 1)  
PROG#  
(P2.2) = 0  
?
Yes  
No  
Yes  
PALE#  
(P2.1) = 0  
?
To Address/  
Command Decoder  
No  
No  
AINC#  
(P2.4) = 0  
?
Yes  
No  
Increment  
Address by 2  
PVER  
(P2.0) = 1  
?
Deassert CPVER  
Assert PVER  
Yes  
A0194-03  
Figure 16-8. Program Word Routine  
16-21  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Figure 16-9 shows the timings of the program word command with a repeated programming pulse  
and auto increment. Asserting PALE# latches the command and address on the PBUS. Asserting  
PROG# latches the data on the PBUS and starts the programming sequence. The PROG# signal  
controls the programming pulse width. (Slave programming mode does not use the PPW regis-  
ter.) After the rising edge of PROG#, the routine verifies the contents of the location that was just  
programmed and asserts PVER to indicate successful programming. AINC# is optional and can  
automatically increment the address for the next location. If you do not use AINC#, you must  
send a new program word command to access the next word location.  
RESET#  
T
DVPL  
T
AVLL  
ADDR1  
ADDR2  
DATA2  
PBUS  
(Ports 3/4)  
ADDR/COMMAND  
DATA1  
T
T
SHLL  
PLDX††  
T
LLAX  
PALE#  
T
T
LLLH  
LHPL  
T
T
T
ILPL  
PLPH  
PHPL  
PROG#  
Pulse 1  
T
ILVH  
PVER  
AINC#  
T
PHVL  
T
ILIH  
T
PHIL  
Additional program pulses and verifications.  
†† Measure from falling edge of last PROG# pulse in sequence.  
A0121-02  
Figure 16-9. Program Word Waveform  
16-22  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PROGRAMMING THE NONVOLATILE MEMORY  
From Address/  
Command Decoder  
Yes  
Lock Bits  
Enabled  
?
No  
Get Data  
from OPTROM  
PROG#  
(P2.2) = 0  
?
No  
Yes  
Write Data  
to PBUS  
PROG#  
(P2.2) = 1  
?
No  
Yes  
Write 0FFFFH  
to PBUS  
PALE#  
(P2.1) = 0  
?
Yes  
To Address/  
Command Decoder  
No  
AINC#  
(P2.4) = 0  
?
No  
Yes  
Increment  
Address by 2  
A0189-03  
Figure 16-10. Dump Word Routine  
16-23  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Figure 16-11 shows the timings of the dump word command. PROG# governs when the device  
drives the bus. The timings before the dump word command are the same as those shown in Fig-  
ure 16-9. In the dump word mode, the AINC# pin can remain active and toggling. The PROG#  
pin automatically increments the address.  
RESET#  
T
SHLL  
ADDR1  
ADDR2  
PBUS  
(Ports 3/4)  
ADDR/COMMAND  
Word Dump  
Word Dump  
T
T
T
T
PHDX  
PLDV  
PLDV  
PHDX  
PALE#  
PROG#  
T
ILPL  
T
PHPL  
AINC#  
A0122-02  
Figure 16-11. Dump Word Waveform  
16.8.5 Timing Mnemonics  
Table 16-10 defines the timing mnemonics used in the program word and dump word waveforms.  
The datasheets include timing specifications for these signals.  
Table 16-10. Timing Mnemonics  
Mnemonic  
Description  
TSHLL  
TLLLH  
TAVLL  
TLLAX  
TPLDV  
Reset High to First PALE# Low.  
PALE# Pulse Width.  
Address Setup Time.  
Address Hold Time.  
PROG# Low to Word Dump Valid.  
Word Dump Data Hold.  
Data Setup Time.  
TPHDX  
TDVPL  
TPLDX  
TPLPH  
TPHLL  
TLHPL  
Data Hold Time.  
PROG# Pulse Width.  
PROG# High to Next PALE# Low.  
PALE# High to PROG# Low.  
16-24  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PROGRAMMING THE NONVOLATILE MEMORY  
Table 16-10. Timing Mnemonics (Continued)  
Mnemonic  
Description  
TPHPL  
TPHIL  
TILIH  
PROG# High to Next PROG# Low.  
PROG# High to AINC# Low.  
AINC# Pulse Width.  
TILVH  
TILPL  
TPHVL  
PVER Hold After AINC# Low.  
AINC# Low to PROG# Low.  
PROG# High to PVER Valid.  
16.9 AUTO PROGRAMMING MODE  
The auto programming mode is a low-cost programming alternative. Using this programming  
mode, the device programs itself with data from an external EPROM (external locations 4000H  
and above; see Table 16-1 on page 16-3). A bank switching mechanism provided by port 1 pins  
(see Figure 16-12) supports auto programming of devices with more than 16 Kbytes of internal  
memory.  
16.9.1 Auto Programming Circuit and Memory Map  
Figure 16-12 shows the recommended circuit for auto programming mode. Table 16-11 shows the  
8XC196MC/MD memory map and Table 16-11 shows the 8XC196MH auto programming mem-  
ory map. Auto programming is specified for a crystal frequency of 6 to 8 MHz. At 8 MHz, use a  
27(C)512 EPROM with tACC = 250 ns and tOE = 100 ns or faster specifications.  
Tie the BUSWIDTH pin low to configure an 8-bit data bus. Connect P1.3:0 (8XC196MH only)  
as shown to generate the high-order bits of the external EPROM address. Connect P0.7:4 to VSS  
and VCC to select auto programming (1100B = 0CH). PACT# and PVER are status outputs, buff-  
ered by the 74HC14s. They drive LEDs that indicate programming active (PACT#) and program-  
ming verification (PVER). Connect all unused inputs to ground (VSS) and leave unused outputs  
floating. READY and NMI are active; connect them as indicated.  
NOTE  
All external EPROM addresses specified in this section are given for the  
circuit in Figure 16-12. If you choose a different circuit, you must adjust the  
addresses accordingly.  
16-25  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
VCC  
20 pF  
20 pF  
100 kΩ  
XTAL1  
XTAL2  
Reset  
RESET#  
VCC  
+5.0V  
VCC  
1 kΩ  
74HC14  
1.0µF  
READY/P5.6  
NMI  
10µF  
VSS  
BUSWIDTH/P5.7  
EA#  
VPP  
+12.50V  
VCC  
VREF  
P0.7/  
RD#/P5.3  
PMODE.3  
P0.6/  
PMODE.2  
OE# CE#  
MH  
P1.3:0  
AD11:8  
P0.5/  
PMODE.1  
A15:8  
MC/MD  
AD15:8  
P0.4/  
PMODE.0  
VCC  
ANGND  
LE OE#  
74LS373  
270kΩ  
ALE/P5.0  
AD7:0  
27(C)512  
P2.7/PACT#  
A7:0  
74HC14  
P2.5  
P2.4  
P2.3  
P2.2  
P2.1  
ON = Programming  
VCC  
270kΩ  
P2.0/PVER  
74HC14  
87C196Mx  
ON = Error  
A3111-01  
Figure 16-12. Auto Programming Circuit  
16-26  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PROGRAMMING THE NONVOLATILE MEMORY  
Table 16-11. 8XC196MC/MD Auto Programming Memory Map  
Address  
Output from  
8XC196MC,  
8XC196MD  
Address Using  
Circuit in  
Figure 16-12  
(A15:0)  
Internal  
OTPROM  
Address  
Description  
4014H  
4015H  
N/A  
14H Programming pulse width (PPW) LSB.  
15H Programming pulse width (PPW) MSB.  
0020–002FH Security key for verification.  
N/A  
2020–202FH  
2000–5FFFH  
4020–402FH  
4000–7FFFH  
4000–7FFFH Code, data, and reserved locations.  
Table 16-12. 8XC196MH Auto Programming Memory Map  
Address Using  
Internal  
Address  
Output from  
8XC196MH  
Circuit in  
OTPROM  
Address  
Description  
Figure 16-12  
(P1.3:0, A11:0)  
105EH  
105FH  
N/A  
105EH Programming pulse width (PPW) LSB.  
105FH Programming pulse width (PPW) MSB.  
0020–002FH Security key for verification.  
N/A  
2020–202FH  
2000–9FFFH  
0020–002FH  
2000–9FFFH  
2000–9FFFH Code, data, and reserved locations.  
16.9.2 Operating Environment  
In the auto programming mode, the PCCBs are loaded into the chip configuration registers. Since  
the device gets programming data through the external bus, the memory device in the program-  
ming system must correspond to the default configuration (Figure 16-6 on page 16-18). Auto pro-  
gramming requires an 8-bit bus configuration, so the circuit must tie the BUSWIDTH pin low.  
The PCCB defaults allow you to use any standard EPROM that satisfies the AC specifications  
listed in the device datasheet.  
The auto programming mode also loads CCB0 into an internal RAM location and checks the lock  
bits. If either lock bit is programmed, the auto programming routine compares the internal secu-  
rity key to the external security key location. If the verification fails, the device enters an endless  
internal loop. If the security keys match, the routine continues. The auto programming routine  
uses the modified quick-pulse algorithm and the pulse width value programmed into the external  
EPROM.  
16.9.3 Auto Programming Routine  
Figure 16-13 illustrates the auto programming routine. This routine checks the security lock bits  
in CCB0; if either bit is programmed, it compares the internal security key to the external security  
key locations. If the security keys match, the routine continues; otherwise, the device enters an  
endless loop.  
16-27  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
No  
Yes  
Other  
Modes  
PMODE = 0CH  
?
Lock Bits  
Enabled  
?
No  
Yes  
Verify  
Security Key  
No  
Loop  
Forever  
Pass  
?
Yes  
Assert PACT#  
Load PPW  
Get External Data  
Yes  
Data = 0FFFFH  
?
No  
Execute Modified  
Quick-Pulse Algorithm  
then Return  
Error  
Programming  
?
No  
Yes  
Clear PVER  
Increment Address Pointer  
Deassert PACT#  
Loop Forever  
(Done)  
Top of  
OTPROM  
?
No  
Yes  
A0191-03  
Figure 16-13. Auto Programming Routine  
16-28  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PROGRAMMING THE NONVOLATILE MEMORY  
If the security key verification is successful, the routine loads the programming pulse width  
(PPW) value from the external EPROM into the internal PPW register. It then asserts PACT#, in-  
dicating that programming has begun. (PACT# is also active during reset, although no program-  
ming is in progress.) PVER is initially asserted and remains asserted unless an error is detected,  
in which case it is deasserted.  
The routine then reads the contents of the external EPROM, beginning at 4000H (2000H for the  
8XC196MH). It skips any word that contains FFFFH (unprogrammed state). When it reads a  
word that contains any value other than FFFFH, the routine calls the modified quick-pulse algo-  
rithm, which writes that value to the OTPROM, using the appropriate number of pulses for the  
device, then verifies the result. The routine repeats this activity until the entire OTPROM is pro-  
grammed, then deasserts PACT# and enters an endless loop.  
16.9.4 Auto Programming Procedure  
If a glitch or reset occurs while programming the security key and lock bits, an unknown security  
key might accidentally be written, rendering the device inaccessible for further programming. To  
minimize this possibility, follow this recommended programming procedure.  
NOTE  
All addresses are given for the circuit shown in Figure 16-12 on page 16-26. If  
you choose a different circuit, you must adjust the addresses accordingly.  
1. Using a blank EPROM device, follow these steps to skip programming of CCB0 and  
program the rest of the OTPROM array, including the security key.  
— Place the programming pulse width (PPW) in external EPROM locations 14H–15H  
(for the 8XC196MC, MD) or 105E–105FH (for the 8XC196MH).  
— Leave the external CCB0 location (4018H) unprogrammed (0FFFFH).  
— Place the appropriate CCB1 value at external location 401AH.  
— Place the security key to be programmed in external EPROM locations 4020H–402FH  
(for the 8XC196MC, MD) or 0020–002FH (for the 8XC196MH).  
— Place the value 20H in external EPROM locations 4019H and 401BH (for the reserved  
OTPROM locations that require this value).  
— Place the desired code in the remaining external EPROM locations 4000–7FFFH (for  
the 8XC196MC, MD) or 2000–9FFFH (for the 8XC196MH).  
— Execute the power-up sequence (page 16-14) to initiate auto programming.  
— When programming is complete, execute the powerdown sequence (page 16-14) before  
continuing to step 2.  
16-29  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
2. Using another blank EPROM device, follow these steps to program only CCB0.  
— Place the programming pulse width (PPW) in external locations 14H–15H.  
— Place the appropriate CCB0 value in external location 4018H.  
— Place the security key to be verified in external EPROM locations 0020H–002FH. This  
value must match the security key programmed in step 1.  
— Leave the remaining EPROM locations unprogrammed (0FFFFH).  
— Execute the power-up sequence (page 16-14) to initiate auto programming.  
— When programming is complete, follow the powerdown sequence (page 16-14).  
At this point, you can modify the circuit, then use ROM-dump mode to write the entire OTPROM  
array to an external memory device and verify its contents. (See “ROM-dump Mode” for details.)  
16.9.5 ROM-dump Mode  
The ROM-dump mode provides an easy way to verify the contents of the OTPROM array after  
auto programming. Use the same circuit as for auto programming, but change the connections of  
the PMODE (P0.7:4) pins. To select ROM-dump mode (PMODE=6H), connect P0.6 and P0.5 to  
VCC and connect P0.7 and P0.4 to ground. The same bank switching mechanism is used and the  
memory map is the same as that for auto programming. The example circuit (Figure 16-12 on  
page 16-26) does not show the necessary WR# and VPP connections to allow writing to the  
EPROM. And although the example uses an EPROM, you could also use a RAM device. Alter-  
natively, you could dump the OTPROM contents to any 16-bit parallel port.  
NOTE  
If you have programmed the DED bit (USFR.2), ROM-dump mode is  
disabled. (See “Controlling Fetches from External Memory” on page 16-6).  
To enter ROM-dump mode, follow the power-up sequence on page 16-14. The ROM-dump mode  
checks the security key, regardless of the CCR security-lock bits. If you have programmed a se-  
curity key, a matching key must reside in the external memory; otherwise, the device enters an  
endless loop. If the security key verifies, ROM-dump mode fetches the PPW, then writes the en-  
tire OTPROM array to external memory. PACT# remains low while the dump is in progress, then  
goes high to indicate that the dump is complete.  
16.10 PCCB AND UPROM PROGRAMMING (8XC196MH ONLY)  
The PCCB and UPROM programming modes are useful if you have auto programmed and veri-  
fied the rest of the OTPROM array and now need to program only the PCCB and UPROM bits.  
(With slave programming mode, you can program the PCCB and UPROM bits along with the rest  
of the array.)  
16-30  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PROGRAMMING THE NONVOLATILE MEMORY  
Figure 16-14 shows the recommended circuit for PCCB and UPROM programming. In these cir-  
cuits, the PBUS holds data to be written to the OTPROM, PALE# begins programming, and  
PVER drives an LED that lights to indicate successful programming.  
VCC  
20 pF  
1.0µF  
20 pF  
100 kΩ  
XTAL1  
XTAL2  
Reset  
RESET#  
VCC  
VSS  
+5.0V  
VCC  
1 kΩ  
74HC14  
READY/P5.6  
NMI  
10µF  
BUSWIDTH/P5.7  
EA#  
VPP  
+12.50V  
VCC  
VCC  
10kΩ  
VREF  
SW1  
Pullups Required  
P4.7 – P3.0  
P0.7  
P0.6  
P0.5  
P4.7:0  
P3.7:0  
P0.4  
P0.3:0  
P1.4:0  
P2.5:2  
ANGND  
PMODE = 0DH PCCB Mode  
PMODE = 09H UPROM Mode  
PCCB/UPROM  
Value  
SW2  
VCC  
P2.1/PALE#  
10kΩ  
Push to Program  
270kΩ  
P2.0/PVER  
74HC14  
87C196 Device  
A3003-02  
Figure 16-14. PCCB and UPROM Programming Circuit  
To enter either mode, follow the standard power-up sequence (page 16-14) after setting the values  
listed in Table 16-13. If you want to program both the PCCB and the UPROM bits, program one  
of them and complete the power-down sequence. Then reconfigure the PMODE and port 3 pins  
and repeat the power-up sequence.  
16-31  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table 16-13. PCCB and UPROM Programming Values  
PCCB Programming UPROM Programming  
Pins  
PMODE3:0 0DH  
09H  
P4.7:0  
P3.7:0  
FFH  
FFH  
Data to be programmed in PCCB  
Value to program UPROM bits:  
(See CCR descriptions in Appendix C)  
04H to program DED only  
08H to program DEI only  
0CH to program both DED and DEI  
Assert PALE# to begin programming. The algorithm sends five programming pulses that write  
the port 3 data to the OTPROM, then it compares the input data with the programmed data. If the  
programming verifies, the PVER signal lights the LED to indicate successful programming. Oth-  
erwise, you can pulse PALE# to repeat programming. Complete the procedure by following the  
power-down sequence (page 16-14).  
NOTE  
The PCCB and UPROM programming modes are available only for the  
8XC196MH device. The pulse width is 200 µs at 8 MHz or 266 µs at 6 MHz.  
16.11 RUN-TIME PROGRAMMING  
You can program an OTPROM location during normal code execution. To make the OTPROM  
array accessible, apply VCC voltage to EA# while you reset the device. Apply VPP voltage to the  
VPP pin during the entire programming process. Then simply write to the location to be pro-  
grammed.  
NOTE  
Programming either security-lock bit in CCB0 disables run-time  
programming. (For details, see “Controlling Access to the OTPROM During  
Normal Operation” on page 16-4.)  
Immediately after writing to the OTPROM, the device must either enter idle mode or execute  
code from external memory. An access to OTPROM would abort the current programming cycle.  
Each programming cycle begins when a word is written to the OTPROM and ends when the next  
OTPROM access occurs. Each word requires a total of five programming cycles, each of which  
must be approximately 100 µs in duration.  
Figure 16-15 is a run-time programming example. It performs five programming cycles for each  
word. After each programming cycle, the code causes the device to enter idle mode.  
16-32  
Download from Www.Somanuals.com. All Manuals Search And Download.  
PROGRAMMING THE NONVOLATILE MEMORY  
The calling routine must pass two parameters to this routine — the data to be programmed (in  
DATA_TEMP) and the address (in ADDR_TEMP).  
PROGRAM:  
PUSHA  
LD  
LD  
;clear PSW, WSR, INT_MASK, INT_MASK1  
;select 32-byte window with EPA0_CON  
;set up for 5 programming cycles  
;clear EPA0 pending bit  
;enable EPA0 interrupt  
;set up EPA0 as software timer  
WSR,#7BH  
COUNT,#5  
ANDB INT_PEND,#CLEAR_EPA0  
LDB INT_MASK,#ENABLE_EPA0  
LDB EPA0_CON,#EPA0_TIMER  
LOOP:  
LD  
TEMP0,TIMER1  
;load TIMER1 value into TEMP0  
ADD EPA0_TIME,TEMP0,#PGM_PULSE  
;load EPA0_TIME with TIMER1 + PGM_PULSE  
;enable unmasked interrupt(EPA0)  
;store passed data at passed address  
;enter idle mode  
EI  
ST  
IDLPD #1  
DATA_TEMP,[ADDR_TEMP]  
DJNZ COUNT,LOOP  
;decrement COUNT and loop if not 0  
;to complete 5 programming cycles  
;restore PSW, WSR, and INT_MASKs  
POPA  
RET  
EPA0_ISR:  
RET  
Figure 16-15. Run-time Programming Code Example  
16-33  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
A
Instruction Set  
Reference  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
APPENDIX A  
INSTRUCTION SET REFERENCE  
®
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.  
Table A-1 on page A-2 is a map of the opcodes.  
Table A-2 on page A-4 defines the processor status word (PSW) flags.  
Table A-3 on page A-5 shows the effect of the PSW flags or a specified register bit on  
conditional jump instructions.  
Table A-4 on page A-5 defines the symbols used in Table A-6.  
Table A-5 on page A-6 defines the variables used in Table A-6 to represent instruction  
operands.  
Table A-6 beginning on page A-7 lists the instructions alphabetically, describes each of  
them, and shows the effect of each instruction on the PSW flags.  
Table A-7 beginning on page A-41 lists the instruction opcodes, in hexadecimal order,  
along with the corresponding instruction mnemonics.  
Table A-8 on page A-47 lists instruction lengths and opcodes for each applicable addressing  
mode.  
Table A-9 on page A-52 lists instruction execution times, expressed in state times.  
NOTE  
The # symbol prefixes an immediate value in immediate addressing mode.  
Chapter 3, “Programming Considerations,” describes the operand types and  
addressing modes.  
A-1  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-1. Opcode Map (Left Half)  
Opcode  
0x  
x0  
x1  
x2  
x3  
x4  
XCH  
di  
x5  
x6  
x7  
SKIP  
CLR  
NOT  
NEG  
DEC  
EXT  
INC  
CLRB  
NOTB  
NEGB  
XCHB  
di  
DECB  
EXTB  
INCB  
1x  
2x  
3x  
4x  
5x  
6x  
7x  
8x  
9x  
Ax  
Bx  
Cx  
Dx  
SJMP  
JBC  
bit 0  
di  
bit 1  
bit 2  
in  
bit 3  
ix  
bit 4  
di  
bit 5  
bit 6  
in  
bit 7  
ix  
AND 3op  
ADD 3op  
im  
im  
im  
im  
im  
im  
ANDB 3op  
ADDB 3op  
di  
in  
ix  
di  
in  
ix  
AND 2op  
ADD 2op  
di  
in  
ix  
di  
in  
ix  
ANDB 2op  
im in  
ADDB 2op  
im in  
di  
ix  
di  
ix  
OR  
ORB  
LD  
XOR  
XORB  
ADDC  
ADDCB  
di  
im  
im  
im  
in  
in  
in  
in  
ix  
di  
im  
im  
im  
im  
in  
in  
in  
in  
ix  
di  
ix  
di  
ix  
di  
ix  
di  
ix  
LDB  
di  
ST  
im  
ix  
di  
STB  
di  
ix  
BMOV  
ST  
CMPL  
JNV  
STB  
di  
in  
ix  
in  
ix  
JNST  
JNH  
JGT  
JNC  
JNVT  
JGE  
JNE  
BR  
in  
Ex  
Fx  
DJNZ  
RET  
DJNZW  
TIJMP  
LJMP  
TRAP  
PUSHF  
POPF  
PUSHA  
POPA  
IDLPD  
NOTE: The first digit of the opcode is listed vertically, and the second digit is listed horizontally. The  
related instruction mnemonic is shown at the intersection of the two digits. Shading indicates  
reserved opcodes. If the CPU attempts to execute an unimplemented opcode, an interrupt  
occurs. For more information, see “Unimplemented Opcode” on page 5-6.  
A-2  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
Table A-1. Opcode Map (Right Half)  
Opcode  
0x  
x8  
x9  
xA  
xB  
XCH  
ix  
xC  
xD  
xE  
xF  
SHR  
SHL  
SHRA  
SHRL  
SHLL  
SHRAL  
NORML  
SHRB  
SHLB  
SHRAB  
XCHB  
ix  
1x  
2x  
3x  
4x  
5x  
6x  
7x  
8x  
9x  
Ax  
Bx  
Cx  
SCALL  
JBS  
bit 0  
di  
bit 1  
bit 2  
in  
bit 3  
ix  
bit 4  
di  
bit 5  
bit 6  
bit 7  
ix  
SUB 3op  
MULU 3op (Note 2)  
im in  
MULUB 3op (Note 2)  
im in  
MULU 2op (Note 2)  
im in  
MULUB 2op (Note 2)  
im in  
DIVU (Note 2)  
im in  
DIVUB (Note 2)  
im  
im  
im  
SUBB 3op  
di  
in  
ix  
di  
ix  
SUB 2op  
di  
in  
ix  
di  
ix  
SUBB 2op  
im in  
di  
ix  
di  
ix  
CMP  
CMPB  
SUBC  
SUBCB  
PUSH  
di  
im  
im  
im  
im  
in  
in  
in  
in  
ix  
di  
ix  
di  
ix  
di  
im  
im  
im  
in  
in  
in  
ix  
LDBZE  
LDBSE  
di  
ix  
di  
ix  
di  
ix  
di  
POP  
di  
ix  
BMOVI  
POP  
di  
im  
in  
ix  
in  
ix  
JST  
JH  
JLE  
JC  
JVT  
JV  
JLT  
JE  
Dx  
Ex  
DPTS  
(Note 1)  
LCALL  
RST  
CLRC  
SETC  
DI  
EI  
CLRVT  
NOP  
signed  
MUL/DIV  
(Note 2)  
Fx  
NOTES:  
1. This opcode is reserved, but it does not generate an unimplemented opcode interrupt.  
2. Signed multiplication and division are two-byte instructions. The first byte is “FE” and the second is the  
opcode of the corresponding unsigned instruction.  
A-3  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-2. Processor Status Word (PSW) Flags  
Mnemonic  
Description  
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
0
1
Value of Bits Shifted Off  
< ½ LSB  
½ 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
0
0
1
1
ST  
0
Value of Bits Shifted Off  
= 0  
1
> 0 and < ½ LSB  
= ½ LSB  
0
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 3,  
“Programming Considerations,” defines the operands and possible values for each.)  
Instruction Quotient Stored in: V Flag Set if Quotient is:  
DIVB  
DIV  
Short-integer  
Integer  
< –128 or > +127 (< 81H or > 7FH)  
< –32768 or > +32767 (< 8001H or > 7FFFH)  
> 255 (FFH)  
DIVUB Byte  
DIVU Word  
> 65535 (FFFFH)  
VT  
Z
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.  
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.  
A-4  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
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  
decremented byte 0  
decremented word 0  
specified register bit = 0  
specified register bit = 1  
C = 0  
Continues if  
DJNZ  
decremented byte = 0  
decremented word = 0  
specified register bit = 1  
specified register bit = 0  
C = 1  
DJNZW  
JBC  
JBS  
JNC  
JNH  
JC  
C = 0 OR Z = 1  
C = 1  
C = 1 AND Z = 0  
C = 0  
JH  
C = 1 AND Z = 0  
N = 0  
C = 0 OR Z = 1  
N = 1  
JGE  
JGT  
JLT  
N = 0 AND Z = 0  
N = 1  
N = 1 OR Z = 1  
N = 0  
JLE  
JNST  
JST  
JNV  
JV  
N = 1 OR Z = 1  
ST = 0  
N = 0 AND Z = 0  
ST = 1  
ST = 1  
ST = 0  
V = 0  
V = 1  
V = 1  
V = 0  
JNVT  
JVT  
JNE  
JE  
VT = 0  
VT = 1 (clears VT)  
VT = 0  
VT = 1 (clears VT)  
Z = 0  
Z = 1  
Z = 1  
Z = 0  
.
Table A-4. PSW Flag Setting Symbols  
Description  
Symbol  
1
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.  
The instruction sets the flag.  
0
The instruction clears the flag.  
?
The instruction leaves the flag in an indeterminate state.  
A-5  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-5 defines the variables that are used in Table A-6 to represent the instruction operands.  
Table A-5. Operand Variables  
Variable  
aa  
Description  
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  
bbb  
A byte operand that is addressed by any addressing mode.  
A 3-bit field within an opcode that selects a specific bit within a register.  
A 3-bit field within an opcode that selects one of the eight bits in a byte.  
bitno  
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.  
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†  
Slreg†  
A byte register in the lower register file that serves as the source of the instruction operation.  
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.  
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.  
A-6  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
Table A-6. Instruction Set  
Operation  
ADD WORDS. Adds the source and  
Mnemonic  
Instruction Format  
ADD  
DEST, SRC  
wreg, waop  
(2 operands) destination word operands and stores the  
ADD  
sum into the destination operand.  
(011001aa) (waop) (wreg)  
(DEST) (DEST) + (SRC)  
PSW Flag Settings  
Z
N
C
V
VT ST  
ADD  
ADD WORDS. Adds the two source word  
DEST, SRC1, SRC2  
Dwreg, Swreg, waop  
(010001aa) (waop) (Swreg) (Dwreg)  
(3 operands) operands and stores the sum into the  
destination operand.  
ADD  
(DEST) (SRC1) + (SRC2)  
PSW Flag Settings  
Z
N
C
V
VT ST  
ADDB  
ADD BYTES. Adds the source and  
DEST, SRC  
breg, baop  
(011101aa) (baop) (breg)  
(2 operands) destination byte operands and stores the sum  
into the destination operand.  
ADDB  
(DEST) (DEST) + (SRC)  
PSW Flag Settings  
Z
N
C
V
VT ST  
ADDB  
ADD BYTES. Adds the two source byte  
DEST, SRC1, SRC2  
Dbreg, Sbreg, baop  
(010101aa) (baop) (Sbreg) (Dbreg)  
(3 operands) operands and stores the sum into the  
ADDB  
destination operand.  
(DEST) (SRC1) + (SRC2)  
PSW Flag Settings  
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, SRC  
wreg, waop  
(101001aa) (waop) (wreg)  
ADDC  
(DEST) (DEST) + (SRC) + C  
PSW Flag Settings  
Z
N
C
V
VT ST  
A-7  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-6. Instruction Set (Continued)  
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, SRC  
ADDCB breg, baop  
(101101aa) (baop) (breg)  
(DEST) (DEST) + (SRC) + C  
PSW Flag Settings  
Z
N
C
V
VT ST  
AND  
LOGICAL AND WORDS. ANDs the source  
DEST, SRC  
wreg, waop  
(011000aa) (waop) (wreg)  
(2 operands) 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.  
AND  
(DEST) (DEST) AND (SRC)  
PSW Flag Settings  
Z
N
C
V
VT ST  
0
0
AND  
LOGICAL AND WORDS. ANDs the two  
DEST, SRC1, SRC2  
Dwreg, Swreg, waop  
(010000aa) (waop) (Swreg) (Dwreg)  
(3 operands) 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  
(DEST) (SRC1) AND (SRC2)  
PSW Flag Settings  
Z
N
C
V
VT ST  
0
0
ANDB  
LOGICAL AND BYTES. ANDs the source  
DEST, SRC  
breg, baop  
(011100aa) (baop) (breg)  
(2 operands) 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.  
ANDB  
(DEST) (DEST) AND (SRC)  
PSW Flag Settings  
Z
N
C
V
VT ST  
0
0
A-8  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
Table A-6. Instruction Set (Continued)  
Mnemonic  
Operation  
Instruction Format  
ANDB  
LOGICAL AND BYTES. ANDs the two source  
DEST, SRC1, SRC2  
Dbreg, Sbreg, baop  
(3 operands) 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  
(010100aa) (baop) (Sbreg) (Dbreg)  
(DEST) (SRC1) AND (SRC2)  
PSW Flag Settings  
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 word data can be  
located anywhere in register RAM, but should  
not overlap.  
PTRS, CNTREG  
lreg, wreg  
BMOV  
(11000001) (wreg) (lreg)  
NOTE: The pointers are autoincre-  
mented during this instruction.  
However, CNTREG is not decre-  
mented. Therefore, it is easy to  
unintentionally create a long,  
uninterruptible operation with the  
BMOV instruction. Use the  
BMOVI instruction for an interrupt-  
ible operation.  
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  
end_if  
PSW Flag Settings  
Z
N
C
V
VT ST  
A-9  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-6. Instruction Set (Continued)  
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 word data can be located anywhere in  
register RAM, but should not overlap.  
PTRS, CNTREG  
BMOVI lreg, wreg  
(11001101) (wreg) (lreg)  
NOTE: The pointers are autoincre-  
mented during this instruction.  
However, CNTREG is decre-  
mented only when the instruction  
is interrupted. When BMOVI is  
interrupted, CNTREG is updated  
to store the interim word count at  
the time of the interrupt. For this  
reason, you should always reload  
CNTREG before starting a  
BMOVI.  
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  
end_if  
PSW Flag Settings  
Z
N
C
V
VT ST  
BR  
BRANCH INDIRECT. Continues execution at  
the address specified in the operand word  
register.  
DEST  
BR  
[wreg]  
(11100011) (wreg)  
PC (DEST)  
PSW Flag Settings  
Z
N
C
V
VT ST  
CLR  
CLEAR WORD. Clears the value of the  
operand.  
DEST  
wreg  
(00000001) (wreg)  
CLR  
(DEST) 0  
PSW Flag Settings  
Z
N
C
V
VT ST  
1
0
0
0
A-10  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
Table A-6. Instruction Set (Continued)  
Mnemonic  
Operation  
Instruction Format  
DEST  
breg  
CLRB  
CLEAR BYTE. Clears the value of the  
operand.  
CLRB  
(DEST) 0  
(00010001) (breg)  
PSW Flag Settings  
Z
N
C
V
VT ST  
1
0
0
0
CLRC  
CLEAR CARRY FLAG. Clears the carry flag.  
C 0  
CLRC  
(11111000)  
PSW Flag Settings  
Z
N
C
V
VT ST  
0
CLRVT  
CLEAR OVERFLOW-TRAP FLAG. Clears  
the overflow-trap flag.  
CLRVT  
VT 0  
(11111100)  
PSW Flag Settings  
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  
wreg, waop  
(100010aa) (waop) (wreg)  
CMP  
(DEST) – (SRC)  
PSW Flag Settings  
Z
N
C
V
VT ST  
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  
breg, baop  
(100110aa) (baop) (breg)  
CMPB  
(DEST) – (SRC)  
PSW Flag Settings  
Z
N
C
V
VT ST  
A-11  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-6. Instruction Set (Continued)  
Mnemonic  
Operation  
Instruction Format  
CMPL  
COMPARE LONG. Compares the  
DEST, SRC  
Dlreg, Slreg  
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.  
CMPL  
(11000101) (Slreg) (Dlreg)  
(DEST) – (SRC)  
PSW Flag Settings  
Z
N
C
V
VT ST  
DEC  
DECB  
DI  
DECREMENT WORD. Decrements the value  
of the operand by one.  
DEST  
wreg  
(00000101) (wreg)  
DEC  
(DEST) (DEST) –1  
PSW Flag Settings  
Z
N
C
V
VT ST  
DECREMENT BYTE. Decrements the value  
of the operand by one.  
DEST  
breg  
DECB  
(DEST) (DEST) –1  
(00010101) (breg)  
PSW Flag Settings  
Z
N
C
V
VT ST  
DISABLE INTERRUPTS. Disables  
interrupts. Interrupt calls cannot occur after  
this instruction.  
DI  
(11111010)  
Interrupt Enable (PSW.1) 0  
PSW Flag Settings  
Z
N
C
V
VT ST  
A-12  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
Table A-6. Instruction Set (Continued)  
Mnemonic  
Operation  
Instruction Format  
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.  
DEST, SRC  
lreg, waop  
DIV  
(11111110) (100011aa) (waop) (lreg)  
(low word DEST) (DEST) / (SRC)  
(high word DEST) (DEST) MOD (SRC)  
PSW Flag Settings  
Z
N
C
V
VT ST  
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.  
DEST, SRC  
wreg, baop  
(11111110) (100111aa) (baop) (wreg)  
DIVB  
(low byte DEST) (DEST) / (SRC)  
(high byte DEST) (DEST) MOD (SRC)  
PSW Flag Settings  
Z
N
C
V
VT ST  
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  
DEST, SRC  
lreg, waop  
(100011aa) (waop) (lreg)  
DIVU  
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)  
PSW Flag Settings  
Z
N
C
V
VT ST  
A-13  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-6. Instruction Set (Continued)  
Mnemonic  
Operation  
Instruction Format  
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  
DEST, SRC  
DIVUB wreg, baop  
(100111aa) (baop) (wreg)  
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)  
PSW Flag Settings  
Z
N
C
V
VT ST  
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.  
DJNZ  
breg, cadd  
(11100000) (breg) (disp)  
NOTE: The displacement (disp) is sign-  
extended to 16 bits.  
(COUNT) (COUNT) –1  
if (COUNT) 0 then  
PC PC + 8-bit disp  
end_if  
PSW Flag Settings  
Z
N
C
V
VT ST  
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.  
DJNZW wreg, cadd  
(11100001) (wreg) (disp)  
NOTE: The displacement (disp) is sign-  
extended to 16 bits  
(COUNT) (COUNT) –1  
if (COUNT) 0 then  
PC PC + 8-bit disp  
end_if  
PSW Flag Settings  
Z
N
C
V
VT ST  
A-14  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
Table A-6. Instruction Set (Continued)  
Mnemonic  
Operation  
Instruction Format  
DPTS  
DISABLE PERIPHERAL TRANSACTION  
SERVER (PTS). Disables the peripheral  
transaction server (PTS).  
DPTS  
(11101100)  
PTS Disable (PSW.2) 0  
PSW Flag Settings  
Z
N
C
V
VT ST  
EI  
ENABLE INTERRUPTS. Enables interrupts  
following the execution of the next statement.  
Interrupt calls cannot occur immediately  
following this instruction.  
EI  
(11111011)  
Interrupt Enable (PSW.1) 1  
PSW Flag Settings  
Z
N
C
V
VT ST  
EPTS  
ENABLE PERIPHERAL TRANSACTION  
SERVER (PTS). Enables the peripheral  
transaction server (PTS).  
EPTS  
(11101101)  
PTS Enable (PSW.2) 1  
PSW Flag Settings  
Z
N
C
V
VT ST  
EXT  
SIGN-EXTEND INTEGER INTO LONG-  
INTEGER. Sign-extends the low-order word  
of the operand throughout the high-order  
word of the operand.  
EXT  
lreg  
(00000110) (lreg)  
if DEST.15 = 1 then  
(high word DEST) 0FFFFH  
else  
(high word DEST) 0  
end_if  
PSW Flag Settings  
Z
N
C
V
VT ST  
0
0
A-15  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-6. Instruction Set (Continued)  
Operation Instruction Format  
Mnemonic  
EXTB  
SIGN-EXTEND SHORT-INTEGER INTO  
INTEGER. Sign-extends the low-order byte  
of the operand throughout the high-order byte  
of the operand.  
EXTB  
wreg  
(00010110) (wreg)  
if DEST.7 = 1 then  
(high byte DEST) 0FFH  
else  
(high byte DEST) 0  
end_if  
PSW Flag Settings  
Z
N
C
V
VT ST  
0
0
IDLPD  
IDLE/POWERDOWN. Depending on the 8-bit  
value of the KEY operand, this instruction  
causes the device to:  
IDLPD  
#key  
(11110110) (key)  
enter idle mode, if KEY=1,  
enter powerdown mode, if KEY=2,  
execute a reset sequence,  
if KEY = any value other than 1 or 2.  
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  
execute reset  
PSW Flag Settings  
Z
N
C
V
VT ST  
KEY = 1 or 2  
KEY = any value other than  
1 or 2  
0
0
0
0
0
0
INC  
INCREMENT WORD. Increments the value  
of the word operand by 1.  
INC  
wreg  
(DEST) (DEST) + 1  
(00000111) (wreg)  
PSW Flag Settings  
Z
N
C
V
VT ST  
0
A-16  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
Table A-6. Instruction Set (Continued)  
Mnemonic  
Operation  
Instruction Format  
INCB  
INCREMENT BYTE. Increments the value of  
the byte operand by 1.  
INCB  
breg  
(DEST) (DEST) + 1  
(00010111) (breg)  
PSW Flag Settings  
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.  
JBC  
breg, bitno, cadd  
(00110bbb) (breg) (disp)  
NOTE: The displacement (disp) is sign-  
extended to 16 bits.  
if (specified bit) = 0 then  
PC PC + 8-bit disp  
PSW Flag Settings  
Z
N
C
V
VT ST  
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.  
JBS  
breg, bitno, cadd  
(00111bbb) (breg) (disp)  
NOTE: The displacement (disp) is sign-  
extended to 16 bits.  
if (specified bit) = 1 then  
PC PC + 8-bit disp  
PSW Flag Settings  
Z
N
C
V
VT ST  
A-17  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-6. Instruction Set (Continued)  
Operation Instruction Format  
Mnemonic  
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.  
JC  
cadd  
(11011011) (disp)  
NOTE: The displacement (disp) is sign-  
extended to 16 bits.  
if C = 1 then  
PC PC + 8-bit disp  
PSW Flag Settings  
Z
N
C
V
VT ST  
JE  
JUMP IF EQUAL. Tests the zero flag. If the  
flag is clear, control passes to the next  
JE  
cadd  
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.  
(11011111) (disp)  
NOTE: The displacement (disp) is sign-  
extended to 16 bits.  
if Z = 1 then  
PC PC + 8-bit disp  
PSW Flag Settings  
Z
N
C
V
VT ST  
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.  
JGE  
cadd  
(11010110) (disp)  
NOTE: The displacement (disp) is sign-  
extended to 16 bits.  
if N = 0 then  
PC PC + 8-bit disp  
PSW Flag Settings  
Z
N
C
V
VT ST  
A-18  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
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.  
JGT  
cadd  
(11010010) (disp)  
NOTE: The displacement (disp) is sign-  
extended to 16 bits.  
if N = 0 AND Z = 0 then  
PC PC + 8-bit disp  
PSW Flag Settings  
Z
N
C
V
VT ST  
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.  
JH  
cadd  
(11011001) (disp)  
NOTE: The displacement (disp) is sign-  
extended to 16 bits.  
if C = 1 AND Z = 0 then  
PC PC + 8-bit disp  
PSW Flag Settings  
Z
N
C
V
VT ST  
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.  
JLE  
cadd  
(11011010) (disp)  
NOTE: The displacement (disp) is sign-  
extended to 16 bits.  
if N = 1 OR Z = 1 then  
PC PC + 8-bit disp  
PSW Flag Settings  
Z
N
C
V
VT ST  
A-19  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-6. Instruction Set (Continued)  
Operation Instruction Format  
Mnemonic  
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.  
JLT  
cadd  
(11011110) (disp)  
NOTE: The displacement (disp) is sign-  
extended to 16 bits.  
if N = 1 then  
PC PC + 8-bit disp  
PSW Flag Settings  
Z
N
C
V
VT ST  
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.  
JNC  
cadd  
(11010011) (disp)  
NOTE: The displacement (disp) is sign-  
extended to 16 bits.  
if C = 0 then  
PC PC + 8-bit disp  
PSW Flag Settings  
Z
N
C
V
VT ST  
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.  
JNE  
cadd  
(11010111) (disp)  
NOTE: The displacement (disp) is sign-  
extended to 16 bits.  
if Z = 0 then  
PC PC + 8-bit disp  
PSW Flag Settings  
Z
N
C
V
VT ST  
A-20  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
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.  
JNH  
cadd  
(11010001) (disp)  
NOTE: The displacement (disp) is sign-  
extended to 16 bits.  
if C = 0 OR Z = 1 then  
PC PC + 8-bit disp  
PSW Flag Settings  
Z
N
C
V
VT ST  
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.  
JNST  
cadd  
(11010000) (disp)  
NOTE: The displacement (disp) is sign-  
extended to 16 bits.  
if ST = 0 then  
PC PC + 8-bit disp  
PSW Flag Settings  
Z
N
C
V
VT ST  
JNV  
JUMP IF OVERFLOW FLAG IS CLEAR.  
Tests the overflow flag. If the flag is set,  
control passes to the next sequential  
JNV  
cadd  
(11010101) (disp)  
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.  
NOTE: The displacement (disp) is sign-  
extended to 16 bits.  
if V = 0 then  
PC PC + 8-bit disp  
PSW Flag Settings  
Z
N
C
V
VT ST  
A-21  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-6. Instruction Set (Continued)  
Operation Instruction Format  
Mnemonic  
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  
JNVT  
cadd  
(11010100) (disp)  
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.  
NOTE: The displacement (disp) is sign-  
extended to 16 bits.  
if VT = 0 then  
PC PC + 8-bit disp  
PSW Flag Settings  
Z
N
C
V
VT ST  
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.  
JST  
cadd  
(11011000) (disp)  
NOTE: The displacement (disp) is sign-  
extended to 16 bits.  
if ST = 1 then  
PC PC + 8-bit disp  
PSW Flag Settings  
Z
N
C
V
VT ST  
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.  
JV  
cadd  
(11011101) (disp)  
NOTE: The displacement (disp) is sign-  
extended to 16 bits.  
if V = 1 then  
PC PC + 8-bit disp  
PSW Flag Settings  
Z
N
C
V
VT ST  
A-22  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
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.  
JVT  
cadd  
(11011100) (disp)  
NOTE: The displacement (disp) is sign-  
extended to 16 bits.  
if VT = 1 then  
PC PC + 8-bit disp  
PSW Flag Settings  
Z
N
C
V
VT ST  
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.  
LCALL cadd  
(11101111) (disp-low) (disp-high)  
SP SP – 2  
(SP) PC  
PC PC + 16-bit disp  
PSW Flag Settings  
Z
N
C
V
VT ST  
LD  
LOAD WORD. Loads the value of the source  
word operand into the destination operand.  
DEST, SRC  
LD  
wreg, waop  
(DEST) (SRC)  
(101000aa) (waop) (wreg)  
PSW Flag Settings  
Z
N
C
V
VT ST  
LDB  
LOAD BYTE. Loads the value of the source  
byte operand into the destination operand.  
DEST, SRC  
breg, baop  
(101100aa) (baop) (breg)  
LDB  
(DEST) (SRC)  
PSW Flag Settings  
Z
N
C
V
VT ST  
A-23  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-6. Instruction Set (Continued)  
Mnemonic  
Operation  
Instruction Format  
LDBSE  
LOAD BYTE SIGN-EXTENDED. Sign-  
extends the value of the source short-  
integer operand and loads it into the  
destination integer operand.  
DEST, SRC  
LDBSE wreg, baop  
(101111aa) (baop) (wreg)  
(low byte DEST) (SRC)  
if DEST.15 = 1 then  
(high word DEST) 0FFH  
else  
(high word DEST) 0  
end_if  
PSW Flag Settings  
Z
N
C
V
VT ST  
LDBZE  
LOAD BYTE ZERO-EXTENDED. Zero-  
extends the value of the source byte operand  
and loads it into the destination word  
operand.  
DEST, SRC  
LDBZE wreg, baop  
(101011aa) (baop) (wreg)  
(low byte DEST) (SRC)  
(high byte DEST) 0  
PSW Flag Settings  
Z
N
C
V
VT ST  
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.  
LJMP  
cadd  
(11100111) (disp-low) (disp-high)  
PC PC + 16-bit disp  
PSW Flag Settings  
Z
N
C
V
VT ST  
?
A-24  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
Table A-6. Instruction Set (Continued)  
Mnemonic  
Operation  
Instruction Format  
MUL  
MULTIPLY INTEGERS. Multiplies the source  
DEST, SRC  
lreg, waop  
(2 operands) 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.  
MUL  
(11111110) (011011aa) (waop) (lreg)  
(DEST) (DEST) × (SRC)  
PSW Flag Settings  
Z
N
C
V
VT ST  
?
MUL  
MULTIPLY INTEGERS. Multiplies the two  
DEST, SRC1, SRC2  
lreg, wreg, waop  
(11111110) (010011aa) (waop) (wreg) (lreg)  
(3 operands) 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  
(DEST) (SRC1) × (SRC2)  
PSW Flag Settings  
Z
N
C
V
VT ST  
?
MULB  
MULTIPLY SHORT-INTEGERS. Multiplies  
DEST, SRC  
wreg, baop  
(11111110) (011111aa) (baop) (wreg)  
(2 operands) 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.  
MULB  
(DEST) (DEST) × (SRC)  
PSW Flag Settings  
Z
N
C
V
VT ST  
?
MULB  
MULTIPLY SHORT-INTEGERS. Multiplies  
DEST, SRC1, SRC2  
wreg, breg, baop  
(11111110) (010111aa) (baop) (breg) (wreg)  
(3 operands) 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  
(DEST) (SRC1) × (SRC2)  
PSW Flag Settings  
Z
N
C
V
VT ST  
?
A-25  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-6. Instruction Set (Continued)  
Mnemonic  
Operation  
Instruction Format  
MULU  
MULTIPLY WORDS, UNSIGNED. Multiplies  
DEST, SRC  
lreg, waop  
(2 operands) 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.  
MULU  
(011011aa) (waop) (lreg)  
(DEST) (DEST) × (SRC)  
PSW Flag Settings  
Z
N
C
V
VT ST  
?
MULU  
MULTIPLY WORDS, UNSIGNED. Multiplies  
DEST, SRC1, SRC2  
lreg, wreg, waop  
(3 operands) 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  
(010011aa) (waop) (wreg) (lreg)  
(DEST) (SRC1) × (SRC2)  
PSW Flag Settings  
Z
N
C
V
VT ST  
?
MULUB  
MULTIPLY BYTES, UNSIGNED. Multiplies  
DEST, SRC  
MULUB wreg, baop  
(011111aa) (baop) (wreg)  
(2 operands) 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)  
PSW Flag Settings  
Z
N
C
V
VT ST  
?
MULUB  
MULTIPLY BYTES, UNSIGNED. Multiplies  
DEST, SRC1, SRC2  
MULUB wreg, breg, baop  
(3 operands) 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.  
(010111aa) (baop) (breg) (wreg)  
(DEST) (SRC1) × (SRC2)  
PSW Flag Settings  
Z
N
C
V
VT ST  
?
A-26  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
Table A-6. Instruction Set (Continued)  
Mnemonic  
Operation  
Instruction Format  
NEG  
NEGATE INTEGER. Negates the value of the  
integer operand.  
NEG  
wreg  
(DEST) – (DEST)  
(00000011) (wreg)  
PSW Flag Settings  
Z
N
C
V
VT ST  
NEGB  
NEGATE SHORT-INTEGER. Negates the  
value of the short-integer operand.  
NEGB  
breg  
(DEST) – (DEST)  
(00010011) (breg)  
PSW Flag Settings  
Z
N
C
V
VT ST  
NOP  
NO OPERATION. Does nothing. Control  
passes to the next sequential instruction.  
NOP  
(11111101)  
PSW Flag Settings  
Z
N
C
V
VT ST  
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.  
SRC, DEST  
NORML lreg, breg  
(00001111) (breg) (lreg)  
(COUNT) 0  
do while  
(MSB (DEST) = 0) AND (COUNT) < 31)  
(DEST) (DEST) × 2  
(COUNT) (COUNT) + 1  
end_while  
PSW Flag Settings  
Z
N
C
V
VT ST  
?
0
A-27  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-6. Instruction Set (Continued)  
Operation Instruction Format  
Mnemonic  
NOT  
COMPLEMENT WORD. Complements the  
value of the word operand (replaces each “1”  
with a “0” and each “0” with a “1”).  
NOT  
wreg  
(00000010) (wreg)  
(DEST) NOT (DEST)  
PSW Flag Settings  
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”).  
NOTB  
breg  
(00010010) (breg)  
(DEST) NOT (DEST)  
PSW Flag Settings  
Z
N
C
V
VT ST  
0
0
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  
DEST, SRC  
wreg, waop  
(100000aa) (waop) (wreg)  
OR  
destination operand had a “1”.  
(DEST) (DEST) OR (SRC)  
PSW Flag Settings  
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  
DEST, SRC  
breg, baop  
(100100aa) (baop) (breg)  
ORB  
destination operand had a “1”.  
(DEST) (DEST) OR (SRC)  
PSW Flag Settings  
Z
N
C
V
VT ST  
0
0
A-28  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
Table A-6. Instruction Set (Continued)  
Mnemonic  
Operation  
Instruction Format  
POP  
POP WORD. Pops the word on top of the  
stack and places it at the destination  
operand.  
POP  
waop  
(110011aa) (waop)  
(DEST) (SP)  
SP SP + 2  
PSW Flag Settings  
Z
N
C
V
VT ST  
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  
POPA  
(11110101)  
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  
PSW Flag Settings  
Z
N
C
V
VT ST  
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.  
POPF  
(11110011)  
(PSW)/INT_MASK (SP)  
SP SP + 2  
PSW Flag Settings  
Z
N
C
V
VT ST  
PUSH  
PUSH WORD. Pushes the word operand  
onto the stack.  
PUSH  
waop  
SP SP – 2  
(110010aa) (waop)  
(SP) (DEST)  
PSW Flag Settings  
Z
N
C
V
VT ST  
A-29  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-6. Instruction Set (Continued)  
Operation Instruction Format  
Mnemonic  
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.  
PUSHA  
(11110100)  
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  
PSW Flag Settings  
Z
N
C
V
VT ST  
0
0
0
0
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.  
PUSHF  
(11110010)  
SP SP – 2  
(SP) PSW/INT_MASK  
PSW/INT_MASK 0  
PSW Flag Settings  
Z
N
C
V
VT ST  
0
0
0
0
0
0
RET  
RETURN FROM SUBROUTINE. Pops the  
PC off the top of the stack.  
RET  
PC (SP)  
(11110000)  
SP SP + 2  
PSW Flag Settings  
Z
N
C
V
VT ST  
A-30  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
Table A-6. Instruction Set (Continued)  
Mnemonic  
Operation  
Instruction Format  
RST  
RESET SYSTEM. Initializes the PSW to zero,  
the PC to 2080H, and the pins and SFRs to  
their reset values. Executing this instruction  
causes the RESET# pin to be pulled low for  
16 state times.  
RST  
(11111111)  
SFR Reset Status  
Pin Reset Status  
PSW 0  
PC 2080H  
PSW Flag Settings  
Z
N
C
V
VT ST  
0
0
0
0
0
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.  
SCALL cadd  
(00101xxx) (disp-low)  
NOTE: The displacement (disp) is sign-  
extended to 16-bits.  
SP SP – 2  
(SP) PC  
PCPC +11-bit disp  
PSW Flag Settings  
Z
N
C
V
VT ST  
SETC  
SET CARRY FLAG. Sets the carry flag.  
C 1  
SETC  
(11111001)  
PSW Flag Settings  
Z
N
C
V
VT ST  
1
A-31  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
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  
SHL  
wreg, #count  
(00001001) (count) (wreg)  
value in the range of 0 to 15 (0FH), inclusive, or  
or as the content of any register (10H –  
SHL  
wreg, breg  
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.  
(00001001) (breg) (wreg)  
Temp (COUNT)  
do while Temp 0  
C High order bit of (DEST)  
(DEST) (DEST) × 2  
Temp Temp – 1  
end_while  
PSW Flag Settings  
Z
N
C
V
VT ST  
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  
SHLB  
breg, #count  
(00011001) (count) (breg)  
value in the range of 0 to 15 (0FH), inclusive, or  
or as the content of any register (10H –  
SHLB  
breg, breg  
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.  
(00011001) (breg) (breg)  
Temp (COUNT)  
do while Temp 0  
C High order bit of (DEST)  
(DEST) (DEST) × 2  
Temp Temp – 1  
end_while  
PSW Flag Settings  
Z
N
C
V
VT ST  
A-32  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
Table A-6. Instruction Set (Continued)  
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  
SHLL  
lreg, #count  
(00001101) (count) (lreg)  
as an immediate value in the range of 0 to 15 or  
(0FH), inclusive, or as the content of any  
SHLL  
lreg, breg  
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.  
(00001101) (breg) (lreg)  
Temp (COUNT)  
do while Temp 0  
C High order bit of (DEST)  
(DEST) (DEST) × 2  
Temp Temp – 1  
end_while  
PSW Flag Settings  
Z
N
C
V
VT ST  
SHR  
LOGICAL RIGHT SHIFT WORD. Shifts the  
destination word operand to the right as  
many times as specified by the count  
SHR  
wreg, #count  
(00001000) (count) (wreg)  
operand. The count may be specified either  
as an immediate value in the range of 0 to 15 or  
(0FH), inclusive, or as the content of any  
SHR  
wreg, breg  
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.  
(00001000) (breg) (wreg)  
NOTES: This instruction clears the  
sticky bit flag at the beginning  
of the instruction. If at any time  
during the shift a “1” is shifted  
into the carry flag and another  
shift cycle occurs, the instruc-  
tion sets the sticky bit 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  
Z
N
C
V
VT ST  
0
0
A-33  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
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  
SHRA  
wreg, #count  
(00001010) (count) (wreg)  
operand. The count may be specified either  
as an immediate value in the range of 0 to 15 or  
(0FH), inclusive, or as the content of any  
SHRA  
wreg, breg  
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.  
(00001010) (breg) (wreg)  
NOTES: This instruction clears the  
sticky bit flag at the beginning  
of the instruction. If at any time  
during the shift a “1” is shifted  
into the carry flag and another  
shift cycle occurs, the instruc-  
tion sets the sticky bit 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  
Z
N
C
V
VT ST  
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  
SHRAB breg, #count  
(00011010) (count) (breg)  
or  
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.  
SHRAB breg, breg  
(00011010) (breg) (breg)  
NOTES: This instruction clears the  
sticky bit flag at the beginning  
of the instruction. If at any time  
during the shift a “1” is shifted  
into the carry flag and another  
shift cycle occurs, the instruc-  
tion sets the sticky bit 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  
Z
N
C
V
VT ST  
0
A-34  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
Table A-6. Instruction Set (Continued)  
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.  
SHRAL lreg, #count  
(00001110) (count) (lreg)  
or  
SHRAL lreg, breg  
(00001110) (breg) (lreg)  
NOTES: This instruction clears the  
sticky bit flag at the beginning  
of the instruction. If at any time  
during the shift a “1” is shifted  
into the carry flag and another  
shift cycle occurs, the instruc-  
tion sets the sticky bit 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  
Z
N
C
V
VT ST  
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  
SHRB  
breg, #count  
(00011000) (count) (breg)  
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.  
or  
SHRB  
breg, breg  
(00011000) (breg) (breg)  
NOTES: This instruction clears the  
sticky bit flag at the beginning  
of the instruction. If at any time  
during the shift a “1” is shifted  
into the carry flag and another  
shift cycle occurs, the instruc-  
tion sets the sticky bit 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  
Z
N
C
V
VT ST  
0
0
A-35  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
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  
SHRL  
lreg, #count  
(00001100) (count) (lreg)  
either as an immediate value in the range of 0 or  
to 15 (0FH), inclusive, or as the content of  
SHRL  
lreg, breg  
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.  
(00001100) (breg) (lreg)  
NOTES: This instruction clears the  
sticky bit flag at the beginning  
of the instruction. If at any time  
during the shift a “1” is shifted  
into the carry flag and another  
shift cycle occurs, the instruc-  
tion sets the sticky bit 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  
Z
N
C
V
VT ST  
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.  
SJMP  
cadd  
(00100xxx) (disp-low)  
PC PC + 11-bit disp  
NOTE: The displacement (disp) is sign-  
extended to 16 bits.  
PSW Flag Settings  
Z
N
C
V
VT ST  
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.  
SKIP  
breg  
(00000000) (breg)  
PSW Flag Settings  
Z
N
C
V
VT ST  
A-36  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
Table A-6. Instruction Set (Continued)  
Mnemonic  
ST  
Operation  
Instruction Format  
STORE WORD. Stores the value of the  
source (leftmost) word operand into the  
destination (rightmost) operand.  
SRC, DEST  
wreg, waop  
ST  
(110000aa) (waop) (wreg)  
(DEST) (SRC)  
PSW Flag Settings  
Z
N
C
V
VT ST  
STB  
STORE BYTE. Stores the value of the source  
(leftmost) byte operand into the destination  
(rightmost) operand.  
SRC, DEST  
breg, baop  
(110001aa) (baop) (breg)  
STB  
(DEST) (SRC)  
PSW Flag Settings  
Z
N
C
V
VT ST  
SUB  
SUBTRACT WORDS. Subtracts the source  
DEST, SRC  
wreg, waop  
(011010aa) (waop) (wreg)  
(2 operands) word operand from the destination word  
operand, stores the result in the destination  
operand, and sets the carry flag as the  
complement of borrow.  
SUB  
(DEST) (DEST) – (SRC)  
PSW Flag Settings  
Z
N
C
V
VT ST  
SUB  
SUBTRACT WORDS. Subtracts the first  
DEST, SRC1, SRC2  
Dwreg, Swreg, waop  
(010010aa) (waop) (Swreg) (Dwreg)  
(3 operands) source word operand from the second, stores  
SUB  
the result in the destination operand, and sets  
the carry flag as the complement of borrow.  
(DEST) (SRC1) – (SRC2)  
PSW Flag Settings  
Z
N
C
V
VT ST  
A-37  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-6. Instruction Set (Continued)  
Mnemonic  
Operation  
Instruction Format  
SUBB  
SUBTRACT BYTES. Subtracts the source  
DEST, SRC  
breg, baop  
(2 operands) byte operand from the destination byte  
operand, stores the result in the destination  
operand, and sets the carry flag as the  
complement of borrow.  
SUBB  
(011110aa) (baop) (breg)  
(DEST) (DEST) – (SRC)  
PSW Flag Settings  
Z
N
C
V
VT ST  
SUBB  
SUBTRACT BYTES. Subtracts the first  
DEST, SRC1, SRC2  
Dbreg, Sbreg, baop  
(010110aa) (baop) (Sbreg) (Dbreg)  
(3 operands) source byte operand from the second, stores  
the result in the destination operand, and sets  
the carry flag as the complement of borrow.  
SUBB  
(DEST) (SRC1) – (SRC2)  
PSW Flag Settings  
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, SRC  
wreg, waop  
SUBC  
(101010aa) (waop) (wreg)  
(DEST) (DEST) – (SRC) – (1–C)  
PSW Flag Settings  
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, SRC  
SUBCB breg, baop  
(101110aa) (baop) (breg)  
(DEST) (DEST) – (SRC) – (1–C)  
PSW Flag Settings  
Z
N
C
V
VT ST  
A-38  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
Table A-6. Instruction Set (Continued)  
Mnemonic  
Operation  
Instruction Format  
TIJMP  
TABLE INDIRECT JUMP. Causes execution  
to continue at an address selected from a  
table of addresses.  
TIJMP  
TBASE, [INDEX], #MASK  
(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.  
NOTE: TIJMP multiplies OFFSET by two  
to provide for word alignment of  
the jump table.  
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).  
[INDEX] AND #MASK = OFFSET  
(2 × OFFSET) + TBASE = DEST X  
PC (DEST X)  
PSW Flag Settings  
Z
N
C
V
VT ST  
TRAP  
SOFTWARE TRAP. This instruction causes  
an interrupt call that is vectored through  
location 2010H. 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.  
TRAP  
(11110111)  
NOTE: This instruction is not supported  
by assemblers. The TRAP  
SP SP – 2  
(SP) PC  
instruction is intended for use by  
development tools. These tools  
may not support user-application  
of this instruction.  
PC (2010H)  
PSW Flag Settings  
Z
N
C
V
VT ST  
A-39  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-6. Instruction Set (Continued)  
Mnemonic  
Operation  
Instruction Format  
XCH  
EXCHANGE WORD. Exchanges the value of  
the source word operand with that of the  
destination word operand.  
DEST, SRC  
wreg, waop  
XCH  
(00000100) (waop) (wreg) direct  
(00001011) (waop) (wreg) indexed  
(DEST) (SRC)  
PSW Flag Settings  
Z
N
C
V
VT ST  
XCHB  
EXCHANGE BYTE. Exchanges the value of  
the source byte operand with that of the  
destination byte operand.  
DEST, SRC  
XCHB  
breg, baop  
(00010100) (baop) (breg) direct  
(00011011) (baop) (breg) indexed  
(DEST) (SRC)  
PSW Flag Settings  
Z
N
C
V
VT ST  
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, SRC  
XOR  
wreg, waop  
(100001aa) (waop) (wreg)  
(DEST) (DEST) XOR (SRC)  
PSW Flag Settings  
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, SRC  
breg, baop  
(100101aa) (baop) (breg)  
XORB  
(DEST) (DEST) XOR (SRC)  
PSW Flag Settings  
Z
N
C
V
VT ST  
0
0
A-40  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
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  
00  
01  
SKIP  
CLR  
02  
NOT  
03  
NEG  
04  
XCH Direct  
DEC  
05  
06  
EXT  
07  
INC  
08  
SHR  
09  
SHL  
0A  
SHRA  
0B  
XCH Indexed  
SHRL  
0C  
0D  
SHLL  
0E  
SHRAL  
0F  
NORML  
Reserved  
CLRB  
10  
11  
12  
NOTB  
13  
NEGB  
14  
XCHB Direct  
DECB  
15  
16  
EXTB  
17  
INCB  
18  
SHRB  
19  
SHLB  
1A  
SHRAB  
1B  
XCHB Indexed  
Reserved  
SJMP  
1C–1F  
20–27  
28–2F  
30–37  
38–3F  
40  
SCALL  
JBC  
JBS  
AND Direct (3 ops)  
AND Immediate (3 ops)  
AND Indirect (3 ops)  
AND Indexed (3 ops)  
ADD Direct (3 ops)  
41  
42  
43  
44  
A-41  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-7. Instruction Opcodes (Continued)  
Instruction Mnemonic  
Hex Code  
45  
46  
47  
48  
49  
4A  
4B  
4C  
4D  
4E  
4F  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
5A  
5B  
5C  
5D  
5E  
5F  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
6A  
6B  
6C  
6D  
ADD Immediate (3 ops)  
ADD Indirect (3 ops)  
ADD Indexed (3 ops)  
SUB Direct (3 ops)  
SUB Immediate (3 ops)  
SUB Indirect (3 ops)  
SUB Indexed (3 ops)  
MULU Direct (3 ops)  
MULU Immediate (3 ops)  
MULU Indirect (3 ops)  
MULU Indexed (3 ops)  
ANDB Direct (3 ops)  
ANDB Immediate (3 ops)  
ANDB Indirect (3 ops)  
ANDB Indexed (3 ops)  
ADDB Direct (3 ops)  
ADDB Immediate (3 ops)  
ADDB Indirect (3 ops)  
ADDB Indexed (3 ops)  
SUBB Direct (3 ops)  
SUBB Immediate (3 ops)  
SUBB Indirect (3 ops)  
SUBB Indexed (3 ops)  
MULUB Direct (3 ops)  
MULUB Immediate (3 ops)  
MULUB Indirect (3 ops)  
MULUB Indexed (3 ops)  
AND Direct (2 ops)  
AND Immediate (2 ops)  
AND Indirect (2 ops)  
AND Indexed (2 ops)  
ADD Direct (2 ops)  
ADD Immediate (2 ops)  
ADD Indirect (2 ops)  
ADD Indexed (2 ops)  
SUB Direct (2 ops)  
SUB Immediate (2 ops)  
SUB Indirect (2 ops)  
SUB Indexed (2 ops)  
MULU Direct (2 ops)  
MULU Immediate (2 ops)  
A-42  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
Table A-7. Instruction Opcodes (Continued)  
Instruction Mnemonic  
Hex Code  
6E  
6F  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
7A  
7B  
7C  
7D  
7E  
7F  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
8A  
8B  
8C  
8D  
8E  
8F  
90  
91  
92  
93  
94  
95  
96  
MULU Indirect (2 ops)  
MULU Indexed (2 ops)  
ANDB Direct (2 ops)  
ANDB Immediate (2 ops)  
ANDB Indirect (2 ops)  
ANDB Indexed (2 ops)  
ADDB Direct (2 ops)  
ADDB Immediate (2 ops)  
ADDB Indirect (2 ops)  
ADDB Indexed (2 ops)  
SUBB Direct (2 ops)  
SUBB Immediate (2 ops)  
SUBB Indirect (2 ops)  
SUBB Indexed (2 ops)  
MULUB Direct (2 ops)  
MULUB Immediate (2 ops)  
MULUB Indirect (2 ops)  
MULUB Indexed (2 ops)  
OR Direct  
OR Immediate  
OR Indirect  
OR Indexed  
XOR Direct  
XOR Immediate  
XOR Indirect  
XOR Indexed  
CMP Direct  
CMP Immediate  
CMP Indirect  
CMP Indexed  
DIVU Direct  
DIVU Immediate  
DIVU Indirect  
DIVU Indexed  
ORB Direct  
ORB Immediate  
ORB Indirect  
ORB Indexed  
XORB Direct  
XORB Immediate  
XORB Indirect  
A-43  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-7. Instruction Opcodes (Continued)  
Instruction Mnemonic  
Hex Code  
97  
98  
XORB Indexed  
CMPB Direct  
99  
CMPB Immediate  
CMPB Indirect  
CMPB Indexed  
DIVUB Direct  
9A  
9B  
9C  
9D  
9E  
9F  
A0  
A1  
A2  
A3  
A4  
A5  
A6  
A7  
A8  
A9  
AA  
AB  
AC  
AD  
AE  
AF  
B0  
B1  
B2  
B3  
B4  
B5  
B6  
B7  
B8  
B9  
BA  
BB  
BC  
BD  
BE  
BF  
DIVUB Immediate  
DIVUB Indirect  
DIVUB Indexed  
LD Direct  
LD Immediate  
LD Indirect  
LD Indexed  
ADDC Direct  
ADDC Immediate  
ADDC Indirect  
ADDC Indexed  
SUBC Direct  
SUBC Immediate  
SUBC Indirect  
SUBC Indexed  
LDBZE Direct  
LDBZE Immediate  
LDBZE Indirect  
LDBZE Indexed  
LDB Direct  
LDB Immediate  
LDB Indirect  
LDB Indexed  
ADDCB Direct  
ADDCB Immediate  
ADDCB Indirect  
ADDCB Indexed  
SUBCB Direct  
SUBCB Immediate  
SUBCB Indirect  
SUBCB Indexed  
LDBSE Direct  
LDBSE Immediate  
LDBSE Indirect  
LDBSE Indexed  
A-44  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
Table A-7. Instruction Opcodes (Continued)  
Instruction Mnemonic  
Hex Code  
C0  
C1  
C2  
C3  
C4  
C5  
C6  
C7  
C8  
C9  
CA  
CB  
CC  
CD  
CE  
CF  
D0  
D1  
D2  
D3  
D4  
D5  
D6  
D7  
D8  
D9  
DA  
DB  
DC  
DD  
DE  
DF  
E0  
ST Direct  
BMOV  
ST Indirect  
ST Indexed  
STB Direct  
CMPL  
STB Indirect  
STB Indexed  
PUSH Direct  
PUSH Immediate  
PUSH Indirect  
PUSH Indexed  
POP Direct  
BMOVI  
POP Indirect  
POP Indexed  
JNST  
JNH  
JGT  
JNC  
JNVT  
JNV  
JGE  
JNE  
JST  
JH  
JLE  
JC  
JVT  
JV  
JLT  
JE  
DJNZ  
E1  
DJNZW  
TIJMP  
E2  
E3  
BR Indirect  
Reserved  
DPTS  
E4–EB  
EC  
ED  
EE  
EF  
EPTS  
Reserved (Note 1)  
LCALL  
A-45  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-7. Instruction Opcodes (Continued)  
Instruction Mnemonic  
Hex Code  
F0  
F2  
F3  
F4  
F5  
F6  
F7  
F8  
F9  
FA  
FB  
FC  
FD  
FE  
FF  
RET  
PUSHF  
POPF  
PUSHA  
POPA  
IDLPD  
TRAP  
CLRC  
SETC  
DI  
EI  
CLRVT  
NOP  
DIV/DIVB/MUL/MULB (Note 2)  
RST  
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.”  
A-46  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
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  
Arithmetic (Group I)  
Indexed  
(Note 1)  
Direct  
Immediate  
Indirect  
Mnemonic  
Length  
Length Opcode Length Opcode Length Opcode  
Opcode  
S/L  
ADD (2 ops)  
3
4
3
4
3
3
2
2
3
3
3
2
2
2
2
2
2
3
4
3
4
3
3
64  
44  
74  
54  
A4  
B4  
01  
11  
4
5
65  
45  
75  
55  
A5  
B5  
89  
99  
69  
49  
79  
59  
A9  
B9  
3
4
66  
46  
76  
56  
A6  
B6  
4/5  
5/6  
4/5  
5/6  
4/5  
4/5  
67  
47  
77  
57  
A7  
B7  
ADD (3 ops)  
ADDB (2 ops)  
ADDB (3 ops)  
ADDC  
3
3
4
4
4
3
ADDCB  
CLR  
3
3
4
3
CLRB  
CMP  
88  
98  
C5  
05  
15  
06  
16  
07  
17  
68  
48  
78  
58  
A8  
B8  
8A  
9A  
4/5  
4/5  
8B  
9B  
CMPB  
3
3
CMPL  
4
3
DEC  
DECB  
EXT  
EXTB  
INC  
INCB  
SUB (2 ops)  
SUB (3 ops)  
SUBB (2 ops)  
SUBB (3 ops)  
SUBC  
6A  
4A  
7A  
5A  
AA  
BA  
4/5  
5/6  
4/5  
5/6  
4/5  
4/5  
6B  
4B  
7B  
5B  
AB  
BB  
5
4
3
3
4
4
4
3
SUBCB  
NOTES:  
3
3
1. 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.  
2. 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, two’s complement offset.  
A-47  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-8. Instruction Lengths and Hexadecimal Opcodes (Continued)  
Arithmetic (Group II)  
Indexed  
(Note 1)  
Direct  
Immediate  
Indirect  
Mnemonic  
Length  
Length Opcode Length Opcode Length Opcode  
Opcode  
S/L  
DIV  
4
4
3
3
4
5
4
5
3
4
3
4
FE 8C  
FE 9C  
8C  
5
4
4
3
5
6
4
5
4
5
3
4
FE 8D  
FE 9D  
8D  
4
4
3
3
4
5
4
5
3
4
3
4
FE 8E  
FE 9E  
8E  
5/6  
5/6  
4/5  
4/5  
5/6  
6/7  
5/6  
6/7  
4/5  
5/6  
4/5  
5/6  
FE 8F  
FE 9F  
8F  
DIVB  
DIVU  
DIVUB  
9C  
9D  
9E  
9F  
MUL (2 ops)  
MUL (3 ops)  
MULB (2 ops)  
MULB (3 ops)  
MULU (2 ops)  
MULU (3 ops)  
MULUB (2 ops)  
MULUB (3 ops)  
FE 6C  
FE 4C  
FE 7C  
FE 5C  
6C  
FE 6D  
FE 4D  
FE 7D  
FE 5D  
6D  
FE 6E  
FE 4E  
FE 7E  
FE 5E  
6E  
FE 6F  
FE 4F  
FE 7F  
FE 5F  
6F  
4C  
4D  
4E  
4F  
7C  
7D  
7E  
7F  
5C  
5D  
5E  
5F  
Logical  
Indexed  
(Note 1)  
Direct  
Immediate  
Indirect  
Mnemonic  
Length  
Length Opcode Length Opcode Length Opcode  
Opcode  
S/L  
AND (2 ops)  
AND (3 ops)  
ANDB (2 ops)  
ANDB (3 ops)  
NEG  
3
4
3
4
2
2
2
2
3
3
3
3
60  
40  
70  
50  
03  
13  
02  
12  
80  
90  
84  
94  
4
5
61  
41  
71  
51  
81  
91  
85  
95  
3
4
62  
42  
72  
52  
82  
92  
86  
96  
4/5  
5/6  
4/5  
5/6  
63  
43  
73  
53  
83  
93  
87  
97  
3
3
4
4
4
3
NEGB  
NOT  
NOTB  
OR  
4/5  
4/5  
4/5  
4/5  
ORB  
3
3
XOR  
4
3
XORB  
3
3
NOTES:  
1. 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.  
2. 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, two’s complement offset.  
A-48  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
Table A-8. Instruction Lengths and Hexadecimal Opcodes (Continued)  
Stack  
Indexed  
(Note 1)  
Direct  
Immediate  
Indirect  
Mnemonic  
Length  
Length Opcode Length Opcode Length Opcode  
Opcode  
S/L  
POP  
2
1
1
2
1
1
CC  
F5  
F3  
C8  
F4  
F2  
3
C9  
2
CE  
3/4  
CF  
POPA  
2
POPF  
PUSH  
PUSHA  
PUSHF  
CA  
3/4  
CB  
Data  
Indexed  
(Note 1)  
Direct  
Immediate  
Indirect  
Mnemonic  
Length  
Length Opcode Length Opcode Length Opcode  
Opcode  
S/L  
BMOV  
BMOVI  
LD  
3
4
3
3
C1  
CD  
A2  
B2  
BE  
AE  
C2  
C6  
A0  
B0  
BC  
AC  
C0  
C4  
04  
14  
A1  
B1  
BD  
AD  
3
4/5  
4/5  
4/5  
4/5  
4/5  
4/5  
4/5  
4/5  
A3  
B3  
BF  
AF  
C3  
C7  
0B  
1B  
LDB  
3
3
3
LDBSE  
LDBZE  
ST  
3
3
3
3
3
3
3
3
STB  
3
3
XCH  
3
XCHB  
3
Jump  
Indexed  
(Note 1)  
Direct  
Immediate  
Indirect  
Mnemonic  
Length  
Length Opcode Length Opcode Length Opcode  
Opcode  
S/L  
BR  
4
E2  
4
E2  
2
E3  
E7  
LJMP  
—/3  
2/—  
—/4  
SJMP (Note 2)  
TIJMP  
20–27  
E2  
NOTES:  
1. 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.  
2. 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, two’s complement offset.  
A-49  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-8. Instruction Lengths and Hexadecimal Opcodes (Continued)  
Call  
Indexed  
(Note 1)  
Direct  
Immediate  
Indirect  
Mnemonic  
Length Opcode Length Opcode Length Opcode Length Opcode  
LCALL  
1
F7  
1
F0  
3
2
EF  
RET  
SCALL (Note 2)  
TRAP  
28–2F  
Conditional Jump  
Indexed  
(Note 1)  
Direct  
Immediate  
Indirect  
Mnemonic  
Length  
S/L  
Length Opcode Length Opcode Length Opcode  
Opcode  
DJNZ  
DJNZW  
JBC  
JBS  
JC  
3/—  
3/—  
3/—  
3/—  
2/—  
2/—  
2/—  
2/—  
2/—  
2/—  
2/—  
2/—  
2/—  
2/—  
2/—  
2/—  
2/—  
2/—  
2/—  
2/—  
E0  
E1  
30–37  
38–3F  
DB  
DF  
JE  
JGE  
JGT  
JH  
D6  
D2  
D9  
JLE  
DA  
DE  
D3  
JLT  
JNC  
JNE  
JNH  
JNST  
JNV  
JNVT  
JST  
D7  
D1  
D0  
D5  
D4  
D8  
JV  
DD  
DC  
JVT  
NOTES:  
1. 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.  
2. 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, two’s complement offset.  
A-50  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
Table A-8. Instruction Lengths and Hexadecimal Opcodes (Continued)  
Shift  
Direct  
Immediate  
Indirect  
Indexed  
Mnemonic  
NORML  
Length Opcode Length Opcode Length Opcode Length Opcode  
3
3
3
3
3
3
3
3
3
3
0F  
09  
19  
0D  
08  
0A  
1A  
0E  
18  
0C  
SHL  
SHLB  
SHLL  
SHR  
SHRA  
SHRAB  
SHRAL  
SHRB  
SHRL  
Special  
Immediate  
Length Opcode Length Opcode Length Opcode Length Opcode  
Direct  
Indirect  
Indexed  
Mnemonic  
CLRC  
CLRVT  
DI  
1
1
F8  
FC  
FA  
FB  
1
F6  
1
EI  
1
IDLPD  
NOP  
RST  
1
FD  
FF  
F9  
00  
1
SETC  
SKIP  
1
2
PTS  
Immediate  
Length Opcode Length Opcode Length Opcode Length Opcode  
Direct  
Indirect  
Indexed  
Mnemonic  
DPTS  
1
1
EC  
ED  
EPTS  
NOTES:  
1. 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.  
2. 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, two’s complement offset.  
A-51  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-9 lists instructions alphabetically within groups, along with their execution times, ex-  
pressed in state times.  
Table A-9. Instruction Execution Times (in State Times)  
Arithmetic (Group I)  
Indirect  
Normal Autoinc.  
Reg. Mem. Reg. Mem. Reg. Mem. Reg. Mem.  
Indexed  
Mnemonic  
Direct  
Immed.  
Short  
Long  
ADD (2 ops)  
4
5
4
5
4
4
3
3
4
4
7
3
3
4
4
3
3
4
5
4
5
4
4
5
6
6
7
8
10  
8
7
8
9
11  
9
6
7
8
10  
8
7
8
9
11  
9
ADD (3 ops)  
ADDB (2 ops)  
ADDB (3 ops)  
ADDC  
4
6
7
6
7
5
7
10  
8
8
11  
9
7
10  
8
8
11  
9
5
6
7
6
7
ADDCB  
CLR  
4
6
8
7
9
6
8
7
9
5
6
8
7
9
6
8
7
9
CLRB  
CMP  
CMPB  
4
6
8
7
9
6
8
7
9
CMPL  
5
6
8
7
9
6
8
7
9
DEC  
DECB  
EXT  
EXTB  
INC  
INCB  
SUB (2 ops)  
SUB (3 ops)  
SUBB (2 ops)  
SUBB (3 ops)  
SUBC  
6
7
10  
8
8
11  
9
7
10  
8
8
11  
9
4
6
7
6
7
5
7
10  
8
8
11  
9
7
10  
8
8
11  
9
5
6
7
6
7
SUBCB  
4
6
8
7
9
6
8
7
9
NOTE: The column entitled “Reg.” lists the instruction execution times for accesses to the register file or  
peripheral SFRs. The column entitled “Mem.” lists the instruction execution times for accesses to  
all memory-mapped registers, I/O, or memory. See Table 4-1 on page 4-2 for address information.  
A-52  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
Table A-9. Instruction Execution Times (in State Times) (Continued)  
Arithmetic (Group II)  
Indirect  
Indexed  
Mnemonic  
Direct  
Immed.  
Normal  
Autoinc.  
Short  
Long  
Reg. Mem. Reg. Mem. Reg. Mem. Reg. Mem.  
DIV  
26  
18  
24  
16  
16  
16  
12  
12  
14  
14  
10  
10  
27  
18  
25  
16  
17  
17  
12  
12  
15  
15  
10  
10  
28  
20  
26  
18  
18  
18  
14  
14  
16  
16  
12  
12  
31  
23  
29  
21  
21  
21  
17  
17  
19  
19  
15  
15  
29  
21  
27  
19  
19  
19  
15  
15  
17  
17  
13  
13  
32  
24  
30  
22  
22  
22  
18  
18  
19  
19  
15  
15  
29  
21  
27  
19  
19  
19  
15  
15  
17  
17  
12  
12  
32  
24  
30  
22  
22  
22  
18  
18  
20  
20  
16  
16  
30  
22  
28  
20  
20  
20  
16  
16  
18  
18  
14  
14  
33  
25  
31  
23  
23  
23  
19  
19  
21  
21  
17  
17  
DIVB  
DIVU  
DIVUB  
MUL (2 ops)  
MUL (3 ops)  
MULB (2 ops)  
MULB (3 ops)  
MULU (2 ops)  
MULU (3 ops)  
MULUB (2 ops)  
MULUB (3 ops)  
Logical  
Indirect  
Normal Autoinc.  
Reg. Mem. Reg. Mem. Reg. Mem. Reg. Mem.  
Indexed  
Mnemonic  
Direct  
Immed.  
Short  
Long  
AND (2 ops)  
AND (3 ops)  
ANDB (2 ops)  
ANDB (3 ops)  
NEG  
4
5
4
5
3
3
3
3
4
4
4
4
5
6
6
7
8
10  
8
7
8
9
11  
9
6
7
8
10  
8
7
8
9
11  
9
4
6
7
6
7
5
7
10  
8
8
11  
9
7
10  
8
8
11  
9
5
6
7
6
7
NEGB  
NOT  
NOTB  
OR  
ORB  
4
6
8
7
9
6
8
7
9
XOR  
5
6
8
7
9
6
8
7
9
XORB  
4
6
8
7
9
6
8
7
9
NOTE: The column entitled “Reg.” lists the instruction execution times for accesses to the register file or  
peripheral SFRs. The column entitled “Mem.” lists the instruction execution times for accesses to  
all memory-mapped registers, I/O, or memory. See Table 4-1 on page 4-2 for address information.  
A-53  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-9. Instruction Execution Times (in State Times) (Continued)  
Stack (Register)  
Indirect  
Normal Autoinc.  
Reg. Mem. Reg. Mem. Reg. Mem. Reg. Mem.  
Indexed  
Mnemonic  
Direct  
Immed.  
Short  
Long  
POP  
8
12  
7
7
10  
9
12  
12  
11  
10  
13  
13  
11  
10  
13  
13  
12  
11  
14  
14  
POPA  
POPF  
PUSH  
6
PUSHA  
PUSHF  
12  
6
Stack (Memory)  
Indirect  
Indexed  
Mnemonic  
Direct  
Immed.  
Normal  
Autoinc.  
Short  
Long  
Reg. Mem. Reg. Mem. Reg. Mem. Reg. Mem.  
POP  
11  
18  
10  
8
9
13  
11  
15  
14  
14  
12  
16  
15  
14  
12  
16  
15  
15  
13  
17  
16  
POPA  
POPF  
PUSH  
PUSHA  
PUSHF  
18  
8
NOTE: The column entitled “Reg.” lists the instruction execution times for accesses to the register file or  
peripheral SFRs. The column entitled “Mem.” lists the instruction execution times for accesses to  
all memory-mapped registers, I/O, or memory. See Table 4-1 on page 4-2 for address information.  
A-54  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
Table A-9. Instruction Execution Times (in State Times) (Continued)  
Data  
Mnemonic  
BMOV  
Indirect  
register/register  
memory/register  
memory/memory  
6 + 8 per word  
6 + 11 per word  
6 + 14 per word  
BMOVI  
register/register  
memory/register  
memory/memory  
7 + 8 per word + 14 per interrupt  
7 + 11 per word + 14 per interrupt  
7 + 14 per word + 14 per interrupt  
Indirect  
Indexed  
Mnemonic  
Direct  
Immed.  
Normal  
Autoinc.  
Short  
Long  
Reg. Mem. Reg. Mem. Reg. Mem. Reg. Mem.  
LD  
4
4
4
4
4
4
5
5
5
4
5
5
8
8
6
6
8
8
6
6
6
6
6
6
8
8
9
9
7
7
7
7
7
7
9
9
10  
10  
10  
10  
10  
10  
14  
14  
LDB  
LDBSE  
LDBZE  
ST  
4
5
8
6
8
9
4
5
8
6
8
9
5
8
6
9
9
STB  
5
8
6
8
9
XCH  
XCHB  
13  
13  
Jump  
Indirect  
Indexed  
Mnemonic  
Direct  
Immed.  
Normal  
Autoinc.  
Short  
Long  
BR  
7
7
7
7
LJMP  
SJMP  
TIJMP  
register/register  
memory/register  
memory/memory  
15  
18  
21  
Call (Register)  
Indirect  
Indexed  
Mnemonic  
Direct  
Immed.  
Normal  
Autoinc.  
Short  
Long  
LCALL  
16  
11  
11  
11  
RET  
SCALL  
TRAP  
NOTE: The column entitled “Reg.” lists the instruction execution times for accesses to the register file or  
peripheral SFRs. The column entitled “Mem.” lists the instruction execution times for accesses to  
all memory-mapped registers, I/O, or memory. See Table 4-1 on page 4-2 for address information.  
A-55  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table A-9. Instruction Execution Times (in State Times) (Continued)  
Call (Memory)  
Indirect  
Indexed  
Mnemonic  
Direct  
Immed.  
Normal  
Autoinc.  
Short  
Long  
LCALL  
13  
RET  
14  
13  
SCALL  
TRAP  
18  
Conditional Jump  
Mnemonic  
Short-Indexed  
DJNZ  
DJNZW  
JBC  
JBS  
JC  
5 (jump not taken), 9 (jump taken)  
6 (jump not taken), 10 (jump taken)  
5 (jump not taken), 9 (jump taken)  
5 (jump not taken), 9 (jump taken)  
4 (jump not taken), 8 (jump taken)  
4 (jump not taken), 8 (jump taken)  
4 (jump not taken), 8 (jump taken)  
4 (jump not taken), 8 (jump taken)  
4 (jump not taken), 8 (jump taken)  
4 (jump not taken), 8 (jump taken)  
4 (jump not taken), 8 (jump taken)  
4 (jump not taken), 8 (jump taken)  
4 (jump not taken), 8 (jump taken)  
4 (jump not taken), 8 (jump taken)  
4 (jump not taken), 8 (jump taken)  
4 (jump not taken), 8 (jump taken)  
4 (jump not taken), 8 (jump taken)  
4 (jump not taken), 8 (jump taken)  
4 (jump not taken), 8 (jump taken)  
4 (jump not taken), 8 (jump taken)  
JE  
JGE  
JGT  
JH  
JLE  
JLT  
JNC  
JNE  
JNH  
JNST  
JNV  
JNVT  
JST  
JV  
JVT  
NOTE: The column entitled “Reg.” lists the instruction execution times for accesses to the register file or  
peripheral SFRs. The column entitled “Mem.” lists the instruction execution times for accesses to  
all memory-mapped registers, I/O, or memory. See Table 4-1 on page 4-2 for address information.  
A-56  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INSTRUCTION SET REFERENCE  
Table A-9. Instruction Execution Times (in State Times) (Continued)  
Shift  
Mnemonic  
NORML  
Direct  
8 + 1 per shift (9 for 0 shift)  
6 + 1 per shift (7 for 0 shift)  
6 + 1 per shift (7 for 0 shift)  
7 + 1 per shift (8 for 0 shift)  
6 + 1 per shift (7 for 0 shift)  
6 + 1 per shift (7 for 0 shift)  
6 + 1 per shift (7 for 0 shift)  
7 + 1 per shift (8 for 0 shift)  
6 + 1 per shift (7 for 0 shift)  
7 + 1 per shift (8 for 0 shift)  
SHL  
SHLB  
SHLL  
SHR  
SHRA  
SHRAB  
SHRAL  
SHRB  
SHRL  
Special  
Indirect  
Autoinc.  
Indexed  
Mnemonic  
Direct  
Immed.  
Normal  
Short  
Long  
CLRC  
CLRVT  
DI  
2
2
2
2
EI  
IDLPD  
Valid key  
Invalid key  
12  
28  
NOP  
2
4
2
3
RST  
SETC  
SKIP  
PTS  
Indirect  
Indexed  
Mnemonic  
Direct  
Immed.  
Normal  
Autoinc.  
Short  
Long  
DPTS  
EPTS  
2
2
NOTE: The column entitled “Reg.” lists the instruction execution times for accesses to the register file or  
peripheral SFRs. The column entitled “Mem.” lists the instruction execution times for accesses to  
all memory-mapped registers, I/O, or memory. See Table 4-1 on page 4-2 for address information.  
A-57  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
B
Signal Descriptions  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
APPENDIX B  
SIGNAL DESCRIPTIONS  
This appendix provides reference information for the pin functions of the 8XC196MC,  
8XC196MD, and 8XC196MH.  
B.1 SIGNAL NAME CHANGES  
The names of some 8XC196MC and 8XC196MD signals have been changed for consistency  
®
with other MCS 96 microcontrollers. Table B-1 lists the old and new names.  
Table B-1. Signal Name Changes  
Name in 8XC196MC User’s Manual  
AGND  
New Name  
ANGND  
EPAx  
CAPCOMPx  
COMPAREx  
COMPx  
B.2 FUNCTIONAL GROUPINGS OF SIGNALS  
Tables B-2, B-3, and B-4 list the signals for the 8XC196MC, 8XC196MD, and 8XC196MH re-  
spectively, grouped by function. A diagram of each package that is currently available shows the  
pin location of each signal.  
NOTE  
The datasheets are revised more frequently than this manual. As new packages  
are supported, the pin-out diagrams will be added to the datasheets first. If  
your package type is not shown in this appendix, refer to the latest datasheet to  
find the pin locations.  
B-1  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table B-2. 8XC196MC Signals Arranged by Functional Categories  
Address & Data  
AD15:0  
Programming Control  
AINC#  
Input/Output  
P0.7:0/ACH7:0  
P1.0/ACH8  
P1.1/ACH9  
P1.2/ACH10/T1CLK  
P1.3/ACH11/T1DIR  
P1.4/ACH12  
P2.3:0/EPA3:0  
P2.6:4/COMP2:0  
P2.7/COMP3  
P3.7:0  
Input/Output (Cont’d)  
P6.5/WG3  
CPVER  
P6.6/PWM0  
Bus Control & Status  
ALE/ADV#  
BHE#/WRH#  
BUSWIDTH  
INST  
PACT#  
P6.7/PWM1  
PALE#  
PBUS.15:0  
PMODE.3:0  
PROG#  
READY  
PVER  
RD#  
WR#/WRL#  
Processor Control  
CLKOUT  
EA#  
P4.7:0  
Power & Ground  
P5.1  
ANGND  
VCC  
EXTINT  
NMI  
P5.7:0  
P6.0/WG1#  
P6.1/WG1  
VPP  
ONCE#  
VREF  
VSS  
RESET#  
XTAL1  
P6.2/WG2#  
P6.3/WG2  
XTAL2  
P6.4/WG3#  
NOTE: The shaded signals are not available in the 64-pin package.  
B-2  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SIGNAL DESCRIPTIONS  
V
64  
63  
62  
61  
60  
59  
58  
57  
56  
55  
54  
53  
52  
51  
50  
49  
48  
47  
46  
45  
44  
43  
42  
41  
40  
39  
38  
37  
36  
35  
34  
32  
1
P5.6 / READY  
SS  
P5.0 / ALE / ADV#  
2
P5.4 / ONCE#  
EXTINT  
V
3
PP  
V
P5.3 / RD#  
P5.5 / BHE# / WRH#  
P5.2 / WR# / WRL#  
4
SS  
5
XTAL1  
6
XTAL2  
P5.7 / BUSWIDTH  
7
P6.6 / PWM0  
AD14 / P4.6 / PBUS.14  
AD13 / P4.5 / PBUS.13  
AD15 / P4.7 / PBUS.15  
8
P6.7 / PWM1  
9
P2.6 / COMP2 / CPVER  
P2.5 / COMP1 / PACT#  
P2.4 / COMP0 / AINC#  
P2.3 / EPA3  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
V
CC  
AD12 / P4.4 / PBUS.12  
AD11 / P4.3 / PBUS.11  
AD10 / P4.2 / PBUS.10  
AD9 / P4.1 / PBUS.9  
AD8 / P4.0 / PBUS.8  
AD7 / P3.7 / PBUS.7  
AD6 / P3.6 / PBUS.6  
AD5 / P3.5 / PBUS.5  
AD4 / P3.4 / PBUS.4  
AD3 / P3.3 / PBUS.3  
AD2 / P3.2 / PBUS.2  
AD1 / P3.1 / PBUS.1  
AD0 / P3.0 / PBUS.0  
RESET#  
P2.2 / EPA2 / PROG#  
P2.1 / EPA1 / PALE#  
P2.0 / EPA0 / PVER  
P0.0 / ACH0  
U8XC196MC  
P0.1 / ACH1  
P0.2 / ACH2  
View of component as  
mounted on PC board  
P0.3 / ACH3  
P0.4 / ACH4 / PMODE.0  
P0.5 / ACH5 / PMODE.1  
V
REF  
ANGND  
P0.6 / ACH6 / PMODE.2  
P0.7 / ACH7 / PMODE.3  
P1.0 / ACH8  
NMI  
EA#  
P1.1 / ACH9  
V
P1.2 / ACH10 / T1CLK  
P1.3 / ACH11 / T1DIR  
P6.0 / WG1#  
SS  
V
CC  
P6.5 / WG3  
P6.4 / WG3#  
P6.3 / WG2  
P6.1 / WG1  
P6.2 / WG2#  
A3103-02  
Figure B-1. 8XC196MC 64-lead Shrink DIP (SDIP) Package  
B-3  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
AD15 / P4.7 / PBUS.15  
AD14 / P4.6 / PBUS.14  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
74  
73  
72  
71  
70  
69  
68  
67  
66  
65  
64  
63  
62  
61  
60  
59  
58  
57  
56  
55  
54  
P2.5 / COMP1 / PACT#  
P2.4 / COMP0 / AINC#  
NC  
V
CC  
AD13 / P4.5 / PBUS.13  
CLKOUT  
NC  
P2.7 / COMP3  
P2.3 / EPA3  
P2.2 / EPA2 / PROG#  
NC  
AD12 / P4.4 / PBUS.12  
AD11 / P4.3 / PBUS.11  
AD10 / P4.2 / PBUS.10  
AD9 / P4.1 / PBUS.9  
AD8 / P4.0 / PBUS.8  
NC  
NC  
x8XC196MC  
P2.1 / EPA1 / PALE#  
P2.0 / EPA0 / PVER  
NC  
P0.0 / ACH0  
P0.1 / ACH1  
NC  
View of component as  
mounted on PC board  
AD7 / P3.7 / PBUS.7  
AD6 / P3.6 / PBUS.6  
AD5 / P3.5. / PBUS.5  
AD4 / P3.4 / PBUS.4  
AD3 / P3.3 / PBUS.3  
AD2 / P3.2 / PBUS.2  
AD1 / P3.1 / PBUS.1  
AD0 / P3.0 / PBUS.0  
NC  
P0.2 / ACH2  
P0.3 / ACH3  
P0.4 / ACH4 / PMODE.0  
P0.5 / ACH5 / PMODE.1  
V
REF  
ANGND  
P0.6 / ACH6 / PMODE.2  
A3101-02  
Figure B-2. 8XC196MC 84-lead PLCC Package  
B-4  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SIGNAL DESCRIPTIONS  
P5.2 / WR# / WRL#  
P5.7 / BUSWIDTH  
1
2
3
4
5
6
7
8
64  
63  
62  
61  
60  
59  
58  
57  
56  
55  
54  
53  
52  
51  
50  
49  
48  
47  
46  
45  
44  
43  
42  
41  
P6.7 / PWM1  
P2.6 / COMP2 / CPVER  
P2.5 / COMP1 / PACT#  
P2.4 / COMP0 / AINC#  
NC  
AD15 / P4.7 / PBUS.15  
AD14 / P4.6 / PBUS.14  
V
CC  
AD13 / P4.5 / PBUS.13  
CLKOUT  
NC  
P2.7 / COMP3  
P2.3 / EPA3  
P2.2 / EPA2 / PROG#  
NC  
AD12 / P4.4 / PBUS.12  
AD11 / P4.3 / PBUS.11  
AD10 / P4.2 / PBUS.10  
AD9 / P4.1 / PBUS.9  
AD8 / P4.0 / PBUS.8  
AD7 / P3.7 / PBUS.7  
AD6 / P3.6 / PBUS.6  
AD5 / P3.5 / PBUS.5  
AD4 / P3.4 / PBUS.4  
AD3 / P3.3 / PBUS.3  
AD2 / P3.2 / PBUS.2  
AD1 / P3.1 / PBUS.1  
AD0 / P3.0 / PBUS.0  
NC  
x8XC196MC  
9
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
NC  
P2.1 / EPA1 / PALE#  
P2.0 / EPA0 / PVER  
NC  
P0.0 / ACH0  
P0.1 / ACH1  
View of component as  
mounted on PC board  
P0.2 / ACH2  
P0.3 / ACH3  
P0.4 / ACH4 / PMODE.0  
P0.5 / ACH5 / PMODE.1  
V
REF  
RESET#  
ANGND  
P0.6 / ACH6 / PMODE.2  
P0.7 / ACH7 / PMODE.3  
NMI  
EA#  
A3104-01  
Figure B-3. 8XC196MC 80-lead Shrink EIAJ/QFP Package  
B-5  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table B-3. 8XC196MD Signals Arranged by Functional Categories  
Address & Data  
AD15:0  
Programming Control  
AINC#  
Input/Output  
P0.7:0/ACH7:0  
P1.1:0/ACH9:8  
P1.2/ACH10/T1CLK  
P1.3/ACH11/T1DIR  
P1.5:4/ACH13:12  
P1.7:6  
Input/Output (Cont’d)  
P7.1:0/EPA5:4  
P7.3:2/COMP5:4  
P7.6:4  
CPVER  
Bus Control & Status  
ALE/ADV#  
BHE#/WRH#  
BUSWIDTH  
INST  
PACT#  
PALE#  
P7.7/FREQOUT  
PBUS.15:0  
PMODE.3:0  
PROG#  
P2.3:0/EPA3:0  
P2.7:4/COMP3:0  
P3.7:0  
READY  
PVER  
RD#  
WR#/WRL#  
Processor Control  
CLKOUT  
EA#  
P4.7:0  
P5.7:0  
Power & Ground  
P6.0/WG1#  
ANGND  
VCC  
EXTINT  
NMI  
P6.1/WG1  
P6.2/WG2#  
VPP  
ONCE#  
P6.3/WG2  
VREF  
VSS  
RESET#  
XTAL1  
P6.4/WG3#  
P6.5/WG3  
XTAL2  
P6.7:6/PWM1:0  
B-6  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SIGNAL DESCRIPTIONS  
AD15 / P4.7 / PBUS.15  
AD14 / P4.6 / PBUS.14  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
74  
73  
72  
71  
70  
69  
68  
67  
66  
65  
64  
63  
62  
61  
60  
59  
58  
57  
56  
55  
54  
P2.5 / COMP1 / PACT#  
P2.4 / COMP0 / AINC#  
P7.3 / COMP5  
P7.2 / COMP4  
P2.7 / COMP3  
P2.3 / EPA3  
P2.2 / EPA2 / PROG#  
P7.1 / EPA5  
V
CC  
AD13 / P4.5 / PBUS.13  
CLKOUT  
AD12 / P4.4 / PBUS.12  
AD11 / P4.3 / PBUS.11  
AD10 / P4.2 / PBUS.10  
AD9 / P4.1 / PBUS.9  
AD8 / P4.0 / PBUS.8  
NC  
P7.0 / EPA4  
x8XC196MD  
P2.1 / EPA1 / PALE#  
P2.0 / EPA0 / PVER  
P7.7 / FREQOUT  
P0.0 / ACH0  
P0.1 / ACH1  
P0.2 / ACH2  
NC  
View of component as  
mounted on PC board  
AD7 / P3.7 / PBUS.7  
AD6 / P3.6 / PBUS.6  
AD5 / P3.5. / PBUS.5  
AD4 / P3.4 / PBUS.4  
AD3 / P3.3 / PBUS.3  
AD2 / P3.2 / PBUS.2  
AD1 / P3.1 / PBUS.1  
AD0 / P3.0 / PBUS.0  
P1.7  
P0.3 / ACH3  
P0.4 / ACH4 / PMODE.0  
P0.5 / ACH5 / PMODE.1  
V
REF  
ANGND  
P0.6 / ACH6 / PMODE.2  
A3102-02  
Figure B-4. 8XC196MD 84-lead PLCC Package  
B-7  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
P5.2 / WR# / WRL#  
P5.7 / BUSWIDTH  
1
2
3
4
5
6
7
8
64  
63  
62  
61  
60  
59  
58  
57  
56  
55  
54  
53  
52  
51  
50  
49  
48  
47  
46  
45  
44  
43  
42  
41  
P6.7 / PWM1  
P2.6 / COMP2 / CPVER  
P2.5 / COMP1 / PACT#  
P2.4 / COMP0 / AINC#  
P7.3 / COMP5  
P7.2 / COMP4  
P2.7 / COMP3  
P2.3 / EPA3  
P2.2 / EPA2 / PROG#  
P7.1 / EPA5  
AD15 / P4.7 / PBUS.15  
AD14 / P4.6 / PBUS.14  
V
CC  
AD13 / P4.5 / PBUS.13  
CLKOUT  
AD12 / P4.4 / PBUS.12  
AD11 / P4.3 / PBUS.11  
AD10 / P4.2 / PBUS.10  
AD9 / P4.1 / PBUS.9  
AD8 / P4.0 / PBUS.8  
AD7 / P3.7 / PBUS.7  
AD6 / P3.6 / PBUS.6  
AD5 / P3.5 / PBUS.5  
AD4 / P3.4 / PBUS.4  
AD3 / P3.3 / PBUS.3  
AD2 / P3.2 / PBUS.2  
AD1 / P3.1 / PBUS.1  
AD0 / P3.0 / PBUS.0  
P1.7  
x8XC196MD  
9
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
P7.0 / EPA4  
P2.1 / EPA1 / PALE#  
P2.0 / EPA0 / PVER  
P7.7 / FREQOUT  
P0.0 / ACH0  
P0.1 / ACH1  
P0.2 / ACH2  
View of component as  
mounted on PC board  
P0.3 / ACH3  
P0.4 / ACH4 / PMODE.0  
P0.5 / ACH5 / PMODE.1  
V
REF  
RESET#  
ANGND  
P0.6 / ACH6 / PMODE.2  
P0.7 / ACH7 / PMODE.3  
NMI  
EA#  
A3105-01  
Figure B-5. 8XC196MD 80-lead Shrink EIAJ/QFP Package  
B-8  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SIGNAL DESCRIPTIONS  
Table B-4. 8XC196MH Signals Arranged by Functional Categories  
Address & Data  
AD15:0  
Programming Control  
AINC#  
Input/Output  
P0.5:0/ACH5:0  
P0.6/ACH6/T1CLK  
P0.7/ACH7/T1DIR  
P1.0/TXD0  
Input/Output (Cont’d)  
P5.0  
CPVER  
P5.1  
Bus Control & Status  
ALE/ADV#  
BHE#/WRH#  
BUSWIDTH  
INST  
PACT#  
P5.7:2  
PALE#  
P6.0/WG1#  
P6.1/WG1  
P6.2/WG2#  
P6.3/WG2  
P6.4/WG3#  
P6.5/WG3  
P6.6/PWM0  
P6.7/PWM1  
PBUS.15:0  
PMODE.3:0  
PROG#  
P1.1/RXD0  
P1.2/TXD1  
P1.3/RXD1  
READY  
PVER  
P2.0/EPA0  
RD#  
P2.1/SCLK0#/BCLK0  
P2.2/EPA1  
WR#/WRL#  
Processor Control  
EA#  
P2.3/COMP3  
P2.4/COMP0  
P2.5/COMP1  
P2.6/COMP2  
P2.7/SCLK1#/BCLK1  
P3.7:0  
Power & Ground  
EXTINT  
NMI  
ANGND  
VCC  
ONCE#  
VPP  
RESET#  
XTAL1  
VREF  
VSS  
XTAL2  
P4.7:0  
NOTE: The shaded signals are not available in the 64-pin package.  
B-9  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
V
64  
63  
62  
61  
60  
59  
58  
57  
56  
55  
54  
53  
52  
51  
50  
49  
48  
47  
46  
45  
44  
43  
42  
41  
40  
39  
38  
37  
36  
35  
34  
32  
1
P5.6 / READY  
P5.4 / ONCE#  
EXTINT  
SS  
P5.0 / ALE / ADV#  
2
V
3
PP  
V
P5.3 / RD#  
P5.5 / BHE# / WRH#  
P5.2 / WR# / WRL#  
4
SS  
5
XTAL1  
6
XTAL2  
P5.7 / BUSWIDTH  
7
P6.6 / PWM0  
AD14 / P4.6 / PBUS.14  
AD13 / P4.5 / PBUS.13  
AD15 / P4.7 / PBUS.15  
8
P2.7 / SCLK1# / BCLK1  
P2.6 / COMP2 / CPVER  
P2.5 / COMP1 / PACT#  
P2.4 / COMP0 / AINC#  
P2.3 / COMP3  
9
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
V
CC  
AD12 / P4.4 / PBUS.12  
AD11 / P4.3 / PBUS.11  
AD10 / P4.2 / PBUS.10  
AD9 / P4.1 / PBUS.9  
AD8 / P4.0 / PBUS.8  
AD7 / P3.7 / PBUS.7  
AD6 / P3.6 / PBUS.6  
AD5 / P3.5 / PBUS.5  
AD4 / P3.4 / PBUS.4  
AD3 / P3.3 / PBUS.3  
AD2 / P3.2 / PBUS.2  
AD1 / P3.1 / PBUS.1  
AD0 / P3.0 / PBUS.0  
RESET#  
P2.2 / EPA1 / PROG#  
P2.1 / SCLK0# / BCLK0 / PALE#  
P2.0 / EPA0 / PVER  
P0.0 / ACH0  
x8XC196MH  
P0.1 / ACH1  
P0.2 / ACH2  
View of component as  
mounted on PC board  
P0.3 / ACH3  
P0.4 / ACH4 / PMODE.0  
P0.5 / ACH5 / PMODE.1  
V
REF  
ANGND  
P0.6 / ACH6 / T1CLK / PMODE.2  
P0.7 / ACH7 / T1DIR / PMODE.3  
P1.0 / TXD0  
NMI  
EA#  
P1.1 / RXD0  
V
P1.2 / TXD1  
SS  
V
P1.3 / RXD1  
CC  
P6.5 / WG3  
P6.4 / WG3#  
P6.3 / WG2  
P6.0 / WG1#  
P6.1 / WG1  
P6.2 / WG2#  
A2572-02  
Figure B-6. 8XC196MH 64-lead Shrink DIP (SDIP) Package  
B-10  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SIGNAL DESCRIPTIONS  
AD15 / P4.7 / PBUS.15  
AD14 / P4.6 / PBUS.14  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
74  
73  
72  
71  
70  
69  
68  
67  
66  
65  
64  
63  
62  
61  
60  
59  
58  
57  
56  
55  
54  
P2.5 / COMP1 / PACT#  
P2.4 / COMP0 / AINC#  
NC  
V
CC  
AD13 / P4.5 / PBUS.13  
NC  
NC  
P2.7 / SCLK1# / BCLK1  
P2.3 / COMP3  
P2.2 / EPA1 / PROG#  
NC  
AD12 / P4.4 / PBUS.12  
AD11 / P4.3 / PBUS.11  
AD10 / P4.2 / PBUS.10  
AD9 / P4.1 / PBUS.9  
AD8 / P4.0 / PBUS.8  
NC  
NC  
x8XC196MH  
P2.1 / SCLK0# / BCLK0 / PALE#  
P2.0 / EPA0 / PVER  
NC  
P0.0 / ACH0  
P0.1 / ACH1  
NC  
View of component as  
mounted on PC board  
AD7 / P3.7 / PBUS.7  
AD6 / P3.6 / PBUS.6  
AD5 / P3.5 / PBUS.5  
AD4 / P3.4 / PBUS.4  
AD3 / P3.3 / PBUS.3  
AD2 / P3.2 / PBUS.2  
AD1 / P3.1 / PBUS.1  
AD0 / P3.0 / PBUS.0  
NC  
P0.2 / ACH2  
P0.3 / ACH3  
P0.4 / ACH4 / PMODE.0  
P0.5 / ACH5 / PMODE.1  
V
REF  
ANGND  
P0.6 / ACH6 / T1CLK / PMODE.2  
A2573-03  
Figure B-7. 8XC196MH 84-lead PLCC Package  
B-11  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
P5.2 / WR# / WRL#  
P5.7 / BUSWIDTH  
1
2
3
4
5
6
7
8
64  
63  
62  
61  
60  
59  
58  
57  
56  
55  
54  
53  
52  
51  
50  
49  
48  
47  
46  
45  
44  
43  
42  
41  
P6.7 / PWM1  
P2.6 / COMP2 / CPVER  
P2.5 / COMP1 / PACT#  
P2.4 / COMP0 / AINC#  
NC  
P4.7 / AD15 / PBUS.15  
P4.6 / AD14 / PBUS.14  
V
CC  
P4.5 / AD13 / PBUS.13  
NC  
NC  
P2.7 / SCLK1# / BCLK1  
P2.3 / COMP3  
P2.2 / EPA1 / PROG#  
NC  
P4.4 / AD12 / PBUS.12  
P4.3 / AD11 / PBUS.11  
P4.2 / AD10 / PBUS.10  
P4.1 / AD9 / PBUS.9  
P4.0 / AD8 / PBUS.8  
P3.7 / AD7 / PBUS.7  
P3.6 / AD6 / PBUS.6  
P3.5 / AD5 / PBUS.5  
P3.4 / AD4 / PBUS.4  
P3.3 / AD3 / PBUS.3  
P3.2 / AD2 / PBUS.2  
P3.1 / AD1 / PBUS.1  
P3.0 / AD0 / PBUS.0  
NC  
x8XC196MH  
9
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
NC  
P2.1 / SCLK0# / BCLK0 / PALE#  
P2.0 / EPA0 / PVER  
NC  
P0.0 / ACH0  
P0.1 / ACH1  
View of component as  
mounted on PC board  
P0.2 / ACH2  
P0.3 / ACH3  
P0.4 / ACH4 / PMODE.0  
P0.5 / ACH5 / PMODE.1  
V
REF  
RESET#  
ANGND  
NMI  
EA#  
P0.6 / ACH6 / T1CLK / PMODE.2  
P0.7 / ACH7 / T1DIR / PMODE.3  
A2574-02  
Figure B-8. 8XC196MH 80-lead Shrink EIAJ/QFP Package  
B.3 SIGNAL DESCRIPTIONS  
Table B-5 defines the columns used in Table B-6, which describes the signals.  
B-12  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SIGNAL DESCRIPTIONS  
Table B-5. Description of Columns of Table B-6  
Column Heading  
Name  
Description  
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).  
Note that all inputs except RESET# are sampled inputs. RESET# is a level-  
sensitive input. During powerdown mode, the powerdown circuitry uses  
EXTINT as a level-sensitive input.  
Description  
Briefly describes the function of the pin for the specific signal listed in the  
Name column. Also lists any alternate fuctions that are multiplexed with the  
signal.  
Table B-6. Signal Descriptions  
Description  
Name  
Type  
ACH12:0 (MC)  
ACH13:0 (MD)  
ACH7:0 (MH)  
I
Analog Channels  
These pins are analog inputs to the A/D converter.  
These pins may individually be used as analog inputs (ACHx) or digital inputs  
(P0.y). While it is possible for the pins to function simultaneously as analog and  
digital inputs, this is not recommended because reading port 0 while a  
conversion is in process can produce unreliable conversion results.  
The ANGND and VREF pins must be connected for the A/D converter and port 0  
to function.  
ACH7:0 are multiplexed as follows: ACH0/P0.0, ACH1/P0.1, ACH2/P0.2,  
ACH3/P0.3, ACH4/P0.4/PMODE.0, ACH5/P0.5/PMODE.1,  
ACH6/P0.6/PMODE.2, ACH7/P0.7/PMODE.3, ACH8/P1.0, ACH9/P1.1,  
ACH10/P1.2/T1CLK, ACH11/P1.3/T1DIR, and ACH12/P1.4, and ACH13/P1.5.  
ACH13 is not implemented on the 8XC196MC and ACH13:8 are not  
implemented on the 8XC196MH.  
AD15:0  
I/O  
Address/Data Lines  
These pins provide a multiplexed address and data bus. During the address  
phase of the bus cycle, address bits 0–15 are presented on the bus and can be  
latched using ALE or ADV#. During the data phase, 8- or 16-bit data is trans-  
ferred.  
AD7:0 are multiplexed with P3.7:0, and PBUS.7:0. AD15:8 are multiplexed with  
P4.7:0 and PBUS.15:8.  
ADV#  
O
Address Valid  
This active-low output signal is asserted only during external memory  
accesses. ADV# indicates that valid address information is available on the  
system address/data bus. The signal remains low while a valid bus cycle is in  
progress and is returned high as soon as the bus cycle completes.  
An external latch can use this signal to demultiplex the address from the  
address/data bus. A decoder can also use this signal to generate chip selects  
for external memory.  
ADV# is multiplexed with P5.0 and ALE.  
B-13  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table B-6. Signal Descriptions (Continued)  
Description  
Name  
AINC#  
Type  
I
Auto Increment  
During slave programming, this active-low input enables the auto-increment  
feature. (Auto increment allows reading or writing of sequential OTPROM  
locations, without requiring address transactions across the PBUS for each  
read or write.) AINC# is sampled after each location is programmed or dumped.  
If AINC# is asserted, the address is incremented and the next data word is  
programmed or dumped.  
AINC# is multiplexed with P2.4 and COMP0.  
Address Latch Enable  
ALE  
O
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. 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 the address from the  
address/data bus.  
ALE is multiplexed with P5.0 and ADV#.  
Analog Ground  
ANGND  
GND  
ANGND must be connected for A/D converter and port 0 operation (also Port 1  
on the 8XC196MC and MD). ANGND and VSS should be nominally at the same  
potential.  
BCLK1:0  
(MH only)  
I
Baud Clock 0 and 1  
BCLK0 and 1 are alternate clock sources for the baud-rate generator input. The  
maximum input frequency is FXTAL1/4.  
BCLK0 is multiplexed with P2.1, SCLK0#, and PALE#. BCLK1 is multiplexed  
with P2.7 and SCLK1#.  
BHE#  
O
Byte High Enable†  
During 16-bit bus cycles, this active-low output signal is asserted for word 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 AD0, to determine which memory byte is being transferred  
over the system bus:  
BHE#  
AD0 Byte(s) Accessed  
0
0
1
0
1
0
both bytes  
high byte only  
low byte only  
BHE# is multiplexed with P5.5 and 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#.  
B-14  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SIGNAL DESCRIPTIONS  
Table B-6. Signal Descriptions (Continued)  
Name  
Type  
Description  
BUSWIDTH  
I
Bus Width  
Two chip configuration register bits, CCR0.1 and CCR1.2, along with the  
BUSWIDTH pin, control the data bus width. When both CCR bits are set, the  
BUSWIDTH signal selects the external data bus width. When only one CCR bit  
is set, the bus width is fixed at either 16 or 8 bits, and the BUSWIDTH signal  
has no effect.  
CCR0.1 CCR1.2 BUSWIDTH  
0
1
1
1
1
0
1
1
X
X
high  
low  
fixed 8-bit data bus  
fixed 16-bit data bus  
16-bit data bus  
8-bit data bus  
BUSWIDTH is multiplexed with P5.7.  
Clock Output  
CLKOUT  
(MC, MD)  
O
O
Output of the internal clock generator. The CLKOUT frequency is ½ the  
oscillator input frequency (FXTAL1). CLKOUT has a 50% duty cycle.  
CLKOUT is not implemented on the 8XC196MH.  
Event Processor Array (EPA) Compare Pins  
COMP3:0(MC,  
MH)  
These signals are the output of the EPA compare-only channels. These pins  
are multiplexed with other signals and may be configured as standard I/O.  
COMP5:0  
(MD)  
COMP5:0 are multiplexed as follows: COMP0/P2.4/AINC#,  
COMP1/P2.5/PACT#, COMP2/P2.6/CPVER, COMP3/P2.7(MC, MD),  
COMP3/P2.3 (MH), COMP4/P7.2, and COMP5/P7.3.  
COMP4 and COMP5 are not implemented on the 8XC196MC and MH.  
Cumulative Program Verification  
CPVER  
EA#  
O
During slave programming, a high signal indicates that all locations  
programmed correctly, while a low signal indicates that an error occurred during  
one of the programming operations.  
CPVER is multiplexed with P2.6 and COMP2.  
External Access  
I
This input determines whether memory accesses to special-purpose and  
program memory partitions are directed to internal or external memory. (See  
Table 4-1 on page 4-2 for address ranges of special-purpose and program  
memory partitions.) 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# also controls entry into the programming modes. If EA# is at VPP voltage  
(typically +12.5 V) on the rising edge of RESET#, the microcontroller enters a  
programming mode.  
NOTE: Systems with EA# tied inactive have idle time between external bus  
cycles. When the address/data bus is idle, you can use ports 3 and 4  
for I/O. Systems with EA# tied active cannot use ports 3 and 4 as  
standard I/O; when EA# is active, these ports will function only as the  
address/data bus.  
EA# is sampled and latched only on the rising edge of RESET#. Changing the  
level of EA# after reset has no effect.  
Always connect EA# to VSS when using a microcontroller that has no internal  
nonvolatile memory.  
B-15  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table B-6. Signal Descriptions (Continued)  
Name  
Type  
Description  
EPA3:0 (MC)  
EPA5:0 (MD)  
EPA1:0 (MH)  
I/O  
Event Processor Array (EPA) Capture/Compare Channels  
High-speed input/output signals for the EPA capture/compare channels.  
EPA5:0 are multiplexed as follows: EPA0/P2.0/PVER, EPA1/P2.1/PALE# (MC,  
MD), EPA1/P2.2/PROG# (MH), EPA2/P2.2/PROG#, EPA3/P2.3, EPA4/P7.0,  
and EPA5/P7.1.  
EPA5:4 are not implemented on the 8XC196MC and EPA5:2 are not  
implemented on the 8XC196MH.  
EXTINT  
I
External Interrupt  
This programmable interrupt is controlled by the WG_PROTECT register. This  
register controls whether the interrupt is edge triggered or sampled and whether  
a rising edge/high level or falling edge/low level activates the interrupt.  
In powerdown mode, asserting the EXTINT signal for at least 50 ns causes the  
device to resume normal operation. The interrupt need not be enabled. If the  
EXTINT 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.  
FREQOUT  
(MD only)  
O
O
Frequency Generator Output  
A fixed 50% duty cycle waveform that can vary in frequency from 4 KHz to 1  
MHz (assuming FXTAL1 = 16 MHz).  
FREQOUT is multiplexed with P7.7.  
FREQOUT is not implemented on the 8XC196MC or MH.  
Instruction Fetch  
INST  
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.  
INST is multiplexed with P5.1.  
Nonmaskable Interrupt  
NMI  
I
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.  
B-16  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SIGNAL DESCRIPTIONS  
Table B-6. Signal Descriptions (Continued)  
Name  
ONCE#  
Type  
Description  
I
On-circuit Emulation  
Holding ONCE# low during the rising edge of RESET# places the device into  
on-circuit emulation (ONCE) mode. This mode puts all pins, except XTAL1 and  
XTAL2, 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 inadvertent entry into ONCE mode, either configure this pin as an  
output or hold it high during reset and ensure that your system meets the VIH  
specification (see datasheet).  
ONCE# is multiplexed with P5.4.  
P0.7:0  
I
Port 0  
This is a high-impedance, input-only port. Port 0 pins should not be left floating.  
These pins may individually be used as analog inputs (ACHx) or digital inputs  
(P0.y). While it is possible for the pins to function simultaneously as analog and  
digital inputs, this is not recommended because reading port 0 while a  
conversion is in process can produce unreliable conversion results.  
ANGND and VREF must be connected for port 0 to function.  
Port 0 is multiplexed as follows: P0.0/ACH0, P0.1/ACH1, P0.2/ACH2,  
P0.3/ACH3, P0.4/ACH4/PMODE.0, P0.5/ACH5/PMODE.1,  
P0.6/ACH6/PMODE.2 (MC, MD), P0.6/ACH6/T1CLK/PMODE.2 (MH),  
P0.7/ACH7/PMODE.3 (MC, MD), and P0.7/ACH7/T1DIR/PMODE.3 (MH).  
P1.4:0 (MC)  
P1.7:0 (MD)  
I
Port 1  
This is a high-impedance, input-only port.  
On the 8XC196MC and MD, some port 1 pins may individually be used as  
analog inputs (ACHx) or digital inputs (P1.y). While it is possible for the pins to  
function simultaneously as analog and digital inputs, this is not recommended  
because reading port 1 while a conversion is in process can produce unreliable  
conversion results.  
ANGND and VREF must be connected for port 1 to function.  
Port 1 is multiplexed as follows: P1.0/ ACH8, P1.1/ACH9, P1.2/ACH10/T1CLK,  
P1.3/ACH11/T1DIR, P1.4/ACH12, and P1.5/ACH13).  
P1.6 and P1.7 are not multiplexed with any other signals. P1.7:5 are not  
implemented on the 8XC196MC.  
P1.3:0 (MH)  
I/O  
Port 1  
This is a standard, bidirectional port that is multiplexed with individually  
selectable special-function signals.  
On the 8XC196MH, port 1 is multiplexed as follows: P1.0/ TXD0, P1.1/RXD0,  
P1.2/TXD1, and P1.3/RXD1.  
B-17  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table B-6. Signal Descriptions (Continued)  
Description  
Name  
P2.7:0  
Type  
I/O  
Port 2  
This is a standard, 8-bit, bidirectional port that is multiplexed with individually  
selectable special-function signals.  
P2.6 is multiplexed with a special test-mode-entry function. If this pin is held low  
during reset, the device will enter a reserved test mode, so exercise caution if  
you use this pin for input. If you choose to configure this pin as an input, always  
hold it high during reset and ensure that your system meets the VIH specification  
(see datasheet) to prevent inadvertent entry into ONCE mode.  
On the 8XC196MC and MD, port 2 is multiplexed as follows: P2.0/EPA0/PVER,  
P2.1/EPA1/PALE#, P2.2/EPA2/PROG#, P2.3/EPA3, P2.4/COMP0/AINC#,  
P2.5/COMP1/PACT#, P2.6/COMP2/CPVER, and P2.7/COMP3.  
On the 8XC196MH, port 2 is multiplexed as follows: P2.0/EPA0/PVER,  
P2.1/SCLK0#/BCLK0/PALE#, P2.2/EPA1/PROG#, P2.3/COMP3,  
P2.4/COMP0/AINC#, P2.5/COMP1/PACT#, P2.6/COMP2/CPVER, and  
P2.7/SCLK1#/BCLK1.  
P3.7:0  
P4.7:0  
P5.7:0  
I/O  
I/O  
I/O  
Port 3  
This is a memory-mapped, 8-bit, bidirectional port with programmable open-  
drain or complementary output modes. The pins are shared with the  
multiplexed address/data bus, which has complementary drivers.  
P3.7:0 are multiplexed with AD7:0 and PBUS.7:0.  
Port 4  
This is a memory-mapped, 8-bit, bidirectional port with programmable open-  
drain or complementary output modes. The pins are shared with the  
multiplexed address/data bus, which has complementary drivers.  
P4.7:0 are multiplexed with AD15:8 and PBUS15:8.  
Port 5  
This is a memory-mapped, 8-bit, bidirectional port that is multiplexed with  
individually selectable control signals.  
P5.4 is multiplexed with the ONCE# function. If this pin is held low during reset,  
the device will enter ONCE mode , so exercise caution if you use this pin for  
input. If you choose to configure this pin as an input, always hold it high during  
reset and ensure that your system meets the VIH specification (see datasheet)  
to prevent inadvertent entry into ONCE mode.  
Port 5 is multiplexed as follows: P5.0/ALE/ADV#, P5.1/INST, P5.2/WR#/WRL#,  
P5.3/RD#, P5.4/ONCE#, P5.5/BHE#/WRH#, P5.6/READY, and  
P5.7/BUSWIDTH.  
P6.7:0  
O
Port 6  
This is a standard, 8-bit, output-only port that is multiplexed with the special  
functions of the waveform generator and PWM peripherals. The WG_OUT  
register configures the pins, establishes the output polarity, and controls  
whether changes to the outputs are synchronized with an event or take effect  
immediately.  
Port 6 is multiplexed as follows: P6.0/WG1#, P6.1/WG1, P6.2/WG2#,  
P6.3/WG2, P6.4/WG3#, P6.5/WG3, P6.6/PWM0, and P6.7/PWM1.  
B-18  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SIGNAL DESCRIPTIONS  
Table B-6. Signal Descriptions (Continued)  
Name  
P7.7:0  
Type  
Description  
I/O  
Port 7  
(MD only)  
This is a standard, 8-bit, bidirectional port with Schmitt-trigger inputs.  
Port 7 is multiplexed as follows: P7.0/EPA4, P7.1/EPA5, P7.2/COMP4,  
P7.3/COMP5, and P7.7/FREQOUT. P7.6:4 are not multiplexed.  
Port 7 is not implemented on the 8XC196MC and 8XC196MH.  
Programming Active  
PACT#  
O
During auto programming or ROM-dump, a low signal indicates that  
programming or dumping is in progress, while a high signal indicates that the  
operation is complete.  
PACT# is multiplexed with P2.5 and COMP1.  
Programming ALE  
PALE#  
I
During slave programming, a falling edge causes the device to read a  
command and address from the PBUS.  
PALE# is multiplexed with P2.1 and EPA1 (MC, MD) and P2.1, SCLK0#, and  
BCLK0 (MH).  
PBUS.15:0  
I/O  
Address/Command/Data Bus  
During slave programming, ports 3 and 4 serve as a bidirectional port with  
open-drain outputs to pass commands, addresses, and data to or from the  
device. Slave programming requires external pull-up resistors.  
During auto programming and ROM-dump, ports 3 and 4 serve as a regular  
system bus to access external memory. P4.6 and P4.7 are left unconnected;  
P1.1 and P1.2 serve as the upper address lines.  
Slave programming:  
PBUS.7:0 are multiplexed with AD7:0 and P3.7:0.  
PBUS.15:8 are multiplexed with AD15:8 and P4.7:0.  
Auto programming:  
On the 8XC196MC, MC, and MH, PBUS.7:0 are multiplexed with AD7:0 and  
P3.7:0.  
On the 8XC196MC and MD, PBUS.13:8 are multiplexed with AD13:8 and  
P4.5:0; PBUS15:14 are multiplexed with P1.2:1.  
On the 8XC196MH, PBUS.11:8 are multiplexed with AD11:8 and P4.3:0;  
PBUS15:12 are multiplexed with P1.3:0.  
PMODE.3:0  
I
Programming Mode Select  
Determines the programming mode. PMODE is sampled after a device reset  
and must be static while the microcontroller is operating. (Table 16-7 on page  
16-13 lists the PMODE values and programming modes.)  
PMODE.3:0 are multiplexed with P0.7:4 and ACH7:4. On the 8XC196MH,  
PMODE.2 is also is also multiplexed with T1CLK, and PMODE.3 is also  
multiplexed with T1DIR.  
B-19  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table B-6. Signal Descriptions (Continued)  
Description  
Name  
PROG#  
Type  
I
Programming Start  
During programming, a falling edge latches data on the PBUS and begins  
programming, while a rising edge ends programming. The current location is  
programmed with the same data as long as PROG# remains asserted, so the  
data on the PBUS must remain stable while PROG# is active.  
During a word dump, a falling edge causes the contents of an OTPROM  
location to be output on the PBUS, while a rising edge ends the data transfer.  
On the 8XC196MC and MD, PROG# is multiplexed with P2.2 and EPA2. On the  
8XC196MH, PROG# is multiplexed with P2.2 and EPA1.  
O
Program Verification  
PVER  
During slave or auto programming, PVER is updated after each programming  
pulse. A high output signal indicates successful programming of a location,  
while a low signal indicates a detected error.  
PVER is multiplexed with P2.0 and EPA0.  
Pulse Width Modulator Outputs  
PWM1:0  
RD#  
O
O
These are PWM output pins with high-current drive capability.  
PWM1:0 are multiplexed with P6.7:6.  
Read  
Read-signal output to external memory. RD# is asserted only during external  
memory reads.  
RD# is multiplexed with P5.3.  
Ready Input  
READY  
I
This active high input along with the chip configuration registers determine the  
number of wait states inserted into the bus cycle. The chip configuration  
registers selects the maximum number of wait states (0, 1, 2, 3, or infinite) that  
can be inserted into the bus cycle. While READY is low, wait states are inserted  
into the bus cycle until the programmed number of wait states is reached. If  
READY is pulled high before the programmed number of wait states is reached,  
no additional wait states will be inserted into the bus cycle.  
READY is multiplexed with P5.6.  
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 and idle modes, asserting RESET# causes the chip to reset and  
return to normal operating mode. The 8XC196MH provides the option of  
preventing an internal reset from generating a reset on the external pin (see  
“Resetting the Device” on page 13-8). After a device reset, the first instruction  
fetch is from FF2080H.  
RXD1:0  
I/O  
Receive Serial Data 0 and 1  
(MH only)  
In modes 1, 2, and 3, RXD0 and 1 receive serial port input data. In mode 0, they  
function as either inputs or open-drain outputs for data.  
RXD0 is multiplexed with P1.1 and RXD1 is multiplexed with P1.3.  
B-20  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SIGNAL DESCRIPTIONS  
Table B-6. Signal Descriptions (Continued)  
Name  
Type  
Description  
SCLK1:0#  
(MH only)  
I/O  
Shift Clock 0 and 1  
In SIO mode 4, SCLKx# are bidirectional shift clock signals that synchronize the  
serial data transfer. The DIR bit in the SP_CON register controls the direction of  
SCLKx#.  
DIR = 1 allows an external shift clock to be input on SCLKx#.  
DIR = 0 causes SCLKx# to output the internal shift clock.  
SCLK0# is multiplexed with P2.1, BCLK0, and PALE#. SCLK1# is multiplexed  
with P2.7 and BCLK1.  
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.  
and  
External clock for the serial I/O baud-rate generator input (program selectable).  
On the 8XC196MC and MD, T1CLK is multiplexed with P1.2 and ACH10. On  
the 8XC196MH, T1CLK is multiplexed with P0.6, ACH6, and PMODE.2.  
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.  
On the 8XC196MC and MD, T1DIR is multiplexed with P1.3 and ACH11. On the  
8XC196MH, T1DIR is multiplexed with P0.7, ACH7, and PMODE.3.  
TXD1:0  
O
Transmit Serial Data 0 and 1  
(MH only)  
In serial I/O modes 1, 2, and 3, TXD0 and 1 transmit serial port output data. In  
mode 0, they are the serial clock outputs.  
TXD0 is multiplexed with P1.0 and TXD1 is multiplexed with P1.2.  
TXD0 and 1 are not implemented on the 8XC196MC and MD.  
VCC  
VPP  
PWR Digital Supply Voltage  
Connect each VCC pin to the digital supply voltage.  
PWR Programming Voltage  
During programming, the VPP pin is typically at +12.5 V (VPP voltage).  
Exceeding the maximum VPP voltage specification can damage the device.  
PP also causes the device to exit powerdown mode when it is driven low for at  
V
least 50 ns. Use this method to exit powerdown only when using an external  
clock source because it enables the internal phase clocks, but not the internal  
oscillator. See “Driving the Vpp Pin Low” on page 14-6.  
On devices with no internal nonvolatile memory, connect VPP to VCC  
.
VREF  
PWR Reference Voltage for the A/D Converter  
This pin also supplies operating voltage to both the analog portion of the A/D  
converter and the logic used to read port 0 (also port 1 in the 8XC196MC and  
8XC196MD).  
VSS  
GND  
Digital Circuit Ground  
These pins supply ground for the digital circuitry. Connect each VSS pin to  
ground through the lowest possible impedance path.  
B-21  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table B-6. Signal Descriptions (Continued)  
Name  
WG3:1  
Type  
Description  
O
Waveform Generator Phase 1–3 Positive Outputs  
3-phase output signals used in motion-control applications.  
WG1 is multiplexed with P6.1, WG2 is multiplexed with P6.3, and WG3 is  
multiplexed with P6.5.  
WG3:1#  
WR#  
O
O
Waveform Generator Phase 1–3 Negative Outputs  
Complimentary 3-phase output signals used in motion-control applications.  
WG1# is multiplexed with P6.0, WG2# is multiplexed with P6.2, and WG3# is  
multiplexed with P6.4.  
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 P5.2 and 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 P5.5 and 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 to external memory. During 8-bit bus cycles, WRL# is  
asserted for all write operations.  
WRL# is multiplexed with P5.2 and 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  
XTAL2  
I
Input Crystal/Resonator or External Clock Input  
Input to the on-chip oscillator and the internal clock generators. The internal  
clock generators provide the peripheral clocks, CPU clock, and CLKOUT signal  
(MC/MD only). 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).  
O
Inverted Output for the Crystal/Resonator  
Output of the on-chip oscillator inverter. Leave XTAL2 floating when the design  
uses an external clock source instead of the on-chip oscillator.  
B.4 DEFAULT CONDITIONS  
Table B-8 lists the values of the signals of the 8XC196MC and 8XC196MD during various oper-  
ating conditions. The shaded rows indicate those signals that are available only on the  
B-22  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SIGNAL DESCRIPTIONS  
8XC196MD. Table B-9 lists the same information for the 8XC196MH. Table B-7 defines the  
symbols used to represent the pin status. Refer to the DC Characteristics table in the datasheet for  
actual specifications for VOL, V , VOH, and V .  
IL  
IH  
Table B-7. Definition of Status Symbols  
Symbol  
Definition  
Symbol  
MD0  
Definition  
Medium pull-down  
0
Voltage less than or equal to VOL, VIL  
Voltage greater than or equal to VOH, VIH  
High impedance  
1
MD1  
WK0  
WK1  
ODIO  
Medium pull-up  
Weak pull-down  
Weak pull-up  
HiZ  
LoZ0  
LoZ1  
Low impedance; strongly driven low  
Low impedance; strongly driven high  
Open-drain I/O  
Table B-8. 8XC196MC and MD Default Signal Conditions  
Upon RESET#  
Alternate  
Functions  
During  
RESET# Active  
Port Signals  
Inactive  
(Note 14)  
Idle  
Powerdown  
P0.7:0  
ACH7:0  
HiZ  
HiZ  
HiZ  
HiZ  
HiZ  
HiZ  
P1.1:0  
ACH9:8  
ACH10/T1CLK  
ACH11/T1DIR  
ACH12  
P1.2  
HiZ  
HiZ  
HiZ  
P1.3  
HiZ  
HiZ  
HiZ  
P1.4  
HiZ  
HiZ  
HiZ  
P1.5 (Note 15)  
P1.7:6 (Note 15)  
P2.0  
ACH13  
HiZ  
HiZ  
HiZ  
HiZ  
HiZ  
HiZ  
EPA0  
WK1 (Note 1)  
WK1  
WK1  
WK1  
WK1  
WK1  
WK1  
(Note 12)  
(Note 12)  
(Note 12)  
(Note 12)  
(Note 12)  
(Note 12)  
(Note 12)  
(Note 12)  
P2.1  
EPA1  
P2.3:2  
EPA3:2  
P2.6:4  
COMP2:0  
WK1; except  
P2.5 = LZ  
(Note 1)  
P2.7  
P3.7:0  
P4.7:0  
P5.0  
P5.1  
P5.2  
P5.3  
P5.4  
P5.5  
P5.6  
P5.7  
P6.0  
P6.1  
P6.2  
COMP3  
AD7:0  
WK1  
WK1  
WK1  
HiZ  
(Note 12)  
(Note 3)  
(Note 12)  
(Note 3)  
AD15:8  
ADV#/ALE  
INST  
WK1  
HiZ  
(Note 3)  
(Note 3)  
WK1 (Note 1)  
WK1  
WK1 (Note 4)  
WK1  
(Note 8)  
(Note 8)  
(Note 9)  
(Note 9)  
WR#/WRL#  
RD#  
WK1 (Note 1)  
WK1 (Note 1)  
MD1  
WK1  
(Note 10)  
(Note 10)  
(Note 10)  
(Note 10)  
(Note 11)  
(Note 11)  
(Note 13)  
(Note 13)  
(Note 13)  
(Note 10)  
(Note 10)  
(Note 10)  
(Note 10)  
(Note 11)  
(Note 11)  
(Note 13)  
(Note 13)  
(Note 13)  
WK1 (Note 4)  
LZ (Note 1)  
WK1 (Note 4)  
(Note 5)  
(Note 6)  
WK1  
ONCE#  
BHE#/WRH#  
READY  
BUSWIDTH  
WG1#  
WK1  
WK1  
WK1  
WK1  
WG1  
WK1  
WK1  
WG2#  
WK1  
WK1  
B-23  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table B-8. 8XC196MC and MD Default Signal Conditions (Continued)  
Upon RESET#  
Inactive  
(Note 14)  
Alternate  
Functions  
During  
RESET# Active  
Port Signals  
Idle  
Powerdown  
P6.3  
WG2  
WK1  
WK1  
WK1  
WK1  
WK1  
(Note 13)  
(Note 13)  
(Note 13)  
(Note 13)  
(Note 13)  
(Note 12)  
(Note 12)  
(Note 12)  
(Note 12)  
(Note 13)  
(Note 13)  
(Note 13)  
(Note 13)  
(Note 13)  
(Note 12)  
(Note 12)  
(Note 12)  
(Note 12)  
LoZ0  
P6.4  
WG3#  
P6.5  
WG3  
WK1  
P6.6  
PWM0  
PWM1  
EPA5:4  
COMP5:4  
WK0  
P6.7  
WK0  
P7.1:0 (Note 15)  
P7.3:2 (Note 15)  
P7.6:4 (Note 15)  
P7.7 (Note 15)  
WK1 (Note 1)  
WK1  
WK1  
FREQOUT  
CLKOUT  
WK1  
CLKOUTactive,  
LoZ0/1  
CLKOUT  
active, LoZ0/1  
EA#  
HiZ  
HiZ  
HiZ  
HiZ  
HiZ  
HiZ  
EXTINT  
NMI  
WK0  
WK0  
HiZ  
WK0  
HiZ  
RESET#  
LoZ0/HiZ  
(Note 2)  
VPP  
HiZ  
LoZ1  
LoZ1  
XTAL1  
XTAL2  
Osc input, HiZ  
Osc input, HiZ  
Osc input, HiZ Osc input, HiZ  
Osc output,  
LoZ0/1  
Osc output,  
LoZ0/1  
Osc output,  
LoZ0/1  
(Note 7)  
NOTES:  
1. These pins also control test mode entry.  
2. If Disable Reset Out = 0, pin is LoZ0. If Disable Reset Out =1, pin is HiZ.  
3. If EA# = 0, Port 3 and Port 4 = HiZ. If EA# = 1, Port 3 and Port 4 = ODIO.  
4. If EA# = 1, pin is WK1. If EA# = 0, P5.0, P5.3, and P5.5 are configured as outputs and function as  
ADV#, RD#, or BHE# respectively.  
5. READY function not selected and three wait states inserted to allow fetch of CCB.  
6. BUSWIDTH function is selected.  
7. If XTAL1 = 1, pin is LoZ0. If XTAL1 = 0, pin is LoZ1.  
8. If P5_MODE.0 = 0, port is as programmed.  
If P5_MODE.0 = 1 and CCR.3 = 1 (ALE mode), pin is LoZ0. If P5_MODE.0 = 1 and CCR.3 = 0 (ADV#  
mode), pin is LoZ1.  
9. If P5_MODE.1 = 0, port is as programmed. If P5_MODE.1 = 1, pin is LoZ0.  
10. If P5_MODE.y = 0, port is as programmed. If P5_MODE.y = 1, pin is LoZ1.  
11. If P5_MODE.y = 0, port is as programmed. If P5_MODE.y = 1, pin is HiZ.  
12. If Px_MODE.y = 0, port is as programmed. If Px_MODE.y = 1, pin is as specified by the associated  
peripheral.  
13. If output port, pin is as programmed. If special function, pin is as specified by the associated periph-  
eral.  
14. The values in this column are valid until your software writes to Px_MODE.  
15. Shaded rows indicate those signals that are available only on the 8XC196MD.  
B-24  
Download from Www.Somanuals.com. All Manuals Search And Download.  
SIGNAL DESCRIPTIONS  
Table B-9. 8XC196MH Default Signal Conditions  
Upon  
During  
RESET#  
Active  
Alternate  
Functions  
RESET#  
Inactive  
(Note 12)  
Port Signals  
Idle  
Powerdown  
P0.5:0  
P0.6  
P0.7  
P1.0  
P1.1  
P1.2  
P1.3  
P2.0  
P2.1  
P2.2  
P2.3  
P2.5:4  
P2.6  
P2.7  
P3.7:0  
P4.7:0  
P5.0  
P5.1  
P5.2  
P5.3  
P5.4  
P5.5  
P5.6  
P5.7  
P6.0  
P6.1  
P6.2  
P6.3  
P6.4  
P6.5  
P6.6  
P6.7  
ACH5:0  
HiZ  
HiZ  
HiZ  
HiZ  
ACH6/T1CLK  
ACH7/T1DIR  
TXD0  
HiZ  
HiZ  
HiZ  
HiZ  
HiZ  
WK1  
WK1  
WK1  
WK1  
WK1  
WK1  
WK1  
WK1  
WK1  
WK1  
MD1  
WK1  
HiZ  
(Note 10)  
(Note 10)  
(Note 10)  
(Note 10)  
(Note 10)  
(Note 10)  
(Note 10)  
(Note 10)  
(Note 10)  
(Note 10)  
(Note 10)  
(Note 10)  
(Note 3)  
(Note 6)  
(Note 7)  
(Note 8)  
(Note 8)  
(Note 8)  
(Note 10)  
(Note 9)  
(Note 9)  
(Note 11)  
(Note 11)  
(Note 11)  
(Note 11)  
(Note 11)  
(Note 11)  
(Note 11)  
(Note 11)  
HiZ  
(Note 10)  
(Note 10)  
(Note 10)  
(Note 10)  
(Note 10)  
(Note 10)  
(Note 10)  
(Note 10)  
(Note 10)  
(Note 10)  
(Note 10)  
(Note 3)  
(Note 3)  
(Note 6)  
(Note 7)  
(Note 8)  
(Note 8)  
(Note 8)  
(Note 10)  
(Note 9)  
(Note 9)  
(Note 11)  
(Note 11)  
(Note 11)  
(Note 11)  
(Note 11)  
(Note 11)  
(Note 11)  
(Note 11)  
HiZ  
RXD0  
WK1  
TXD1  
WK1  
RXD1  
WK1  
EPA0  
WK1 (Note 1)  
WK1  
BCLK0 /SCLK0#  
EPA1  
WK1  
COMP3  
COMP1:0  
COMP2  
BCLK1 /SCLK1#  
AD7:0  
WK1  
WK1  
MD1 (Note 1)  
WK1  
WK1  
AD15:8  
ADV#/ALE  
INST  
WK1  
HiZ  
WK1 (Note 1)  
WK1  
(Note 6)  
WK1  
WK1  
(Note 4)  
MD1  
(Note 5)  
WK1  
WK1  
WK1  
WK1  
WK1  
WK1  
WK1  
WK1  
WK1  
WK1  
WR#/WRL#  
RD#  
WK1 (Note 1)  
WK1 (Note 1)  
MD1 (Note 1)  
WK1  
ONCE#  
BHE#/WRH#  
READY  
BUSWIDTH  
WG1#  
WK1  
WK1  
WK1  
WG1  
WK1  
WG2#  
WK1  
WG2  
WK1  
WG3#  
WK1  
WG3  
WK1  
PWM0  
WK0  
PWM1  
WK0  
EA#  
HiZ  
EXTINT  
NMI  
HiZ  
HiZ  
HiZ  
WK0  
WK0  
WK0  
RESET#  
LoZ0/HiZ  
(Note 2)  
HiZ  
HiZ  
VPP  
HiZ  
LoZ1  
LoZ1  
B-25  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table B-9. 8XC196MH Default Signal Conditions (Continued)  
Upon  
During  
RESET#  
Active  
Alternate  
Functions  
RESET#  
Inactive  
(Note 12)  
Port Signals  
Idle  
Powerdown  
XTAL1  
XTAL2  
Osc input, HiZ  
Osc input, HiZ Osc input, HiZ  
Osc output,  
LoZ0/1  
Osc output,  
LoZ0/1  
(Note 5)  
NOTES:  
1. These pins also control test mode entry.  
2. If Disable Reset Out = 0, pin is LoZ0. Else if Disable Reset Out =1, pin is HiZ.  
3. If EA# = 0, Port 3 and Port 4 = HiZ. If EA# = 1, Port 3 and Port 4 = ODIO.  
4. If EA# = 1, pin is WK1. If EA# = 0, P5.0, P5.3, and P5.5 are configured as outputs and function as  
ADV#, RD#, or BHE# respectively.  
5. If XTAL1 = 1, pin is LoZ0. If XTAL1 = 0, pin is LoZ1.  
6. If P5_MODE.0 = 0, port is as programmed.  
If P5_MODE.0 = 1 and CCR.3 = 1 (ALE mode), pin is LoZ0. If P5_MODE.0 = 1 and CCR.3 = 0 (ADV#  
mode), pin is LoZ1.  
7. If P5_MODE.1 = 0, port is as programmed. If P5_MODE.1 = 1, pin is LoZ0.  
8. If P5_MODE.y = 0, port is as programmed. If P5_MODE.y = 1, pin is LoZ1.  
9. If P5_MODE.y = 0, port is as programmed. If P5_MODE.y = 1, pin is HiZ.  
10. If Px_MODE.y = 0, port is as programmed. If Px_MODE.y = 1, pin is as specified by the associated  
peripheral.  
11. If output port, pin is as programmed. If special function, pin is as specified by the associated periph-  
eral.  
12. The values in this column are valid until your software writes to Px_MODE.  
B-26  
Download from Www.Somanuals.com. All Manuals Search And Download.  
C
Registers  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
APPENDIX C  
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.  
Table C-1. Modules and Related Registers  
EPA  
A/D Converter  
Chip Configuration  
CPU  
(8XC196MC, MH, x = 0–3)  
(8XC196MD, x = 0–5)  
AD_COMMAND  
AD_RESULT  
AD_TEST  
CCR0  
ONES_REG  
PSW  
COMPx_CON  
COMPx_TIME  
EPAx_CON  
CCR1  
GEN_CON (8XC196MH)  
PPW (or SP_PPW)  
USFR  
SP  
AD_TIME  
ZERO_REG  
EPAx_TIME  
Frequency Generator  
(8XC196MD)  
I/O Ports  
Interrupts and PTS  
Memory Control  
FREQ_CNT  
FREQ_GEN  
Px_DIR†  
INT_MASK  
INT_MASK1  
INT_PEND  
INT_PEND1  
PI_MASK  
PI_PEND  
PTSSEL  
WSR  
Px_MODE†  
Px_PIN††  
Px_REG†  
PTSSRV  
PWM  
(x = 0–1)  
Serial Port  
(8XC196MH, x = 0–1)  
Timers  
(x = 0–1)  
Waveform Generator  
(x = 1–3)  
PWM_COUNT  
SBUFx_RX  
SBUFx_TX  
SPx_BAUD  
SPx_CON  
TxCONTROL  
T1RELOAD  
TIMERx  
WG_COMPx  
PWM_PERIOD  
PWMx_CONTROL  
WG_CONTROL  
WG_COUNTER  
WG_OUTPUT  
WG_PROTECT  
WG_RELOAD  
WATCHDOG  
SPx_STATUS  
For the 8XC196MC, x = 2, 5; for the 8XC196MD, x = 2, 5, 7; for the 8XC196MH, x = 1, 2, 5.  
For the 8XC196MC and 8XC196MH, x = 0–5; for the 8XC196MD, x = 0–5, 7.  
††  
C-1  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table C-2. Register Name, Address, and Reset Status  
Binary Reset Value  
Register  
Mnemonic  
Hex  
Addr  
Register Name  
High  
Low  
0000  
AD_COMMAND  
A/D Command  
1FAC  
1FAA  
1000  
1100  
1100  
1100  
1000  
1111  
AD_RESULT (MC, MD)  
AD_RESULT (MH)  
1111  
0111  
1111  
1111  
0000  
0000  
0000  
1000  
1111  
A/D Result  
A/D Test  
AD_TEST (MC, MD)  
AD_TEST (MH)  
1FAE  
AD_TIME  
A/D Time  
1FAF  
†††  
CCR0  
Chip Configuration 0  
Chip Configuration 1  
EPA Compare 0 Control  
EPA Compare 1 Control  
EPA Compare 2 Control  
XXXX XXXX  
XXXX XXXX  
CCR1  
†††  
COMP0_CON  
COMP1_CON  
COMP2_CON  
1F58  
1F5C  
1F60  
1F64  
1F4C  
1F68  
1F6C  
1F5A  
1F5E  
1F62  
1F66  
1F4E  
1F6A  
1F6E  
1F40  
1F44  
1F48  
1F4C  
1F50  
1F54  
1F42  
0000  
0000  
0000  
0000  
0000  
0000  
COMP3_CON (MC, MD)  
COMP3_CON (MH)  
EPA Compare 3 Control  
0000  
0000  
COMP4_CON (MD)  
COMP5_CON (MD)  
COMP0_TIME  
EPA Compare 4 Control  
EPA Compare 5 Control  
EPA Compare 0 Time  
EPA Compare 1 Time  
EPA Compare 2 Time  
0000  
0000  
0000  
0000  
XXXX XXXX XXXX XXXX  
XXXX XXXX XXXX XXXX  
XXXX XXXX XXXX XXXX  
COMP1_TIME  
COMP2_TIME  
COMP3_TIME (MC, MD)  
COMP3_TIME (MH)  
EPA Compare 3 Time  
XXXX XXXX XXXX XXXX  
COMP4_TIME (MD)  
COMP5_TIME (MD)  
EPA0_CON  
EPA Compare 4 Time  
XXXX XXXX XXXX XXXX  
XXXX XXXX XXXX XXXX  
EPA Compare 5 Time  
EPA Capture/Comp 0 Control  
EPA Capture/Comp 1 Control  
EPA Capture/Comp 2 Control  
EPA Capture/Comp 3 Control  
EPA Capture/Comp 4 Control  
EPA Capture/Comp 5 Control  
EPA Capture/Comp 0 Time  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
EPA1_CON  
EPA2_CON (MC, MD)  
EPA3_CON (MC, MD)  
EPA4_CON (MD)  
EPA5_CON (MD)  
EPA0_TIME  
XXXX XXXX XXXX XXXX  
Reset value is FFH when pin is not driven.  
††  
Reset value is 80H if the EA# pin is high, A9H if EA# is low.  
††† The CCRs are loaded with the contents of the chip configuration bytes (CCBs) after a device reset,  
unless the device is entering programming modes (see “Entering Programming Modes” on page  
16-13), in which case the programming chip configuration bytes (PCCBs) are used. The CCBs reside in  
internal nonvolatile memory at addresses 2018H (CCB0) and 201AH (CCB1).  
C-2  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
Table C-2. Register Name, Address, and Reset Status (Continued)  
Binary Reset Value  
High Low  
Register  
Mnemonic  
Hex  
Addr  
Register Name  
EPA1_TIME  
EPA Capture/Comp 1 Time  
EPA Capture/Comp 2 Time  
EPA Capture/Comp 3 Time  
EPA Capture/Comp 4 Time  
EPA Capture/Comp 5 Time  
Frequency Gen Count  
Frequency  
1F46  
1F4A  
1F4E  
1F52  
1F56  
1FBA  
1FB8  
1FA0  
0008  
0013  
0009  
0012  
0002  
1F9B  
1FD2  
1FF3  
1FD3  
1F99  
1FD0  
1FF1  
1FD1  
1FA8  
1FDA  
1FA9  
1F9F  
1FD6  
1FFE  
1FFF  
1FF7  
XXXX XXXX XXXX XXXX  
XXXX XXXX XXXX XXXX  
XXXX XXXX XXXX XXXX  
XXXX XXXX XXXX XXXX  
EPA2_TIME (MC, MD)  
EPA3_TIME (MC, MD)  
EPA4_TIME (MD)  
EPA5_TIME (MD)  
FREQ_CNT (MD)  
FREQ_GEN (MD)  
GEN_CON (MH)  
INT_MASK  
XXXX XXXX 0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
1111  
1111  
1111  
1111  
1111  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
General Configuration  
Interrupt Mask  
INT_MASK1  
Interrupt Mask 1  
INT_PEND  
Interrupt Pending  
Interrupt Pending 1  
Ones Register  
INT_PEND1  
ONES_REG  
1111  
1111  
1111  
1111  
1111  
1111  
1111  
0000  
0000  
P1_DIR (MH)  
P2_DIR  
Port 1 I/O Direction  
Port 2 I/O Direction  
Port 5 I/O Direction  
Port 7 I/O Direction  
Port 1 Mode  
P5_DIR  
P7_DIR (MD)  
P1_MODE (MH)  
P2_MODE  
Port 2 Mode  
0000  
††  
P5_MODE  
Port 5 Mode  
P7_MODE (MD)  
Port 7 Mode  
0000  
0000  
P0_PIN (MC, MD)  
P0_PIN (MH)  
Port 0 Pin Input  
Port 1 Pin Input  
P1_PIN (MC, MD)  
P1_PIN (MH)  
P2_PIN  
P3_PIN  
P4_PIN  
Port 2 Pin Input  
Port 3 Pin Input  
Port 4 Pin Input  
Port 5 Pin Input  
P5_PIN  
1111  
1111  
Reset value is FFH when pin is not driven.  
††  
Reset value is 80H if the EA# pin is high, A9H if EA# is low.  
††† The CCRs are loaded with the contents of the chip configuration bytes (CCBs) after a device reset,  
unless the device is entering programming modes (see “Entering Programming Modes” on page  
16-13), in which case the programming chip configuration bytes (PCCBs) are used. The CCBs reside in  
internal nonvolatile memory at addresses 2018H (CCB0) and 201AH (CCB1).  
C-3  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Table C-2. Register Name, Address, and Reset Status (Continued)  
Binary Reset Value  
Register  
Mnemonic  
Hex  
Addr  
Register Name  
High  
Low  
P7_PIN (MD)  
Port 7 Pin Input  
1FD7  
1F9D  
1FD4  
1FFC  
1FFD  
XXXX XXXX  
P1_REG (MH)  
P2_REG  
Port 1 Data Output  
Port 2 Data Output  
Port 3 Data Output  
Port 4 Data Output  
1111  
1111  
1111  
1111  
1111  
1111  
1111  
1111  
P3_REG  
P4_REG  
P5_REG (MC, MD)  
P5_REG (MH)  
Port 5 Data Output  
1FF5  
1111  
1111  
1010  
1010  
1111  
1111  
1010  
1010  
P7_REG (MD)  
PI_MASK  
Port 7 Data Output  
Peripheral Interrupt Mask  
Peripheral Interrupt Pending  
Programming Pulse Width  
Processor Status Word  
PTS Select  
1FD5  
1FBC  
1FBE  
PI_PEND  
PPW  
no direct  
access  
PSW  
PTSSEL  
0004  
0006  
1FB6  
1FB4  
1FB0  
1FB2  
1F80  
1F88  
1F82  
1F8A  
0018  
1F84  
1F8C  
1F83  
1F8B  
1F81  
1F89  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
PTSSRV  
PTS Service  
PWM_COUNT  
PWM_PERIOD  
PWM0_CONTROL  
PWM1_CONTROL  
SBUF0_RX (MH)  
SBUF1_RX (MH)  
SBUF0_TX (MH)  
SBUF1_TX (MH)  
SP  
PWM Count  
PWM Period  
PWM 0 Control  
PWM 1 Control  
Serial Port Receive Buffer  
Serial Port Receive Buffer  
Serial Port Transmit Buffer  
Serial Port Transmit Buffer  
Stack Pointer  
XXXX XXXX XXXX XXXX  
SP0_BAUD (MH)  
SP1_BAUD (MH)  
SP0_CON (MH)  
SP1_CON (MH)  
SP0_STATUS (MH)  
Serial Port 0 Baud Rate  
Serial Port 1 Baud Rate  
Serial Port Control  
Serial Port Control  
Serial Port Status  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
SP1_STATUS (MH)  
Serial Port Status  
Reset value is FFH when pin is not driven.  
††  
Reset value is 80H if the EA# pin is high, A9H if EA# is low.  
††† The CCRs are loaded with the contents of the chip configuration bytes (CCBs) after a device reset,  
unless the device is entering programming modes (see “Entering Programming Modes” on page  
16-13), in which case the programming chip configuration bytes (PCCBs) are used. The CCBs reside in  
internal nonvolatile memory at addresses 2018H (CCB0) and 201AH (CCB1).  
C-4  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
Table C-2. Register Name, Address, and Reset Status (Continued)  
Binary Reset Value  
High Low  
Register  
Mnemonic  
Hex  
Addr  
Register Name  
T1CONTROL  
Timer 1 Control  
1F78  
1F7C  
1F72  
1F7A  
1F7E  
0000  
0000  
0000  
0000  
T2CONTROL  
T1RELOAD  
TIMER1  
Timer 2 Control  
Timer 1 Reload  
Timer 1 Value  
Timer 2 Value  
XXXX XXXX XXXX XXXX  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0010  
TIMER2  
USFR (MC, MD)  
USFR (MH)  
UPROM Special Function  
1FF6  
XXXX XXXX  
XXXX XXXX  
WATCHDOG  
WG_COMP1  
WG_COMP2  
WG_COMP3  
Watchdog Timer  
000A  
1FC2  
1FC4  
1FC6  
Waveform Gen Phase Comp 1  
Waveform Gen Phase Comp 2  
Waveform Gen Phase Comp 3  
0000  
0000  
0000  
0000  
1000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
0000  
1100  
0000  
0000  
0000  
0000  
0000  
0000  
WG_CONTROL (MC, MD)  
WG_CONTROL (MH)  
Waveform Gen Control  
1FCC  
WG_COUNTER  
WG_OUTPUT  
Waveform Gen Count  
1FCA  
1FC0  
XXXX XXXX XXXX XXXX  
Waveform Gen Output Config  
0000  
0000  
0000  
1111  
0000  
0000  
0000  
0000  
0000  
0000  
WG_PROTECT (MC, MD)  
WG_PROTECT (MH)  
Waveform Gen Protection  
1FCE  
1110  
0000  
0000  
0000  
WG_RELOAD  
WSR  
Waveform Gen Reload  
Window Selection  
Zero Register  
1FC8  
0014  
0000  
0000  
0000  
0000  
0000  
ZERO_REG  
Reset value is FFH when pin is not driven.  
††  
Reset value is 80H if the EA# pin is high, A9H if EA# is low.  
††† The CCRs are loaded with the contents of the chip configuration bytes (CCBs) after a device reset,  
unless the device is entering programming modes (see “Entering Programming Modes” on page  
16-13), in which case the programming chip configuration bytes (PCCBs) are used. The CCBs reside in  
internal nonvolatile memory at addresses 2018H (CCB0) and 201AH (CCB1).  
C-5  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
AD_COMMAND  
Address:  
Reset State:  
1FACH  
80H  
AD_COMMAND  
The A/D command (AD_COMMAND) register selects the A/D channel number to be converted,  
controls whether the A/D converter starts immediately or with an EPA command, and selects the  
conversion mode.  
7
0
M1  
M0  
GO  
ACH3  
ACH2  
ACH1  
ACH0  
Bit  
Number  
Bit  
Mnemonic  
Function  
7
Reserved; for compatibility with future devices, write zeros to these bits.  
6:5  
M1:0  
A/D Mode†  
These bits determine the A/D mode.  
M1  
M0  
Mode  
0
0
1
1
0
1
0
1
10-bit conversion  
8-bit conversion  
threshold detect high  
threshold detect low  
4
GO  
A/D Conversion Trigger††  
Writing this bit arms the A/D converter. The value that you write to it  
determines at what point a conversion is to start.  
0 = EPA initiates conversion  
1 = start immediately  
3:0  
ACH3:0  
A/D Channel Selection  
Write the A/D conversion channel number to these bits.  
While a threshold-detection mode is selected for an analog input pin, no other conversion can be  
started. If another value is loaded into AD_COMMAND, the threshold-detection mode is disabled  
and the new command is executed.  
††  
It is the act of writing to the GO bit, rather than its value, that starts a conversion. Even if the GO bit  
has the desired value, you must set it again to start a conversion immediately or clear it again to  
arm it for an EPA-initiated conversion.  
C-6  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
AD_RESULT (Read)  
Address:  
Reset State (MC, MD):  
Reset State (MH):  
1FAAH  
FFC0H  
7FC0H  
AD_RESULT (Read)  
The A/D result (AD_RESULT) register consists of two bytes. The high byte contains the eight most-  
significant bits from the A/D converter. The low byte contains the two least-significant bits from a ten-  
bit A/D conversion, indicates the A/D channel number that was used for the conversion, and indicates  
whether a conversion is currently in progress.  
15  
ADRLT9  
8
ADRLT8  
ADRLT0  
ADRLT7  
ADRLT6  
STATUS  
ADRLT5  
ACH3  
ADRLT4  
ACH2  
ADRLT3  
ACH1  
ADRLT2  
7
0
ADRLT1  
ACH0  
Bit  
Number  
Bit  
Mnemonic  
Function  
15:6  
ADRLT9:0  
A/D Result  
These bits contain the A/D conversion result.  
Reserved. This bit is undefined.  
A/D Status  
5
4
STATUS  
Indicates the status of the A/D converter. Up to 8 state times are required  
to set this bit following a start command. When testing this bit, wait at  
least the 8 state times.  
0 = A/D is idle  
1 = A/D conversion is in progress  
3:0  
ACH3:0  
A/D Channel Number  
These bits indicate the A/D channel number that was used for the  
conversion.  
C-7  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
AD_RESULT (Write)  
Address:  
Reset State (MC, MD):  
Reset State (MH):  
1FAAH  
FFC0H  
7FC0H  
AD_RESULT (Write)  
The high byte of the A/D result (AD_RESULT) register can be written to set the reference voltage for  
the A/D threshold-detection modes.  
15  
8
0
REFV7  
REFV6  
REFV5  
REFV4  
REFV3  
REFV2  
REFV1  
REFV0  
7
Bit  
Number  
Bit  
Mnemonic  
Function  
15:8  
REFV7:0  
Reference Voltage  
These bits specify the threshold value. This selects a reference voltage  
that is compared with an analog input pin. When the voltage on the  
analog input pin crosses over (detect high) or under (detect low) the  
threshold value, the A/D conversion complete interrupt pending bit is set.  
Use the following formula to determine the value to write to this register  
for a given threshold voltage.  
desired threshold voltage × 256  
----------------------------------------------------------------------------------  
reference voltage =  
V
REF ANGND  
7:0  
Reserved; for compatibility with future devices, write zeros to these bits.  
C-8  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
AD_TEST  
Address:  
Reset State (MC, MD):  
Reset State (MH):  
1FAEH  
C0H  
AD_TEST  
88H  
The A/D test (AD_TEST) register specifies adjustments for DC offset errors.  
7
0
OFF1  
OFF0  
Bit  
Number  
Bit  
Mnemonic  
Function  
7:5  
Reserved; for compatibility with future devices, write zeros to these bits.  
4
OFF1  
Offset  
This bit , along with OFF0 (bit 2) allows you to set the zero offset point.  
OFF1 OFF0  
0
0
1
1
0
1
0
1
no adjustment  
add 2.5 mV  
subtract 2.5 mV  
subtract 5.0 mV  
3
Reserved; for compatibility with future devices, write zero to this bit.  
See bit 4 (OFF1).  
2
OFF0  
1:0  
Reserved; for compatibility with future devices, write zeros to these bits.  
C-9  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
AD_TIME  
Address:  
Reset State:  
1FAFH  
FFH  
AD_TIME  
The A/D time (AD_TIME) register programs the sample window time and the conversion time for each  
bit. This register programs the speed at which the A/D can run — not the speed at which it can convert  
correctly. Consult the data sheet for recommended values. Initialize the AD_TIME register before  
initializing the AD_COMMAND register. Do not write to this register while a conversion is in progress;  
the results are unpredictable.  
7
0
SAM2  
SAM1  
SAM0  
CONV4  
CONV3  
CONV2  
CONV1  
CONV0  
Bit  
Number  
Bit  
Mnemonic  
Function  
7:5  
SAM2:0  
A/D Sample Time  
These bits specify the sample time. Use the following formula to  
compute the sample time.  
TSAM × FXTAL1 2  
------------------------------------------------  
SAM =  
8
where:  
SAM  
=
=
=
1 to 7  
TSAM  
FXTAL1  
the sample time, in µsec, from the data sheet  
the input frequency on XTAL1, in MHz  
4:0  
CONV4:0  
A/D Convert Time  
These bits specify the conversion time for each bit. Use the following  
formula to compute the conversion time.  
TCONV ×FXTAL1 3  
----------------------------------------------------  
CONV =  
where:  
1  
2 ×B  
CONV= 2 to 31  
TCONV  
FXTAL1  
B
=
=
=
the conversion time, in µsec, from the data sheet  
the input frequency on XTAL1, in MHz  
the number of bits to be converted (8 or 10)  
C-10  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
CCR0  
no direct access†  
CCR0  
The chip configuration 0 (CCR0) register controls powerdown mode, bus-control signals, and internal  
memory protection. Three of its bits combine with two bits of CCR1 to control wait states and bus  
width.  
7
0
LOC1  
LOC0  
IRC1  
IRC0  
ALE  
WR  
BW0  
PD  
Bit  
Number  
Bit  
Mnemonic  
Function  
7:6  
LOC1:0  
Lock Bits  
These two bits control read and write access to the OTPROM during  
normal operation. Refer to “Controlling Access to the OTPROM During  
Normal Operation” on page 16-4 for details.  
LOC1 LOC0  
0
0
1
1
0
1
0
1
read and write protect  
read protect only  
write protect only  
no protection  
5:4  
IRC1:0  
Internal Ready Control  
These two bits, along with IRC2 (CCR1.1) and the READY pin determine  
the number of wait states that can be inserted into the bus cycle. While  
READY is held low, wait states are inserted into the bus cycle until the  
programmed number of wait states is reached. If READY is pulled high  
before the programmed number of wait states is reached, no additional  
wait states will be inserted into the bus cycle.  
IRC2 IRC1 IRC0  
0
0
1
1
1
1
1
0
X
1
0
0
1
1
0
1
X
0
1
0
1
zero wait states  
illegal  
illegal  
one wait state  
two wait states  
three wait states  
infinite  
If you choose the infinite wait states option, you must keep P5.6  
configured as the READY signal. Also, be sure to add external hardware  
to count wait states and pull READY high within a specified time.  
Otherwise, a defective external device could tie up the address/data bus  
indefinitely.  
The CCRs are loaded with the contents of the chip configuration bytes (CCBs) after reset, unless the  
microcontroller is entering programming modes (see “Entering Programming Modes” on page 16-13),  
in which case the programming chip configuration bytes (PCCBs) are used. The CCBs reside in  
nonvolatile memory at addresses 2018H (CCB0) and 201AH (CCB1).  
C-11  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
CCR0  
no direct access†  
CCR0 (Continued)  
The chip configuration 0 (CCR0) register controls powerdown mode, bus-control signals, and internal  
memory protection. Three of its bits combine with two bits of CCR1 to control wait states and bus  
width.  
7
0
LOC1  
LOC0  
IRC1  
IRC0  
ALE  
WR  
BW0  
PD  
Bit  
Number  
Bit  
Mnemonic  
Function  
Address Valid Strobe and Write Strobe  
3
ALE  
These bits define which bus-control signals will be generated during  
external read and write cycles.  
2
WR  
ALE WR  
0
0
1
1
0
1
0
1
address valid with write strobe mode  
(ADV#, RD#, WRL#, WRH#)  
address valid strobe mode  
(ADV#, RD#, WR#, BHE#)  
write strobe mode  
(ALE, RD#, WRL#, WRH#)  
standard bus-control mode  
(ALE, RD#, WR#, BHE#)  
1
BW0  
Buswidth Control  
This bit, along with the BW1 bit (CCR1.2), selects the bus width.  
BW1 BW0  
0
0
1
1
0
1
0
1
illegal  
16-bit only  
8-bit only  
BUSWIDTH pin controlled  
0
PD  
Powerdown Enable  
Controls whether the IDLPD #2 instruction causes the microcontroller to  
enter powerdown mode. If your design uses powerdown 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 mode.  
0 = disable powerdown mode  
1 = enable powerdown mode  
The CCRs are loaded with the contents of the chip configuration bytes (CCBs) after reset, unless the  
microcontroller is entering programming modes (see “Entering Programming Modes” on page 16-13),  
in which case the programming chip configuration bytes (PCCBs) are used. The CCBs reside in  
nonvolatile memory at addresses 2018H (CCB0) and 201AH (CCB1).  
C-12  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
CCR1  
no direct access†  
CCR1  
The chip configuration 1 (CCR1) register enables the watchdog timer and selects the bus timing  
mode. Two of its bits combine with three bits of CCR0 to control wait states and bus width.  
7
0
1
1
0
1
WDE  
BW1  
IRC2  
0
Bit  
Number  
Bit  
Mnemonic  
Function  
7:6  
1
To guarantee proper operation, write ones to these bits.  
To guarantee proper operation, write zero to this bit.  
To guarantee proper operation, write one to this bit.  
Watchdog Timer Enable  
5
4
3
0
1
WDE  
Selects whether the watchdog timer is always enabled or enabled the  
first time it is cleared.  
0 = always enabled  
1 = enabled first time it is cleared  
2
BW1  
Buswidth Control  
This bit, along with the BW0 bit (CCR0.1), selects the bus width.  
BW1 BW0  
0
0
1
1
0
1
0
1
illegal  
16-bit only  
8-bit only  
BUSWIDTH pin controlled  
The CCRs are loaded with the contents of the chip configuration bytes (CCBs) after reset, unless  
the microcontroller is entering programming modes (see “Entering Programming Modes” on page  
16-13), in which case the programming chip configuration bytes (PCCBs) are used. The CCBs  
reside in nonvolatile memory at addresses 2018H (CCB0) and 201AH (CCB1).  
C-13  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
CCR1  
no direct access†  
CCR1 (Continued)  
The chip configuration 1 (CCR1) register enables the watchdog timer and selects the bus timing  
mode. Two of its bits combine with three bits of CCR0 to control wait states and bus width.  
7
0
1
1
0
1
WDE  
BW1  
IRC2  
0
Bit  
Number  
Bit  
Mnemonic  
Function  
1
IRC2  
Ready Control  
This bit, along with IRC0 (CCR0.4), IRC1 (CCR0.5), and the READY pin  
determine the number of wait states that can be inserted into the bus  
cycle. While READY is held low, wait states are inserted into the bus  
cycle until the programmed number of wait states is reached. If READY is  
pulled high before the programmed number of wait states is reached, no  
additional wait states will be inserted into the bus cycle.  
IRC2 IRC1 IRC0  
0
0
1
1
1
1
1
0
X
1
0
0
1
1
0
1
X
0
1
0
1
zero wait states  
illegal  
illegal  
one wait state  
two wait states  
three wait states  
infinite  
If you choose the infinite wait states option, you must keep P5.6  
configured as the READY signal. Also, be sure to add external hardware  
to count wait states and pull READY high within a specified time.  
Otherwise, a defective external device could tie up the address/data bus  
indefinitely.  
0
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 reset, unless  
the microcontroller is entering programming modes (see “Entering Programming Modes” on page  
16-13), in which case the programming chip configuration bytes (PCCBs) are used. The CCBs  
reside in nonvolatile memory at addresses 2018H (CCB0) and 201AH (CCB1).  
C-14  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
COMPx_CON  
Address:  
Reset State:  
Table C-3  
COMPx_CON  
x = 0–3 (8XC196MC, MH)  
x = 0–5 (8XC196MD)  
The EPA compare control (COMPx_CON) registers determine the function of the EPA compare  
channels.  
7
0
0
x = 0, 2, 4  
TB  
TB  
CE  
CE  
M1  
M1  
M0  
M0  
RE  
RE  
WGR  
AD  
ROT  
ROT  
RT  
RT  
7
x = 1, 3, 5  
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 (start of an A/D conversion; 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.  
6
CE  
Compare Enable  
This bit enables the compare function.  
0 = compare function disabled  
1 = compare function enabled  
5:4  
M1:0  
EPA Mode Select  
Specifies the type of compare event.  
M1  
M0  
0
0
1
1
0
1
0
1
no output  
clear output pin  
set output pin  
toggle output pin  
3
RE  
Re-enable  
Allows a compare event to continue to execute each time the event-time  
register (COMPx_TIME) matches the reference timer rather than only  
upon the first time match.  
0 = compare function will drive the output only once  
1 = compare function always enabled  
C-15  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
COMPx_CON  
Address:  
Reset State:  
Table C-3  
COMPx_CON (Continued)  
x = 0–3 (8XC196MC, MH)  
x = 0–5 (8XC196MD)  
The EPA compare control (COMPx_CON) registers determine the function of the EPA compare  
channels.  
7
0
0
x = 0, 2, 4  
TB  
TB  
CE  
CE  
M1  
M1  
M0  
M0  
RE  
RE  
WGR  
AD  
ROT  
ROT  
RT  
RT  
7
x = 1, 3, 5  
2
WGR  
AD  
A/D Conversion, Waveform Generator Reload  
The function of this bit depends on the EPA channel.  
For EPA capture/compare channels 0, 2, 4:  
The WGR bit allows you to use the EPA activities to cause the reload of  
new values in the waveform generator.  
0 = no action  
1 = enables waveform generator reload  
For EPA capture/compare channels 1, 3, 5:  
The AD bit allows you to use the EPA activities to start an A/D  
conversion that has been previously set up in the A/D control registers.  
0 = causes no A/D action  
1 = starts an A/D conversion on an output compare  
1
0
ROT  
Reset Opposite Timer  
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 state of the TB bit determines which timer is the reference timer and  
which timer is the opposite timer.  
RT  
Reset Timer  
This bit controls whether the timer selected by the ROT bit will be reset.  
1 = resets the timer selected by the ROT bit  
0 = disables the reset function  
C-16  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
COMPx_TIME  
Address:  
Reset State:  
Table C-3  
COMPx_TIME  
x = 0–3 (8XC196MC, MH)  
x = 0–5 (8XC196MD  
The EPA compare x time (COMPx_TIME) registers are the event-time registers for the EPA compare  
channels; they are functionally identically to the EPAx_TIME registers. The EPA triggers a compare  
event when the reference timer matches the value in COMPx_TIME.  
15  
0
EPA Event Time Value  
Bit  
Number  
Function  
15:0  
EPA Event Time Value  
Write the desired compare event time to this register.  
Table C-3. COMPx_TIME Addresses and Reset Values  
Register  
Address  
Reset Value  
COMP0_TIME (8XC196Mx)  
COMP1_TIME (8XC196Mx)  
COMP2_TIME (8XC196Mx)  
1F5AH  
1F5EH  
1F62H  
XXXXH  
XXXXH  
XXXXH  
COMP3_TIME (8XC196MC, MD)  
COMP3_TIME (8XC196MH)  
1F66H  
1F4EH  
XXXXH  
XXXXH  
COMP4_TIME (8XC196MD)  
COMP5_TIME (8XC196MD)  
1F6AH  
1F6EH  
XXXXH  
XXXXH  
C-17  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
EPAx_CON  
Address:  
Reset State:  
Table C-4  
EPAx_CON  
x = 0–1 (8XC196MH)  
x = 0–3 (8XC196MC)  
x = 0–5 (8XC196MD)  
The EPA control (EPAx_CON) registers control the functions of their assigned capture/compare  
channels.  
7
0
x = 0, 2, 4  
x = 1, 3, 5  
TB  
TB  
CE  
CE  
M1  
M1  
M0  
M0  
RE  
WGR  
AD  
ROT  
ROT  
ON/RT  
7
0
RE  
ON/RT  
Bit  
Number  
Bit  
Mnemonic  
Function  
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 (reloading the waveform generator; starting an A/D  
conversion; 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  
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
1
1
0
1
0
1
no capture  
capture on falling edge  
capture on rising edge  
capture on either edge  
M1  
M0  
Compare Mode Action  
0
0
1
1
0
1
0
1
no output  
clear output pin  
set output pin  
toggle output pin  
C-18  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
EPAx_CON  
Address:  
Reset State:  
Table C-4  
EPAx_CON (Continued)  
x = 0–1 (8XC196MH)  
x = 0–3 (8XC196MC)  
x = 0–5 (8XC196MD)  
The EPA control (EPAx_CON) registers control the functions of their assigned capture/compare  
channels.  
7
0
x = 0, 2, 4  
x = 1, 3, 5  
TB  
TB  
CE  
CE  
M1  
M1  
M0  
M0  
RE  
WGR  
AD  
ROT  
ROT  
ON/RT  
7
0
RE  
ON/RT  
Bit  
Number  
Bit  
Mnemonic  
Function  
3
RE  
Re-enable  
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
WGR  
AD  
Waveform Generator Reload; A/D Conversion  
The function of this bit depends on the EPA channel.  
For EPA capture/compare channels 0, 2, 4:  
The WGR bit allows you to use the EPA activities to cause the reload  
of new values in the waveform generator.  
0 = no action  
1 = enables waveform generator reload  
For EPA capture/compare channels 1, 3, 5:  
The AD bit allows you to use the EPA activities to start an A/D  
conversion that has been previously set up in the A/D control  
registers.  
0 = causes no A/D action  
1 = starts an A/D conversion on an output compare  
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.  
C-19  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
EPAx_CON  
Address:  
Reset State:  
Table C-4  
EPAx_CON (Continued)  
x = 0–1 (8XC196MH)  
x = 0–3 (8XC196MC)  
x = 0–5 (8XC196MD)  
The EPA control (EPAx_CON) registers control the functions of their assigned capture/compare  
channels.  
7
0
x = 0, 2, 4  
x = 1, 3, 5  
TB  
TB  
CE  
CE  
M1  
M1  
M0  
M0  
RE  
WGR  
AD  
ROT  
ROT  
ON/RT  
7
0
RE  
ON/RT  
Bit  
Number  
Bit  
Mnemonic  
Function  
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  
Table C-4. EPAx_CON Addresses and Reset Values  
Register  
Address  
Reset Value  
EPA0_CON (8XC196Mx)  
EPA1_CON (8XC196Mx)  
EPA2_CON (8XC196MC, MD)  
EPA3_CON (8XC196MC, MD)  
EPA4_CON (8XC196MD)  
EPA5_CON (8XC196MD)  
1F40H  
1F44H  
1F48H  
1F4CH  
1F50H  
1F54H  
00H  
00H  
00H  
00H  
00H  
00H  
C-20  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
EPAx_TIME  
Address:  
Reset State:  
Table C-5  
EPAx_TIME  
x = 0–1 (8XC196MH)  
x = 0–3 (8XC196MC)  
x = 0–5 (8XC196MD)  
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.  
15  
0
EPA Timer Value  
Bit  
Number  
Function  
15:0  
EPA Timer 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.  
Table C-5. EPAx_TIME Addresses and Reset Values  
Register  
Address  
Reset Value  
EPA0_TIME (8XC196Mx)  
EPA1_TIME (8XC196Mx)  
EPA2_TIME (8XC196MC, MD)  
EPA3_TIME (8XC196MC, MD)  
EPA4_TIME (8XC196MD)  
EPA5_TIME (8XC196MD)  
1F42H  
1F46H  
1F4AH  
1F4EH  
1F52H  
1F56H  
XXXXH  
XXXXH  
XXXXH  
XXXXH  
XXXXH  
XX00H  
C-21  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
FREQ_CNT  
Address:  
Reset State:  
1FBAH  
00H  
FREQ_CNT  
(8XC196MD)  
Read the frequency generator count (FREQ_CNT) register to determine the current value of the  
down-counter.  
7
0
8XC196MD  
Count  
Bit  
Number  
Function  
7:0  
Count  
This register contains the current down-counter value.  
C-22  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
FREQ_GEN  
Address:  
Reset State:  
1FB8H  
00H  
FREQ_GEN  
(8XC196MD)  
The frequency (FREQ_GEN) register holds a programmed value that specifies the output frequency.  
This value is reloaded into the down-counter each time the counter reaches 0.  
7
0
8XC196MD  
Output Frequency  
Bit  
Number  
Function  
7:0  
Output Frequency  
Use the following formula to calculate the FREQ value for the desired output frequency  
and write this value to the frequency register.  
FXTAL1  
--------------------------------------------  
FREQ =  
1  
16 ×  
FREQ_OUT  
where:  
FREQ  
FXTAL1  
FREQ_OUT  
=
=
=
8-bit value to load into FREQ_GEN register  
input frequency on XTAL1 pin, in MHz  
output frequency on FREQOUT pin, in MHz  
C-23  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
GEN_CON  
Address:  
Reset State:  
1FA0H  
00H  
GEN_CON  
(8XC196MH)  
The GEN_CON register controls whether an internal reset asserts the external RESET# signal and  
indicates the source of the most recent reset.  
7
0
8XC196MH  
RSTS  
DR0  
Bit  
Number  
Bit  
Mnemonic  
Function  
7
RSTS  
Reset source (read-only status bit)  
0 = external reset (RESET# pin asserted)  
1 = internal reset (watchdog overflow, illegal IDLPD key, or RST  
instruction)  
6:1  
0
Reserved; for compatibility with future devices, write zeros to these bits.  
DRO  
Disable RESET# out  
0 = an internal reset asserts the RESET# pin.  
1 = an internal reset has no effect on the RESET# pin; the RESET# pin is  
pulled high (inactive).  
C-24  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
INT_MASK  
Address:  
Reset State:  
0008H  
00H  
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). PUSHF or PUSHA saves the contents of this register  
onto the stack and then clears this register. Interrupt calls cannot occur immediately following this  
instruction. POPF or POPA restores it.  
7
0
MC, MD  
MH  
COMP2  
EPA2  
COMP1  
EPA1  
EPA1  
COMP0  
COMP0  
EPA0  
EPA0  
AD  
AD  
OVRTM  
7
0
COMP3 COMP2 COMP1  
OVRTM  
Bit  
Number  
Function  
7:0  
Setting a bit enables the corresponding interrupt.  
The standard interrupt vector locations are as follows:  
Bit Mnemonic  
COMP2 (MC, MD) EPA Compare-only Channel 2  
Interrupt  
Standard Vector  
200EH  
COMP3 (MH)  
EPA2 (MC, MD)  
COMP2 (MH)  
COMP1  
EPA Compare-only Channel 3  
EPA Capture/Compare Channel 2  
EPA Compare Channel 2  
200EH  
200CH  
200EH  
EPA Compare Channel 1  
200AH  
EPA1  
EPA Capture/Compare Channel 1  
2008H  
COMP0  
EPA Compare Channel 0  
2006H  
EPA0  
AD  
OVRTM†  
EPA Capture/Compare Channel 0  
A/D Conversion Complete  
Overflow/Underflow Timer  
2004H  
2002H  
2000H  
Both timer 1 and timer 2 can generate the multiplexed overflow/underflow interrupt. Write  
to PI_MASK to enable the interrupt sources; read PI_PEND to determine which source  
caused the interrupt.  
C-25  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
INT_MASK1  
Address:  
Reset State:  
0013H  
00H  
INT_MASK1  
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
7
7
0
8XC196MC  
8XC196MD  
8XC196MH  
NMI  
NMI  
NMI  
EXTINT  
EXTINT  
EXTINT  
PI  
PI  
COMP4  
RI1  
COMP3  
COMP3  
TI1  
EPA3  
EPA3  
TI0  
0
0
EPA5  
SPI  
EPA4  
RI0  
WG  
Bit  
Number  
Function  
7:0†  
Setting a bit enables the corresponding interrupt.  
The standard interrupt vector locations are as follows:  
Bit Mnemonic  
NMI  
EXTINT  
PI (MC, MD)††  
WG (MH)  
EPA5 (MD)  
SPI (MH)†††  
COMP4 (MD)  
RI1 (MH)  
Interrupt  
Nonmaskable Interrupt  
EXTINT pin  
Multiplexed Peripheral Interrupt  
Waveform Generator  
EPA Capture/Compare Channel 5  
Serial Port  
EPA Compare Channel 4  
SIO 1 Receive  
Standard Vector  
203EH  
203CH  
203AH  
203AH  
2038H  
2038H  
2036H  
2036H  
EPA4 (MD)  
RI0 (MH)  
EPA Capture/Compare Channel 4  
SIO 0 Receive  
2034H  
2034H  
COMP3 (MC, MD) EPA Compare Channel 3  
2032H  
TI1 (MH)  
SIO 1 Transmit  
2032H  
EPA3 (MC, MD)  
TI0 (MH)  
EPA Capture/Compare Channel 3  
SIO 0 Transmit  
2030H  
2030H  
††  
The waveform generator and the EPA compare-only channel 5 can generate this  
interrupt. Write to PI_MASK to enable the interrupt sources; read PI_PEND to  
determine which source caused the interrupt.  
††† SIO 0 and SIO 1 can generate this interrupt. Write to PI_MASK to enable the interrupt  
sources; read PI_PEND to determine which source caused the interrupt.  
On the 8XC196MC device bits 4–3 are reserved. For compatibility with future devices, write zeros to  
these bits.  
C-26  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
INT_PEND  
Address:  
Reset State:  
0009H  
00H  
INT_PEND  
When hardware detects an interrupt request, 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
MC, MD  
MH  
COMP2  
EPA2  
COMP1  
EPA1  
EPA1  
COMP0  
COMP0  
EPA0  
EPA0  
AD  
AD  
OVRTM  
7
0
COMP3 COMP2 COMP1  
OVRTM  
Bit  
Number  
Function  
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  
COMP2 (MC, MD) EPA Compare Channel 2  
Interrupt  
Standard Vector  
200EH  
COMP3 (MH)  
EPA2 (MC, MD)  
COMP2 (MH)  
COMP1  
EPA Compare Channel 3  
EPA Capture/Compare Channel 2  
EPA Compare Channel 2  
EPA Compare Channel 1  
200EH  
200CH  
200EH  
200AH  
EPA1  
COMP0  
EPA Capture/Compare Channel 1  
EPA Compare Channel 0  
2008H  
2006H  
EPA0  
AD  
OVRTM†  
EPA Capture/Compare Channel 0  
A/D Conversion Complete  
Overflow/Underflow Timer  
2004H  
2002H  
2000H  
Timer 1 and timer 2 can generate the multiplexed overflow/underflow interrupt. Write to  
PI_MASK to enable the interrupt sources; read PI_PEND to determine which source  
caused the interrupt.  
C-27  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
INT_PEND1  
Address:  
Reset State:  
0012H  
00H  
INT_PEND1  
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
7
7
0
8XC196MC  
8XC196MD  
8XC196MH  
NMI  
NMI  
NMI  
EXTINT  
EXTINT  
EXTINT  
PI  
PI  
COMP4  
RI1  
COMP3  
COMP3  
TI1  
EPA3  
EPA3  
TI0  
0
0
EPA5  
SPI  
EPA4  
RI0  
WG  
Bit  
Number  
Function  
7:0†  
Setting a bit enables the corresponding interrupt.  
The standard interrupt vector locations are as follows:  
Bit Mnemonic  
NMI  
EXTINT  
PI (MC, MD)††  
WG (MH)  
EPA5 (MD)  
SPI (MH)†††  
COMP4 (MD)  
RI1 (MH)  
Interrupt  
Nonmaskable Interrupt  
EXTINT pin  
Multiplexed Peripheral Interrupt  
Waveform Generator  
EPA Capture/Compare Channel 5  
Serial Port  
EPA Compare Channel 4  
SIO 1 Receive  
Standard Vector  
203EH  
203CH  
203AH  
203AH  
2038H  
2038H  
2036H  
2036H  
EPA4 (MD)  
RI0 (MH)  
EPA Capture/Compare Channel 4  
SIO 0 Receive  
2034H  
2034H  
COMP3 (MC, MD) EPA Compare Channel 3  
2032H  
TI1 (MH)  
SIO 1 Transmit  
2032H  
EPA3 (MC, MD)  
EPA Capture/Compare Channel 3  
2030H  
TI0 (MH)  
SIO 0 Transmit  
2030H  
††  
On the 8XC196MD, the waveform generator and the EPA compare channel 5 can  
generate this interrupt. Write to PI_MASK to enable the interrupt sources; read  
PI_PEND to determine which source caused the interrupt. On the 8XC196MC, the  
waveform generator is the sole source for this interrupt.  
††† SIO 0 and SIO 1 can generate this interrupt. Write to PI_MASK to enable the interrupt  
sources; read PI_PEND to determine which source caused the interrupt.  
On the 8XC196MC device bits 4–3 are reserved. These bits are undefined.  
C-28  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
ONES_REG  
Address:  
Reset State:  
02H  
FFFFH  
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  
Bit  
Number  
Function  
15:0  
One  
These bits are always equal to FFFFH.  
C-29  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Px_DIR  
Address:  
Reset State:  
Table C-6  
Px_DIR  
x = 2, 5 (8XC196MC)  
x = 2, 5, 7 (8XC196MD)  
x = 1, 2, 5 (8XC196MH)  
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.  
7
7
7
0
x = 1 (MH)  
x = 2, 5 (Mx)  
x = 7 (MD)  
PIN3  
PIN3  
PIN3  
PIN2  
PIN2  
PIN2  
PIN1  
PIN1  
PIN1  
PIN0  
PIN0  
PIN0  
0
0
PIN7  
PIN7  
PIN6  
PIN6  
PIN5  
PIN5  
PIN4  
PIN4  
Bit  
Number  
Bit  
Mnemonic  
Function  
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.  
The bits shown as dashes (—) are reserved; for compatibility with future devices, write ones to these  
bits.  
Table C-6. Px_DIR Addresses and Reset Values  
Register  
Address  
Reset Value  
P1_DIR (8XC196MH)  
P2_DIR (8XC196Mx)  
P5_DIR (8XC196Mx)  
P7_DIR (8XC196MD)  
1F9BH  
1FD2H  
1FF3H  
1FD3H  
FFH  
FFH  
FFH  
FFH  
C-30  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
Px_MODE  
Address:  
Reset State:  
Table C-7  
Px_MODE  
x = 2, 5 (8XC196MC)  
x = 2, 5, 7 (8XC196MD)  
x = 1, 2, 5 (8XC196MH)  
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.  
7
0
x = 1 (MH)  
x = 2, 5 (Mx)  
x = 7 (MD)  
PIN3  
PIN3  
PIN3  
PIN2  
PIN2  
PIN2  
PIN1  
PIN1  
PIN1  
PIN0  
PIN0  
PIN0  
7
0
0
PIN7  
PIN6  
PIN6  
PIN5  
PIN5  
PIN4  
PIN4  
7
PIN7  
Bit  
Number  
Bit  
Mnemonic  
Function  
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-8 lists the special-function signals for each pin.  
The bits shown as dashes (—) are reserved; for compatibility with future devices, write zeros to these  
bits.  
Table C-7. Px_MODE Addresses and Reset Values  
Register  
Address  
Reset Value  
P1_MODE (8XC196MH)  
P2_MODE (8XC196Mx)  
1F99H  
1FD0H  
00H  
00H  
P5_MODE (8XC196MC, MD)  
P5_MODE (8XC196MH)  
1FF1H  
1FF1H  
FFH when pin is not driven  
80H if the EA# pin is high, A9H if EA# is low  
P7_MODE (8XC196MD)  
1FD1H  
00H  
C-31  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Px_MODE  
Table C-8. Special-function Signals for Ports 1, 2, 5, 6  
Port 1  
Port 2  
Port 2  
(8XC196MH)  
(8XC196MC, MD)  
(8XC196MH)  
Special-function  
Signal  
Special-function  
Special-function  
Signal  
Pin  
P1.0  
Pin  
P2.0  
Pin  
P2.0  
Signal  
TXD0  
RXD0  
TXD1  
RXD1  
EPA0/PVER  
EPA1/PALE#  
EPA2/PROG#  
EPA3  
EPA0/PVER  
P1.1  
P1.2  
P1.3  
P2.1  
P2.2  
P2.3  
P2.4  
P2.5  
P2.6  
P2.7  
P2.1  
P2.2  
P2.3  
P2.4  
P2.5  
P2.6  
P2.7  
SCLK0#/BCLK0/PALE#  
EPA1/PROG#  
COMP3  
COMP0/AINC#  
COMP1/PACT#  
COMP2/CPVER  
COMP3  
COMP0/AINC#  
COMP1/PACT#  
COMP2/CPVER  
SCLK1#BCLK1  
Port 5  
Port 7  
(8XC196Mx)  
(8XC196MD)  
Special-function  
Signal  
Special-function  
Signal  
Pin  
Pin  
P5.0  
P5.1  
P5.2  
P5.3  
P5.4  
P5.5  
P5.6  
P5.7  
ALE/ADV#  
INST  
P7.0  
P7.1  
P7.2  
P7.3  
P7.4  
P7.5  
P7.6  
P7.7  
EPA4  
EPA5  
COMP4  
COMP5  
WR#/WRL#  
RD#  
ONCE#  
BHE#/WRH#  
READY  
BUSWIDTH  
FREQOUT  
C-32  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
Px_PIN  
Address:  
Reset State:  
Table C-9  
Px_PIN  
x = 0–5 (8XC196MC, MH)  
x = 0–5, 7 (8XC196MD)  
Each bit of the port x pin input (Px_PIN) register reflects the current state of the corresponding pin,  
regardless of the pin configuration.  
7
0
0
0
0
x = 1 (MC)  
PIN4  
PIN3  
PIN3  
PIN3  
PIN3  
PIN2  
PIN2  
PIN2  
PIN2  
PIN1  
PIN1  
PIN1  
PIN1  
PIN0  
PIN0  
PIN0  
PIN0  
7
7
7
x = 1 (MH)  
x = 1, 7 (MD)  
x = 0, 2–5 (Mx)  
PIN7  
PIN7  
PIN6  
PIN6  
PIN5  
PIN5  
PIN4  
PIN4  
Bit  
Mnemonic  
Bit Number  
Function  
7:0†  
PIN7:0  
Port x Pin y Input Value  
This bit contains the current state of Px.y.  
The bits shown as dashes (—) are reserved; their values are undefined.  
Table C-9. Px_PIN Addresses and Reset Values  
Register  
Address  
Reset Value  
P0_PIN (8XC196MC, MD)  
P0_PIN (8XC196MH)  
1FA8H  
1FDAH  
FFH when pin is not driven  
FFH when pin is not driven  
P1_PIN (8XC196MC, MD)  
P1_PIN (8XC196MH)  
1FA9H  
1F9FH  
P2_PIN (8XC196Mx)  
P3_PIN (8XC196Mx)  
P4_PIN (8XC196Mx)  
1FD6H  
1FFEH  
1FFFH  
FFH when pin is not driven  
FFH when pin is not driven  
FFH when pin is not driven  
P5_PIN (8XC196MC, MD)  
P5_PIN (8XC196MH)  
1FF7H  
1FF7H  
FFH  
FFH when pin is not driven  
P7_PIN (8XC196MD)  
1FD7H  
XXH  
C-33  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
Px_REG  
Address: Table C-10  
Reset State:  
Px_REG  
x = 2–5 (8XC196MC)  
x = 2–5, 7 (8XC196MD)  
x = 1–5 (8XC196MH)  
For an input, set the corresponding port x data output (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.  
7
7
7
0
x = 1 (MH)  
x = 2–5 (Mx)  
x = 7 (MD)  
PIN3  
PIN3  
PIN3  
PIN2  
PIN2  
PIN2  
PIN1  
PIN1  
PIN1  
PIN0  
PIN0  
PIN0  
0
0
PIN7  
PIN7  
PIN6  
PIN6  
PIN5  
PIN5  
PIN4  
PIN4  
Bit  
Mnemonic  
Bit Number  
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.  
The bits shown as dashes (—) are reserved; for compatibility with future devices, write zeros to  
these bits.  
Table C-10. Px_REG Addresses and Reset Values  
Register  
Address  
Reset Value  
P1_REG (8XC196MH)  
P2_REG (8XC196Mx)  
P3_REG (8XC196Mx)  
P4_REG (8XC196Mx)  
1F9DH  
1FD4H  
1FFCH  
1FFDH  
FFH  
FFH  
FFH  
FFH  
P5_REG (8XC196MC, MD)  
P5_REG (8XC196MH)  
1FF5H  
1FF5H  
FFH when pin is not driven  
FFH  
P7_REG (8XC196MD)  
1FD5H  
FFH  
C-34  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
PI_MASK  
Address:  
Reset State:  
1FBCH  
AAH  
PI_MASK  
The peripheral interrupt mask (PI_MASK) register enables or disables (masks) interrupt requests  
associated with the peripheral interrupt (PI), the serial port interrupt (SPI), and the overflow/underflow  
timer interrupt (OVRTM).  
7
7
7
0
WG  
WG  
SP0  
OVRTM2  
OVRTM2  
OVRTM2  
OVRTM1  
8XC196MC  
8XC196MD  
8XC196MH  
0
COMP5  
SP1  
OVRTM1  
0
OVRTM1  
Bit  
Number  
Bit  
Mnemonic  
Function  
7, 5, 3, 1  
6
Reserved; for compatibility with future devices, write zeros to these bits.  
Reserved; for compatibility with future devices, write zero to this bit.  
— (MC)  
COMP5 (MD) EPA Compare Channel 5  
Setting this bit enables the EPA compare channel 5 interrupt.  
The EPA compare channel 5 and the waveform generator interrupts are  
associated with the peripheral interrupt (PI). Setting INT_MASK1.5  
enables PI.  
SP1 (MH)  
Serial Port 1 Error  
Setting this bit enables the serial port 1 error interrupt.  
The serial port 1 and serial port 0 error interrupts are associated with the  
serial port interrupt (SPI). Setting INT_MASK1.4 enables SPI.  
4
WG (MC, MD) Waveform Generator  
Setting this bit enables the waveform generator interrupt.  
The waveform generator and the EPA compare channel 5 interrupts are  
associated with the peripheral interrupt (PI). Setting INT_MASK1.5  
enables PI.  
SP0 (MH)  
OVRTM2  
Serial Port 0 Error  
Setting this bit enables the serial port 0 error interrupt.  
The serial port 0 and serial port 1 error interrupts are associated with the  
serial port interrupt (SPI). Setting INT_MASK1.4 enables SPI.  
2
Timer 2 Overflow/Underflow  
Setting this bit enables the timer 2 overflow/underflow interrupt.  
The timer 2 and timer 1 overflow/underflow interrupts are associated with  
the overflow/underflow timer interrupt (OVRTM). Setting INT_MASK.0  
enables OVRTM.  
C-35  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
PI_MASK  
Address:  
Reset State:  
1FBCH  
AAH  
PI_MASK (Continued)  
The peripheral interrupt mask (PI_MASK) register enables or disables (masks) interrupt requests  
associated with the peripheral interrupt (PI), the serial port interrupt (SPI), and the overflow/underflow  
timer interrupt (OVRTM).  
7
7
7
0
WG  
WG  
SP0  
OVRTM2  
OVRTM2  
OVRTM2  
OVRTM1  
8XC196MC  
8XC196MD  
8XC196MH  
0
COMP5  
SP1  
OVRTM1  
0
OVRTM1  
Bit  
Number  
Bit  
Mnemonic  
Function  
0
OVRTM1  
Timer 1 Overflow/Underflow  
Setting this bit enables the timer 1 overflow/underflow interrupt.  
The timer 1 and timer 2 overflow/underflow interrupts are associated with  
the overflow/underflow timer interrupt (OVRTM). Setting INT_MASK.0  
enables OVRTM.  
C-36  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
PI_PEND  
Address:  
Reset State:  
1FBEH  
AAH  
PI_PEND  
When hardware detects a pending peripheral or timer interrupt, it sets the corresponding bit in the  
interrupt pending (INT_PEND or INT_PEND1) registers and the peripheral interrupt pending  
(PI_PEND) register. When the vector is taken, the hardware clears the INT_PEND/INT_PEND1  
pending bit. Reading this register clears all the PI_PEND bits. Software can generate an interrupt by  
setting a PI_PEND bit.  
7
0
WG  
WG  
SP0  
OVRTM2  
OVRTM2  
OVRTM2  
OVRTM1  
8XC196MC  
8XC196MD  
8XC196MH  
7
7
0
COMP5  
SP1  
OVRTM1  
0
OVRTM1  
Bit  
Number  
Bit  
Mnemonic  
Function  
7, 5, 3, 1  
6
Reserved. These bits are undefined.  
Reserved. This bit is undefined.  
— (MC)  
COMP5 (MD) EPA Compare Channel 5  
When set, this bit indicates a pending EPA compare channel 5 interrupt.  
The EPA compare channel 5 and the waveform generator interrupts are  
associated with the peripheral interrupt (PI). Setting INT_MASK1.5  
enables PI. Setting PI_MASK.6 enables COMP5.  
SP1 (MH)  
Serial Port 1 Error  
When set, this bit indicates a pending serial port 1 error interrupt.  
The serial port 1 and 0 error interrupts are associated with the serial port  
interrupt (SPI). Setting INT_MASK1.4 enables SPI. Setting PI_MASK.6  
enables SP1.  
4
WG (MC, MD) Waveform Generator  
When set, this bit indicates a pending waveform generator interrupt.  
The waveform generator and the EPA compare channel 5 interrupts are  
associated with the peripheral interrupt (PI). Setting INT_MASK1.5  
enables PI. Setting PI_MASK.5 enables WG.  
SP0 (MH)  
OVRTM2  
Serial Port 0 Error  
When set, this bit indicates a pending serial port 0 error interrupt.  
The serial port 0 and 1 error interrupts are associated with the serial port  
interrupt (SPI). Setting INT_MASK1.4 enables SPI. Setting PI_MASK.4  
enables SP0.  
2
Timer 2 Overflow/Underflow  
When set, this bit indicates a pending timer 2 overflow/underflow interrupt.  
The timer 2 and timer 1 overflow/underflow interrupts are associated with  
the overflow/underflow timer interrupt (OVRTM). Setting INT_MASK.0  
enables OVRTM. Setting PI_MASK.2 enables OVRTM2.  
C-37  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
PI_PEND  
Address:  
Reset State:  
1FBEH  
AAH  
PI_PEND (Continued)  
When hardware detects a pending peripheral or timer interrupt, it sets the corresponding bit in the  
interrupt pending (INT_PEND or INT_PEND1) registers and the peripheral interrupt pending  
(PI_PEND) register. When the vector is taken, the hardware clears the INT_PEND/INT_PEND1  
pending bit. Reading this register clears all the PI_PEND bits. Software can generate an interrupt by  
setting a PI_PEND bit.  
7
0
WG  
WG  
SP0  
OVRTM2  
OVRTM2  
OVRTM2  
OVRTM1  
8XC196MC  
8XC196MD  
8XC196MH  
7
7
0
COMP5  
SP1  
OVRTM1  
0
OVRTM1  
Bit  
Number  
Bit  
Mnemonic  
Function  
0
OVRTM1  
Timer 1 Overflow/Underflow  
When set, this bit indicates a pending timer 1 overflow/underflow interrupt.  
The timer 1 and timer 2 overflow/underflow interrupts are associated with  
the overflow/underflow timer interrupt (OVRTM). Setting INT_MASK.0  
enables OVRTM. Setting PI_MASK.0 enables OVRTM1.  
C-38  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
PPW  
no direct access  
PPW  
The programming pulse width (PPW) register is loaded from the external EPROM (locations 14H and  
15H for the 8XC196MC and MD; locations 4014H and 4015H for the 8XC196MH) in auto programming  
mode. The PPW_VALUE determines the programming pulse width.  
15  
PPW15  
8
PPW14  
PPW6  
PPW13  
PPW5  
PPW12  
PPW4  
PPW11  
PPW3  
PPW10  
PPW2  
PPW9  
PPW1  
PPW8  
PPW0  
7
0
PPW7  
Bit  
Bit  
Function  
Number Mnemonic  
15:0 PPW15:0  
PPW_VALUE  
This value establishes the programming pulse width for auto programming.  
Use the appropriate formula to calculate the PPW_VALUE, then write the  
result to the PPW register.  
PPW_VALUE for 8XC196MC, MD = 62.5 ×FXTAL1  
PPW_VALUE for 8XC196MH  
= 25 ×FXTAL1  
C-39  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
PSW  
no direct access  
PSW  
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.  
15  
8
Z
N
V
VT  
C
PSE  
I
ST  
7
0
See INT_MASK on page C-25  
Bit  
Number  
Bit  
Mnemonic  
Function  
15  
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.  
14  
13  
N
V
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.  
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 3,  
“Programming Considerations,” defines the operands and possible  
values for each. See the PSW flag descriptions in Appendix A for  
details.)  
C-40  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
PSW  
no direct access  
PSW (Continued)  
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.  
15  
8
Z
N
V
VT  
C
PSE  
I
ST  
7
0
See INT_MASK on page C-25  
Bit  
Number  
Bit  
Mnemonic  
Function  
12  
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.  
11  
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.)  
10  
9
PSE  
PTS Enable  
This bit globally enables or disables the peripheral transaction server  
(PTS). The EPTS instruction sets this bit; DPTS clears it.  
0 = disable PTS  
1 = enable PTS  
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.  
0 = disable interrupt servicing  
1 = enable interrupt servicing  
8
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.  
C-41  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
PTSSEL  
Address:  
Reset State:  
0004H  
0000H  
PTSSEL  
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.  
15  
8
0
8XC196MC  
8XC196MD  
8XC196MH  
EXTINT  
EPA2  
PI  
COMP3  
AD  
EPA3  
7
COMP2  
COMP1  
EPA1  
COMP0  
EPA0  
OVRTM  
15  
8
7
EXTINT  
EPA2  
PI  
EPA5  
EPA1  
COMP4  
COMP0  
EPA4  
EPA0  
COMP3  
AD  
EPA3  
0
COMP2  
COMP1  
OVRTM  
15  
7
8
EXTINT  
WG  
SPI  
RI1  
RI0  
TI1  
AD  
TI0  
0
COMP3 COMP2 COMP1  
EPA1  
COMP0  
EPA0  
OVRTM  
Bit  
Number  
Function  
Reserved; for compatibility with future devices, write zero to this bit.  
15  
14: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  
EXTINT  
PTS Vector  
205CH  
205AH  
205AH  
2058H  
2058H  
2056H  
2056H  
2054H  
2054H  
Bit Mnemonic  
TI0 (MH)  
PTS Vector  
2050H  
204EH  
204EH  
204CH  
204CH  
204AH  
2048H  
2046H  
2044H  
2042H  
2040H  
PI (MC, MD)††  
WG (MH)  
COMP2 (MC,MD)  
COMP3 (MH)  
EPA2 (MC, MD)  
COMP2 (MH)  
COMP1  
EPA1  
COMP0  
EPA0  
AD  
OVRTM††  
EPA5 (MD)  
SPI (MH)††  
COMP4 (MD)  
RI1 (MH)  
EPA4 (MD)  
RI0 (MH)  
COMP3 (MC, MD) 2052H  
TI1 (MH)  
EPA3 (MC, MD)  
2052H  
2050H  
††  
PTS service is not useful for multiplexed interrupts because the PTS cannot readily  
determine the source of these interrupts.  
On the 8XC196MC device bits 10–12 are reserved. For compatibility with future devices, write zeros  
to these bits.  
C-42  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
PTSSRV  
Address:  
Reset State:  
0006H  
0000H  
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.  
15  
8
8XC196MC  
8XC196MD  
8XC196MH  
EXTINT  
EPA2  
PI  
COMP3  
AD  
EPA3  
7
0
COMP2  
COMP1  
EPA1  
COMP0  
EPA0  
OVRTM  
15  
8
7
EXTINT  
EPA2  
PI  
EPA5  
EPA1  
COMP4  
COMP0  
EPA4  
EPA0  
COMP3  
AD  
EPA3  
0
COMP2  
COMP1  
OVRTM  
15  
7
8
EXTINT  
WG  
SPI  
RI1  
RI0  
TI1  
AD  
TI0  
0
COMP3 COMP2 COMP1  
EPA1  
COMP0  
EPA0  
OVRTM  
Bit  
Number  
Function  
15  
Reserved. This bit is undefined.  
14:0†  
A bit is set by hardware to request an end-of-PTS interrupt for the corresponding interrupt  
through its standard interrupt vector.  
The PTS interrupt vector locations are as follows:  
Bit Mnemonic  
EXTINT  
PTS Vector  
205CH  
205AH  
205AH  
2058H  
2058H  
2056H  
2056H  
2054H  
2054H  
Bit Mnemonic  
TI0 (MH)  
PTS Vector  
2050H  
204EH  
204EH  
204CH  
204CH  
204AH  
2048H  
2046H  
2044H  
2042H  
2040H  
PI (MC, MD)††  
WG (MH)  
COMP2 (MC,MD)  
COMP3 (MH)  
EPA2 (MC, MD)  
COMP2 (MH)  
COMP1  
EPA1  
COMP0  
EPA0  
AD  
OVRTM††  
EPA5 (MD)  
SPI (MH)††  
COMP4 (MD)  
RI1 (MH)  
EPA4 (MD)  
RI0 (MH)  
COMP3 (MC, MD) 2052H  
TI1 (MH)  
EPA3 (MC, MD)  
2052H  
2050H  
††  
PTS service is not useful for multiplexed interrupts because the PTS cannot readily  
determine the source of these interrupts.  
On the 8XC196MC device bits 10–12 are reserved. These bits are undefined.  
C-43  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
PWM_COUNT  
Address:  
Reset State:  
1FB6H  
00H  
PWM_COUNT  
(read only)  
The PWM count (PWM_COUNT) register provides the current value of the decremented period  
counter.  
7
0
PWM Count Value  
Bit  
Number  
Function  
7:0  
PWM Count Value  
This register contains the current value of the decremented period counter.  
C-44  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
PWM_PERIOD  
Address:  
Reset State:  
1FB4H  
00H  
PWM_PERIOD  
The PWM period (PWM_PERIOD) register controls the period of the PWM outputs. It contains a value  
that determines the number of state counts necessary for incrementing the PWM counter. The value  
of PWM_PERIOD is loaded into the PWM period count register whenever the count equals zero.  
7
0
PWM Period  
Bit  
Number  
Function  
7:0  
PWM Period  
This register controls the period of the PWM outputs. The value of PWM_PERIOD is  
loaded into the PWM period count register whenever the count equals zero.  
C-45  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
PWMx_CONTROL  
Address:  
Reset State:  
1FB0H, 1FB2H  
00H  
PWMx_CONTROL  
x = 0–1  
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  
Bit  
Number  
Function  
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).  
C-46  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
SBUFx_RX  
Address: 1F80H, 1F88H  
SBUFx_RX  
x = 0–1 (8XC196MH)  
Reset State:  
00H  
The serial port receive buffer x (SBUFx_RX) register contains data received from serial port x. 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 SBUFx_RX. If data in the shift register is loaded into SBUFx_RX before the previous byte is read,  
the overflow error bit is set (SPx_STATUS.2). The data in SBUFx_RX will always be the last byte  
received, never a combination of the last two bytes.  
7
0
8XC196MH  
Data Received  
Bit  
Number  
Function  
7:0  
Data Received  
This register contains the last byte of data received from the serial port.  
C-47  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
SBUFx_TX  
Address:  
Reset State:  
1F82H, 1F8AH  
00H  
SBUFx_TX  
x = 0–1 (8XC196MH)  
The serial port transmit buffer x (SBUFx_TX) register contains data that is ready for transmission. In  
modes 1, 2, and 3, writing to SBUFx_TX starts a transmission. In mode 0, writing to SBUFx_TX starts  
a transmission only if the receiver is disabled (SPx_CON.3=0).  
7
0
8XC196MH  
Data to Transmit  
Bit  
Number  
Function  
7:0  
Data to Transmit  
This register contains a byte of data to be transmitted by the serial port.  
C-48  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
SP  
Address:  
Reset State:  
18H  
XXXXH  
SP  
The system’s stack pointer (SP) can point anywhere in internal or external memory; 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.  
15  
0
Stack Pointer  
Bit  
Number  
Function  
15:0  
Stack Pointer  
This register makes up the system’s stack pointer.  
C-49  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
SPx_BAUD  
Address:  
Reset State:  
1F84H, 1F8CH  
0000H  
SPx_BAUD  
x = 0–1 (8XC196MH)  
The serial port baud rate x (SPx_BAUD) register selects the serial port x 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 XTAL1 and 0001H when using BCLKx. In synchronous mode 0,  
the minimum BAUD_VALUE is 0001H for transmissions and 0002H for receptions. In synchronous  
mode 4, the minimum BAUD_VALUE is 0001H for both transmissions and receptions.  
15  
8
0
8XC196MH  
CLKSRC  
BV14  
BV6  
BV13  
BV5  
BV12  
BV4  
BV11  
BV3  
BV10  
BV2  
BV9  
BV1  
BV8  
BV0  
7
BV7  
Bit  
Number  
Bit  
Mnemonic  
Function  
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 = input frequency on the XTAL1 pin (internal source)  
14:0  
BV14:0  
These bits constitute the BAUD_VALUE.  
Use the following equations to determine the BAUD_VALUE for a given  
baud rate.  
Synchronous mode 0:†  
FXTAL1  
BCLKx  
-------------------------------------  
Baud Rate × 2  
---------------------------  
BAUD_VALUE =  
1  
or  
Baud Rate  
Asynchronous modes 1, 2, and 3:  
FXTAL1  
BCLKx  
-------------------------------------  
----------------------------------------  
BAUD_VALUE =  
1 or  
Baud Rate × 8  
Baud Rate × 16  
Synchronous mode 4 (SCLKx# output):  
FXTAL1  
-------------------------------------  
BAUD_VALUE =  
1  
Baud Rate × 4  
For mode 0 receptions, the BAUD_VALUE must be 0002H or greater.  
Otherwise, the resulting data in the receive shift register will be incorrect.  
C-50  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
SPx_CON  
Address:  
Reset State:  
1F83H, 1F8BH  
00H  
SPx_CON  
x = 0–1 (8XC196MH)  
The serial port control (SPx_CON) register selects the communications mode and enables or disables  
the receiver, parity checking, and nine-bit data transmission.  
7
0
8XC196MH  
M2  
DIR  
PAR  
TB8  
REN  
PEN  
M1  
M0  
Bit  
Number  
Bit  
Mnemonic  
Function  
7
6
M2  
See description for bits 0 and 1.  
Synchronous Clock Direction  
DIR  
PAR  
TB8  
This bit determines the direction of the clock during synchronous mode.  
0 = output  
1 = input  
5
4
Parity Selection Bit  
This bit selects even or odd parity.  
0 = even parity  
1 = odd parity  
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 SBUFx_TX is  
written. When parity is enabled (SPx_CON.2 = 1), this bit takes on the  
even parity value.  
3
REN  
Receive Enable  
Setting this bit enables receptions. When this bit is set, a falling edge on  
the RXDx 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. To avoid a partial or undesired reception, clear this bit before  
clearing the RI flag in SPx_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.  
2
PEN  
M1:0  
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 and SPx_STATUS.7 becomes the receive parity  
error bit.  
1:0  
Mode Selection  
These bits along with bit 7 select the communications mode.  
M2  
0
X
M1  
0
0
M0  
0
1
synchronous mode 0  
mode 1  
X
1
0
mode 2  
X
1
1
mode 3  
1
0
0
synchronous mode 4  
C-51  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
SPx_STATUS  
Address:  
Reset State:  
1F81H, 1F89H  
00H  
SPx_STATUS  
x = 0–1 (8XC196MH)  
The serial port status (SPx_STATUS) register contains bits that indicate the status of serial port x.  
7
0
8XC196MH RPE/RB8  
RI  
TI  
FE  
TXE  
OE  
Bit  
Number  
Bit  
Mnemonic  
Function  
7
RPE/RB8  
Received Parity Error/Received Bit 8  
RPE is set if parity is disabled (SPx_CON.2 = 0) and the ninth data bit  
received is high.  
RB8 is set if parity is enabled (SPx_CON.2 = 1) and a parity error occurred.  
Reading SPx_STATUS clears this bit.  
6
RI  
Receive Interrupt  
This bit is set when the last data bit is sampled. Reading SPx_STATUS  
clears this bit.  
5
TI  
Transmit Interrupt  
This bit is set at the beginning of the stop bit transmission. Reading  
SPx_STATUS clears this bit.  
4
FE  
TXE  
OE  
Framing Error  
This bit is set if a stop bit is not found within the appropriate period of time.  
Reading SPx_STATUS clears this bit.  
3
SBUFx_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 SBUFx_TX.  
2
Overrun Error  
This bit is set if data in the receive shift register is loaded into SBUFx_RX  
before the previous bit is read. Reading SPx_STATUS clears this bit.  
1:0  
Reserved; for compatibility with future devices, write zeros to these bits.  
C-52  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
T1CONTROL  
Address:  
Reset State:  
1F78H  
00H  
T1CONTROL  
The timer 1 control (T1CONTROL) register determines the clock source, counting direction, and count  
rate for timer 1.  
7
0
CE  
UD  
M2  
M1  
M0  
P2  
P1  
P0  
Bit  
Number  
Bit  
Mnemonic  
Function  
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  
6
UD  
Up/Down  
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
X
0
0
1
0
0
1
1
1
0
1
0
1
1
F
XTAL1/4  
T1CLK pin†  
XTAL1/4  
T1CLK pin†  
UD bit (T1CONTROL.6)  
UD bit (T1CONTROL.6)  
T1DIR pin  
F
T1DIR pin  
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
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
divide by 1 (disabled)  
divide by 2  
divide by 4  
divide by 8  
divide by 16  
divide by 32  
divide by 64  
enable T1RELOAD  
250 ns  
500 ns  
1 µs  
2 µs  
4 µs  
8 µs  
16 µs  
At 16 MHz. Use the formula on page 11-6 to calculate the resolution  
at other frequencies.  
C-53  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
T1RELOAD  
Address:  
Reset State:  
1F72H  
XXXXH  
T1RELOAD  
The timer 1 reload (T1RELOAD) register contains a reinitialization value for timer 1. The value of  
T1RELOAD is loaded into TIMER1 when timer 1 overflows or underflows and both quadrature  
clocking and the reload function are enabled (i.e., T1CONTROL.5:0 = 1).  
15  
0
Timer 1 Reload Value  
Bit  
Number  
Function  
15:0  
Timer 1 Reload Value  
Write the timer 1 reinitialization value to this register.  
C-54  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
T2CONTROL  
Address:  
Reset State:  
1F7CH  
00H  
T2CONTROL  
The timer 2 control (T2CONTROL) register determines the clock source, counting direction, and count  
rate for timer 2.  
7
0
CE  
UD  
M2  
M1  
M0  
P2  
P1  
P0  
Bit  
Number  
Bit  
Mnemonic  
Function  
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  
6
UD  
Up/Down  
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  
XTAL1/4  
reserved  
reserved  
reserved  
timer 1 overflow  
timer 1 overflow  
reserved  
Direction Source  
0
X
0
0
1
1
1
0
0
1
1
0
1
1
0
1
0
1
0
0
1
F
UD bit (T2CONTROL.6)  
UD bit (T2CONTROL.6)  
same as timer 1  
2:0  
P2:0  
EPA Clock Prescaler Bits  
These bits determine the clock prescaler value.  
P2  
P1  
P0  
Prescaler  
Resolution†  
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
divide by 1 (disabled)  
divide by 2  
divide by 4  
250 ns  
500 ns  
1 µs  
2 µs  
4 µs  
8 µs  
16 µs  
divide by 8  
divide by 16  
divide by 32  
divide by 64  
reserved  
Resolution at 16 MHz. Use the formula on page 11-6 to calculate the  
resolution at other frequencies.  
C-55  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
TIMERx  
Address:  
Reset State:  
1F7AH,  
1F7EH  
0000H  
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.  
15  
0
Timer Value  
Bit  
Number  
Function  
15:0  
Timer Value  
Read the current timer x value from this register or write a new timer x value to this  
register.  
C-56  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
USFR  
Address:  
Reset State (MC, MD):  
Reset State (MH):  
1FF6H  
02H  
XXH  
USFR  
The unerasable PROM (USFR) register contains two bits that disable external fetches of data and  
instructions and another that detects a failed oscillator. These bits can be programmed, but cannot be  
erased.  
WARNING: These bits can be programmed, but can never be erased. Programming these bits makes  
dynamic failure analysis impossible. For this reason, devices with programmed UPROM bits cannot  
be returned to Intel for failure analysis.  
7
0
DEI  
DED  
Bit  
Number  
Bit  
Mnemonic  
Function  
7:4  
Reserved; for compatibility with future devices, write zeros to these bits.  
Disable External Instruction Fetch  
3
DEI  
DED  
Setting this bit prevents the bus controller from executing external  
instruction fetches. Any attempt to load an external address initiates a  
reset.  
2
Disable External Data Fetch  
Setting this bit prevents the bus controller from executing external data  
reads and writes. Any attempt to access data through the bus controller  
initiates a reset.  
1:0  
Reserved; for compatibility with future devices, write zero to these bits.  
C-57  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
WATCHDOG  
Address:  
Reset State:  
0AH  
XXH  
WATCHDOG  
Unless it is cleared every 64K state times, the watchdog timer resets the device. To clear the  
watchdog timer, send “1EH” followed immediately by “E1H” to location 0AH. Clearing this register the  
first time enables the watchdog with an initial value of 0000H, which is incremented once every state  
time. After it is enabled, the watchdog can be disabled only by a reset.  
The WDE bit (bit 3) of CCR1 controls whether the watchdog is enabled immediately or is disabled until  
the first time it is cleared. Clearing WDE activates the watchdog. Setting WDE makes the watchdog  
timer inactive, but you can activate it by clearing the watchdog register. Once the watchdog is  
activated, only a reset can disable it.  
7
0
Watchdog Timer Value  
Bit  
Number  
Function  
7:0  
Watchdog Timer Value  
This register contains the 8 most-significant bits of the current value of the watchdog  
timer.  
C-58  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
WG_COMPx  
Address: 1FC2H,1FC4H,1FC6H  
WG_COMPx  
x = 1–3  
Reset State:  
0000H  
The phase compare (WG_COMPx) register controls the duty cycle of each phase. Write a value to  
each phase compare register to specify the length of time that the associated outputs will remain  
asserted.  
Changing the WG_RELOAD value changes both the carrier period and the duty cycle because the  
outputs remain asserted for a constant length of time, while the counter takes longer to cycle. To  
change the carrier period without changing the duty cycle, you must proportionally change both  
WG_RELOAD and WG_COMPx at the same time, immediately after the interrupt.  
15  
0
Compare  
Bit  
Number  
Function  
15:0  
Compare  
These bits determine the length of time that the associated outputs are asserted.  
Use the following formulas to calculate output assertion time and duty cycle.  
multiplier × WG_COMPx  
----------------------------------------------------------------  
TOUTPUT  
=
FXTAL1  
WG_COMPx  
-------------------------------------  
Duty Cycle =  
× 100%  
WG_RELOAD  
where:  
TOUTPUT  
=
=
=
=
=
total time output is asserted, in µs  
FXTAL1  
input frequency on XTAL1 pin, in MHz  
multiplier  
WG_RELOAD  
WG_COMPx  
4 for center-aligned modes; 2 for edge-aligned modes  
16-bit WG_RELOAD value WG_COMPx  
16-bit WG_COMPx value WG_RELOAD  
C-59  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
WG_CONTROL  
Address:  
Reset State (MC, MD):  
Reset State (MH):  
1FCCH  
00C0H  
8000H  
WG_CONTROL  
The waveform generator control (WG_CONTROL) register controls the operating mode, dead time,  
and count direction, and enables and disables the counter.  
15  
8
0
M2  
M1  
M0  
CS  
EC  
DT9  
DT1  
DT8  
DT0  
7
DT7  
DT6  
DT5  
DT4  
DT3  
DT2  
Bit  
Bit  
Mnemonic  
Function  
Number  
15  
14:12  
Reserved; for compatibility with future devices, write zero to this bit.  
M2:0  
Operating Mode  
This field controls the waveform generator’s operating mode:  
M2  
M1  
M0  
Mode  
0
0
0
0
1
0
0
1
1
1
0
1
0
1
1
0
1
2
3
4
center-aligned; update registers once  
center-aligned; update registers twice  
edge-aligned; update registers once  
edge-aligned; update registers twice  
(8XC196MH only) edge-aligned; update  
WG_COMPx and WG_COUNTER only when  
WG_COUNTER = WG_RELOAD  
11  
CS  
Counter Status  
This read-only bit indicates whether the counter is counting up or  
counting down.  
0 = down counting  
1 = up counting  
10  
EC  
Enable Counter  
This bit starts and stops the counter.  
0 = disable (stop) counter  
1 = enable (start) counter  
9:0  
DT9:0  
Dead-time  
This field specifies the dead-time for all three phases. Use the following  
formula to calculate the appropriate DT_VALUE.  
TDEAD × FXTAL1  
------------------------------------------  
DT_VALUE =  
2
where:  
TDEAD = dead-time, in µs  
XTAL1 = input frequency on XTAL1 pin, in MHz  
F
C-60  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
WG_COUNTER  
Address:  
Reset State (MC, MD):  
Reset State (MH):  
1FCAH  
XXXXH  
0000H  
WG_COUNTER  
You can read the waveform generator counter (WG_COUNTER) register to determine the current  
counter value.  
15  
0
Counter Value  
Bit  
Number  
Function  
15:0  
Counter Value  
This register reflects the current counter value.  
C-61  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
WG_OUTPUT (Port 6)  
Address:  
Reset State:  
1FC0H  
0000H  
WG_OUTPUT (Port 6)  
The port 6 output configuration (WG_OUTPUT) register controls port 6 functions. If you are using port  
6 for general-purpose outputs, write C0H (for active-high outputs) or 00H (for active-low outputs) to  
the high byte of WG_OUTPUT and write the desired pin values to the low byte.  
15  
8
OP1  
D7  
OP0  
D6  
M7  
D4  
M6  
D3  
M5:4  
D2  
M3:2  
D1  
M1:0  
D0  
7
0
D5  
Bit  
Number  
Bit  
Mnemonic  
Function  
15:14  
OP1:0  
Output Polarity  
These bits select the output polarity of the port 6 pins.  
0 = active-low outputs  
1 = active-high outputs  
13  
Reserved; for compatibility with future devices, write zero to this bit.  
Mode  
12:8  
M7:0  
These bits select either the peripheral function or general-purpose  
output function of the port 6 pins. Clear these bits for general-purpose  
output.  
7:0  
D7:0  
Data  
In general-purpose output mode, these bits hold the values to be driven  
out on the pins. Write the desired values to these bits (bits 7:0  
correspond to pins P6.7:0).  
C-62  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
WG_OUTPUT (Waveform Generator)  
Address:  
Reset State:  
1FC0H  
0000H  
WG_OUTPUT (Waveform Generator)  
The waveform generator output configuration (WG_OUTPUT) register controls the configuration of  
the waveform generator and PWM module pins. Both the waveform generator and the PWM module  
share pins with port 6. Having these control bits in a single register enables you to configure all port 6  
pins with a single write to WG_OUTPUT.  
15  
8
OP1  
P7  
OP0  
P6  
SYNC  
PH3.1  
PE7  
PE6  
PH3.2  
PH2.0  
PH2.2  
PH1.1  
PH1.2  
PH1.0  
7
0
PH3.0  
PH2.1  
Bit  
Number  
Bit  
Mnemonic  
Function  
15  
OP1  
Output Polarity  
Selects the output polarity for negative-phase outputs WG1#, WG2#,  
and WG3#.  
0 = active-low outputs  
1 = active-high outputs  
14  
13  
OP0  
Output Polarity  
Selects the output polarity for positive-phase outputs WG1, WG2, and  
WG3.  
0 = active-low outputs  
1 = active-high outputs  
SYNC  
Synchronize  
Selects whether updating the WG_OUTPUT register is synchronized  
with another event or occurs immediately after you change it.  
0 = update WG_OUTPUT immediately  
1 = synchronize WG_OUTPUT update with an event  
To ensure that the outputs are in the desired states when the waveform  
generator starts, you should initially clear this bit, then set it later if you  
want subsequent WG_OUTPUT updates to be synchronized with an  
event. (Table 9-4 on page C-8 lists the events that update WG_OUTPUT  
in each mode.)  
12  
11  
PE7  
PE6  
P6.7/PWM1 Function  
Selects the port function or the PWM output function of P6.7/PWM1.  
0 = P6.7  
1 = PWM1  
P6.6/PWM0 Function  
Selects the port function or the PWM output function of P6.6/PWM0.  
0 = P6.6  
1 = PWM0  
C-63  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
WG_OUTPUT (Waveform Generator)  
Address:  
Reset State:  
1FC0H  
0000H  
WG_OUTPUT (Waveform Generator) (Continued)  
The waveform generator output configuration (WG_OUTPUT) register controls the configuration of  
the waveform generator and PWM module pins. Both the waveform generator and the PWM module  
share pins with port 6. Having these control bits in a single register enables you to configure all port 6  
pins with a single write to WG_OUTPUT.  
15  
8
OP1  
P7  
OP0  
P6  
SYNC  
PH3.1  
PE7  
PE6  
PH3.2  
PH2.0  
PH2.2  
PH1.1  
PH1.2  
PH1.0  
7
0
PH3.0  
PH2.1  
Bit  
Number  
Bit  
Mnemonic  
Function  
10  
PH3.2  
Phase 3 Function  
Selects either the port function or the waveform generator output  
function for pins P6.4/WG3# and P6.5/WG3.  
0 = P6.4, P6.5  
1 = WG3#, WG3  
9
8
PH2.2  
PH1.2  
Phase 2 Function  
Selects either the port function or the waveform generator output  
function for pins P6.2/WG2# and P6.3/WG2.  
0 = P6.2, P6.3  
1 = WG2#, WG2  
Phase 1 Function  
Selects either the port function or the waveform generator output  
function for pins P6.0/WG1# and P6.1/WG1.  
0 = P6.0, P6.1  
1 = WG1#, WG1  
7
P7  
P6.7/PWM1 Value  
Write the desired P6.7/PWM1 value to this bit.  
6
P6  
P6.6/PWM0 Value  
Write the desired P6.6/PWM0 value to this bit.  
5:4  
PH3.1:0  
P6.4/WG3#, P6.5/WG3 Value  
Write the desired output values to these bits. See Table C-11 on page  
C-65.  
3:2  
1:0  
PH2.1:0  
PH1.1:0  
P6.2/WG2#, P6.3/WG2 Values  
Write the desired output values to these bits. See Table C-11 on page  
C-65.  
P6.0/WG1#, P6.1/WG1 Values  
Write the desired output values to these bits. See Table C-11 on page  
C-65.  
C-64  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
WG_OUTPUT (Waveform Generator)  
,
Table C-11. Output Configuration  
Output Values Output Polarities  
PHx.2 PHx.1 PHx.0  
WGx  
WGx#  
WGx  
WGx#  
1
1
0
0
0
1
Low  
Low  
Always Low  
Always Low  
Low  
WG_EVEN#  
Always Low  
1
1
1
1
0
1
WG_ODD  
Low  
Always Low  
WG_ODD WG_EVEN  
NOTE: This table assumes active-high outputs (OP1=OP0=1).  
C-65  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
WG_PROTECT  
Address:  
Reset State (MC, MD)  
Reset State (MH):  
1FCEH  
F0H  
WG_PROTECT  
E0H  
The waveform protection (WG_PROTECT) register enables and disables the outputs and the  
protection circuitry. It also selects either level-sensitive or edge-triggered EXTINT interrupts, and  
selects which level or edge will generate an EXTINT interrupt request.  
7
0
0
8XC196MC, MD  
8XC196MH  
ES  
ES  
IT  
IT  
DP  
DP  
EO  
EO  
7
PT  
Bit  
Number  
Bit  
Mnemonic  
Function  
7:5  
Reserved; for compatibility with future devices, write zeros to these bits.  
6†  
PT  
Protection Type  
This bit selects the method used for disabling the outputs.  
0 = inactive states  
1 = weak pull-ups  
3:2  
ES  
IT  
Enable Sampling and Interrupt Type  
The ES bit selects whether the protection circuitry samples the EXTINT  
signal level or detects a signal transition (edge), while the IT bit controls  
which value of the edge or level triggers an interrupt request. The  
possible combinations are as follows.  
ES  
IT  
Event  
0
0
1
1
0
1
0
1
falling edge  
rising edge  
low level  
high level  
1
DP  
EO  
Disable Protection  
This bit enables and disables the protection circuitry.  
0 = enable protection  
1 = disable protection  
0
Enable Outputs  
This bit enables and disables the outputs.  
0 = disable outputs  
1 = enable outputs  
On the 8XC196MC, MD devices, this bit is reserved. For compatibility with future devices, always  
write as zero.  
C-66  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
WG_RELOAD  
Address:  
Reset State:  
1FC8H  
0000H  
WG_RELOAD  
The waveform generator reload (WG_RELOAD) register and the phase compare registers  
(WG_COMPx) control the carrier period and duty cycle. Write a value to the reload register to  
establish the carrier period.  
Changing the WG_RELOAD value changes both the carrier period and the duty cycle because the  
outputs remain asserted for a constant length of time, while the counter takes longer to cycle. To  
change the carrier period without changing the duty cycle, you must proportionally change both  
WG_RELOAD and WG_COMPx at the same time, immediately after the interrupt.  
15  
0
Reload  
Bit  
Number  
Function  
15:0  
Reload  
This register determines the carrier period.  
Use the following formulas to calculate carrier period and duty cycle.  
multiplier × WG_RELOAD  
--------------------------------------------------------------------  
TCARRIER  
=
FXTAL1  
WG_COMPx  
-------------------------------------  
Duty Cycle =  
× 100%  
WG_RELOAD  
where:  
TCARRIER  
=
=
=
=
=
carrier period, in µs  
FXTAL1  
input frequency on XTAL1 pin, in MHz  
4 for center-aligned modes; 2 for edge-aligned modes  
16-bit WG_RELOAD value WG_COMPx  
16-bit WG_COMPx value WG_RELOAD  
multiplier  
WG_RELOAD  
WG_COMPx  
C-67  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
WSR  
Address:  
Reset State:  
0014H  
00H  
WSR  
The window selection register (WSR) maps 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
0
W6  
W5  
W4  
W3  
W2  
W1  
W0  
Bit  
Bit  
Function  
Number Mnemonic  
7
Reserved; for compatibility with future devices, write zero to this bit.  
Window Selection  
6:0  
W6:0  
These bits specify the window size and number. Table C-12 shows the WSR  
settings and direct addresses for windowable SFRs.  
Table C-12. WSR Settings and Direct Addresses for Windowable SFRs  
32-byte Windows  
(00E0–00FFH)  
64-byte Windows  
(00C0–00FFH)  
128-byte Windows  
(0080–00FFH)  
Memory  
Location  
Register Mnemonic  
Direct  
WSR  
Direct  
WSR  
Direct  
WSR  
Address  
Address  
Address  
AD_COMMAND  
AD_RESULT  
1FACH  
1FAAH  
1FAEH  
1FAFH  
1F58H  
1F5CH  
1F60H  
1F64H  
1F68H  
1F6CH  
1F5AH  
1F5EH  
1F62H  
1F66H  
1F6AH  
1F6EH  
1F40H  
1F44H  
7DH  
7DH  
7DH  
7DH  
7AH  
7AH  
7BH  
7BH  
7BH  
7BH  
7AH  
7AH  
7BH  
7BH  
7BH  
7BH  
7AH  
7AH  
00ECH  
00EAH  
00EEH  
00EFH  
00F8H  
00FCH  
00E0H  
00E4H  
00E8H  
00ECH  
00FAH  
00FEH  
00E2H  
00E6H  
00EAH  
00EEH  
00E0H  
00E4H  
3EH  
3EH  
3EH  
3EH  
3DH  
3DH  
3DH  
3DH  
3DH  
3DH  
3DH  
3DH  
3DH  
3DH  
3DH  
3DH  
3DH  
3DH  
00ECH  
00EAH  
00EEH  
00EFH  
00D8H  
00DCH  
00E0H  
00E4H  
00E8H  
00ECH  
00DAH  
00DEH  
00E2H  
00E6H  
00EAH  
00EEH  
00C0H  
00C4H  
1FH  
1FH  
1FH  
1FH  
1EH  
1EH  
1EH  
1EH  
1EH  
1EH  
1EH  
1EH  
1EH  
1EH  
1EH  
1EH  
1EH  
1EH  
00ACH  
00AAH  
00AEH  
00AFH  
00D8H  
00DCH  
00E0H  
00E4H  
00E8H  
00ECH  
00DAH  
00DEH  
00E2H  
00E6H  
00EAH  
00EEH  
00C0H  
00C4H  
AD_TEST  
AD_TIME  
COMP0_CON  
COMP1_CON  
COMP2_CON  
COMP3_CON  
COMP4_CON (MD)  
COMP5_CON (MD)  
COMP0_TIME†  
COMP1_TIME†  
COMP2_TIME†  
COMP3_TIME†  
COMP4_TIME(MD)  
COMP5_TIME(MD)  
EPA0_CON  
EPA1_CON†  
Must be addressed as a word.  
C-68  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
WSR  
Table C-12. WSR Settings and Direct Addresses for Windowable SFRs (Continued)  
32-byte Windows  
(00E0–00FFH)  
64-byte Windows  
(00C0–00FFH)  
128-byte Windows  
(0080–00FFH)  
Memory  
Location  
Register Mnemonic  
Direct  
WSR  
Direct  
WSR  
Direct  
WSR  
Address  
Address  
Address  
EPA2_CON (MC, MD)  
EPA3_CON(MC, MD)  
EPA4_CON (MD)  
EPA5_CON (MD)  
EPA0_TIME†  
1F48H  
1F4CH  
1F50H  
1F54H  
1F42H  
1F46H  
1F4AH  
1F4EH  
1F52H  
1F56H  
1FBAH  
1FB8H  
1FA0H  
1F9AH  
1FD2H  
1FD3H  
1F98H  
1FD0H  
1FD1H  
1FA8H  
1FDAH  
1FA8H  
1F9EH  
1FD6H  
1FD7H  
1F9CH  
1FD4H  
1FD5H  
1FBCH  
1FBEH  
1FB6H  
1FB4H  
7AH  
7AH  
7AH  
7AH  
7AH  
7AH  
7AH  
7AH  
7AH  
7AH  
7DH  
7DH  
7DH  
7CH  
7EH  
7EH  
7CH  
7EH  
7EH  
7DH  
7EH  
7DH  
7CH  
7EH  
7EH  
7CH  
7EH  
7EH  
7DH  
7DH  
7DH  
7DH  
00E8H  
00ECH  
00F0H  
00F4H  
00E2H  
00E6H  
00EAH  
00EEH  
00F2H  
00F6H  
00FAH  
00FBH  
00E0H  
00FAH  
00F2H  
00F3H  
00F8H  
00F0H  
00F1H  
00E8H  
00FAH  
00E8H  
00FEH  
00F6H  
00F7H  
00FCH  
00F4H  
00F5H  
00FCH  
00FEH  
00F6H  
00F4H  
3DH  
3DH  
3DH  
3DH  
3DH  
3DH  
3DH  
3DH  
3DH  
3DH  
3EH  
3EH  
3EH  
3EH  
3FH  
3FH  
3EH  
3FH  
3FH  
3EH  
3FH  
3EH  
3EH  
3FH  
3FH  
3EH  
3FH  
3FH  
3EH  
3EH  
3EH  
3EH  
00C8H  
00CCH  
00D0H  
00D4H  
00C2H  
00C6H  
00CAH  
00CEH  
00D2H  
00D6H  
00FAH  
00F8H  
00E0H  
00DAH  
00D2H  
00D3H  
00D8H  
00D0H  
00D1H  
00E8H  
00DAH  
00E8H  
00DEH  
00D6H  
00D7H  
00DCH  
00D4H  
00D5H  
00FCH  
00FEH  
00F6H  
00F4H  
1EH  
1EH  
1EH  
1EH  
1EH  
1EH  
1EH  
1EH  
1EH  
1EH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
00C8H  
00CCH  
00D0H  
00D4H  
00C2H  
00C6H  
00CAH  
00CEH  
00D2H  
00D6H  
00BAH  
00B8H  
00A0H  
009AH  
00D2H  
00D3H  
0098H  
00D0H  
00D1H  
00A8H  
00DAH  
00A8H  
009EH  
00D6H  
00D7H  
009CH  
00D4H  
00D5H  
00BCH  
00BEH  
00B6H  
00B4H  
EPA1_TIME†  
EPA2_TIME(MC, MD)  
EPA3_TIME(MC, MD)  
EPA4_TIME(MD)  
EPA5_TIME(MD)  
FREQ_CNT (MD)  
FREQ_GEN (MD)  
GEN_CON (MH)  
P1_DIR (MH)  
P2_DIR  
P7_DIR (MD)  
P1_MODE (MH)  
P2_MODE  
P7_MODE (MD)  
P0_PIN (MC, MD)  
P0_PIN (MH)  
P1_PIN (MC)  
P1_PIN (MH)  
P2_PIN  
P7_PIN (MD)  
P1_REG (MH)  
P2_REG  
P7_REG (MD)  
PI_MASK  
PI_PEND  
PWM_COUNT  
PWM_PERIOD  
Must be addressed as a word.  
C-69  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
WSR  
Table C-12. WSR Settings and Direct Addresses for Windowable SFRs (Continued)  
32-byte Windows  
(00E0–00FFH)  
64-byte Windows  
(00C0–00FFH)  
128-byte Windows  
(0080–00FFH)  
Memory  
Location  
Register Mnemonic  
Direct  
WSR  
Direct  
WSR  
Direct  
WSR  
Address  
Address  
Address  
PWM0_CONTROL  
PWM1_CONTROL  
SBUF0_RX (MH)  
SBUF1_RX (MH)  
SBUF0_TX (MH)  
SBUF1_TX (MH)  
SP0_BAUD (MH)  
SP1_BAUD (MH)  
SP0_CON (MH)  
SP1_CON (MH)  
SP0_STATUS (MH)  
SP1_STATUS (MH)  
T1CONTROL  
1FB0H  
1FB2H  
1F80H  
1F88H  
1F82H  
1F8AH  
1F84H  
1F8CH  
1F83H  
1F8BH  
1F81H  
1F89H  
1F78H  
1F72H  
1F7CH  
1F7AH  
1F7EH  
1FC2H  
1FC4H  
1FC6H  
1FCCH  
1FCAH  
1FC0H  
1FCEH  
1FC8H  
7DH  
7DH  
7CH  
7CH  
7CH  
7CH  
7CH  
7CH  
7CH  
7CH  
7CH  
7CH  
7BH  
7BH  
7BH  
7BH  
7BH  
7EH  
7EH  
7EH  
7EH  
7EH  
7EH  
7EH  
7EH  
00F0H  
00F2H  
00E0H  
00E8H  
00E2H  
00EAH  
00E4H  
00ECH  
00E3H  
00EBH  
00E1H  
00E9H  
00F8H  
00F2H  
00FCH  
00FAH  
00FEH  
00E2H  
00E4H  
00E6H  
00ECH  
00EAH  
00E0H  
00EEH  
00E8H  
3EH  
3EH  
3EH  
3EH  
3EH  
3EH  
3EH  
3EH  
3EH  
3EH  
3EH  
3EH  
3DH  
3DH  
3DH  
3DH  
3DH  
3FH  
3FH  
3FH  
3FH  
3FH  
3FH  
3FH  
3FH  
00F0H  
00F2H  
00C0H  
00C8H  
00C2H  
00CAH  
00C4H  
00CCH  
00C3H  
00CBH  
00C1H  
00C9H  
00F8H  
00F2H  
00FCH  
00FAH  
00FEH  
00C2H  
00C4H  
00C6H  
00CCH  
00CAH  
00C0H  
00CEH  
00C8H  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1EH  
1EH  
1EH  
1EH  
1EH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
1FH  
00B0H  
00B2H  
0080H  
0088H  
0082H  
008AH  
0084H  
008CH  
0083H  
008BH  
0081H  
0089H  
00F8H  
00F2H  
00FCH  
00FAH  
00FEH  
00C2H  
00C4H  
00C6H  
00CCH  
00CAH  
00C0H  
00CEH  
00C8H  
T1RELOAD  
T2CONTROL  
TIMER1†  
TIMER2†  
WG_COMP1  
WG_COMP2  
WG_COMP3  
WG_CONTROL  
WG_COUNTER  
WG_OUTPUT  
WG_PROTECT  
WG_RELOAD  
Must be addressed as a word.  
C-70  
Download from Www.Somanuals.com. All Manuals Search And Download.  
REGISTERS  
ZERO_REG  
Address:  
Reset State:  
00H  
0000H  
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  
Bit  
Number  
Function  
15:0  
Zero  
This register is always equal to zero.  
C-71  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Glossary  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
GLOSSARY  
This glossary defines acronyms, abbreviations, and terms that have special meaning in this man-  
ual. (Chapter 1 discusses notational conventions and general terminology.)  
absolute error  
The maximum difference between corresponding  
actual and ideal code transitions. Absolute error  
accounts for all deviations of an actual A/D converter  
from an ideal converter.  
accumulator  
A register or storage location that forms the result of  
an arithmetic or logical operation.  
actual characteristic  
A graph of output code versus input voltage of an  
actual A/D converter. An actual characteristic may  
vary with temperature, supply voltage, and frequency  
conditions.  
A/D converter  
ALU  
Analog-to-digital converter.  
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.  
attenuation  
bit  
A decrease in amplitude; voltage decay.  
A binary digit.  
BIT  
A single-bit operand that can take on the Boolean  
values, “true” and “false.”  
break-before-make  
The property of a multiplexer which guarantees that a  
previously selected channel is deselected before a  
new channel is selected. (That is, break-before-make  
ensures that the A/D converter will not short inputs  
together.)  
byte  
Any 8-bit unit of data.  
BYTE  
An unsigned, 8-bit variable with values from 0  
through 2 –1.  
8
Glossary-1  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
CCBs  
Chip configuration bytes. The chip configuration  
registers (CCRs) are loaded with the contents of the  
CCBs after a device reset, unless the device is  
entering programming modes, in which case the  
PCCBs are used.  
CCRs  
Chip configuration registers. Registers that specify  
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  
unless the device is entering programming modes, in  
which case the PCCBs are used.  
channel-to-channel matching error  
The difference between corresponding code  
transitions of actual characteristics taken from  
different A/D converter channels under the same  
temperature, voltage, and frequency conditions. This  
error is caused by differences in DC input leakage and  
on-channel resistance from one multiplexer channel  
to another.  
characteristic  
clear  
A graph of output code versus input voltage; the  
transfer function of an A/D converter.  
The “0” value of a bit or the act of giving it a “0”  
value. See also set.  
code  
1) A set of instructions that perform a specific  
function; a program.  
2) The digital value output by the A/D converter.  
code center  
The voltage corresponding to the midpoint between  
two adjacent code transitions on the A/D converter.  
code transition  
The point at which the A/D converter’s output code  
changes from “Q” to “Q+1.” The input voltage corre-  
sponding to a code transition is defined as the voltage  
that is equally likely to produce either of two adjacent  
codes.  
code width  
The voltage change corresponding to the difference  
between two adjacent code transitions. Code width  
deviations cause differential nonlinearity and nonlin-  
earity errors.  
crosstalk  
See off-isolation.  
DC input leakage  
Leakage current from an analog input pin to ground.  
Glossary-2  
Download from Www.Somanuals.com. All Manuals Search And Download.  
GLOSSARY  
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.  
differential nonlinearity  
The difference between the actual code width and the  
ideal one-LSB code width of the terminal-based  
characteristic of an A/D converter. It provides a  
measure of how much the input voltage may have  
changed in order to produce a one-count change in the  
conversion result. Differential nonlinearity is a  
measure of local code-width error; nonlinearity is a  
measure of overall code-transition error.  
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 2 –1.  
32  
EPA  
Event processor array. An integrated peripheral that  
provides high-speed input/output capability.  
EPROM  
ESD  
Erasable, programmable read-only-memory.  
Electrostatic discharge.  
feedthrough  
The attenuation from an input voltage on the selected  
channel to the A/D output after the sample window  
closes. The ability of the A/D converter to reject an  
input on its selected channel after the sample window  
closes.  
FET  
Field-effect transistor.  
frequency generator  
The 8XC196MD peripheral that generates outputs  
with a fixed 50% duty cycle and a programmable  
frequency. The frequency generator can be used for  
infrared transmission.  
Glossary-3  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
full-scale error  
The difference between the ideal and actual input  
voltage corresponding to the final (full-scale) code  
transition of an A/D converter.  
hold latency  
The time it takes the microcontroller to assert HLDA#  
after an external device asserts HOLD#.  
ideal characteristic  
The characteristic of an ideal A/D converter. An ideal  
characteristic is unique: its first code transition occurs  
when the input voltage is 0.5 LSB, its full-scale (final)  
code transition occurs when the input voltage is 1.5  
LSB less than the full-scale reference, and its code  
widths are all exactly 1.0 LSB. These properties result  
in a conversion without zero-offset, full-scale, or  
linearity errors. Quantizing error is the only error  
seen in an ideal A/D converter.  
input leakage  
Current leakage from an input pin to power or ground.  
input series resistance  
The effective series resistance from an analog input  
pin to the sample capacitor of an A/D converter.  
integer  
Any member of the set consisting of the positive and  
negative whole numbers and zero.  
15  
INTEGER  
A 16-bit, signed variable with values from –2  
through +2 –1.  
15  
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  
interrupt vector  
A software routine that you provide to service a  
standard interrupt. See also PTS routine.  
A location in special-purpose memory that holds the  
starting address of an interrupt service routine.  
ISR  
See interrupt service routine.  
linearity errors  
LONG-INTEGER  
See differential nonlinearity and nonlinearity.  
31  
A 32-bit, signed variable with values from –2  
31  
through +2 –1.  
Glossary-4  
Download from Www.Somanuals.com. All Manuals Search And Download.  
GLOSSARY  
LSB  
1) Least-significant bit of a byte or least-significant  
byte of a word.  
2) In an A/D converter, the reference voltage divided  
n
by 2 , where n is the number of bits to be converted.  
For a 10-bit converter with a reference voltage of 5.12  
10  
volts, one LSB is equal to 5.0 millivolts (5.12 ÷ 2 ).  
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.  
monotonic  
The property of successive approximation converters  
which guarantees that increasing input voltages  
produce adjacent codes of increasing value, and that  
decreasing input voltages produce adjacent codes of  
decreasing value. (In other words, a converter is  
monotonic if every code change represents an input  
voltage change in the same direction.) Large differ-  
ential nonlinearity errors can cause the converter to  
exhibit nonmonotonic behavior.  
MSB  
Most-significant bit of a byte or most-significant byte  
of a word.  
n-channel FET  
n-type material  
A field-effect transistor with an n-type conducting  
path (channel).  
Semiconductor material with introduced impurities  
(doping) causing it to have an excess of negatively  
charged carriers.  
no missing codes  
nonlinearity  
An A/D converter has no missing codes if, for every  
output code, there is a unique input voltage range  
which produces that code only. Large differential  
nonlinearity errors can cause the converter to miss  
codes.  
The maximum deviation of code transitions of the  
terminal-based characteristic from the corre-  
sponding code transitions of the ideal characteristic.  
Glossary-5  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
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.  
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  
off-isolation  
OTPROM  
A transistor consisting of one part p-type material and  
two parts n-type material.  
The ability of an A/D converter to reject (isolate) the  
signal on a deselected (off) output.  
One-time-programmable read-only memory. Similar  
to EPROM, but it comes in an unwindowed package  
and cannot be erased.  
p-channel FET  
p-type material  
A field-effect transistor with a p-type conducting  
path.  
Semiconductor material with introduced impurities  
(doping) causing it to have an excess of positively  
charged carriers.  
PC  
Program counter.  
PCCBs  
Programming chip configuration bytes, which are  
loaded into the chip configuration registers (CCRs)  
when the device is entering programming modes;  
otherwise, the CCBs are used.  
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.  
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.  
Glossary-6  
Download from Www.Somanuals.com. All Manuals Search And Download.  
GLOSSARY  
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.  
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  
PTS mode  
Any maskable interrupt that is assigned to the PTS for  
interrupt processing.  
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, managing multiple A/D conver-  
sions, and generating PWM outputs.  
PTS routine  
PTS transfer  
PTS vector  
The entire microcoded response to multiple PTS  
interrupt requests. The PTS routine is controlled by  
the contents of the PTS control block.  
The movement of a single byte or word from the  
source memory location to the destination memory  
location.  
A location in special-purpose memory that holds the  
starting address of a PTS control block.  
Glossary-7  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
PWM  
Pulse-width modulated (outputs). The 8XC196Mx  
devices have several options for producing PWM  
outputs: the generic pulse-width modulator modules,  
the waveform generator, and the EPA with or without  
the PTS. The 8XC196MD also has a frequency  
generator that produces PWM outputs.  
quantizing error  
An unavoidable A/D conversion error that results  
simply from the conversion of a continuous voltage to  
its integer digital representation. Quantizing error is  
always ± 0.5 LSB and is the only error present in an  
ideal A/D converter.  
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.  
repeatability error  
The difference between corresponding code  
transitions from different actual characteristics taken  
from the same converter on the same channel with the  
same temperature, voltage, and frequency conditions.  
The amount of repeatability error depends on the  
comparator’s ability to resolve very similar voltages  
and the extent to which random noise contributes to  
the error.  
reserved memory  
resolution  
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.  
The number of input voltage levels that an A/D  
converter can unambiguously distinguish between.  
The number of useful bits of information that the  
converter can return.  
sample capacitor  
sample delay  
A small (2–3 pF) capacitor used in the A/D converter  
circuitry to store the input voltage on the selected  
input channel.  
The time period between the time that A/D converter  
receives the “start conversion” signal and the time  
that the sample capacitor is connected to the selected  
channel.  
sample delay uncertainty  
The variation in the sample delay.  
Glossary-8  
Download from Www.Somanuals.com. All Manuals Search And Download.  
GLOSSARY  
sample time  
The period of time that the sample window is open.  
(That is, the length of time that the input channel is  
actually connected to the sample capacitor.)  
sample time uncertainty  
sample window  
The variation in the sample time.  
The period of time that begins when the sample  
capacitor is attached to a selected channel of an A/D  
converter and ends when the sample capacitor is  
disconnected from the selected channel.  
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. EXTINT is  
normally a sampled input; however, the powerdown  
circuitry uses EXTINT as a level-sensitive input  
during powerdown mode.  
SAR  
set  
Successive approximation register. A component of  
the A/D converter.  
The “1” value of a bit or the act of giving it a “1”  
value. See also clear.  
SFR  
Special-function register.  
7
SHORT-INTEGER  
An 8-bit, signed variable with values from –2  
through +2 –1.  
7
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  
source current  
SP  
Current flowing into a device to ground. Always a  
positive value.  
Current flowing out of a device from VCC. Always a  
negative value.  
Stack pointer.  
Glossary-9  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
special interrupt  
Any of the three nonmaskable interrupts (unimple-  
mented opcode, software trap, or NMI).  
special-purpose memory  
A partition of memory used for storing the interrupt  
vectors, PTS vectors, chip configuration bytes, and  
several reserved locations.  
standard interrupt  
state time (or state)  
Any maskable interrupt that is assigned to the  
interrupt controller for processing by an interrupt  
service routine.  
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.  
successive approximation  
An A/D conversion method that uses a binary search  
to arrive at the best digital representation of an analog  
input.  
temperature coefficient  
temperature drift  
Change in the stated variable for each degree  
Centigrade of temperature change.  
The change in a specification due to a change in  
temperature. Temperature drift can be calculated by  
using the temperature coefficient for the specification.  
terminal-based characteristic  
transfer function  
An actual characteristic that has been translated and  
scaled to remove zero-offset error and full-scale error.  
A terminal-based characteristic resembles an actual  
characteristic with zero-offset error and full-scale  
error removed.  
A graph of output code versus input voltage; the  
characteristic of the A/D converter.  
Glossary-10  
Download from Www.Somanuals.com. All Manuals Search And Download.  
GLOSSARY  
transfer function errors  
Errors inherent in an analog-to-digital conversion  
process: quantizing error, zero-offset error, full-scale  
error, differential nonlinearity, and nonlinearity.  
Errors that are hardware-dependent, rather than being  
inherent in the process itself, include feedthrough,  
repeatability, channel-to-channel matching, off-  
isolation, and VCC rejection errors.  
UART  
CC rejection  
Universal asynchronous receiver and transmitter. A  
part of the serial I/O port.  
V
The property of an A/D converter that causes it to  
ignore (reject) changes in VCC so that the actual  
characteristic is unaffected by those changes. The  
effectiveness of VCC rejection is measured by the ratio  
of the change in VCC to the change in the actual  
characteristic.  
wait state  
Time spent waiting for an operation to take place.  
Wait states are added to external bus cycles to allow a  
slow memory device to respond to a request from the  
microcontroller.  
watchdog timer  
An internal timer that resets the device if software  
fails to respond before the timer overflows.  
waveform generator  
One of the 8XC196Mx peripherals that can be used to  
produce pulse-width modulated (PWM) outputs. The  
waveform generator is optimized for controlling 3-  
phase AC induction motors, brushless DC motors,  
and other devices requiring multiple PWM outputs.  
WDT  
word  
See watchdog timer.  
Any 16-bit unit of data.  
WORD  
An unsigned, 16-bit variable with values from 0  
through 2 –1.  
16  
zero extension  
A method for converting data to a larger format by  
filling the upper bit positions with zeros.  
zero-offset error  
An ideal A/D converter’s first code transition occurs  
when the input voltage is 0.5 LSB. Zero-offset error is  
the difference between 0.5 LSB and the actual input  
voltage that triggers an A/D converter’s first code  
transition.  
Glossary-11  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Index  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INDEX  
#, defined, 1-3, A-1  
16-bit data bus  
read cycles, 15-14  
timing diagram, 15-15  
write cycles, 15-14  
8-bit data bus  
transfer function, 12-15–12-18  
zero-offset adjustment, 12-3, 12-5  
zero-offset error, 12-16  
See also port 0  
A/D result register (read), 12-9, C-7  
A/D result register (write), 12-6, C-8  
A/D scan mode‚ See PTS  
A/D test register, 12-5, C-9  
A/D time register, 12-7, C-10  
AC timing  
read cycles, 15-16  
timing diagram, 15-17  
write cycles, 15-16  
specifications, 15-31–15-34  
symbol explanations, 15-33  
Accumulator, RALU, 2-5  
ACH13:0, B-13  
AD_COMMAND, C-68  
AD_RESULT, 12-9, C-68  
AD_TEST, C-68  
AD_TIME, C-68  
AD15:0, B-13  
ADD instruction, A-2, A-7, A-41, A-42, A-47,  
A-52  
ADDB instruction, A-2, A-7, A-42, A-43, A-47,  
A-52  
A
A/D command register, 12-8, C-6  
A/D converter, 2-11, 12-1–12-18  
actual characteristic, 12-16  
and port 0 reads, 12-13  
and PTS, 5-32–5-37  
block diagram, 12-1  
calculating result, 12-9, 12-13  
calculating series resistance, 12-10  
characteristics, 12-15–12-18  
conversion time, 12-6  
determining status, 12-9  
errors, 12-13–12-18  
hardware considerations, 12-10–12-13  
ideal characteristic, 12-15, 12-16  
input circuit, suggested, 12-12  
input protection devices, 12-12  
interfacing with, 12-10–12-13  
interpreting results, 12-9  
interrupt, 12-8  
minimizing input source resistance, 12-11  
overview, 12-3–12-4  
programming, 12-4–12-8  
sample delay, 12-4  
sample time, 12-6  
sample window, 12-4  
SFRs, 12-2  
signals, 12-2  
starting with PTS, 5-32–5-37  
successive approximation  
algorithm, 12-4  
register (SAR), 12-4  
terminal-based characteristic, 12-18  
threshold-detection modes, 12-5  
ADDC instruction, A-2, A-7, A-44, A-47, A-52  
ADDCB instruction, A-2, A-8, A-44, A-47, A-52  
Address space  
map, 4-2  
See also memory partitions  
Address valid strobe mode  
ALE/ADV# comparison, 15-27  
example system, 15-28, 15-29  
signals, 15-27  
Address valid with write strobe mode  
example system, 15-31  
signals, 15-30  
Address/data bus, 2-6  
multiplexing, 15-10–15-17  
Addressing modes, 3-5–3-6, A-6  
ADV#, B-13  
AINC#, 16-12, B-14  
ALE, B-14  
idle, powerdown, reset status, B-23, B-25  
Analog outputs, generating, 10-10  
Analog-to-digital converter‚ See A/D converter  
Index-1  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
AND instruction, A-2, A-8, A-41, A-42, A-48,  
A-53  
ANDB instruction, A-2, A-8, A-9, A-42, A-43,  
A-48, A-53  
standard, 15-22–15-24  
write strobe, 15-25–15-26  
Bus-control signals, 15-21  
Bus-width modes  
ANGND, 12-5, 13-1, B-14  
ApBUILDER software, downloading, 1-10  
Application notes, ordering, 1-6  
Arithmetic instructions, A-47, A-48, A-52, A-53  
Assert, defined, 1-3  
16-bit data bus, 15-14  
8-bit data bus, 15-16  
dynamic data bus, 15-13  
dynamic example, 15-24  
BUSWIDTH, 16-25, 16-27, B-15  
idle, powerdown, reset status, B-23, B-25  
timing, 15-11  
Auto programming mode, 16-25–16-28  
algorithm, 16-28  
circuit, 16-25–16-26  
definitions, 15-13  
memory map, 16-27  
diagram, 15-12  
PCCB, 16-27  
requirements, 15-13  
security key programming, 16-29  
BYTE, defined, 3-2  
B
C
Baud rate  
Call instructions, A-50, A-55, A-56  
Carry (C) flag, 3-4, A-4, A-5, A-11, A-18, A-19,  
A-20, A-21, A-31  
SIO port, 7-12–7-14  
Baud-rate generator  
SIO port, 7-12  
BAUD_VALUE, 7-13  
BCLK1:0, B-14  
Cascading timers, 11-7  
CCB fetch  
and BHE#, 6-13  
BCLKx, 7-2  
and P5.5, 6-13  
BHE#, B-14  
and P5.6, 6-13  
BIT, defined, 3-2  
and READY, 6-13  
Bit-test instructions, A-17  
Block diagram  
CCBs, 4-3, 13-8  
security-lock bits, 16-29–16-30  
CCBs, See also chip configuration bytes  
CCR0, 14-2  
A/D converter, 12-1  
address/data bus, 6-15  
clock circuitry, 2-7  
CCRs, 13-8, 14-5  
core and peripherals, 2-3  
EPA, 11-2  
frequency generator, 8-1  
infrared remote control application, 8-5  
I/O ports, 6-3, 6-8, 6-15, 6-16  
SIO port, 7-1  
security-lock bits, 16-17  
CCRs, See also chip configuration registers  
Chip configuration  
and bus contention, 15-11  
and reset, 15-6  
bytes, 15-5  
waveform generator, 9-2  
Block transfer mode‚ See PTS  
BMOV instruction, A-2, A-9, A-45, A-49  
BMOVI instruction, A-3, A-9, A-10, A-45, A-49  
BR (indirect) instruction, A-2, A-10, A-49, A-55  
Bus controller, 2-6, 16-6  
Bus-control modes, 15-21–15-31  
address valid strobe, 15-27–15-29  
address valid with write strobe, 15-30–15-31  
chip configuration register 0, 15-7, C-11  
chip configuration register 1, 15-9, C-13  
registers, 15-5  
Clear, defined, 1-3  
CLKOUT, 14-1, B-15  
and internal timing, 2-7  
and interrupts, 5-6  
and RESET#, 13-8  
idle, powerdown, reset status, B-24  
reset status, 6-7  
Index-2  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INDEX  
Clock  
external, 13-7  
pin reset status, B-23, B-25  
programming, 16-1–16-33  
generator, 2-7, 13-7, 13-8  
internal, and idle mode, 14-4, 14-5  
phases, internal, 2-8  
reset, 13-8, 13-9, 13-10, 13-11, 13-12  
DI instruction, A-3, A-12, A-46, A-51, A-57  
Digital-to-analog converter, 10-10  
DIR bit, 7-2, 7-6  
CLR instruction, A-2, A-10, A-41, A-47, A-52  
CLRB instruction, A-2, A-11, A-41, A-47, A-52  
CLRC instruction, A-3, A-11, A-46, A-51, A-57  
CLRVT instruction, A-3, A-11, A-46, A-51, A-57  
CMP instruction, A-3, A-11, A-43, A-47, A-52  
CMPB instruction, A-3, A-11, A-44, A-47, A-52  
CMPL instruction, A-2, A-12, A-45, A-47, A-52  
Code execution, 2-5, 2-6  
Direct addressing, 3-6, 3-9  
DIV instruction, A-13, A-46, A-48, A-53  
DIVB instruction, A-13, A-46, A-48, A-53  
DIVU instruction, A-3, A-13, A-43, A-48, A-53  
DIVUB instruction, A-3, A-14, A-44, A-48, A-53  
DJNZ instruction, A-2, A-5, A-14, A-45, A-50,  
A-56  
COMP0_TIME, C-68  
COMP1_CON, C-68  
DJNZW instruction, A-2, A-5, A-14, A-45, A-50,  
A-56  
COMP1_TIME, C-68  
Documents, related, 1-5–1-8  
COMP5:0, 11-3, B-15  
CompuServe forums, 1-10  
Conditional jump instructions, A-5  
Configuring external memory pins, 15-5  
CPU, 2-4  
DOUBLE-WORD, defined, 3-3  
DPTS instruction, A-3, A-15, A-45, A-51, A-57  
Dump-word routine, 16-24  
E
CPVER, 16-12, B-15  
Customer service, 1-8  
EA#, 16-13, B-15  
and P5.0, 6-13  
and P5.3, 6-13  
D
and programming modes, 16-14  
idle, powerdown, reset status, B-24, B-25  
EE opcode, and unimplemented opcode interrupt,  
A-3, A-46  
D/A converter, 10-10  
Data instructions, A-49, A-55  
Data types, 3-1–3-4  
addressing restrictions, 3-1  
converting between, 3-4  
defined, 3-1  
EI instruction, 5-13, A-3, A-15, A-46, A-51, A-57  
EPA, 2-10, 11-1–11-24  
and PTS, 11-12  
iC-96, 3-1  
block diagram, 11-2  
PLM-96, 3-1  
capture data overruns, 11-21  
capture/compare channels  
programming, 11-18  
choosing capture or compare mode, 11-19  
clock prescaler, 11-16, 11-17  
compare channels  
signed and unsigned, 3-1, 3-4  
values permitted, 3-1  
Datasheets  
online, 1-10  
ordering, 1-7  
Deassert, defined, 1-3  
DEC instruction, A-2, A-12, A-41, A-47, A-52  
DECB instruction, A-2, A-12, A-41, A-47, A-52  
DED bit, 16-6–16-7, 16-30  
DEI bit, 16-6–16-7, 16-17  
Design considerations  
waveform generator, 9-19, 9-20  
Device  
programming, 11-18  
compare modules  
programming, 11-18  
controlling the clock source and direction,  
11-16, 11-17  
determining event status, 11-24  
enabling a timer/counter, 11-16, 11-17  
enabling the compare function, 11-22  
overruns, 11-12, 11-13  
minimum hardware configuration, 13-1  
Index-3  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
re-enabling the compare event, 11-20, 11-22  
reloading the waveform generator, 11-20,  
11-23, C-16  
A/D conversion time, 12-7  
A/D error, 12-11  
A/D sample time, 12-7  
resetting the timer in compare mode, 11-21  
resetting the timers, 11-21, 11-23  
selecting the capture/compare event, 11-19  
selecting the compare event, 11-22  
selecting the time base, 11-19, 11-22  
selecting up or down counting, 11-16, 11-17  
signals, 11-2  
A/D series resistance, 12-10  
A/D threshold voltage, 12-5  
A/D voltage drop, 12-11  
capacitor size (powerdown circuit), 14-10  
PH1 and PH2 frequency, 2-8  
programming pulse width, OTPROM, 16-8  
programming voltage, 16-15  
SIO baud rate, 7-13  
starting an A/D conversion, 11-20, 11-23,  
C-16  
state time, 2-8  
See also port 1, port 6, PWM, timer/counters  
EPA compare control x register, 11-22, C-15  
EPA compare x time register, C-17  
EPA control x register, 11-19, C-18  
EPA time registers, C-21  
FPAL-96, 3-4  
FREQOUT, B-16  
Frequency generator, 8-1–8-9  
application example, 8-4–8-9  
data encoding example, 8-5  
block diagram, 8-1  
EPA0_CON, C-68  
EPA0_TIME, C-69  
infrared remote control application, 8-5  
EPA1_CON, C-68  
EPA1_TIME, C-69  
overview, 8-1–8-2  
programming  
EPA2_CON, C-69  
frequency, 8-3  
EPA2_TIME, C-69  
output, 8-3  
EPA3_CON, C-69  
registers, 8-2  
EPA3_TIME, C-69  
status, 8-4  
EPA4_CON, C-69  
EPA4_TIME, C-69  
Frequency generator count register, 8-4, C-22  
Frequency register, 8-3, C-23  
EPA5:0, 11-2, B-16  
EPA5_CON, C-69  
EPA5_TIME, C-69  
H
Handbooks, ordering, 1-6  
Hardware  
EPTS instruction, 5-13, A-15, A-45, A-51, A-57  
ESD protection, 6-3, 6-7, 13-5  
Event processor array‚ See EPA  
EXT instruction, A-2, A-15, A-41, A-47, A-52  
EXTB instruction, A-2, A-16, A-41, A-47, A-52  
EXTINT, 5-3, 14-7, B-16  
A/D converter considerations, 12-10–12-13  
addressing modes, 3-5  
auto programming circuit, 16-26  
device considerations, 13-1–13-13  
device reset, 13-8, 13-10, 13-11, 13-12  
interrupt processor, 2-6, 5-1  
memory protection, 16-7, 16-17  
minimum configuration, 13-1  
NMI considerations, 5-6  
and idle mode, 14-5  
and powerdown mode, 14-6, 14-7  
hardware considerations, 14-7  
F
noise protection, 13-4  
FaxBack service, 1-8  
FE opcode  
pin reset status, B-23, B-25  
programming mode requirements, 16-13  
reset instruction, 3-11  
SIO port considerations, 7-8  
slave programming circuit, 16-16  
UPROM considerations, 16-7  
and inhibiting interrupts, 5-9  
Floating point library, 3-4  
Formulas  
A/D conversion result, 12-9, 12-13  
Index-4  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INDEX  
Hypertext manuals and datasheets, downloading,  
1-10  
Interrupt pending register, 5-21, C-27  
Interrupts, 5-1–5-58  
controller, 2-6, 5-1  
end-of-PTS, 5-25  
inhibiting, 5-9  
latency, 5-9–5-11  
calculating, 5-10  
priorities, 5-4, 5-5  
modifying, 5-18–5-19  
procedures, PLM-96, 3-11  
processing, 5-2  
programming, 5-12–5-19  
selecting PTS or standard service, 5-12  
service routine  
processing, 5-19  
sources, 5-5  
I
Idle mode, 2-11, 13-13, 14-4–14-5  
entering, 14-5  
pin status, B-23, B-25  
timeout control, 11-7  
IDLPD instruction, A-2, A-16, A-46, A-51, A-57  
IDLPD #1, 14-5  
IDLPD #2, 14-6  
illegal operand, 13-9, 13-12  
Immediate addressing, 3-6  
INC instruction, A-2, A-16, A-41, A-47, A-52  
INCB instruction, A-2, A-17, A-41, A-47, A-52  
Indexed addressing, 3-9  
and register RAM, 4-10  
and windows, 4-19  
Indirect addressing, 3-6  
and register RAM, 4-10  
with autoincrement, 3-7  
Input pins  
unused inputs, 13-2  
vectors, 5-1, 5-5  
vectors, memory locations, 4-3  
Italics, defined, 1-3  
J
level-sensitive, B-13  
sampled, B-13  
unused, 13-2  
JBC instruction, A-2, A-5, A-17, A-41, A-50, A-56  
JBS instruction, A-3, A-5, A-17, A-41, A-50, A-56  
JC instruction, A-3, A-5, A-18, A-45, A-50, A-56  
JE instruction, A-3, A-5, A-18, A-45, A-50, A-56  
JGE instruction, A-2, A-5, A-18, A-45, A-50, A-56  
JGT instruction, A-2, A-5, A-19, A-45, A-50, A-56  
JH instruction, A-3, A-5, A-19, A-45, A-50, A-56  
JLE instruction, A-3, A-5, A-19, A-45, A-50, A-56  
JLT instruction, A-3, A-5, A-20, A-45, A-50, A-56  
JNC instruction, A-2, A-5, A-20, A-45, A-50,  
A-56  
JNE instruction, A-2, A-5, A-20, A-45, A-50, A-56  
JNH instruction, A-2, A-5, A-21, A-45, A-50,  
A-56  
JNST instruction, A-2, A-5, A-21, A-45, A-50,  
A-56  
INST, B-16  
Instruction set, 3-1  
and PSW flags, A-5  
code execution, 2-5, 2-6  
conventions, 1-3  
execution times, A-52–A-53  
lengths, A-47–A-52  
opcode map, A-2–A-3  
opcodes, A-41–A-46  
overview, 3-1–3-4  
protected instructions, 5-9  
reference, A-1–A-3  
See also RISM  
INT_MASK, 14-2  
JNV instruction, A-2, A-5, A-21, A-45, A-50,  
A-56  
JNVT instruction, A-2, A-5, A-22, A-45, A-50,  
A-56  
JST instruction, A-3, A-5, A-22, A-45, A-50, A-56  
Jump instructions, A-55  
INTEGER, defined, 3-3  
Interfacing with external memory  
configuring port pins, 15-5  
registers, 15-4  
signals, 15-1  
Interrupt mask 1 register, 5-16, C-26  
Interrupt mask register, 5-15, C-25  
Interrupt pending 1 register, 5-22, C-28  
conditional, A-5, A-50, A-56  
unconditional, A-49  
JV instruction, A-3, A-5, A-22, A-45, A-50, A-56  
Index-5  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
JVT instruction, A-3, A-5, A-23, A-45, A-50, A-56  
Mode 4, SIO, 7-6  
Modified quick-pulse algorithm, 16-9  
MUL instruction, A-25, A-46, A-48, A-53  
MULB instruction, A-25, A-46, A-48, A-53  
Multiprocessor communications  
SIO port, 7-8, 7-9  
MULU instruction, A-3, A-26, A-42, A-43, A-46,  
A-48, A-53  
MULUB instruction, A-3, A-26, A-42, A-43,  
A-48, A-53  
L
Latency‚ See bus-hold protocol‚ interrupts  
LCALL instruction, A-3, A-23, A-45, A-50, A-56  
LD instruction, A-2, A-23, A-44, A-49, A-55  
LDB instruction, A-2, A-23, A-44, A-49, A-55  
LDBSE instruction, A-3, A-24, A-44, A-49, A-55  
LDBZE instruction, A-3, A-24, A-44, A-49, A-55  
Level-sensitive input, B-13  
Literature, 1-11  
N
LJMP instruction, A-2, A-24, A-49, A-55  
Logical instructions, A-48, A-53  
LONG-INTEGER, defined, 3-4  
Naming conventions, 1-3–1-4  
NEG instruction, A-2, A-27, A-41, A-48, A-53  
Negative (N) flag, A-4, A-5, A-18, A-19, A-20  
NEGB instruction, A-2, A-27, A-41, A-48, A-53  
NMI, 5-3, 5-4, 5-6, B-16  
Lookup tables, software protection, 3-11  
M
hardware considerations, 5-6  
Manual contents, summary, 1-1  
Manuals, online, 1-10  
Measurements, defined, 1-5  
Memory bus, 2-6  
idle, powerdown, reset status, B-24, B-25  
Noise, reducing, 6-3, 6-4, 6-7, 12-12, 12-13, 13-4,  
13-5, 13-6  
NOP instruction, 3-11, A-3, A-27, A-46, A-51,  
A-57  
two-byte‚ See SKIP instruction  
NORML instruction, 3-4, A-3, A-27, A-41, A-51,  
A-57  
NOT instruction, A-2, A-28, A-41, A-48, A-53  
Notational conventions, 1-3–1-4  
NOTB instruction, A-2, A-28, A-41, A-48, A-53  
Numbers, conventions, 1-4  
Memory controller, 2-4, 2-6  
Memory map, 4-1, 4-2  
Memory mapping  
auto programming mode, 16-27  
Memory partitions, 4-1–4-19  
chip configuration bytes, 4-4  
chip configuration registers, 4-4  
interrupt and PTS vectors, 4-3  
OTPROM, 16-2  
program memory, 4-2, 16-2  
register file, 4-9  
register RAM, 4-10  
O
ONCE mode, 2-11, 14-10  
entering, 14-11  
reserved memory, 4-3  
security key, 4-4  
exiting, 14-11  
SFRs, 4-4  
ONCE#, 14-2, B-17  
special-purpose memory, 4-2, 4-3, 16-2  
Memory protection, 16-3–16-7  
CCR security-lock bits, 16-17  
UPROM security bits, 16-7  
Memory space, See memory partitions  
Microcode engine, 2-4  
Miller effect, 13-7  
Ones register, C-29  
Opcodes, A-41  
EE, and unimplemented opcode interrupt,  
A-3, A-46  
FE, and signed multiply and divide, A-3  
map, A-2  
reserved, A-3, A-46  
Mode 0, SIO, 7-5  
Mode 1, SIO, 7-7  
Mode 2, SIO, 7-9  
Mode 3, SIO, 7-9  
Operand types, See data types  
Operands, addressing, 3-10  
Operating modes, 2-11  
OR instruction, A-2, A-28, A-43, A-48, A-53  
Index-6  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INDEX  
ORB instruction, A-2, A-28, A-43, A-48, A-53  
Oscillator  
P6_REG, C-69  
P7.7:0, B-19  
and powerdown mode, 14-5  
external crystal, 13-6  
on-chip, 13-5  
PACT#, B-19  
PALE#, 16-8, 16-10, 16-11, B-19  
Parameters, passing to subroutines, 3-10  
Parity, 7-7, 7-8, 7-9  
PBUS, 16-12  
OTPROM  
controlling access to internal memory,  
16-3–16-6  
PBUS15:0, B-19  
controlling fetches from external memory,  
16-6–16-7  
PC (program counter), 2-4  
master, 2-6  
memory map, 16-2  
slave, 2-6  
programming, 16-1–16-33  
See also programming modes  
ROM-dump mode, 16-30  
verifying, 16-30  
Peripheral Interrupt mask register, 5-17, C-35  
Peripheral interrupt pending register, 5-23, C-37  
Peripherals, internal, 2-8  
Phase compare register, 9-17, C-59  
Pin-out diagrams, B-3, B-4, B-5, B-7, B-8, B-11,  
B-12  
Overflow (V) flag, A-4, A-5, A-21, A-22  
Overflow-trap (VT) flag, A-4, A-5, A-11, A-22,  
A-23  
PLM-96  
conventions, 3-9, 3-10, 3-11  
interrupt procedures, 3-11  
PMODE, 16-11, 16-13  
and programming modes, 16-14  
PMODE3:0, B-19  
P
P0.7:0, B-17  
P0.7:4  
and programming modes, 16-14  
P0_PIN, C-69  
P1.3:0, B-17  
P1.7:0, B-17  
P1_DIR, C-69  
P1_MODE, C-69  
P1_PIN, C-69  
P1_REG, C-69  
P2.2 considerations, 14-7  
P2.7:0, B-18  
P2_DIR, C-69  
P2_MODE, C-69  
P2_PIN, C-69  
P2_REG, C-69  
P3.7:0, B-18  
P4.7:0, B-18  
P5.0–P5.7  
POP instruction, A-3, A-29, A-45, A-49, A-54  
POPA instruction, A-2, A-29, A-46, A-49, A-54  
POPF instruction, A-2, A-29, A-46, A-49, A-54  
Port 0, 6-2, B-17  
considerations, 6-4, 12-13, 13-5  
idle, powerdown, reset status, B-25  
input only pins, 6-2  
overview, 6-1  
structure, 6-3  
Port 1, 6-2, B-17  
considerations, 6-4, 6-12  
idle, powerdown, reset status, B-23, B-25  
input buffer, 6-7  
input only pins, 6-2  
logic tables, 6-9  
operation, 6-4  
overview, 6-1  
SFRs, 6-6, 14-3  
See also port 5  
P5.7:0, B-18  
P5_PIN  
Port 2, 14-2, B-18  
considerations, 6-12  
idle, powerdown, reset status, B-23, B-25  
operation, 6-4  
overview, 6-1  
P2.7 considerations, 6-12  
P2.7 reset status, 6-7  
SFRs, 6-6  
P6.7:0, B-18  
P6_DIR, C-69  
P6_MODE, C-69  
P6_PIN, C-69  
Index-7  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
SFRs, 6-6, 14-3  
Port 3, B-18  
enabling, 14-5  
entering, 14-6  
exiting, 14-6  
addressing, 6-14  
idle, powerdown, reset status, B-23, B-25  
operation, 6-15–6-16  
overview, 6-1  
with EXTINT, 14-7–14-10  
with RESET#, 14-6  
with VPP, 14-6  
pin configuration, 6-14  
structure, 6-15  
pin status, B-23  
reset status, B-25  
Port 4, B-18  
Powerdown sequence, programming modes, 16-14  
Prefetch queue, 2-6  
addressing, 6-14  
idle, powerdown, reset status, B-23, B-25  
operation, 6-15–6-16  
overview, 6-1  
pin configuration, 6-14  
structure, 6-15  
Priority encoder, 5-4  
Processor status word‚ See PSW  
Product information, ordering, 1-6  
PROG#, 16-10, 16-12, B-20  
Program counter‚ See PC  
Program memory, 4-2  
Port 5, B-18  
considerations, 6-12  
idle, powerdown, reset status, B-23, B-25  
operation, 6-4, 6-12  
Program-word routine, 16-22  
Programming  
frequency generator  
overview, 6-1  
frequency, 8-3  
pin configuration, 6-12  
SFRs, 6-6, 14-3  
Port 6, B-18  
output, 8-3  
Programming modes, 16-1–16-33  
algorithms, 16-20, 16-21, 16-23, 16-28  
auto, 16-2  
configuration, 6-17  
idle, powerdown, reset status, B-23, B-25  
operation, 6-17  
entering, 16-13, 16-14  
exiting, 16-14  
output configuration register, 6-18, C-62  
overview, 6-1  
Port 7, B-19  
hardware requirements, 16-13  
pin functions, 16-11–16-13  
selecting, 16-13  
idle, powerdown, reset status, B-24  
operation, 6-4  
serial port, 16-2  
slave, 16-1  
overview, 6-1  
SFRs, 6-6, 14-3  
Programming pulse width register, 16-8, C-39  
Programming voltages, 13-1, 14-2, 16-13, B-21  
calculating, 16-15  
Port x data output register, C-34  
Port x I/O direction register, C-30  
Port x mode register, C-31  
Port x pin input register, C-33  
Port, serial‚ See SIO port  
Ports  
PSW, 2-4, 3-11, C-40  
flags, and instructions, A-5  
PTS, 2-4, 2-6, 2-11, 5-1  
A/D scan mode, 5-32–5-37  
and A/D converter, 5-33  
asynchronous serial I/O receive mode,  
5-55–5-58  
general-purpose I/O, 2-9  
unused inputs, 13-2  
Power and ground pins  
minimum hardware connections, 13-5  
Power consumption, reducing, 2-11, 14-5  
Power-up sequence, programming modes, 16-14  
Powerdown mode, 2-11, 14-5–14-10  
circuitry, external, 14-8, 14-10  
disabling, 14-5  
asynchronous serial I/O transmit mode,  
5-50–5-54  
block transfer mode, 5-30  
control block, See PTSCB  
cycle execution time, 5-12  
cycle, defined, 5-30  
initializing PTS control blocks, 5-24  
Index-8  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INDEX  
instructions, A-51, A-57  
interrupt latency, 5-11  
interrupt processing flow, 5-2  
routine, defined, 5-1  
Q
Quadrature clocking, 11-7  
Quick reference guides, ordering, 1-8  
serial I/O modes, 5-37–5-58  
single transfer mode, 5-27  
synchronous serial I/O receive mode,  
5-47–5-50  
synchronous serial I/O transmit mode,  
5-43–5-46  
R
RALU, 2-4–2-6  
RD#, B-20  
considerations, 6-13  
idle, powerdown, reset status, B-23, B-25  
Read cycles  
vectors, memory locations, 4-3  
See also PWM  
16-bit data bus, 15-14  
8-bit data bus, 15-16  
PTS select register, 5-14, C-42  
PTS service register, 5-26, C-43  
PTSCB, 5-4, 5-9  
READY, 15-17–15-21, 16-25  
and wait states, 15-18  
considerations, 6-13  
idle, powerdown, reset status, B-23, B-25  
timing definitions, 15-20  
timing diagram, 15-19  
timing requirements, 15-18  
REAL variables, 3-4  
A/D scan mode, 5-33  
block transfer mode, 5-31  
memory locations, 4-3  
PTSCON register, 5-27  
PTSCOUNT register, 5-25  
single transfer mode, 5-28  
PTSCB1  
serial I/O mode, 5-38  
PTSCB2  
Register bits  
naming conventions, 1-4  
reserved, 1-4  
Register file, 2-4, 4-9  
and windowing, 4-9, 4-12  
See also windows  
serial I/O mode, 5-41  
Pulse-width modulator, See PWM  
PUSH instruction, A-3, A-29, A-45, A-49, A-54  
PUSHA instruction, A-2, A-30, A-46, A-49, A-54  
PUSHF instruction, A-2, A-30, A-46, A-49, A-54  
PVER, 16-9, 16-11, B-20  
PWM, 10-1  
Register RAM, 4-10  
and idle mode, 14-4  
and powerdown mode, 14-5  
Register-direct addressing, 4-10  
and register RAM, 4-10  
and windows, 4-12, 4-19  
Registers  
and cascading timer/counters, 11-7  
block diagram, 10-2  
D/A converter, 10-10  
duty cycle, 10-4  
enabling outputs, 10-8  
generating analog outputs, 10-10  
highest-speed, 11-14  
low-speed, 11-7, 11-13  
AD_COMMAND, 12-8, C-6  
AD_RESULT (read), 12-9, C-7  
AD_RESULT (write), 12-6, C-8  
AD_TEST, 12-5, C-9  
AD_TIME, 12-7, C-10  
addresses and reset values, C-2  
allocating, 3-10  
CCR0, 15-7, C-11  
CCR1, 15-9, C-13  
COMPx_CON, 11-22, C-15  
COMPx_TIME, C-17  
EPAx_CON, 11-19, C-18  
EPAx_TIME, C-21  
overview, 10-1  
programming duty cycle, 10-4  
typical waveforms, 10-4  
with dedicated timer/counter, 11-14  
PWM control x register, 10-7, C-46  
PWM count register, 10-8, C-44  
PWM period register, 10-6, C-45  
PWM1:0, B-20  
external memory, 15-4  
Index-9  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
FREQ_CNT, 8-4, C-22  
FREQ_GEN, 8-3, C-23  
GEN_CON, 13-9, C-24  
grouped by modules, C-1  
INT_MASK, 5-15, C-25  
INT_MASK1, 5-16, 7-2, C-26  
INT_PEND, 5-21, 7-3, C-27  
INT_PEND1, 5-22, 7-3, C-28  
naming conventions, 1-4  
ONES_REG, C-29  
SP1_CON, 7-4  
SP1_STATUS, 7-4  
SPx_BAUD, 7-12, C-50  
SPx_CON, 7-10, C-51  
SPx_STAUS, 7-15, C-52  
T1CONTROL, 11-16, C-53  
T1RELOAD, C-54  
T2CONTROL, 11-17, C-55  
TIMERx, C-56  
USFR, 16-7, C-57  
P0_PIN, 6-3, 6-4  
using, 3-9  
P1_MODE  
WATCHDOG, C-58  
considerations, 6-12  
P1_PIN, 6-3, 6-4, 7-3  
P2_MODE  
considerations, 6-12  
P2_REG  
considerations, 6-12  
P5_MODE  
considerations, 6-12, 6-13  
PI_MASK, 5-17, 7-4, C-35  
PI_PEND, 5-23, 7-4, C-37  
PPW, 16-8, C-39  
WG_COMPx, 9-17, C-59  
WG_CONTROL, 9-18, C-60  
WG_COUNTER, 9-19, C-61  
WG_OUTPUT (port 6), 6-17, 6-18, C-62  
WG_OUTPUT (waveform generator), 9-13,  
C-63  
WG_PROTECT, 9-15, C-66  
WG_RELOAD, 9-16, C-67  
WSR, 4-12, C-68  
ZERO_REG, C-71  
Reserved bits, defined, 1-4  
Reset, 13-9  
PSW, C-40  
PTSSEL, 5-14, C-42  
PTSSRV, 5-26, C-43  
PWM_COUNT, 10-8, C-44  
PWM_PERIOD, 10-6, C-45  
PWMx_CONTROL, 10-7, C-46  
Px_DIR, 6-6, 6-9, 6-10, 6-11, C-30  
Px_MODE, 6-6, 6-9, 6-10, 6-11, C-31  
Px_PIN, 6-2, 6-6, 6-7, 6-9, 6-14, 6-16, C-33  
Px_REG, 6-6, 6-9, 6-10, 6-11, 6-14, 6-16,  
C-34  
and CCB fetches, 4-4  
circuit diagram, 13-11  
general configuration register, 13-9, C-24  
pin status, B-23, B-25  
status  
CLKOUT/P2.7, 6-7  
with illegal IDLPD operand, 13-12  
with RESET# pin, 13-10  
with RST instruction, 13-9, 13-12  
with watchdog timer, 13-12  
RESET#, 13-1, 14-2, B-20  
and CCB fetch, 13-8  
RALU, 2-4, 2-5, 4-10  
reset values and addresses, C-2  
SBUF0_RX, 7-4  
and CLKOUT, 13-8  
SBUF0_TX, 7-4  
SBUF1_RX, 7-4  
SBUF1_TX, 7-4  
SBUFx_RX, C-47  
SBUFx_TX, C-48  
SP, C-49  
SP_PPW, 16-8  
SP0_BAUD, 7-4  
and device reset, 13-8, 13-9, 13-10  
and ONCE mode, 14-11  
and powerdown mode, 14-6  
and programming modes, 16-13, 16-14  
idle, powerdown, reset status, B-24, B-25  
Resonator, ceramic, 13-6  
RET instruction, A-2, A-30, A-46, A-50, A-55,  
A-56  
SP0_CON, 7-4  
SP0_STATUS, 7-4  
ROM-dump mode, 16-30  
security key verification, 16-30  
SP1_BAUD, 7-4  
Index-10  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INDEX  
RST instruction, 3-11, 13-9, 13-12, A-3, A-31,  
A-46, A-51, A-57  
Run-time programming, 16-32–16-33  
code example, 16-33  
SHRL instruction, A-3, A-36, A-41, A-51, A-57  
Signals  
configuring for external memory interfacing,  
15-5  
default conditions, B-23, B-25  
descriptions, B-13–B-22  
external memory, 15-1  
AD15:0, 15-1  
RXD, B-20  
and SIO port mode 0, 7-5, 7-7  
and SIO port modes 1, 2, and 3, 7-7  
ADV#, 15-1  
ALE, 15-2  
BHE#, 15-2  
BUSWIDTH, 15-2  
CLKOUT, 15-2  
EA#, 15-3  
INST, 15-3  
RD#, 15-3  
READY, 15-3  
S
Sampled input, B-13  
SBUFx_RX, C-70  
SBUFx_TX, C-70  
SCALL instruction, A-3, A-31, A-41, A-47, A-50,  
A-55, A-56  
SCLKx#, 7-2  
Security key  
verification, 16-30  
WR#, 15-3  
WRH#, 15-4  
WRL#, 15-4  
Serial I/O modes, See PTS  
Serial I/O port‚ See SIO port  
Serial port control x register, 7-10, C-51  
Serial port receive buffer x register, C-47  
Serial port status x register, 7-15, C-52  
Serial port transmit buffer x register, C-48  
Serial port x baud rate register, 7-12, C-50  
Set, defined, 1-3  
functional listings, B-2, B-6, B-9  
name changes, B-1  
naming conventions, 1-4  
Single transfer mode‚ See PTS  
SIO port, 2-9, 7-1  
9-bit data‚ See mode 2‚ mode 3  
block diagram, 7-1  
calculating baud rate, 7-13, 7-14  
enabling interrupts, 7-14  
enabling parity, 7-10–??  
framing error, 7-16  
half-duplex considerations, 7-8  
interrupts, 7-7, 7-9, 7-16  
mode 0, 7-5–7-6  
mode 1, 7-7  
mode 2, 7-7, 7-8  
mode 3, 7-7, 7-9  
multiprocessor communications, 7-8, 7-9  
overrun error, 7-16  
programming, 7-10  
receive interrupt (RI) flag, 7-16  
selecting baud rate, 7-12–7-14  
SFRs, 7-2  
SETC instruction, A-3, A-31, A-46, A-51, A-57  
SFRs  
and idle mode, 14-4  
and powerdown mode, 14-5  
CPU, 4-11  
memory-mapped, 4-5  
peripheral, 4-4, 4-5  
and windowing, 4-12  
reserved, 3-10, 4-4, 4-11  
with indirect or indexed operations, 3-10, 4-4,  
4-11  
with read-modify-write instructions, 4-4  
Shift instructions, A-51, A-57  
SHL instruction, A-3, A-32, A-41, A-51, A-57  
SHLB instruction, A-3, A-32, A-41, A-51, A-57  
SHLL instruction, A-3, A-33, A-41, A-51  
SHORT-INTEGER, defined, 3-2  
SHR instruction, A-3, A-33, A-41, A-51, A-57  
SHRA instruction, A-3, A-34, A-41, A-51, A-57  
SHRAB instruction, A-3, A-34, A-41, A-51, A-57  
SHRAL instruction, A-3, A-35, A-41, A-51, A-57  
SHRB instruction, A-3, A-35, A-41, A-51, A-57  
signals, 7-2  
status, 7-15–7-16  
transmit interrupt (TI) flag, 7-16  
See also mode 0‚ mode 1‚ mode 2‚ mode 3‚  
port 2  
Index-11  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
SJMP instruction, A-2, A-36, A-41, A-47, A-49,  
A-55  
SKIP instruction, A-2, A-36, A-41, A-51, A-57  
Slave programming mode, 16-15–16-24  
address/command decoder routine, 16-19,  
16-20  
Subroutines  
linking, 3-10  
nested, 4-10  
Symbols  
signal status, B-23  
System bus timing, 15-32  
algorithm, 16-19–16-24  
circuit, 16-16  
dump-word routine, 16-19, 16-23  
entering, 16-19  
program-word routine, 16-19, 16-21  
security key programming, 16-15  
timings, 16-22, 16-24  
T
T1CLK, 11-2, B-21  
T1CONTROL, C-70  
T1DIR, 11-2, B-21  
T1RELOAD, C-70  
T2CONTROL, C-70  
Technical support, 1-11  
Terminology, 1-3  
Software  
addressing modes, 3-9  
conventions, 3-9–3-11  
TIJMP instruction, A-2, A-39, A-45, A-49, A-55  
Timer 1 control register, 11-16, C-53  
Timer 1 reload register, C-54  
Timer 2 control register, 11-17, C-55  
Timer x register, C-56  
Timer, watchdog‚ See watchdog timer  
Timer/counters, 2-10  
and PWM, 11-13, 11-14  
cascading, 11-7  
device reset, 13-12  
interrupt service routines, 5-19  
linking subroutines, 3-10  
protection, 3-11  
trap interrupt, 5-4, 5-6, 5-9  
SP_STATUS, 7-15  
SPE bit, 7-3  
Special instructions, A-51, A-57  
Special operating modes  
SFRs, 14-2  
Special-purpose memory, 4-2  
SPx bit, 7-4  
SPx_BAUD, C-70  
SPx_CON, C-70  
count rate, 11-6  
programming, 11-15  
quadrature clocking, 11-7  
resolution, 11-6  
signals, 11-2  
See also EPA  
SPx_STATUS, C-70  
TIMER1, C-70  
ST instruction, A-2, A-37, A-45, A-49, A-55  
Stack instructions, A-49, A-54  
Stack pointer, 4-10, C-49  
and subroutine call, 4-10  
initializing, 4-11  
Standard bus-control mode  
decoding WRL# and WRH#, 15-22  
example system, 15-23  
TIMER2, C-70  
Timing  
dump-word routine, 16-24  
instruction execution, A-52–A-53  
internal, 2-7, 2-8  
interrupt latency, 5-9–5-12, 5-30  
program-word routine, 16-22  
PTS cycles, 5-12  
signals, 15-22  
State time, defined, 2-8  
SIO port mode 0, 7-6, 7-7  
SIO port mode 1, 7-8  
SIO port mode 2, 7-9  
SIO port mode 3, 7-9  
slave programming routines, 16-22, 16-24  
Timing definitions  
STB instruction, A-2, A-37, A-45, A-49, A-55  
Sticky bit (ST) flag, 3-4, A-4, A-5, A-21, A-22  
SUB instruction, A-3, A-37, A-42, A-47, A-52  
SUBB instruction, A-3, A-38, A-42, A-43, A-47,  
A-52  
BUSWIDTH, 15-13  
READY, 15-20  
SUBC instruction, A-3, A-38, A-44, A-47, A-52  
SUBCB instruction, A-3, A-38, A-44, A-47, A-52  
Index-12  
Download from Www.Somanuals.com. All Manuals Search And Download.  
INDEX  
Timing diagrams  
16-bit data bus, 15-15  
and duty cycle, 9-19  
generator circuitry, 9-5  
8-bit data bus, 15-17  
BUSWIDTH, 15-12  
READY, 15-19  
design considerations, 9-19, 9-20  
EXTINT interrupts and protection circuitry,  
9-21  
system bus timing, 15-32  
Timing requirements  
BUSWIDTH, 15-13  
READY, 15-18  
TRAP instruction, 5-6, A-2, A-39, A-46, A-50,  
A-55, A-56  
interrupts, 9-20  
operating modes, 9-7, 9-11  
center-aligned, 9-8, 9-9, 9-10  
edge-aligned, 9-8, 9-10, 9-11  
overview, 9-1  
phase driver channels, 9-5  
programming, 9-12, 9-20  
carrier period, 9-16  
TRAP interrupt, 5-4  
TXD, B-21  
and SIO port mode 0, 7-5  
EXTINT  
interrupts, 9-15  
outputs, 9-12, C-63–C-65  
protection circuitry, 9-15  
programming example, 9-21, 9-25  
protection circuitry, 9-6  
register  
buffering and synchronization, 9-6, 9-7  
updates, 9-8  
registers, 9-3, 9-4  
U
UART, 2-9, 7-1  
Unerasable PROM register, 16-7, C-57  
Unimplemented opcode interrupt, 3-11, 5-4, 5-6,  
5-9  
Units of measure, defined, 1-5  
Universal asynchronous receiver and transmitter‚  
See UART  
UPROM, 16-6  
programming, 16-6–16-7  
USFR, 16-7  
signals, 9-3  
status, 9-19  
timebase generator, 9-4  
Waveform generator control register, 9-18, C-60  
Waveform generator counter register, 9-19, C-61  
Waveform generator output configuration register,  
9-13, C-63  
Waveform generator reload register, 9-16, C-67  
Waveform protection register, 9-15, C-66  
WDE bit, 13-12  
WG3:1, B-22  
WG3:1#, B-22  
Window selection register‚ See WSR  
Windowing, 4-12–4-19  
examples, 4-16–4-19  
V
VCC, 13-1, B-21  
and programming modes, 16-14  
VPP, 13-1, 14-2, 16-13, B-21  
and programming modes, 16-14  
V
REF, 12-5, 13-1, B-21  
VSS, 13-1, B-21  
and programming modes, 16-14  
W
Wait states, 15-17–15-20  
controlling, 15-18  
See also windows  
Windows, 4-12–4-19  
Watchdog timer, 2-11, 3-11, 3-12, 13-9, 13-12  
and idle mode, 14-5  
selecting reset interval, 13-13  
Watchdog timer register, C-58  
Waveform generator, 9-1, 9-25  
block diagram, 9-2  
addressing, 4-16  
and addressing modes, 4-19  
and memory-mapped SFRs, 4-15  
base address, 4-14, 4-15  
locations that cannot be windowed, 4-15  
offset address, 4-14  
control and protection circuitry, 9-5  
dead time  
selecting, 4-13  
setting up with linker loader, 4-17  
Index-13  
Download from Www.Somanuals.com. All Manuals Search And Download.  
8XC196MC, MD, MH USER’S MANUAL  
WSR values and direct addresses, 4-15  
WORD, defined, 3-2  
World Wide Web, 1-11  
WR#, B-22  
idle, powerdown, reset status, B-23, B-25  
WRH#, B-22  
Write cycles  
16-bit data bus, 15-14  
8-bit data bus, 15-16  
Write strobe mode  
example system, 15-26  
signals, 15-25  
WRL#, B-22  
WSR, 4-13, C-68  
X
X, defined, 1-5  
x, defined, 1-3  
XCH instruction, A-2, A-3, A-40, A-41, A-49,  
A-55  
XCHB instruction, A-2, A-3, A-40, A-41, A-49,  
A-55  
XOR instruction, A-2, A-40, A-43, A-48, A-53  
XORB instruction, A-2, A-40, A-43, A-44, A-48,  
A-53  
XTAL1, 13-2, B-22  
and Miller effect, 13-7  
and programming modes, 16-13  
and SIO baud rate, 7-14  
hardware connections, 13-6, 13-7  
XTAL2, 13-2, B-22  
hardware connections, 13-6, 13-7  
Y
y, defined, 1-3  
Z
Zero (Z) flag, A-4, A-5, A-18, A-19, A-20, A-21  
Zero register, C-71  
Index-14  
Download from Www.Somanuals.com. All Manuals Search And Download.  

Insignia DVD Player NS 7PDVD User Manual
Johnson Controls Automobile Parts M9220 GGX 3 User Manual
JVC DVD Player SR DVM700ER User Manual
JVC DVD Player XV NA7SL User Manual
Jwin CD Player JX CD680 User Manual
Kalamazoo Outdoor Gourmet Oven Pizza Oven User Manual
Kenwood Marine Radio tm 732A E User Manual
King Canada Lathe CH 900C User Manual
KitchenAid Blender KSB580CR0 User Manual
KitchenAid Microwave Oven KBHS179 User Manual