Inside The Computer: Module 1: 8051 Microcontroller Basics
Inside The Computer: Module 1: 8051 Microcontroller Basics
Inside The Computer: Module 1: 8051 Microcontroller Basics
of E & E
Hirasugar Institute of Technology,Nidasoshi. Notes
Inculcating Values, Promoting Prosperity Microcontroller
Approved by AICTE and Affiliated to VTU Belagavi 2018-19
Microprocessor Microcontroller
1) It contains ALU, General purpose registers, 1) It contains microprocessors and in addition it
stack pointer, program counter, interrupt has built in ROM, RAM, I/O devices, timers
circuits etc. and counters.
2) Requires more hardware, increases in PCB 2) Requires less hardware, reduced PCB size.
3) Access time for memory and I/O devices are 3) Access time is less due to in built memory
more and I/O port
4) Many instructions to move data between 4) One or more instructions to move data
memory and CPU between memory and CPU
5) More flexible from design point of view 5) Less flexible
6) Single memory map for data and code 6) Separate memory map for data and code.
7) Few pins are multifunctional 7) More pins are multifunctional
8) One or more bit handling instructions are 8) More number of bit handling instructions are
available available.
Criteria for choosing a Microcontroller
There are wide varieties of Microcontrollers available in the market. Program written for one
Microcontroller will not run others. Choice of the microcontroller is based on three parameters.
1. It must perform the required task efficiently and effectively.
a) Speed, Amount of RAM and ROM on chip, Power consumption
b) Number of I/O pins and timer on chip
c) Cost per unit, Ease of upgrading
d) Packaging-No of Pins and Packaging formats
2. Availability of software development tools such as compilers and assemblers, debuggers.
3. Availability of reliable source for the microcontroller.
Other members of 8051 family
There are two other members in 8051 family of Microcontroller. They are 8052 and 8031. 8052
has all standard features of 8051 as well as an extra 128 bytes of RAM and an extra timer. 8052
has 256 bytes of RAM and 3 timers. It also has 8K bytes of on chip program instead of 4K bytes.
8031 Microcontroller is often referred as a ROM less 8051 since it has 0K bytes of on chip
ROM. To use this chip we must add external ROM to it. Two ports will be lost in the process of
adding external ROM.
Comparison of 8051 family members
Fig. 6 Instruction cycle of 8051(Instruction cycle has six states (S 1 - S 6 ). Each state has two
pulses (P1 and P2))
0FFFH
4K bytes
of ROM
0000H
Figure: 74LS138
The above shows that the range for Y4 is 4000H to 4FFFH. We notice that A15 must be 0 for the
decoder to be activated. Y4 will be selected when A14 A13 A12 = 100 (4 in binary). The
remaining A11-A0 will be 0 for the lowest address and 1 for the highest address.
(b) The address range for Y2 is 2000H to 2FFFH.
A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1
(c) The address range for Y7 is 7000H to 7FFFH.
A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
4. Using programmable logic as an address decoder
Other widely used decoders are programmable logic chips such as PAL and GAL chips. One
disadvantage of these chips is that one must have access to a PAL/GAL software and burner,
whereas the 74LS138 needs neither of these. The advantage of these chips is that they are much
more versatile since they can be programmed for any combination of address ranges.
8031/51 interfacing with external ROM and RAM
8031/51 interfacing with external ROM
The 8031 chip is a ROM less version of the 8051. It is exactly like any member of the 8051
family as far as executing the instructions and features are concerned, but it has no on-chip
ROM. To make the 8031 execute 8051 code, it must be connected to external ROM memory
containing the program code. 8031 is ideal for many systems where the on-chip ROM of 8051 is
not sufficient, since it allows the program size to be as large as 64K bytes.
For 8751/89C51/DS5000-based system, we connected the EA pin to Vcc to indicate that the
program code is stored in the microcontroller’s on-chip ROM. To indicate that the program code
is stored in external ROM, this pin must be connected to GND.
Since the PC (program counter) of the 8031/51 is 16-bit, it is capable of accessing up to 64K
bytes of program code. In the 8031/51, port 0 and port 2 provide the 16-bit address to access
Fig 20: Data , address and control buses for the 8031/51
In an 8751 system we could use onchip ROM for boot code and an external ROM will contain
the user’s program. We still have EA = Vcc, Upon reset 8051 executes the on-chip program
first, then when it reaches the end of the on-chip ROM, it switches to external ROM for rest of
program.
Fig 23: 8031 Connection to External Data ROM and External Program ROM
8051 Data memory space
To connect the 8051 to an external SRAM, we must use both RD (P3.7) and WR (P3.6) pins. In
writing data to external data RAM, we use the instruction MOVX @DPTR, A. In some
applications we need a large amount of memory to store data. The 8051 can support only 64K
bytes of external data memory since DPTR is 16-bit.