Is an 8-bit open drain bi-directional I/O port. Port 0 pins that have 1’s written to them float, and in this state can be used as
high-impedance 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 pull-ups when emitting 1’s.
Port 0 also outputs the code Bytes during program validation. External pull-ups are required during program verification.
AT89C51AC3
P1.0:7I/OPort 1:
Is an 8-bit bi-directional I/O port with internal pull-ups. Port 1 pins can be used for digital input/output or as analog inputs for
the Analog Digital Converter (ADC). Port 1 pins that have 1’s written to them are pulled high by the internal pull-up transistors
and can be used as inputs in this state. As inputs, Port 1 pins that are being pulled low externally will be the source of current
(IIL, see section "Electrical Characteristic") because of the internal pull-ups. Port 1 pins are assigned to be used as analog
inputs via the ADCCF register (in this case the internal pull-ups are disconnected).
As a secondary digital function, port 1 contains the Timer 2 external trigger and clock input; the PCA external clock input and
the PCA module I/O.
P1.0/AN0/T2
Analog input channel 0,
External clock input for Timer/counter2.
P1.1/AN1/T2EX
Analog input channel 1,
Trigger input for Timer/counter2.
P1.2/AN2/ECI
Analog input channel 2,
PCA external clock input.
P1.3/AN3/CEX0
Analog input channel 3,
PCA module 0 Entry of input/PWM output.
P1.4/AN4/CEX1
Analog input channel 4,
PCA module 1 Entry of input/PWM output.
P1.5/AN5/CEX2
Analog input channel 5,
PCA module 2 Entry of input/PWM output.
P1.6/AN6/CEX3
Analog input channel 6,
PCA module 3 Entry of input/PWM output.
P1.7/AN7/CEX4
Analog input channel 7,
PCA module 4 Entry ot input/PWM output.
Port 1 receives the low-order address byte during EPROM programming and program verification.
It can drive CMOS inputs without external pull-ups.
P2.0:7I/OPort 2:
4383D–8051–02/08
Is an 8-bit bi-directional I/O port with internal pull-ups. Port 2 pins that have 1’s written to them are pulled high by the internal
pull-ups and can be used as inputs in this state. As inputs, Port 2 pins that are being pulled low externally will be a source of
current (IIL, see section "Electrical Characteristic") because of the internal pull-ups. Port 2 emits the high-order address byte
during accesses to the external Program Memory and during accesses to external Data Memory that uses 16-bit addresses
(MOVX @DPTR). In this application, it uses strong internal pull-ups when emitting 1’s. During accesses to external Data
Memory that use 8 bit addresses (MOVX @Ri), Port 2 transmits the contents of the P2 special function register.
It also receives high-order addresses and control signals during program validation.
It can drive CMOS inputs without external pull-ups.
5
AT89C51AC3
Pin NameTypeDescription
P3.0:7I/OPort 3:
Is an 8-bit bi-directional I/O port with internal pull-ups. Port 3 pins that have 1’s written to them are pulled high by the internal
pull-up transistors and can be used as inputs in this state. As inputs, Port 3 pins that are being pulled low externally will be a
source of current (IIL, see section "Electrical Characteristic") because of the internal pull-ups.
The output latch corresponding to a secondary function must be programmed to one for that function to operate (except for
TxD and WR). The secondary functions are assigned to the pins of port 3 as follows:
P3.0/RxD:
Receiver data input (asynchronous) or data input/output (synchronous) of the serial interface
P3.1/TxD:
Transmitter data output (asynchronous) or clock output (synchronous) of the serial interface
P3.2/INT0:
External interrupt 0 input/timer 0 gate control input
P3.3/INT1:
External interrupt 1 input/timer 1 gate control input
P3.4/T0:
Timer 0 counter input
P3.5/T1/SS:
Timer 1 counter input
SPI Slave Select
P3.6/WR:
External Data Memory write strobe; latches the data byte from port 0 into the external data memory
P3.7/RD:
External Data Memory read strobe; Enables the external data memory.
It can drive CMOS inputs without external pull-ups.
P4.0:4I/O Port 4:
Is an 2-bit bi-directional I/O port with internal pull-ups. Port 4 pins that have 1’s written to them are pulled high by the internal
pull-ups and can be used as inputs in this state. As inputs, Port 4 pins that are being pulled low externally will be a source of
current (IIL, on the datasheet) because of the internal pull-up transistor.
The secondary functions are assigned to the 5 pins of port 4 as follows:
P4.0: Regular Port I/O
P4.1: Regular Port I/O
P4.2/MISO:
Master Input Slave Output of SPI controller
P4.3/SCK:
Serial Clock of SPI controller
P4.4/MOSI:
Master Ouput Slave Input of SPI controller
It can drive CMOS inputs without external pull-ups.
6
4383D–8051–02/08
Pin NameTypeDescription
Reset:
RESETI/O
ALEO
PSENO
EAI
XTAL1I
A high level on this pin during two machine cycles while the oscillator is running resets the device. An internal pull-down
resistor to VSS permits power-on reset using only an external capacitor to VCC.
ALE:
An Address Latch Enable output for latching the low byte of the address during accesses to the external memory. The ALE is
activated every 1/6 oscillator periods (1/3 in X2 mode) except during an external data memory access. When instructions are
executed from an internal Flash (EA = 1), ALE generation can be disabled by the software.
PSEN:
The Program Store Enable output is a control signal that enables the external program memory of the bus during external
fetch operations. It is activated twice each machine cycle during fetches from the external program memory. However, when
executing from of the external program memory two activations of PSEN are skipped during each access to the external Data
memory. The PSEN is not activated for internal fetches.
EA:
When External Access is held at the high level, instructions are fetched from the internal Flash. When held at the low level,
AT89C51AC3 fetches all instructions from the external program memory
XTAL1:
Input of the inverting oscillator amplifier and input of the internal clock generator circuits.
To drive the device from an external clock source, XTAL1 should be driven, while XTAL2 is left unconnected. To operate
above a frequency of 16 MHz, a duty cycle of 50% should be maintained.
AT89C51AC3
.
XTAL2O
XTAL2:
Output from the inverting oscillator amplifier.
I/O Configurations
Port 1, Port 3 and Port 4
Each Port SFR operates via type-D latches, as illustrated in Figure 1 for Ports 3 and 4. A
CPU "write to latch" signal initiates transfer of internal bus data into the type-D latch. A
CPU "read latch" signal transfers the latched Q output onto the internal bus. Similarly, a
"read pin" signal transfers the logical level of the Port pin. Some Port data instructions
activate the "read latch" signal while others activate the "read pin" signal. Latch instructi ons are referred to as Read-Modify-Write instructions. Each I/ O line may be
independently programmed as input or output.
Figure 1 shows the structure of Ports 1 and 3, which have internal pull-ups. An external
source can pull the pin low. Each Port pin can be configured either for general-purpose
I/O or for its alternate input output function.
To use a pin for general-purpose output, set or clear the corresponding bit in the Px register (x = 1,3 or 4). To use a pin for general-purpose input, set the bit in the Px register.
This turns off the output FET drive.
To configure a pin for its alternate function, set the bit in the Px register. When the latch
is set, the "alternate output function" signal controls the output level (see Figure 1). The
operation of Ports 1, 3 and 4 is discussed further in the "quasi-Bidirectional Port Operation" section.
4383D–8051–02/08
7
AT89C51AC3
Figure 1. Port 1, Port 3 and Port 4 Structure
D
CL
QP1.X
LATCH
INTERNAL
WRITE
TO
LATCH
READ
PIN
READ
LATCH
P1.x
P3.X
P4.X
ALTERNATE
OUTPUT
FUNCTION
VCC
INTERNAL
PULL-UP (1)
ALTERNATE
INPUT
FUNCTION
P3.x
P4.x
BUS
D
Q
P0.X
LATCH
INTERNAL
WRITE
TO
LATCH
READ
PIN
READ
LATCH
0
1
P0.x (1)
ADDRESS LOW/
DATA
CONTROL
VDD
BUS
(2)
Note:The internal pull-up can be disabled on P1 when analog function is selected.
Port 0 and Port 2
8
Ports 0 and 2 are used for general-purpose I/O or as the external address/data bus. Port
0, shown in Figure 3, differs from the other Ports in not having internal pull-ups. Figure 3
shows the structure of Port 2. An external source can pull a Port 2 pin low.
To use a pin for general-purpose output, set or clear the corresponding bit in the Px register (x = 0 or 2). To use a pin for general-purpose input, set the bit in the Px register to
turn off the output driver FET.
Figure 2. Port 0 Structure
Notes:1. Port 0 is precluded from use as general-purpose I/O Ports when used as
address/data bus drivers.
2. Port 0 internal strong pull-ups assist the logic-one output for memory bus cycles only.
Except for these bus cycles, the pull-up FET is off, Port 0 outputs are open-drain.
4383D–8051–02/08
AT89C51AC3
D
Q
P2.X
LATCH
INTERNAL
WRITE
TO
LATCH
READ
PIN
READ
LATCH
0
1
P2.x (1)
ADDRESS HIGH/
CONTROL
BUS
VDD
INTERNAL
PULL-UP (2)
Figure 3. Port 2 Structure
Notes:1. Port 2 is precluded from use as general-purpose I/O Ports when as address/data bus
drivers.
2. Port 2 internal strong pull-ups FET (P1 in FiGURE) assist the logic-one output for
memory bus cycle.
Read-Modify-Write
Instructions
When Port 0 and Port 2 are used for an external memory cycle, an internal control signal
switches the output-driver input from the latch output to the internal address/data line.
Some instructions read the latch data rather than the pin data. The latch based instructions read the data, modify the data and then rewrite the latch. These are called "ReadModify-Write" instructions. Below is a complete list of these special instructions (see
Table ). When the destination operand is a Port or a Port bit, these instructions read the
latch rather than the pin:
InstructionDescriptionExample
ANLlogical ANDANL P1, A
ORLlogical ORORL P2, A
XRLlogical EX-ORXRL P3, A
JBCjump if bit = 1 and clear bitJBC P1.1, LABEL
CPLcomplement bitCPL P3.0
INCincrementINC P2
DECdecrementDEC P2
It is not obvious the last three instructions in this list are Read-Modify-Write instructions.
DJNZdecrement and jump if not zeroDJNZ P3, LABEL
MOV Px.y, Cmove carry bit to bit y of Port xMOV P1.5, C
CLR Px.yclear bit y of Port xCLR P2.4
SET Px.yset bit y of Port xSET P3.3
These instructions read the port (all 8 bits), modify the specifically addressed bit and
4383D–8051–02/08
9
AT89C51AC3
write the new byte back to the latch. These Read-Modify-Write instructions are directed
READ PIN
INPUT DATA
P1.x
OUTPUT DATA
2 Osc. PERIODS
n
p1(1)
p2
p3
VCCVCCVCC
P2.x
P3.x
P4.x
to the latch rather than the pin in order to avoid possible misinterpretation of voltage
(and therefore, logic) levels at the pin. For example, a Port bit used to drive the base of
an external bipolar transistor can not rise above the transistor’s base-emitter junction
voltage (a value lower than VIL). With a logic one written to the bit, attempts by the CPU
to read the Port at the pin are misinterpreted as logic zero. A read of the latch rather
than the pins returns the correct logic-one value.
Quasi-Bidirectional Port
Operation
Port 1, Port 2, Port 3 and Port 4 have fixed internal pull-ups and are referred to as
"quasi-bidirectional" Ports. When configured as an input, the pin impedance appears as
logic one and sources current in response to an external logic zero condition. Port 0 is a
"true bidirectional" pin. The pins float when configured as input. Resets write logic one to
all Port latches. If logical zero is subsequently written to a Port latch, it can be returned
to input conditions by a logical one written to the latch.
Note:Port latch values change near the end of Read-Modify-Write instruction cycles. Output
buffers (and therefore the pin state) update early in the instruction after Read-ModifyWrite instruction cycle.
Logical zero-to-one transitions in Port 1, Port 2, Port 3 and Port 4 use an additional pullup (p1) to aid this logic transition (see Figure 4.). This increases switch speed. This
extra pull-up sources 100 times normal internal circuit current during 2 oscillator clock
periods. The internal pull-ups are field-effect transistors rather than linear resistors. Pullups consist of three p-channel FET (pFET) devices. A pFET is on when the gate senses
logical zero and off when the gate senses logical one. pFET #1 is turned on for two
oscillator periods immediately after a zero-to-one transition in the Port latch. A logical
one at the Port pin turns on pFET #3 (a weak pull-up) through the inverter. This inverter
and pFET pair form a latch to drive logical one. pFET #2 is a very weak pull-up switched
on whenever the associated nFET is switched off. This is traditional CMOS switch convention. Current strengths are 1/10 that of pFET #3.
Figure 4. Internal Pull-Up Configurations
10
Note:Port 2 p1 assists the logic-one output for memory bus cycles.
4383D–8051–02/08
AT89C51AC3
SFR Mapping
The Special Function Registers (SFRs) of the AT89C51AC3 fall into the following
categories:
2. These registers are bit–addressable.
Sixteen addresses in the SFR space are both byte–addressable and bit–addressable. The bit–addressable SFR’s are those
whose address ends in 0 and 8. The bit addresses, in this area, are 0x80 through to 0xFF.
TL1
0000 0000
DPH
0000 0000
TH0
0000 0000
TH1
0000 0000
WDTRST
1111 1111
AUXR
x001 0100
WDTPRG
xxxx x000
CKCON1
xxxx xxx0
CKCON0
x00 0000
PCON
00x1 0000
A7h
9Fh
97h
8Fh
87h
14
4383D–8051–02/08
AT89C51AC3
Clock
Description
The AT89C51AC3 core needs only 6 clock periods per machine cycle. This feature,
called”X2”, provides the following advantages:
•Divides frequency crystals by 2 (cheaper crystals) while keeping the same CPU
power.
•Saves power consumption while keeping the same CPU power (oscillator power
saving).
•Saves power consumption by dividing dynamic operating frequency by 2 in
operating and idle modes.
•Increases CPU power by 2 while keeping the same crystal frequency.
In order to keep the original C51 compatibility, a divider-by-2 is inserted between the
XTAL1 signal and the main clock input of the core (phase generator). This divider may
be disabled by the software.
An extra feature is available to start after Reset in the X2 mode. This feature can be
enabled by a bit X2B in the Hardware Security Byte. This bit is described in the section
"In-System Programming".
The X2 bit in the CKCON register (see Table 2) allows switching from 12 clock cycles
per instruction to 6 clock cycles and vice versa. At reset, the standard speed is activated
(STD mode).
Setting this bit activates the X2 feature (X2 mode) for the CPU Clock only (see Figure
5.).
The Timers 0, 1 and 2, Uart, PCA or WatchDog switch in X2 mode only if the corresponding bit is cleared in the CKCON register.
The clock for the whole circuit and peripheral is first divided by two before being used by
the CPU core and peripherals. This allows any cyclic ratio to be accepted on the XTAL1
input. In X2 mode, as this divider is bypassed, the signals on XTAL1 must have a cyclic
ratio between 40 to 60%. Figure 5. shows the clock generation block diagram. The X2
bit is validated on the XTAL1÷2 rising edge to avoid glitches when switching from the X2
to the STD mode. Figure 6 shows the mode switching waveforms.
4383D–8051–02/08
15
AT89C51AC3
Figure 5. Clock CPU Generation Diagram
XTAL1
XTAL2
PD
PCON.1
CPU Core
1
0
÷
2
PERIPH
CLOCK
Clock
Peripheral
CPU
CLOCK
CPU Core Clock Symbol
X2
CKCON.0
X2B
Hardware byte
WDX2
CKCON0.6
PCAX2
CKCON0.5
SIX2
CKCON0.4
T2X2
CKCON0.3
T1X2
CKCON0.2
T0X2
CKCON0.1
IDL
PCON.0
1
0
÷
2
1
0
÷
2
1
0
÷
2
1
0
÷
2
1
0
÷
2
1
0
÷
2
X2
CKCON.0
FWd Clock
FPca Clock
FUart Clock
FT2 Clock
FT1 Clock
FT0 Clock
and ADC
On RESET
1
0
÷
2
FSPIClock
SPIX2
CKCON1.0
Clock Symbol
16
4383D–8051–02/08
AT89C51AC3
XTAL1/2
XTAL1
CPU clock
X2 bit
X2 ModeSTD ModeSTD Mode
Figure 6. Mode Switching Waveforms
Note:In order to prevent any incorrect operation while operating in the X2 mode, users must be aware that all peripherals using the
clock frequency as a time reference (UART, timers...) will have their time reference divided by two. For example a free running
timer generating an interrupt every 20 ms will then generate an interrupt every 10 ms. A UART with a 4800 baud rate will have
a 9600 baud rate.
4383D–8051–02/08
17
AT89C51AC3
Registers
Table 2. CKCON0 Register
CKCON0 (S:8Fh)
Clock Control Register
76543210
-WDX2PCAX2SIX2T2X2T1X2T0X2X2
Bit
Number
7-
6WDX2
5PCAX2
4SIX2
3T2X2
2T1X2
1T0X2
0X2
Bit
Mnemonic Description
Reserved
The value read from this bits is indeterminate. Do not set this bit.
WatchDog clock
Clear to select 6 clock periods per peripheral clock cycle.
Set to select 12 clock periods per peripheral clock cycle.
Programmable Counter Array clock
Clear to select 6 clock periods per peripheral clock cycle.
Set to select 12 clock periods per peripheral clock cycle.
Enhanced UART clock (MODE 0 and 2)
Clear to select 6 clock periods per peripheral clock cycle.
Set to select 12 clock periods per peripheral clock cycle.
Timer2 clock
Clear to select 6 clock periods per peripheral clock cycle.
Set to select 12 clock periods per peripheral clock cycle.
Timer1 clock
Clear to select 6 clock periods per peripheral clock cycle.
Set to select 12 clock periods per peripheral clock cycle.
Timer0 clock
Clear to select 6 clock periods per peripheral clock cycle.
Set to select 12 clock periods per peripheral clock cycle.
CPU clock
Clear to select 12 clock periods per machine cycle (STD mode) for CPU and all
the peripherals.
Set to select 6 clock periods per machine cycle (X2 mode) and to enable the
individual peripherals "X2"bits.
(1)
(1)
(1)
(1)
(1)
(1)
18
Note:1. This control bit is validated when the CPU clock bit X2 is set; when X2 is low, this bit
has no effect.
Reset Value = x000 0000b
4383D–8051–02/08
AT89C51AC3
Table 3. CKCON1 Register
CKCON1 (S:9Fh)
Clock Control Register 1
76543210
SPIX2
Bit
Number
7-1-
0SPIX2
Bit
Mnemonic Description
Reserved
The value read from these bits is indeterminate. Do not set these bits.
SPI clock
Clear to select 6 clock periods per peripheral clock cycle.
Set to select 12 clock periods per peripheral clock cycle.
(1)
Note:1. This control bit is validated when the CPU clock bit X2 is set; when X2 is low, this bit
has no effect.
Reset Value = XXXX XXX0b
4383D–8051–02/08
19
AT89C51AC3
Data Memory
Upper
128 Bytes
Internal RAM
Lower
128 Bytes
Internal RAM
Special
Function
Registers
80h
80h
00h
FFh
FFh
direct addressing
addressing
7Fh
direct or indirect
indirect addressing
256 up to 2048 Bytes
00h
64K Bytes
External XRAM
0000h
FFFFh
Internal ERAM
EXTRAM = 0
EXTRAM = 1
FFh or 7FFh
Internal
External
The AT89C51AC3 provides data memory access in two different spaces:
1.The internal space mapped in three separate segments:
•the lower 128 Bytes RAM segment.
•the upper 128 Bytes RAM segment.
•the expanded 2048 Bytes RAM segment (ERAM).
2.The external space.
A fourth internal segment is available but dedicated to Special Function Registers,
SFRs, (addresses 80h to
FFh
) accessible by direct addressing mode.
Figure 8 shows the internal and external data memory spaces organization.
Figure 7. Internal Memory - RAM
Figure 8. Internal and External Data Memory Organization ERAM-XRAM
20
4383D–8051–02/08
AT89C51AC3
Bit-Addressable Space
4 Banks of
8 Registers
R0-R7
30h
7Fh
(Bit Addresses 0-7Fh)
20h
2Fh
18h
1Fh
10h
17h
08h
0Fh
00h
07h
Internal Space
Lower 128 Bytes RAMThe lower 128 Bytes of RAM (see Figure 8) are accessible from address 00h to 7Fh
using direct or indirect addressing modes. The lowest 32 Bytes are grouped into 4
banks of 8 registers (R0 to R7). Two bits RS0 and RS1 in PSW register (see Figure 6)
select which bank is in use according to Table 4. This allows more efficient use of code
space, since register instructions are shorter than instructions that use direct addressing, and can be used for context switching in interrupt service routines.
Table 4. Register Bank Selection
RS1RS0Description
00Register bank 0 from 00h to 07h
01Register bank 0 from 08h to 0Fh
10Register bank 0 from 10h to 17h
11Register bank 0 from 18h to 1Fh
The next 16 Bytes above the register banks form a block of bit-addressable memory
space. The C51 instruction set includes a wide selection of single-bit instructions, and
the 128 bits in this area can be directly addressed by these instructions. The bit
addresses in this area are 00h to 7Fh.
Upper 128 Bytes RAMThe upper 128 Bytes of RAM are accessible from address 80h to FFh using only indirect
addressing mode.
Expanded RAMThe on-chip 2048 Bytes of expanded RAM (ERAM) are accessible from address 0000h
to 07FFh using indirect addressing mode through MOVX instructions. In this address
range, the bit EXTRAM in AUXR register is used to select the ERAM (default) or the
XRAM. As shown in Figure 8 when EXTRAM = 0, the ERAM is selected and when
EXTRAM = 1, the XRAM is selected.
The size of ERAM can be configured by XRS2-0 bit in AUXR register (default size is
2048 Bytes).
4383D–8051–02/08
Note:Lower 128 Bytes RAM, Upper 128 Bytes RAM, and expanded RAM are made of volatile
memory cells. This means that the RAM content is indeterminate after power-up and
must then be initialized properly.
21
AT89C51AC3
External Space
RAM
PERIPHERAL
AT89C51AC3
P2
P0
AD7:0
A15:8
A7:0
A15:8
D7:0
A7:0
ALE
WR
OERD#
WR#
Latch
Memory InterfaceThe external memory interface comprises the external bus (port 0 and port 2) as well as
the bus control signals (RD#, WR#, and ALE).
Figure 10 shows the structure of the external address bus. P0 carries address A7:0
while P2 carries address A15:8. Data D7:0 is multiplexed with A7:0 on P0. Table 5
describes the external memory interface signals.
Figure 10. External Data Memory Interface Structure
Table 5. External Data Memory Interface Signals
Signal
NameTypeDescription
A15:8O
AD7:0I/O
ALEO
RD#O
WR#O
Address Lines
Upper address lines for the external bus.
Address/Data Lines
Multiplexed lower address lines and data for the external
memory.
Address Latch Enable
ALE signals indicates that valid address information are available
on lines AD7:0.
Read
Read signal output to external data memory.
Write
Write signal output to external memory.
Alternative
Function
P2.7:0
P0.7:0
-
P3.7
P3.6
External Bus CyclesThis section describes the b us cycles the AT89C51AC3 execu tes to read (see
Figure 11), and write data (see Figure 12) in the external data memory.
External memory cycle takes 6 CPU clock periods. This is equivalent to 12 oscillator
clock period in standard mode or 6 oscillator clock periods in X2 mode. For further information on X2 mode.
Slow peripherals can be accessed by stretching the read and write cycles. This is done
using the M0 bit in AUXR register. Setting this bit changes the width of the RD# and
WR# signals from 3 to 15 CPU clock periods.
For simplicity, the accompanying figures depict the bus cycle waveforms in idealized
form and do not provide precise timing information. For bus cycle timing parameters
refer to the Section “AC Characteristics” of the AT89C51AC3 datasheet.
22
4383D–8051–02/08
AT89C51AC3
ALE
P0
P2
RD#1
DPL or RiD7:0
DPH or P22
P2
CPU Clock
ALE
P0
P2
WR#1
DPL or RiD7:0
P2
CPU Clock
DPH or P22
Figure 11. External Data Read Waveforms
Notes:1. RD# signal may be stretched using M0 bit in AUXR register.
2. When executing MOVX @Ri instruction, P2 outputs SFR content.
Figure 12. External Data Write Waveforms
4383D–8051–02/08
Notes:1. WR# signal may be stretched using M0 bit in AUXR register.
2. When executing MOVX @Ri instruction, P2 outputs SFR content.
23
AT89C51AC3
Dual Data Pointer
0
1
DPH0
DPH1
DPL0
0
1
DPS
AUXR1.0
DPH
DPL
DPL1
DPTR
DPTR0
DPTR1
DescriptionThe AT89C51AC3 implements a second data pointer for speeding up code execution
and reducing code size in case of intensive usage of external memory accesses.
DPTR 0 and DPTR 1 are seen by the CPU as DPTR and are accessed using the SFR
addresses 83h and 84h that are the DPH and DPL addresses. The DPS bit in AUXR1
register (see Figure 8) is used to select whether DPTR is the data pointer 0 or the data
pointer 1 (see Figure 13).
Figure 13. Dual Data Pointer Implementation
ApplicationSoftware can take advantage of the additional data pointers to both increase speed and
reduce code size, for example, block operations (copy, compare…) are well served by
using one data pointer as a “source” pointer and the other one as a “destination” pointer.
Hereafter is an example of block move implementation using the two pointers and coded
in assembler. The latest C compiler takes also advantage of this feature by providing
enhanced algorithm libraries.
24
The INC instruction is a short (2 Bytes) and fast (6 machine cycle) way to manipulate the
DPS bit in the AUXR1 register. However, note that the INC instruction does not directly
force the DPS bit to a particular state, but simply toggles it. In simple routines, such as
the block move example, only the fact that DPS is toggled in the proper sequence matters, not its actual value. In other words, the block move routine works the same whether
DPS is '0' or '1' on entry.
; ASCII block move using dual data pointers
; Modifies DPTR0, DPTR1, A and PSW
; Ends when encountering NULL character
; Note: DPS exits opposite to the entry state unless an extra INC AUXR1 is added
AUXR1EQU0A2h
move:movDPTR,#SOURCE ; address of SOURCE
incAUXR1 ; switch data pointers
movDPTR,#DEST ; address of DEST
mv_loop:incAUXR1; switch data pointers
movxA,@DPTR; get a byte from SOURCE
incDPTR; increment SOURCE address
incAUXR1; switch data pointers
movx@DPTR,A; write the byte to DEST
incDPTR; increment DEST address
jnzmv_loop; check for NULL terminator
end_move:
4383D–8051–02/08
AT89C51AC3
Registers
Table 6. PSW Register
PSW (S:8Eh)
Program Status Word Register
76543210
CYACF0RS1RS0OVF1P
Bit
Number
7CY
6AC
5F0
4-3RS1:0
2OV
1F1
0P
Bit
Mnemonic Description
Carry Flag
Carry out from bit 1 of ALU operands.
Auxiliary Carry Flag
Carry out from bit 1 of addition operands.
User Definable Flag 0.
Register Bank Select Bits
Refer to Table 4 for bits description.
Overflow Flag
Overflow set by arithmetic operations.
User Definable Flag 1
Parity Bit
Set when ACC contains an odd number of 1’s.
Cleared when ACC contains an even number of 1’s.
Reset Value = 0000 0000b
Table 7. AUXR Register
AUXR (S:8Eh)
Auxiliary Register
76543210
--M0XRS2XRS1XRS0EXTRAMA0
Bit
Number
7-6-
5M0
Bit
Mnemonic Description
Reserved
The value read from these bits are indeterminate. Do not set this bit.
Stretch MOVX control:
the RD/ and the WR/ pulse length is increased according to the value of M0.
101 2048 Bytes (default configuration after reset)
110 Reserved
111 Reserved
Internal/External RAM (00h - FFh)
access using MOVX @ Ri/@ DPTR
0 - Internal ERAM access using MOVX @ Ri/@ DPTR.
1 - External data memory access.
Disable/Enable ALE)
0 - ALE is emitted at a constant rate of 1/6 the oscillator frequency (or 1/3 if X2
mode is used)
1 - ALE is active only during a MOVX or MOVC instruction.
Reset Value = X001 0100b
Not bit addressable
Table 8. AUXR1 Register
AUXR1 (S:A2h)
Auxiliary Control Register 1
76543210
--ENBOOT-GF30-DPS
Bit
Number
7-6-
5ENBOOT
4-
3GF3
20
1-
0DPS
Bit
Mnemonic Description
Reserved
The value read from these bits is indeterminate. Do not set these bits.
Enable Boot Flash
Set this bit for map the boot Flash between F800h -FFFFh
Clear this bit for disable boot Flash.
Reserved
The value read from this bit is indeterminate. Do not set this bit.
General-purpose Flag 3
Always Zero
This bit is stuck to logic 0 to allow INC AUXR1 instruction without affecting GF3
flag.
Reserved for Data Pointer Extension.
Data Pointer Select Bit
Set to select second dual data pointer: DPTR1.
Clear to select first dual data pointer: DPTR0.
26
Reset Value = XXXX 00X0b
4383D–8051–02/08
AT89C51AC3
VCC
Power On Reset
Power Fail Detect
Voltage Regulator
XTAL1
(1)
CPU core
Memories
Peripherals
Regulated
Supply
RST pin
Hardware
Watchdog
PCA
Watchdog
Internal Reset
Power Monitor
The POR/PFD function monitors the internal power-supply of the CPU core memories
and the peripherals, and if needed, suspends their activity when the internal power supply falls below a safety threshold. This is achieved by applying an internal reset to them.
By g enera ting t he Res et the Power Monit or in sures a corr ect st art up w hen
AT89C51CC03 is powered up.
Description
In order to startup and maintain the microcontroller in correct operating mode, VCC has
to be stabilized in the VCC operating range and the oscillator has to be stabilized with a
nominal amplitude compatible with logic level VIH/VIL.
These parameters are controlled during the three phases: power-up, normal operation
and power going down. See Figure 14.
Figure 14. Power Monitor Block Diagram
Note:1. Once XTAL1 high and low levels reach above and below VIH/VIL a 1024 clock period
delay will extend the reset coming from the Power Fail Detect. If the power falls below
the Power Fail Detect thresthold level, the reset will be applied immediately.
The Voltage regulator generates a regulated internal supply for the CPU core the memories and the peripherals. Spikes on the external Vcc are smoothed by the voltage
regulator.
The Power fail detect monitor the supply generated by the voltage regulator and generate a reset if this supply falls below a safety threshold as illustrated in the Figure 15.
4383D–8051–02/08
27
AT89C51AC3
Figure 15. Power Fail Detect
Vcc
t
Reset
Vcc
When the power is applied, the Power Monitor immediately asserts a reset. Once the
internal supply after the voltage regulator reach a safety level, the power monitor then
looks at the XTAL clock input. The internal reset will remain asserted until the Xtal1 levels are above and below VIH and VIL. Further more. An internal counter will count 1024
clock periods before the reset is de-asserted.
If the internal power supply falls below a safety level, a reset is immediately asserted.
.
28
4383D–8051–02/08
Reset
Power
Monitor
Hardware
Watchdog
PCA
Watchdog
RST
Internal Reset
RST
R
RST
VSS
To internal reset
RST
VDD
+
b. Power-on Reseta. RST input circuitry
AT89C51AC3
Introduction
Reset Input
The reset sources are : Power Management, Hardware Watchdog, PCA Watchdog and
Reset input.
Figure 16. Reset Schematic
The Reset input can be used to force a reset pulse longer than the internal reset controlled by the Power Monitor. RST input has a pull-down resistor allowing power-on
reset by simply connecting an external capacitor to VCC as shown in Figure 17. Resistor
value and input characteristics are discussed in the Section “DC Characteristics” of the
AT89C51AC3 datasheet. The status of the Port pins during reset is detailed in Table 9.
4383D–8051–02/08
Figure 17. Reset Circuitry and Power-On Reset
29
AT89C51AC3
Reset Output
RST
VDD
+
VSS
VDD
RST
1K
To other
on-board
circuitry
AT89C51AC3
As detailed in Section “Watchdog Timer”, page 79, the WDT generates a 96-clock
period pulse on the RST pin. In order to properly propagate this pulse to the rest of the
application in case of external capacitor or power-supply supervisor circuit, a 1 kΩ resistor must be added as shown Figure 18.
Figure 18. Recommended Reset Output Schematic
30
4383D–8051–02/08
Loading...
+ 109 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.