Docsity

I Difference between Microprocessor and microcontroller ..., Lecture notes of Communication

Toggle sidebar
bg1
UNIT - I
Difference between Microprocessor and microcontroller
Microprocessor
Micro Controller
Microprocessor is heart of Computer system.
Micro Controller is a heart of embedded system.
It is just a processor. Memory and I/O
components have to be connected externally
Micro controller has processor along with
internal memory and i/O components
Since memory and I/O has to be connected
externally, the circuit becomes large.
Since memory and I/O are present internally, the
circuit is small.
Cannot be used in compact systems and hence
inefficient
Can be used in compact systems and hence it is
an efficient technique
Cost of the entire system increases
Cost of the entire system is low
Due to external components, the entire power
consumption is high. Hence it is not suitable to
used with devices running on stored power like
batteries.
Since external components are low, total power
consumption is less and can be used with devices
running on stored power like batteries.
Most of the microprocessors do not have power
saving features.
Most of the micro controllers have power saving
modes like idle mode and power saving mode.
This helps to reduce power consumption even
further.
Since memory and I/O components are all
external, each instruction will need external
operation, hence it is relatively slower.
Since components are internal, most of the
operations are internal instruction, hence speed is
fast.
Microprocessor have less number of registers,
hence more operations are memory based.
Micro controller have more number of registers,
hence the programs are easier to write.
Microprocessors are based on von Neumann
model/architecture where program and data are
stored in same memory module
Micro controllers are based on Harvard
architecture where program memory and Data
memory are separate
Mainly used in personal computers
Used mainly in washing machine, MP3 players
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e

Partial preview of the text

Download I Difference between Microprocessor and microcontroller ... and more Lecture notes Communication in PDF only on Docsity!

UNIT - I

Difference between Microprocessor and microcontroller

Microprocessor Micro Controller

Microprocessor is heart of Computer system. Micro Controller is a heart of embedded system.

It is just a processor. Memory and I/O components have to be connected externally

Micro controller has processor along with internal memory and i/O components

Since memory and I/O has to be connected externally, the circuit becomes large.

Since memory and I/O are present internally, the circuit is small.

Cannot be used in compact systems and hence inefficient

Can be used in compact systems and hence it is an efficient technique

Cost of the entire system increases Cost of the entire system is low

Due to external components, the entire power consumption is high. Hence it is not suitable to used with devices running on stored power like batteries.

Since external components are low, total power consumption is less and can be used with devices running on stored power like batteries.

Most of the microprocessors do not have power saving features.

Most of the micro controllers have power saving modes like idle mode and power saving mode. This helps to reduce power consumption even further.

Since memory and I/O components are all external, each instruction will need external operation, hence it is relatively slower.

Since components are internal, most of the operations are internal instruction, hence speed is fast.

Microprocessor have less number of registers, hence more operations are memory based.

Micro controller have more number of registers, hence the programs are easier to write.

Microprocessors are based on von Neumann model/architecture where program and data are stored in same memory module

Micro controllers are based on Harvard architecture where program memory and Data memory are separate

Mainly used in personal computers Used mainly in washing machine, MP3 players

8051 Microcontroller

The INTEL 8051 is an 8 bit microcontroller with 128 byte internal RAM and 4K bytes internal ROM. The 8051 is a 40 pin IC available in Dual in line package (DIP) and it requires a single power supply of +5V.

Pin Diagram

 Internal RAM of 128 bytes.

o 4 Register banks , each containing 8 registers o 16 bytes ,which may be addressed at the bit level o 80 bytes of general purpose memory

 32 input / output pins are arranged as four 8 bit ports : P0-P

 Two 16 bit timer / counters : T0 and T

 Full duplex serial data receiver / transmitter : SBUF  Control registers TCON,TMOD,SCON,PCON,IP and IE

 2 external and 3 internal interrupt sources

 Oscillator and Clock circuits.

8051 System Clock

A & B Registers

8051 microcontroller has 2 registers, namely Register A and Register B. Register A serves as an accumulator while Register B functions as a general purpose register. These registers are used to store the output of mathematical and logical instructions.

The operations of addition, subtraction, multiplication and division are carried out by Register A. Register B is usually unused and comes into picture only when multiplication and division functions are carried out by Register A. Register A also involved in data transfers between the microcontroller and external memory.

Program Counter (PC)

A program counter is a 16-bit register and it has no internal address. The basic function of program counter is to fetch from memory the address of the next instruction to be executed. The PC holds the address of the next instruction residing in memory and when a command is encountered, it produces that instruction. This way the PC increments automatically, holding the address of the next instruction.

Data Pointer (DPTR)

The data pointer or DPTR is a 16-bit register. It is made up of two 8-bit registers called DPH and DPL. Separate addresses are assigned to each of DPH and DPL. These 8-bit registers are used for the storing the memory addresses that can be used to access internal and external data/code.

