• Two Full Duplex Enhanced UART with Dedicated Internal Baud Rate Generator
• Low EMI (inhibit ALE)
• Hardware Watchdog Timer (One-time Enabled with Reset-Out), Power-Off Flag
• Power Control Modes: Idle Mode, Power-down Mode
• Power Supply: 2.7V to 5.5V
• Temperature Ranges: Industrial (-40 to +85°C)
• Packages: PLCC44, VQFP44
Power Supply
CC
8-bit Flash
Microcontroller
AT89C51RE2
AT89C51RE2
Description
AT89C51RE2 is a high performance CMOS Flash version of the 80C51 CMOS single chip 8-bit
microcontroller. It contains a 128 Kbytes Flash memory block for program.
The 128 Kbytes Flash memory can be programmed either in parallel mode or in serial mode with
the ISP capability or with software. The programming voltage is internally generated from the
standard VCC pin.
The AT89C51RE2 retains all features of the Atmel 80C52 with 256 bytes of internal RAM, a 10source 4-level interrupt controller and three timer/counters.
In addition, the AT89C51RE2 has a Programmable Counter Array, an XRAM of 8192 bytes, a
Hardware Watchdog Timer, SPI and Keyboard, two serial channels that facilitates multiprocessor communication (EUART), a speed improvement mechanism (X2 mode) and an extended
stack mode that allows the stack to be extended in the lower 256 bytes of XRAM.
The fully static design of the AT89C51RE2 allows to reduce system power consumption by
bringing the clock frequency down to any value, even DC, without loss of data.
The AT89C51RE2 has 2 software-selectable modes of reduced activity and 8-bit clock prescaler
for further reduction in power consumption. In the Idle mode the CPU is frozen while the peripherals and the interrupt system are still operating. In the power-down mode the RAM is saved and
all other functions are inoperative.
The added features of the AT89C51RE2 make it more powerful for applications that need pulse
width modulation, high speed I/O and counting capabilities such as alarms, motor control,
corded phones, smart card readers.
341IT2EX (P1.1): Timer/Counter 2 Reload/Capture/Direction Control
442IECI (P1.2): External Clock for the PCA
543I/OCEX0 (P1.3): Capture/Compare External I/O for PCA module 0
TypeName and FunctionLCCVQFP 1.4
float and can be used as high impedance inputs. Port 0 must be polarized to VCC or VSS in
order to prevent any parasitic current consumption. Port 0 is also the multiplexed low-order
address and data bus during access to external program and data memory. In this
application, it uses strong internal pull-up when emitting 1s. Port 0 also inputs the code bytes
during EPROM programming. External pull-ups are required during program verification
during which P0 outputs the code bytes.
I/OPort 1: Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. Port 1 pins that have 1s
written to them are pulled high by the internal pull-ups and can be used as inputs. As inputs,
Port 1 pins that are externally pulled low will source current because of the internal pull-ups.
Port 1 also receives the low-order address byte during memory programming and
verification.
Alternate functions for TSC8x54/58 Port 1 include:
644I/OCEX1 (P1.4): Capture/Compare External I/O for PCA module 1
71I/OCEX2 (P1.5): Capture/Compare External I/O for PCA module 2
82I/OCEX3 (P1.6): Capture/Compare External I/O for PCA module 3
93I/OCEX4 (P1.7): Capture/Compare External I/O for PCA module 4
P2.0-P2.724-3118-25I/OPort 2: Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. Port 2 pins that have 1s
P3.0-P3.711,
13-19
115IRXD_0 (P3.0): Serial input port
137OTXD_0 (P3.1): Serial output port
5,
7-13
written to them are pulled high by the internal pull-ups and can be used as inputs. As inputs,
Port 2 pins that are externally pulled low will source current because of the internal pull-ups.
Port 2 emits the high-order address byte during fetches from external program memory and
during accesses to external data memory that use 16-bit addresses (MOVX @DPTR).In this
application, it uses strong internal pull-ups emitting 1s. During accesses to external data
memory that use 8-bit addresses (MOVX @Ri), port 2 emits the contents of the P2 SFR.
Some Port 2 pins receive the high order address bits during EPROM programming and
verification:
P2.0 to P2.5 for RB devices
P2.0 to P2.6 for RC devices
P2.0 to P2.7 for RD devices.
I/OPort 3: Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. Port 3 pins that have 1s
written to them are pulled high by the internal pull-ups and can be used as inputs. As inputs,
Port 3 pins that are externally pulled low will source current because of the internal pull-ups.
Port 3 also serves the special features of the 80C51 family, as listed below.
7663C–8051–05/08
148IINT0 (P3.2): External interrupt 0
5
AT89C51RE2
Pin Number
Mnemonic
159IINT1 (P3.3): External interrupt 1
1610IT0 (P3.4): Timer 0 external input
1711IT1 (P3.5): Timer 1 external input
1812OWR (P3.6): External data memory write strobe
1913ORD (P3.7): External data memory read strobe
P6.0-P6.1
Reset104I/OReset: A high on this pin for two machine cycles while the oscillator is running, resets the
ALE/PROG3327O (I)Address Latch Enable/Program Pulse: Output pulse for latching the low byte of the
12,346, 28
126IRXD_1 (P6.0): Serial input port
3428OTXD_1 (P6.1): Serial output port
TypeName and FunctionLCCVQFP 1.4
Port 6: Port 6 is an 2-bit bidirectional I/O port with internal pull-ups. Port 6 pins that have 1s
written to them are pulled high by the internal pull-ups and can be used as inputs. As inputs,
Port 6 pins that are externally pulled low will source current because of the internal pull-ups.
Port 6 also serves some special features as listed below.
device. An internal diffused resistor to V
capacitor to VCC. This pin is an output when the hardware watchdog forces a system reset.
address during an access to external memory. In normal operation, ALE is emitted at a
constant rate of 1/6 (1/3 in X2 mode) 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 (PROG) during Flash programming. ALE
can be disabled by setting SFR’s AUXR.0 bit. With this bit set, ALE will be inactive during
internal fetches.
permits a power-on reset using only an external
SS
PSEN3226OProgram Store ENable: The read strobe to external program memory. When executing
EA3529IExternal Access Enable: EA must be externally held low to enable the device to fetch code
XTAL12115I
XTAL22014OCrystal 2: Output from the inverting oscillator amplifier
Tx_OCD2317OTx_OCD: On chip debug Serial output port
Rx_OCD139IRx_OCD: On chip debug Serial input port
code from the external program memory, PSEN is activated twice each machine cycle,
except that two PSEN activations are skipped during each access to external data memory.
PSEN is not activated during fetches from internal program memory.
from external program memory locations 0000H to FFFFH (RD). If security level 1 is
programmed, EA will be internally latched on Reset.
Crystal 1: Input to the inverting oscillator amplifier and input to the internal clock generator
circuits.
6
7663C–8051–05/08
AT89C51RE2
SFR Mapping
The Special Function Registers (SFRs) of the AT89C51RE2 fall into the following categories:
KBF9Eh Keyboard Flag RegisterKBF7KBF6KBF5KBF4KBF3KBF2KBF1KBF0
7663C–8051–05/08
11
AT89C51RE2
Table 13. SFR Mapping
addressableNon Bit addressable
Table below shows all SFRs with their address and their reset value.
Bit
0/81/9 2/A3/B 4/C5/D6/E 7/F
C0h
F8h
F0h
E8h
E0h
D8h
D0h
C8h
U2(AUXR1.5)
=0
U2(AUXR1.5)
=1
B8h
P6
XXXX XX11CH0000 0000
B
0000 0000
P5
1111 1111CL0000 0000
ACC
0000 0000
CCON
00X0 0000
PSW
0000 0000
T2CON
0000 0000
SCON_1
0000 0000
P4
1111 1111
IPL0
X000 000
CMOD
00XX X000
FCON
0000 0000
T2MOD
XXXX XX00
SBUF_1
0000 0000
SADEN_0
0000 0000
CCAP0H
XXXX XXXX
CCAP0L
XXXX XXXX
CCAPM0
X000 0000
RCAP2L
0000 0000
SADEN1
0000 0000
CCAP1H
XXXX XXXX
CCAP1L
XXXX XXXX
CCAPM1
X000 0000
FSTA
xxxx x000
RCAP2H
0000 0000
SPCON
0001 0100
BRL_1
0000 0000
CCAP2H
XXXX XXXX
CCAP2L
XXXX XXXX
CCAPM2
X000 0000
TL2
0000 0000
SPSCR
0000 0000
BDRCON_1
XXX0 0000
CCAP3H
XXXX XXXX
CCAP3L
XXXX XXXX
CCAPM3
X000 0000
TH2
0000 0000
SPDAT
XXXX XXXX
CCAP4H
XXXX XXXX
CCAP4L
XXXX XXXX
CCAPM4
X000 0000
FFh
F7h
EFh
E7h
DFh
D7h
CFh
C7h
BFh
12
B0h
A8h
A0h
98h
90h
88h
80h
P3
1111 1111
IEN0
0000 0000
P2
1111 1111
SCON_0
0000 0000
P1
1111 1111
TCON
0000 0000
P0
1111 1111
0/81/9 2/A3/B 4/C5/D6/E 7/F
IEN1
XXXX 0000
SADDR_0
0000 0000
SBUF_0
XXXX XXXX
TMOD
0000 0000
SP
0000 0111
IPL1
XXXX 0000
SADDR_1
0000 0000
AUXR1
000x 11x0
BRL_0
0000 0000
BMSEL
0000 0YYY
TL0
0000 0000
DPL
0000 0000
IPH1
XXXX 0111
BDRCON_0
XXX0 0000
TL1
0000 0000
DPH
0000 0000
KBLS
0000 0000
TH0
0000 0000
KBE
0000 0000
TH1
0000 0000
WDTRST
XXXX XXXX
KBF
0000 0000
AUXR
XX00 1000
Reserved
IPH0
X000 0000
CKCON1
XXXX XX00
WDTPRG
XXXX X000
CKRL
1111 1111
CKCON0
0000 0000
PCON
00X1 0000
7663C–8051–05/08
B7h
AFh
A7h
9Fh
97h
8Fh
87h
AT89C51RE2
XTAL1
2
CKCON0
X2
8 bit Prescaler
F
OSC
FXTAL
0
1
XTAL1:2
F
CLK CPU
F
CLK PERIPH
CKRL
Enhanced
Features
X2 Feature
In comparison to the original 80C52, the AT89C51RE2 implements some new features, which
are
:
•X2 option
•Dual Data Pointer
•Extended RAM
•Extended stack
•Programmable Counter Array (PCA)
•Hardware Watchdog
•SPI interface
•4-level interrupt priority system
•power-off flag
•ONCE mode
•ALE disabling
•Enhanced features on the UART and the timer 2
The AT89C51RE2 core needs only 6 clock periods per machine cycle. This feature called ‘X2’
provides the following advantages:
•Divide frequency crystals by 2 (cheaper crystals) while keeping same CPU power.
•Save power consumption while keeping same CPU power (oscillator power saving).
•Save power consumption by dividing dynamically the operating frequency by 2 in operating
and idle modes.
•Increase CPU power by 2 while keeping 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
software.
DescriptionThe clock for the whole circuit and peripherals is first divided by two before being used by the
CPU core and the peripherals.
This allows any cyclic ratio to be accepted on XTAL1 input. In X2 mode, as this divider is
bypassed, the signals on XTAL1 must have a cyclic ratio between 40 to 60%.
Figure 2 shows the clock generation block diagram. X2 bit is validated on the rising edge of the
XTAL1÷2 to avoid glitches when switching from X2 to STD mode. Figure 3 shows the switching
mode waveforms.
Figure 2. Clock Generation Diagram
7663C–8051–05/08
13
AT89C51RE2
Figure 3. Mode Switching Waveforms
XTAL1:2
XTAL1
CPU clock
X2 bit
X2 ModeSTD ModeSTD Mode
F
OSC
The X2 bit in the CKCON0 register (see Table 14) allows a switch from 12 clock periods per
instruction to 6 clock periods and vice versa. At reset, the speed is set according to X2 bit of the
Fuse Configuration Byte (FCB). By default, Standard mode is active. Setting the X2 bit activates
the X2 feature (X2 mode).
The T0X2, T1X2, T2X2, UartX2, PcaX2, and WdX2 bits in the CKCON0 register (See Table 14.)
and SPIX2 bit in the CKCON1 register (see Table 15) allows a switch from standard peripheral
speed (12 clock periods per peripheral clock cycle) to fast peripheral speed (6 clock periods per
peripheral clock cycle). These bits are active only in X2 mode.
14
7663C–8051–05/08
AT89C51RE2
Table 14. CKCON0 Register
CKCON0 - Clock Control Register (8Fh)
76543210
-WDX2PCAX2SIX2_0T2X2T1X2T0X2X2
Bit
Number
7-Reserved
6WDX2
5PCAX2
4SIX2_0
3T2X2
Bit
Mnemonic Description
Watchdog Clock
(This control bit is validated when the CPU clock X2 is set; when X2 is low, this bit has no
effect).
Cleared to select 6 clock periods per peripheral clock cycle.
Set to select 12 clock periods per peripheral clock cycle.
Programmable Counter Array Clock
(This control bit is validated when the CPU clock X2 is set; when X2 is low, this bit has no
effect).
Cleared to select 6 clock periods per peripheral clock cycle. Set to select 12 clock
periods per peripheral clock cycle.
Enhanced UART0 Clock (Mode 0 and 2)
(This control bit is validated when the CPU clock X2 is set; when X2 is low, this bit has no
effect).
Cleared to select 6 clock periods per peripheral clock cycle. Set to select 12 clock
periods per peripheral clock cycle.
Timer2 Clock
(This control bit is validated when the CPU clock X2 is set; when X2 is low, this bit has no
effect).
Cleared to select 6 clock periods per peripheral clock cycle.
Set to select 12 clock periods per peripheral clock cycle.
7663C–8051–05/08
Timer1 Clock
2T1X2
1T0X2
0X2
(This control bit is validated when the CPU clock X2 is set; when X2 is low, this bit has no
effect).
Cleared to select 6 clock periods per peripheral clock cycle. Set to select 12 clock
periods per peripheral clock cycle.
Timer0 Clock
(This control bit is validated when the CPU clock X2 is set; when X2 is low, this bit has no
effect).
Cleared to select 6 clock periods per peripheral clock cycle. Set to select 12 clock
periods per peripheral clock cycle.
CPU Clock
Cleared to select 12 clock periods per machine cycle (STD mode) for CPU and all the
peripherals. Set to select 6clock periods per machine cycle (X2 mode) and to enable the
individual peripherals’X2’ bits. Programmed by hardware after Power-up regarding
Hardware Security Byte (HSB), Default setting, X2 is cleared.
Reset Value = X000 000’HSB. X2’b (See “Fuse Configuration Byte: FCB”)
Not bit addressable
15
AT89C51RE2
Table 15. CKCON1 Register
CKCON1 - Clock Control Register (AFh)
76543210
------SIX2_1SPIX2
Bit
Number
7-Reserved
6-Reserved
5-Reserved
4-Reserved
3-Reserved
2-Reserved
1SIX2_1
0SPIX2
Bit
Mnemonic Description
Enhanced UART1 Clock (Mode 0 and 2)
(This control bit is validated when the CPU clock X2 is set; when X2 is low, this bit has no
effect).
Cleared to select 6 clock periods per peripheral clock cycle. Set to select 12 clock
periods per peripheral clock cycle.
SPI (This control bit is validated when the CPU clock X2 is set; when X2 is low, this bit
has no effect).
Clear to select 6 clock periods per peripheral clock cycle.
Set to select 12 clock periods per peripheral clock cycle.
Reset Value = XXXX XX00b
Not bit addressable
16
7663C–8051–05/08
AT89C51RE2
External Data Memory
AUXR1(A2H)
DPS
DPH(83H) DPL(82H)
07
DPTR0
DPTR1
Dual Data
Pointer Register
DPTR
Figure 4. Use of Dual Pointer
The additional data pointer can be used to speed up code execution and reduce code size.
The dual DPTR structure is a way by which the chip will specify the address of an external data
memory location. There are two 16-bit DPTR registers that address the external memory, and a
single bit called DPS = AUXR1.0 (see Table 16) that allows the program code to switch between
them (Refer to Figure 4).
7663C–8051–05/08
17
AT89C51RE2
Table 16. AUXR1 register
AUXR1- Auxiliary Register 1(0A2h)
76543210
EESSP9U2-GF20-DPS
Bit
Number
7EES
6SP9
5U2
4-
3GF2This bit is a general purpose user flag. *
20Always cleared.
1-
0DPS
Bit
Mnemonic Description
Enable Extended Stack
This bit allows the selection of the stack extended mode.
Set to enable the extended stack
Clear to disable the extended stack (default value)
Stack Pointer 9th Bit
This bit has no effect when the EES bit is cleared.
Set when the stack pointer belongs to the XRAM memory space
Cleared when the stack pointer belongs to the 256bytes of internal RAM.
P4 bit addressable
Clear to map SCON_1 register at C0h sfr address
Set to map P4 port register at C0h address.
Reserved
The value read from this bit is indeterminate. Do not set this bit.
Reserved
The value read from this bit is indeterminate. Do not set this bit.
Data Pointer Selection
Cleared to select DPTR0.
Set to select DPTR1.
18
Reset Value: XX0X XX0X0b
Not bit addressable
Note:*Bit 2 stuck at 0; this allows to use INC AUXR1 to toggle DPS without changing GF3.
ASSEMBLY LANGUAGE
; Block move using dual data pointers
; Modifies DPTR0, DPTR1, A and PSW
; note: DPS exits opposite of entry state
; unless an extra INC AUXR1 is added
;
00A2 AUXR1 EQU 0A2H
;
0000 909000MOV DPTR,#SOURCE ; address of SOURCE
0003 05A2 INC AUXR1 ; switch data pointers
0005 90A000 MOV DPTR,#DEST ; address of DEST
0008 LOOP:
0008 05A2 INC AUXR1 ; switch data pointers
000A E0 MOVX A,@DPTR ; get a byte from SOURCE
000B A3 INC DPTR ; increment SOURCE address
000C 05A2 INC AUXR1 ; switch data pointers
000E F0 MOVX @DPTR,A ; write the byte to DEST
000F A3 INC DPTR ; increment DEST address
INC is a short (2 bytes) and fast (12 clocks) way to manipulate the DPS bit in the AUXR1 SFR.
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. Observe that without the last instruction (INC AUXR1), the routine will exit with DPS in the opposite state.
7663C–8051–05/08
19
AT89C51RE2
Memory Architecture
128K bytes
Flash memory
FM0
Hardware Security (1 byte)
Column Latches (128 bytes)
user space
4K bytes
ROM
1FFFFh
00000h
RM0
Fuse Configuration Byte(1 byte)
FCB
HSB
256 bytes
IRAM
XRAM
8K bytes
AT89C51RE2 features several on-chip memories:
•Flash memory:
containing 128 Kbytes of program memory (user space) organized into 128 bytes pages.
•Boot ROM:
4K bytes for boot loader.
•8K bytes internal XRAM
Physical memory
organisation
Figure 5. Physical memory organisation
20
7663C–8051–05/08
AT89C51RE2
XRAM
Upper
128 bytes
Internal
Ram
Lower
128 bytes
Internal
Ram
Special
Function
Register
80h80h
00
0FFh to 1FFFh
0FFh
00
0FFh
External
Data
Memory
0000
00FFh up to 1FFFh
0FFFFh
indirect accesses
direct accesses
direct or indirect
accesses
7Fh
Expanded RAM
(XRAM)
The AT89C51RE2 provides additional Bytes of random access memory (RAM) space for
increased data parameter handling and high level language usage.
AT89C51RE2 devices have expanded RAM in external data space configurable up to 8192bytes
(see Table 17.).
The AT89C51RE2 has internal data memory that is mapped into four separate segments.
The four segments are:
1. The Lower 128 bytes of RAM (addresses 00h to 7Fh) are directly and indirectly
addressable.
2. The Upper 128 bytes of RAM (addresses 80h to FFh) are indirectly addressable only.
3. The Special Function Registers, SFRs, (addresses 80h to FFh) are directly addressable
only.
4. The expanded RAM bytes are indirectly accessed by MOVX instructions, and with the
EXTRAM bit cleared in the AUXR register (see Table 17).
The lower 128 bytes can be accessed by either direct or indirect addressing. The Upper 128
bytes can be accessed by indirect addressing only. The Upper 128 bytes occupy the same
address space as the SFR. That means they have the same address, but are physically separate from SFR space.
Figure 6. Internal and External Data Memory Address
7663C–8051–05/08
When an instruction accesses an internal location above address 7Fh, the CPU knows whether
the access is to the upper 128 bytes of data RAM or to SFR space by the addressing mode used
in the instruction.
•Instructions that use direct addressing access SFR space. For example: MOV 0A0H, # data,
accesses the SFR at location 0A0h (which is P2).
•Instructions that use indirect addressing access the Upper 128 bytes of data RAM. For
example: MOV @R0, # data where R0 contains 0A0h, accesses the data byte at address
0A0h, rather than P2 (whose address is 0A0h).
•The XRAM bytes can be accessed by indirect addressing, with EXTRAM bit cleared and
MOVX instructions. This part of memory which is physically located on-chip, logically
occupies the first bytes of external data memory. The bits XRS0 and XRS1 are used to hide
a part of the available XRAM as explained in Table 17. This can be useful if external
peripherals are mapped at addresses already used by the internal XRAM.
21
AT89C51RE2
•With EXTRAM = 0, the XRAM is indirectly addressed, using the MOVX instruction in
combination with any of the registers R0, R1 of the selected bank or DPTR. An access to
XRAM will not affect ports P0, P2, P3.6 (WR) and P3.7 (RD). For example, with EXTRAM =
0, MOVX @R0, # data where R0 contains 0A0H, accesses the XRAM at address 0A0H
rather than external memory. An access to external data memory locations higher than the
accessible size of the XRAM will be performed with the MOVX DPTR instructions in the
same way as in the standard 80C51, with P0 and P2 as data/address busses, and P3.6 and
P3.7 as write and read timing signals. Accesses to XRAM above 0FFH can only be done by
the use of DPTR.
•With EXTRAM = 1, MOVX @Ri and MOVX @DPTR will be similar to the standard
80C51.MOVX @ Ri will provide an eight-bit address multiplexed with data on Port0 and any
output port pins can be used to output higher order address bits. This is to provide the
external paging capability. MOVX @DPTR will generate a sixteen-bit address. Port2 outputs
the high-order eight address bits (the contents of DPH) while Port0 multiplexes the low-order
eight address bits (DPL) with data. MOVX @ Ri and MOVX @DPTR will generate either
read or write signals on P3.6 (WR) and P3.7 (RD).
The stack pointer (SP) may be located anywhere in the 256 bytes RAM (lower and upper RAM)
internal data memory. The stack may be located in the 256 lower bytes of the XRAM by activating the extended stack mode (see EES bit in AUXR1).
The M0 bit allows to stretch the XRAM timings; if M0 is set, the read and write pulses are
extended from 6 to 30 clock periods. This is useful to access external slow peripherals.
22
7663C–8051–05/08
AT89C51RE2
Registers
Table 17. AUXR Register
AUXR - Auxiliary Register (8Eh)
76543210
--M0XRS2XRS1XRS0EXTRAMAO
Bit
Number
7-
6-
5M0
4-2XRS2:0
Bit
Mnemonic Description
Reserved
The value read from this bit is indeterminate. Do not set this bit.
Reserved
The value read from this bit is indeterminate. Do not set this bit.
Pulse length
Cleared to stretch MOVX control: the RD/ and the WR/ pulse length is 6 clock periods
(default).
Set to stretch MOVX control: the RD/ and the WR/ pulse length is 30 clock periods.
XRAM Size
XRS2 XRS1 XRS0XRAM size
0 0 0 256 bytes
00 1 512 bytes
01 0 768 bytes
01 1 1024 bytes
1 0 0 1792 bytes
1 0 1 2048 bytes
1 1 0 4096 bytes
1 1 1 8192 bytes (default)
EXTRAM bit
Cleared to access internal XRAM using movx @ Ri/ @ DPTR.
1EXTRAM
0AO
Set to access external memory.
Programmed by hardware after Power-up regarding Hardware Security Byte (HSB),
default setting, XRAM selected.
ALE Output bit
Cleared, ALE is emitted at a constant rate of 1/6 the oscillator frequency (or 1/3 if X2
mode is used). (default) Set, ALE is active only during a MOVX or MOVC instruction is
used.
Reset Value = XX01 1100b
Not bit addressable
7663C–8051–05/08
23
AT89C51RE2
Extended Stack
00h
FFh
0000h
FFFFh
256 bytes
IRAM
00h
FFh
Logical MCU
Address
256 SP values
rollover within 256B of IRAM
00h
FFh
0000h
256 bytes
IRAM
00h
FFh
512 SP Values
rollover in:
00FFh
00h
FFh
256B of IRAM
+
lower 256B of XRAM
XRAM
SP Value
FFFFh
Logical MCU
Address
XRAM
SP Value
Standard C51 Stack mode EES = 0Extended Stack mode Stack EES = 1
SP9=1
SP9=0
The lowest bytes of the XRAM may be used to allow extension of the stack pointer.
The extended stack allows to extend the standard C51 stack over the 256 bytes of internal RAM.
When the extended stack mode is activated (EES bit in AUXR1), the stack pointer (SP) can
grow in the lower 256 bytes of the XRAM area.
The stack extension consists in a 9 bits stack pointer where the ninth bit is located in SP9 (bit 6
of AUXR1). The SP9 then indicates if the stack pointer belongs to the internal RAM (SP9
cleared) or to the XRAM memory (SP9 set).
To ensure backward compatibility with standard C51 architecture, the extended mode is disable
at chip reset.
Figure 7. Stack modes
Figure 8. AUXR1 register
AUXR1- Auxiliary Register 1(0A2h)
76543210
24
EESSP9U2-GF20-DPS
Bit
Number
7EES
Bit
Mnemonic Description
Enable Extended Stack
Set to enable the extended stack
Clear to disable the extended stack (default value)
This bit allows the selection of the stack extended mode.
7663C–8051–05/08
AT89C51RE2
Bit
Number
6SP9
5U2
4-
3GF2This bit is a general purpose user flag. *
20Always cleared.
1-
0DPS
Bit
Mnemonic Description
Stack Pointer 9th Bit
This bit has no effect when the EES bit is cleared.
Set when the stack pointer belongs to the XRAM memory space
Cleared when the stack pointer belongs to the 256bytes of internal RAM. Set and
cleared by hardware. Can only be read.
P4 bit addressable
Clear to map SCON_1 register at C0h sfr address
Set to map P4 port register at C0h address.
Reserved
The value read from this bit is indeterminate. Do not set this bit.
Reserved
The value read from this bit is indeterminate. Do not set this bit.
Data Pointer Selection
Cleared to select DPTR0.
Set to select DPTR1.
Reset Value = 00XX 00X0b
Not bit addressable
7663C–8051–05/08
25
AT89C51RE2
Flash Memory
General
Description
Features
Flash memory
organization
The Flash memory increases EPROM and ROM functionality with in-circuit electrical erasure
and programming. It contains 128K bytes of program memory organized in 1024 pages of 128
bytes. This memory is both parallel and serial In-System Programmable (ISP). ISP allows
devices to alter their own program memory in the actual end product under software control. A
default serial loader (bootloader) program allows ISP of the Flash.
The programming does not require external high programming voltage. The necessary high programming voltage is generated on-chip using the standard VCC pins of the microcontroller.
•Flash internal program memory.
•Boot vector allows user provided Flash loader code to reside anywhere in the Flash memory
space. This configuration provides flexibility to the user.
•Default loader in Boot Flash allows programming via the serial port without the need of a
user provided loader.
•Up to 64K byte external program memory if the internal program memory is disabled (EA =
0).
•Programming and erase voltage with standard 5V or 3V VCC supply.
AT89C51RE2 features several on-chip memories:
•Flash memory FM0:
containing 128 Kbytes of program memory (user space) organized into 128 bytes pages.
•Boot ROM RM0:
4K bytes for boot loader.
•8K bytes internal XRAM
26
7663C–8051–05/08
AT89C51RE2
128K bytes
Flash memory
FM0
Hardware Security (1 byte)
Column Latches (128 bytes)
user space
Extra Row FM0 (128 bytes)
4K bytes
ROM
1FFFFh
00000h
RM0
Fuse Configuration Byte(1 byte)
FCB
HSB
Physical memory
organisation
Figure Physical memory organisation
On-Chip Flash
memory
The AT89C51RE2 implements up to 128K bytes of on-chip program/code memory. Figure 1 and
Figure 2. shows the partitioning of internal and external program/code memory spaces according to EA value.
The memory partitioning of the 8051 core microcontroller is typical a Harvard architecture where
program and data areas are held in separate memory areas. The program and data memory
areas use the same physical address range from 0000H-FFFFH and a 8 bit instruction
code/data format.
To access more than 64kBytes of code memory, without modifications of the MCU core, and
development tools, the bank switching method is used.
The internal program memory is expanded to 128kByte in the ´Expanded Configuration’, the
data memory remains in the ´Normal Configuration´. The program memory is split into four 32
kByte banks (named Bank 0-2). The MCU core still addresses up to 64kBytes where the upper
32Kbytes can be selected between 3 32K bytes bank of on-chip flash memory. The lower 32K
bank is used as common area for interrupt subroutines, bank switching and functions calls
between banks.
The AT89C51RE2 also implements an extra upper 32K bank (Bank3) that allows external code
execution.
7663C–8051–05/08
27
AT89C51RE2
Figure 1. Program/Code Memory Organization EA=1
0000h
7FFFh
8000h
FFFFh
8000h
FFFFh
8000h
FFFFh
8000h
FFFFh
32K
Common
upper 32K
Bank 0
upper 32K
Bank 1
upper 32K
Bank 2
upper 32K
Bank 3
Optional
External
Memory
On-Chip flash code memory
External code memory
00000h
07FFFh
08000h
0FFFFh
10000h
17FFFh
18000h
1FFFFh
Logical MCU
Address
Physical Flash
Address
Logical MCU
Address
Logical MCU
Address
Physical Flash
Address
Physical Flash
Address
Logical MCU
Address
28
7663C–8051–05/08
AT89C51RE2
0000h
FFFFh
64K
Common
On-Chip flash code memory
External code memory
00000h
0FFFFh
Logical MCU
Address
External Physical Memory
Address
When EA=0, the on-chip flash memory is disabled and the MCU core can address only up to
64kByte of external memory (none of the on-chip flash memory FM0 banks or RM0 can be
mapped and executed).
Figure 2. Program/Code Memory Organization EA=0
7663C–8051–05/08
29
AT89C51RE2
On-Chip ROM
0000h
7FFFh
8000h
FFFFh
8000h
FFFFh
8000h
FFFFh
8000h
FFFFh
Bank 0
On-Chip flash code memory
External code memory
00000h
07FFFh
08000h
0FFFFh
10000h
17FFFh
18000h
1FFFFh
Logical MCU
Address
Physical
Address
Logical MCU
Address
Logical MCU
Address
Physical
Address
Physical
Address
Logical MCU
Address
Bank 1Bank 2Bank 3
Logical MCU
Address
ROM
Address
Bank
BOOT
(Ext)
0000h
On-Chip ROM memory (RM0)
1000h
0000h
1000h
bootloader
The On-chip ROM bootloader (RM0) is enable only for ISP operations after reset (bootloader
execution). The RM0 memory area belongs to a logical addressable memory space called ‘Bank
Boot’.
RM0 cannot be activated from the On-chip flash memory. It means that it is not possible activate the Bank Boot area by software (it prevents any RM0 execution and flash corruption from
the user application).
RM0 logical area consists in an independent code execution memory area of 4K bytes starting
at logical 0x0000 address (it allows the use of the interrupts in the bootloader execution).
30
7663C–8051–05/08
Loading...
+ 137 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.