The ISSI IS89C52 is a high-performance microcontroller
fabricated using high-density CMOS technology. The
CMOS IS89C52 is functionally compatible with the
industry standard 80C51 microcontrollers.
The IS89C52 is designed with 8-Kbytes of Flash
memory, 258 x 8 RAM; 32 programmable I/O lines; a serial
I/O port for either multiprocessor communications, I/O
expansion or full duplex UART; three 16-bit timer/counters;
an eight-source, two-priority-level, nested interrupt
structure; and an on-chip oscillator and clock circuit. The
IS89C52 can be expanded using standard TTL compatible
memory.
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
IS89C52
®
ISSI
P1.5
P1.6
P1.7
RST
RxD/P3.0
NC
TxD/P3.1
INT0/P3.2
INT1/P3.3
T0/P3.4
T1/P3.5
P1.4
P1.3
P1.2
P1.1/T2EX
P1.0/T2NCV
1
2
3
4
5
6
7
8
9
10
11
12131415161718
CC
P0.0/AD0
38
37363534444342414039
19202122
P0.1/AD1
P0.2/AD2
P0.3/AD3
33
32
31
30
29
29
27
26
25
24
23
P0.4/AD4
P0.5/AD5
P0.6/AD6
P0.7/AD7
EA
NC
ALE
PSEN
P2.7/A15
P2.6/A14
P2.5/A13
XTAL2
RD/P3.7
WR/P3.6
XTAL1
Figure 3. IS89C52 Pin Configuration: 44-pin PQFP
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
GND
NC
A8/P2.0
A9/P2.1
A10/P2.2
A11/P2.3
A12/P2.4
3
IS89C52
®
ISSI
Vcc
GND
RAM ADDR
REGISTER
B
REGISTER
P2.0-P2.7
P2
DRIVERS
ADDRESS
DECODER
& 256
BYTES RAM
STACK
POINT
PCON SCON TMOD TCON
T2CONTH0TL0TH1
TL1TH2TL2 RCAP2H
RCAP2L SBUFIEIP
INTERRUPT BLOCK
SERIAL PORT BLOCK
TIMER BLOCK
P2
LATCH
ACC
LATCH
TMP2
P0.0-P0.7
P0
DRIVERS
P0
ALU
ADDRESS
DECODER
8K FLASH
TMP1
&
3 LOCK BITS
&
32 BYTES
ENCRYPTION
INCREMENTER
PROGRAM
ADDRESS
REGISTER
PROGRAM
COUNTER
PC
PSEN
ALE/PROG
RST
EA/VPP
TIMING
AND
CONTROL
OSCILLATOR
REGISTER
INSTRUCTION
XTAL2XTAL1
PSW
P3
LATCH
P3
DRIVERS
P3.0-P3.7
Figure 4. IS89C52 Block Diagram
P1
LATCH
P1
DRIVERS
P1.0-P1.7
BUFFER
DPTR
4
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
IS89C52
Table 1. Detailed Pin Description
SymbolPDIPPLCCPQFPI/OName and Function
ALE/
PROG
EA
/VPP313529IExternal Access enable:EA must be externally held low to
P0.0-P0.739-3243-3637-30I/OPort 0: Port 0 is an 8-bit open-drain, bidirectional I/O port. Port
P1.0-P1.71-82-940-44I/OPort 1: Port 1 is an 8-bit bidirectional I/O port with internal
P2.0-P2.721-2824-3118-25I/OPort 2: Port 2 is an 8-bit bidirectional I/O port with internal
303327I/OAddress Latch Enable: Output pulse for latching the low byte
of the address during an address to the external memory. In
normal operation, ALE is emitted at a constant rate of 1/6 the
oscillator frequency, and can be used for external timing or
clocking. Note that one ALE pulse is skipped during each
access to external data memory. This pin is also the Program
Pulse input (
enable the device to fetch code from external program memory
locations 0000H to FFFFH. If EA is held high, the device
executes from internal program memory unless the program
counter contains an address greater than 0FFFH. This also
receives the 12V programming enable voltage (VPP) during
Flash programming.
0 pins that have 1s written to them float and can be used as highimpedance inputs. Port 0 is also the multiplexed low-order
address and data bus during accesses to external program and
data memory. In this application, it uses strong internal pullups
when emitting 1s.
Port 0 also receives the code bytes during programmable
memory programming and outputs the code bytes during
program verification. External pullups are required during program verification.
1-3pullups. Port 1 pins that have 1s written to them are pulled high
by the internal pullups and can be used as inputs. As inputs,
Port 1 pins that are externally pulled low will source current
because of the internal pullups. (See DC Characteristics: IIL).
The Port 1 output buffers can sink/source four TTL inputs.
Port 1 also receives the low-order address byte during Flash
programming and verification.
pullups. Port 2 pins that have 1s written to them are pulled high
by the internal pullups and can be used as inputs. As inputs,
Port 2 pins that are externally pulled low will source current
because of the internal pullups. (See DC Characteristics: IIL).
Port 2 emits the high order address byte during fetches from
external program memory and during accesses to external data
memory that used 16-bit addresses (MOVX @ DPTR). In this
application, Port 2 uses strong internal pullups when emitting
1s. During accesses to external data memory that use 8-bit
addresses (MOVX @ Ri [i = 0, 1]), Port 2 emits the contents of
the P2 Special Function Register.
Port 2 also receives the high-order bits and some control
signals during Flash programming and verification. P2.6 and
P2.7 are the control signals while the chip programs and
erases.
PROG
) during Flash programming.
ISSI
®
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
5
IS89C52
®
ISSI
Table 1. Detailed Pin Description
SymbolPDIPPLCCPQFPI/OName and Function
P3.0-P3.710-1711, 13-195, 7-13I/OPort 3: Port 3 is an 8-bit bidirectional I/O port with internal
RST9104IReset: A high on this pin for two machine cycles while the
293226OProgram Store Enable: The read strobe to external program
(continued)
pullups. Port 3 pins that have 1s written to them are pulled high
by the internal pullups and can be used as inputs. As inputs,
Port 3 pins that are externally pulled low will source current
because of the internal pullups. (See DC Characteristics: IIL).
Port 3 also serves the special features of the IS89C52, as listed
below:
INT0INT0
INT0
(P3.2): External interrupt 0.
INT0INT0INT1INT1
INT1
(P3.3): External interrupt 1.
INT1INT1
WRWR
WR
(P3.6): External data memory write strobe.
WRWRRDRD
RD
(P3.7): External data memory read strobe.
RDRD
memory. When the device is executing code from the external
program memory,
except that two
access to external data memory.
fetches from internal program memory.
oscillator is running, resets the device. An internal MOS resistor
to GND permits a power-on reset using only an external
capacitor connected to Vcc.
PSEN
is activated twice each machine cycle
PSEN
activations are skipped during each
PSEN
is not activated during
XTAL 1192115ICrystal 1: Input to the inverting oscillator amplifier and input
to the internal clock generator circuits.
XTAL 2182014OCrystal 2: Output from the inverting oscillator amplifier.
GND202216IGround: 0V reference.
Vcc404438IPower Supply: This is the power supply voltage for operation.
6
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
IS89C52
OPERATING DESCRIPTION
®
ISSI
The detail description of the IS89C52 included in this
description are:
• Memory Map and Registers
• Timer/Counters
• Serial Interface
• Interrupt System
• Other Information
• Flash Memory
MEMORY MAP AND REGISTERS
Memory
The IS89C52 has separate address spaces for program
and data memory. The program and data memory can be
up to 64K bytes long. The lower 8K program memory can
reside on-chip. Figure 5 shows a map of the IS89C52
program and data memory.
The IS89C52 has 256 bytes of on-chip RAM, plus numbers
of special function registers. The lower 128 bytes can be
accessed either by direct addressing or by indirect
addressing. Figure 6 shows internal data memory
organization and SFR Memory Map.
The lower 128 bytes of RAM can be divided into three
segments as listed below and shown in Figure 7.
1.
Register Banks 0-3:
locations 00H through 1FH (32
bytes). The device after reset defaults to register bank
0. To use the other register banks, the user must select
them in software. Each register bank contains eight
1-byte registers R0-R7. Reset initializes the stack
point to location 07H, and is incremented once to start
from 08H, which is the first register of the second
register bank.
2.
Bit Addressable Area:
16 bytes have been assigned
for this segment 20H-2FH. Each one of the 128 bits of
this segment can be directly addressed (0-7FH). Each
of the 16 bytes in this segment can also be addressed
as a byte.
3.
Scratch Pad Area:
30H-7FH are available to the user
as data RAM. However, if the data pointer has been
initialized to this area, enough bytes should be left
aside to prevent SP data destruction.
FFFFH:
64K
EA = 0
External
PSEN
Program Memory
(Read Only)
1FFFH:
8K
0000
FFH:
EA = 1
Internal
Data Memory
(Read/Write)
External
Internal
00
Figure 5. IS89C52 Program and Data Memory Structure
FFFFH:
0000
RD WR
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
7
IS89C52
SPECIAL FUNCTION REGISTERS
®
ISSI
The Special Function Registers (SFR's) are located in
upper 128 Bytes direct addressing area. The SFR Memory
Map in Figure 6 shows that.
Not all of the addresses are occupied. Unoccupied
addresses are not implemented on the chip. Read accesses
to these addresses in general return random data, and
write accesses have no effect.
User software should not write 1s to these unimplemented
locations, since they may be used in future microcontrollers
to invoke new features. In that case, the reset or inactive
values of the new bits will always be 0, and their active
values will be 1.
Upper
128
Lower
128
FFH
80H
7FH
Accessible
by Indirect
Addressing
Only
Accessible
by Direct
and Indirect
Addressing
0
Accessible
by Direct
Addressing
Special
Function
Registers
FFH
80H
Ports,
Status and
Control Bits,
Timer,
Registers,
Stack Pointer,
Accumulator
(Etc.)
The functions of the SFRs are outlined in the following
sections, and detailed in Table 2.
Accumulator (ACC)
ACC is the Accumulator register. The mnemonics for
Accumulator-specific instructions, however, refer to the
Accumulator simply as A.
B Register (B)
The B register is used during multiply and divide operations.
For other instructions it can be treated as another scratch
pad register.
Program Status Word (PSW). The PSW register contains
program status information.
F8
B
F0
E8
ACC
E0
D8
PSW
D0
T2CON
C8
C0
B8
B0
A8
A0
98
90
88
80
Addressable
IP
P3
IE
P2
SCON
P1
TCON
P0
Bit
SBUF
TMOD
SP
RCAP2L
TL0
DPL
RCAP2H
TL1
DPH
TL2
TH0
TH2
TH1
PCON
FF
F7
EF
E7
DF
D7
CF
C7
BF
B7
AF
A7
9F
97
8F
87
Figure 6. Internal Data Memory and SFR Memory Map
8 BYTES
78
70
68
60
58
50
48
40
38
30
28
0 ...
20
18
10
08
00
BANK3
BANK2
BANK 1
BANK 0
...7F
7F
77
6F
67
5F
57
4F
47
3F
37
2F
ADDRESSABLE
27
1F
17
0F
07
SCRATCH
PAD
AREA
BIT
SEGMENT
REGISTER
BANKS
Figure 7. Lower 128 Bytes of Internal RAM
8
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
IS89C52
SPECIAL FUNCTION REGISTERS
(Continued)
®
ISSI
Stack Pointer (SP)
The Stack Pointer Register is eight bits wide. It is
incremented before data is stored during PUSH and CALL
executions. While the stack may reside anywhere in onchip RAM, the Stack Pointer is initialized to 07H after a
reset. This causes the stack to begin at location 08H.
Data Pointer (DPTR)
The Data Pointer consists of a high byte (DPH) and a low
byte (DPL). Its function is to hold a 16-bit address. It may
be manipulated as a 16-bit register or as two independent
8-bit registers.
Ports 0 To 3
P0, P1, P2, and P3 are the SFR latches of Ports 0, 1, 2, and
3, respectively.
Serial Data Buffer (SBUF)
The Serial Data Buffer is actually two separate registers,
a transmit buffer and a receive buffer register. When data
is moved to SBUF, it goes to the transmit buffer, where it
is held for serial transmission. (Moving a byte to SBUF
initiates the transmission.) When data is moved from
SBUF, it comes from the receive buffer.
Timer Registers
Register pairs (TH0, TL0) and (TH1, TL1) are the 16-bit
Counter registers for Timer/Counters 0 and 1, respectively.
Capture Registers
The register pair (RCAP2H, RCAP2L) are the Capture
registers for the Timer 2 Capture Mode. In this mode, in
response to a transition at the IS89C52's T2EX pin, TH2
and TL2 are copied into RCAP2H and RCAP2L. Timer 2
also has a 16-bit auto-reload mode, and RCAP2H and
RCAP2L hold the reload value for this mode.
Control Registers
Special Function Registers IP, IE, TMOD, TCON, SCON,
and PCON contain control and status bits for the interrupt
system, the Timer/Counters, and the serial port. They are
described in later sections of this chapter.
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
9
IS89C52
ISSI
Table 2. Special Function Registers
SymbolDescriptionDirect AddressBit Address, Symbol, or Alternative Port FunctionReset Value
(1)
ACC
(1)
B
AccumulatorE0HE7E6E5E4E3E2E1E000H
B registerF0HF7F6F5F4F3F2F1F000H
DPHData pointer (DPTR) high83H00H
DPLData pointer (DPTR) low82H00H
AFAEADACABAAA9A8
(1)
IE
Interrupt enableA8HEA——ESET1EX1ET0EX00XX00000B
BFBEBDBCBBBAB9B8
(1)
IP
Interrupt priorityB8H———PSPT1PX1PT0PX0XXX00000B
8786858483828180
(1)
P0
Port 080HP0.7P0.6P0.5P0.4P0.3P0.2 P0.1 P0.0FFH
AD7AD6AD5AD4AD3AD2AD1AD0
9796959493929190
(1)
P1
Port 190HP1.7P1.6P1.5P1.4P1.3P1.2 P1.1 P1.0FFH
A7A6A5A4A3A2A1A0
(1)
P2
Port 2A0HP2.7P2.6P2.5P2.4P2.3P2.2 P2.1 P2.0FFH
AD15 AD14AD13 AD12 AD11 AD10 AD9AD8
B7B6B5B4B3B2B1B0
(1)
P3
Port 3B0HP3.7P3.6P3.5P3.4P3.3P3.2 P3.1 P3.0FFH
RDWR
T1T0
INT1INT0
TXD RXD
PCONPower control87HSMOD———GF1GF0PDIDL0XXX0000B
D7D6D5D4D3D2D1D0
(1)
PSW
Program status wordD0HCYACF0RS1RS0OV—P00H
SBUFSerial data buffer99HXXXXXXXXB
9F9E9D9C9B9A9998
(1)
SCON
Serial controller98HSM0SM1SM2RENTB8RB8TIRI00H
SPStack pointer81H07H
8F8E8D8C8B8A8988
(1)
TCON
TMODTimer mode89HGATEC/
Timer control88HTF1TR1TF0TR0IE1IT1IE0IT000H
T
M1M0GATEC/TM1M000H
TH0Timer high 08CH00H
TH1Timer high 18DH00H
TL0Timer low 08AH00H
TL1Timer low 18BH00H
RCAP2H
RCAP2L
TL2
Notes:
(2)
Capture highCAH00H
(2)
(2)
1. Denotes bit addressable.
2. SFRs are added to the 80C51 SFRs.
Capture lowCBH00H
Timer low 2CCH00H
®
10
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
IS89C52
The detail description of each bit is as follows:
®
ISSI
PSW:
Program Status Word. Bit Addressable.
76543210
CYACF0RS1RS0OV—P
Register Description:
CYPSW.7Carry flag.
ACPSW.6Auxiliary carry flag.
F0PSW.5Flag 0 available to the user for general
purpose.
RS1PSW.4Register bank selector bit 1.
RS0PSW.3Register bank selector bit 0.
(1)
(1)
OVPSW.2Overflow flag.
—PSW.1Usable as a general purpose flag
PPSW.0Parity flag. Set/Clear by hardware each
instruction cycle to indicate an odd/even
number of “1” bits in the accumulator.
Note:
1. The value presented by RS0 and RS1 selects the corresponding register bank.
RS1RS0Register BankAddress
00000H-07H
01108H-0FH
10210H-17H
11318H-1FH
PCON:
Power Control Register. Not Bit Addressable.
76543210
SMOD———GF1GF0PDIDL
Register Description:
SMODDouble baud rate bit. If Timer 1 is used to generate
baud rate and SMOD=1, the baud rate is doubled
when the serial port is used in modes 1, 2, or 3.
—Not implemented, reserve for future use.
—Not implemented, reserve for future use.
—Not implemented, reserve for future use.
GF1General purpose flag bit.
GF0General purpose flag bit.
PDPower-down bit. Setting this bit activates power-
down mode.
IDLIdle mode bit. Setting this bit activates idle mode.
If 1s are written to PD and IDL at the same time,
PD takes precedence.
Note:
1. User software should not write 1s to reserved bits. These
bits may be used in future products to invoke new features.
(1)
(1)
(1)
IE:
Interrupt Enable Register. Bit Addressable.
76543210
EA——ESET1EX1ET0 EX0
Register Description:
EAIE.7Disable all interrupts. If EA=0, no
interrupt will be acknowledged. If EA=1,
each interrupt source is individually
enabled or disabled by setting or
clearing its enable bit.
—IE.6Not implemented, reserve for future
—IE.5Not implemented, reserve for future
ESIE.4Enable or disable the serial port
ET1IE.3Enable or disable the Timer 1 overflow
EX1IE.2Enable or disable External Interrupt 1.
ET0IE.1Enable or disable the Timer 0 overflow
EX0IE.0Enable or disable External Interrupt 0.
Note: To use any of the interrupts in the 80C51 Family, the
following three steps must be taken:
1. Set the EA (enable all) bit in the IE register to 1.
2. Set the coresponding individual interrupt enable bit in
the IE register to 1.
3. Begin the interrupt service routine at the corresponding
Vector Address of that interrupt (see below).
Interrupt SourceVector Address
IE00003H
TF0000BH
IE10013H
TF1001BH
RI & TI0023H
4. In addition, for external interrupts, pins
(P3.2 and P3.3) must be set to 1, and depending on
whether the interrupt is to be level or transition activated, bits IT0 or IT1 in the TCON register may need to
be set to 0 or 1.
ITX = 0 level activated (X = 0, 1)
ITX = 1 transition activated
User software should not write 1s to reserved bits. These
5.
bits may be used in future products to invoke new
features.
(5)
use.
(5)
use.
interrupt.
interrupt.
interrupt.
INT0
and
INT1
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
11
IS89C52
®
ISSI
IP:
Interrupt Priority Register. Bit Addressable.
76543210
———PSPT1PX1PT0 PX0
Register Description:
—IP.7Not implemented, reserve for future use
—IP.6Not implemented, reserve for future use
—IP.5Not implemented, reserve for future use
PSIP.4Defines Serial Port interrupt priority level
PT1IP.3Defines Timer 1 interrupt priority level
PX1IP.2Defines External Interrupt 1 priority level
PT0IP.1Defines Timer 0 interrupt priority level
PX0IP.0Defines External Interrupt 0 priority level
Notes:
1. In order to assign higher priority to an interrupt the
coresponding bit in the IP register must be set to 1. While
an interrupt service is in progress, it cannot be interrupted
by a lower or same level interrupt.
2. Priority within level is only to resolve simultaneous
requests of the same priority level. From high-to-low,
interrupt sources are listed below:
IE0
TF0
IE1
TF1
RI or TI
TF2 or EXF2
User software should not write 1s to reserved bits. These
3.
bits may be used in future products to invoke new features.
TCON:
Timer/Counter Control Register. Bit Addressable
76543210
TF1TR1TF0TR0IE1IT1IE0IT0
Register Description:
(3)
TF1TCON.7Timer 1 overflow flag. Set by hardware
(3)
(3)
TR1TCON.6Timer 1 run control bit. Set/Cleared by
TF0TCON.5Timer 0 overflow flag. Set by hardware
TR0TCON.4Timer 0 run control bit. Set/Cleared by
IE1TCON.3External Interrupt 1 edge flag. Set by
IT1TCON.2Interrupt 1 type control bit. Set/Cleared
IE0TCON.1External Interrupt 0 edge flag. Set by
IT0TCON.0Interrupt 0 type control bit. Set/Cleared
when the Timer/Counter 1 overflows.
Cleared by hardware as processor
vectors to the interrupt service routine.
software to turn Timer/Counter 1 ON/
OFF.
when the Timer/Counter 0 overflows.
Cleared by hardware as processor
vectors to the interrupt service routine.
software to turn Timer/Counter 0 ON/
OFF.
hardware when the External Interrupt
edge is detected. Cleared by hardware
when interrupt is processed.
by software specify falling edge/low level
triggered External Interrupt.
hardware when the External Interrupt
edge is detected. Cleared by hardware
when interrupt is processed.
by software specify falling edge/low level
triggered External Interrupt.
12
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
IS89C52
®
ISSI
TMOD:
Timer/Counter Mode Control Register.
Not Bit Addressable.
Timer 1 Timer 0
GATE C/
TT
T
M1 M0GATEC/
TT
GATE When TRx (in TCON) is set and GATE=1, TIMER/
COUNTERx will run only while
(hardware control). When GATE=0, TIMER/
COUNTERx will run only while TRx=1 (software
control).
C/
T
Timer or Counter selector. Cleared for Timer
operation (input from internal system clock). Set
for Counter operation (input from Tx input pin).
M1Mode selector bit.
M0Mode selector bit.
TH0. TL0 is an 8-bit Timer/Counter
controller by the standard Timer 0
control bits. TH0 is an 8-bit Timer and
is controlled by Timer 1 control bits.)
11Mode 3. (Timer/Counter 1 stopped).
(1)
(1)
TT
T
M1 M0
TT
INTx
pin is high
SCON:
Serial Port Control Register. Bit Addressable.
76543210
SM0 SM1 SM2RENTB8RB8TIRI
Register Description:
SM0 SCON.7Serial port mode specifier.
SM1 SCON.6Serial port mode specifier.
SM2 SCON.5Enable the multiprocessor com-
munication feature in mode 2 and 3. In
mode 2 or 3, if SM2 is set to 1 then RI
will not be activated if the received 9th
data bit (RB8) is 0. In mode 1, if SM2=1
then RI will not be activated if valid stop
bit was not received. In mode 0, SM2
should be 0.
REN SCON.4Set/Cleared by software to Enable/
Disable reception.
TB8SCON.3The 9th bit that will be transmitted in
mode 2 and 3. Set/Cleared by software.
RB8SCON.2In modes 2 and 3, RB8 is the 9th data
bit that was received. In mode 1, if
SM2=0, RB8 is the stop bit that was
received. In mode 0, RB8 is not used.
TISCON.1Transmit interrupt flag. Set by hardware
at the end of the eighth bit time in mode
0, or at the beginning of the stop bit in
the other modes. Must be cleared by
software.
RISCON.0Receive interrupt flag. Set by hardware
at the end of the eighth bit time in mode
0, or halfway through the stop bit time
in the other modes (except see SM2).
Must be cleared by software.
(1)
(1)
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
Note 1:
SM0 SM1 MODEDescriptionBaud Rate
000Shift registerFosc/12
0118-bit UARTVariable
1029-bit UARTFosc/64 or
Fosc/32
1139-bit UARTVariable
13
IS89C52
T2CON:
Timer/Counter 2 Control Register. Bit Addressable.
76543210
TF2EXF2 RCLK TCLK EXEN2TR2 C/
T2T2
T2
T2T2
Register Description:
TF2T2CON.7 Timer 2 overflow flag set by hardware
and cleared by software. TF2 cannot
be set when either RCLK = 1 or
TCLK = 1.
EXF2 T2CON.6 Timer 2 external flag set when either a
capture or reload is caused by a
negative transition on T2EX, and
EXEN2 = 1. When Timer 2 interrupt is
enabled, EXF2 = 1 causes the CPU to
vector to the Timer 2 interrupt routine.
EXF2 must be cleared by software.
RCLK T2CON.5 Receive clock flag. When set, causes
the Serial Port to use Timer 2 overflow
pulses for its receive clock in modes 1
and 3. RCLK = 0 causes Timer 1
overflow to be used for the receive
clock.
TLCK T2CON.4 Transmit clock flag. When set, causes
the Serial Port to use Timer 2 overflow
pulses for its transmit clock in modes 1
and 3. TCLK = 0 causes Timer 1
overflows to be used for the transmit
clock.
EXEN2T2CON.3 Timer 2 external enable flag.
When set, allows a capture or reload to
occur as a result of negative transition
on T2EX if Timer 2 is not being used to
clock the Serial Port, EXEN2 = 0 causes
Timer 2 to ignore events at T2EX.
T2CON.0Capture/Reload flag.
When set, captures occur on negative
transitions at T2EX if EXEN2 = 1. When
cleared, auto-reloads occur either with
Timer 2 overflows or negative
transitions at T2EX when EXEN2 = 1.
When either RCLK = 1 or TCLK = 1,
this bit is ignored and the Timer is
forced to auto-reload on Timer 2
overflow.
RL2RL2
RL2
TR2 MODE
RL2RL2
®
14
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
IS89C52
TIMER/COUNTERS
®
ISSI
The IS89C52 has two 16-bit Timer/Counter registers:
Timer 0 and Timer 1. All two can be configured to operate
either as Timers or event Counters.
As a Timer, the register is incremented every machine cycle.
Thus, the register counts machine cycles. Since a machine
cycle consists of 12 oscillator periods, the count rate is 1/12
of the oscillator frequency.
As a Counter, the register is incremented in response to a
1-to-0 transition at its corresponding external input pin, T0
and T1. The external input is sampled during S5P2 of every
machine cycle. When the samples show a high in one cycle
and a low in the next cycle, the count is incremented. The
new count value appears in the register during S3P1 of the
cycle following the one in which the transition was detected.
Since two machine cycles (24 oscillator periods) are required
to recognize a 1-to-0 transition, the maximum count rate is
1/24 of the oscillator frequency. There are no restrictions on
the duty cycle of the external input signal, but it should be
held for at least one full machine cycle to ensure that a given
level is sampled at least once before it changes.
In addition to the Timer or Counter functions, Timer 0 and
Timer 1 have four operating modes: 13-bit timer, 16-bit timer,
8-bit auto-reload, split timer. Timer 2 in the IS89C52 has
three modes of operation: Capture, Auto-Reoload, and
Baud Rate Generator.
Timer 0 and Timer 1
The Timer or Counter function is selected by control bits
C/T in the Special Function Regiser TMOD. These two
Timer/Counters have four operating modes, which are
selected by bit pairs (M1, M0) in TMOD. Modes 0, 1, and 2
are the same for both Timer/Counters, but Mode 3 is different.
The four modes are described in the following sections.
Mode 0:
Both Timers in Mode 0 are 8-bit Counters with a divide-by-32
prescaler. Figure 8 shows the Mode 0 operation as it applies
to Timer 1.
In this mode, the Timer register is configured as a 13-bit
register. As the count rolls over from all 1s to all 0s, it sets the
Timer interrupt flag TF1. The counted input is enabled to the
Timer when TR1 = 1 and either GATE = 0 or
GATE = 1 allows the Timer to be controlled by external input
INT1
, to facilitate pulse width measurements. TR1 is a
control bit in the Special Function Register TCON. Gate is in
TMOD.
The 13-bit register consists of all eight bits of TH1 and the
lower five bits of TL1. The upper three bits of TL1 are
indeterminate and should be ignored. Setting the run flag
(TR1) does not clear the registers.
Mode 0 operation is the same for Timer 0 as for Timer 1,
except that TR0, TF0 and
INT0
replace the corresponding
Timer 1 signals in Figure 8. There are two different GATE
bits, one for Timer 1 (TMOD.7) and one for Timer 0 (TMOD.3).
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
(5 BITS)
CONTROL
TL1
ONE MACHINE
CYCLE
TH1
(8 BITS)
TF1
INTERRUPT
15
IS89C52
®
ISSI
Mode 1:
Mode 1 is the same as Mode 0, except that the Timer
register is run with all 16 bits. The clock is applied to the
combined high and low timer registers (TL1/TH1). As clock
pulses are received, the timer counts up: 0000H, 0001H,
0002H, etc. An overflow occurs on the FFFFH-to-0000H
overflow flag. The timer continues to count. The overflow
flag is the TF1 bit in TCON that is read or written by software
(see Figure 9).
Mode 2:
Mode 2 configures the Timer register as an 8-bit Counter
(TL1) with automatic reload, as shown in Figure 10. Overflow
from TL1 not only sets TF1, but also reloads TL1 with the
contents of TH1, which is preset by software. The reload
leaves the TH1 unchanged. Mode 2 operation is the same
for Timer/Counter 0.
TIMER
CLOCK
TL1
(8 BITS)
Mode 3:
Timer 1 in Mode 3 simply holds its count. The effect is the
same as setting TR1 = 0. Timer 0 in Mode 3 establishes TL0
and TH0 as two separate counters. The logic for Mode 3 on
Timer 0 is shown in Figure 11. TL0 uses the Timer 0 control
bits: C/T, GATE, TR0,
INT0
, and TF0. TH0 is locked into a
timer function (counting machine cycles) and over the use
of TR1 and TF1 from Timer 1. Thus, TH0 now controls the
Timer 1 interrupt.
Mode 3 is for applications requiring an extra 8-bit timer or
counter. With Timer 0 in Mode 3, the IS89C52 can appear
to have four Timer/Counters. When Timer 0 is in Mode 3,
Timer 1 can be turned on and off by switching it out of and
into its own Mode 3. In this case, Timer 1 can still be used
by the serial port as a baud rate generator or in any
application not requiring an interrupt.
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
IS89C52
®
ISSI
OSC
DIVIDE 121/12 FOSC
1/12 FOSC
T0 PIN
GATE
INT0 PIN
1/12 FOSC
C/T = 0
TL0
(8 BITS)
C/T = 1
TR0
TR1
CONTROL
TH0
(8 BITS)
CONTROL
Figure 11. Timer/Counter 0 Mode 3: Two 8-Bit Counters
TF0
TF1
INTERRUPT
INTERRUPT
Timer 2
This is a powerful addition to the other two just discussed.
Five extra special function registers are added to
accommodate Timer 2 which are: the timer registers, TL2
and TH2, the timer control register, T2CON, and the
capture registers, RCAP2L and RCAP2H. Like Timers 0
and 1, it can operate either as a timer or as an event
counter, depending on the value of bit C/T2 in the Special
Function Register T2CON. Timer 2 has three operating
modes: capture, auto-reload, and baud rate generator,
which are selected by RCLK, TCLK, CP/
In the Capture Mode, the EXEN2 bit in T2CON selects two
options. If EXEN2 = 0, then Timer 2 is a 16-bit timer or
counter whose overflow sets bit TF2, the Timer 2 overflow
bit, which can be used to generate an interrupt. If EXEN2
= 1, then Timer 2 performs the same way, but a 1-to-0
transition at external input T2EX also causes the current
value in the Timer 2 registers, TL2 and TH2, to be captured
RL2
, and TR2.
into the RCAP2L and RCAP2H registers, respectively. In
addition, the transition at T2EX sets the EXF2 bit in
T2CON, and EXF2, like TF2, can generate an interrupt.
The Capture Mode is illustrated in Figure 12.
In the auto-reload mode, the EXEN2 bit in T2CON also
selects two options. If EXEN2 = 0, then when Timer 2 rolls
over it sets TF2 and also reloads the Timer 2 registers with
the 16-bit value in the RCAP2L and RCAP2H registers,
which are preset by software. If EXEN2 = 1, then Timer 2
performs the same way, but a 1-to-0 transition at external
input T2EX also triggers the 16-bit reload and sets EXF2.
The auto-reload mode is illustrated in Figure 13.
The baud rate generator mode is selected by RCLK = 1
and/or TCLK = 1. This mode is described in conjunction
with the serial port (see Figure 14).
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
17
IS89C52
®
ISSI
OSC
T2EX PIN
OSC
T2EX PIN
T2 PIN
DIVIDE 12
T2 PIN
DIVIDE 12
TRANSITION
DETECTOR
TRANSITION
DETECTOR
EXEN2
C/T2 = 0
C/T2 = 1
EXEN2
C/T2 = 0
C/T2 = 1
CONTROL
CONTROL
TR2
CAPTURE
TL2
(8 BITS)
RCAP2L
TH2
(8 BITS)
RCAP2H
Figure 12. Timer 2 In Capture Mode
CONTROL
CONTROL
TR2
RELOAD
TL2
(8 BITS)
RCAP2L
TH2
(8 BITS)
RCAP2H
TF2
EXF2
TF2
EXF2
TIMER 2
INTERRUPT
TIMER 2
INTERRUPT
Figure 13. Timer 2 in Auto-Reload Mode
NOTE: OSC FREQ.
IS DIV BY 2, NOT 12
OSC
T2EX PIN
T2 PIN
DIVIDE 2
TRANSITION
DETECTOR
EXEN2
C/T2 = 0
C/T2 = 1
CONTROL
CONTROL
TR2
EXF2
Figure 14. Timer 2 in Baud Rate Generator Mode
Note:
T2EX can be used as an additional external interrupt.
TL2
(8 BITS)
RCAP2L
TIMER 2
INTERRUPT
TH2
(8 BITS)
RCAP2H
RELOAD
"1"
TIMER 1
OVERFLOW
DIVIDE 2
"0"
"0"
"0""1"
"1"
SMOD
RCLK
DIVIDE 16
TCLK
DIVIDE 16
RX CLOCK
TX CLOCK
18
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
IS89C52
®
ISSI
Timer Setup
Tables 3 through 6 give TMOD values that can be used to
set up Timers in different modes.
It assumes that only one timer is used at a time. If Timers
0 and 1 must run simultaneously in any mode, the value in
TMOD for Timer 0 must be ORed with the value shown for
Timer 1 (Tables 5 and 6).
For example, if Timer 0 must run in Mode 1 GATE (external
control), and Timer 1 must run in Mode 2 COUNTER, then
the value that must be loaded into TMOD is 69H (09H from
Table 3 ORed with 60H from Table 6).
Moreover, it is assumed that the user is not ready at this
point to turn the timers on and will do so at another point
in the program by setting bit TRx (in TCON) to 1.
1. The Timer is turned ON/OFF by setting/clearing bit TR1
in the software.
2. The Timer is turned ON/OFF by the 1-to-0 transition on
INT1
(P3.3) when TR1 = 1 (hardware control).
(2)
(2)
Table 4. Timer/Counter 0 Used as a Counter
TMOD
ModeTimer 0InternalExternal
FunctionControl
(1)
Control
013-Bit Timer04H0CH
116-Bit Timer05H0DH
28-Bit Auto-Reload06H0EH
3One 8-Bit Counter07H0FH
Notes:
1. The Timer is turned ON/OFF by setting/clearing bit TR0
in the software.
2. The Timer is turned ON/OFF by the 1 to 0 transition on
INT0
(P3.2) when TR0 = 1 (hardware control).
(2)
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
19
IS89C52
®
ISSI
Timer/Counter 2 Set-Up
Except for the baud rate generator mode, the values given
for T2C0N do not include the setting of the TR2 bit. Therefore,
bit TR2 must be set separately to turn the Timer on.
and Transmit Same Baud Rate
Receive Only24H26H
Transmit Only14H16H
Table 8. Timer/Counter 2 Used as a Counter
ModeInternalExternal
Control
16-Bit Auto-Reload02H0AH
16-Bit Capture03H0BH
Notes:
1. Capture/Reload occurs only on Timer/Counter overflow.
2. Capture/Reload occurs on Timer/Counter overflow and
a 1-to-0 transition on T2EX (P1.1) pin except when
Timer 2 is used in the baud rate generating mode.
(1)
TMOD
(1)
Control
Control
(2)
(2)
SERIAL INTERFACE
The Serial port is full duplex, which means it can transmit
and receive simultaneously. It is also receive-buffered,
which means it can begin receiving a second byte before
a previously received byte has been read from the receive
register. (However, if the first byte still has not been read
when reception of the second byte is complete, one of the
bytes will be lost.) The serial port receive and transmit
registers are both accessed at Special Function Register
SBUF. Writing to SBUF loads the transmit register, and
reading SBUF accesses a physically separate receive
register.
The serial port can operate in the following four modes:
Mode 0:
Serial data enters and exits through RXD. TXD outputs the
shift clock. Eight data bits are transmitted/received, with
the LSB first. The baud rate is fixed at 1/12 the oscillator
frequency (see Figure 15).
Mode 1:
Ten bits are transmitted (through TXD) or received (through
RXD): a start bit (0), eight data bits (LSB first), and a stop
bit (1). On receive, the stop bit goes into RB8 in Special
Function Register SCON. The baud rate is variable (see
Figure 16).
Mode 2:
Eleven bits are transmitted (through TXD) or received
(through RXD): a start bit (0), eight data bits (LSB first), a
programmable ninth data bit, and a stop bit (1). On transmit,
the ninth data bit (TB8 in SCON) can be assigned the value
of 0 or 1. Or, for example, the parity bit (P, in the PSW) can
be moved into TB8. On receive, the ninth data bit goes into
RB8 in Special Function Register SCON, while the stop bit
is ignored. The baud rate is programmable to either 1/32 or
1/64 the oscillator frequency (see Figure 17).
20
Mode 3:
Eleven bits are transmitted (through TXD) or received
(through RXD): a start bit (0), eight data bits (LSB first), a
programmable ninth data bit, and a stop bit (1). In fact,
Mode 3 is the same as Mode 2 in all respects except the
baud rate, which is variable in Mode 3 (see Figure 18).
In all four modes, transmission is initiated by any instruction
that uses SBUF as a destination register. Reception is
initiated in Mode 0 by the condition RI = 0 and REN = 1.
Reception is initiated in the other modes by the incoming
start bit if REN = 1.
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
IS89C52
®
ISSI
Multiprocessor Communications
Modes 2 and 3 have a special provision for multiprocessor
communications. In these modes, nine data bits are
received, followed by a stop bit. The ninth bit goes into
RB8; then comes a stop bit. The port can be programmed
such that when the stop bit is received, the serial port
interrupt is activated only if RB8 = 1. This feature is
enabled by setting bit SM2 in SCON.
The following example shows how to use the serial interrupt
for multiprocessor communications. When the master
processor must transmit a block of data to one of several
slaves, it first sends out an address byte that identifies the
target slave. An address byte differs from a data byte in
that the ninth bit is 1 in an address byte and 0 in a data byte.
With SM2 = 1, no slave is interrupted by a data byte. An
address byte, however, interrupts all slaves, so that each
slave can examine the received byte and see if it is being
addressed. The addressed slave clears its SM2 bit and
prepares to receive the data bytes that follows. The slaves
that are not addressed set their SM2 bits and ignore the
data bytes.
SM2 has no effect in Mode 0 but can be used to check the
validity of the stop bit in Mode 1. In a Mode 1 reception, if
SM2 = 1, the receive interrupt is not activated unless a
valid stop bit is received.
Baud Rates
The baud rate in Mode 0 is fixed as shown in the following
equation.
Using the Timer 1 to Generate Baud Rates
When Timer 1 is the baud rate generator, the baud rates in
Modes 1 and 3 are determined by the Timer 1 overflow rate
and the value of SMOD according to the following equation.
Mode 1, 3 2
Baud Rate =
SMOD
32
(Timer 1 Overflow Rate)
X
The Timer 1 interrupt should be disabled in this application.
The Timer itself can be configured for either timer or
counter operation in any of its three running modes. In the
most typical applications, it is configured for timer operation
in auto-reload mode (high nibble of TMOD = 0010B). In this
case, the baud rate is given by the following formula.
Mode 1,3 2
Baud Rate
=
SMOD
3212x [256 – (TH1)]
Oscillator Frequency
X
Programmers can achieve very low baud rates with Timer
1 by leaving the Timer 1 interrupt enabled, configuring the
Timer to run as a 16-bit timer (high nibble of TMOD =
0001B), and using the Timer 1 interrupt to do a 16-bit
software reload.
Table 9 lists commonly used baud rates and how they can
be obtained from Timer 1.
Oscillator Frequency
Mode 0 Baud Rate =
12
The baud rate in Mode 2 depends on the value of the
SMOD bit in Special Function Register PCON. If SMOD =
0 (the value on reset), the baud rate is 1/64 of the oscillator
frequency. If SMOD = 1, the baud rate is 1/32 of the
oscillator frequency, as shown in the following equation.
SMOD
Mode 2 Baud Rate =
2
x (Oscillator Frequency)
64
In the IS89C52, these baud rates can be determined by
Timer 1, Timer 2, or both (one for transmit and the other for
receive).
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
21
IS89C52
®
ISSI
Using Timer 2 to Generate Baud Rates
In the IS89C52, setting TCLK and/or RCLK in T2CON
selects Timer 2 as the baud rate generator. Under these
conditions, the baud rates for transmit and receive can be
simultaneously different. Setting RCLK and/or TCLK puts
Timer 2 into its baud rate generator mode, as shown in
Figure 14.
The baud rate generator mode is similar to the auto-reload
mode, in that a rollover in TH2 reloads the Timer 2 registers
with the 16-bit value in the RCAP2H and RCAP2L registers,
which are preset by software.
In this case, the baud rates in Mode 1 and 3 are determined
by the Timer 2 overflow rate according to the following
equation.
Modes 1, 3 Baud Rate =
Timer 2 can be configured for either timer or counter
operation. In the most typical applications, it is configured
for timer operation (C/T2 = 0). Normally, a timer increments
every machine cycle (thus, at 1/12 the oscillator frequency),
but timer operation is a different for Timer 2 when it is used
as a baud rate generator. As a baud rate generator, Timer
2 increments every state time (thus at 1/2 the oscillator
frequency). In this case, the baud rate is given by the
following formula.
Timer 2 Overflow Rate
16
Where (RCAP2H, RCAP2L) is the content of RCAP2H and
RCAP2L taken as a 16-bit unsigned integer.
Figure 13 shows Timer 2 as a baud rate generator. This
figure is valid only if RCLK + TCLK = 1 in T2CON. A rollover
in TH2 does not set TF2 and does no generate an interrupt.
Therefore, the Timer 2 interrupt does not have to be
disabled when Timer 2 is in the baud rate generator mode.
If EXEN2 is set, a 1-to-0 transition in T2EX sets EXF2 but
does not cause a reload from (RCAP2H, RCAP2L) to
(TH2, TL2). Thus, when Timer 2 is used as a baud rate
generator, T2EX can be used as an extra external interrupt.
When Timer 2 is running (TR2 = 1) as a timer in the baud
rate generator mode, programmers should not read from
or write to TH2 or TL2. Under these conditions, Timer 2 is
incremented every state time, and the results of a read or
write may not be accurate. The RCAP registers may be
read, but should not be written to, because a write might
overlap a reload and cause write and/or reload errors. Turn
Timer 2 off (clear TR2) before accessing the Timer 2 or
RCAP registers, in this case.
Modes 1, 3Oscillator Frequency
Baud Rate
Table 9. Commonly Used Baud Rates Generated by Timer 1
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
IS89C52
®
ISSI
More About Mode 0
Serial data enters and exits through RXD. TXD outputs the
shift clock. Eight data bits are transmitted/received, with
the LSB first. The baud rate is fixed at 1/12 the oscillator
frequency.
Figure 15 shows a simplified functional diagram of the
serial port in Mode 0 and associated timing.
Transmission is initiated by any instruction that uses SBUF
as a destination register. The "write to SBUF" signal at
S6P2 also loads a 1 into the ninth position of the transmit
shift register and tells the TX Control block to begin a
transmission. The internal timing is such that one full
machine cycle will elapse between "write to SBUF" and
activation of SEND.
SEND transfer the output of the shift register to the
alternate output function line of P3.0, and also transfers
SHIFT CLOCK to the alternate output function line of P3.1.
SHIFT CLOCK is low during S3, S4, and S5 of every
machine cycle, and high during S6, S1, and S2. At S6P2
of every machine cycle in which SEND is active, the
contents of the transmit shift register are shifted one
position to the right.
As data bits shift out to the right, 0s come in from the left.
When the MSB of the data byte is at the output position of
the shift register, the 1 that was initially loaded into the
ninth position is just to the left of the MSB, and all positions
to the left of that contain 0s. This condition flags the TX
Control block to do one last shift, then deactivate SEND
and set TI. Both of these actions occur at S1P1 of the tenth
machine cycle after "write to SBUF."
Reception is initiated by the condition REN = 1 and
RI = 0. At S6P2 of the next machine cycle, the RX Control
unit writes the bits 11111110 to the receive shift register
and activates RECEIVE in the next clock phase.
RECEIVE enables SHIFT CLOCK to the alternate output
function line of P3.1. SHIFT CLOCK makes transitions at
S3P1 and S6P1 of every machine cycle. At S6P2 of every
machine cycle in which RECEIVE is active, the contents of
the receive shift register are shifted on position to the left.
The value that comes in from the right is the value that was
sampled at the P3.0 pin at S5P2 of the same machine
cycle.
As data bits come in from the right, 1s shift out to the left.
When the 0 that was initially loaded into the right-most
position arrives at the left-most position in the shift register,
it flags the RX Control block to do one last shift and load
SBUF. At S1P1 of the tenth machine cycle after the write
to SCON that cleared RI, RECEIVE is cleared and RI is set.
More About Mode 1
Ten bits are transmitted (through TXD), or received (through
RXD): a start bit (0), eight data bits (LSB first), and a stop
bit (1). On receive, the stop bit goes into RB8 in SCON. In
the IS89C52 the baud rate is determined by the Timer 1
overflow rate.
Figure 16 shows a simplified functional diagram of the
serial port in Mode 1 and associated timings for transmit
and receive.
Transmission is initiated by any instruction that uses SBUF
as a destination register.
The "write to SBUF" signal also loads a 1 into the ninth bit
position of the transmit shift register and flags the TX
control unit that a transmission is requested. Transmission
actually commences at S1P1 of the machine cycle following
the next rollover in the divide-by-16 counter. Thus, the bit
times are synchronized to the divide-by-16 counter, not to
the "write to SBUF" signal.
The transmission begins when SEND is activated, which
puts the start bit at TXD. One bit time later, DATA is
activated, which enables the output bit of the transmit shift
register to TXD. The first shift pulse occurs one bit time
after that.
As data bits shift out to the right, 0s are clocked in from the
left. When the MSB of the data byte is at the output position
of the shift register, the 1 that was initially loaded into the
ninth position is just to the left of the MSB, and all positions
to the left of that contain 0s. This condition flags the TX
Control unit to do one last shift, then deactivate SEND and
set TI. This occurs at the tenth divide-by-16 rollover after
"write to SBUF".
Reception is initiated by a 1-to-0 transition detected at
RXD. For this purpose, RXD is sampled at a rate of 16
times the established baud rate. When a transition is
detected, the divide-by-16 counter is immediately reset,
and 1FFH is written into the input shift register. Resetting
the divide-by-16 counter aligns its rollovers with the
boundaries of the incoming bit times.
The 16 states of the counter divide each bit time into 16th.
At the seventh, eighth, and ninth counter states of each bit
time, the bit detector samples the value of RXD. The value
accepted is the value that was seen in at least two of the
three samples. This is done to reject noise. In order to
reject false bits, if the value accepted during the first bit
time is not 0, the receive circuits are reset and the unit
continues looking for another 1-to-0 transition. If the start
bit is valid, it is shifted into the input shift register, and
reception of the rest of the frame proceeds.
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
23
IS89C52
®
ISSI
As data bits come in from the right, 1s shift to the left. When
the start bit arrives at the leftmost position in the shift
register, (which is a 9-bit register in Mode 1), it flags the RX
Control block to do one last shift, load SBUF and RB8, and
set RI. The signal to load SBUF and RB8 and to set RI is
generated if, and only if, the following conditions are met
at the time the final shift pulse is generated.
1) RI = 0 and
2) Either SM2 = 0, or the received stop bit =1
If either of these two conditions is not met, the received
frame is irretrievably lost. If both conditions are met, the
stop bit goes into RB8, the eight data bits go into SBUF,
and RI is activated. At this time, whether or not the above
conditions are met, the unit continues looking for a 1-to-0
transition in RXD.
More About Modes 2 and 3
Eleven bits are transmitted (through TXD), or received
(through RXD): a start bit (0), eight data bits (LSB first), a
programmable ninth data bit, and a stop bit (1). On
transmit, the ninth data bit (TB8) can be assigned the value
of 0 or 1. On receive, the ninth data bit goes into RB8 in
SCON. The baud rate is programmable to either 1/32 or
1/64 of the oscillator frequency in Mode 2. Mode 3 may
have a variable baud rate generated from Timer 1.
Figures 17 and 18 show a functional diagram of the serial
port in Modes 2 and 3. The receive portion is exactly the
same as in Mode 1. The transmit portion differs from Mode
1 only in the ninth bit of the transmit shift register.
Transmission is initiated by any instruction that uses SBUF
as a destination register. The "write to SBUF" signal also
loads TB8 into the ninth bit position of the transmit shift
register and flags the TX Control unit that a transmission
is requested. Transmission commences at S1P1 of the
machine cycle following the next rollover in the divide-by16 counter. Thus, the bit times are synchronized to the
divide-by-16 counter, not to the "write to SBUF" signal.
The transmission begins when SEND is activated, which
puts the start bit at TXD. One bit timer later, DATA is
activated, which enables the output bit of the transmit shift
register to TXD. The first shift pulse occurs one bit time
after that. The first shift clocks a 1 (the stop bit) into the
ninth bit position of the shift register. Thereafter, only 0s
are clocked in. Thus, as data bits shift out to the right, 0s
are clocked in from the left. When TB8 is at the output
position of the shift register, then the stop bit is just to the
left of TB8, and all positions to the left of that contain 0s.
This condition flags the TX Control unit to do one last shift,
then deactivate SEND and set TI. This occurs at the
eleventh divide-by-16 rollover after "write to SBUF".
Reception is initiated by a 1-to-0 transition detected at
RXD. For this purpose, RXD is sampled at a rate of 16
times the established baud rate. When a transition is
detected, the divide-by-16 counter is immediately reset,
and 1FFH is written to the input shift register.
At the seventh, eighth, and ninth counter states of each bit
time, the bit detector samples the value of RXD. The value
accepted is the value that was seen in at least two of the
three samples. If the value accepted during the first bit time
is not 0, the receive circuits are reset and the unit continues
looking for another 1-to-0 transition. If the start bit proves
valid, it is shifted into the input shift register, and reception
of the rest of the frame proceeds.
As data bits come in from the right, 1s shift out to the left.
When the start bit arrives at the leftmost position in the shift
register (which in Modes 2 and 3 is a 9-bit register), it flags
the RX Control block to do one last shift, load SBUF and
RB8, and set RI. The signal to load SBUF and RB8 and to
set RI is generated if, and only if, the following conditions
are met at the time the final shift pulse is generated:
1) RI = 0, and
2) Either SM2 = 0 or the received ninth data bit = 1
If either of these conditions is not met, the received frame
is irretrievably lost, and RI is not set. If both conditions are
met, the received ninth data bit goes into RB8, and the first
eight data bits go into SBUF. One bit time later, whether the
above conditions were met or not, the unit continues
looking for a 1-to-0 transition at the RXD input.
Note that the value of the received stop bit is irrelevant to
SBUF, RB8, or RI.
Table 10. Serial Port Setup
ModeSCONSM2Variation
010H
150H
290H
3D0H
0NA
170H
2B0H
3F0H
Single Processor
Environment
(SM2 = 0)
Multiprocessor
Environment
(SM2 = 1)
24
Integrated Silicon Solution, Inc. — 1-800-379-4774
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
25
IS89C52
®
ISSI
TIMER 1
OVERFLOW
÷ 2
SMOD
= 0
TCLK
RCLK
SMOD
= 1
"0""1"
"0"
TIMER 2
OVERFLOW
"1"
SAMPLE
RXD
WRITE
TO
SBUF
÷ 16
1-TO-0
TRANSITION
DETECTOR
TB8
S
Q
D
CL
START
RX CLOCK
÷ 16
RX CLOCK
START
BIT
DETECTOR
IS89C52 INTERNAL BUS
SBUF
ZERO DETECTOR
SHIFT
TX CONTROL
TI
RI
RX CONTROL
INPUT SHIFT REG.
LOAD
SBUF
DATA
SEND
LOAD
SBUF
SHIFT
1FFH
(9 BITS)
TXD
SERIAL
PORT
INTERRUPT
SHIFT
TX CLOCK
WRITE TO SBUF
SEND
DATA
SHIFT
TXD
RECEIVE
S1P1
START
BIT
TI
RX
CLOCK
RXD
BIT DETECTOR SAMPLE TIMES
SHIFT
RI
READ
SBUF
IS89C52 INTERNAL BUS
D0D1D2D3D5D6
÷ 16 RESET
START
D0D1D2D3D5D6
BIT
D4
D4
Figure 16. Serial Port Mode 1
SBUF
TRANSMIT
D7
STOP BIT
D7
STOP BIT
26
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
IS89C52
®
ISSI
PHASE 2 CLOCK
(1/2 f
OSC)
MODE 2
÷ 2
(SMOD IS PCON. 7)
RXD
SMOD 1
SMOD 0
SAMPLE
WRITE
TO
SBUF
÷ 16
1-TO-0
TRANSITION
DETECTOR
TB8
S
D
CL
START
TX CLOCK
÷ 16
START
BIT
DETECTOR
IS89C52 INTERNAL BUS
Q
ZERO DETECTOR
STOP BIT GEN
TX CONTROL
TI
RI
RX
CLOCK
RX CONTROL
LOAD
SBUF
SBUF
SHIFT
DATA
SEND
SERIAL
PORT
INTERRUPT
LOAD
SBUF
SHIFT
1FFH
INPUT SHIFT REG.
(9 BITS)
TXD
SHIFT
WRITE TO SBUF
DATA
SHIFT
RECEIVE
TX
CLOCK
SEND
S1P1
START
BIT
TI
STOP BIT GEN
RX
CLOCK
RXD
BIT DETECTOR SAMPLE TIMES
SHIFT
RI
READ
SBUF
IS89C52 INTERNAL BUS
D0D1D2D3D5D6
÷ 16 RESET
START
D0D1D2D3D5D6
BIT
D4
SBUF
TRANSMIT
D7TB8
D4
STOP BITTXD
RB8
D7
STOP
BIT
Figure 17. Serial Port Mode 2
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
27
IS89C52
®
ISSI
TIMER 1
OVERFLOW
÷ 2
SMOD
= 0
RCLK
TCLK
SMOD
= 1
"0""1"
"0"
TIMER 2
OVERFLOW
"1"
SAMPLE
RXD
WRITE
TO
SBUF
÷ 16
1-TO-0
TRANSITION
DETECTOR
TB8
S
Q
D
CL
START
TX CLOCK
÷ 16
RX CLOCK
START
BIT
DETECTOR
IS89C52 INTERNAL BUS
SBUF
ZERO DETECTOR
TI
RI
LOAD
SBUF
SHIFT
INPUT SHIFT REG.
TX CONTROL
RX CONTROL
DATA
SEND
LOAD
SBUF
SHIFT
1FFH
(9 BITS)
SERIAL
PORT
INTERRUPT
SHIFT
TXD
WRITE TO SBUF
SEND
DATA
SHIFT
RECEIVE
TX
CLOCK
S1P1
START
BIT
TI
STOP BIT GEN
RX
CLOCK
RXD
BIT DETECTOR SAMPLE TIMES
SHIFT
RI
READ
SBUF
IS89C52 INTERNAL BUS
D0D1D2D3D5D6
÷ 16 RESET
START
D0D1D2D3D5D6
BIT
D4
SBUF
TRANSMIT
TB8D7
STOP BITTXD
D4
RB8
D7
STOP
BIT
28
Figure 18. Serial Port Mode 3
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
IS89C52
INTERRUPT SYSTEM
®
ISSI
The IS89C52 provides six interrupt sources: two external
interrupts, two timer interrupts, and a serial port interrupt.
These are shown in Figure 19.
The External Interrupts
INT0
and
INT1
can each be either
level-activated or transition-activated, depending on bits
IT0 and IT1 in Register TCON. The flags that actually
generate these interrupts are the IE0 and IE1 bits in
TCON. When the service routine is vectored, hardware
clears the flag that generated an external interrupt only if
the interrupt was transition-activated. If the interrupt was
level-activated, then the external requesting source (rather
than the on-chip hardware) controls the request flag.
The Timer 0 and Timer 1 Interrupts are generated by TF0
and TF1, which are set by a rollover in their respective
Timer/Counter registers (except for Timer 0 in Mode 3).
When a timer interrupt is generated, the on-chip hardware
clears the flag that generated it when the service routine is
vectored to.
The Serial Port Interrupt is generated by the logical OR of
RI and TI. Neither of these flags is cleared by hardware
when the service routine is vectored to. In fact, the service
routine normally must determine whether RI or TI generated
the interrupt, and the bit must be cleared in software.
In the IS89C52, the Timer 2 Interrupt is generated by the
logical OR of TF2 and EXF2. Neither of these flags is
cleared by hardware when the service routine is vectored
to. In fact, the service routine may have to determine
whether TF2 or EXF2 generated the interrupt, and the bit
must be cleared in software.
All of the bits that generate interrupts can be set or cleared
by software, with the same result as though they had been
set or cleared by hardware. That is, interrupts can be
generated and pending interrupts can be canceled in
software.
Each of these interrupt sources can be individually enabled
or disabled by setting or clearing a bit in Special Function
Register IE (interrupt enable) at address 0A8H. As well as
individual enable bits for each interrupt source, there is a
global enable/disable bit that is cleared to disable all
interrupts or set to turn on interrupts (see SFR IE).
INT0
INT1
T2EX
TCON.1
EXTERNAL
INT RQST 0
TCON.5
TIMER/COUNTER 0
TCON.3
EXTERNAL
INT RQST 1
TCON.7
TIMER/COUNTER 1
INTERNAL
SERIAL
PORT
TIMER/
COUNTER 2
SCON.0
RI
SCON.1
TI
T2CON.7
TF2
T2CON.6
EXF2
IE0
TF0
IE1
TF1
IE.0
EX0
IE.1
ET0
IE.2
EX1
IE.3
ET1
IE.4
ES
IE.5IP.5
IE.7
IP.0
PX0
IP.1
PT0
IP.2
PX1
IP.3
PT1
IP.4
PS
PT2ET2EA
POLLING
HARDWARE
SOURCE
I.D.
SOURCE
I.D.
HIGH PRIORITY
INTERRUPT
REQUEST
VECTOR
LOW PRIORITY
INTERRUPT
REQUEST
VECTOR
Figure 19. Interrupt System
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
29
IS89C52
Priority Level Structure
Each interrupt source can also be individually programmed
to one of two priority levels by setting or clearing a bit in
Special Function Register IP (interrupt priority) at address
0B8H. IP is cleared after a system reset to place all
interrupts at the lower priority level by default. A lowpriority interrupt can be interrupted by a high-priority
interrupt but not by another low-priority interrupt. A highpriority interrupt can not be interrupted by any other
interrupt source.
If two requests of different priority levels are received
simultaneously, the request of higher priority level is
serviced. If requests of the same priority level are received
simultaneously, an internal polling sequence determines
which request is serviced. Thus, within each priority level
there is a second priority structure determined by the
polling sequence, as follows:
SourcePriority Within Level
1.IE0(Highest)
2.TF0
3.IE1
4.TF1
5.RI + TI(Lowest)
Note that the "priority within level" structure is only used to
resolve
How Interrupts Are Handled
The interrupt flags are sampled at S5P2 of every machine
cycle. The samples are polled during the following machine
cycle (the Timer 2 interrupt cycle is different, as described
in the Response Timer Section). If one of the flags was in
a set condition at S5P2 of the preceding cycle, the polling
simultaneous requests of the same priority level
cycle will find it and the interrupt system will generate an
LCALL to the appropriate service routine, provided this
hardware generated LCALL is not blocked by any of the
following conditions:
1. An interrupt of equal or higher priority level is already
in progress.
2. The current (polling) cycle is not the final cycle in the
execution of the instruction in progress.
3. The instruction in progress is RETI or any write to the
IE or IP registers.
Any of these three conditions will block the generation of
the LCALL to the interrupt service routine. Condition 2
ensures that the instruction in progress will be completed
before vectoring to any service routine. Condition 3 ensures
that if the instruction in progress is RETI or any access to
IE or IP, then at least one more instruction will be executed
before any interrupt is vectored to.
The polling cycle is repeated with each machine cycle, and
the values polled are the values that were present at S5P2
of the previous machine cycle. If an active interrupt flag is
not being serviced because of one of the above conditions
and is not still active when the blocking condition is
removed, the denied interrupt will not be serviced. In other
words, the fact that the interrupt flag was once active but
.
not serviced is not remembered. Every polling cycle is
new. The polling cycle/LCALL sequence is illustrated in
Figure 20.
Note that if an interrupt of higher priority level goes active
prior to S5P2 of the machine cycle labeled C3 in Figure 20,
then in accordance with the above rules it will be serviced
during C5 and C6, without any instruction of the lower
priority routine having been executed.
®
ISSI
30
INTERRUPT
GOES ACTIVE
E
C1
S5P2
INTERRUPT
LATCHED
S6
INTERRUPTS
ARE POLLED
LONG CALL TO
INTERRUPT
VECTOR ADDRESS
Figure 20. Interrupt Response Timing Diagram
Integrated Silicon Solution, Inc. — 1-800-379-4774
C4C3C2
C5
INTERRUPT
ROUTINE
MC013-1C
11/21/98
IS89C52
®
ISSI
Thus, the processor acknowledges an interrupt request by
executing a hardware-generated LCALL to the appropriate
servicing routine. In some cases it also clears the flag that
generated the interrupt, and in other cases it does not. It
never clears the Serial Port or Timer 2 flags. This must be
done in the user's software. The processor clears an
external interrupt flag (IE0 or IE1) only if it was transitionactivated. The hardware-generated LCALL pushes the
contents of the Program Counter onto the stack (but it does
not save the PSW) and reloads the PC with an address that
depends on the source of the interrupt being serviced, as
shown in the following table.
InterruptInterruptCleared byVector
SourceRequest BitsHardwareAddress
INT0
Timer 0TF0Yes000BH
INT1
Timer 1TF1Yes001BH
Serial PortRI, TINo0023H
Timer 2TF2, EXF2No002BH
SystemRST0000H
Reset
Execution proceeds from that location until the RETI
instruction is encountered. The RETI instruction informs
the processor that this interrupt routine is no longer in
progress, then pops the top two bytes from the stack and
reloads the Program Counter. Execution of the interrupted
program continues from where it left off.
Note that a simple RET instruction would also have returned
execution to the interrupted program, but it would have left
the interrupt control system thinking an interrupt was still in
progress.
InterruptFlagBit Position
External 0IE0TCON.1
External 1IE1TCON.3
Timer 1TF1TCON.7
Timer 0TF0TCON.5
Serial PortTISCON.1
Serial PortRISCON.0
Timer 2TF2T2CON.7
Timer 2EXF2T2CON.6
IE0No (level)0003H
Yes (trans.)
IE1No (level)0013H
Yes (trans.)
SFR Register and
When an interrupt is accepted, the following action occurs:
1. The current instruction completes operation.
2. The PC is saved on the stack.
3. The current interrupt status is saved internally.
4. Interrupts are blocked at the level of the interrupts.
5. The PC is loaded with the vector address of the ISR
(interrupts service routine).
6. The ISR executes.
The ISR executes and takes action in response to the
interrupt. The ISR finishes with RETI (return from interrupt)
instruction. This retrieves the old value of the PC from the
stack and restores the old interrupt status. Execution of the
main program continues where it left off.
External Interrupts
The external sources can be programmed to be levelactivated or transition-activated by setting or clearing bit
IT1 or IT0 in Register TCON. If ITx= 0, external interrupt x
is triggered by a detected low at the
external interrupt x is edge-triggered. In this mode if
successive samples of the
cycle and a low in the next cycle, interrupt request flag IEx
in TCON is set. Flag bit IEx then requests the interrupt.
Since the external interrupt pins are sampled once each
machine cycle, an input high or low should hold for at least
12 oscillator periods to ensure sampling. If the external
interrupt is transition-activated, the external source has to
hold the request pin high for at least one machine cycle,
and then hold it low for at least one machine cycle to
ensure that the transition is seen so that interrupt request
flag IEx will be set. IEx will be automatically cleared by the
CPU when the service routine is called.
If the external interrupt is level-activated, the external
source has to hold the request active until the requested
interrupt is actually generated. Then the external source
must deactivate the request before the interrupt service
routine is completed, or else another interrupt will be
generated.
INTx
INTx
pin. If ITx = 1,
pin show a high in one
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
31
IS89C52
®
ISSI
Response Time
The
INT0
and
INT1
levels are inverted and latched into the
interrupt flags IE0 and IE1 at S5P2 of every machine cycle.
Similarly, the Timer 2 flag EXF2 and the Serial Port flags
RI and TI are set at S5P2. The values are not actually
polled by the circuitry until the next machine cycle.
The Timer 0 and Timer 1 flags, TF0 and TF1, are set at
S5P2 of the cycle in which the timers overflow. The values
are then polled by the circuitry in the next cycle. However,
the Timer 2 flag TF2 is set at S2P2 and is polled in the same
cycle in which the timer overflows.
If a request is active and conditions are right for it to be
acknowledged, a hardware subroutine call to the requested
service routine will be the next instruction executed. The
call itself takes two cycles. Thus, a minimum of three
complete machine cycles elapsed between activation of
an external interrupt request and the beginning of execution
of the first instruction of the service routine. Figure 19
shows response timings.
A longer response time results if the request is blocked by
one of the three previously listed conditions. If an interrupt
of equal or higher priority level is already in progress, the
additional wait time depends on the nature of the other
interrupt's service routine. If the instruction in progress is
not in its final cycle, the additional wait time cannot be more
than three cycles, since the longest instructions (MUL and
DIV) are only four cycles long. If the instruction in progress
is RETI or an access to IE or IP, the additional wait time
cannot be more than five cycles (a maximum of one more
cycle to complete the instruction in progress, plus four
cycles to complete the next instruction if the instruction is
MUL or DIV).
Single-Step Operation
The IS89C52 interrupt structure allows single-step
execution with very little software overhead. As previously
noted, an interrupt request will not be serviced while an
interrupt of equal priority level is still in progress, nor will it
be serviced after RETI until at least one other instruction
has been executed. Thus, once an interrupt routine has
been entered, it cannot be re-entered until at least one
instruction of the interrupted program is executed. One
way to use this feature for single-step operation is to
program one of the external interrupts (for example,
to be level-activated. The service routine for the interrupt
will terminate with the following code:
JNBP3.2,$;Wait Here Till
JBP3.2,$;Now Wait Here Till it Goes Low
RETI;Go Back and Execute One
Instruction
If the
INT0
pin, which is also the P3.2 pin, is held normally
low, the CPU will go right into the External Interrupt 0
routine and stay there until INT0 is pulsed (from low-tohigh-to-low). Then it will execute RETI, go back to the task
program, execute one instruction, and immediately reenter the External Interrupt 0 routine to await the next
pulsing of P3.2. One step of the task program is executed
each time P3.2 is pulsed.
INT0
Goes High
INT0
)
Thus, in a single-interrupt system, the response time is
always more than three cycles and less than nine cycles.
32
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
IS89C52
®
ISSI
OTHER INFORMATION
Reset
The reset input is the RST pin, which is the input to a
Schmitt Trigger.
A reset is accomplished by holding the RST pin high for at
least two machine cycles (24 oscillator periods),
oscillator is running
internal reset, with the timing shown in Figure 21.
The external reset signal is asynchronous to the internal
clock. The RST pin is sampled during State 5 Phase 2 of
every machine cycle. The port pins will maintain their
current activities for 19 oscillator periods after a logic 1 has
been sampled at the RST pin; that is, for 19 to 31 oscillator
periods after the external reset signal has been applied to
the RST pin.
The internal reset algorithm writes 0s to all the SFRs
except the port latches, the Stack Pointer, and SBUF. The
port latches are initialized to FFH, the Stack Pointer to 07H,
and SBUF is indeterminate. Table 9 lists the SFRs and
their reset values.
Then internal RAM is not affected by reset. On power-up
the RAM content is indeterminate.
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
ADDR
11 OSC. PERIODS
INSTINSTINST
SAMPLE
RST
ADDRADDRADDR
Figure 21. Reset Timing
19 OSC. PERIODS
INTERNAL RESET SIGNAL
INST
ADDR
33
IS89C52
Power-on Reset
For the IS89C52, the external resistor can be removed
because the RST pin has an internal pulldown.
The capacitor value can then be reduced to 1 µF (see
Figure 22).
When power is turned on, the circuit holds the RST pin high
for an amount of time that depends on the value of the
capacitor and the rate at which it charges. To ensure a
good reset, the RST pin must be high long enough to allow
the oscillator time to start-up (normally a few msec) plus
two machine cycles.
Note that the port pins will be in a random state until the
oscillator has start and the internal reset algorithm has
written 1s to them.
With this circuit, reducing VCC quickly to 0 causes the RST
pin voltage to momentarily fall below 0V. However, this
voltage is internally limited and will not harm the device.
Vcc
1.0 µF
Figure 22. Power-On Reset Circuit
+
IS89C52
RST
GND
®
ISSI
Vcc
34
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
IS89C52
OSC
CLOCK
GEN
PD
XTAL 2XTAL 1
IDL
CPU
INTERRUPT,
SERIAL PORT,
TIMER BLOCKS
Power-Saving Modes of Operation
The IS89C52 has two power-reducing modes. Idle and
Power-down. The input through which backup power is
supplied during these operations is Vcc. Figure 23 shows
the internal circuitry which implements these features. In
the Idle mode (IDL = 1), the oscillator continues to run and
the Interrupt, Serial Port, and Timer blocks continue to be
clocked, but the clock signal is gated off to the CPU. In
Power-down (PD = 1), the oscillator is frozen. The Idle and
Power-down modes are activated by setting bits in Special
Function Register PCON.
®
ISSI
Idle Mode
An instruction that sets PCON.0 is the last instruction
executed before the Idle mode begins. In the Idle mode, the
internal clock signal is gated off to the CPU, but not to the
Interrupt, Timer, and Serial Port functions. The CPU status
is preserved in its entirety; the Stack Pointer, Program
Counter, Program Status Word, Accumulator, and all other
registers maintain their data during Idle. The port pins hold
the logical states they had at the time Idle was activated.
ALE and
PSEN
hold at logic high levels.
There are two ways to terminate the Idle. Activation of any
enabled interrupt will cause PCON.0 to be cleared by
hardware, terminating the Idle mode. The interrupt will be
serviced, and following RETI the next instruction to be
executed will be the one following the instruction that put
the device into Idle.
The flag bits GF0 and GF1 can be used to indicate whether
an interrupt occurred during normal operation or during an
Idle. For example, an instruction that activates Idle can
also set one or both flag bits. When Idle is terminated by an
interrupt, the interrupt service routine can examine the flag
bits.
The other way of terminating the Idle mode is with a
hardware reset. Since the clock oscillator is still running,
the hardware reset must be held active for only two
machine cycles (24 oscillator periods) to complete the
reset.
Figure 23. Idle and Power-Down Hardware
Power-down Mode
An instruction that sets PCON.1 is the last instruction
executed before Power-down mode begins. In the Powerdown mode, the on-chip oscillator stops. With the clock
frozen, all functions are stopped, but the on-chip RAM and
Special function Registers are held. The port pins output
the values held by their respective SFRs. ALE and
PSEN
output lows.
In the Power-down mode of operation, Vcc can be reduced
to as low as 2V. However, Vcc must not be reduced before
the Power-down mode is invoked, and Vcc must be restored
to its normal operating level before the Power-down mode
is terminated. The reset that terminates Power-down also
frees the oscillator. The reset should not be activated
before Vcc is restored to its normal operating level and
must be held active long enough to allow the oscillator to
restart and stabilize (normally less than 10 msec).
The only exit from Power-down is a hardware reset. Reset
redefines all the SFRs but does not change the on-chip
RAM.
The signal at the RST pin clears the IDL bit directly and
asynchronously. At this time, the CPU resumes program
execution from where it left off; that is, at the instruction
following the one that invoked the Idle Mode. As shown in
Figure 22, two or three machine cycles of program execution
may take place before the internal reset algorithm takes
control. On-chip hardware inhibits access to the internal
RAM during his time, but access to the port pins is not
inhibited. To eliminate the possibility of unexpected outputs
at the port pins, the instruction following the one that
invokes Idle should not write to a port pin or to external data
RAM.
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
35
IS89C52
Table 12. Status of the External Pins During Idle and Power-down Modes.
The on-chip oscillator circuitry of the IS89C52 is a single
stage inverter, intended for use as a crystal-controlled,
positive reactance oscillator. In this application the crystal
is operated in its fundamental response mode as an
inductive reactance in parallel resonance with capacitance
external to the crystal (Figure 24). Examples of how to
drive the clock with external oscillator are shown in
Figure 25.
The crystal specifications and capacitance values (C1 and
C2 in Figure 24) are not critical. 20 pF to 30 pF can be used
in these positions at a 12 MHz to 24 MHz frequency with
good quality crystals. (For ranges greater than 24 MHz
refer to Figure 26.) A ceramic resonator can be used in
place of the crystal in cost-sensitive applications. When a
ceramic resonator is used, C1 and C2 are normally selected
to be of somewhat higher values. The manufacturer of the
ceramic resonator should be consulted for recommendation
on the values of these capacitors.
C2
C1
Figure 21. Oscillator Connections
XTAL2
XTAL1
GND
NC
EXTERNAL
OSCILLATOR
SIGNAL
XTAL2
XTAL1
GND
Figure 22. External Clock Drive Configuration
36
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
IS89C52
®
ISSI
XTAL2XTAL1
R
C1
Figure 26. Oscillator Connections for High Speed (> 24 MHz)
Note:
When the frequency is higher than 24 MHz, please refer to Table 11 for recommended values of C1, C2, and R.
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
37
IS89C52
Program Memory Lock System
The program lock system, when programmed, protects
the code against software piracy. The IS89C52 has a
three-level program lock system (see Table 14). The lockbits are programmed in the same manner as the program
memory.
The detailed lock-bits features are listed in Table 14.
Table 14. Program Lock Bits
LB1LB2LB3Protection Type
1 UUU No Program Lock Features enabled.
2PUUMOVC instructions executed from external program memory are diabled
form fetching code bytes from internal memory, EA is sampled and
latched on Reset and further programming of the Flash is disabled.
3PPUSame as 2, also verify is disabled.
4 PPP Same as 3, also external execution is disabled.
®
ISSI
FLASH MEMORY
Programming the IS89C52
The IS89C52 is normally shipped with the on-chip Flash
memory array in the erased state (i.e., contents = FFH)
and ready to be programmed. The IS89C52 is programmed
byte-by-byte in programming mode. Before the on-chip
flash code memory can be re-programmed, the entire
memory array must be erased electrically.
Table 15. Flash Programming Mode
ModeRST
Program Code DataHL12VLHHH
Verify Code DataHLHHLLHH
Program Lock Bit 1HL12VHHHH
Program Lock Bit 2HL12VHHLL
Program Lock Bit 3HL12VHLHL
Read Signature ByteHLHHLLLL
Chip EraseHL12VHLLL
PSENPSEN
PSEN
PSENPSEN
ALE/
PROGPROG
PROG
PROGPROG
Programming Interface
Every code byte in the Flash array can be written and the
entire array can be erased using the appropriate
combination of control signals. The write operation cycles
is self-timed once initiated, will automatically time itself to
completion. The programming interface is shown in
Table 15 and Figures 27 and 28.
EAEA
EA
/VPPP2.6P2.7P3.6P3.7
EAEA
38
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
IS89C52
®
ISSI
CONTROL
SIGNALS
3.5-12 MHz
+ 5V
Vcc
P0
ALE
EA
RST
A0-A7
A11-A8
IS89LV52
P1
P2.0-P2.3
P2.6
P2.7
P3.6
P3.7
XTAL2
XTAL1
GND
PSEN
Figure 27. Programming the Flash Memory
PGM
DATA
PROG
V
PP
V
IH
CONTROL
SIGNALS
3.5-12 MHz
+ 5V
Vcc
P0
ALE
EA
RST
A0-A7
A12-A8
IS89LV52
P1
P2.0-P2.4
P2.6
P2.7
P3.6
P3.7
XTAL2
XTAL1
GND
PSEN
Figure 28. Verifying the Flash Memory
PGM DATA
(USE 10K
PULLUPS)
V
IH
V
IH
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
39
IS89C52
®
ISSI
Programming Algorithm
Before programming the IS89C52, the control signals, the
address, data should be setup according to the
programming mode table and programming interface. To
program the IS89C52, the following sequence should be
followed:
1. Insert the desired memory location on the
address bus.
2. Insert the appropriate data byte on the data bus.
3. Active the correct combination of control signals.
4. Raise EA / VPP to 12V.
5. Pulse ALE /
Flash array, Encryption array or the lock bits.
6. Set EA / VPP to 5 V and verify data. If the data is correct
then execute step 7, otherwise execute steps 1-6.
7. Repeat steps 1 through 6, changing the address
and data for the entire array or until the end of the
object file is reached.
PROG
once to program a byte in the
Program Verify
If lock bits LB1, LB2 and LB3 have not been programmed,
the programmed code data can be read back via the
address and data lines for verification. The lock bits cannot
be verified directly. Verification of lock bits is achieved by
observing that their features are enabled.
To verify the data after all addresses are programmed
completely, power down the IS89C52 and then reapply
power. The programmed data can then be verified by
applying the verify signals to the device.
Erasing Chip
All Flash memory cells must be programmed to '00' (include
encryption array and lock bits) before the chip is erased.
The entire Flash array is erased electrically by using the
proper combination of control signals and by holding ALE/
PROG
low for tGLGHE duration (See Table 16. Flash
Programming and Verification Characteristics for tGLGHE
value.) After the chip is erased, the code array and lock bits
are written with all “1”s. If any Flash memory cell is not '1'
(including lock bits), repeat the chip erase again. The chip
erase operation must be executed successfully before the
code memory can be re-programmed.
Reading the Signature Bytes
The signature bytes are read by the same procedure as a
normal verification of locations 030H, 031H and 032H,
except that P3.6 and P3.7 need to be pulled to a logic low.
The values returned are:
Signature
LocationValue
(030H)D5H indicates manufactured
by ISSI
(031H)51H indicates IS89C52
(032H)FFH indicates programming
voltage is 12V
40
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
IS89C52
FLASH PROGRAMMING AND VERIFICATION CHARACTERISTICS AND WAVEFORMS
®
ISSI
Table 16. Flash Programming and Verification Characteristics
(1)
SymbolParameterMinMaxUnit
VPPProgramming Supply Voltage11.512.5V
1/tCLCLOscillator Frequency3.512MHz
tAVGLAddress Setup to
tGHAXAddress Hold after
tDVGLData Setup to
tGHDXData Hold after
PROG
Low48—tCLCL
PROG
PROG
Low48—tCLCL
PROG
48—tCLCL
48—tCLCL
tEHSHCOND ENABLE to VPPH48—tCLCL
tSHGLVPPH Setup to
tGHSLVPPH Hold after
tGLGH
tGHGL
PROG
Pulse Width120—µs
PROG
High to
PROG
Low10—µs
PROG
PROG
Low10—µs
10—µs
tAVQVAddress to Data Valid—48tCLCL
tELQVCOND ENABLE to Data Valid—48tCLCL
tEHQZData Float after COND DISABLE—48tCLCL
tGLGHEErase
PROG
Pulse Width200—ms
tELPLCOND DISABLE to Power Low0—ns
tPLPHPower Off Time10—µs
tPHEHPower On to VPPL10—ms
tEHVHVPPL to COND ENABLE0—ns
Notes:
A = 21°C to 27°C, Vcc = 5.0V ± 10%.
1. T
2. COND ENABLE and COND DISABLE are generated and depend on the control signals on pins P2.6,
P2.7, P3.6 and P3.7. The signals set the device in to and out of different processing conditions, such
as programming condition, erasing condition, and verify condition.
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
41
IS89C52
®
ISSI
P2.3-P2.0
P1.7-P1.0
tAVGL
P0.7-P0.0
tDVGL
EA/VPP
tSHGL
25 PULSE
tGLGH
V
tGHDX
PPH
VPPL
tGHSL
(1)
ALE/PROG
tEHSH
P2.6, P2.7
P3.6, P3.7
Notes:
1. One pulse for the main code array, 25 pulses for the encryption array and lock bits.
2. This verify condition is using at main code verification.
3. Power off waveform not shown.
DON'T
CARE
PROGRAMMING COND.
Figure 29. Flash Memory Programming and Verification Timing Waveform
tGHGL
tELQVtELQZ
VERIFY COND.
ADDRESSADDRESS
tAVQVtGHAX
DATA
OUTDATAIN
0V
DON'T
(2)
CARE
Vcc
0V
tPLPH
VPPH
tELPL
0V
0V
0V
tPHEH
VPPL
P2.3-P2.0
P1.7-P1.0
P0.7-P0.0
EA/VPP
tGHSL
tSHGL
ALE/PROG
0V
tGLGHE
tEHSH
P2.6, P2.7
P3.6, P3.7
DON'T
CARE
Figure 30. Flash Memory Erase Timing Waveform
Note:
1. The power off and power on waveform can be used in programming or erasing.
tEHVH
0V
VERIFY COND.ERASE COND.
ADDRESS
tAVQV
OUT
DATA
tELQV
tEHQZ
DON'T
CARE
0V
42
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
IS89C52
®
ISSI
ABSOLUTE MAXIMUM RATINGS
(1)
SymbolParameterValueUnit
VTERMTerminal Voltage with Respect to GND
TBIASTemperature Under Bias
(3)
(2)
–2.0 to +7.0V
–40 to +85°C
TSTGStorage Temperature–65 to +125°C
PTPower Dissipation1.5W
Note:
1. Stress greater than those listed under ABSOLUTE MAXIMUM RATINGS may cause
permanent damage to the device. This is a stress rating only and functional operation
of the device at these or any other conditions above those indicated in the operational
sections of this specification is not implied. Exposure to absolute maximum rating
conditions for extended periods may affect reliability.
2. Minimum DC input voltage is –0.5V. During transitions, inputs may undershoot to –
2.0V for periods less than 20 ns. Maximum DC voltage on output pins is Vcc + 0.5V
which may overshoot to Vcc + 2.0V for periods less than 20 ns.
3. Operating temperature is for commercial products only defined by this specification.
OPERATING RANGE
(1)
RangeAmbient TemperatureVCCOscillator Frequency
Commercial0°C to +70°C5V ± 10%3.5 to 40 MHz
Industrial–40°C to +85°C5V ± 10%3.5 to 40 MHz
Note:
1. Operating ranges define those limits between which the functionality of the device is guaranteed.
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
43
IS89C52
ISSI
DC CHARACTERISTICS
(Over Operating Range; GND = 0V)
SymbolParameterTest conditionsMinMaxUnit
VILInput low voltage (All except EA)–0.50.2Vcc – 0.1V
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
45
IS89C52
Vcc – 0.5V
0.45V
0.7Vcc
0.2Vcc – 0.1
t
CHCL
t
CLCX
t
CLCL
t
CHCX
t
CLCH
®
ISSI
Note:
1. Clock signal waveform for Icc tests in active and idle mode (tCLCH = tCHCL = 5 ns)
Figure 34. Icc Test Conditions
AC CHARACTERISTICS
(Over Operating Range; GND = 0V; CL for Port 0, ALE and
PSEN
Outputs = 100 pF; CL for Other Outputs = 80 pF)
EXTERNAL MEMORY CHARACTERISTICS
24 MHz40 MHzVariable Oscillator
ClockClock(3.5 - 40 MHz)
SymbolParameterMinMaxMin MaxMinMaxUnit
1/tCLCLOscillator frequency————3.540MHz
tLHLLALE pulse width68—35—2tCLCL–15—ns
tAVLLAddress valid to ALE low26—10—tCLCL–15—ns
tLLAXAddress hold after ALE low31—15—tCLCL–10—ns
tLLIVALE low to valid instr in—147—80—4tCLCL–20ns
tLLPLALE low to
tPLPH
tPLIV
tPXIXInput instr hold after
tPXIZInput instr float after
tAVIVAddress to valid instr in—188—105—5tCLCL–20ns
tPLAZ
tRLRH
tWLWH
tRLDV
tRHDXData hold after
tRHDZData float after
tLLDVALE low to valid data in—282—165—7tCLCL–10ns
tAVDVAddress to valid data in—323—190—8tCLCL–10ns
tLLWLALE low to RD or WR low10514555953tCLCL–203tCLCL+20ns
tAVWLAddress to RD or WR low146—80—4tCLCL–20—ns
tQVWXData valid to WR transition26—10—tCLCL –15—ns
tWHQXData hold after
tRLAZ
tWHLH
PSENPSEN
PSENRD
pulse width230—130—6tCLCL–20—ns
WR
pulse width230—130—6tCLCL–20—ns
RD
low to valid data in—157—90—4tCLCL–10ns
RD
low to address float—0—0—0ns
RD
or WR high to ALE high26571040tCLCL–15tCLCL+15ns
PSEN
low31—15—tCLCL–10—ns
pulse width110—60—3tCLCL–15—ns
low to valid instr in—105—55—3tCLCL–20ns
PSENPSEN
low to address float—10—10—10ns
RDRD
WR
0—0—0—ns
—37—20—tCLCL–5ns
0—0—0—ns
—78—45—2tCLCL–5ns
31—15—tCLCL–10—ns
46
Integrated Silicon Solution, Inc. — 1-800-379-4774
MC013-1C
11/21/98
IS89C52
SERIAL PORT TIMING: SHIFT REGISTER MODE
24 MHz40 MHzVariable Oscillator
ClockClock(3.5-40 MHz)
SymbolParameterMinMaxMin MaxMinMaxUnit
tXLXLSerial port clock cycle time490510290 31012tCLCL–1012tCLCL+10ns
tQVXHOutput data setup to406—240—10tCLCL–10—ns