Stack Pointer (SP)

The stack pointer (SP) in 8051 is an 8-bit register. The main purpose of SP is to access the stack. As it has 8-bits it can take values in the range 00 H to FF H. Stack is a special area of data in memory. The SP acts as a pointer for an address that points to the top of the stack.

PSW (Program Status Word)

Program Status Word or PSW is a hardware register which is a memory location which holds a program's information and also monitors the status of the program this is currently being executed. PSW also has a pointer which points towards the address of the next instruction to be executed. PSW register has 3 fields namely are instruction address field, condition code field and error status field. We can say that PSW is an internal register that keeps track of the computer at every instant.

Generally, the instruction of the result of a program is stored in a single bit register called a 'flag'. The are7 flags in the PSW of 8051. Among these 7 flags, 4 are math flags and 3 are general purpose or user flags.

The 4 Math flags are: Carry flag(C), Auxiliary Carry (AC) ,Overflow (OV) and Parity (P)

The 3 General purpose flags or User flags are: FO, GFO and GF 1

CY PSW.7 Carry flag (Carry out from the D7 bit)

AC PSW.6 Auxiliary carry flag (A carry from D3 to D4)

— PSW.5 Available to the user for general purpose

RS1 PSW.4 Register Bank selector bit 1.

RS0 PSW.3 Register Bank selector bit 0.

OV PSW.2 Overflow flag.

— PSW.1 User definable bit.

P PSW.0 Parity flag. Set/cleared by hardware each instruction cycle to indicate an

odd/even number of 1 bits in the accumulator.

\

Special function registers

The table shows the list of special function registers for various operations in 8051.

RAM

The 8051 microcontroller is composed of 128 bytes of internal RAM. This is a volatile memory since its contents will be lost if power is switched off. These 128 bytes of internal RAM are divided into 32 working registers which in turn constitute 4 register banks (Bank 0-Bank 3) with each bank consisting of 8 registers (R0 - R7). There are 128 addressable bits in the internal RAM.

Data and Address Bus

A bus is group of wires using which data transfer takes place from one location to another within a system. Buses reduce the number of paths or cables needed to set up connection between components.

There are mainly two kinds of buses - Data Bus and Address Bus

Data Bus: The purpose of data bus is to transfer data. It acts as an electronic channel using which data travels. Wider the width of the bus, greater will be the transmission of data.

Address Bus: The purpose of address bus is to transfer information but not data. The information tells from where within the components, the data should be sent to or received from. The

capacity or memory of the address bus depends on the number of wires that transmit a single address bit.

Four General Purpose Parallel Input/Output Ports

The 8051 microcontroller has four 8-bit input/output ports. These are:

PORT P0: When there is no external memory present, this port acts as a general purpose input/output port. In the presence of external memory, it functions as a multiplexed address and data bus. It performs a dual role.

PORT P1: This port is used for various interfacing activities. This 8-bit port is a normal I/O port i.e. it does not perform dual functions.

PORT P2: Similar to PORT P0, this port can be used as a general purpose port when there is no external memory but when external memory is present it works in conjunction with PORT PO as an address bus. This is an 8-bit port and performs dual functions.

PORT P3: PORT P3 behaves as a dedicated I/O port

PORT 0 :

The structure of a Port-0 pin is shown in fig 6.It has 8 pins (P0.0-P0.7).

PORT 0 as an Output Port

Suppose we want to write 1 on pin of Port 0, a '1' written to the latch which turns 'off' the lower FET while due to '0' control signal upper FET also turns off as shown in fig. above. Here we wants logic '1' on pin but we getting floating value so to convert that floating value into logic '1' we need to connect the pull up resistor parallel to upper FET. This is the reason why we needed to connect pull up resistor to port 0 when we want to initialize port 0 as an output port.

If we want to write '0' on pin of port 0 , when '0' is written to the latch, the pin is pulled down by the lower FET. Hence the output becomes zero.

When the control is '1', address/data bus controls the output driver FETs. If the address/data bus (internal) is '0', the upper FET is 'off' and the lower FET is 'on'. The output becomes '0'. If the address/data bus is '1', the upper FET is 'on' and the lower FET is 'off'. Hence the output is '1'. Hence for normal address/data interfacing (for external memory access) no pull-up resistors are required.Port-0 latch is written to with 1's when used for external memory access.

PORT 1:

The structure of a port-1 pin is shown in fig below.It has 8 pins (P1.1-P1.7).

Port-2 we use for higher external address byte or a normal input/output port. The I/O operation is similar to Port-1. Port-2 latch remains stable when Port-2 pin are used for external memory access. Here again due to internal pull-up there is limited current driving capability.

PORT 3:

Port-3 (P3.0-P3.7) having alternate functions to each pin,The internal structure of a port-3 pin is shown in fig below.

Following are the alternate functions of port 3:

It work as an IO port same like Port 2. only alternate function of port 3 makes its architecture different than other ports.

Timers and Counters

The 8051 has two timers: timer0 and timer1. They can be used either as timers or as counters. Both timers are 16 bits wide. Since the 8051 has an 8-bit architecture, each 16-bit is accessed as two separate registers of low byte and high byte. First we shall discuss about Timer0 registers.

Timer0 registers is a 16 bits register and accessed as low byte and high byte. The low byte is

referred as a TL0 and the high byte is referred as TH0. These registers can be accessed like any

other registers.

Timer1 registers is also a 16 bits register and is split into two bytes, referred to as TL1 and TH1.

0 1 1 16-bit timer mode, 16-bit timer/counters THx and TLx are cascaded; There are no prescalar.

1 0 2 8-bit auto reload mode, 8-bit auto reload timer/counter; THx holds a

value which is to be reloaded into TLx each time it overflows.

1 1 3 Spilt timer mode.

Mode 1- It is a 16-bit timer; therefore it allows values from 0000 to FFFFH to be loaded into the

timer’s registers TL and TH. After TH and TL are loaded with a 16-bit initial value, the timer must be

started. We can do it by “SETB TR0” for timer 0 and “SETB TR1” for timer 1. After the timer is started. It starts count up until it reaches its limit of FFFFH. When it rolls over from FFFF to 0000H, it

sets high a flag bit called TF (timer flag). This timer flag can be monitored. When this timer flag is

raised, one option would be stop the timer with the instructions “CLR TR0“ or CLR TR1 for timer 0

and timer 1 respectively. Again, it must be noted that each timer flag TF0 for timer 0 and TF1 for timer1. After the timer reaches its limit and rolls over, in order to repeat the process the registers TH

and TL must be reloaded with the original value and TF must be reset to 0.

Mode 1 programming

The following are the characteristics and operations of mode 1:

  1. It is a 16-bit timer; therefore, it allows values of 0000 to FFFFH to be loaded into the timer’s registers TL and TH.
  2. After TH and TL are loaded with a 16-bit initial value, the timer must be start ed. This is done by “SETB TRO” for Timer 0 and “SETB TR1″ for Timer 1.
  3. After the timer is started, it starts to count up. It counts up until it reaches its limit of FFFFH. When it rolls over from FFFFH to 0000, it sets high a flag bit called TF (timer flag). This timer flag can be monitored. When this timer flag is raised, one option would be to stop the timer with the instructions “CLR TRO” or “CLR TR1″, for Timer 0 and Timer 1, respectively. Again, it must be noted that each timer has its own timer flag: TFO for Timer 0, and TF1 for Timer 1.
  4. After the timer reaches its limit and rolls over, in order to repeat the process the registers TH

and TL must be reloaded with the original value, and TF must be reset to 0.

Steps to program in mode 1

To generate a time delay, using the timer’s mode 1, the following steps are taken. To clarify

these steps, see Example 9-4.

  1. Load the TMOD value register indicating which timer (Timer 0 or Timer 1) is

to be used and which timer mode (0 or 1) is selected.

  1. Load registers TL and TH with initial count values.
  2. Start the timer.
    1. Keep monitoring the timer flag (TF) with the “JNB TFx, target” instruc tion to see if it is raised. Get out of the loop when TF becomes high.
  3. Stop the timer.
  4. Clear the TF flag for the next round.
  5. Go back to Step 2 to load TH and TL again.

Mode0- Mode 0 is exactly same like mode 1 except that it is a 13-bit timer instead of 16-bit. The 13-

bit counter can hold values between 0000 to 1FFFH in TH-TL. Therefore, when the timer reaches its

maximum of 1FFH, it rolls over to 0000, and TF is raised.

Mode 2- It is an 8 bit timer that allows only values of 00 to FFH to be loaded into the timer’s register

TH. After TH is loaded with 8 bit value, the 8051 gives a copy of it to TL. Then the timer must be

started. It is done by the instruction “SETB TR0” for timer 0 and “SETB TR1” for timer1. This is like

mode 1. After timer is started, it starts to count up by incrementing the TL register. It counts up until it reaches its limit of FFH. When it rolls over from FFH to 00. It sets high the TF (timer flag). If we are

using timer 0, TF0 goes high; if using TF1 then TF1 is raised. When Tl register rolls from FFH to 00

and TF is set to 1, TL is reloaded automatically with the original value kept by the TH register. To

repeat the process, we must simply clear TF and let it go without any need by the programmer to reload the original value. This makes mode 2 auto reload, in contrast in mode 1 in which

programmer has to reload TH and TL.

  1. Mode 2 programming The following are the characteristics and operations of mode 2.