17 Preliminary 2003 May 13
Philips Semiconductors P87C51Mx2 User Manual
P87C51Mx2Extended Address Range Microcontroller
Using Extended Call Return Mode saves code space since ACALL, LCALL and RET instructions require less bytes for coding
than ECALL and ERET. Furthermore, we need to write desired subroutine only once and it can be placed and called without
restrictions in the code space. However, having ECRM=1 will increase subroutine’s execution time, since all calls and returns
made by ACALL, LCALL and RET will become longer.
If the Stack Pointer is not initialized by software, the stack will begin at on-chip RAM address 8, just as for the 80C51. Also note
that in Extended Stack Memory Mode, both MB2 and MC2 parts have 256 bytes of RAM on the top of DATA/IDATA space
available for the stack.
The stack mode bits ECRM, ESMM and EIFM are shown in Figure 6. Note that the stack mode bits are intended to be set once
during program initialization and not altered after that point. Changing stack modes dynamically may cause stack synchronization
problems.
2.2.5 MX CONTROL REGISTER (MXCON)
MX family of microcontrollers was developed with an idea to provide 80C51 users with the part that will allow applications to grow
in different directions. While improving a number of characteristics, it had to keep full compatibility with its predecessors.
Two major areas for improvement were identified as microcontroller’s internal resources, and microcontroller’s interface to
external world with address and data bus.
MX2 part brings larger on-chip code and data space available, compared to previous 80C51 compatible microcontrollers. In order
to enable these enhancements to be used, MX specific features had to be added, and consequently instruction set had to be
enriched.
MX Control Register (MXCON) determines mode of MX2’s operation. Although it is possible, change of this register during
application’s execution is not advised. Structure of MXCON is shown in Figure 6. Total of three operational modes are available
using bits EAM1 and EAM0.
EAM1:0=00
After reset, bits EAM1:0=00 (default value) place MX2 part in fully pin-to-pin 80C51 binary compatible micro. Its interface with
external world is with 16 bits wide address bus and 8 bits wide data bus. PC is 16 bits wide and therefor on-chip executable code
can not go beyond 64 kB. Use of MX specific instructions that relay on PC (e.g. EMOV) is limited to values contained in the lowest
16 bits of PC: upper 7 bits are considered to be 0s. This is why EMOV instruction can not fetch content from internal code space
above 64 kB boundary. Once code starts from on-chip code space, no external code can be executed; address bus enables
access up to 64 kB of RAM only.
EAM1:0=10
Mode determined with EAM1:0=10 enables on-chip code to go beyond 64 kB and, in case of MC2, utilize 96 kB of available code
space. Interface to external memory is through standard 51 external bus: 16 bits address and 8 bits wide. In this configuration,
PC is internally 23 bits wide and special attention is needed when EIFM (Extended Interrupt Frame) bit is configured. If
executable on-chip code goes beyond 64 kB and this code can be interrupted, EIFM must be set to 1, since address of interrupted
instruction might be of 01:xxxx type. Keeping EIFM=0 (in application when PC crosses 64 kB) will result in pushing of only 2 bytes
of address to the stack. Consequently, after invoked interrupt service routine (ISR) is finished, RETI instruction will direct further
code execution to 00:xxxx (due to popping only 2 bytes from the stack), which can result in unpredicted system behavior.
If on-chip memory code space above 64 kB is used for storage of constants only (e.g. look-up-tables), EIFM can be 0, since any
address of executed code can be represented with only two bytes. In this case it is sufficient to push only these two bytes onto
the stack (which is default for MX2 part).
Once code starts from on-chip code space, no external code can be executed; address bus enables access up to 64 kB of
external RAM only. Due to only 16 bits wide address bus in this mode, even if EMOV instruction points to location above 64 kB,
(e.g. yz:xxxx), external memory will recognize this as address under 64 kB (00:xxxx).
EAM1:0=01
This mode differs from the previous one only in external bus structure: instead of 16 bits, outputted address is 23 bits wide. This
enables MX2 to address up to 8 MB of code and 8 MB of data space independently. Now, microcontroller is capable of accessing
external code space in case PC goes beyond 96 kB (part performs fetch from outside code space generating proper signals on
ports 0, 2 and 3 when PC>96K). EIFM restrictions are the same as in EAM1:0=10 configuration.