4.4 Special Function Registers (SFRs)
The AT89S8253 microcontroller has in total of 40 Special Function Registers. For the sake of the compatibility with the previous 8051 models, the core registers (22 in total) are the same for all of them, while the others were added later for the purpose of controlling upgraded functions of the microcontroller.

As shown in the table above, each of these registers has its name and specific address in RAM. Unoccupied locations are intended for the future upgraded versions of the microcontroller and shouldn’t be used. As their name suggests, these registers are mostly in control of one specific circuit within the microcontroller such as timers or SPI etc. and they will be discussed later in the book. This chapter covers only those SFRs controlling more than one circuit within the microcontroller.
Accumulator (ACC)
The accumulator, otherwise marked as ACC or A, belongs to the core registers of the 8051 microcontroller. Its contents is not modified.
B register
The B register also belongs to the core registers of the 8051 microcontroller. Bits of this register are not modified. It is used during multiply and divide operations (MUL and DIV instructions) to store the operands upon which these operations are performed.
PSW register (Program Status Word Register)
The PSW register belongs to the core registers of the 8051 microcontroller. Bits of this register are not modified.
SP registar (Stack Pointer Register)
The SP register belongs to the core registers of the 8051 microcontroller. Bits of this register are not modified.
Registers P0, P1, P2, P3
Each bit of these registers corresponds to one of the port pins having the same name. These registers are therefore used for comminication with peripheral environment which is carried out by sending data from registers to the corresponding pins and vice versa. They belong to the core registers of the 8051 microcontroller and their bits are not modified.
R registers (R0 - R7)
They belong to the core registers of the 8051 microcontroller. Their bits are not modified.
AUXR register (Auxiliary register)
The AUXR register contains only two active bits:
- DISALE
- 0 - ALE is activated at a constant rate of 1/6 the oscillator frequency.
- 1 - ALE is active only during execution of MOVX or MOVC instructions.
- Intel_Pwd_Exit
- 0 - When the microcontroller is in Power Down mode, the program proceeds with execution on high-to-low transition (1-0).
- 1 - When the microcontroller is in Power Down mode, the program proceeds with execution on low-to-high transition (0-1).
CLKREG register (Clock Register) X2
- 0 - The oscillator frequency (the XTAL1 pin) is divided by 2 before used as a clock (machine cycle lasts for 6 such periods).
- 1 - Quartz oscillator is used as a clock generator. This enables the quartz crystal of two times lower frequency (for example 6MHz instead of 12MHz) to be used for the same operating rate of the microcontroller.
Data Pointers
Data Pointers are not true registers as they don’t physically exist. They consist of two separate registers: DPH (Data Pointer High) and DPL (Data Pointer Low). All 16 bits are used for addressing external and internal EEPROM memory. The DPS bit of the EECON register determines the registers to be used as data pointers:
DPS=0 -> Data pointer consists of DP0L and DP0H registers and is marked as DPTR0.
DPS=1 -> Data pointer consists of DP1L and DP1H registers and is marked as DPTR1.
Handling EEPROM memory
2 Kb of on-chip EEPROM memory enables this microcontroller to store data created during operation which must be permanently saved. In other words, all data stored in this memory remains permanently saved even after the loss of power. Minimum 100 000 writing cycles can be executed. This memory is easily used since there are only a few control bits enabling it.
EEPROM write and read is under control of the EECON special function register. Since the process of programming EEPROM is relatively slow (write to one register takes approximately 4mS), a small hardware trick is done in order to speed it up. When the EELD bit of the EECON register is set, the data is not directly written to the EEPROM registers, but loaded in a small buffer (temporary memory) with a capacity of 32 bytes. When this bit is cleared, the first data following it will be normally written to the EEPROM (takes 4 mS) along with all registers currently loaded in the buffer. Thus, it takes only 4mS to write all 32 bytes instead of 128mS otherwise required in a single byte writing.
EEPROM memory is handled in the same way as external memory. For this reason, a special instruction for additional memory chip (MOVX) is also used for EEPROM write and read. The EEMEN bit of the EECON register determines whether the data is to be written/read from additional memory chip or on-chip EEPROM memory.
EECON register
Bits of the EECON register controls the operation of EEPROM memory:
WRTINH
The WRTINH bit is read-only. When the power supply voltage is too low for programming EEPROM, hardware automatically clears this bit, which means that write to EEPROM cannot be completed or is aborted if in progress.
RDY/BSY
The RDY/BSY bit is read-only.
- 0 - Write in progress (takes approximately 4mS).
- 1 - Write complete (data is written to EEPROM).
DPS
- 0 - Address for EEPROM write/read is stored in the DP0H and DP0L registers.
- 1 - Address for EEPROM write/read is stored in the DP1H and DP1L registers.
EEMEN
- 0 - Instruction MOVX is used for accessing external memory chip.
- 1 - Instruction MOVX is used for accessing internal EEPROM memory. If the register address is larger than 2K, the microcontroller will access external memory chip.
EEMWE
When set, the EEMWE bit enables write to EEPROM using the MOVX instruction. After completing EEPROM write, the bit must be cleared from within the program.
EELD
When set, the EELD bit enables up to 32 bytes to be written simultaneously. The bit is set and the MOVX instruction writes data to EEPROM (buffer is loaded). The bit is cleared before writing the last data. When the last MOVX is executed, the entire buffer is automatically loaded to EEPROM for 4mS.