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).