0% found this document useful (0 votes)
199 views54 pages

MIcrocontroller Based Embedded System E - Contents

The document discusses microcontrollers and the 8051 microcontroller architecture. It provides details on: 1) The key features of microcontrollers that make them suitable for embedded systems including being self-contained, designed for a single application, able to be optimized for low power usage, and inexpensive. 2) The main components of the 8051 microcontroller including the CPU, memory, buses, oscillator, and ports. It also describes the pin diagram and functions of the different pins. 3) Details on the program counter, data pointer, and A and B registers in the 8051 architecture.

Uploaded by

Lokesh Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
199 views54 pages

MIcrocontroller Based Embedded System E - Contents

The document discusses microcontrollers and the 8051 microcontroller architecture. It provides details on: 1) The key features of microcontrollers that make them suitable for embedded systems including being self-contained, designed for a single application, able to be optimized for low power usage, and inexpensive. 2) The main components of the 8051 microcontroller including the CPU, memory, buses, oscillator, and ports. It also describes the pin diagram and functions of the different pins. 3) Details on the program counter, data pointer, and A and B registers in the 8051 architecture.

Uploaded by

Lokesh Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

B.K.

N GOVT POLYTECHNIC NARNAUL


DEPARTMENT- INSTRUMENTATION AND CONTROL
ENGINEERING

SUBJECT: MICROCONTROLLER BASED EMBEDDED SYSTEMS

NAME OF FACULTY: Mrs. RAJNI


SEMESTER- 4th

UNIT-1
Introduction:

1. Difference between microprocessor and microcontroller.

1.2 Microcontroller for embedded system.

Embedded Systems and Microcontrollers


Microcontrollers include many features that make them suitable for application in embedded systems:
1. They are self-contained, including all of the necessary peripherals on a single
integrated circuit chip
2. They are designed to run a single dedicated application
3. They can be optimized (software and hardware) for a single dedicated application
4. They exhibit low power consumption and may include power-saving features, making
them ideal for applications that require the processor to function for long periods of
time without human interference
5. They are relatively inexpensive when compared to CPUs, mainly because the entire
system exists on a single chip
1.3 Microcontroller and their applications

Different Applications of Microcontroller

1. Consumer Electronics Products: Toys, Cameras, Robots, Washing Machine,


Microwave Ovens etc.
2. Instrumentation and Process Control: Oscilloscopes, Multi-meter, Leakage Current
Tester, Data Acquisition and Control etc.
3. Medical Instruments
4. Communication
5. Office Equipment
6. Multimedia Application
7. Automobile

1.4 Overview of the 8051 family.


B.K.N GOVT POLYTECHNIC NARNAUL

DEPARTMENT- INSTRUMENTATION AND CONTROL


ENGINEERING

SUBJECT: MICROCONTROLLER BASED EMBEDDED SYSTEMS

NAME OF FACULTY: Mrs. RAJNI


SEMESTER- 4th

UNIT-2
2. 8051 Architecture

2.1 Block Diagram and Pin Diagram of 8051 microcontroller


The 8051 Microcontroller is one of the basic type of microcontroller, designed by Intel in 1980’s.
This microcontroller was based on Harvard Architecture and developed primarily for use
in embedded systems technology.

8051 Microcontroller Architecture


CPU (Central Processing Unit): CPU act as a mind of any processing machine. It synchronizes
and manages all processes that are carried out in microcontroller. User has no power to control the
functioning of CPU. It interprets the program stored in ROM and carries out from storage and
then performs it projected duty. CPU manage the different types of registers available in 8051
microcontroller.

Interrupts: Interrupts is a sub-routine call that given by the microcontroller when some other
program with high priority is request for acquiring the system buses the n interrupts occur in current
running program.
Interrupts provide a method to postpone or delay the current process, performs a sub-routine task and
then restart the standard program again.

Types of interrupt in 8051 Microcontroller:

Let's see the five sources of interrupts in 8051 Microcontroller:

o Timer 0 overflow interrupt - TF0


o Timer 1 overflow interrupt - TF1
o External hardware interrupt - INT0
o External hardware interrupt - INT1
o Serial communication interrupt - RI/TI

Memory: For operation Micro-controller required a program. This program guides the
microcontroller to perform the specific tasks. This program installed in microcontroller required some
on chip memory for the storage of the program.

Microcontroller also required memory for storage of data and operands for the short duration. In
microcontroller 8051 there is code or program memory of 4 KB that is it has 4 KB ROM and it also
comprise of data memory (RAM) of 128 bytes.

Bus : Bus is a group of wires which uses as a communication canal or acts as means of data transfer.
The different bus configuration includes 8, 16 or more cables. Therefore, a bus can bear 8 bits, 16 bits
all together.

Types of buses in 8051 Microcontroller:

Let's see the two types of bus used in 8051 microcontroller:

o Address Bus: 8051 microcontrollers is consisting of 16 bit address bus. It is generally be


used for transferring the data from Central Processing Unit to Memory.
o Data bus: 8051 microcontroller is consisting of 8 bits data bus. It is generally be used for
transferring the data from one peripherals position to other peripherals.

Oscillator: As the microcontroller is digital circuit therefore it needs timer for their operation. To
perform timer operation inside microcontroller it required externally connected or on-chip oscillator.
Microcontroller is used inside an embedded system for managing the function of devices. Therefore,
8051 uses the two 16 bit counters and timers. For the operation of this timers and counters the
oscillator is used inside microcontroller.

2.1.2 Pin Diagram of 8051 microcontroller


The Pin Diagram of 8051 with respect to 40 pins. In 8051 Pin Diagram, you
can see that it has 4 ports P0, P1, P2, and P3 and each port has 8 pin.
Explanation of 8051 pin diagram

Pins 1 – 8:

Port1 uses the Pins 1 to 8. Each pin is bidirectional Input /Output with internal pull – up resistors.

Pin 9:

It is a reset input Pin which used to reset the 8051 microcontrollers. It is an active HIGH Pin i.e. if we
apply a high pulse to this pin, the microcontroller will reset and terminate all activities.

Note: All value of the register will be lost after activating a power-on reset.

Pins 10-17:

Port3 uses the Pins 10 to 17. Each pin is bidirectional Input /Output with internal pull – up resistors.
Besides the Input /Output, each pin has some special functionality. In the below table, I have
described the other functionality of Port-3.

PORT 3 Bit and Pin Function Description

P3.0 (10) RXD Serial Input


P3.1 (11) TXD Serial Output

P3.2 (12) INT0 External Interrupt 0

P3.3 (13) INT1 External Interrupt 1

P3.4 (14) T0 Timer 0

P3.5 (15) T1 Timer 1

P3.6 (16) WR External Memory Write

P3.7 (17) RD External Memory Read

Pins 18 & 19:

Pin 18 and 19 are used for interfacing an external crystal oscillator to get the system clock. We should
use the ceramic capacitor with an external crystal oscillator.

Pin 20 (GND):

Pin 20 is the Ground Pin of the 8051 Microcontroller.

Pins 21 -28:

Port2 uses the Pins 21 to 28. Each pin is bidirectional Input /Output with internal pull – up resistors.
Besides the Input /Output, when external memory is interfaced, PORT 2 pins act as the higher-order
address byte.

Pin 29 (PSEN):

Pin 29 is the Program Store Enable Pin (PSEN). It is an output pin and using this pin, external
Program Memory can be read.

Pin 30 (ALE/PROG):

Pin 30 is the Address Latch Enable Pin. It is an output pin and using this Pin, external address can be
separated from data (as they are multiplexed by 8051).
Pin 31 (EA/VPP):

Pin 31 is the External Access Enable Pin i.e. allows external Program Memory. It is an input pin and
must be connected from VCC or GND. If you want to access the code from external program
memory, it must be connected with GND. If you want to use on-chip memory, it must be high
(connected with VCC).

Pins 32–39:

Port0 uses the Pins 32 to 39. Each pin is bidirectional Input /Output but without internal pull – up
resistors. So we need to use an external pull-up before using Port0 as Input /Output.

Pin 40 (VCC):

Pin 40 is the power supply pin of the 8051 Microcontroller. It should be +5V.

