The 8051

 
<-Previous
   
  8051 Memory Organisation
   
  Internal ROM
  The 8051 has 4K (4096 locations) of on-chip ROM. This is used for storing the system program. 212 = 4096, therefore the internal ROM address bus is 12 bits wide and internal ROM locations go from 000H to FFFH.
   
   
  Internal RAM
   
  There are 256 bytes of internal RAM on the 8051. 28 = 256, therefore the internal RAM address bus is 8 bits wide and internal RAM locations go from 00H to FFH.
   
  The first 128 locations (00H to 7FH) of internal RAM are used by the programmer for storing data while the second 128 locations (80H to FFH) are the Special Function Registers (SFRs) which we will deal with later.
   
  The diagram below is a summary of the 8051 on-chip RAM.
   
 
7F
 
 
 
General Purpose RAM
 
 
 
30
2F
7F 7E 7D 7C 7B 7A 79 78
2E
77 76 75 74 73 72 71 70
2D
6F 6E 6D 6C 6B 6A 69 68
2C
67 66 65 64 63 62 61 60
2B
5F 5E 5D 5C 5B 5A 59 58
2A
57 56 55 54 53 52 51 50
28
4F 4E 4D 4C 4B 4A 49 48
28
47 46 45 44 43 42 41 40
27
3F 3E 3D 3C 3B 3A 39 38
26
37 36 35 34 33 32 31 30
25
2F 2E 2D 2C 2B 2A 29 28
24
27 26 25 24 23 22 21 20
23
1F 1E 1D 1C 1B 1A 19 18
22
17 16 15 14 13 12 11 10
21
0F 0E 0D 0C 0B 0A 09 08
20
07 06 05 04 03 02 01 00
1F
Register Bank 3
18
17
Register Bank 2
10
0F
Register Bank 1
08
07
Default Register Bank (Bank 0)
00
 
     
F0
F7 F6 F5 F4 F3 F2 F1 F0
B
     
E0
E7 E6 E5 E4 E3 E2 E1 E0
ACC
     
D0
D7 D6 D5 D4 D3 D2 D1 D0
PSW
     
B8
BF BE BD BC BB BA B9 B8
IP
     
B0
B7 B6 B5 B4 B3 B2 B1 B0
P3
     
A8
AF AE AD AC AB AA A9 A8
IE
     
A0
A7 A6 A5 A4 A3 A2 A1 A0
P2
     
99
 
SBUF
98
9F 9E 9D 9C 9B 9A 99 98
SCON
     
90
97 96 95 94 93 92 91 90
P1
     
8D
 
TH1
8C
 
TH0
8B
 
TL1
8A
 
TL0
89
 
TMOD
88
8F 8E 8D 8C 8B 8A 89 88
TCON
87
 
PCON
     
83
 
DPH
82
 
DPL
81
 
SP
80
87 86 85 84 83 82 81 80
P0
RAM
SPECIAL FUNCTION REGISTERS
   
  Register Banks
  There are four register banks from 00H to 1FH. On power-up, registers R0 to R7 are located at 00H to 07H. However, this can be changed so that the register set points to any of the other three banks (if you change to Bank 2, for example, R0 to R7 is now located at 10H to 17H).
   
  Bit-addressable Locations
  The 8051 contains 210 bit-addressable locations of which 128 are at locations 20H to 2FH while the rest are in the SFRs. Each of the 128 bits from 20H to 2FH have a unique number (address) attached to them, as shown in the table above. The 8051 instruction set allows you to set or reset any single bit in this section of RAM.
With the general purpose RAM from 30H to 7FH and the register banks from 00H to 1FH, you may only read or write a full byte (8 bits) at these locations.
However, with bit-addressable RAM (20H to 2FH) you can read or write any single bit in this region by using the unique address for that bit. We will later see that this is a very powerful feature.
   
  Special Function Registers (SFRs)
  Locations 80H to FFH contain the special function registers. As you can see from the diagram above, not all locations are used by the 8051 (eleven locations are blank). These extra locations are used by other family members (8052, etc.) for the extra features these microcontrollers possess.
  Also note that not all SFRs are bit-addressable. Those that are have a unique address for each bit.
  We will deal with each of the SFRs as we progress through the course, but for the moment you should take note of the accumulator (ACC) at address E0H and the four port registers at addresses 80H for P0, 90h for P1, A0 for P2 and B0 for P3.
  We will later see how easy this makes ready from and writing to any of the four ports.
   
  The Missing Registers
  The two registers not shown in the table above are the instruction register and the program counter. These two very important registers are not placed in RAM because it is not necessary to make them directly accessible to the programmer. The instruction register gets its data from the execution cycle while the program counter is manipulated by the operation of these instructions.
   
   
 
<-Previous
 
   
 
Copyright (c) 2005-2006 NyCelt LLC