80C196KB User's Guide
80C196KB User's Guide
User’s Guide
November 1990
Intel may make changes to specifications and product descriptions at any time, without notice.
*Third-party brands and names are the property of their respective owners.
Contact your local Intel sales office or your distributor to obtain the latest specifications and before placing your product order.
Copies of documents which have an ordering number and are referenced in this document, or other Intel literature, may be
obtained from:
Intel Corporation
P.O. Box 7641
Mt. Prospect, IL 60056-7641
or call 1-800-879-4683
COPYRIGHT © INTEL CORPORATION, 1996
80C196KB USER’S GUIDE
CONTENTS PAGE CONTENTS PAGE
The 80C196KB family is a CHMOS branch of the There are many members of the 80C196KB family, so
MCSÉ-96 family. Other members of the MCS-96 fami- to provide easier reading this manual will refer to the
ly include the 8096BH and 8098. All of the MCS-96 80C196KB family generically as the 80C196KB.
components share a common instruction set and archi- Where information applies only to specific components
tecture. However the CHMOS components have en- it will be clearly indicated.
hancements to provide higher performance at lower
power consumptions. To further decrease power usage, The 80C196KB can be separated into four sections for
these parts can be placed into idle and powerdown the purpose of describing its operation. A block dia-
modes. gram is shown in Figure 1-1. There is the CPU and
architecture, the instruction set, the peripherals and the
MCS-96 family members are all high-performance mi- bus unit. Each of the sections will be sub-divided as the
crocontrollers with a 16-bit CPU and at least 230 bytes discussion progresses. Let us first examine the CPU.
of on-chip RAM. They are register-to-register ma-
chines, so no accumulator is needed, and most opera-
tions can be quickly performed from or to any of the 1.0 CPU OPERATION
registers. In addition, the register operations can con-
trol the many peripherals which are available on the The major components of the CPU on the 80C196KB
chips. These peripherals include a serial port, A/D con- are the Register File and the Register/Arithmetic Log-
verter, PWM output, up to 48 I/O lines and a High- ic Unit (RALU). Communication with the outside
Speed I/O subsystem which has 2 16-bit timer/coun- world is done through either the Special Function Reg-
ters, an 8-level input capture FIFO and an 8-entry pro- isters (SFRs) or the Memory Controller. The RALU
grammable output generator. does not use an accumulator. Instead, it operates di-
rectly on the 256-byte register space made up of the
Typical applications for MCS-96 products are closed- Register File and the SFRs. Efficient I/O operations
loop control and mid-range digital signal processing. are possible by directly controlling the I/O through the
MCS-96 products are being used in modems, motor SFRs. The main benefits of this structure are the ability
controls, printers, engine controls, photocopiers, anti- to quickly change context, absence of accumulator bot-
lock brakes, air conditioner temperature controls, disk tleneck, and fast throughput and I/O times.
drives, and medical instrumentation.
270651 – 1
1
80C196KB USER’S GUIDE
The CPU on the 80C196KB is 16 bits wide and con- REGISTER/ALU (RALU)
nects to the interrupt controller and the memory con-
troller by a 16-bit bus. In addition, there is an 8-bit bus Most calculations performed by the 80C196KB take
which transfers instruction bytes from the memory con- place in the RALU. The RALU, shown in Figure 1-2,
troller to the CPU. An extension of the 16-bit bus con- contains a 17-bit ALU, the Program Status Word
nects the CPU to the peripheral devices. (PSW), the Program Counter (PC), a loop counter, and
three temporary registers. All of the registers are 16-
bits or 17-bits (16 a sign extension) wide. Some of the
1.1 Memory Controller registers have the ability to perform simple operations
to off-load the ALU.
The RALU talks to the memory, except for the loca-
tions in the register file and SFR space, through the A separate incrementor is used for the Program Coun-
memory controller. Within the memory controller is a ter (PC) as it accesses operands. However, PC changes
bus controller, a four byte queue and a Slave Program due to jumps, calls, returns and interrupts must be han-
Counter (Slave PC). Both the internal ROM/EPROM dled through the ALU. Two of the temporary registers
bus and the external memory bus are driven by the bus have their own shift logic. These registers are used for
controller. Memory access requests to the bus control- the operations which require logical shifts, including
ler can come from either the RALU or the queue, with Normalize, Multiply, and Divide. The ‘‘Lower Word’’
queue accesses having priority. Requests from the and ‘‘Upper Word’’ are used together for the 32-bit
queue are always for instruction at the address in the instructions and as temporary registers for many in-
slave PC. structions. Repetitive shifts are counted by the 6-bit
‘‘Loop Counter’’.
By having program fetches from memory referenced to
the slave PC, the processor saves time as addresses sel- A third temporary register stores the second operand of
dom have to be sent to the memory controller. If the two operand instructions. This includes the multiplier
address sequence changes because of a jump, interrupt, during multiplications and the divisor during divisions.
call or return, the slave PC is loaded with a new value, To perform subtractions, the output of this register can
the queue is flushed, and processing continues. be complemented before being placed into the ‘‘B’’ in-
put of the ALU.
Execution speed is increased by using a queue since it
usually keeps the next instruction byte available. The Several constants, such as 0, 1 and 2 are stored in the
instruction execution times shown in Section 3 show RALU to speed up certain calculations. (e.g. making a
the normal execution times with no wait states added 2’s complement number or performing an increment or
and the 16-bit bus selected. Reloading the slave PC and decrement instruction.) In addition, single bit masks for
fetching the first byte of the new instruction stream bit test instructions are generated in the constant regis-
takes 4 state times. This is reflected in the jump taken/ ter based on the 3-bit Bit Select register.
not-taken times shown in the table.
When debugging code using a logic analyzer, one must 1.3 Internal Timing
be aware of the queue. It is not possible to determine
when an instruction will begin executing by simply The 80C196KB requires an input clock on XTAL1 to
watching when it is fetched, since the queue is filled in function. Since XTAL1 and XTAL2 are the input and
advance of instruction execution. output of an inverter a crystal can be used to generate
the clock. Details of the circuit and suggestions for its
use can be found in Section 13.
1.2 CPU Control
Internal operation of the 80C196KB is based on the
A microcode engine controls the CPU, allowing it to crystal or external oscillator frequency divided by 2.
perform operations with any byte, word or double word Every 2 oscillator periods is referred to as one ‘‘state
in the 256 byte register space. Instructions to the CPU time’’, the basic time measurement for all 80C196KB
are taken from the queue and stored temporarily in the operations. With a 12 MHz oscillator, a state time is
instruction register. The microcode engine decodes the 167 nanoseconds. With an 8 MHz oscillator, a state
instructions and generates the correct sequence of time is 250 nanoseconds, the same as an 8096BH run-
events to have the RALU perform the desired function. ning with a 12 MHz oscillator. Since the 80C196KB
Figure 1-2 shows the memory controller, RALU, in- will be run at many frequencies, the times given
struction register and the control unit. throughout this chapter will be in state times or
‘‘states’’, unless otherwise specified. A clock out
2
80C196KB USER’S GUIDE
270651– 2
3
80C196KB USER’S GUIDE
4
80C196KB USER’S GUIDE
Listed registers
are present in
all three windows
19H 19H
STACK POINTER STACK POINTER
18H 18H
17H *IOS2 17H PWMÐCONTROL
16H IOS1 16H IOC1
15H IOS0 15H IOC0
14H *WSR 14H *WSR
13H *INTÐMASK 1 13H *INTÐMASK 1
12H *INTÐPEND 1 12H *INTÐPEND 1
11H *SPÐSTAT 11H *SPÐCON
10H PORT2 10H PORT2 10H RESERVED**
0FH PORT1 0FH PORT1 0FH RESERVED**
0EH PORT0 0EH BAUD RATE 0EH RESERVED**
0DH TIMER2 (HI) 0DH TIMER2 (HI) 0DH *T2 CAPTURE (HI)
0CH TIMER2 (LO) 0CH TIMER2 (LO) 0CH *T2 CAPTURE (LO)
0BH TIMER1 (HI) 0BH *IOC2
WSR e 15
0AH TIMER1 (LO) 0AH WATCHDOG
09H INTÐPEND 09H INTÐPEND OTHER SFRS IN WSR 15 BECOME
08H INTÐMASK 08H INTÐMASK READABLE IF THEY WERE WRITABLE
IN WSR e 0, AND WRITABLE IF THEY
07H SBUF(RX) 07H SBUF(TX) WERE READABLE IN WSR e 0
06H HSIÐSTATUS 06H HSOÐCOMMAND
05H HSIÐTIME (HI) 05H HSOÐTIME (HI)
04H HSIÐTIME (LO) 04H HSOÐTIME (LO) 04H PPW
03H ADÐRESULT (HI) 03H HSIÐMODE WSR e 14
02H ADÐRESULT (LO) 02H ADÐCOMMAND
01H ZERO REG (HI) 01H ZERO REG (HI) *NEW OR CHANGED REGISTER
00H ZERO REG (LO) 00H ZERO REG (LO) FUNCTION FROM 8096BH
**RESERVED REGISTERS SHOULD NOT
WHEN READ WHEN WRITTEN
WSR e 0 BE WRITTEN OR READ
5
80C196KB USER’S GUIDE
Register Description
R0 Zero Register - Always reads as a zero, useful for a base when indexing and as a
constant for calculations and compares.
ADÐRESULT A/D Result Hi/Low - Low and high order results of the A/D converter
ADÐCOMMAND A/D Command Register - Controls the A/D
HSIÐMODE HSI Mode Register - Sets the mode of the High Speed Input unit.
HSIÐTIME HSI Time Hi/Lo - Contains the time at which the High Speed Input unit was triggered.
HSOÐTIME HSO Time Hi/Lo - Sets the time or count for the High Speed Output to execute the
command in the Command Register.
HSOÐCOMMAND HSO Command Register - Determines what will happen at the time loaded into the
HSO Time registers.
HSIÐSTATUS HSI Status Registers - Indicates which HSI pins were detected at the time in the HSI
Time registers and the current state of the pins. In Window 15 - Writes to pin
detected bits, but not current state bits.
SBUF(TX) Transmit buffer for the serial port, holds contents to be outputted. Last written value
is readable in Window 15.
SBUF(RX) Receive buffer for the serial port, holds the byte just received by the serial port.
Writable in Window 15.
INTÐMASK Interrupt Mask Register - Enables or disables the individual interrupts.
INTÐPEND Interrupt Pending Register - Indicates that an interrupt signal has occurred on one of
the sources and has not been serviced. (also INTÐPENDING)
WATCHDOG Watchdog Timer Register - Written periodically to hold off automatic reset every 64K
state times. Returns upper byte of WDT counter in Window 15.
TIMER1 Timer 1 Hi/Lo - Timer1 high and low bytes.
TIMER2 Timer 2 Hi/Lo - Timer2 high and low bytes.
IOPORT0 Port 0 Register - Levels on pins of Port 0. Reserved in Window 15.
BAUDÐRATE Register which determines the baud rate, this register is loaded sequentially.
Reserved in Window 15.
IOPORT1 Port 1 Register - Used to read or write to Port 1. Reserved in Window 15
IOPORT2 Port 2 Register - Used to read or write to Port 2. Reserved in Window 15
SPÐSTAT Serial Port Status - Indicates the status of the serial port.
SPÐCON Serial Port Control - Used to set the mode of the serial port.
IOS0 I/O Status Register 0 - Contains information on the HSO status. Writes to HSO pins
in Window 15.
IOS1 I/O Status Register 1 - Contains information on the status of the timers and of the
HSI.
IOC0 I/O Control Register 0 - Controls alternate functions of HSI pins, Timer 2 reset
sources and Timer 2 clock sources.
IOC1 I/O Control Register 1 - Controls alternate functions of Port 2 pins, timer interrupts
and HSI interrupts.
PWMÐCONTROL Pulse Width Modulation Control Register - Sets the duration of the PWM pulse.
INTÐPEND1 Interrupt Pending register for the 8 new interrupt vectors (also INTÐPENDING1)
INTÐMASK1 Interrupt Mask register for the 8 new interrupt vectors
IOC2 I/O Control Register 2 - Controls new 80C196KB features
IOS2 I/O Status Register 2 - Contains information on HSO events
WSR Window Select Register - Selects register window
Figure 2-4. Special Function Register Description
6
80C196KB USER’S GUIDE
Programming control and test operations are done in in Window 15. (Timer2 was read-only on the 8096.)
Window 14. Registers in this window that are not la- Registers which can be read and written in Window 0
beled should be considered reserved and should not be can also be read and written in Window 15.
either read or written.
Figure 2-4 contains brief descriptions of the SFR regis-
In register Window 15 (WSR e 15), the operation of ters. Detailed descriptions are contained in the section
the SFRs is changed, so that those which were read- which discusses the peripheral controlled by the regis-
only in Window 0 space are write-only and vice versa. ter. Figure 2-5 contains a description of the alternate
The only major exception to this is that Timer2 is read/ function in Window 15.
write in Window 0, and T2 Capture is read/write
Being able to write to the read-only registers and vice-versa provides a lot of flexibility. One of the most useful
advantages is the ability to set the timers and HSO lines for initial conditions other than zero.
7
80C196KB USER’S GUIDE
Within the SFR space are several registers and bit loca- change the contents of this location. Refer to Section
tions labeled ‘‘RESERVED’’. These locations should 15.2 for more information about bus contention during
never be written or read. A reserved bit location should CCB fetch.
always be written with 0 to maintain compatibility with
future parts. Values read from these locations may
change from part to part or over temperature and volt- FFFFH
EXTERNAL MEMORY
age. Registers and bits which are not labeled should be OR I/O
treated as reserved registers and bits. Note that the de- 4000H
fault state of internal registers is 0, while that for exter- INTERNAL PROGRAM
nal memory is 1. This is because SFR functions are STORAGE ROM/EPROM
typically disabled with a zero, while external memory is OR
EXTERNAL MEMORY 2080H
typically erased to all 1s.
RESERVED 2074H–207FH
VOLTAGE LEVELS 2072H–2073H
Caution must be taken when using the SFRs as sources
of operations or as base or index registers for indirect or SIGNATURE WORD 2070H–2071H
8
80C196KB USER’S GUIDE
The 80C196KB provides a ROM/EPROM lock feature These are the same as the names for the general data
to allow the program to be locked against reading registers used in the 8086. It is important to note that in
and/or writing the internal program memory. In order the 80C196KB these are not dedicated registers but
to maintain security, code can not be executed out of merely the symbolic names assigned by the program-
the last three locations of internal ROM/EPROM if mer to an eight byte region within the on-board register
the lock is enabled. Details on this feature are in Sec- file.
tion 17.
This section provides information on writing programs WORDS are unsigned 16-bit variables which can take
to execute in the 80C196KB. Additional information on the values between 0 and 65535. Arithmetic and
can be found in the following documents: relational operators can be applied to WORD operands
but the result must be interpreted modulo 65536. Logi-
MCSÉ-96 MACRO ASSEMBLER USER’S GUIDE cal operations on WORDS are applied bitwise. Bits
Order Number 122048 (Intel Systems) within words are labeled from 0 to 15 with 0 being the
Order Number 122351 (DOS Systems) least significant bit. WORDS must be aligned at even
byte boundaries in the MCS-96 address space. The least
MCSÉ-96 UTILITIES USER’S GUIDE significant byte of the WORD is in the even byte ad-
Order Number 122049 (Intel Systems) dress and the most significant byte is in the next higher
Order Number 122356 (DOS Systems) (odd) address. The address of a word is the address of
its least significant byte. Word operations to odd ad-
PL/M-96 USER’S GUIDE dresses are not guaranteed to operate in a consistent
Order Number 122134 (Intel Systems) manner.
Order Number 122361 (DOS Systems)
9
80C196KB USER’S GUIDE
10
80C196KB USER’S GUIDE
INDIRECT REFERENCES
The indirect mode is used to access an operand by plac- file. The register which contains the indirect address is
ing its address in a WORD variable in the register file. selected by an eight bit field within the instruction. An
The calculated address must conform to the alignment instruction can contain only one indirect reference and
rules for the operand type. Note that the indirect ad- the remaining operands of the instruction (if any) must
dress can refer to an operand anywhere within the ad- be register-direct references.
dress space of the 80C196KB, including the register
Examples
LD AX,[AX] ; AX:4MEM WORD(AX)
ADDB AL,BL,[CX] ; AL:4BL0MEM BYTE(CX)
POP [AX] ; MEM WORD(AX):4MEM WORD(SP); SP:4SP02
This addressing mode is the same as the indirect mode SHORT-INTEGERS the indirect address variable will
except that the WORD variable which contains the in- be incremented by one. If the instruction operates on
direct address is incremented after it is used to address WORDS or INTEGERS the indirect address variable
the operand. If the instruction operates on BYTES or will be incremented by two.
Examples
LD AX,[BX]0 ; AX:4MEM WORD(BX); BX:4BX02
ADDB AL,BL,[CX]0 ; AL:4BL0MEM BYTE(CX); CX:4CX01
PUSH [AX]0 ; SP:4SP12;
; MEM WORD(SP):4MEM WORD(AX)
; AX:4AX02
IMMEDIATE REFERENCES
This addressing mode allows an operand to be taken INTEGER operands the field is 16 bits wide. An in-
directly from a field in the instruction. For operations struction can contain only one immediate reference and
on BYTE or SHORT-INTEGER operands this field is the remaining operand(s) must be register-direct refer-
eight bits wide. For operations on WORD or ences.
Examples
ADD AX,#340 ; AX:4AX0340
PUSH #1234H ; SP:4SP12; MEM WORD(SP):41234H
DIVB AX,#10 ; AL:4AX/10; AH:4AX MOD 10
SHORT-INDEXED REFERENCES
In this addressing mode an eight bit field in the instruc- Since the eight bit field is sign-extended, the effective
tion selects a WORD variable in the register file which address can be up to 128 bytes before the address in the
contains an address. A second eight bit field in the in- WORD variable and up to 127 bytes after it. An in-
struction stream is sign-extended and summed with the struction can contain only one short-indexed reference
WORD variable to form the address of the operand and the remaining operand(s) must be register-direct
which will take part in the calculation. references.
Examples
LD AX,12[BX] ; AX:4MEM WORD(BX012)
MULB AX,BL,3[CX] ; AX:4BL*MEM BYTE(CX03)
11
80C196KB USER’S GUIDE
LONG-INDEXED REFERENCES
This addressing mode is like the short-indexed mode struction can contain only one long-indexed reference
except that a 16-bit field is taken from the instruction and the remaining operand(s) must be register-direct
and added to the WORD variable to form the address references.
of the operand. No sign extension is necessary. An in-
Examples
AND AX,BX,TABLE[CX] ; AX:4BX AND MEM WORD(TABLE0CX)
ST AX,TABLE[BX] ; MEM WORD(TABLE0BX):4AX
ADDB AL,BL,LOOKUP[CX] ; AL:4BL0MEM BYTE(LOOKUP0CX)
The first two bytes in the register file are fixed at zero variable in a long-indexed reference. This combination
by the 80C196KB hardware. In addition to providing a of register selection and address mode allows any loca-
fixed source of the constant zero for calculations and tion in memory to be addressed directly.
comparisons, this register can be used as the WORD
Examples
ADD AX,1234[0] ; AX:4AX0MEM WORD(1234)
POP 5678[0] ; MEM WORD(5678):4MEM WORD(SP)
; SP:4SP02
Examples
PUSH [SP] ; DUPLICATE TOP OF STACK
LD AX,2[SP] ; AX:4NEXT TO TOP
ASSEMBLY LANGUAGE ADDRESSING MODES These features of the assembly language simplify the
programming task and should be used wherever possi-
The MCS-96 assembly language simplifies the choice of
ble.
addressing modes to be used in several respects:
Direct Addressing. The assembly language will choose
between register-direct addressing and long-indexed 3.3 Program Status Word
with the ZERO register depending on where the oper-
and is in memory. The user can simply refer to an oper- The program status word (PSW) is a collection of Boo-
and by its symbolic name: if the operand is in the regis- lean flags which retain information concerning the state
ter file, a register-direct reference will be used, if the of the user’s program. There are two bytes in the PSW;
operand is elsewhere in memory, a long-indexed refer- the actual status word and the low byte of the interrupt
ence will be generated. mask. Figure 3-1 shows the status bits of the PSW. The
PSW can be saved in the system stack with a single
Indexed Addressing. The assembly language will operation (PUSHF) and restored in a like manner
choose between short and long indexing depending on (POPF). Only the interrupt section of the PSW can be
the value of the index expression. If the value can be accessed directly. There is no SFR for the PSW status
expressed in eight bits then short indexing will be used, bits.
if it cannot be expressed in eight bits then long indexing
will be used.
12
80C196KB USER’S GUIDE
CONDITION FLAGS VT: The oVerflow Trap flag is set when the V flag is
set, but it is only cleared by the CLRVT, JVT and
The PSW bits on the 80C196KB are set as follows: JNVT instructions. The operation of the VT flag
allows for the testing for a possible overflow con-
7 6 5 4 3 2 1 0 dition at the end of a sequence of related arithme-
PSW: tic operations. This is normally more efficient
Z N V VT C X I ST than testing the V flag after each instruction.
Figure 3-1. PSW Register C: The Carry flag is set to indicate the state of the
arithmetic carry from the most significant bit of
Z: The Z (Zero) flag is set to indicate that the opera-
the ALU for an arithmetic operation, or the state
tion generated a result equal to zero. For the add-
of the last bit shifted out of an operand for a shift.
with-carry (ADDC) and subtract-with-borrow
Arithmetic Borrow after a subtract operation is
(SUBC) operations the Z flag is cleared if the re-
the complement of the C flag (i.e. if the operation
sult is non-zero but is never set. These two in-
generated a borrow then C e 0.)
structions are normally used in conjunction with
the ADD and SUB instructions to perform multi- X: Reserved. Should always be cleared when writing
ple precision arithmetic. The operation of the Z to the PSW for compatibility with future prod-
flag for these instructions leaves it indicating the ucts.
proper result for the entire multiple precision cal- I: The global Interrupt disable bit disables all inter-
culation. rupts when cleared except NMI, TRAP, and un-
N: The Negative flag is set to indicate that the opera- implemented opcode.
tion generated a negative result. Note that the N ST: The ST (STicky bit) flag is set to indicate that
flag will be in the algebraically correct state even during a right shift a 1 has been shifted first into
if an overflow occurs. For shift operations, includ- the C flag and then been shifted out. The ST flag
ing the normalize operation and all three forms is undefined after a multiply operation. The ST
(SHL, SHR, SHRA) of byte, word and double flag can be used along with the C flag to control
word shifts, the N flag will be set to the same rounding after a right shift. Consider multiplying
value as the most significant bit of the result. This two eight bit quantities and then scaling the result
will be true even if the shift count is 0. down to 12 bits:
V: The oVerflow flag is set to indicate that the opera-
tion generated a result which is outside the range MULUB AX,CL,DL ;AX:4CL*DL
for the destination data type. For the SHL, SHLB SHR AX,#4 ;Shift right 4
and SHLL instructions, the V flag will be set if the places
most significant bit of the operand changes at any
time during the shift. For divide operations, the If the C flag is set after the shift, it indicates that the
following conditions are used to determine if the V bits shifted off the end of the operand were greater-than
flag is set: or equal-to one half the least significant bit (LSB) of the
result. If the C flag is clear after the shift, it indicates
For the
that the bits shifted off the end of the operand were less
operation: V is set if Quotient is:
than half the LSB of the result. Without the ST flag,
UNSIGNED the rounding decision must be made on the basis of the
BYTE DIVIDE l 255(0FFH) C flag alone. (Normally the result would be rounded up
if the C flag is set.) The ST flag allows a finer resolution
UNSIGNED in the rounding decision:
WORD DIVIDE l 65535(0FFFFH)
13
80C196KB USER’S GUIDE
The MCS-96 instruction set contains a full set of arith- The execution times for the instruction set are given in
metic and logical operations for the 8-bit data types Figure 3-3. These times are given for a 16-bit bus with
BYTE and SHORT INTEGER and for the 16-bit data no wait states. On-chip EPROM/ROM space is a 16-
types WORD and INTEGER. The DOUBLE-WORD bit, zero wait state bus. When executing from an 8-bit
and LONG data types (32 bits) are supported for the external memory system or adding wait states, the CPU
products of 16-by-16 multiplies and the dividends of becomes bus limited and must sometimes wait for the
32-by-16 divides, for shift operations, and for 32-bit prefetch queue. The performance penalty for an 8-bit
compares. The remaining operations on 32-bit variables external bus is difficult to measure, but has shown to be
can be implemented by combinations of 16-bit opera- between 10 and 30 percent based on the instruction
tions. As an example the sequence: mix. The best way to measure code performance is to
actually benchmark the code and time it using an emu-
ADD AX,CX lator or with TIMER1.
ADDC BX,DX
The indirect and indexed instruction timings are given
performs a 32-bit addition, and the sequence for two memory spaces: SFR/Internal RAM space (0 –
0FFH), and a memory controller reference (100H –
SUB AX,CX 0FFFFH). Any instruction that uses an operand that is
SUBC BX,DX referenced through the memory controller (ex. Add
r1,5000H [0] ) takes 2 – 3 states longer than if the oper-
performs a 32-bit subtraction. Operations on REAL and was in the SFR/Internal RAM space. Any data
(i.e. floating point) variables are not supported directly access to on-chip ROM/EPROM is considered to be a
by the hardware but are supported by the floating point memory controller reference.
library for the 80C196KB (FPAL-96) which imple-
ments a single precision subset of draft 10 of the IEEE Flag Settings. The modification to the flag setting is
standard for floating point arithmetic. The performance shown for each instruction. A checkmark (&) means
of this software is significantly improved by the that the flag is set or cleared as appropriate. A hyphen
80C196KB NORML instruction which normalizes a means that the flag is not modified. A one or zero (1) or
32-bit variable and by the existence of the ST flag in the (0) indicates that the flag will be in that state after the
PSW. u
instruction. An up arrow ( ) indicates that the in-
struction may set the flag if it is appropriate but will
In addition to the operations on the various data types, v
not clear the flag. A down arrow ( ) indicates that the
the 80C196KB supports conversions between these flag can be cleared but not set by the instruction. A
types. LDBZE (load byte zero extended) converts a question mark (?) indicates that the flag will be left in
BYTE to a WORD and LDBSE (load byte sign extend- an indeterminant state after the operation.
ed) converts a SHORT-INTEGER into an INTEGER.
14
80C196KB USER’S GUIDE
LD/LDB 2 DwA b b b b b b
ST/STB 2 AwD b b b b b b
POP 1 A w (SP); SP a 2 b b b b b b
SCALL 1 SP w SP b 2; b b b b b b 5
(SP) w PC; PC w PC a 11-bit offset
LCALL 1 SP w SP b 2; (SP) w PC; b b b b b b 5
PC w PC a 16-bit offset
15
80C196KB USER’S GUIDE
J (conditional) 1 PC
b w PC a 8-bit offset (if taken) b b b b b b 5
JC 1 Jump if C e 1 b b b b b b 5
JNC 1 jump if C e 0 b b b b b b 5
JE 1 jump if Z e 1 b b b b b b 5
JNE 1 Jump if Z e 0 b b b b b b 5
JGE 1 Jump if N e 0 b b b b b b 5
JLT 1 Jump if N e 1 b b b b b b 5
JGT 1 Jump if N e 0 and Z e 0 b b b b b b 5
JLE 1 Jump if N e 1 or Z e 1 b b b b b b 5
JH 1 Jump if C e 1 and Z e 0 b b b b b b 5
JNH 1 Jump if C e 0 or Z e 1 b b b b b b 5
JV 1 Jump if V e 1 b b b b b b 5
JNV 1 Jump if V e 0 b b b b b b 5
JVT 1 Jump if VT e 1; Clear VT b b b b 0 b 5
JNVT 1 Jump if VT e 0; Clear VT b b b b 0 b 5
JST 1 Jump if ST e 1 b b b b b b 5
JNST 1 Jump if ST e 0 b b b b b b 5
JBS 3 Jump if Specified Bit e 1 b b b b b b 5,6
JBC 3 Jump if Specified Bit e 0 b b b b b b 5,6
DJNZ/ 1 D w D b 1; b b b b b b 5
DJNZW If D i 0 then PC w PC a 8-bit offset 10
DEC/DECB 1 D wDb1 & & & & u b
CLR/CLRB 1 Dw0 1 0 0 0 b b
CLRC 0 Cw0 b b 0 b b b
16
80C196KB USER’S GUIDE
RST 0 PC w 2080H 0 0 0 0 0 0 8
DI 0 Disable All Interupts (I w 0) b b b b b b
NOP 0 PC w PC a 1 b b b b b b
SKIP 0 PC w PC a 2 b b b b b b
NOTES:
1. If the mnemonic ends in ‘‘B’’ a byte operation is performed, otherwise a word operation is done. Operands D, B, and A
must conform to the alignment rules for the required operand type. D and B are locations in the Register File; A can be
located anywhere in memory.
2. D,D a 2 are consecutive WORDS in memory; D is DOUBLE-WORD aligned.
3. D,D a 1 are consecutive BYTES in memory; D is WORD aligned.
4. Changes a byte to word.
5. Offset is a 2’s complement number.
6. Specified bit is one of the 2048 bits in the register file.
7. The ‘‘L’’ (Long) suffix indicates double-word operation.
8. Initiates a Reset by pulling RESET low. Software should re-initialize all the necessary registers with code starting at
2080H.
9. The assembler will not accept this mnemonic.
10. The DJNZW instruction is not guaranteed to work. See Functional Deviations section.
17
80C196KB USER’S GUIDE
NOTES:
1. Indirect and indirect a share the same opcodes, as do short and long indexed opcodes. If the second byte is even, use
indirect or short indexed. If odd, use indirect or long indexed.
2. The opcodes for signed multiply and divide are the unsigned opcode with an ‘‘FE’’ prefix.
18
80C196KB USER’S GUIDE
19
80C196KB USER’S GUIDE
NOTE:
1. The DJNZW instruction is not guaranteed to work. See Functional Deviations section.
21
80C196KB USER’S GUIDE
3.5 80C196KB Instruction Set language and PLM-96 environment and it offers com-
Additions and Differences patibility between these environments. Another advan-
tage is that it allows the user access to the same floating
For users already familiar with the 8096BH, there are point arithmetics library that PLM-96 uses to operate
six instructions added to the standard MCS-96 instruc- on REAL variables.
tion set to form the 80C196KB instruction set. All of
the former instructions perform the same function, ex-
REGISTER UTILIZATION
cept as indicated in the next section. The new instruc-
tions and their descriptions are listed below: The MCS-96 architecture provides a 256 byte register
PUSHA Ð PUSHes the PSW, INTÐMASK, IM- file. Some of these registers are used to control register-
ASK1, and WSR mapped I/O devices and for other special functions
POPA Ð POPs the PSW, INTÐMASK, IMASK1, such as the ZERO register and the stack pointer. The
and WSR remaining bytes in the register file, some 230 of them,
are available for allocation by the programmer. If these
IDLPD Ð Sets the part into IDLE or Powerdown registers are to be used effectively, some overall strategy
mode for their allocation must be adopted. PLM-96 adopts
CMPL Ð Compare 2 long direct values the simple and effective strategy of allocating the eight
BMOV Ð Block move using 2 auto-incrementing bytes between addresses 1CH and 23H as temporary
pointers and a counter storage. The starting address of this region is called
PLMREG. The remaining area in the register file is
DJNZW Ð Decrement Jump Not Zero using a Word treated as a segment of memory which is allocated as
counter (Not functional on current step- required.
ping.)
22
80C196KB USER’S GUIDE
When this procedure is entered at run time the stack It is recommended that unused areas of code be filled
will contain the parameters in the following order: with NOPs and periodic jumps to an error routine or
RST (reset chip) instructions. This is particularly im-
portant in the code around lookup tables, since if look-
?????? : param1
up tables are executed undesired results will occur.
high word of param2 Wherever space allows, each table should be surround-
ed by 7 NOPs (the longest 80C196KB instruction has 7
low word of param2 bytes) and a RST or jump to error routine instruction.
param3 Since RST is a one-byte instruction, the NOPs are not
needed if RSTs are used instead of jumps to an error
return address w StackÐpointer routine. This will help to ensure a speedy recovery
Figure 3-5. Stack Image should the processor have a glitch in the program flow.
If a procedure returns a value to the calling code (as The Watchdog Timer (WDT) further protects against
opposed to modifying more global variables) then the software and hardware errors. When using the WDT to
result is returned in the variable PLMREG. PLMREG protect software it is desirable to reset it from only one
is viewed as either an 8-, 16- or 32-bit variable depend- place in code, lessening the chance of an undesired
ing on the type of the procedure. WDT reset. The section of code that resets the WDT
should monitor the other code sections for proper oper-
The standard calling convention adopted by PLM-96 ation. This can be done by checking variables to make
has several key features: sure they are within reasonable values. Simply using a
software timer to reset the WDT every 10 milliseconds
a) Procedures can always assume that the eight bytes of will provide protection only for catastrophic failures.
register file memory starting at PLMREG can be
used as temporaries within the body of the proce-
dure.
4.0 PERIPHERAL OVERVIEW
b) Code which calls a procedure must assume that the
eight bytes of register file memory starting at There are five major peripherals on the 80C196KB: the
PLMREG are modified by the procedure. pulse-width-modulated output (PWM), Timer1 and
c) The Program Status Word (PSWÐsee Section 3.3) is Timer2, High Speed I/O Unit, Serial Port and A/D
not saved and restored by procedures so the calling Converter. With the exception of the high speed I/O
code must assume that the condition flags (Z, N, V, unit (HSIO), each of the peripherals is a single unit that
VT, C, and ST) are modified by the procedure. can be discussed without further separation.
d) Function results from procedures are always re- Four individual sections make up the HSIO and work
turned in the variable PLMREG. together to form a very flexible timer/counter based
I/O system. Included in the HSIO are a 16-bit timer
PLM-96 allows the definition of INTERRUPT proce- (Timer1), a 16-bit up/down counter (Timer2), a pro-
dures which are executed when a predefined interrupt grammable high speed input unit (HSI), and a pro-
occurs. These procedures do not conform to the rules of grammable high speed output unit (HSO). With very
a normal procedure. Parameters cannot be passed to little CPU overhead the HSIO can measure pulse
these procedures and they cannot return results. Since widths, generate waveforms, and create periodic inter-
they can execute essentially at any time (hence the term rupts. Depending on the application, it can perform the
interrupt), these procedures must save the PSW and work of up to 18 timer/counters and capture/compare
PLMREG when they are entered and restore these val- registers.
ues before they exit.
A brief description of the peripheral functions and in-
terractions is included in this section. It provides over-
3.7 Software Protection Hints view information prior to the detailed discussions in the
following sections. All of the details on control bits and
Several features to assist in recovery from hardware precautions are in the individual sections for each pe-
and software errors are available on the 80C196KB. ripheral starting with Section 5.
Protection is also provided against executing unimple-
mented opcodes by the unimplemented opcode inter-
rupt. In addition, the hardware reset instruction (RST)
can cause a reset if the program counter goes out of
bounds. This instruction has an opcode of 0FFH, so if
the processor reads in bus lines which have been pulled
high it will reset itself.
23
80C196KB USER’S GUIDE
4.1 Pulse Width Modulation Output HSIÐTIME register. When the time register is read
(D/A) the next FIFO location is loaded into the holding regis-
ter.
Digital to analog conversion can be done with the Pulse
Width Modulation output. The output waveform is a Three forms of HSI interrupts can be generated: when a
variable duty cycle pulse which repeats every 256 state value moves from the FIFO into the holding register;
times or 512 state times if the prescaler is enabled. when the FIFO (independent of the holding register)
Changes in the duty cycle are made by writing to the has 4 or more events stored; and when the FIFO has 6
PWM register. There are several types of motors which or more events stored. This flexibility allows optimiza-
require a PWM waveform for most efficient operation. tion of the HSI for the expected frequency of interrupts.
Additionally, if this waveform is integrated it will pro-
duce a DC level which can be changed in 256 steps by Independent of the HSI operation, the state of the HSI
varying the duty cycle. Details on the PWM are in Sec- pins is indicated by 4 bits of the HSIÐSTATUS regis-
tion 6. ter. Also independent of the HSI operation is the HSI.0
pin interrupt, which can be used as an extra external
interrupt even if the pin is not enabled to the HSI unit.
4.2 Timers
Two 16-bit timers are available for use on the 4.4 High Speed Outputs (HSO)
80C196KB. The first is designated ‘‘Timer1’’, the sec-
ond ‘‘Timer2’’. Timer1 is used to synchronize events to The High Speed Output (HSO) unit can generate events
real time, while Timer2 is clocked externally and syn- at specified times or counts based on Timer1 or Timer2
chronizes events to external occurrences. The timers with minimal CPU overhead. A block diagram of the
are the time bases for the High Speed Input (HSI) and HSO unit is shown in Figure 4-4. Up to 8 pending
High Speed Output (HSO) units and can be considered events can be stored in the CAM (Content Addressable
an integral part of the HSI/O. Details on the timers are Memory) of the HSO unit at one time. Commands are
in Section 7. placed into the HSO unit by first writing to HSOÐ
COMMAND with the event to occur, and then to
Timer1 is a free-running timer which is incremented HSOÐTIME with the timer match value.
every eight state times, just as it is on the 8096BH.
Timer1 can cause an interrupt when it overflows. Fourteen different types of events can be triggered by
the HSO: 8 external and 6 internal. There are two inter-
Timer2 counts transitions, both positive and negative, rupt vectors associated with the HSO, one for external
on its input which can be either the T2CLK pin or the events, and one for internal events. External events con-
HSI.1 pin. Timer2 can be read and written and can be sist of switching one or more of the 6 HSO pins
reset by hardware, software or the HSO unit. It can be (HSO.0-HSO.5). Internal events include setting up 4
used as an up/down counter based on Port 2.6 and it’s Software Timers, resetting Timer2, and starting an A/
value can be captured into the T2CAPture register. In- D conversion. The software timers are flags that can be
terrupts can be generated on capture events and if Tim- set by the HSO and optionally cause interrupts. Details
er2 crosses the 0FFFFH/0000H boundary or the on the HSO Unit are in Section 9.
7FFFH/8000H boundary in either direction.
24
80C196KB USER’S GUIDE
270651 – 18
270651 – 19
25
80C196KB USER’S GUIDE
26
80C196KB USER’S GUIDE
Twenty-eight (28) sources of interrupts are available on Three special interrupts are available on the
the 80C196KB. These sources are gathered into 15 vec- 80C196KB: NMI, TRAP and Unimplemented opcode.
tors plus special vectors for NMI, the TRAP instruc- The external NMI pin generates an unmaskable inter-
tion, and Unimplemented Opcodes. Figure 5-1 shows rupt for implementation of critical interrupt routines.
the routing of the interrupt sources into their vectors as The TRAP instruction is useful in the development of
well as the control bits which enable some of the custom software debuggers or generation of software
sources. interrupts. The unimplemented opcode interrupt gener-
ates an interrupt when unimplemented opcodes are exe-
270651 – 9
27
80C196KB USER’S GUIDE
cuted. This provides software recovery from random The programmer must initialize the interrupt vector ta-
execution during hardware and software failures. Al- ble with the starting addresses of the appropriate inter-
though available for customer use, these interrupts may rupt service routines. It is suggested that any unused
be used in Intel development tools or evaluation boards. interrupts be vectored to an error handling routine. In a
debug environment, it may be desirable to have the rou-
tine lock into a jump to self loop which would be easily
NMI traceable with emulation tools. More sophisticated rou-
tines may be appropriate for production code recover-
NMI, the external Non-Maskable Interrupt, is the
ies.
highest priority interrupt. It vectors indirectly through
location 203EH. For design symmetry, a mask bit ex-
ists in INTÐMASK1 for the NMI. To prevent acci-
dental masking of an NMI, the bit does not function
and will not stop an NMI from occurring. For future
compatibility, the NMI mask bit must be set to zero.
TRAP
Opcode 0F7H, the TRAP instruction, causes an indi- 270651 – 10
rect vector through location 2010H. The TRAP in-
Figure 5-2. 80C196KB Interrupt Structure
struction provides a single instruction interrupt useful
in designing software debuggers. The TRAP instruc- Block Diagram
tion prevents the acknowledgement of interrupts until
after execution of the next instruction. Five registers control the operation of the interrupt sys-
tem: INTÐPEND, INTÐPEND1, INTÐMASK and
INTÐMASK1 and the PSW which contains a global
Unimplemented Opcode disable bit. A block diagram of the system is shown in
Figure 5-2. The transition detector looks for 0 to 1 tran-
Opcodes which are not implemented on the 80C196KB sitions on any of the sources. External sources have a
will cause an indirect vector through location 2012H. maximum transition speed of one edge every state time.
User code or hardware which may have failed and run Sampling will be guaranteed if the level on the interrupt
into an unimplemented opcode can software recover line is held for at least one state time. If the interrupt
through this interrupt. The DJNZW instruction is not line is not held for at least one state time, the interrupt
supported on the 80C196KB but remains a valid op- may not be detected.
code, therefore, no interrupt will occur.
28
80C196KB USER’S GUIDE
5.1 Interrupt Control format of these registers is the same as that of the Inter-
rupt Pending Register shown in Figure 5-3.
Interrupt Pending Register The INTÐMASK and INTÐMASK1 registers can be
read or written as byte registers. A one in any bit posi-
When the hardware detects one of the sixteen inter-
tion will enable the corresponding interrupt source and
rupts it sets the corresponding bit in one of two pending
a zero will disable the source. The hardware will save
interrupt registers (INTÐPEND-09H and INTÐ
any interrupts that occur by setting bits in the pending
PEND1-12H). When the interrupt vector is taken, the
register, even if the interrupt mask bit is cleared. The
pending bit is cleared. These registers, the formats of
INTÐMASK register is the lower eight bits of the
which are shown in Figure 5-3, can be read or modified
PSW so the PUSHF and POPF instructions save and
as byte registers. They can be read to determine which
restore the INTÐMASK register as well as the global
of the interrupts are pending at any given time or modi-
interrupt lockout and the arithmetic flags. Both the
fied to either clear pending interrupts or generate inter-
INTÐMASK and INTÐMASK1 registers can be
rupts under software control. Any software which
saved with the PUSHA and POPA Instructions.
modifies the INTÐPEND registers should ensure that
the entire operation is inseparable. The easiest way to
do this is to use the logical instructions in the two or Global Disable
three operand format, for example:
The processing of all interrupts except the NMI, TRAP
ANDB INT PEND,#11111101B and unimplemented opcode interrupts can be disabled
; Clears the A/D Interrupt by clearing the I bit in the PSW. Setting the I bit will
ORB INT PEND,#00000010B enable interrupts that have mask register bits which are
; Sets the A/D Interrupt set. The I bit is controlled by the EI (Enable Interrupts)
and DI (Disable Interrupts) instructions. Note that the
Caution must be used when writing to the pending reg- I bit only controls the actual servicing of interrupts.
ister to clear interrupts. If the interrupt has already Interrupts that occur during periods of lockout will be
been acknowledged when the bit is cleared, a 5 state held in the pending register and serviced on a priori-
time ‘‘partial’’ interrupt cycle will occur. This is be- tized basis when the lockout period ends.
cause the 80C196KB will have to fetch the next instruc-
tion of the normal instruction flow, instead of proceed-
ing with the interrupt processing. The effect on the pro- 5.2 Interrupt Priorities
gram will be essentially that of an extra two NOPs.
This can be prevented by clearing the bits using a 2 The priority encoder looks at all of the interrupts which
operand immediate logical, as the 80C196KB holds off are both pending and enabled, and selects the one with
acknowledging interrupts during these ‘‘read/modify/ the highest priority. The priorities are shown in Figure
write’’ instructions. 5-4 (15 is highest, 0 is lowest). The interrupt generator
then forces a call to the location in the indicated vector
location. This location would be the starting location of
Interrupt Mask Register the Interrupt Service Routine (ISR).
Individual interrupts can be enabled or disabled by set-
ting or clearing bits in the interrupt mask registers
(INTÐMASK-08H and INTÐMASK1-13H). The
7 6 5 4 3 2 1 0
12H IPEND1: FIFO EXT T2 T2
NMI HSI4 RI TI
13H IMASK1: FULL INT1 OVF CAP
7 6 5 4 3 2 1 0
09H IPEND: EXT SER SOFT HSI.0 HSO HSI A/D TIMER
08H IMASK: INT PORT TIMER PIN PIN DATA DONE OVF
Figure 5-3. Interrupt Mask and Pending Registers
29
80C196KB USER’S GUIDE
serial io isr:
PUSHA ; Save the PSW, INT MASK
; INT MASK1, and WSR
LDB INT MASK,#00000100B
EI ; Enable interrupts again
;
;
;
; Service the interrupt
;
;
;
POPA
– ; Restore
RET
30
80C196KB USER’S GUIDE
Notice that the ‘‘preamble’’ and exit code for the inter- if interrupts are disabled. Depending on system config-
rupt service routine does not include any code for sav- urations, several other SFRs might also need to be
ing or restoring registers. This is because it has been changed in a single instruction for the same reason.
assumed that the interrupt service routine has been al-
located its own private set of registers from the on- When variables must be modified without interruption,
board register file. The availability of some 230 bytes of and a single instruction can not be used, the program-
register storage makes this quite practical. mer must create what is termed a critical region in
which it is safe to modify the variable. One way to do
this is to simply disable interrupts with a DI instruc-
5.3 Critical Regions tion, perform the modification, and then re-enable in-
terrupts with an EI instruction. The problem with this
Interrupt service routines must sometimes share data approach is that it leaves the interrupts enabled even if
with other routines. Whenever the programmer is cod- they were not enabled at the start. A better solution is
ing those sections of code which access these shared to enter the critical region with a PUSHF instruction
pieces of data, great care must be taken to ensure that which saves the PSW and also clears the interrupt en-
the integrity of the data is maintained. Consider clear- able flags. The region can then be terminated with a
ing a bit in the interrupt pending register as part of a POPF instruction which returns the interrupt enable to
non-interrupt routine: the state it was in before the code sequence. It should be
noted that some system configurations might require
LDB AL,INT PEND more protection to form a critical region. An example
ANDB AL,#bit mask is a system in which more than one processor has ac-
STB AL,INT PEND cess to a common resource such as memory or external
I/O devices.
This code works if no other routines are operating con-
currently, but will cause occasional but serious prob-
lems if used in a concurrent environment. (All pro- 5.4 Interrupt Timing
grams which make use of interrupts must be considered
to be part of a concurrent environment.) To demon- The 80C196KB can be interrupted from four different
strate this problem, assume that the INTÐPEND reg- external sources; NMI, P2.2, HSI.0 and P0.7. All exter-
ister contains 00001111B and bit 3 (HSO event inter- nal interrupts are sampled during PH1 or CLKOUT
rupt pending) is to be reset. The code does work for this low and are latched internally. Holding levels on exter-
data pattern but what happens if an HSI interrupt oc- nal interrupts for at least one state time will ensure
curs somewhere between the LDB and the STB instruc- recognition of the interrupts.
tions? Before the LDB instruction INTÐPEND con-
tains 00001111B and after the LDB instruction so does The external interrupts on the 80C196KB, although
AL. If the HSI interrupt service routine executes at this sampled during PH1, are edge triggered interrupts as
point then INTÐPEND will change to 00001011B. opposed to level triggered. Edge triggered interrupts
The ANDB changes AL to 00000111B and the STB will generate only one interrupt if the input is held
changes INTÐPEND to 00000111B. It should be high. On the other hand, level triggered interrupts will
00000011B. This code sequence has managed to gener- generate multiple interrupts when held high.
ate a false HSI interrupt The same basic process can
generate an amazing assortment of problems and head- Interrupts are not always acknowledged immediately.
aches. These problems can be avoided by assuring mu- If the interrupt signal does not occur prior to 4 state-
tual exclusion which basically means that if more than times before the end of an instruction, the interrupt
one routine can change a variable, then the program- may not be acknowledged until after the next instruc-
mer must ensure exclusive access to the variable during tion has been executed. This is because an instruction is
the entire operation on the variable. fetched and prepared for execution a few state times
before it is actually executed.
In many cases the instruction set of the 80C196KB al-
lows the variable to be modified with a single instruc- There are 6 instructions which always inhibit interrupts
tion. The code in the above example can be implement- from being acknowledged until after the next instruc-
ed with a single instruction. tion has been executed. These instructions are:
EI, DI Ð Enable and disable all interrupts by tog-
ANDB INT PEND,#bit mask gling the global disable bit (PSW.9).
Instructions are indivisible so mutual exclusion is en- PUSHF Ð PUSH Flags pushes the PSW/INTÐ
sured in this case. Changes to the INTÐPEND or MASK pair then clears it, leaving both
INTÐPEND1 register must be made as a single in- INTÐMASK and PSW.9 clear.
struction, since bits can be changed in this register even
31
80C196KB USER’S GUIDE
POPF Ð POP Flags pops the PSW/INTÐMASK following EI. The DI, PUSHF, POPF, PUSHA, POPA
pair off the stack and TRAP instructions will also cause the same situa-
PUSHA Ð PUSH All does a PUSHF, then pushes tion. Typically these instructions would only effect la-
the INTÐMASK1/WSR pair and clears tency when one interrupt routine is already in process,
INTÐMASK1 as these instructions are seldom used at other times.
POPA Ð POP All pops the INTÐMASK1/WSR
pair and then does a POPF
5.5 Interrupt Summary
Interrupts can also not occur immediately after execu- Many of the interrupt vectors on the 8096BH were
tion of: shared by multiple interrupts. The interrupts which
Unimplemented Opcodes were shared on the 8096BH are: Transmit Interrupt,
TRAP Ð The software trap instruction Receive Interrupt, HSI FIFO Full, Timer2 Overflow
and EXTINT. On the 80C196KB, each of these inter-
SIGND Ð The signed prefix for multiply and divide rupts have their own interrupt vectors. The source of
instructions the interrupt vectors are typically programmed through
control registers. These registers can be read in Win-
When an interrupt is acknowledged the interrupt pend- dow 15 to determine the source of any interrupt. Inter-
ing bit is cleared, and a call is forced to the location rupt sources with two possible interrupt vectors, serial
indicated by the specified interrupt vector. This call oc- receive interrupt sharing serial port and receive inter-
curs after the completion of the instruction in process, rupt vectors for example, should be configured for only
except as noted above. The procedure of getting the one interrupt vector.
vector and forcing the call requires 16 state times. If the
stack is in external RAM an additional 2 state times are Interrupts with separate vectors include: NMI, TRAP,
required. Unimplemented Opcode, Timer2 Capture, 4th Entry
into HSI FIFO, Software timer, HSI.0 Pin, High Speed
The maximum number of state times required from the Outputs, and A/D conversion Complete. The NMI,
time an interrupt is generated (not acknowledged) until TRAP and Unimplemented Opcode interrupts were
the 80C196KB begins executing code at the desired lo- covered in section 5.0.
cation is the time of the longest instruction, NORML
(Normalize Ð 39 state times), plus the 4 state times
prior to the end of the previous instruction, plus the EXTINT and P0.7
response time (16(internal stack) or 18(external stack)
state times). Therefore, the maximum response time is The 80C196KB has two external interrupt vectors;
61 (39 a 4 a 18) state times. This does not include the EXTINT (200EH) and EXTINT1 (203AH). The
10 state times required for PUSHF if it is used as the EXTINT vector has two alternate sources selectable by
first instruction in the interrupt routine or additional IOC1.1, the external interrupt pin (Port 2.2) and Port
latency caused by having the interrupt masked or dis- 0.7. The external interrupt pin is the only source for the
abled. Refer to Figure 5-5, Interrupt Response Time, to EXTINT1 interrupt vector. The external interrupt pin
visualize an example of worst case scenario. should not be programmed to interrupt through both
vectors. Both external interrupt sources are rising edge
Interrupt latency time can be reduced by careful selec- triggered.
tion of instructions in areas of code where interrupts
are expected. Using ‘EI’ followed immediately by a
long instruction (e.g. MUL, NORML, etc.) will in-
crease the maximum latency by 4 state times, as an
interrupt cannot occur between EI and the instruction
270651 – 11
32
80C196KB USER’S GUIDE
Serial Port Interrupts are individually enabled by setting bits 2 and 3 of IOC1:
bit 2 for Timer1, and bit 3 for Timer2. Which timer
The serial port generates one of three possible inter- actually caused the interrupt can be determined by bits
rupts: Transmit interrupt TI(2030H), Receive Interrupt 4 and 5 of IOS1: bit 4 for Timer2 and 5 for Timer1. On
RI(2032H) and SERIAL(200CH). Refer to section 10 the 80C196KB Timer2 overflow(0H or 8000H) has a
for information on the serial port interrupts. The separate interrupt vector through location 2038H.
8096BH shared the TI and RI interrupts on the SERI-
AL interrupt vector. On the 80C196KB, these inter-
rupts share both the serial interrupt vector and have Timer2 Capture
their own interrupt vectors. Ideally, the transmit and The 80C196KB can generate an interrupt in response
receive interrupts should be programmed as separate to a Timer2 capture triggered by a rising edge on P2.7.
interrupt vectors while disabling the SERIAL inter- Timer2 Capture vectors through location 2036H.
rupt. For 8096BH compatibility, the interrupts can still
use the SERIAL interrupt vector.
High Speed Outputs
HSI FIFO FULL and HSI DATA AVAILABLE The High Speed Outputs interrupt can be generated in
response to a programmed HSO command which caus-
HSI FIFO FULL and HSI DATA AVAILABLE in- es an external event. HSO commands which set or clear
terrupts shared the HSI DATA AVAILABLE inter- the High Speed Output pins are considered external
rupt vector on the 8096BH. The source of the HSI events. Status Register IOS2 indicates which HSO
DATA AVAILABLE interrupt is controlled by the events have occured and can be used to arbitrate which
setting of I/O Control Register 1,(IOC1.7). Setting HSO command caused the interrupt. The High Speed
IOC1.7 to zero will generate an interrupt when a time Output interrupt vectors indirectly through location
value is loaded into the holding register. Setting the bit 2006H. For more information on High Speed Outputs,
to one generates an interrupt when the FIFO, indepen- refer to Section 9.
dent of the holding register, has six entries in it.
33
80C196KB USER’S GUIDE
270651 – 13
34
80C196KB USER’S GUIDE
270651 – 14
270651 – 15
270651 – 16
35
80C196KB USER’S GUIDE
36
80C196KB USER’S GUIDE
270651 – 5
Bit e 1 Bit e 0
IOC0.1 Reset Timer2 each write No action
IOC0.3 Enable external reset Disable
IOC0.5 HSI.0 is ext. reset source T2RST is reset source
IOC0.7 HSI.1 is T2 clock source T2CLK is clock source
IOC1.3 Enable Timer2 overflow int. Disable overflow interrupt
IOC2.0 Enable fast increment Disable fast increment
IOC2.1 Enable downcount feature Disable downcount
P2.6 Count down if IOC2.1 e 1 Count up
IOC2.5 Interrupt on 7FFFH/8000H Interrupt on 0FFFFH/0000H
P2.7 Capture Timer2 into
T2CAPture on rising edge
Figure 7-2. Timer2 Configuration and Control Pins
7.4 Timer Interrupts
Both Timer1 and Timer2 can trigger a timer overflow
interrupt and set a flag in the I/O Status Register 1
(IOS1). Timer1 overflow is controlled by setting
IOC1.2 and the interrupt status is indicated in IOS1.5.
The TIMER OVERFLOW interrupt is enabled by set-
ting INTÐMASK.0.
A Timer2 overflow condition interrupts through loca-
tion 2000H by setting IOC1.3 and setting INTÐ
MASK.0. Alternatively, Timer2 overflow can interrupt
through location 2038H by setting INTÐMASK1.3.
The status of the Timer2 overflow interrupt is indicated
in IOS1.4.
Interrupts can be generated if Timer2 crosses the
270651 – 17
0FFFFH/0000H boundary or the 7FFFH/8000H
Figure 7-3. Timer2 Clock and Reset Options boundary in either direction. By having two interrupt
points it is possible to have interrupts enabled even if
37
80C196KB USER’S GUIDE
Timer2 is counting up and down centered around one timer interrupts are controlled by the Interrupt Mask
of the interrupt points. The boundaries used to control Register bit 0. In all cases, setting a bit enables a func-
the Timer2 interrupt is determined by the setting of tion, while clearing a bit disables it.
IOC2.5. When set, Timer2 will interrupt on the
7FFFH/8000H boundary, otherwise, the 0FFFFH/
0000H boundary interrupts. 8.0 HIGH SPEED INPUTS
A T2CAPTURE interrupt is enabled by setting INTÐ The High Speed Input Unit (HSI) can record the time
MASK1.3. The interrupt will vector through location an event occurs with respect to Timer1. There are 4
2036H. lines (HSI.0 through HSI.3) which can be used in this
mode and up to a total of 8 events can be recorded.
Caution must be used when examining the flags, as any HSI.2 and HSI.3 are bidirectional pins which can also
access (including Compare and Jump on Bit) of IOS1 be used as HSO.4 and HSO.5. The I/O Control Regis-
clears bits 0 through 5 including the software timer ters (IOC0 and IOC1) determine the functions of these
flags. It is, therefore, recommended to copy the byte to pins. The values programmed into IOC0 and IOC1 can
a temporary register before testing bits. Writing to be read in Window 15. A block diagram of the HSI unit
IOS1 in Window 15 will set the status bits but not cause is shown in Figure 8-1.
interrupts. The general enabling and disabling of the
270651 – 18
270651 – 19
270651 – 22
38
80C196KB USER’S GUIDE
There are 4 possible modes of operation for each of the Figure 8-4. IOC0 Control of HSI Pin Functions
HSI pins. The HSIÐMODE register at location 03H
controls which pins will look for what type of events. In
Window 15, reading the register will read back the pro-
8.2 HSI Status
grammed HSI mode. The 8-bit register is set up as Bits 6 and 7 of the I/O Status Register 1 (IOS1Ðsee
shown in Figure 8-3. Figure 8-5) indicate the status of the HSI FIFO. If bit 7
is set, the HSI holding register is loaded. The FIFO
may or may not contain 1 – 5 events. If bit 6 is set, the
FIFO contains 6 entries. If the FIFO fills, future events
will not be recorded. Reading IOS1 clears bits 0 – 5, so
keep an image of the register and test the image to
retain all 6 bits.
Reading the HSI holding register must be done in a
certain order. The HSIÐSTATUS Register (Figure 8-
2) is read first to obtain the status and input bits. Sec-
ond, the HSIÐTIME Register (04H) is read to obtain
the time tag. Reading HSIÐTIME unloads one level of
the FIFO. If the HSIÐTIME is read before
HSIÐSTATUS, the contents of HSIÐSTATUS associ-
ated with that HSIÐTIME tag are lost.
270651 – 20
39
80C196KB USER’S GUIDE
If the HSIÐTIME register is read without the holding The HSI.0 pin can generate an interrupt on the rising
register being loaded, the returned value will be indeter- edge even if its not enabled to the HSI FIFO. An inter-
minate. Under the same conditions, the four bits in rupt generated by this pin vectors through location
HSIÐSTATUS indicating which events have occurred 2008H.
will also be indeterminate. The four HSIÐSTATUS
bits which indicate the current state of the pins will
always return the correct value. 8.4 HSI Input Sampling
It should be noted that many of the Status register con- The HSI pins are sampled internally once each state
ditions are changed by a reset, see section 13. Writing time. Any value on these pins must remain stable for at
to HSIÐTIME in window 15 will write to the HSI least 1 full state time to guarantee that it is recognized.
FIFO holding register. Writing to HSIÐSTATUS in The actual sampling occurs during PH1 or during
Window 15 will set the status bits but will not affect the CLKOUT low. The HSI inputs should be valid at least
input bits. 30 nsec before the rising of CLKOUT. Otherwise, the
HSI input may be sampled in the next CLKOUT.
Therefore, if information is to be synchronized to the
8.3 HSI Interrupts HSI it should be latched on the rising edge of
CLKOUT.
Interrupts can be generated by the HSI unit in three
ways: when a value moves from the FIFO into the
holding register; when the FIFO (independent of the 8.5 Initializing the HSI
holding register) has 4 or more event stored; when the
FIFO has 6 or more events. To start the HSI, the following steps and the sequence
must be observed; 1) flush the FIFO, 2) enable the HSI
The HSI DATA AVAILABLE and HSI FIFO FULL interrupts, and 3) initialize and enable the HSI pins.
interrupts are shared on the 8096BH. The source for The following section of code can be used to flush the
the HSI DATA AVAILABLE interrupt is controlled FIFO:
by IOC1.7. When IOC1.7 is cleared, the HSI will gen-
erate an interrupt when the holding register is loaded. reflush: ld 0, HSI TIME ;clear an event
The interrupt indicates at least one HSI event has oc- skip0 ;wait 8 state times
curred and is ready to be processed. The interrupt vec- skip0
tors through location 2004H. The interrupt is enabled jbs IOS1, 7, reflush
by setting INTÐMASK.2. The generation of a HSI
DATA AVAILABLE interrupt will set IOS1.7. The Enabling the HSI pins before enabling the interrupts
HSI FIFO FULL interrupt will vector through HSI can cause a FIFO lockout condition. For example, if
DATA AVAILABLE if IOC1.7 is set. On the the HSI pins were enabled first, an event could get
80C196KB, the HSI FIFO FULL has a separate inter- loaded into the holding register before the HSIÐ
rupt vector at location 203CH. DATAÐAVAILABLE interrupt is enabled. If this
happens, no HSIÐDATAÐAVAILABLE interrupts
A HSI FIFO FULL interrupt occurs when the HSI will ever occur.
FIFO has six or more entries loaded independent of the
holding register. Since all interrupts are rising edge trig-
gered, the processor will not be reinterrupted until the 9.0 HIGH SPEED OUTPUTS
FIFO first contains 5 or less records, then contains six
or more. The HSI FIFO FULL interrupt mask bit is The High Speed Output unit (HSO) trigger events at
INTÐMASK1.6. The occurrence of a HSI FIFO specific times with minimal CPU overhead. Events are
FULL interrupt is indicated by IOS1.6. Earlier warning generated by writing commands to the HSOÐCOM-
of a impending FIFO full condition can be achieved by MAND register and the relative time at which the
the HSI FIFO 4th Entry interrupt. events are to occur into the HSOÐTIME register. In
Window 15, these registers will read the last value pro-
The HSIÐFIFOÐ4 interrupt generates an interrupt grammed in the holding register. The programmable
when four or more events are stored in the HSI FIFO events include: starting an A/D conversion, resetting
independent of the holding register. The interrupt is Timer2, setting 4 software flags, and switching 6 output
enabled by setting INTÐMASK1.2. The HSIÐ lines (HSO.0 through HSO.5). The format of the
FIFOÐ4 vectors indirectly through location 2034H. HSOÐCOMMAND register is shown in Figure 9-1.
There is no status flag associated with the HSIÐ Commands 0CH and 0DH are reserved for use on fu-
FIFOÐ4 interrupt since it has its own independent in- ture products. Up to eight events can be pending at one
terrupt vector. time and interrupts can be generated whenever any of
these events are triggered. HSO.4 and HSO.5 are bi-
40
80C196KB USER’S GUIDE
7 6 5 4 3 2 1 0
HSOÐ CAM TMR2/ SET/ INT/
CHANNEL 06H
COMMAND LOCK TMR1 CLEAR INT
CAM Lock Ð Locks event in CAM if this is enabled by IOC2.6 (ENAÐLOCK)
TMR/TMR1 Ð Events Based on Timer2/Based on Timer1 if 0
SET/CLEAR Ð Set HSO pin/Clear HSO pin if 0
INT/INT Ð Cause interrupt/No interrupt if 0
CHANNEL: 0–5: HSO pins 0–5 separately
(in Hex) 6: HSO pins 0 and 1 together
7: HSO pins 2 and 3 together
8–B: Software Timers 0 – 3
C–D: Unflagged Events (Do not use for future compatibility)
E: Reset Timer2
F: Start A to D Conversion
directional pins which are multiplexed with HSI.2 and HSO Interrupt Status
HSI.3 respectively. Bits 4 and 6 of I/O Control Regis-
ter 1 (IOC1.4, IOC1.6) enable HSO.4 and HSO.5 as Register IOS2 at location 17H displays the HSO events
outputs. The Control Registers can be read in Window which have occurred. IOS2 is shown in Figure 9-2. The
15 to determine the programmed modes for the HSO. events displayed are HSO.0 through HSO.5, Timer2
However, the IOC2.7(CAM CLEAR) bit is not latched Reset and start of an A/D conversion. IOS2 is cleared
and will read as a one. Entries can be locked in the when accessed, therefore, the register should be saved
CAM to generate periodic events or waveforms. in an image register if more than one bit is being tested.
The status register is useful in determining which
events have caused an HSO generated interrupt. Writ-
9.1 HSO Interrupts and Software ing to this register in Window 15 will set the status bits
Timers but not cause interrupts. In Window 15, writing to
IOS2 can set the High Speed Output lines to an initial
The HSO unit can generate two types of interrupts. The value. Refer to Section 2.2 for more information on
High Speed Output execution interrupt can be generat- Window 15.
ed (if enabled) for HSO commands which change one
or more of the six output pins. The other HSO inter-
rupt is the interrupt which can be generated by any
other HSO command, (e.g. triggering the A/D, reset-
ting Timer2 or generating a software time delay).
IOS2: 7 6 5 4 3 2 1 0
START T2
HSO.5 HSO.4 HSO.3 HSO.2 HSO.1 HSO.0
A/D RESET
17H
read Indicates which HSO event occcured
START A/D: HSOÐCMD 15, start A/D
T2RESET: HSOÐCMD 14, Timer2 Reset
HSO.0–5: Output pins HSO.0 through HSO.5
41
80C196KB USER’S GUIDE
42
80C196KB USER’S GUIDE
270651 – 25 270651 – 26
Figure 9-4. I/O Status Register 0 Figure 9-5. I/O Status Register 1 (IOS1)
Writing the time value loads the HSO Holding Register this register in Window 15. The format for I/O Status
with both the time and the last written command tag. Register 0 is shown in Figure 9-4.
The command does not actually enter the CAM file
until an empty CAM register becomes available. The expiration of software timer 0 through 4, and the
overflow of Timer1 and Timer2 are indicated in IOS1.
Commands in the holding register will not execute even The status bits can be set in Window 15 but not cause
if their time tag is reached. Commands must be in the interrupts. The register is shown in Figure 9-5.
CAM to execute. Commands in the holding register
can also be overwritten. Since it can take up to 8 state Whenever the processor reads this register all of the
times for a command to move from the holding register time-related flags (bits 5 through 0) are cleared. This
to the CAM, 8 states must be allowed between succes- applies not only to explicit reads such as:
sive writes to the CAM.
LDB AL,IOS1
To provide proper synchronization, the minimum time
that should be loaded to Timer1 is Timer1 a 2. Small- but also to implicit reads such as:
er values may cause the Timer match to occur 65,636
counts later than expected. A similar restriction applies JBS IOS1,3,somewhere else
if Timer2 is used.
which jumps to somewhereÐelse if bit 3 of IOS1 is set.
Care must be taken when writing the command tag for In most cases this situation can best be handled by hav-
the HSO, because an interrupt can occur between writ- ing a byte in the register file which maintains an image
ing the command tag and loading the time value. If the of the register. Any time a hardware timer interrupt or
interrupt service routine writes to the HSO, the com- a HSO software timer interrupt occurs the byte can be
mand tag used in the interrupt routine will overwrite updated:
the command tag from the main routine. One way of
avoiding this problem would be to disable interrupts ORB IOS1 image,IOS1
when writing to the HSO unit.
leaving IOS1Ðimage containing all the flags that were
set before plus all the new flags that were read and
9.3 HSO Status cleared from IOS1. Any other routine which needs to
sample the flags can safely check IOS1Ðimage. Note
Before writing to the HSO, it is desirable to ensure that that if these routines need to clear the flags that they
the Holding Register is empty. If it is not, writing to the have acted on, then the modification of IOS1Ðimage
HSO will overwrite the value in the Holding Register. must be done from inside a critical region.
I/O Status Register 0 (IOS0) bits 6 and 7 indicate the
status of the HSO unit. If IOS0.6 equals 0, the holding
register is empty and at least one CAM register is emp- 9.4 Clearing the HSO and Locked
ty. If IOS0.7 equals 0, the holding register is empty. Entries
The programmer should carefully decide which of these
two flags is the best to use for each application. This All 8 CAM locations of the HSO are compared before
register also shows the current status of the HSO.0 any action is taken. This allows a pending external
through HSO.5. The HSO pins can be set by writing to
43
80C196KB USER’S GUIDE
event to be cancelled by simply writing the opposite be carefully done. The user should ensure writing to
event to the CAM. However, once an entry is placed in Timer1 will not cause programmed HSO events to be
the CAM, it cannot be removed until either the speci- missed or occur in the wrong order. The same precau-
fied timer matches the written value , a chip reset oc- tion applies to Timer2.
curs or IOC2.7 is set. IOC2.7 is the CAM clear bit
which clears all entries in the CAM. The HSO requires at least eight state times to compare
each entry in the CAM. Therefore, the fast increment
Internal events cannot be cleared by writing an oppo- mode for Timer2 cannot be used as a reference for the
site event. This includes events on HSO channels 8 HSO if transitions occur faster then once every eight
through F. The only method for clearing these events state times.
are by a reset or setting IOC2.7.
Referencing events when Timer2 is being used as an
up/down counter could cause events to occur in oppo-
HSO LOCKED ENTRIES site order or be missed entirely. Additionally, locked
The CAM Lock bit (HSOÐCommand.7) can be set to entries could possibly occur several times if Timer2 is
keep commands in the CAM, otherwise the commands oscillating around the time tag for an entry.
will clear from the CAM as soon as they cause an
event. This feature allows for generation periodic events When using Timer2 as the HSO reference, caution
based on Timer2 and must be enabled by setting must be taken that Timer2 is not reset prior to the
IOC2.6. To clear locked events from the CAM, the en- highest value for a Timer2 match in the CAM. If that
tire CAM can be cleared by writing a one to the CAM match is never reached, the event will remain pending
clear bit IOC2.7. A chip reset will also clear the CAM. in the CAM until the part is reset or CAM is cleared.
44
80C196KB USER’S GUIDE
reprogrammed in addition to the Timer2 reset com- er changes every eight state times during Phase1. From
mand. This method provides for up to four PWM’s an external perspective the HSO pin should change just
with no software overhead except when reprogramming prior to the falling edge of CLKOUT and be stable by
the duty cycle of any particular PWM. The code to its rising edge. Information from the HSO can be
generate these PWMs is shown in Figure 9-6. latched on the CLKOUT rising edge. Internal events
also occur when the reference timer increments.
9.7 HSO Output Timing
Changes in the HSO lines are synchronized to either 10.0 SERIAL PORT
Timer1 or Timer2. All of the external HSO lines due to
change at a certain value of a timer will change just The serial port on the 80C196KB has one synchronous
after the incrementing of the timer. Internally, the tim- and 3 asynchronous modes. The asynchronous modes
$include (reg196.inc)
; **********************************************************
; *
; * GENERATION OF FOUR PWM’S USING LOCKED ENTRIES *
; *
; * Timer2 is used as a reference and is clocked *
; * externally by T2CLK. The High Speed outputs are *
; * used as PWMs by programming each individual *
; * PWM(low) and PWM(High) time as a locked entry. *
; * The period of the PWM is programmed by resetting *
; * timer2 and setting all the HSO lines high at the *
; * same time. The PWMs are reprogrammed by *
; * clearing the HSO CAM and reloading new values *
; * for the PWM period and duty cycle. *
; *
; **********************************************************
RSEG at 60h
pwm0timl: dsw 1
pwm1timl: dsw 1
pwm2timl: dsw 1
pwm3timl: dsw 1
PWM period: dsw 1
temp: dsw 1
cseg at 2080h
ld sp,#0d0h ; initialize stack pointer
ld PWM period,#0f000h ; intialize pwm period
ld pwm0timl,#2000h ; initialize pwm 0-3 duty cycle
ld pwm1timl,#4000h
ld pwm2timl,#6000h
ld pwm3timl,#8000h
ldb ioc2,#40h ; Enable locked entries
ldb ioc0,#0h ; Enable t2clk for timer2 clock
; source
call pwm program ; program pwm’s on CAM
here: sjmp here ; loop forever
45
80C196KB USER’S GUIDE
pwm program:
ldb ioc2,#0c0h ; flush entire cam
ldb hso command,#0ceh ; program timer2 reset time
ld hso time,PWM period
nop ; delay eight state times before
nop ; next load
nop
nop
ldb hso command,#0e6h ; HSO 0/1 high, locked, timer2 as
; reference
ld hso time,PWM period ; set hso high on t2rst
nop
nop
nop
nop
ldb hso command,#0e7h ; HSO 2/3 high, locked, timer2
; as reference
ld hso time,PWM period ; set hso high on t2rst
nop
nop
nop
nop
ldb hso command,#0c0h ; set HSO.0 low, locked, timer2
; as reference
ld hso time,pwm0timl ; HSO.0 time low
nop
nop
nop
nop
ldb hso command,#0c1h ; set HSO.1 low, locked, timer2
; reference
ld hso time,pwm1timl ; HSO.1 time low
nop
nop
nop
nop
ldb hso command,#0c2h ; set HSO.2 low, locked,timer2
; as reference
ld hso time,pwm2timl ; HSO.2 time low
nop
nop
nop
nop
ldb hso command,#0c3h ; set HSO.3 low, locked,timer2
; as reference
ld hso time,pwm3timl ; HSO.3 time low
ret
end
46
80C196KB USER’S GUIDE
are full duplex, meaning they can transmit and receive reading it accesses SPÐSTAT. The upper 3 bits of
at the same time. The receiver is double buffered so that SPÐCON must be written as 0s for future compatibil-
the reception of a second byte can begin before the first ity. On the 80C196KB the SPÐSTAT register contains
byte has been read. The transmitter on the 80C196KB new bits to indicate receive Overrun Error (OE), Fram-
is also double buffered allowing continuous transmis- ing Error (FE), and Transmitter Empty (TXE). The
sions. The port is functionally compatible with the seri- bits which were also present on the 8096BH are the
al port on the MCS-51 family of microcontrollers, al- Transmit Interrupt (TI) bit, the Receive Interrupt (RI)
though the software controlling the ports is different. bit, and the Received Bit 8 (RB8) or Receive Parity
Error (RPE) bit. SPÐSTAT is read-only in Window 0
Data to and from the serial port is transferred through and is shown in Figure 10-1.
SBUF(RX) and SBUF(TX), both located at 07H.
SBUF(TX) holds data ready for transmission and In all modes, the RI flag is set after the last data bit is
SBUF(RX) contains data received by the serial port. sampled, approximately in the middle of a bit time.
SBUF(TX) and SBUF(RX) can be read and can be Data is held in the receive shift register until the last
written in Window 15. data bit is received, then the data byte is loaded into
SBUF (RX). The receiver on the 80C196KB also
Mode 0, the synchronous shift register mode, is de- checks for a valid stop bit. If a stop bit is not found
signed to expand I/O over a serial line. Mode 1 is the within the appropriate time, the Framing Error (FE)
standard 8 bit data asynchronous mode used for normal bit is set.
serial communications. Modes 2 and 3 are 9 bit data
asynchronous modes typically used for interprocessor Since the receiver is double-buffered, reception on a
communications. Mode 2 provides monitoring of a second data byte can begin before the first byte is read.
communication line for a 1 in the 9th bit position before However, if data in the shift register is loaded into
causing an interrupt. Mode 3 causes interrupts indepen- SBUF (RX) before the previous byte is read, the Over-
dant of the 9th bit value. flow Error (OE) bit is set. Regardless, the data in SBUF
(RX) will always be the latest byte received; it will nev-
er be a combination of the two bytes. The RI, FE, and
10.1 Serial Port Status and Control OE flags are cleared when SPÐSTAT is read. Howev-
er, RI does not have to be cleared for the serial port to
Control of the serial port is done through the Serial receive data.
Port Control (SPÐCON) register shown in Figure 10-
1. Writing to location 11H accesses SPÐCON while
SPÐCON: 7 6 5 4 3 2 1 0
X X X TB8 REN PEN M2 M1 11H
TB8 Ð Sets the ninth data bit for transmission. Cleared after each transmission. Not valid
if parity is enabled.
REN Ð Enables the receiver
PEN Ð Enables the Parity function (even parity)
M2, M1 Ð Sets the mode. Mode0 e 00, Mode1 e 01, Mode2 e 10, Mode3 e 11
SPÐSTAT 7 6 5 4 3 2 1 0
RB8/
RI TI FE TXE OE X X 11H
RPE
RB8 Ð Set if the 9th data bit is high on reception (parity disabled)
RPE Ð Set if parity is enabled and a parity error occurred
RI Ð Set after the last data bit is sampled
TI Ð Set at the beginning of the STOP bit transmission
FE Ð Set if no STOP bit is found at the end of a reception
TXE Ð Set if two bytes can be transmitted
OE Ð Set if the receiver buffer is overwritten
47
80C196KB USER’S GUIDE
The Transmitter Empty (TXE) bit is set if the transmit BAUD RATES
buffer is empty and ready to take up to two characters.
TXE gets cleared as soon as a byte is written to SBUF. Baud rates are generated based on either the T2CLK
Two bytes may be written consecutively to SBUF if pin or XTAL1 pin. The values used are different than
TXE is set. One byte may be written if TI alone is set. those used for the 8096BH because the 80C196KB uses
By definition, if TXE has just been set, a transmission a divide-by-2 clock instead of a divide-by-3 clock to
has completed and TI will be set. The TI bit is reset generate the internal timings. Baud rates are calculated
when the CPU reads the SPÐSTAT registers. using the following formulas where BAUDÐREG is
the value loaded into the baud rate register:
The TB8 bit is cleared after each transmission and both
TI and RI are cleared when SPÐSTAT read. The RI Asynchronous Modes 1, 2 and 3:
and TI status bits can be set by writing to SPÐSTAT in
window 15 but they will not cause an interrupt. Read- XTAL1 T2CLK
ing of SPÐCON in Window 15 will read the last value BAUDÐREG e b 1 OR
Baud Rate * 16 Baud Rate * 8
written. Whenever the TXD pin is used for the serial
port it must be enabled by setting IOC1.5 to a 1. I/O
Synchronous Mode 0:
control register 1 can be read in window 15 to deter-
mine the setting.
XTAL1 T2CLK
BAUDÐREG e b 1 OR
Baud Rate * 2 Baud Rate
STARTING TRANSMISSIONS AND RECEPTIONS
The most significant bit in the baud register value is set
In Mode 0, if REN e 0, writing to SBUF (TX) will
to a one to select XTAL1 as the source. If it is a zero
start a transmission. Causing a rising edge on REN, or
the T2CLK pin becomes the source. The following ta-
clearing RI with REN e 1, will start a reception. Set-
ble shows some typical baud rate values.
ting REN e 0 will stop a reception in progress and
inhibit further receptions. To avoid a partial or com-
plete undesired reception, REN must be set to zero be- BAUD RATES AND BAUD REGISTER VALUES
fore RI is cleared. This can be handled in an interrupt
environment by using software flags or in straight-line Baud XTAL1 Frequency
code by using the Interrupt Pending register to signal Rate
8.0 MHz 10.0 MHz 12.0 MHz
the completion of a reception.
300 1666 / b 0.02 2082 / 0.02 2499 / 0.00
In the asynchronous modes, writing to SBUF (TX) 1200 416 / b 0.08 520 / b 0.03 624 / 0.00
starts a transmission. A falling edge on RXD will begin 2400 207 / 0.16 259 / 0.16 312 / b 0.16
a reception if REN is set to 1. New data placed in 4800 103 / 0.16 129 / 0.16 155 / 0.16
SBUF (TX) is held and will not be transmitted until the 9600 51 / 0.16 64 / 0.16 77 / 0.16
end of the stop bit has been sent. 19.2K 25 / 0.16 32 / 1.40 38 / 0.16
In all modes, the RI flag is set after the last data bit is Baud Register Value / % Error
sampled approximately in the middle of the bit time.
Also for all modes, the TI flag is set after the last data A maximum baud rate of 750 Kbaud is available in the
bit (either 8th or 9th) is sent, also in the middle of the asynchronous modes with 12 MHz on XTAL1. The
bit time. The flags clear when SPÐSTAT is read, but synchronous mode has a maximum rate of 3.0 Mbaud
do not have to be clear for the port to receive or trans- with a 12 MHz clock. Location 0EH is the Baud Regis-
mit. The serial port interrupt bit is set as a logical OR ter. It is loaded sequentially in two bytes, with the low
of the RI and TI bits. Note that changing modes will byte being loaded first. This register may not be loaded
reset the Serial Port and abort any transmission or re- with zero in serial port Mode 0.
ception in progress on the channel.
48
80C196KB USER’S GUIDE
10.2 Serial Port Interrupts mode the TXD pin outputs a set of 8 pulses while the
RXD pin either transmits or receives data. Data is
The serial port generates one of three possible inter- transferred 8 bits at a time with the LSB first. A dia-
rupts: Transmit Interrupt TI(2030H), Receive Inter- gram of the relative timing of these signals is shown in
rupt RI(2032H) and SERIAL(200CH). When the RI Figure 10-2. Note that this is the only mode which uses
bit gets set an interrupt is generated through either RXD as an output.
200CH or 2032H depending on which interrupt is en-
abled. INTÐMASK1.1 controls the serial port receive
interrupt through location 2032H and INTÐMASK.6 Mode 0 Timings
controls serial port interrupts through location 200CH. In Mode 0, the TXD pin sends out a clock train, while
The 8096BH shared the TI and RI interrupts on the the RXD pin transmits or receives the data. Figure 10-
SERIAL interrupt vector. On the 80C196KB, these in- 2 shows the waveforms and timing.
terrupts share both the serial interrupt vector and have
their own interrupt vectors. In this mode the serial port expands the I/O capability
of the 80C196KB by simply adding shift registers. A
When the TI bit is set it can cause an interrupt through schematic of a typical circuit is shown in Figure 10-3.
the vectors at locations 200CH or 2030. Interrupt This circuit inverts the data coming in, so it must be
through location 2030 is determined by INTÐ reinverted in software.
MASK1.0. Interrupts through the serial interrupt is
controlled by the same bit as the RI interrupt(INTÐ
MASK.6). The user should not mask off the serial port MODE 1
interrupt when using the double-buffered feature of the
transmitter, as it could cause a missed count in the Mode 1 is the standard asynchronous communications
number of bytes being transmitted. mode. The data frame used in this mode is shown in
Figure 10-4. It consists of 10 bits; a start bit (0), 8 data
bits (LSB first), and a stop bit (1). If parity is enabled
10.3 Serial Port Modes by setting SPCON.2, an even parity bit is sent instead
of the 8th data bit and parity is checked on reception.
MODE 0
Mode 0 is a synchronous mode which is commonly
used for shift register based I/O expansion. In this
270651 – 28
49
80C196KB USER’S GUIDE
270651 – 29
270651 – 30
270651 – 31
The transmit and receive functions are controlled by port will hold off transmission until the stop bit is com-
separate shift clocks. The transmit shift clock starts plete. RI is set when 8 data bits are received, not when
when the baud rate generator is initialized, the receive the stop bit is received. Note that when the serial port
shift clock is reset when a ‘1 to 0’ transition (start bit) is status register is read both TI and RI are cleared.
received. The transmit clock may therefore not be in
sync with the receive clock, although they will both be Caution should be used when using the serial port to
at the same frequency. connect more than two devices in half-duplex, (i.e. one
wire for transmit and receive). If the receiving proces-
The TI (Transmit Interrupt) and RI (Receive Inter- sor does not wait for one bit time after RI is set before
rupt) flags are set to indicate when operations are com- starting to transmit, the stop bit on the link could be
plete. TI is set when the last data bit of the message has corrupted. This could cause a problem for other devices
been sent, not when the stop bit is sent. If an attempt to listening on the link.
send another byte is made before the stop bit is sent the
50
80C196KB USER’S GUIDE
MODE 2 bit is set. Two types of frames are used: address frames
which have the 9th bit set and data frames which have
Mode 2 is the asynchronous 9th bit recognition mode. the 9th bit cleared. When the master processor wants to
This mode is commonly used with Mode 3 for multi- transmit a block of data to one of several slaves, it first
processor communications. Figure 10-4 shows the data sends out an address frame which identifies the target
frame used in this mode. It consists of a start bit (0), 9 slave. Slaves in Mode 2 will not be interrupted by a data
data bits (LSB first), and a stop bit (1). When transmit- frame, but an address frame will interrupt all slaves.
ting, the 9th bit can be set to a one by setting the TB8 Each slave can examine the received byte and see if it is
bit in the control register before writing to SBUF (TX). being addressed. The addressed slave switches to Mode
The TB8 bit is cleared on every transmission, so it must 3 to receive the coming data frames, while the slaves
be set prior to writing to SBUF (TX). During recep- that were not addressed stay in Mode 2 continue exe-
tion, the serial port interrupt and the Receive Interrupt cuting.
will not occur unless the 9th bit being received is set.
This provides an easy way to have selective reception
on a data link. Parity cannot be enabled in this mode. 11.0 A/D CONVERTER
Analog Inputs to the 80C196KB System are handled
MODE 3 by the A/D converter System. As shown in Figure
11-4, the converter system has an 8 channel multiplex-
Mode 3 is the asynchronous 9th bit mode. The data
er, a sample-and-hold, and a 10 bit successive approxi-
frame for this mode is identical to that of Mode 2. The
mation A/D converter. Conversions can be performed
transmission differences between Mode 3 and Mode 2
on one of eight channels, the inputs of which share pins
are that parity can be enabled (PEN e 1) and cause the
with port 0. A conversion can be done in as little as 91
9th data bit to take the even parity value. The TB8 bit state times.
can still be used if parity is not enabled (PEN e 0).
When in Mode 3, a reception always causes an inter- Conversions are started by loading the ADÐCOM-
rupt, regardless of the state of the 9th bit. The 9th bit is MAND register at location 02H with the channel num-
stored if PEN e 0 and can be read in bit RB8. If ber. The conversion can be started immediately by set-
PEN e 1 then RB8 becomes the Receive Parity Error ting the GO bit to a one. If it is cleared the conversion
(RPE) flag. will start when the HSO unit triggers it. The A/D com-
mand register must be written to for each conversion,
Mode 2 and 3 Timings even if the HSO is used as the trigger. The result of
the conversion is read in the ADÐRESULT(High)
Modes 2 and 3 operate in a manner similar to that of and ADÐRESULT(Low) registers. The ADÐRE-
Mode 1. The only difference is that the data is now SULT(High) contains the most significant eight bits of
made up of 9 bits, so 11-bit packages are transmitted the conversion. The ADÐRESULT(Low) register con-
and received. This means that TI and RI will be set on tains the remaining two bits and the A/D channel num-
the 9th data bit rather than the 8th. The 9th bit can be ber and A/D status. The format for the ADÐCOM-
used for parity or multiple processor communications. MAND register is shown in Figure 11-1. In Window
15, reading the ADÐCOMMAND register will read
the last command written. Writing to the ADÐRE-
10.4 Multiprocessor Communications SULT register will write a value into the result register.
51
80C196KB USER’S GUIDE
The A/D converter can cause an interrupt through the started. The upper byte of the result register contains
vector at location 2002H when it completes a conver- the most significant 8 bits of the conversion. The lower
sion. It is also possible to use a polling method by byte format is shown in Figure 11-2.
checking the Status (S) bit in the lower byte of the
ADÐRESULT register, also at location 02H. The At high crystal frequencies, more time is needed to al-
status bit will be a 1 while a conversion is in progress. It low the comparator to settle. For this reason IOC2.4 is
takes 8 state times to set this bit after a conversion is provided to adjust the speed of the A/D conversion by
disabling/enabling a clock prescaler.
270651 – 34
52
80C196KB USER’S GUIDE
11.1 A/D Conversion Process The total number of state times required for a conver-
sion is determined by the setting of IOC2.4 clock pre-
The conversion process is initiated by the execution of scaler bit. With the bit set the conversion time is 91
HSO command 0FH, or by writing a one to the GO Bit states and 158 states when the bit is cleared.
in the A/D Control Register. Either activity causes a
start conversion signal to be sent to the A/D converter
control logic. If an HSO command was used, the con- 11.2 A/D Interface Suggestions
version process will begin when Timer1 increments.
This aids applications attempting to approach spectral- The external interface circuitry to an analog input is
ly pure sampling, since successive samples spaced by highly dependent upon the application, and can impact
equal Timer1 delays will occur with a variance of about converter characteristics. In the external circuit’s de-
g 50 ns (assuming a stable clock on XTAL1). Howev- sign, important factors such as input pin leakage, sam-
er, conversions initiated by writing a one to the AD- ple capacitor size and multiplexer series resistance from
CON register GO Bit will start within three state times the input pin to the sample capacitor must be consid-
after the instruction has completed execution resulting ered.
in a variance of about 0.50 ms (XTAL1 e 12 MHz).
For the 80C196KB, these factors are idealized in Fig-
Once the A/D unit receives a start conversion signal, ure 11-5. The external input circuit must be able to
there is a one state time delay before sampling (Sample charge a sample capacitor (CS) through a series resist-
Delay) while the successive approximation register is ance (RI) to an accurate voltage given a D.C. leakage
reset and the proper multiplexer channel is selected. (IL). On the 80C196KB, CS is around 2 pF, RI is
After the sample delay, the multiplexer output is con- around 5 KX and IL is specified as 3 mA maximum. In
nected to the sample capacitor and remains connected determining the necessary source impedance RS, the
for 8 state times in fast mode or 15 state times for slow value of VBIAS is not important.
mode (Sample Time). After this 8/15 state time ‘‘sam-
ple window’’ closes, the input to the sample capacitor is
disconnected from the multiplexer so that changes on
the input pin will not alter the stored charge while the
conversion is in progress. The comparator is then auto-
zeroed and the conversion begins. The sample delay
and sample time uncertainties are each approximately
g 50 ns, independent of clock speed.
53
80C196KB USER’S GUIDE
Placing an external capacitor on each analog input will ANGND must be connected even if the A/D converter
also reduce the sensitivity to noise, as the capacitor is not being used. Remember that Port 0 receives its
combines with series resistance in the external circuit to power from the VREF and ANGND pins even when it
form a low-pass filter. In practice, one should include a is used as digital I/O.
small series resistance prior to the external capacitor on
the analog input pin and choose the largest capacitor
value practical, given the frequency of the signal being 11.3 The A/D Transfer Function
converted. This provides a low-pass filter on the input,
while the resistor will also limit input current during The conversion result is a 10-bit ratiometric representa-
over-voltage conditions. tion of the input voltage, so the numerical value ob-
tained from the conversion will be:
Figure 11-6 shows a simple analog interface circuit
based upon the discussion above. The circuit in the fig- INT [1023 c (VIN b ANGND)/(VREF b ANGND)].
ure also provides limited protection against over-volt-
age conditions on the analog input. Should the input This produces a stair-stepped transfer function when
voltage inappropriately drop significantly below the output code is plotted versus input voltage (see Fig-
ground, diode D2 will forward bias at about 0.8 DCV. ure 11-7). The resulting digital codes can be taken as
Since the specification of the pin has an absolute maxi- simple ratiometric information, or they provide infor-
mum low voltage of b 0.3V, this will leave about 0.5V mation about absolute voltages or relative voltage
across the 270X resistor, or about 2 mA of current. changes on the inputs. The more demanding the appli-
This should limit the current to a safe amount. cation is on the A/D converter, the more important it
is to fully understand the converter’s operation. For
However, before any circuit is used in an actual applica- simple applications, knowing the absolute error of the
tion, it should be thoroughly analyzed for applicability to converter is sufficient. However, closing a servo-loop
the specific problem at hand. with analog inputs necessitates a detailed understand-
ing of an A/D converter’s operation and errors.
54
80C196KB USER’S GUIDE
270651– 37
55
80C196KB USER’S GUIDE
270651– 38
56
80C196KB USER’S GUIDE
270651– 39
57
80C196KB USER’S GUIDE
scale reference minus 1.5 LSB; and it’s code widths are Undesired signals come from three main sources. First,
all exactly one LSB. These qualities result in a digitiza- noise on VCCÐVCC Rejection. Second, input signal
tion without offset, full-scale or linearity errors. In oth- changes on the channel being converted after the sam-
er words, a perfect conversion. ple window has closedÐFeedthrough. Third, signals
applied to channels not selected by the multiplexerÐ
Figure 11-8 shows an Actual Characteristic of a hypo- Off-Isolation.
thetical 3-bit converter, which is not perfect. When the
Ideal Characteristic is overlaid with the imperfect char- Finally, multiplexer on-channel resistances differ slight-
acteristic, the actual converter is seen to exhibit errors ly from one channel to the next causing Channel-to-
in the location of the first and final code transitions and Channel Matching errors, and random noise in general
code widths. The deviation of the first code transition results in Repeatability errors.
from ideal is called ‘‘zero offset’’, and the deviation of
the final code transition from ideal is ‘‘full-scale error’’.
The deviation of the code widths from ideal causes two 11.4 A/D Glossary of Terms
types of errors. Differential Non-Linearity and Non-
Linearity. Differential Non-Linearity is a local linearity Figures 11-7, 11-8, and 11-9 display many of these
error measurement, whereas Non-Linearity is an over- terms. Refer to AP-406 ‘MCS-96 Analog Acquisition
all linearity error measure. Primer‘ for additional information on the A/D terms.
Differential Non-Linearity is the degree to which actual ABSOLUTE ERRORÐThe maximum difference be-
code widths differ from the ideal one LSB width. It tween corresponding actual and ideal code transitions.
gives the user a measure of how much the input voltage Absolute Error accounts for all deviations of an actual
may have changed in order to produce a one count converter from an ideal converter.
change in the conversion result. Non-Linearity is the
worst case deviation of code transitions from the corre- ACTUAL CHARACTERISTICÐThe characteristic of
sponding code transitions of the Ideal Characteristic. an actual converter. The characteristic of a given con-
Non-Linearity describes how much Differential Non- verter may vary over temperature, supply voltage, and
Linearities could add up to produce an overall maxi- frequency conditions. An Actual Characteristic rarely
mum departure from a linear characteristic. If the Dif- has ideal first and last transition locations or ideal code
ferential Non-Linearity errors are too large, it is possi- widths. It may even vary over multiple conversion un-
ble for an A/D converter to miss codes or exhibit non- der the same conditions.
monotonicity. Neither behavior is desirable in a closed-
loop system. A converter has no missed codes if there BREAK-BEFORE-MAKEÐThe property of a multi-
exists for each output code a unique input voltage range plexer which guarantees that a previously selected
that produces that code only. A converter is monotonic channel will be deselected before a new channel is se-
if every subsequent code change represents an input lected. (e.g. the converter will not short inputs togeth-
voltage change in the same direction. er.)
58
80C196KB USER’S GUIDE
IDEAL CHARACTERISTICÐA characteristic with SAMPLE TIMEÐThe time that the sample window is
its first code transition at VIN e 0.5 LSB, its last code open.
transition at VIN e (VREF b 1.5 LSB) and all code
widths equal to one LSB. SAMPLE TIME UNCERTAINTYÐThe variation in
the sample time.
INPUT RESISTANCEÐThe effective series resistance
from the analog input pin to the sample capacitor. SAMPLE WINDOWÐBegins when the sample capac-
itor is attached to a selected channel and ends when the
LSBÐLEAST SIGNIFICANT BIT: The voltage value sample capacitor is disconnected from the selected
corresponding to the full scale voltage divided by 2n, channel.
where n is the number of bits of resolution of the con-
verter. For a 10-bit converter with a reference voltage SUCCESSIVE APPROXIMATIONÐAn A/D con-
of 5.12 volts, one LSB is 5.0 mV. Note that this is version method which uses a binary search to arrive at
different than digital LSBs, since an uncertainty of two the best digital representation of an analog input.
LSBs, when referring to an A/D converter, equals
10 mV. (This has been confused with an uncertainty of TEMPERATURE COEFFICIENTSÐChange in the
two digital bits, which would mean four counts, or stated variable per degree centigrade temperature
20 mV.) change. Temperature coefficients are added to the typi-
cal values of a specification to see the effect of tempera-
MONOTONICÐThe property of successive approxi- ture drift.
mation converters which guarantees that increasing in-
put voltages produce adjacent codes of increasing value, TERMINAL BASED CHARACTERISTICÐAn Ac-
and that decreasing input voltages produce adjacent tual Characteristic which has been rotated and translat-
codes of decreasing value. ed to remove zero offset and full-scale error.
NO MISSED CODESÐFor each and every output VCC REJECTIONÐAttenuation of noise on the VCC
code, there exists a unique input voltage range which line to the A/D converter.
produces that code only.
ZERO OFFSETÐThe difference between the expected
NON-LINEARITYÐThe maximum deviation of code and actual input voltage corresponding to the first code
transitions of the terminal based characteristic from the transition.
corresponding code transitions of the ideal characteris-
tics.
59
80C196KB USER’S GUIDE
12.0 I/O PORTS In addition to acting as a digital input, each line of Port
0 can be selected to be the input of the A/D converter
There are five 8-bit I/O ports on the 80C196KB. Some as discussed in Section 11. The capacitance on these
of these ports are input only, some are output only, pins is approximately 1 pF and will instantaneously in-
some are bidirectional and some have alternate func- crease by around 2 pF when the pin is being sampled by
tions. In addition to these ports, the HSI/O unit pro- the A/D converter.
vides extra I/O lines if the timer related features of
these lines are not needed. Port 0 pins are special in that they may individually be
used as digital inputs and analog inputs at the same
Port 0 is an input port which is also used as the analog time. A Port 0 pin being used as a digital input acts as
input for the A/D converter. Port 0 is read at location the high impedance input ports just described. Howev-
0EH. Port 1 is a quasi-bidirectional port and is read or er, Port 0 pins being used as analog inputs are required
written to through location 0FH. The three most signif- to provide current to the internal sample capacitor
icant bits of Port 1 are the control signals for the when a conversion begins. This means that the input
HOLD/HLDA bus port pins. Port 2 contains three characteristics of a pin will change if a conversion is
types of port lines: quasi-bidirectional, input and out- being done on that pin. In either case, if Port 0 is to be
put. Port2 is read or written from location 10H. The used as analog or digital I/O, it will be necessary to
ports cannot be read or written in Window 15. The provide power to this port through the VREF pin and
input and output lines are shared with other functions ANGND pins.
in the 80C196KB as shown in Figure 12-1. Ports 3 and
4 are open-drain bidirectional ports which share their Port 0 is only sampled when the SFR is read to reduce
pins with the address/data bus. On EPROM and ROM the noise in the A/D converter. The data must be stable
parts, Port 3 and 4 are read and written through loca- one state time before the SFR is read.
tion 1FFEH.
ALTERNATE CONTROL
PIN FUNC.
FUNCTION REG.
2.0 Output TXD (Serial Port Transmit) IOC1.5
2.1 Input RXD (Serial Port Receive) SPCON.3
P2.2 Input EXTINT IOC1.1
2.3 Input T2CLK (Timer2 Clock & Baud) IOC0.7
2.4 Input T2RST (Timer2 Reset) IOC0.5
2.5 Output PWM Output IOC1.0
2.6 QBD* Timer2 up/down select IOC2.1
2.7 QBD* Timer2 Capture N/A
*QBD e Quasi-bidirectional
Figure 12-1. Port 2 Multiple Functions
270651 – 76
While discussing the characteristics of the I/O pins
some approximate current or voltage specifications will NOTE:
be given. The exact specifications are available in the *Q1 and Q2 are ESD Protection Devices
latest version of the data sheet that corresponds to the
part being used. Figure 12-2. Input Port Structure
60
80C196KB USER’S GUIDE
270651 – 40
CHMOS Configuration. pFET 1 is turned on for 2 osc. periods after Q makes a 0-to-1 transition. During this time, pFET 1
also turns on pFET 3 through the inverter to form a latch which holds the 1. pFET 2 is also on.
the low impedance pullup will remain on for one state turns on for two oscillator periods. P2 remains on until
time after the change. a zero is written to the pin. P3 is used as a latch, so it is
turned on whenever the pin is above the threshold value
Port 1, Port 2.6 and Port 2.7 are quasi-bidirectional (around 2 volts).
ports. When the processor writes to the pins of a quasi-
bidirectional port it actually writes into a register which To reduce the amount of current which flows when the
in turn drives the port pin. When the processor reads pin is externally pulled low, P3 is turned off when the
these ports, it senses the status of the pin directly. If a pin voltage drops below the threshold. The current re-
port pin is to be used as an input then the software quired to pull the pin from a high to a low is at its
should write a one to its associated SFR bit, this will maximum just prior to the pull-up turning off. An ex-
cause the low-impedance pull-down device to turn off ternal driver can switch these pins easily. The maxi-
and leave the pin pulled up with a relatively high im- mum current required occurs at the threshold voltage
pedance pullup device which can be easily driven down and is approximately 700 microamps.
by the device driving the input.
When the Port 1 pins are used as their alternate func-
If some pins of a port are to be used as inputs and some tions (HOLD, HLDA, and BREQ), the pins act like a
are to be used as outputs the programmer should be standard output port.
careful when writing to the port.
Particular care should be exercised when using XOR HARDWARE CONNECTION HINTS
opcodes or any opcode which is a read-modify-write
When using the quasi-bidirectional ports as inputs tied
instruction. It is possible for a Quasi-Bidirectional Pin
to switches, series resistors may be needed if the ports
to be written as a one, but read back as a zero if an
will be written to internally after the part is initialized.
external device (i.e., a transistor base) is pulling the pin
The amount of current sourced to ground from each
below VIH.
pin is typically 7 mA or more. Therefore, if all 8 pins
are tied to ground, 56 mA will be sourced. This is
Quasi-bidirectional pins can be used as input and out- equivalent to instantaneously doubling the power used
put pins without the need for a data direction register. by the chip and may cause noise in some applications.
They output a strong low value and a weak high value.
The weak high value can be externally pulled low pro- This potential problem can be solved in hardware or
viding an input function. Figure 12-3 shows the config- software. In software, never write a zero to a pin being
uration of a CHMOS quasi-bidirectional port. used as an input.
Outputting a 0 on a quasi-bidirectional pin turns on the In hardware, a 1K resistor in series with each pin will
strong pull-down and turns off all of the pull-ups. limit current to a reasonable value without impeding
When a 1 is output the pull-down is turned off and 3 the ability to override the high impedance pullup. If all
pull-ups (strong-P1, weak-P3, very weak-P2) are turned 8 pins are tied together a 120X resistor would be rea-
on. Each time a pin switches from 0 to 1 transistor P1 sonable. The problem is not quite as severe when the
61
80C196KB USER’S GUIDE
inputs are tied to electronic devices instead of switches, the voltage present on the port pin. The second case can
as most external pulldowns will not hold 20 mA to 0.0 be taken care of in the software fairly easily:
volts.
LDB AL, IOPORT1
Writing to a Quasi-Bidirectional Port with electronic XORB AL, #010B
devices attached to the pins requires special attention. ORB AL, #001B
Consider using P1.0 as an input and trying to toggle STB AL, IOPORT1
P1.1 as an output:
A software solution to both cases is to keep a byte in
ORB IOPORT1, #00000001B ; Set P1.0 RAM as an image of the data to be output to the port;
; for input any time the software wants to modify the data on the
XORB IOPORT1, #00000010B ; Complement port it can then modify the image byte and copy it to
; P1.1 the port.
The first instruction will work as expected but two If a switch is used on a long line connected to a quasi-
problems can occur when the second instruction exe- bidirectional pin, a pullup resistor is recommended to
cutes. The first is that even though P1.1 is being driven reduce the possibility of noise glitches and to decrease
high by the 80C196KB it is possible that it is being held the rise time of the line. On extremely long lines that
low externally. This typically happens when the port are handling slow signals, a capacitor may be helpful in
pin drives the base of an NPN transistor which in turn addition to the resistor to reduce noise.
drives whatever there is in the outside world which
needs to be toggled. The base of the transistor will
clamp the port pin to the transistor’s Vbe above 12.3 Output Ports
ground, typically 0.7V. The 80C196KB will input this
value as a zero even if a one has been written to the port Output pins include the bus control lines, the HSO
pin. When this happens the XORB instruction will al- lines, and some of Port 2. These pins can only be used
ways write a one to the port pin’s SFR and the pin will as outputs as there are no input buffers connected to
not toggle. them. The output pins are output before the rising edge
of PH1 and is valid some time during PH1. Externally,
The second problem, which is related to the first, is that PH1 corresponds to CLKOUT low. It is not possible to
if P1.0 happens to be driven to a zero when Port 1 is use immediate logical instructions such as XOR to tog-
read by the XORB instruction, then the XORB will gle these pins.
write a zero to P1.0 and it will no longer be useable as
an input. The control outputs and HSO pins have output buffers
with the same output characteristics as those of the bus
The first situation can best be solved by the external pins. Included in the category of control outputs are:
driver design. A series resistor between the port pin and TXD, RXD (in Mode 0), PWM, CLKOUT, ALE,
the base of the transistor often works by bringing up BHE, RD, and WR. The bus pins have 3 states: output
high, output low, and high impedance. Figure 12-4
shows the internal configuration of an output pin.
270651 – 77
62
80C196KB USER’S GUIDE
12.4 Ports 3 and 4/AD0–15 be used as inputs. Reading Port 3 and 4 from a previ-
ously written zero condition is as follows . . .
These pins have two functions. They are either bidirec-
tional ports with open-drain outputs or System Bus LD intregA, #0FFFFH ; setup port
pins which the memory controller uses when it is ac- ; change mode
cessing off-chip memory. If the EA line is low, the pins ; pattern
always act as the System Bus. Otherwise they act as bus
pins only during a memory access. If these pins are ST intregA, 1FFEH ; register x
being used as ports and bus pins, ones must be written ; Port 3 and 4
to them prior to bus operations. ; LD & ST not
; needed if
Accessing Port 3 and 4 as I/O is easily done from inter- ; previously
nal registers. Since the LD and ST instructions require ; written as ones
the use of internal registers, it may be necessary to first
move the port information into an internal location be- LD intregB, 1FFEH ; register w
fore utilizing the data. If the data is already internal, ; Port 3 and 4
the LD is unnecessary. For instance, to write a word
value to Port 3 and 4 . . . Note that while the format of the LD and ST instruc-
tions are similar, the source and destination directions
LD intreg, portdata ; register w change.
; data
; not needed if When acting as the system bus the pins have strong
; already drivers to both VCC and VSS. These drivers are used
; internal whenever data is being output on the system bus and
are not used when data is being output by Ports 3 and
ST intreg, 1FFEH ; register x 4. The pins, external input buffers and pulldowns are
; Port 3 and 4 shared between the bus and the ports. The ports use
different output buffers which are configured as open-
To read Port 3 and 4 requires that ‘‘ones’’ be written to drain, and require external pullup resistors. (open-drain
the port registers to first setup the input port configura- is the MOS version of open-collector.) The port pins
tion circuit. Note that the ports are reset to this input and their system bus functions are shown in Figure
condition, but if zeroes have been written to the port, 12-5.
then ones must be re-written to any pins which are to
270651 – 41
63
80C196KB USER’S GUIDE
Ports 3 and 4 on the 80C196KB are open drain ports. follow good design and board layout techniques to keep
There is no pullup when these pins are used as I/O noise to a minimum. Liberal use of decoupling caps,
ports. A diagram of the output buffers connected to VCC and ground planes, and transient absorbers can all
Ports 3 and 4 and the bus pins is shown in Figure 12-5. be of great help. It is much easier to design a board
with these features then to search for random noise on
When Ports 3 and 4 are to be used as inputs, or as bus a poorly designed PC board. For more information on
pins, they must first be written with a ‘1’. This will put noise, refer to Applications Note AP-125, ‘Designing
the ports in a high impedance mode. When they are Microcontroller Systems for Noisy Environments’ in
used as outputs, a pullup resistor must be used external- the Embedded Control Application Handbook.
ly. A 15K pullup resistor will source a maximum of
0.33 milliamps, so it would be a reasonable value to
choose if no other circuits with pullups were connected 13.3 Oscillator and Internal Timings
to the pin.
64
80C196KB USER’S GUIDE
INTERNAL TIMINGS
Internal operation of the chip is based on the oscillator
frequency divided by two, giving the basic time unit,
known as a ‘state time‘. With a 12 Mhz crystal, a state
time is 167 nS. Since the 80C196KB can operate at
many frequencies, the times given throughout this over-
view will be in state times.
270651 – 78
65
80C196KB USER’S GUIDE
270651– 45
80C196KB Reset Sequence
66
80C196KB USER’S GUIDE
There are three ways in which the 80C196KB can reset Executing a RST instruction will also reset the
itself. The watchdog timer will reset the 80C196KB if it 80C196KB. The opcode for the RST instruction is
is not cleared in 64K state times. The watchdog timer is 0FFH. By putting pullups on the Addr/data bus, unim-
enabled the first time it is cleared. To clear the watch- plemented areas of memory will read 0FFH and cause
dog, write a ‘1E‘ followed immediately by an ‘E1‘ to the 80C196KB to be reset.
location 0AH. Once enabled, the watchdog can only be
disabled by a reset.
67
80C196KB USER’S GUIDE
RESET CIRCUITS is only asserted for four state times. If this is done, it is
possible for the 80C196KB to start running before oth-
The simplest way to reset an 80C196KB is to insert a er chips in the system are out of reset. Software must
capacitor between the RESET pin and VSS. The take this condition into account. A capacitor cannot be
80C196KB has an internal pullup which has a value connected directly to RESET if it is to drive the reset
between 6K and 50K ohms. A 5 uF or greater capaci- pins of other chips in the circuit. The capacitor may
tor should provide sufficient reset time as long as Vcc keep the voltage on the pin from going below guaran-
rises quickly. teed VIL for circuits connected to the RESET pin. Fig-
ure 13-8 shows an example of a system reset circuit.
Figure 13-7 shows what the RESET pin looks like in-
ternally. The RESET pin functions as an input and as
an output to reset an entire system with a watchdog 13.5 Minimum Hardware Connections
timer overflow, or by executing a RST instruction. For
a system reset application, the reset circuit should be a Figure 13-9 shows the minimum connections needed to
one-shot with an open collector output. The reset pulse get the 80C196KB up and running. It is important to
may have to be lengthened and buffered since RESET tie all unused inputs to VCC or VSS. If these pins are
270651 – 46
270651 – 47
NOTE:
1. The diode will provide a faster cycle time repetitive power-on-resets.
68
80C196KB USER’S GUIDE
270651 – 48
NOTE:
*Must be driven high or low.
**VSS3 was formerly the CDE pin. The CDE function is no longer available. This pin must be connectd to VSS.
left floating, they can float to a mid voltage level and the CPU out of the Idle Mode, the CPU vectors to the
draw excessive current. Some pins such as NMI or corresponding interrupt service routine and begins exe-
EXTINT may generate spurious interrupts if left un- cuting. The CPU returns from the interrupt service
connected. routine to the next instruction following the ‘IDLPD
Ý1’ instruction that put the CPU in the Idle Mode.
14.0 SPECIAL MODES OF In the Idle Mode, the system bus control pins (ALE,
OPERATION RD, WR, INST, and BHE), go to their inactive states.
Ports 3 and 4 will retain the value present in their data
The 80C196KB has Idle and Powerdown Modes to re- latches if being used as I/O ports. If these ports are the
duce the amount of current consumed by the chip. The ADDR/DATA bus, the pins will float.
80C196KB also has an ONCE (ON-Circuit-Emulation)
Mode to isolate itself from the rest of the components It is important to note the Watchdog Timer continues
in the system. to run in the Idle Mode if it is enabled. So the chip
must be awakened every 64K state times to clear the
Watchdog or the chip will reset.
14.1 Idle Mode
The Idle Mode is entered by executing the instruction
‘IDLPD Ý1’. In the Idle Mode, the CPU stops execut-
14.2 Powerdown Mode
ing. The CPU clocks are frozen at logic state zero, but The Powerdown Mode is entered by executing the in-
the peripheral clocks continue to be active. CLKOUT struction, ‘IDLPD Ý2’. In the Powerdown Mode, all
continues to be active. Power consumption in the Idle internal clocks are frozen at logic state zero and the
Mode is reduced to about 40% of the active Mode. oscillator is shut off. All 232 bytes of registers and most
peripherals hold their values if VCC is maintained.
The CPU exits the Idle Mode by any enabled interrupt Power is reduced to the device leakage and is in the uA
source or a hardware reset. Since all of the peripherals range. The 87C196KB (EPROM part) will consume
are running, the interrupt can be generated by the HSI, more power if the EPROM window is not covered.
HSO, A/D, serial port, etc. When an interrupt brings
69
80C196KB USER’S GUIDE
270651 – 49
In Powerdown, the bus control pins go to their inactive If the external interrupt brings the chip out of Power-
states. All of the output pins will assume the value in down, the corresponding bit will be set in the interrupt
their data latches. Ports 3 and 4 will continue to act as pending register. If the interrupt is unmasked, the part
ports in the single chip mode or will float if acting as will immediately execute the interrupt service routine,
the ADDR/DATA bus. and return to the instruction following the IDLPD in-
struction that put the chip into Powerdown. If the in-
To prevent accidental entry into the Powerdown Mode, terrupt is masked, the chip will start at the instruction
this feature may be disabled at reset by clearing bit 0 of following the IDLPD instruction. The bit in the pend-
the CCR (Chip Configuration Register). Since the de- ing register will remain set, however.
fault value of the CCR bit 0 is 1, the Powerdown Mode
is normally enabled. All peripherals should be in an inactive state before
entering Powerdown. If the A/D converter is in the
The Powerdown Mode can be exited by a chip reset or middle of a conversion, it is aborted. If the chip comes
a high level on the external interrupt pin. If the RESET out of Powerdown by an external interrupt, the serial
pin is used, it must be asserted long enough for the port will continue where it left off. Make sure that the
oscillator to stabilize. serial port is done transmitting or receiving before en-
tering Powerdown. The SFRs associated with the A/D
When exiting Powerdown with an external interrupt, a and the serial port may also contain incorrect informa-
positive level on the pin mapped to INT7 (either tion when returning from Powerdown.
EXTINT or port0.7) will bring the chip out of Power-
down Mode. The interrupt does not have to be un- When the chip is in Powerdown, it is impossible for the
masked to exit Powerdown. An internal timing circuit watchdog timer to time out because its clock has
ensures that the oscillator has time to stabilize before stopped. Systems which must use the Watchdog and
turning on the internal clocks. Figure 14-1 shows the Powerdown, should clear the Watchdog right before
power down and power up sequence using an external entering Powerdown. This will keep the Watchdog
interrupt. from timing out when the oscillator is stabilizing after
leaving Powerdown.
During normal operation, before entering Powerdown
Mode, the VPP pin will rise to VCC through an internal
pullup. The user must connect a capacitor between VPP
14.3 ONCE and Test Modes
and VSS. A positive level on the external interrupt pin Test Modes can be entered on the 80C196KB by hold-
starts to discharge this capacitor. The internal current ing ALE, INST or RD in their active state on the rising
source that discharges the capacitor can sink approxi- edge of RESET. The only Test Mode not reserved for
mately 100 uA. When the voltage goes below about 1 use by Intel is the ONCE, or ON-Circuit-Emulation
volt on the VPP pin, the chip begins executing code. A Mode.
1uF capacitor would take about 4 ms to discharge to 1
volt.
70
80C196KB USER’S GUIDE
ONCE is entered by driving ALE high, INST low and Address Latch Enable (ALE) provides a strobe to
RD low on the rising edge of RESET. All pins except transparent latches (74AC373s) to demultiplex the bus.
XTAL1 and XTAL2 are floated. Some of the pins are To avoid confusion, the latched address signals will be
not truly high impedance as they have weak pullups or called MA0-MA15 and the data signals will be named
pulldowns. The ONCE Mode is useful in electrically MD0-MD15.
removing the 80C196KB from the rest of the system. A
typical application of the ONCE Mode would be to The data returned from external memory must be on
program discrete EPROMs onboard without removing the bus and stable for a specified setup time before the
the 80C196KB from its socket. rising edge of RD (read). The rising edge of RD signals
the end of the sampling window. Writing to external
ALE, INST, and RD are weakly pulled high or low memory is controlled with the WR (write) pin. Data is
during reset. It is important that a circuit does not in- valid on MD0-MD15 on the rising edge of WR. At this
advertantly drive these signals during reset, or a Test time data must be latched by the external system. The
Mode could be entered by accident. 80C196KB has ample setup and hold times for writes.
270651 – 50
71
80C196KB USER’S GUIDE
CLKOUT drives ALE inactive. The next falling edge Mode. Before the CCB fetch, if the program memory is
of CLKOUT asserts RD (read) and floats the bus for a external, the CPU assumes that the bus is configured as
read cycle. During a WR (write) cycle, this edge asserts an 8-bit bus. In the 8-bit bus mode, during the CCB
WR and drives valid data on the bus. On the last rising fetch, address lines 8 – 15 use only the weak drivers.
edge of CLKOUT, data is latched into the 80C196KB However, in a 16-bit bus system, the external memory
for a read cycle, or data is valid for a write cycle. device will be driving the high byte of the bus while
outputting the CCB. This could cause bus contention if
location 2019H contains FFH. A value 20H in location
READY Pin 2019H will help prevent the contention.
The READY pin can insert wait states into the bus
cycle for interfacing to slow memory or peripherals. A
wait state is 2 Tosc in length. Since the bus is synchro-
nized to CLKOUT, it can only be held for an integral
number of waitstates. Because the 80C196KB is a com-
pletely static part, the number of waitstates that can be
inserted into a bus cycle is unbounded. Refer to the
next section for information on internally controlling
the number of waitstates inserted into a bus cycle.
INST Pin
The INST pin is useful for decoding more than 64K of 270651 – 51
addressing space. The INST pin allows both 64K of
code space and 64K of data space. For instruction Figure 15-2. Chip Configuration Register
fetches from external memory, the INST pin is assert-
ed, or high for the entire bus cycle. For data reads and
READY control
writes, the INST pin is low. The INST pin is low for
the Chip Configuration Byte fetch and for interrupt To simplify ready control, four modes of internal ready
vector fetches. control are available. The modes are chosen by bits 4
and 5 of the CCR and are shown in Figure 15-3.
72
80C196KB USER’S GUIDE
This feature gives very simple and flexible ready con- hardware. The ALE, WR, and BHE pins serve dual
trol. For example, every slow memory chip select line functions. Bits 2 and 3 of the CCR specify the function
could be ORed together and connected to the READY performed by these control lines.
pin with Internal Ready Control programmed to insert
the desired number of waitstates into the bus cycle.
Standard Bus Control
If the READY pin is pulled low during the CCR fetch,
If CCR bits 2 and 3 are 1s, the standard bus control
the bus controller will automatically insert 3 waitstates
signals ALE, WR, and BHE are generated as shown in
into the CCR bus cycle. This allows the CCR fetch to
Figure 15-4. ALE rises as the address starts to be driv-
come from slow memory without having to assert the
en, and falls to externally latch the address. WR is driv-
READY pin.
en for every write. BHE and MA0 can be combined to
form WRL and WRH for even and odd byte writes.
Bus Control
270651 – 52 270651 – 53
16-Bit Bus Cycle 8-Bit Bus Cycle
270651 – 79
73
80C196KB USER’S GUIDE
Figure 15-5 is an example of external circuitry to de- Address Valid Strobe Mode
code WRL and WRH.
Address Valid strobe replaces ALE if CCR bit 3 is 0.
When Address valid Strobe mode is selected, ADV will
Write Strobe Mode be asserted after an external address is setup. It will
stay asserted until the end of the bus cycle as shown in
The Write Strobe Mode eliminates the need to external-
Figure 15-7. ADV can be used as a simple chip select
ly decode for odd and even byte writes. If CCR bit 2 is
0, and the bus is a 16-bit cycle, WRL and WRH are for external memory. ADV looks exactly like ALE for
back to back bus cycles. The only difference is ADV
generated in place of WR and BHE. WRL is asserted
for all byte writes to an even address and all word will be inactive when the external bus is idle.
writes. WRH is asserted for all byte writes to odd ad-
dresses and all word writes. The Write Strobe mode is Address Valid with Write Strobe
shown in Figure 15-6.
If CCR bits 2 and 3 are 0, the Address Valid with Write
In the eight bit mode, WRL and WRH are asserted for Strobe mode is enabled. Figure 15-8 shows the signals.
both even and odd addresses.
270651 – 55 270651 – 56
16-Bit Bus Cycle 8-Bit Bus Cycle
270651 – 57 270651 – 58
16-Bit Bus Cycle 8-Bit Bus Cycle
74
80C196KB USER’S GUIDE
15.3 Bus Width During 16 bit bus cycles, Ports 3 and 4 contain the
address multiplexed with data using ALE to latch the
The 80C196KB external bus width can be run-time address. In 8-bit bus cycles, Port 3 is multiplexed with
conFigured to operate as a 16 bit multiplexed address/ address/data but Port 4 only outputs the upper 8 ad-
data bus, or as an MCS-51 style multiplexed 16 bit ad- dress bits. The Addresses on Port 4 are valid through-
dress/8 bit data bus. out the entire bus cycle. Figure 15-9 shows the two bus
width options.
270651 – 59 270651 – 60
16-Bit Bus Cycle 8-Bit Bus Cycle
270651 – 61 270651 – 62
(a) 16-Bit Bus (b) 8-Bit Bus
75
80C196KB USER’S GUIDE
The external bus width can be changed every bus cycle protocol consists of three signals, HOLD, HLDA, and
if a 1 was loaded into bit CCR.1 at reset. The bus width BREQ. HOLD is an input asserted by a device which
is changed on the fly by using the BUSWIDTH pin. If requests the 80C196KB bus. Figure 15-10 shows the
the BUSWIDTH pin is a 1, the bus cycle is 16-bits. For timing for HOLD/HLDA. The 80C196KB responds
an 8-bit bus cycle, the BUSWIDTH pin is a zero. The by releasing the bus and asserting HLDA. When the
BUSWIDTH is sampled by the 80C196KB after the device is done accessing the 80C196KB memory, it re-
address is on the bus. The BUSWIDTH pin has about linquishes the bus by deactivating the HOLD pin. The
the same timing as the READY pin. 80C196KB will remove its HDLA and assume control
of the bus. The third signal, BREQ, is asserted by the
Applications for the BUSWIDTH pin are numerous. 80C196KB during the hold sequence when it has a
For example, a system could have code fetched from 16 pending external bus cycle. The 80C196KB deactivates
bit memory, while data would come from 8 bit memo- BREQ at the same time it deactivates HDLA.
ry. This saves the cost of using two 8 bit static RAMS if
only the capacity of one is needed. This system could be The HOLD, HLDA, and BREQ pins are multiplexed
easily implemented by tying the chip select input of the with P1.7, P1.6, and P1.5, respectively. To enable
8-bit memory to the BUSWIDTH pin. HOLD, HLDA and BREQ, the HLDEN bit (WSR.7)
must be 1. HLDEN is cleared during reset. Once this
If CCR bit 1 is a 0, the 80C196KB is locked into the 8 bit is set, the port1 pins cannot be returned to being
bit mode and the BUSWIDTH pin is ignored. quasi-bidirectional pins until the device is reset, but can
still be read. The HOLD/HLDA feature, however, can
When executing code from a 8-bit bus, some perform- be disabled by clearing the HLDEN bit.
ance degradation is to be expected. The prefetch queue
cannot be kept full under all conditions from an 8-bit The HOLD is sampled on phase 1, or when CLKOUT
bus. Also, word reads and writes to external memory is low.
will take an extra bus cycle for the extra byte.
When the 80C196KB acknowledges the hold request,
the output buffers for the addr/data bus, RD, WR,
15.4 HOLD/HLDA Protocol BHE and INST are floated. Although the strong pullup
and pulldown on ALE/ADV are disabled, a weak pull-
The 80C196KB supports a bus exchange protocol, al- down is turned on. This provides the option to wire OR
lowing other devices to gain control of the bus. The ALE with other bus masters. The request to hold laten-
cy is dependent on the state of the bus controller.
270651 – 63
76
80C196KB USER’S GUIDE
77
80C196KB USER’S GUIDE
270651 – 82
270651 – 83
DI ; disable interrupts
ANDB WSR, #OEFH ; disable hold request
WAIT: JBC PORT1, 6, WAIT; Check the HLDA pin
# ; If set, execute
# ; protected instructions
#
ORB WSR,#80h ; enable HOLD requests
EI ; enable interrupts
NOTE:
Interrupts should be disabled to prevent code interruption
78
80C196KB USER’S GUIDE
270651 – 80
79
80C196KB USER’S GUIDE
270651 – 81
270651 – 84
80
80C196KB USER’S GUIDE
TIMINGS THE MEMORY SYSTEM MUST MEET: TCLDV Ð CLKOUT Low to Input Data Valid:
Maximum time the memory system has
TAVYV Ð ADDRESS Valid to READY Setup: to output valid data after the CLKOUT
Maximum time the memory system has falls.
to decode READY after ADDRESS is TRHDZ Ð RD High to Input Data Float: Time af-
output by the 80C196KB to guarantee at ter RD is inactive until the memory sys-
least one-wait state will occur. tem must float the bus. If this timing is
TLLYV Ð ALE Low to READY Setup: Maximum not met, bus contention will occur.
time the memory system has to decode TRXDX Ð Data Hold after RD Inactive: Time after
READY after ALE falls to guarantee at RD is inactive that the memory system
least one wait state will occur. must hold Data on the bus. Always 0 ns
TYLYH Ð READY Low to READY HIGH: Maxi- on the 80C196KB.
mum amount of nonREADY time or
the maximum number of wait states that
can be inserted into a bus cycle. Since TIMINGS THE 80C196KB WILL PROVIDE:
the 80C196KB is a completely static FXTAL Ð Frequency on XTAL1: Frequency of sig-
part, TYLYH is unbounded. nal input into the 80C196KB. The
80C196KB runs internally at (/2 FXTAL.
TCLYX Ð READY Hold after CLKOUT Low:
Minimum time the level on the READY TOSC Ð 1/FXTAL: All A.C. Timings are refer-
pin must be valid after CLKOUT falls. enced to TOSC.
The minimum hold time is always 0 ns. TXHCH Ð XTAL1 High to CLKOUT High or
If maximum value is exceeded, addition- Low: Needed in systems where the sig-
al wait states will occur. nal driving XTAL1 is also a clock for
TLLYX Ð READY Hold AFTER ALE Low: Mini- external devices.
mum time the level on the READY pin TCLCL Ð CLKOUT Cycle Time: Nominally 2
must be valid after ALE falls. If maxi- TOSC.
mum value is exceeded, additional wait
TCHCL Ð CLKOUT High Period: Needed in sys-
states will occur.
tems which use CLKOUT as clock for
TAVGV Ð ADDRESS Valid to BUSWIDTH Val- external devices.
id: Maximum time the memory system
TCLLH Ð CLKOUT Falling Edge to ALE/ADV
has to decode BUSWIDTH after AD-
Rising: A help in deriving other timings.
DRESS is output by the 80C196KB. If
exceeded, it is not guaranteed the TLLCH Ð ALE/ADV Falling Edge to CLKOUT
80C196KB will respond with an 8- or Rising: A help in deriving other timings.
16-bit bus cycle. TLHLH Ð ALE Cycle Time: Time between ALE
TLLGV Ð ALE Low to BUSWIDTH Valid: Maxi- pulses.
mum time after ALE/ADV falls until TLHLL Ð ALE/ADV High Period: Useful in de-
BUSWIDTH must be valid. If exceeded, termining ALE/ADV rising edge to
it is not guaranteed the 80C196KB will ADDRESS valid. External latches must
respond with an 8- or 16-bit bus cycle. also meet this spec.
TCLGX Ð BUSWIDTH Hold after CLKOUT TAVLL Ð ADDRESS Setup to ALE/ADV Falling
Low: Minimum time BUSWIDTH must Edge: Length of time ADDRESS is val-
be held valid after CLKOUT falls. Al- id before ALE/ADV falls. External
ways 0 ns of the 80C196KB. latches must meet this spec.
TAVDV Ð ADDRESS Valid to Input Data Valid: TLLAX Ð ADDRESS Hold after ALE/ADV Fall-
Maximum time the memory system has ing Edge: Length of Time ADDRESS is
to output valid data after the 80C196KB valid after ALE/ADV falls. External
outputs a valid address. latches must meet this spec.
TRLDV Ð RD Low to Input Data Valid: Maximum TLLRL Ð ALE/ADV Low to RD Low: Length of
time the memory system has to output time after ALE/ADV falls before RD is
valid data after the 80C196KB asserts asserted. Could be needed to insure
RD. proper memory decoding takes place be-
fore a device is enabled.
81
80C196KB USER’S GUIDE
TRLCL Ð RD Low to CLKOUT Falling Edge: TWLWH Ð WR Low to WR High: WR pulse width.
Length of time from RD asserted to Memory devices must meet this spec.
CLKOUT falling edge: Useful for sys- TWHQX Ð Data Hold after WR Rising Edge:
tems based on CLKOUT. Amount of time data is valid on the bus
TRLRH Ð RD Low to RD High: RD pulse width. after WR going inactive. Memory devic-
TRHLH Ð RD High to ALE/ADV Asserted: Time es must meet this spec.
between RD going inactive and next TWHLH Ð WR Rising Edge to ALE/ADV Rising
ALE/ADV, also used to calculate time Edge: Time between WR going inactive
between inactive and next ADDRESS and next ALE/ADV. Also used to cal-
valid. culate WR inactive and next ADDRESS
TRLAZ Ð RD Low to ADDRESS Float: Used to valid.
calculate when the 80C196KB stops TWHBX Ð BHE, INST, Hold after WR Rising
driving ADDRESS on the bus. Edge: Minimum time these signals will
TLLWL Ð ALE/ADV Low Edge to WR Low: be valid after WR inactive.
Length of time ALE/ADV falls before TRHBX Ð BHE, INST HOLD after RD Rising
WR is asserted. Could be needed to en- Edge: Minimum time these signals will
sure proper memory decoding takes be valid after RD inactive.
place before a device is enabled. TWHAX Ð AD8 – 15 Hold after WR Rising Edge:
TCLWL Ð CLKOUT Falling Edge to WR Low: Minimum time the high byte of the ad-
Time between CLKOUT going low and dress in 8-bit mode will be valid after
WR being asserted. Useful in systems WR inactive.
based on CLKOUT. TRHAX Ð AD8 – 15 Hold after RD Rising Edge:
TQVWH Ð Data Valid to WR Rising Edge: Time Minimum time the high byte of the ad-
between data being valid on the bus and dress in 8-bit mode will be valid after
WR going inactive. Memory devices RD inactive.
must meet this spec.
TCHWH Ð CLKOUT High to WR Rising Edge:
Time between CLKOUT going high and
WR going inactive. Useful in systems
based on CLKOUT.
270651 – 66
82
80C196KB USER’S GUIDE
15.6 Memory System Examples ed in the lower half of memory,and the RAM in the
upper half.
External memory systems for the 80C196KB can be set
up in many different ways. Figure 15-16 shows a simple Figure 15-18 shows a 16 bit system with 2 EPROMs.
8 bit system with a single EPROM. The ADV Mode Again, ADV is used to chip select the memory. Figure
can be selected to provide a chip select to the memory. 15-19 shows a system with dynamic bus width. Code is
By setting bit CCR.1 to 0, the system is locked into the executed from the two EPROMs and data is stored in
eight bit mode. An eight bit system with EPROM and the single RAM. Note the Chip Select of the RAM also
RAM is shown in Figure 15-17. The EPROM is decod- is input to the BUSWIDTH pin to select an eight bit
cycle.
270651 – 67
270651 – 68
83
80C196KB USER’S GUIDE
270651 – 69
270651 – 70
84
80C196KB USER’S GUIDE
15.7 I/O Port Reconstruction The Run-Time Programming Mode allows individu-
al EPROM locations to be programmed at run-time
When a single-chip system is being designed using a under complete software control. (Run-Time Pro-
multiple chip system as a prototype, it may be neces- gramming is done with EA e 5V.)
sary to reconstruct I/O Ports 3 and 4 using a memory
mapped I/O technique. The circuit to reconstruct the In the Programming Mode some I/O pins have new
Ports is shown in Figure 15-20. It can be attached to a functions. These pins determine the programming func-
80C196KB system which has the required address de- tion, provide programming control signals and slave ID
coding and bus demultiplexing. numbers, and pass error information. Figure 16-1
shows how the pins are renamed. Figure 16-2 describes
The output circuitry is a latch that operates when each new pin function.
1FFEH or 1FFFH are placed on the MA lines. The
inverters surrounding the latch create an open-collector PMODE selects the programming mode (see Figure
output to emulate the open-drain output found on the 16-3). The 87C196KB does not need to be in the Pro-
80C196KB. The RESET line sets the ports to all 1s gramming Mode to do run-time programming; it can be
when the chip is reset. The voltage and current specifi- done at any time.
cations of the port will be different from the
80C196KB, but the functionality will be the same. When an 87C196KB EPROM device is not being
erased the window must be covered with an opaque
The input circuitry is a bus transceiver that is addressed label. This prevents functional degradation and data
at 1FFEH and 1FFFH. If the ports are going to be loss from the array.
either inputs or outputs, but not both, some of the cir-
cuitry may be eliminated.
16.1 Power-Up and Power-Down
16.0 USING THE EPROM To avoid damaging devices during programming, fol-
low these rules:
The 87C196KB contains 8 Kbytes of ultraviolet Eras- RULE Ý1 VPP must be within 1V of VCC while VCC
able and electrically Programmable Read Only Memo- is below 4.5V.
ry (EPROM). When EA is a TTL high, the EPROM is
RULE Ý2 VPP can not be higher than 5.0V until VCC
located at memory locations 2000H through 3FFFH.
is above 4.5V.
Applying a 12.75V to EA when the chip is reset places RULE Ý3 VPP must not have a low impedance path
the 87C196KB device in the EPROM Programming to ground when VCC is above 4.5V.
Mode. The Programming Mode supports EPROM pro- RULE Ý4 EA must be brought to 12.75V before VPP
gramming and verification. The following is a brief de- is brought to 12.75V (not needed for run-
scription of each of the programming modes: time programming).
The Auto Configuration Byte Programming Mode RULE Ý5 The PMODE and SID pins must be in
programs the Programming Chip Configuration Byte their desired state before RESET rises.
and the Chip Configuration Byte. RULE Ý6 All voltages must be within tolerance and
the oscillator stable before RESET rises.
The Auto Programming Mode enables an RULE Ý7 The supplies to VCC, VPP, EA and RE-
87C196KB to program itself without using an SET must be well regulated and free of
EPROM programmer. spikes and glitches.
The Slave Programming Mode provides a standard To adhere to these rules you can use the following pow-
interface for programming any number of er-up and power-down sequences:
87C196KB’s by a master device such as an EPROM
programmer.
85
80C196KB USER’S GUIDE
POWER-UP EA e 5V
PALE e PROG e SID e PMODE e PORT3, 4 e
RESET e 0V 0V
VCC e VPP e EA e 5V VCC e VPP e EA e 0V
CLOCK on (if using an external clock instead of the CLOCK OFF
internal oscillator)
PALE e PROG e PORT3, 4 e VIH(1) NOTES:
SID and PMODE valid 1. VIH e logical ‘‘1’’ (2.4V minimum)
EA e 12.75V(2) 2. The same power supply can be used for EA and
VPP e 12.75V(3) VPP. However, the EA pin must be powered up before
WAIT (wait for supplies and clock to settle) VPP is powered up. Also, EA should be protected
RESET e 5V from noise to prevent damage to it.
WAIT Tshll (RESET high to first PALE low) 3. Exceeding the maximum limit on VPP for any
BEGIN amount of time could damage the device permanently.
The VPP source must be well regulated and free of
glitches.
POWER-DOWN
RESET e 0V
VPP e 5V 16.2 Reserved Locations
All Intel Reserved locations except address 2019H,
when mapped internally or externally, must be loaded
with 0FFH to ensure compatibility with future devices.
Address 2019H must be loaded with 20H.
270651 – 71
86
80C196KB USER’S GUIDE
87
80C196KB USER’S GUIDE
16.4 Auto Configuration Byte or WRITE lock bits are enabled, some programming
Programming Mode modes will require security key verification before exe-
cuting and some modes will not execute. See Figure
The Programming Chip Configuration Byte (PCCB) is 16-10 and the sections on each programming mode for
a non-memory mapped EPROM location. It gets load- details of the effects of enabling the lock bits.
ed into the CCR during reset for auto and slave pro-
gramming. The Auto Configuration Byte Programming If the PCCB is not programmed, the CCR will be load-
Mode programs the PCCB. ed with 0FFFH when the device is in the Programming
Mode.
The Chip Configuration Byte (CCB) is at location
2018H and can be programmed like any other EPROM
location using Auto, Slave, or Run-Time Programming. 16.5 Auto Programming Mode
However, you can also use Auto Configuration Byte
Programming to program the CCB when no other loca- The Auto Programming Mode provides the ability to
tions need to be programmed. The CCB is programmed program the 87C196KB EPROM without using an
with the same value as the PCCB. EPROM programmer. For this mode follow the power-
up sequence described in Section 16.1 with PMODE e
The Auto Configuration Byte Programming Mode is 0CH. External location 4014H must contain the PPW.
entered by following the power-up sequence described When RESET rises, the 87C196KB automatically pro-
in Section 16.1 with PMODE e 0DH, Port 4 e grams itself with the data found at external locations
0FFH, and Port 3 e the data to be programmed into 4000H through 5FFFH.
the PCCB and CCB. When a 0 is placed on PALE the
CCB and PCCB are automatically programmed with The 87C196KB begins programming by setting PACT
the data on Port 3. After programming, PVER is driv- low. Then it reads a word from external memory. The
en high if the bytes programmed correctly and low if Modified Quick-Pulse Programming Algorithm (de-
they did not. scribed later) programs the corresponding EPROM lo-
cation. Since the erased state of a byte is 0FFH, the
Once the PCCB and CCB are programmed, all pro- Auto Programming Mode will skip locations with
gramming activities and bus operations use the selected 0FFH for data. When all 8K have been programmed,
bus width, READY control, bus controls, and READ/ PACT goes high and the device outputs a 0 on PVAL
WRITE protection until you erase the device. You (P3.0) if it programmed correctly and a 1 if it failed.
must be careful when programming the READ and Figure 16-4 shows a minimum configuration using an
WRITE lock bits in the PCCB and CCB. If the READ 8K c 8 EPROM to program an 87C196KB in the
Auto Programming Mode.
88
80C196KB USER’S GUIDE
270651 – 72
NOTES:
*Inputs must be driven high or low.
**Allow RESET to rise after the voltages to VCC, EA, and VPP are stable.
89
80C196KB USER’S GUIDE
16.6 Slave Programming Mode The 87C196KB receives an input signal, PALE, to in-
dicate a valid command is present. PROG causes the
Any number of 87C196KBs can be programmed by a 87C196KB to read in or output a data word. PVER
master programmer through the Slave Programming indicates if the programming was successful. AINC au-
Mode. There is no 87C196KB dependent limit to the tomatically increments the address for the Data Pro-
number of devices that can be programmed. gram and Word Dump commands.
270651 – 74
90
80C196KB USER’S GUIDE
PVER is a 1 if the data program was successful. PVER mand and places the value at the new address on Ports
is a 0 if the data program was unsuccessful. Figure 16-7 3 and 4. For example, when the slave receives the com-
shows the relationship of PALE, PROG, and PVER to mand 0100H, it will place the word at internal address
the Command/Data path on Ports 3 and 4 for the Data 2100H on Ports 3 and 4. PROG governs when the slave
Program Command. drives the bus. The Timings are the same as shown in
Figure 16-7.
Data Verify Command Note that the Word Dump Command only works when
a single slave is attached to the bus. Also, there is no
When the Data Verify Command is sent, the slaves in-
restriction on commands that precede or follow a Word
dicate correct or incorrect verification of the previous
Dump Command.
Data Program Command by driving one bit of Ports 3
and 4. A 1 indicates a correct verification, and a 0 indi-
cates incorrect verification. The SID (Slave I.D) of each Gang Programming With the Slave
slave determines which bit of Ports 3 and 4 will be Programming Mode
driven. For example, a SID of 0001 would drive Port
3.1. PROG governs when the slaves drive the bus. Fig- Gang Programming of 87C196KBs can be done using
ure 16-8 shows the relationship of ports 3 and 4 to the Slave Programming Mode. There is no 87C196KB
PALE and PROG. based limit on the number of devices that may be
hooked to the same Port 3 and 4 data path for gang
A Data Verify Command is always preceded by a Data programming.
Program Command in a programming system with as
many as 16 slaves. However, a Data Verify Command If more than 16 devices are being gang programmed,
does not have to follow every Data Program Com- the PVER outputs of each chip can be used for verifica-
mand. tion. The master programmer can issue a Data Pro-
gram Command, then either watch every device’s error
signal, or AND all the signals together to form a sys-
Word Dump Command tem PVER.
When the Word Dump Command is issued, the
87C196KB adds 2000H to the address field of the com-
270651 – 75
91
80C196KB USER’S GUIDE
92
80C196KB USER’S GUIDE
NOTE:
Substantial effort has been made to provide an excel-
lent program protection scheme. However, Intel can-
not and does not guarantee that these protection
methods will always prevent unauthorized access.
93
80C196KB USER’S GUIDE
The Modified Quick-Pulse Algorithm must be used to Erasing begins upon exposure to light with wavelengths
guarantee programming over the life of the EPROM in shorter than approximately 4000 Angstroms. It should
Run-time and Slave Programming Modes. be noted that sunlight and certain types of fluorescent
lamps have wavelengths in the 3000-4000 Angstrom
The Modified Quick-Pulse Algorithm calls for each range. Constant exposure to room level fluorescent
EPROM location to receive 25 separate 100 uS ( g 5 lighting could erase an 87C196KB in about 3 years. It
ms) programming cycles. Verification is done after the would take about 1 week in direct sunlight to erase an
25th pulse. If the location verifies, the next location is 87C196KB.
programmed. If the location fails to verify, the location
fails the programming sequence. Opaque labels should always be placed over the win-
dow to prevent unintentional erasure. In the Power-
Once all locations are programmed and verified, the down Mode, the part will draw more current than nor-
entire EPROM is again verified. mal if the EPROM window is exposed to light.
Programming of 87C196KB EPROMs is done with The recommended erasure procedure for the
VPP e 12.75V g 0.25V and VCC e 5.0V g 0.5V. 87C196KB is exposure to ultraviolet light which has a
wavelength of 2537 Angstroms. The integrated dose
(UV intensity * exposure time) should be a minimum of
Signature Word
15 Wsec/cm2. The total time for erasure is about 15 to
The 87C196KB contains a signature word at location 20 minutes at this level of exposure. The 87C196KB
2070H. The word can be accessed in the Slave Mode by should be placed within 1 inch of the lamp during expo-
executing a Word Dump Command. The programming sure. The maximum integrated dose an 87C196KB can
voltages are determined by reading the test ROM at be exposed to without damage is 7258 Wsec/cm2 (1
locations 2072H and 2073H. The voltages are calculat- week @ 12000 uW/cm2). Exposure to UV light greater
ed by using the following equation. than this can cause permanent damage.
The values for the signature word and voltage levels are
shown in Figure 16-10.
94