2.2 The 8051 Oscillator & clock

8051 illator and Clock The oscillator is formed by the crystal, capacitors and an on-chip
inverter. Circuitry that generates the clock pulses by which all internal operations
are synchronized. Frequency- 1mHz to 16 mHz Minimum frequencies imply that
some internal memories are dynamic and must always operate above a minimum
frequency or data will be lost. The time to execute an instruction is found by •
Tinst = ( C x 12d ) / Crystal Frequency • Where C – number of machine cycle.

2.3 Program Counter and Data Pointer

PC does not have an internal address. Program instruction bytes are fetched from
locations in memory that are addressed by the PC. DPTR register is made up of two 8
bit registers, named DPH and DPL, which are used to furnish memory addresses for
internal and external code access and external data access. DPTR does not have a single
internal address; DPH and DPL are each assigned an address.

Data pointer in the 8051 microcontrollers is one of the storage registers. Other storage
registers in an 8051 microcontroller are the accumulator, the stack pointer (SP), R register, B
register and the program counter (PC). The Data Pointer in 8051 microcontrollers in short form
DPTR is the only 2-byte register a user can access. Other registers like the B register and
accumulator are 1-byte register. This data pointer just like the name implies is for data pointing.
With it, the 8051 can access memory outside the system.
2.4 A & B CPU registers.
A and B CPU register 8051 contains 34 general purpose or working registers. Two of these
registers A and B, hold results of many instructions, particularly math and logical operations,
of the CPU. Other 32 register are arranged as part of internal RAM in four banks.  ‘A’
register:
• Is most versatile of the two registers.
• It is used for many operations (arithmetical, logical and bit manipulations).
• Used for all data transfers between the 8051 and any external memory.  ‘B’ register:
• Used with A register for multiplication and division operations
• No other function other than as a location where data may be stored.

2.5 Flag and the program status word (PSW)


The program status word (PSW) register is an 8-bit register, it is also referred to as the flag
register the PSW register is 8-bit wide only 6-bit of it are used by the 8051, the two unused bits
are user definable flags, four of the flags are called conditional flags, meaning that they indicate
some conditions that results after an instruction is executed, these four are CY(carry),
AC(auxiliary carry), P(parity) and OV(overflow) the bits PSW.3 and PSW.4 are designated as
RS0 and RS1 register selection bit and are used to change the bank register.

CY (carry flag):

 This flag is set whenever there is a carry out from the D.7 bit
 This flag bit is affected after 8 bit addition or subtraction
 It can also be set to 1 or 0 directly by an instruction such as " SET BC" and "CLRC"

AC(Auxiliary flag):

 If there is a carry from D3 to D4 during ADD or SUB operation this bit is set otherwise it is
cleared
 This flag is used by instruction that perform BCD (binary coded decimal) arithmetic

P (parity flag):

 The parity flag reflect the number of 1's in the A (accumulator) register only
 if the A register contains an odd number of 1's then p=1 therefore p=0 if A has an even
number 1's.

OV (overflow flag):

 This flag is set whenever the result of a signed number operation is too large causing the high
order bit to overflow into the sign bit
 the carry flag is used to detect error in unsigned arithmetic operations
 the overflow flag is only used to detect error in signed arithmetic operations.

2.5 Internal Memory

1. Internal ROM
2. Internal RAM

128 Byte RAM There are 128 bytes of RAM in the 8051.

• Assigned addresses 00 to 7FH The 128 bytes are divided into 3 different groups as follows:
1. A total of 32 bytes from locations 00 to 1F hex are set aside for register banks.
2. A total of 16 bytes from locations 20H to 2FH are set aside for bit-addressable read/write
memory.
3. A total of 80 bytes from locations 30H to 7FH are used for read and write storage, called
scratch pad.

2.6 The stack and stack pointer.


2.7.1 The stack

8051 Stack and Stack pointer The stack is a section of RAM used by the CPU to store
information temporarily.
• This information could be data or an address . The register used to access the stack is called
the SP (stack pointer) register.
• The stack pointer in the 8051 is only 8 bit wide, which means that it can take value of 00 to
FFH.
• When the 8051 is powered up (i.e.,) reset, the SP register contains value 07
• RAM location 08 is the first location begin used for the stack by the 8051.

2.6.2 Stack pointer


The storing of a CPU register in the stack is called a PUSH
• SP is pointing to the last used location of the stack.

• As we push data onto the stack, the SP is incremented by one

• This is different from many microprocessors Loading the contents of the stack back into a
CPU register is called a POP
• With every pop, the top byte of the stack is copied to the register specified by the instruction
and the stack pointer is decremented once.
2.7 Input/output ports.
8051 microcontrollers have 4 I/O ports each of 8-bit, which can be configured as input or output.
Hence, total 32 input/output pins allow the microcontroller to be connected with the peripheral
devices.
 Pin configuration, i.e. the pin can be configured as 1 for input and 0 for output as per the
logic state.
o Input/Output (I/O) pin − All the circuits within the microcontroller must be
connected to one of its pins except P0 port because it does not have pull-up resistors
built-in.
o Input pin − Logic 1 is applied to a bit of the P register. The output FE transistor is
turned off and the other pin remains connected to the power supply voltage over a
pull-up resistor of high resistance.
PORT 0:

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

Port-0 can be used as a normal bidirectional I/O port or it can be used for address/data interfacing for
accessing external memory. When control is ‘1’, the port is used for address/data interfacing. When
the control is ‘0’, the port can be used as a bidirectional I/O port.
PORT 1:
The structure of a port-1 pin is shown in fig below.It has 8 pins (P1.1-P1.7) .
P1 is a true I/O port as it doesn’t have any alternative functions as in P0, but this port can be
configured as general I/O only. It has a built-in pull-up resistor and is completely compatible with
TTL circuits.
PORT 2:

