The 8051 is the name of a big family of microcontrollers. The device which we are going to use along this tutorial is the ‘AT89S8253‘which is a typical 8051 microcontroller manufactured by Atmel™.
The block diagram provided by Atmel™ in their datasheet showing the architecture the AT89S8253 device can seem very complicated, and since we are going to use the C high level language to program it, a simpler architecture can be represented as the figure 3.7
This figure shows the main features and components that the designer can interact with. You can notice that the AT 89S8253 has four different ports, each one having eight Input/output lines providing a total of 32 I/O lines. Those ports can be used to output DATA and orders do other devices, or to read the state of a sensor, or a switch. Most of the ports of the 89S52 have ‘dual function’ meaning that they can be used for two different functions: the first one is to perform input/output operations and the second one is used to implement special features of the microcontroller like counting external pulses, interrupting the execution of the program according to external events, performing serial data transfer or connecting the chip to a computer to update the software.
You can also notice two different memory types: RAM and EEPROM. Shortly, RAM is used to store variable during program execution, while the EEPROM memory is used to store the program itself, that’s why it is often referred to as the ‘program memory’. The memory organization will be discussed in below:
A RAM stands for Random Access Memory, it has basically the same purpose of the RAM in a desktop computer, which is to store some data required during the execution time of different programs. While an EEPROM, also called FLASH memory is a more elaborated ROM (Read Only Memory) which is the memory where the program being executed is stored. Even if that’s not exactly true, you can compare an EEPROM to the Hard-Disk of a desktop computer from a general point of view. The EEPROM term stands for Electronically Erasable and Programmable Read Only Memory.
In microcontrollers, like in any digital system, memory is organized in Registers, Which is the basic unit of construction of a memory. Each register is composed of a number of bits (usually eight) where the data can be stored. In the 8051 family of microcontrollers for example, most registers are 8-bit register, capable of storing values ranging from 0 to 255. In order to use bigger values, various register can be used simultaneously. FIGURE above shows a typical 8-bit registers, where the notation D0 to D7 stands for the 8 DATA bits of the register.
As you shall see, the RAM memory of the AT89S8253, which contains 256 registers, is divided into two main parts, the GPR part, and the SFR part. GPR stands for ‘General Purpose Register’ and are the registers that you can use to store any data during the execution of your program. SFRs (Special function Register) are registers used to control the functioning of the microcontroller and to assist the processor through the various operations being executed. For example, SFRs can be used to control Input/output lines, to retrieve data transmitted through the serial port of a desktop computer, or to configure one of the on-chip counters and timers.
In a memory each register has a specific address which is used by the processor to read and write from specific memory location. Figure 1.3.B shows the memory organization of the 256 registers of the RAM of the AT89S8253 microcontroller. The address is noted in Hexadecimal format as this notation simplifies digital logic calculations for the designers, 00 corresponds to the first location and FF which is equal to 256 corresponds to the last location.