Unit 1
Unit 1
Unit 1
Applications of microprocessor:
Calculators, Accounting Systems, Games Machine, Complex Industrial Controllers, Data Acquisition Systems, Military
applications, Communication systems, etc
Microcontroller :
Microcontroller is a modified and developed form of Microcomputer, in which all the necessary components like
programmable input/output peripherals, processor core and memory are present in a single microchip. This
technology is mostly used in embedded applications.
Microcontroller has a CPU, in addition with a fixed amount of RAM, ROM and other peripherals all embedded on a
single chip. At times it is also termed as a minicomputer or a computer on a single chip. Different manufacturers
produce microcontrollers with a wide range of features available in different versions. Some manufacturers are
ATMEL, Microchip, TI, Freescale, Philips, Motorola etc.
Microcontrollers are designed to perform specific tasks. Specific means applications where the relationship of input
and output is defined. Depending on the input, some processing needs to be done and output is delivered. For
example, keyboards, mouse, washing machine, digicam, pen drive, remote, microwave, cars, bikes, telephone,
mobiles, watches, etc. Since the applications are specific, they need small resources like RAM, ROM, I/O ports etc and
hence can be embedded on a single chip. This in turn reduces the size and the cost.
8051 by Intel and PIC by microchip are a few examples of microcontroller.
Microcomputer
Microcomputer is small computer; whereinone can see the association of microprocessor, I/O peripherals, data and
programmable memory as well as other supporting circuits at one place, but not in single chip.
The earlier computers like mainframes and minicomputers were comparatively much larger and more expensive.
Many microcomputers are also personal computers.
Block diagram of Microcomputer
Elements of microcomputer:
The microcomputer has microprocessor, memory, buses, and I/O devices as shown in the above block diagram.
Microprocessor : The microprocessor is the central processing unit. It does all the arithmetic and logical operations
through internal registers and ALU (Arithmetic Logic Unit). It also works as a master to control the data transfer which
includes address generation, bus synchronization and actual data transfer. Generally, the frequency of operation of
microprocessor is in Megahertz which means the time period is in microsecond. So, it is called as microprocessor.
Memory : The microprocessor does not has internal memory. So external memories need to be interfaced with the
microprocessor. It includes ROM which is used for storage of program and RAM which is used to store data
temporarily. Upon reset or power cut, the data in RAM is erased while data in ROM remains the same. Apart from
these, some systems may include EEPROM as per the applications requirement.
Buses : For actual data transfer between CPU and peripheral devices or memory, buses are used. A bus is collection of
connectors/paths (typically in multiples of 8) and is used for data transfer. Depending upon the use, the buses can be
classified in 3 types, viz., address bus, data bus and control bus. The data bus carries data in bidirectional way. The
address bus is used to carry the address whereas control bus is used to synchronize data transfer.
I/O devices : The input/output devices are necessary to interact with external world. The devices can be interfaced
through a peripheral controller IC. Similar to memory, input devices send data to CPU and output devices receive data
from CPU through buses. The I/O device can be as simple as keys and LEDs.
Applications of Microcomputers:
Modern desktop computers, video game consoles, laptops, tablet PCs, and many types of handheld devices, including
smart phones, pocket calculators, and industrial embedded systems.
The processor on a single chip is called a Microprocessor which can process micro-instructions
A Microcontroller is a small and low-cost microcomputer, which is designed to perform the specific tasks of
embedded systems
Microcomputer is a small, relatively inexpensive computer with a microprocessor as its central processing unit
(CPU).
Study Material
< DE/EJ/ET/EN/EX/EQ/IE/IS/IC/>:<22426><Microcontroller and Applications><Basics of Microprocessor and 8051
Microcontroller><UO1b.1:Describe types of Buses: address bus, data bus and control bus .>
Data
Q1. Do you know the
Bus
three types of bus?
Address Control
Bus Bus
Bus
https://youtu.be/3osm-soT_Lc
Applications
Microcomputers .Laptop, Embedded systems,
Microprocessors, Microcontrollers, Desktop PC
All the cables are different with the different grouping of conductors. But the communication paths inside the CPU
that are used to connect the internal components of the CPU are called buses. Similarly, a communication path
connecting the CPU to memory is a bus.
A bus is merely a group of wires that carry information between different components. Depending on the type of
information carried by them they can be classified as...
1. Address Bus
2. Data Bus
3. Control Bus
A bus may be unidirectional or bidirectional depending on the requirement of the information. Similarly, if it
connects the components of CPU then it can be internal buses and if it connects the CPU with the external
components then it is an external bus. Whether it is an internal bus or external bus depending on the type of
information they have the classification as an address bus, data bus, and control bus.
Address Bus
The address bus is used by the CPU to send the address of the memory location or the input/output port that is to be
accessed at the instant. It is a unidirectional bus i.e., the address can be transferred in one direction only and that is
form CPU to the required port or location.
Whether it is a read operation or write operation the CPU calculates the address of the required data and sends it on
the data bus for the execution of the required operation. The maximum number of memory locations that can be
accessed in a system is determined by the number of bits used by an address bus.
n 16
An address bus of n bits can address at the most 2 locations directly. Thus a 16-bit address bus can allow access 2
or 64 K Byte of memory locations.
In Intel 8085 microprocessor, address bus is of 16 bits .This means that microprocessor 8085 can transfer maximum16
bit address that is 65,536 different memory locations. The bus is multiplexed with 8-bit data bus. So, the most
significant bits of address do through Address bus(A7-A0) and least significant bits goes through multiplexed data bus
(AD0-AD7).
In a multiplexed address scheme, the address is sent in two equal parts on alternate cycles. These halves the number
of address signals required to connect to memory.
Data Bus
A data bus is used to carry the data and instructions from the CPU to memory and peripheral devices and vice versa.
Thus, it is a bidirectional bus. It is one of most important parts of the connections to the CPU because every program
instruction and every byte of data must travel across the bus at some point.
The size of the data bus is measured in bits. The data bus size has much influence on the computer architecture
because the important parameters of it like word size, the quantum of data etc. are determined and manipulated by
the size of the data bus.
The width of the data bus reflects the maximum amount of data that can be processed and delivered at one time. A
64-bit processor has a 64-bit data bus and can communicate 64-bits of data at a time, and whether the data is read or
written is determined by the control bus.
Generally, a microprocessor is called n-bit processors. Thus, as the CPU became more advanced, the data bus grew in
size. A 64-bit data bus can transfer 8 bytes in every bus cycle and thus its speed is much faster as compared to the 8-
bit processor that can transfer one byte in every bus cycle.
A good way to understand this flow of information is to consider a highway and the traffic it carries. If a highway has
only one lane for each direction of travel, only one car at a time can move in a certain direction, If one wants to
increase the traffic flow one can either increase the speed of the cars or add more lanes or do both.
Control Bus
A control bus contains various individual lines carrying synchronizing signals that are used to control various
peripheral devices connected to the CPU.
The common signals that are transferred to the control bus from CPU to devices and vice versa are
Memory read
Memory write
I/O read
I/O write etc
Signals are designed, keeping in mind, the design philosophy of the microprocessor and the requirement of the
various devices connected to the CPU. So different types of the microprocessor have different control signals.
A bus is a pathway for digital signals to rapidly move data. There are three internal buses associated with processors: the
data bus, address bus, and control bus. Together, these three make up the “system bus”.
Study Material
Harvard Von-Neumann
Architecture Architecture
Harvard architecture uses separate memories for program and data with their independent address and data buses.
This architecture supports parallel buses for address and data and allows a different internal organization such that
instruction can be prefetched and decoded while multiple data are being fetched and operated on.
The data bus may have different size than the address bus. This allows the optimal bus width of the data and
address buses for fast execution of the instruction.
The MCS-51 family of microcontrollers by Intel has Harvard architecture because there are different memory
spaces for program and data and separate buses for address and data.
Also, PIC microcontrollers by Microchip use Harvard architecture. Example: PIC16F84 MC
Many special designs of microcontroller and DSP use Harvard architectures. Example: SHARC, ARM9
Von-Neumann Architecture :
In Von-Neumann architecture, programs and data are stored on the same memory space.
Von-Neumann architecture allows storing or modifying the program easily.
The code storage may not be optimal and requires multiple fetches to form the instruction.
Program and data fetches are done using time division multiplexing which effect the performance.
For example, Motorola 68HC11 microcontroller, ARM7, Pentium, MSP 430 useVon-Neumann architecture.
Difference between Harvard and Von-Neumann Architecture:
Harvard Architecture Von-Neumann Architecture
(1) The distinction between program and data memory (1) The distinction between program and data memory is
is physical. logical.
(2) It uses physically separate memories for their (2) It uses single memory for their instructions and data.
instructions and data.
(3) Requires separate and dedicated buses for (3) Requires single bus for instructions and data.
instructions and data.
(4) Instructions and data can be fetched simultaneously (4) Instructions and data have to be fetched in sequential
as there are separate buses for instructions and data order and hence affects the performance.
which helps in post execution.
(5) Its design is complicated. (5) Its design is simpler.
Pins 1 – 8 (PORT 1): Pins 1 to 8 are the PORT 1 Pins of 8051. PORT 1 Pins consists of 8 – bit bidirectional Input / Output Port
with internal pull – up resistors. PORT 1acts as 8 – bit I/O PORT.
Pin 9 (RST): Pin 9 is the Reset Input Pin. It is an active HIGH Pin i.e. if the RST Pin is HIGH for a minimum of two machine
cycles, the microcontroller will be reset. During this time, the oscillator must be running.
The Reset Circuit. A logic HIGH (+5V) on Reset Pin for a minimum of two machine cycles (24 clock cycles) will reset the
8051 Microcontroller. The reset circuit of the 8051 Microcontroller consists of a capacitor, a resistor and a push button
and this type of reset circuit provides a Manual Reset Option. If you remove the push button, then the reset circuit
becomes a Power-On Reset Circuit.
Pins 10 – 17 (PORT 3): Pins 10 to 17 form the PORT 3 pins of the 8051 Microcontroller.
PORT 3 also acts as a bidirectional Input / Output PORT with internal pull-ups.
Additionally, all the PORT 3 Pins have special functions. The following table gives the details of the additional functions of
PORT 3 Pins.
Pins 18 & 19: Pins 18 and 19 i.e. XTAL 2 and XTAL 1 are the pins for connecting external oscillator. Generally, a Quartz
Crystal Oscillator is connected here.
Pin 20 (GND): Pin 20 is the Ground Pin of the 8051 Microcontroller. It represents 0V and is connected to the negative
terminal (0V) of the Power Supply.
Pins 21 – 28 (PORT 2): These are the PORT 2 Pins of the 8051 Microcontroller.
PORT 2 is also a Bidirectional Port i.e. all the PORT 2 pins act as Input or Output.
Additionally, when external memory is interfaced, PORT 2 pins act as the higher order address byte. PORT 2 Pins have
internal pull-ups.
Pin 29 (PSEN): Pin 29 is the Program Store Enable Pin (PSEN). Using this pins, external Program Memory can be read.
Pin 30 (ALE/PROG): Pin 30 is the Address Latch Enable Pin. Using this Pins, external address can be separated from data (as
they are multiplexed by 8051).
During Flash Programming, this pin acts as program pulse input (PROG).
Pin 31 (EA/VPP): Pin 31 is the External Access Enable Pin i.e., allows external Program Memory. Code from external
program memory can be fetched only if this pin is LOW. For normal operations, this pins is pulled HIGH.
During Flash Programming, this Pin receives 12V Programming Enable Voltage (VPP).
Pin 40 (VCC): Pin 40 is the power supply pin to which the supply voltage is given (+5V).
• It is special math register. It is used in conjunction with the A register as the second input operand and to return
8-bit result.
• It is used in multiply and divide instructions. It is also used as a general-purpose register. It is also treated as
memory location. It is bit accessible.
Data Pointer (DPTR):
• The data pointer is a 16-bit register used to hold the 16-bit address of data memory.
• This can also be used as two numbers of 8-bit data pointer namely DPH and DPL.
• The 8-bit data pointers are used for accessing internal RAM and SFR.
• The 16-bit data pointer is used for accessing external data memory.
The contents of data pointer are programmable using instructions
STACK POINTER (SP):
• SP is 8- bit register that points to the last used location of the stack(stack top )
• Push operation will first increment SP and then copy data.
• Pop operation will first copy data and then decrement SP.
• Upon reset SP contains 07H. So, register banks 2,3,4 (08H to 1FH) form the default stack area.
• Stack can be relocated by setting SP to the upper memory area in 30H to 7FH.For e.g., MOV SP, #32H, so SP =32h
means stack area starts from 33h.
PROGRAM COUNTER (PC):
• Program counter is a 16-bit register. It stores address of next instruction to be fetched & executed and is
automatically incremented after fetching instruction. PC is the only register that has no address
PSW (Program Status Word) : - 15, 16, 17]
It is a flag register. It provides four math flags and five control flags. Many instructions affect several status flags, which are
grouped together to form PSW.
CY AC F0 RS1 RS0 OV X P
Bit7 Bit0
CY: (Carry Flag) : It is a carry flag. Internal hardware or software sets it. It is set when there is a carry from D7 bit. It is used
in arithmetic, logical, jump, rotate and Boolean operations. In Boolean operation, it functions as an accumulator.
AC: (Auxiliary Carry Flag) : It is also called half carry. It is used in BCD arithmetic operations. It will be set when there is a
carry from D3 bit.
F0: (User Flag 0) : It is user-defined flag. The user defines the function of this flag. The user can test, clear and set this flag
through software.
RS1 and RS0: (Register Bank Select) : These flags are used to select only one bank of 8 registers. In default mode, it selects
bank0. The user can use only one bank of registers at a time. The programmer can use different banks for different
programs.
RS1 RS0 REGISTER BANK
0 0 BANK0 (00 –07H)
0 1 BANK1 (08 – 0FH)
1 0 BANK2 (10 – 17H)
1 1 BANK3 (18 – 1FH)
OV : (Overflow Flag) : It is used in signed arithmetic operations only. Overflow occurs when the result of signed arithmetic
operation is too large, so it is cannot be stored in one register. It is used to detect overflow in the signed arithmetic
operations.
P : (Parity Flag) : It is a parity flag. It shows the parity of data stored in the accumulator. If the number of 1s present in the
accumulator is odd, then P flag is set to 1. This flag is reset for even number of 1s present in the accumulator. The parity of
the data including parity bit is always even. Hence, this flag can be used as even parity flag.
Registers (R0-R7) : There are eight general purpose registers R0 to R7 in each bank which is selected using PSW register
bank selection bits. They are used for temporary storing variables and intermediate results.
Timer Registers:
Register pairs (TH0, TL0), and (TH1, TL1), are the 16-bit counting registers for Timer/Counters 0, and 1, respectively
I/O Ports:
• The 8051 has four numbers of 8-bit ports namely port-0, port- 1, port-2 and port-3.
• Each port has a latch and driver (or buffer).
• When external memory is employed the port-0 lines will function as multiplexed low byte address/data lines and
port-2 lines will function as high byte address lines.
• Also, the port pins P3.7 and P3.6 are used to output read and write control signals respectively.
• The port-1 is dedicated I/O port and does not have any alternate function.
SBUF ( SERIAL DATA BUFFER ) :
SBUF is 8 bit register used for serial communication.
SBUF are physically two registers with same address and same name. One is read-only used for reading serial
input data and the other is write-only used for storing serial output data. SFR Address is 99h
Control Registers:
Special Function Registers IP, IE, TMOD, TCON, T2CON, SCON, and PCON contain control and status bits for the interrupt
system, the timer/counters, and the serial port.
Timer/Counter & Serial port:
• The 8031/8051 has two 16-bit programmable timer/counter namely timer-1 and timer 0.
• In the counter mode of operation, they can count the number of high to low transitions of the signal applied to
the timer pins.
• In timer mode of operation, they can be independently programmed to work in any one of the four operation
modes. They are called mode-0, mode-1, mode-2 and mode-3.
• In mode-0 the serial port can either receive or transmit at fixed baud rate.
• In mode-2 it can simultaneously transmit and receive at any one of the two selectable baud rates.
• In mode-1 and mode-3 it can work as full duplex serial port with variable baud rate, which is programmed using
timer-1
Interrupts:
Six interrupts are allocated as follows
• Reset – power-up reset
• Two interrupts are set aside for the timers: one for timer 0 and one for timer 1
• Two interrupts are set aside for hardware external interrupts ƒ P3.2 and P3.3 are for the external hardware
interrupts INT0 (or EX1), and INT1 (or EX2)
• Serial communication has a single interrupt that belongs to both receive and transfer
A microcontroller is an integrated chip designed under Very Large-Scale Integration technique that consists of a processor
with other peripheral units like memory, I/O port, timer, decoder, ADC etc. A microcontroller is basically designed in such a
way that all the working peripherals are embedded in a single chip with the processor.
Study Material
< DE/EJ/ET/EN/EX/EQ/IE/IS/IC/>: <22426><Microcontroller and Applications><Basics of Microprocessor and 8051
Microcontroller><UO1b.5:Explain Boolean Processor, Power saving options -idle and power down mode>
IDLE MODE
POWER DOWN MODE
1. IDLE MODE:It is selected by setting IDL bit in PCON register. In idle mode the internal clock is gated off to CPU but not to
interrupt, timer and serial port functions. PC, SP,PSW, Accumulator and all other registers maintain their data during idle
mode. Port pins hold their state, they had at time idle mode was activated.
a. Activation of any enabled interrupts will cause PCON.0 to be cleared and idle mode is terminated.
b. Hardware reset clears IDL bit in PCON register directly. At this time CPU resumes program execution from where
it left off, i.e., the instruction following the one which activated idle mode.
2. POWER DOWN MODE:It is selected by setting PD bit in PCON register. In power down mode the on-chip oscillator is
stopped. With the clock frozen, all functions are stopped. Contents of on chip RAM and SFRs are maintained. Port pins
output the values they held by their respective SFRs. ALE & PSEN are held low. In this mode VCC can be reduced as low as
2Volts.
Termination from power down mode:The only exit from this mode is hardware reset. Reset redefines all SFRs, but does not
change on chip RAM
Data
Q1 Did you know 8051 Memory
microcontroller has
128bytes of internal RAM
Memory
and 4k bytes of internal
ROM?
Program
Memory
The stack pointer SP increases before each PUSH operation and decreases after each pop instruction.
When the 8051 is reset, the Stack Pointer will point to 07H. It means the location 08H to 7FHcan be used as a stack.
Here it is assumed that the register bank 0 is in use and 20H to 27H are not like bit-addressable area.
8031 8752
Key Definitions
8051 is a popular 8-bit microcontroller and has
been used in many applications since Intel
Derivative of 8051 microcontroller
Q1. Give difference introduced it. Many 8051 architecture are
between 8951 and 8952 produced by Triscend, Intel, Atmel, Philips,
Derivative microcontroller (or derivative chip) is a
based on chip data Infineon (Siemens), ISSI, and Max Corp. with
term used to refer to any of the hundreds of 8051-
memory and on chip advanced features/ or memory capacity. While
compatible microcontrollers produced by dozens of
program memory each CU may have same core the feature set can
semiconductor firms such as Dallas Semiconductor,
vary a lot. Some of the common differences
Philips, Atmel, etc. These lines of microcontrollers all
within a single family are:
Ans: 8951 has 128 bytes of use the "8051 core" licensed from Intel. The "core"
On Board ROM size
on chip data memory and refers to the instruction set and Special Function
On Board RAM size
4k Bytes of Flash memory Register structure/map.
Re-programmability
whereas 8952 has 256
ADCs
bytes of on chip data https://youtu.be/xTR_7zl9JYg
Timers
memory and 8k Bytes of
And many other features.
Flash memory.
This 8-bit architecture has different segments
such as 8052, 8051, 8751 and 8031. 8052 is the
super-set of 8051 and 8031 is the program
memory-less microcontroller hence, it has
interfaced with external ROM.
Whereas, 8751 chip has only 4Kbytes of on chip
UV-EPROM.
Features of Derivatives of 8051 microcontroller.
8951: The 89c51 is compatible with MCS 51 family. It has 128btes of on chip data memory,4k bytes of flash memory, two 16-bit timers,
four I/O ports, fivevectoredinterrupts, on chip oscillator and a serial port.
8952- Low-power, high-performance CMOS 8-bit microcontroller with 8KB of ISP flash memory. It has 256 bytes of on chip RAM. The
device uses Microchip high-density, non-volatile memory technology and is compatible with the industry-standard 80C51 instruction set
and pinout. On-chip flash allows the program memory to be reprogrammed in-system or by a conventional non-volatile memory
programmer. This powerful microcontroller is suitable for many embedded control applications.
.
8031: The 8031 is the members of MCS-51 family of 8-bit microcontrollers. 8031/80C31 have the same integrated peripherals as on
8051 microcontroller-4 I/O ports, two 16-bit timers/counters, on-chip oscillator, and a serial port.
The MCUs have 128 bytes of internal RAM and in addition to that, can utilize up to 64 KB of external data memory. The microcontrollers
do not have on-chip ROM and must use external program memory.
8751 is the 8051-architecture microcontroller consists of memory and interrupts, timer, same as in 8051 microcontroller. Butit has UV-
EPROM. Using 8751 chip for development requires access to a PROM burner, as well as a UV-EPROM eraser to erase the contents of
UV-EPROM inside the 8751 chips before you can program it again.Because the on-chip ROM for the 8751 is UV-EPROM, it takes around
20 minutes to erase the 8751 before it can be programmed again.
8052 is the super-set of 8051 that consists of 8K bytes of internal ROM (4K in 8051), 256 bytes of RAM (128 bytes in 8051), 3 Timers (2
timers in 8051), and 6 Interrupts (4 Interrupts in 8051) and other functionalities are same. All programs, written for 8051, can be run for
8052 but the reverse is not true
89V51RD2: 80C51 compatible CPU. It has On chipBootloader,32kB of on chip flash user code memory with ISP and IAP, Supports 12-
clock (default) or 6-clock mode selection via software or ISP, SPI and enhanced UART, PCA with PWM and capture/compare functions.
.
ON-CHIP ON-CHIP
NO. OF
DATA PROGRAM 16-BIT FULL DUPLEX
DEVICE VECTORED
MEMORY MEMORY TIMER/COUNTER I/O
INTERUPTS
(bytes) (bytes)
Introduction:
Troubleshooting is the process that determines the cause of the problem in the electronic circuit by examining the affected area of it,
and then by taking appropriate action. For minor problems, troubleshooting requires a little knowledge about the circuit and its
components’ working because it involves checking the connections only. However, the major problems of these circuits require a
deeper knowledge of the circuit operation and the way of using various troubleshooting tools.
Select Troubleshooting Tools
Troubleshooting process involves checking the terminal voltage across different components and devices in the circuit; checking the
continuity of the current for open circuit faults, components like resistor, capacitor, transistors, and their status checking whether they
are functioning or not, and so on. Some of these tools are:
Digital or Analog multimeters
Oscilloscope
LCR meters
Variable Power supply with a metered indication
Generalized Troubleshooting
Power up the Circuit.
Before checking with the above tools, plug the circuit to the main power supply so that it is possible to test it in different ways.
Using oscilloscope -
Check if crystal / clock is working and oscillating. The frequency of clock should match the crystal frequency.
Check if control signals like WR, RD, ALE are operating fine at Microcontroller pins as well as to pins of external ROM
Check that none of the interrupts are permanently active
Check if signals on Data and Address bus are active indicating that some address and data is being transferred on the bus.If
the data and address being transferred are to be accurately monitored, then a logic analyser is to be used instead of an
oscilloscope.
If all signs indiciate that Microcontrollers are functioning and are active and yet the program is not working as desired, then it is highly
likely that the program has a bug and it is not operating as desired. Efforts should be made to debug software step by step and verify if
the I/O Ports of microcontrollers are having the desired signals
To start the process of troubleshooting, first step should be to have a close visual inspection of the system. Then understand the basic
functionality of the system. Then proceed to analyse the cause of the trouble.