The structure of a port-2 pin is shown in fig. below. It has 8-pins (P2.0-P2.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 is multifunction part it can be used as a simple input/output port.


Port 3 as simple input port:

When port 3 is used as an input port ‘1’ must be written to the corresponding port 3 latch bit this
cause the FET to turn off pin & input to pin buffer are pulled to logic high by internal pull up load.

2.8 Counters and timers


A timer is a specialized type of clock which is used to measure time intervals. A
timer that counts from zero upwards for measuring time elapsed is often called
a stopwatch. It is a device that counts down from a specified time interval and
used to generate a time delay, for example, an hourglass is a timer.
A counter is a device that stores (and sometimes displays) the number of times
a particular event or process occurred, with respect to a clock signal. It is used
to count the events happening outside the microcontroller. In electronics,
counters can be implemented quite easily using register-type circuits such as a
flip-flop.

Difference between a Timer and a Counter


The points that differentiate a timer from a counter are as follows −

Timer Counter

The register incremented for every The register is incremented considering 1 to 0 transition at
machine cycle. its corresponding to an external input pin (T0, T1).
Maximum count rate is 1/12 of the Maximum count rate is 1/24 of the oscillator frequency.
oscillator frequency.

A timer uses the frequency of the A counter uses an external signal to count pulses.
internal clock, and generates delay.

2.10 Serial Data input/output.

Computers must be able to communicate with other computers in modern multiprocessor distributed
systems. One cost-effective way to communicate is to send and receive data bits serially. The 8051
has a serial data communication circuit that uses register SBUF to hold data. Register SCON controls
data communication, register PCON controls data rates, and pins RXD (P3.0) and TXD (P3.1)
connect to the serial data network.

SBUf is physically two registers. One is write only and is used to hold data to be transmitted out of
the 8051 via TXD. The other is read only and holds received data from external sources via RXD.
Both mutually exclusive registers use address 99h.

There are four programmable modes for serial data communication that are chosen by setting the
SMX bits in SCON. Baud rates are determined by the mode chosen.

2.11 Interrupts

Interrupts are of different types like software and hardware, maskable and non-maskable, fixed and
vector interrupts, and so on.

Interrupt Structure of 8051

Types of Interrupts in 8051 Microcontroller

The 8051 microcontroller can recognize five different events that cause the main program to interrupt
from the normal execution. These five sources of interrupts in 8051are:

1. Timer 0 overflow interrupt- TF0


2. Timer 1 overflow interrupt- TF1
3. External hardware interrupt- INT0
4. External hardware interrupt- INT1
5. Serial communication interrupt- RI/TI

Interrupt Enable (IE) Register: This register is responsible for enabling and disabling the interrupt.
It is a bit addressable register in which EA must be set to one for enabling interrupts. The
corresponding bit in this register enables particular interrupt like timer, external and serial inputs. In
the below IE register, bit corresponding to 1 activates the interrupt and 0 disables the interrupt.
Interrupt Priority Register (IP): It is also possible to change the priority levels of the interrupts by
setting or clearing the corresponding bit in the Interrupt priority (IP) register as shown in the figure.
This allows the low priority interrupt to interrupt the high-priority interrupt, but prohibits the
interruption by another low-priority interrupt. Similarly, the high-priority interrupt cannot be
interrupted. If these interrupt priorities are not programmed, the microcontroller executes in
predefined manner and its order is INT0, TF0, INT1, TF1, and SI.
TCON Register: In addition to the above two registers, the TCON register specifies the type of
external interrupt to the 8051 microcontroller, as shown in the figure. The two external interrupts,
whether edge or level triggered, specify by this register by a set, or cleared by appropriate bits in it.
And, it is also a bit addressable register.
B.K.N GOVT POLYTECHNIC NARNAUL
DEPARTMENT- INSTRUMENTATION AND CONTROL
ENGINEERING

SUBJECT: MICROCONTROLLER BASED EMBEDDED SYSTEMS

NAME OF FACULTY: Mrs. RAJNI


SEMESTER- 4th

Unit-3
Addressing Modes & Instructions:
3.1 Instructions set of 8051
The instructions of 8051 Microcontroller can be classified into five different groups. These groups are
like below
 Data Transfer Group
 Arithmetic Group
 Logical Group
 Program Branch Group
 Bit Processing Group
This Bit-Processing group is also known as Boolean Variable Manipulation.
Like 8085, some instruction has two operands. The first operand is the Destination, and the second
operator is Source.
3.2 Arithmetic instructions

Arithmetic Instructions are the instructions which perform basic arithmetic operations such as
addition, subtraction and a few more.

The Arithmetic Instructions in 8051 of Basic Assembly Language Programming are

ADD, ADDC, SUBB and DA

The ADD instruction adds a byte variable with the accumulator, leaving the result in the accumulator:
The carry flag is set if there is an overflow from bit 7 and cleared otherwise. The AC flag is set to the
carry-out from bit 3 for use by the DA instruction described later. ADDC adds the previous contents
of the carry flag with the two byte variables, but otherwise is the same as ADD:

The SUBB (subtract with borrow) instruction subtracts the byte variable indicated and. the contents of
the carry flag together from the accumulator, and puts the result back in the accumulator. The carry
flag serves as a “Borrow required” flag during subtraction operations when a greater value is
subtracted from a lesser value (as in subtracting 5 from 1) requiring a borrow into the highest order
bit, the carry flag is set; otherwise it is cleared.

Multiplication and Division:


The instruction “MUL AB” multiplies the unsigned eight-bit integer values held in the accumulator
and B-register. The low-order byte of the sixteen-bit product is left in the accumulator, the higher-
order byte in B. If the high-order eight-bits of the product are all zero, the overflow flag is cleared;
otherwise it is set. The programmer can check OV to determine when the B register is non-zero and
must be processed.

DIV AB” divides the unsigned eight-bit integer in the accumulator by the unsigned eight-bit integer in
the B-register. The integer part of the quotient is returned in the accumulator, the remainder in the B
register. If the B-register originally contains OOH then the overflow flag will be set to indicate a
division error, and the values returned will be undefined. Otherwise OV is cleared.

The divide instruction is also useful for purposes such as radix conversion or separating bit fields of
the accumulator. A short subroutine can convert an eight-bit unsigned binary integer in the
accumulator (between 0 and 255) to a three-digit (two byte) BCD representation. The hundred’s digit
is returned in one register (HUND) and the ten’s and one’s digits returned as packed BCD in another
(TENONE).

3.3 Loops and jump instructions.

Jump Instructions – The jump instruction transfers the program sequence to the memory address
given in the operand based on the specified flag. Jump instructions are 2 types: Unconditional Jump
Instructions and Conditional Jump Instructions.

Other conditional jumps • JC Jump if carry, jumps if CY = 1) • if CY = l it jumps to the target


address • JB (jump if bit is high) • JNB (jump if bit is low)

Other conditional jumps • JZ (jump if A = 0) • In this instruction the content of register A is


checked. If it is zero, it jumps to the target address. • JZ instruction can be used only for register A.
• It can only check to see whether the accumulator is zero, and it does not apply to any other
register. • Don't have to perform an arithmetic instruction such as decrement to use the JZ
instruction.
• In this instruction the content of register A is checked. If it is not zero, it jumps to the target
address.• JNZ (jump if A
• JNC Jump if no carry, jumps if CY = 0) • carry flag bit in the flag (PSW) register is used to
make the decision whether to jump • "JNC label", the processor looks at the carry flag to
see if it is raised (CY = 1). • if it is not, the CPU starts to fetch and execute instructions
from the address of the label. • if CY = 1, it will not jump but will execute the next
instruction below JNC.

Unconditional jump instructions • There are two unconditional jumps:


LJMP (long jump) and SJMP (short jump).
• LJMP is 3-byte instruction in which the first byte is the op-code, and the second and third bytes
represent the 16-bit address of the target location.
• The 2-byte target address allows a jump to any memory location from 0000 to FFFFH.
Unconditional jump instructions • SJMP (short jump)
• 2-byte instruction, the first byte is the op-code and the second byte is the relative address of the
target location. • The relative address range of 00 – FFH is divided into forward and backward
jumps; that is, within -128 to +127 bytes of memory relative to the address of the current PC
(program counter).
• If the jump is forward, the target address can be within a space of 127 bytes from the current PC
• If the target address is backward, the target address can be within -128 bytes from the current PC.
3.4 Call instructions.

The CALL instruction interrupts the flow of a program by passing control to an internal or external
subroutine. An internal subroutine is part of the calling program. An external subroutine is another
program.

CALL is used to call a subroutine. • Subroutines are often used to perform tasks that need to be
performed frequently. • This makes a program more structured in addition to saving memory
space. • There are two instructions:
 LCALL (long call) and ACALL (absolute call).
 Deciding which one to use depends on the target address.
 LCALL (long call) • 3-byte instruction, the first byte is the op-code and the second and
third bytes are used for the address of the target subroutine
 LCALL can be used to call subroutines located anywhere within the 64K-byte address
space of the 8051
To make sure that after execution of the called subroutine the 8051 knows where to come back to,
the processor automatically saves on the stack the address of the instruction immediately below the
LCALL.
• When a subroutine is called, control is transferred to that subroutine, and the processor
saves the PC (program counter) on the stack and begins to fetch instructions from the new
location.
• After finishing execution of the subroutine, the instruction RET (return) transfers control
back to the caller. Every subroutine needs RET as the last instruction.
3.4.1 Differences between CALL and JUMP instructions.

JUMP Instruction CALL instruction

By using JUMP, the program control transfers to a By using CALL instruction, the program control
location which is also a part of the main program transfers to a location which is not a part of main
program.

Here the addressing mode is Immediate Here the addressing mode is Immediate and Register
Indirect.

We do not need to initialize the Stack Pointer (SP) We have to initialize the Stack Pointer (SP) before
to perform the JUMP instruction. using some CALL instruction.

The program counter value is not Pushed into The value of program counter is pushed into stack
Stack before going to the pointed location.

No return instruction is needed after JUMP After CALL, it enters into a subroutine, to come back
instruction. from subroutine we need return instruction.
JUMP Instruction CALL instruction

The value of stack pointer remain unchanged The value of Stack Pointer is decremented by 2.

10 T-States are required to perform JUMP 18 T-States are required to perform CALL instruction.
instruction

3 Machine cycles are needed for JUMP 5 Machine cycles are needed for CALL.

3.5 Push and Pop Instructions

Instructions that store and retrieve an item on a stack. Push enters an item on the stack,
and pop retrieves an item, moving the rest of the items in the stack up one level.
3.6 Addressing modes of 8051

8051 There are six types of addressing modes.


 Immediate Addressing Mode
 Register Addressing Mode
 Direct Addressing Mode
 Register Indirect Addressing Mode
 Indexed Addressing Mode
 Implied Addressing Mode
Immediate addressing mode
In this Immediate Addressing Mode, the data is provided in the instruction itself. The data is provided
immediately after the opcode. These are some examples of Immediate Addressing Mode.

MOVA, #0AFH;

MOVR3, #45H;

MOVDPTR, #FE00H;

In these instructions, the # symbol is used for immediate data. In the last instruction, there is DPTR.
The DPTR stands for Data Pointer. Using this, it points the external data memory location. In the first
instruction, the immediate data is AFH, but one 0 is added at the beginning. So when the data is
starting with A to F, the data should be preceded by 0.
Register addressing mode
In the register addressing mode the source or destination data should be present in a register (R0 to
R7). These are some examples of RegisterAddressing Mode.

MOVA, R5;

MOVR2, #45H;

MOVR0, A;

In 8051, there is no instruction like MOVR5, R7. But we can get the same result by using this
instruction MOV R5, 07H, or by using MOV 05H, R7. But this two instruction will work when the
selected register bank is RB0. To use another register bank and to get the same effect, we have to add
the starting address of that register bank with the register number. For an example, if the RB2 is
selected, and we want to access R5, then the address will be (10H + 05H = 15H), so the instruction
will look like this MOV 15H, R7. Here 10H is the starting address of Register Bank 2.
Direct Addressing Mode
In the Direct Addressing Mode, the source or destination address is specified by using 8-bit data in the
instruction. Only the internal data memory can be used in this mode. Here some of the examples of
direct Addressing Mode.

MOV80H, R6;

MOVR2, 45H;

MOVR0, 05H;
The first instruction will send the content of registerR6 to port P0 (Address of Port 0 is 80H). The
second one is forgetting content from 45H to R2. The third one is used to get data from Register R5
(When register bank RB0 is selected) to register R5.

Register indirect addressing Mode


In this mode, the source or destination address is given in the register. By using register indirect
addressing mode, the internal or external addresses can be accessed. The R0 and R1 are used for 8-bit
addresses, and DPTR is used for 16-bit addresses, no other registers can be used for addressing
purposes. Let us see some examples of this mode.

MOV0E5H, @R0;

MOV@R1, 80H

In the instructions, the @ symbol is used for register indirect addressing. In the first instruction, it is
showing that theR0 register is used. If the content of R0 is 40H, then that instruction will take the data
which is located at location 40H of the internal RAM. In the second one, if the content of R1 is 30H,
then it indicates that the content of port P0 will be stored at location 30H in the internal RAM.

MOVXA, @R1;

MOV@DPTR, A;

In these two instructions, the X in MOVX indicates the external data memory. The external data
memory can only be accessed in register indirect mode. In the first instruction if the R0 is holding
40H, then A will get the content of external RAM location40H. And in the second one, the content of
A is overwritten in the location pointed by DPTR.
Indexed addressing mode
In the indexed addressing mode, the source memory can only be accessed from program memory
only. The destination operand is always the register A. These are some examples of Indexed
addressing mode.

MOVCA, @A+PC;

MOVCA, @A+DPTR;
The C in MOVC instruction refers to code byte. For the first instruction, let us consider A holds 30H.
And the PC value is1125H. The contents of program memory location 1155H (30H + 1125H) are
moved to register A.

Implied Addressing Mode


In the implied addressing mode, there will be a single operand. These types of instruction can work on
specific registers only. These types of instructions are also known as register specific instruction. Here
are some examples of Implied Addressing Mode.
B.K.N GOVT POLYTECHNIC NARNAUL
DEPARTMENT- INSTRUMENTATION AND CONTROL ENGINEERING
SUBJECT: MICROCONTROLLER BASED EMBEDDED SYSTEMS
NAME OF FACULTY: Mrs. RAJNI
SEMESTER- 4th

UNIT 4

INTRODUCTION TO EMBEDDED SYSTEM

DEFINITATION :- An embedded system is a combination of computer hardware and software, either


fixed in capability or programmable, designed for a specific function or functions within a larger system.
Any programme

PROCESSOR EMBEDDED INTO A SYSTEM :- An embedded processor is a type of microprocessor


designed into a system to control electrical and mechanical functions . Embedded processors are
usually simple in design, limited in computational power and I/O capabilities, and have minimal power
requirements.
Real-Time Operating System (RTOS)
When we hear the word operating system, first in our mind comes that the operating system used
in the laptops & computers. Generally, we use different types of operating systems like windows
XP, Linux, Ubuntu, Windows 7,8.8.1, and 10. In the smart phones, the operating systems are like
KitKat, Jellybean, marshmallow, and Nougat. In a digital electronic device, there is some sort of
operating system which is developed by the microcontroller program. There are different types
of operating systems to develop for the microcontroller, but here we have discussed the real-
time operating system.

What is a Real Time Operating System?


The RTOS is an operating system, it is a brain of the real-time system and its response to inputs
immediately. In the RTOS, the task will be completed by the specified time and its responses in a
predictable way to unpredictable events

The structure of the RTOS is shown below.


Types of RTOS
There are three different types of RTOS which are following

 Soft real-time operating system


 Hard real-time operating system
 Firm real-time operating system

Types of RTOS

1. Soft Real-Time Operating System

The soft real-time operating system has certain deadlines, may be missed and they will take the
action at a time t=0+. The soft real-time operating system is a type of OS and it does not contain
constrained to extreme rules. The critical time of this operating system is delayed to some extent.
The examples of this operating system are the digital camera, mobile phones and online data etc.

2. Hard Real-Time Operating System

This is also a type of OS and it is predicted by a deadline. The predicted deadlines will react at a
time t = 0. Some examples of this operating system are air bag control in cars, anti-lock brake,
and engine control system etc.

3. Firm Real-Time Operating System

In the firm real-time, an operating system has certain time constraints, they are not strict and it
may cause undesired effects. Examples of this operating system are a visual inspection in
industrial automation.
Embedded operating system:- An embedded operating system (OS) is a specialized
operating system designed to perform a specific task for a device that is not a computer. An embedded
operating system's main job is to run the code that allows the device to do its job.

The most common examples of embedded operating system Symbian (cell phones) and Linux.

Types of Embedded Operating Systems


 Single System Control Loop
 Multi-Tasking Operating System
 Rate Monotonic Operating System
 Preemptive Operating System
 Real-Time Operating System

1. Single System Control Loop

This is the very basic type of operating system that performs only a single function at a time.
This is still not clear that such a simple operating system could be an embedded operating
system. Because generally operating systems perform multiple tasks to manage the system
resource.

2. Multi-Tasking Operating System

This type of operating system can perform multiple tasks at a time. The multiple tasks can run
simultaneously. The operating system can keep track of each task and can switch between it
without losing the information.

In multitasking actually, the overall time of a problem is divided into small tasks. Each divided
subtask gets the CPU time based on a fixed interval.

Only current executing process get the entire CPU time. The remaining task executing in a
virtual environment. Where they get a register, program counter(PC), stack memory and a stack
pointer. The task is executing in a virtual environment. This all goes in runtime. When a higher
priority task is coming to the currently executing task is saved into memory.

3. Rate Monotonic Operating System

In this type of operating system, a rate monotonic priority algorithm is used in real-time
operating systems(RTOS). It is a priority-based scheduling algorithm. In this operating system,
the scheduling is preemptive. Means the task gets interrupted or suspended by another task with
a short period.

The execution time of the task is set in such a way that all task gets an equal amount of execution
time or at least the task get the chance to execute when it is expected to run. This type of
operating system always gives the shorter task a higher priority.
4. Preemptive Operating System

In this type of operating system, the currently executing task may be interrupted by the other
higher priority task and can be resumed later.

The system has a scheduler that receives the interrupt that is received from the external calls.
Once the interrupt is received scheduler pause the running task and start the higher priority task.
The control of the CPU passes from one task to another. This is called preemption.

The main concept here is to manage the higher priority task that is more important and critical.

Embedded hardware units and devices in a system

1. Embedded Systems Hardware Components


As we know embedded systems are the combination of hardware and software. There are
different hardware components like power supply, processor, memory, timers and counters that
make the embedded hardware.

Power Supply

The power supply is an essential part of any embedded systems circuits. An embedded system
may need a supply of 5 volts or if it is low power then maybe 3.3 or 1.8v. The supply may be
provided with the help of battery or we can use any wall adapter. It will depend on the
application need.

The power supply circuit can be designed with the help some little knowledge of electronics. For
that, we need a bridge rectifier circuit, capacitor as a filter and a voltage regulator that provides
constant output supply.

Characteristics of Good Power Supply

 Stable & Smooth Output


 Proper Output Current to Drive the Load
 Perfect Power Efficiency
 Stable in Different Temperature Range
 Proper Noise Filtering
 Proper Decoupling
 Line Regulation – Fluctuation in output while input changes
 Load Regulation – Fluctuation in output voltage when load current changes
 Efficiency
 Input/Output Ripple Voltage
 Transient Response
 Allowable Dissipation

Processor

A processor is the main brain inside any embedded systems. This is a major factor that affects
the performance of the system. There are different processors available in the market. An
embedded system may use microprocessor or microcontroller.

The processor comes in different architecture like 8-bit, 16-bit and 32-bit. The 8-bit processor is
generally used in a small application where we need some basic computation like input and
output no heavy processing.

For higher-end application where performance matters and need some graphical user interface,
we use 16 or 32-bit processor.

What are the criteria for selecting the processor?

 Speed
 Unit Price
 Packaging
 Performance
 Peripheral Set
 Timer on the Chip
 Operating Voltage
 Number of I/O Pins
 Power Consumption
 Amount of RAM and ROM
 Specialized Processing Units
 Architecture 8-bit, 16-bit, or 32-bit
 Availability of Supplier for a given core
 Easy to upgrade to higher or lower power consumption mode
 Availability of Software tools like assembler, debugger, compiler, emulator and technical
support

Memory

If we are using a microcontroller like AT89s51, AT89s52 or ATmega. The memory is available
on-chip. We generally talk about two types of memory in the embedded systems

 Read-Only memory(RAM)
 Random Access Memory(ROM)
 Electrically Erasable Programmable Read-Only Memory (EEPROM)
RAM memory is volatile memory and used for temporary storage of the data. And the selection
of it depends on the user need and the application.

The ROM memory or Code Memory. This is used for the storage of the program. Once system
powered, the system fetches the code from the ROM memory.

The EEPROM is a unique memory. The content can be erased and reprogrammed by a high
voltage pulse input. This is used to store the data by the program itself. Suppose we have a
temperature data logger. And it needs to store the data every one hour. It means we need the data
at runtime after the system is started.

The system will read temperature and store in the EEPROM memory. And it will be permanent.
And you can retrieve the data later.

So an embedded system developer decide which memory to use for its application.

Timers-Counters

If you are working in embedded systems you must have heard about

 What are timer and counter


 Why we use timer and counter
 What is difference between timers and counter

In some application, we need to generate some delay. Like for blinking an LED, we need a
delay. For making square pulse we need a delay.

But there is some issue when we generate the delay from the normal coding style by making any
loop running for a particular time. Definitely, this will give you some delay but the code after
this loop remains in waiting for state and delayed.

So it is not the best approach to generate the delay. For such kind of application where we need a
delay for a specific time interval without affecting the normal code execution, we use timer and
counter.

By setting some register for timer and counter using the programming we get the desired delay.
The amount of delay depends on the system frequency and crystal oscillator.

Communication Ports

Embedded systems hardware has different types of communication ports to communicate with
the other embedded devices.

Different communication ports in embedded systems

 UART
 CAN
 SPI
 I2C
 USB
 Ethernet
 RS-232
 RS-423
 RS-485

But for a small level of embedded systems microcontroller has on-chip communication ports.

For example, popular Arduino UNO board has ATmega328 IC and it has following
communication port:

 UART
 I2C
 SPI

For sending data from one board to other we can use these serial protocols. But for that, we need
to program it.

Input and Output

To interact with the embedded systems we need input. The input may be provided by the user or
by some sensor. Sometimes some systems need more input or output. So the processor selection
will be based on I/O.

These input and output are generally divided into ports like P0, P1, P2 and P3 in
8051microcontrollersr. And PA, PB, PC and PD in ATmega series of the microcontroller.

The I/O need to be configured for input or output based on the provided register. And for that,
we need to refer the datasheet of the manufacturer.

Application Specific Circuits

Some hardware components are common while designing the embedded systems. But some are
different and depends on the application need. Like a temperature sensor need a temperature
sensor for sensing the temperature. While others hand an alcohol detector has a sensor to detect
the alcohol level.

But the remaining hardware components might be the same like

 Power Supply
 Processor
 Display Device
 Buzzer for Alert
2.Software Components
Once the hardware is completed we need to build the software for the embedded devices. There
are different software tools for programming and coding. These software tools are referred to as
software components.

How is software embedded into a system?

We need a program written in assembly or in embedded c language. And then we compile it.
This compiled code converted into HEX code. This hex code is programmed or burned into the
ROM of the system using some programmer.

These are the tools that are generally used in embedded system development

 Assembler
 Emulator
 Debugger
 Compiler

Assembler

When you program in assembly language. This assembly language program is converted into the
HEX code using this utility. Then using some hardware called as a programmer we write the
chip.

Emulator

An emulator is hardware or software tool that has a similar functionality to the target system or
guest system. It enables the host system to execute the functionality and other components. It is a
replica of the target system. And used for debugging the code and issues.

Once program or code is fixed at the host system. It is transferred to the target system.

Debugger

Sometimes we are not getting expected results or output due to errors or bug. There are certain
tools that are specifically used for the debugging process. Where we can see the controls flow
and register value to identify the issue.

Compiler

A compiler is a software tool that converts one programming language into target code that a
machine can understand. The compiler basically used for translating the high-level language into
the low-level language like machine code, assembly language or object code.
Examples of embedded system
Some examples of embedded systems are MP3 players, mobile phones, video game consoles,
digital cameras, DVD players, and GPS. Household appliances, such as microwave ovens, washing
machines and dishwashers, include embedded systems toprovide flexibility and efficiency.

Present trends in embedded system


1. Improved Security for Embedded Devices

With the rise of the Internet of Things (IoT), the primary focus of developers and manufacturers
is on security. In 2019, advanced technologies for embedded security will emerge as key
generators for identifying devices in an IoT network, and as microcontroller security solutions
that isolate security operations from normal operations.

2. Cloud Connectivity and Mesh Networking

Getting embedded industrial systems connected to the internet and cloud can take weeks and
months in the traditional development cycle. Consequently, cloud connectivity tools will be an
important future market for embedded systems. These tools are designed to simplify the process
of connecting embedded systems with cloud-based services by reducing the underlying hardware
complexities.

A similar yet innovative market for low-energy IoT device developers is Bluetooth mesh
networks. These solutions can be used for seamless connectivity of nearby devices while
reducing energy consumption and costs.

3. Reduced Energy Consumption

A key challenge for developers is the optimization of battery-powered devices for low power
consumption and maximum uptime. Several solutions are under development for monitoring and
reducing the energy consumption of embedded devices that we can expect to see in 2019. These
include energy monitors and visualizations that can help developers fine-tune their embedded
systems, and advanced Bluetooth and Wi-Fi modules that consume less power at the hardware
layer.

4. Visualization Tools with Real Time Data

Developers currently lack tools for monitoring and visualizing their embedded industrial systems
in real time. The industry is working on real-time visualization tools that will give software
engineers the ability to review embedded software execution. These tools will enable developers
to keep a check on key metrics such as raw or processed sensor data and event-based context
switches for tracking the performance of embedded systems.
5. Deep Learning Applications

Deep learning represents a rich, yet unexplored embedded systems market that has a range of
applications from image processing to audio analysis. Even though developers are primarily
focused on security and cloud connectivity right now, deep learning and artificial intelligence
concepts will soon emerge as a trend in embedded systems.

Design parameters of an embedded system and its


importance

What is an Embedded System Design?


Definition: A system designed with the embedding of hardware and software together for a
specific function with a larger area is embedded system design. In embedded system design, a
microcontroller plays a vital role. Micro-controller is based on Harvard architecture, it is an
important component of an embedded system. External processor, internal memory and i/o
components are interfaced with the microcontroller. It occupies less area, less power consumption.
The application of microcontrollers is MP3, washing machines.

Application of embedded system


Embedded systems find numerous applications in various fields such as digital electronics,
telecommunications, computing network, smart cards, satellite systems, military defense system
equipment, research system equipment, and so on. Let us discuss a few practical applications of
embedded systems that are used in designing embedded projects as a part of engineering final year
electronics projects.
B.K.N GOVT POLYTECHNIC NARNAUL
DEPARTMENT- INSTRUMENTATION AND CONTROL ENGINEERING
SUBJECT: MICROCONTROLLER BASED EMBEDDED SYSTEMS
NAME OF FACULTY: Mrs. RAJNI
SEMESTER- 4th
UNIT 5

5.1 Only brief general architecture of AVR, PIC and ARM microcontroller

AVR is a family of microcontrollers developed since 1996 by Atmel, acquired by Microchip Technology in 2016.
Automatic Voltage Regulator (AVR) is a device used in the electrical power field to obtain the stability and good
regulation of the electric system.

Basic of AVR

AVR MCUs are extremely popular MCUs used in various application specially in project prototyping and
embedded devices. AVR is a 8-bit RISC architecture (Reduced Instruction Set Computing) microcontroller in
market since 1996 which is having on-chip programmable flash memory, SRAM, IO data space & EEPROM.
AVR is the first MCU in market which has on-chip flash storage.
According to the datasheet, the block diagram of its architecture is this (look below) :
Data BUS 8 bit : Its an 8-bit parallel data lines by which the data travels inside the MCU (NOTE: this is the reason
why AVR is an 8-bit MCU).
ALU: Arithmetic Logic Unit, the core/heart of the entire system where typically all commands get
executed.
Data SRAM: It basically pretty similar to the RAM (Random access memory) we see inside our
computers.
EEPROM: (Electrically Erasable Programmable Read Only Memory) its very similar to another
component in our computer namely HardDisk, i.e. a permanent storage.
I/O lines: These are the bunch of registers which is used as a switches or controls for different features of AVR.
32X8 GPR (General Purpose Registers): This are 32 registers each having 8-bit which is a general storage space for
data. But, remember, SRAM is also a temporary storage but these registers have
some specialty among all.
Status & Control : A couple of registers which are very special to the MCU & to us also.
Program Counter: This is a register which has a responsibility to track the position of the program that is currently
executing.
Flash Memory: It is also a permanent storage but its only for storing the program we write to it.
Instruction Register & Decoder: These are import for the MCU .

Flash memory:

The last digits of the name of the MCU (32 in case of Atmega32A) signifies the amount of flash memory it
contains (in K Bytes). So, Atmega32A has 32 KB flash memory (more than enough for a standard application
program).
This memory is organized in a different manner. As it can be seen from the image below that the 32K X 8B (32768
Bytes) flash is organized in 16K X 16B (32768 Bytes). So the flash memory is having 16 bits (2 bytes) as the
smallest unit, which can be addressed via 0 through 16383. In this context, I would like to introduce you to the
Program Counter also. Because of the highest address of the flash memory is 16383 (11111111111111 in binary), a
PC (which stores address of the currently executing location of the flash) of 14 bits is sufficient. To be a bit more
clear, an address 'X' of the flash memory denotes 2 bytes of data, where 'X' ranges from 0 to 16383 (Remember,
these numbers are often written in HEX format,
i.e. 0x3FFF/ $3FFF. A dollar sign in front of the HEX number is a convention followed by Atmel
assembler to denote memory address while coding in low level assembly language).
Btw, the entire flash memory is logically divided into 2 sections namely "Boot loader" section &
"Application" section.
GPRs, I/O Space & SRAM memory space:

These memories are organized in another manner than the flash. These memories are different in nature but
having a continuous space (logically) inside the MCU. Let's look at the diagram first.

GPRs (General Purpose Registers) are 32 in number each of them being an 8-bit storage, take address from
$0000 upto $001F. These are general purpose storage for data. We often use these registers for storing
variables and other data while programming the MCU. These registers have special names as R0 upto R31
(Look at the diagram above for more clarification). Now one thing
to mention that the last 6 register in this series of registers (R26 upto R31) have special names XL, XH, YL,
YH, ZL & ZH (They are pointed in the diagram by red dashes) & also special purposes. So, as an example,
$001E is nothing but R30 which is the 31st GPR.

I/O Space is a collection of 64 registers each register having totally different names according to their purposes
e.g. DDRA, PINB, EEAR, etc. Those who already know embedded C programming, may recognize these
names. Apart from their names, they have their usual memory addresses from $20 through $5F . One thing to
note that these registers are called usually by their names not by their addresses.

SRAM is a volatile memory of temporary storage which is actually the main "Memory" of an MCU. In the
diagram as well as in discussion, I have considered Atmega32A which has 2KB of SRAM, which means 2048
cells of 8-bit each, address ranging from $60 upto $85F. These SRAM locations usually accessed via their
memory addresses as they don't have special names.

Some special Registers are Status Register (SREG), Program Counter (PC). Status register refers to that
special register of MCU which keeps track of of the status of the MCU as well as the last arithmetic operation
completed on ALU. The PC is a pointer to the memory address (flash memory) of the next command that will
be executed. PC is a 14 bit register to hold any address ranging from $0000 to $3FFF (The last address of flash
memory).

Program Execution & Clock:As you probably know, a program always coverts down to assembly/ machine
code which is nothing but a bunch of binary numbers, regardless of what programming language you use. So,
the machine code gets uploaded to the flash memory of the MCU in a particular location (not necessarily at
$0000, depends on some settings I'll talk about later). After that, the PC is set to the starting address of the
program & its starts executing. The PC is increased by 1 after completion of the previous command (Actually
the amount of increment depends of the command also, but for now, forget about this).
Another very important component inside the MCU is a pulse generator or a "Clock" which simply generates
square pulses in a constant frequency. The purpose of the Clock is to create a rhythm inside the MCU so that it
can make sure about the concurrent processing of each & every module.
During a single clock pulse, the following things happen:
Step 1. Fetches the command/Instruction at the address of the flash memory pointed by PC.
Step 2. The binary machine code then gets decoded by a "Instruction Decoder".
Step 3. After figuring out the command/Instruction, the ALU starts performing the operation corresponding to
the machine code. (Different machine codes correspond to different tasks)
Step 4. The ALU increases the PC by 1 (it actually depends on the instruction, but for now, simplest case can
be considered).
Step 5. Go to Step 1.
The above cycle continues till the MCU is properly powered.

PIC MICROCONTROLLER ARCHITECTURE: PIC stands for Peripheral Interface Controller. PIC
microcontroller was developed by microchip technology in 1993. It was developed for supporting PDP
computers to control its peripheral devices and that’s why it was named Peripheral Interface Controller. PIC
microcontrollers are of low cost, very fast and easy for the programming and execution of program. Their
interfacing with other peripherals is also very easy. PIC Microcontrollers from Microchip Company are
divided into 4 large families. In this PIC MICROCONTROLLER ARCHITECTURE

ARCHITECTURE:

PIC Microcontroller architecture is based on Harvard architecture and supports RISC architecture (Reduced
Instruction Set Computer). PIC microcontroller architecture consists of memory organization (ram, rom,
stack), CPU, timers, counter, ADC, DAC, serial communication, CCP module and I/O ports. PIC
microcontroller also supports the protocols like CAN, SPI, UART for interfacing with other peripherals .
PIC MICROCONTROLLER ARCHITECTURE block diagram

1. CPU (Central Processing Unit):

PIC microcontroller’s CPU consists of

 Arithmetic logic unit (ALU) 


 Memory unit (MU) 
 Control unit (CU)
 Accumulator 

ALU is used for arithmetic operations and for logical decisions. Memory is used for storing the
instructions after processing. Control unit is used to control the internal and external peripherals
which are connected to the CPU and accumulator is used for storing the results.

2. MEMORY ORGANIZATION:
PIC microcontroller memory module consists of mainly 3 types of memories:

 PROGRAM MEMORY:

It contains the written program after we burned it in microcontroller. Program Counter executes
commands stored in the program memory, one after the other. Pic microcontroller can have 8K
words x 14 bits of Flash program memory that can be electrically erased and
reprogrammed. Whenever we burn program into the micro, we erase an old program and write a
new one.

 DATA MEMORY:

It is a RAM type which is used to store the data temporarily in its registers. The RAM memory is
classified into banks. Each bank extends up to 7Fh (128 bytes). Number of banks may vary
depending on the microcontroller. PIC16F84 has only two banks. Banks contain Special
Function Registers (SFR) and General Purpose Registers (GPR). The lower locations of each
bank are reserved for the Special Function Registers and upper locations are for General Purpose
Registers.

General Purpose Registers (GPR):

These registers don’t have any special function. These are used for general purpose for
multiplying, addition or subtraction and then storing the results in other registers. CPU can easily
access the data in these registers.

Special Function Registers (SFR):

These registers are used for special purposes and they cannot be used as normal registers. Their
function is set at the time of manufacturing. They perform the function assigned to them and user
cannot change the function of SFR. Three important SFRs for programming are:

STATUS register: It changes the bank

PORT registers: It assigns logic values 0 or 1 to the ports

TRIS registers: It is a data direction register for input and output

 DATA EEPROM:

This memory allows storing the variables as a result of burning the written program. It is
readable and writable during normal operation (over the full VDD range). This memory is not
directly mapped in the register file. It is indirectly addressed through the SFRs. There are six
SFRs which are used to read and write to this memory (EECON1, EECON2, EEDATA,
EEDATH, EEADR, EEADRH).

3. SERIAL COMMUNICATION:
The transfer of one bit of data at time consecutively over a communication channel is called
Serial Communication. There are three protocols of serial communication:

 USART: It stands for Universal synchronous and Asynchronous Receiver and


Transmitter which provides a serial communication in two devices. In this protocol data
is transmitted and received bit by bit through a single wire according to the clock pulses.
To send and receive data serially the PIC microcontroller has two pins TXD and RXD. 

 SPI Protocol: SPI stands for Serial Peripheral Interface. It is used to send data between
PIC microcontrollers and other peripherals like sensors, shift registers and SD cards.
Three wire SPI communications is supported in PIC microcontroller between two devices
on a common clock source. SPI protocol has greater data handling capability than that of
the USART.I2C Protocol: I2C stands for Inter Integrated Circuit, and this protocol is
used to connect low speed devices like microcontrollers, EEPROMS and A/D converters.
PIC microcontroller support two wire Interface or I2C communication between two
devices which can work as both Master and Slave device. 

Serial Communication

4. INTERRUPTS:

There are 20 internal interrupts and three external interrupt sources in PIC microcontrollers
which are related with different peripherals like ADC, USART, Timers, and CCP etc.

5. I/O PORTS:

Let us take PIC16 series, it consists of five ports, such as Port A, Port B, Port C, Port D and Port
E.

 Port A:This port is 7-bit wide and can be used for both input and output. The status of
TRISA register decided whether it is used as input or output port.
 Port B:It is an 8-bit port. This port also can be used as input and output. Moreover in
input mode four of its bits are variable according to the interrupt signals. 
 Port C:It is also an 8-bit port and can be used as both input and output port which is
determined by the status of the TRISC register.
 Port D:This 8-bit port, unlike Port A, B and C is not an input/output port, but is used as
acts as a slave port for the connection to the microprocessor When in I/O mode Port D
all pins should have Schmitt Trigger buffers.
 Port E:It is a 3-bit port which is used as the additional feature of the control signals to
the A/D converter. 

6. CCP MODULE:

A CCP module works in the following three modes:

 Capture Mode: In this mode time is captured when a signal is arrived, or we can say
that, when the CCP pin goes high it captures the value of the Timer1.
 Compare Mode: It works same as an analog comparator, which means that when timer
1’s value reaches some reference value it will give an output signal. 
 PWM Mode: This mode provides a 10 bit resolution pulse and duty cycle that is
programmable. 

 Timers:

Timers and counters are important as timers can tell the time and count. PIC microcontroller can
have up to four timers (depending upon the family) Timer0, Timer1, Timer2 and Timer3. Timer0
and Timer2 are of 8-bits while the Timer1 and Timer3 are of 16-bits, which can also be used as
a counter. These timers work according to the selected modes.

8. D/A CONVERTER:

There are no analog outputs in PIC Microcontroller. To get analog output we have to use
external Digital-to-Analog Converter (DAC). It can convert 8 bits of digital number from the
eight digital outputs of PIC microcontroller.
9. A/D CONVERTER:

It converts the analog voltage levels to digital voltage values. In PIC Microcontroller, ADC has
8-channels and has resolution of 10-bit, which means that if we have to convert an analog
voltage between 0V to 5V the converter will divide it to 2^10 levels (1024 levels). The special
function registers ADCON0 and ADCON1 control the operation of ADC. The converter stores
the lower 8 bits in ADRESL register and the upper bits in the ADRESH register. Reference
voltage of 5V is required for the operation of the converter.

ARM Architecture

The ARM Adjustable-Rate Mortgage (ARM) architecture processor is an advanced reduced instruction
set computing [RISC] machine and it’s a 32bit reduced instruction set computer (RISC)
microcontroller. It was introduced by the Acron computer organization in 1987. This ARM is a
family of microcontroller developed by makers like ST Microelectronics,Motorola, and so on.
The ARM architecture comes with totally different versions like ARMv1, ARMv2, etc., and,
each one has its own advantage and disadvantages.
ARM Architecture

The ARM cortex is a complicated microcontroller within the ARM family that has ARMv7
design. There are 3 subfamilies within the ARM cortex family :

 ARM Cortex Ax-series


 ARM-Cortex Rx-series
 ARM-Cortex Mx-series

The ARM Architecture

 Arithmetic Logic Unit


 Booth multiplier
 Barrel shifter
 Control unit
 Register file

This article covers the below mentioned components.

The ARM processor conjointly has other components like the Program status register, which
contains the processor flags (Z, S, V and C). The modes bits conjointly exist within the program
standing register, in addition to the interrupt and quick interrupt disable bits; Some special
registers: Some registers are used like the instruction, memory data read and write registers
and memory address register.

Priority encoder: The encoder is used in the multiple load and store instruction to point
which register within the register file to be loaded or kept .
Multiplexers: several multiplexers are accustomed to the management operation of the
processor buses. Because of the restricted project time, we tend to implement these components
in a very behavioral model. Each component is described with an entity. Every entity has its own
architecture, which can be optimized for certain necessities depending on its application. This
creates the design easier to construct and maintain.

ARM Block Diagram

Arithmetic Logic Unit (ALU)

The ALU has two 32-bits inputs. The primary comes from the register file, whereas the other
comes from the shifter. Status registers flags modified by the ALU outputs. The V -bit output
goes to the V flag as well as the Count goes to the C flag. Whereas the foremost significant bit
really represents the S flag, the ALU output operation is done by NORed to get the Z
flag. The ALU has a 4-bit function bus that permits up to 16 opcode to be implemented.

Booth Multiplier Factor

The multiplier factor has 3 32-bit inputs and the inputs return from the register file. The
multiplier output is barely 32-Least Significant Bits of the merchandise. The entity
representation of the multiplier factor is shown in the above block diagram. The multiplication
starts whenever the beginning 04 input goes active. Fin of the output goes high when
finishing.

Booth Algorithm

Booth algorithm is a noteworthy multiplication algorithmic rule for 2’s complement numbers.
This treats positive and negative numbers uniformly. Moreover, the runs of 0’s or 1’s within the
multiplier factor are skipped over without any addition or subtraction being performed, thereby
creating possible quicker multiplication. The figure shows the simulation results for the
multiplier test bench. It’s clear that the multiplication finishes only in16 clock cycle.
Barrel Shifter

The barrel shifter features a 32-bit input to be shifted. This input is coming back from the
register file or it might be immediate data. The shifter has different control inputs coming back
from the instruction register. The Shift field within the instruction controls the operation of the
barrel shifter. This field indicates the kind of shift to be performed (logical left or right,
arithmetic right or rotate right). The quantity by which the register ought to be shifted is
contained in an immediate field within the instruction or it might be the lower 6 bits of a register
within the register file.

The shift_val input bus is 6-bits, permitting up to 32 bit shift. The shifttype indicates the needed
shift sort of 00, 01, 10, 11 are corresponding to shift left, shift right, an arithmetic shift right and
rotate right, respectively. The barrel shifter is especially created with multiplexers.

Control Unit

For any microprocessor, control unit is the heart of the whole process and it is responsible for the
system operation,so the control unit design is the most important part within the whole design.
The control unit is sometimes a pure combinational circuit design. Here, the control unit is
implemented by easy state machine. The processor timing is additionally included within the
control unit. Signals from the control unit are connected to each component within the processor
to supervise its operation.

ARM7 Functional Diagram

The final thing that must be explained is how the ARM will be used and the way in which the
chip appear. The various signals that interface with the processor are input, output or supervisory
signals which will be used to control the ARM operation.
ARM Functional Diagram

APPLICATION OF MICROCONTROLLER IN

INSTRUMENTATION LIST OF MICROCONTROLLER BASED

PROJECTS

1. MICROCONTROLLER AT-89C51 BASED METRO TRAIN PROTOTYPE


USING LCD:

The project shows resemblance as you are travelling in metro train. It will display three stations
at LCD and a stepper motor to rotate clock or anti-clock wise.

2. MICROCONTROLLER AT-89C51 BASED VOTING MACHINE:

The voting system for four candidates with memory backup to restore the results to be viewed
with password. Now-a-days Electronic voting machines are being used effectively. The
confidence of the voter in its flawless working is gradually building up and these machines are
thus becoming quite popular throughout the country. Features of the electronic voting machine
include avoidance of invalid votes and reduction of counting time and the consequent
expenditure incurred on manpower deployment. By using the Microcontroller the voting
machine can be built up easily and it will make simple to operate.

3. MICROCONTROLLER AT-89C51 BASED TEXT EDITOR CUM


MOVING MESSAGE DISPLAY:

The project comprises 30 keys to edit any message in English. One can restore the message in
memory IC. The 16 characters at a time can be view in running mode.

4. MICROCONTROLLER AT-89C51 BASED FULL FUNCTION STEPPER


MOTOR CONTROLLER:

The project will operate the stepper motor in almost all modes viz. clock, anti -clock, speed

and frequency control with time duration for both directions.

5. MICROCONTROLLER AT-89C51 BASED WATER LEVEL


CONTROLLER CUM MOTOR PROTECTOR:

It can indicate the level and control the water pump at top level filling. The present concept
implements controlling of pump which pumps water from the sump (underground tank) to the
overhead tank, using 8951 microcontroller. The control panel, i.e. the main control unit of the
system which consists of the primary control switches, pump indicator, siren and level
indicators..

6. MICROCONTROLLER AT-89C51 BASED SIMPLE STEPPER


MOTOR CONTROLLER:

A simple stepper motor controller circuit with direction change only. A stepper motor (or step
motor) is a brushless, synchronous electric motor that can divide a full rotation into a large
number of steps. The motor’s position can be controlled precisely without any feedback
mechanism (see Open-loop controller), as long as the motor is carefully sized to the application.
Stepper motors are similar to switched reluctance motors (which are very large stepping motors
with a reduced pole count, and generally are closed-loop commutated.)

7. MICROCONTROLLER AT-89C51 BASED AUTO GEAR SHIFTING SYSTEM:

The circuit shows the demo of auto shifting of gears using stepper motor with the change in
speed of vehicle. One can change the speed of DC motor as actual vehicle running wheel.
Motorcycle is widely used around the world. The gear shifting system of the motorcycle is
conventionally manual. This paper covers development of an indigenous automatic gear
shifting/changing system for the standard motorcycle. By this system the manual mechanical
gear-shifting system will remain unchanged because an additional electro-mechanical system is
placed on the vehicle to shift the gear and for automatic controlling the clutch. So the system has
both the options manual as well as automatic. This system uses low-cost microcontrollers to
make the accurate decision for shifting the gear up and down by observing the speed, and it
controls the clutch transmission where necessary. The complete hardware and software has been
tested and the functioning of the automatic gear shifting system is verified.

8. MICROCONTROLLER AT-89C51 BASED AUTO SPEED LIMITER WITH


AUTO BREAKING:

The project is to read the rpm of an automobile and according to that it limits the speed as Speed
Governor. One can change the speed with variable control. This Project can be used with the
three phase Induction motors. The circuit will take the full control of the motor and it will protect
the motor from several faults such us over voltage and under voltage and the circuit will switch
on the motor under safety conditions. The circuit was fully controlled by the microcontroller and
the microcontroller wills continuously monitors the voltages of the three phases and if the
voltage goes abnormal then it will switch off the motor until they are normal. All the conditions
are displayed it over the LCD display. In our project we are using the popular 8 bit
microcontroller AT89S52. It is a 40 pin microcontroller.

9. MICROCONTROLLER AT-89C51 BASED FASTEST FINGER FIRST:

Useful for Quiz games, dumb charades. It displays the player no. along with the beep for seven
players.

10. MICROCONTROLLER AT-89C51 BASED TEMPERATURE METER:

It will display the room temperature on LCD and one can set the desired value to indicate the
alarm or control at a desired temperature. It uses an ADC to interface with LM-35 sensor.

11. MICROCONTROLLER AT-89C51 BASED INFRARED REMOTE

CONTROLLED SWITCH BOARD:

One can operate (on/off) four electrical devices with TV remote synchronized with circuit
independently.

12. MICROCONTROLLER AT-89C51 BASED RANK DISPLAY SYSTEM

FOR RACE & QUIZ COMPETITION WITH LCD:

It can resolve the time difference (may be few milliseconds) and indicate the correct ranking
between the individuals denoted A to H
13. MICROCONTROLLER AT-89C51 BASED AUTO SPEED

LIMITER/GOVERNER WITH AUTO BREAKING:

The project is to read the rpm of a automobile and according to that it limits the speed as Speed
Governor. One can change the speed with variable control.

14. MICROCONTROLLER AT-89C51 BASED LINE FOLLOWER ROBOT:

A Robotic car that follows the black line at the floor area based on IR sensors with transmitters
and receivers.

15. MICROCONTROLLER AT-89C51 BASED ‘YES MASTER’ FOLLOWER:

A robotic car that follows his master who is sending an IR transmission always.

16. MICROCONTROLLER AT-89C51 BASED VOLTAGE/ POWER

FACTOR / FREQUENCY METER:

The project checks the electrical input factors as multifunction meter.

17. MICROCONTROLLER AT-89C51 BASED RFID ATTENDENCE MONITOR:

The project will show the names of person who had pressed the RFID key on LCD. One can use
DATA encoder/decoder circuit.

18. MICROCONTROLLER AT-89C2051 BASED FREQUENCY COUNTER

USING LCD:

The project will check the unknown frequency input up to 200 KHz. And display at LCD.

19. TRAFFIC SIGNAL CONTROL TRAFFIC MAN:

It can actually control traffic with lights and humanoid robot police man rotating in all directions
with hand movements for stop and go actions. This is a project comprises two stepper motors to
perform the action.
20. MICROCONTROLLER AT-89C2051 BASED IR WIRELESS

FREQUENCY COUNTER:

The project will check the unknown frequency input up to 200KHz. Coming from an IR source
and display at LCD.

You might also like