0% found this document useful (0 votes)
3 views

chapter 1

The document provides an overview of microcontrollers and microprocessors, highlighting their differences, functionalities, and applications. Microprocessors are general-purpose processors requiring external components, while microcontrollers are integrated circuits designed for specific tasks with built-in memory and I/O capabilities. It also discusses embedded systems, real-time systems, and the architecture of CPUs, including buses, registers, and memory types.

Uploaded by

abay.b242
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

chapter 1

The document provides an overview of microcontrollers and microprocessors, highlighting their differences, functionalities, and applications. Microprocessors are general-purpose processors requiring external components, while microcontrollers are integrated circuits designed for specific tasks with built-in memory and I/O capabilities. It also discusses embedded systems, real-time systems, and the architecture of CPUs, including buses, registers, and memory types.

Uploaded by

abay.b242
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 51

INTRODUCTION

TO
MICROCONTROLLERS and MICROPROCESSOR
Connect to the world
The microprocessor and its offspring, the microcontroller, were
destined to infiltrate every country, every means of production, and
almost every home in the world.
But what are these microcontroller and microprocessor we are talking
about?
What are their difference?

Why do microcontrollers exist at all?

Why not just use a normal processor and add all necessary
Microprocessor(processor):
 microprocessors are integrated circuit (IC) which have only CPU (central processing unit)
inside them.
 They don’t have ROM, RAM, Timers, I/O pins etc. they designed to add them externally to
make them functional.
 The processor find in applications where tasks are unspecific(or for general tasks) like
developing software, games, website, photo editing, creating documents( ppt, txt, etc.), hence
the relationship between input and output is not defined.
 A microprocessor cannot be operated stand-alone, at the very least it requires some memory
and an input and output device to be useful.
 They use high amounts resources like; RAM, ROM, I/O pins.
 The clock speed of processor is quite high compared to that of microcontrollers i.e. MC from few
MHz to 50MHz, MP operates above 1GHz as they perform complex tasks.
 They consist of ALU, control unit and register array to performs all arithmetic and logical operations,
to manage and hands the flow of instructions through the systems, and to store the data from
memory for fast access respectively.
 Its applications are desktop, PC’s, laptops, smart phones, etc

 A microprocessor is a very small electronic circuit typically 1⁄2 inch (12 mm) across.

 It is easily damaged by moisture so to offer it some protection, it is encapsulated in plastic or ceramic.

 To provide electrical connections directly to the circuit would be impractical owing to the size and
consequent fragility, so connecting pins are molded into the case and the microprocessor then plugs
into a socket on the main circuit board.
 The size, shape and number of pins on the microprocessor depend on the amount of data that it is
designed to handle.
Microcontroller:
• The microcontroller includes a CPU, RAM, ROM, I/O ports, and timers all embedded on a
single chip like a standard computer which are allow it to operate stand alone, but because
they are designed to execute only a single specific task to control a single system, they are
much smaller and simplified.
• It is brain of computer system which contains enough circuitry to perform specific task that
requires certain degree of control such as TV remote, LED display panel, smart watches,
vehicles, traffic light control, washing machine, etc.
• A microcontroller is an integrated chip that is often part of an embedded system.
• In a microcontroller all that you have to do is to make proper connections of the pins and then
feed a computer program into it.
• After that your microcontroller responds in accordance with the program that has been fed
into it.
• It is more power full, complete computer for specific tasks and requires very small amounts of
RAM, ROM, I/O, etc.
Basic layout of a microcontroller.
Microcontroller Vs Microprocessor
• Both MP and MC are IC(integrated circuit).
• They share many common features
• They found in different versions from (4-100) pins today.
• Both are designed for real-time operations
• Cannot distinguish by looking them
• Comparing MP and MC in terms of cost is not justified, undoubtedly MC is far cheaper than
processor.
• However microcontroller cannot be used in place of microprocessor and using microprocessor
is not advised in place of microcontroller as it makes applications quit costly.
EMBEDDED SYSTEM
 An embedded computer is frequently a computer that is implemented for a particular purpose.

 Embedded systems usually only have a single task, or a very small number of related tasks that

they are programmed to perform.

Examples of embedded system;

digital clock, Hard disks, Printers:

Automobiles Mouse

LCD and phonebook Cell phones


Embedded computer block diagram
PERSONAL COMPUTER(PC)
 It is an average PC computer usually serves a number of purposes: checking email, surfing the

internet, listening to music, word processing, etc...


Real-Time System:
 Controllers are frequently used in real-time systems, where the reaction to an
event has to occur within a specified time.
 This is true for many applications in aerospace, railroad, or automotive areas,
e.g., for brake-by-wire in cars.
Integrated circuits
 An electronic circuit fabricated out of a solid block of semiconductor material.
This design of circuit, often called a solid state circuit, allows for very complex
circuits to be constructed in a small volume.
 An integrated circuit is also called a ‘chip’.
MPU and CPU
 An MPU is a Microprocessor Unit or microprocessor. A CPU is a Central Processing Unit. This is
the central ‘brain’ of a computer and can be (usually is) made from one or more
microprocessors.
 MPU is the thing
 CPU is the job.

Micro
 The word micro is used in electronics and science generally, to mean ‘one-millionth’ or 1x10–6.
 It has also entered general language to mean something very small like a very small processor
or microprocessor.
Microcontroller Components
1. Processor Core
 The processor core (CPU) is the main part of any microcontroller.
 It consists of the data path, which executes instructions, and of the control unit, which
basically tells the data path what to do, arithmetic logic unit (ALU), which is used to perform
computations (AND, ADD, INC, . . . ).
 Several control lines select which operation the ALU should perform on the input data.
 CPU is the brain of the computer system, administers all activity in the system and performs
all operations on data.
 It continuously performs two operations: fetching and executing instructions. It understand
and execute instructions based on a set of binary codes called the instruction set.
Basic CPU architecture.
THE BUSES: ADDRESS, DATA, AND CONTROL
 A BUS is a collection of wires carrying information with a common purpose.
 For each read or write operation, the CPU specifies the location of the data or instruction by
placing an address on the address bus, then activates a signal on the control bus indicating
whether the operation is read or write.
 READ OPERATIONS retrieve a byte of data from memory at the location specified and place it
on the data bus. CPU reads the data and places it in one of its internal registers.
 WRITE OPERATIONS put data from CPU on the data bus and store it in the location specified
ADDRESS BUS carries the address of a specified location. For n address lines, 2n locations can be
accessed. E.g., A 16-bit address bus can access 216 = 65,536 locations or 64K locations (210 = 1024
= 1K, 26 = 64).
Assume a 24 bit address bus, able to access 16M location. (Note this is not necessarily 16MByte
of memory. Why not?)
The PC, SP, and MAR in our cpu will therefore be 24 bits wide.
DATA BUS –
 It carries information between the CPU and memory or between the CPU and I/O devices.
 Microcontrollers have data bus widths of 4 bits, 8-bits, 16-bits and 32-bits, while the most
advanced PCs use 64 bits.
 If memory width is 16 bits wide means each locations can store 2 bytes data, then the MBR
and AC registers and ALU on the data side has 16 bits size.
If the address bus has been chosen to be 24 bits wide, so the address space is from
0x0 to 224 -1 or 0xFFFFFF in hex.
The data bus is 16 bits wide, and so the contents width is 16 bits. In Fig. for
Example, the contents of address 4 are 0x01FF. The largest (unsigned) integer
number that can be held is 216 -1 or 0xFFFF.
The IR is special. The IR (opcode) part should be wide enough to take the largest
opcode.

We assume the opcode is a fixed 8 bits wide, allowing 256 different instructions
— which is plenty enough.

The IR (address) part has to have the same width as the address bus, 24 bits. So
the whole IR is 32 bits wide.
CPU Registers

MAR -The Memory Address Register is used to store the address to access memory.
MBR -The Memory Buffer Register stores information that is being sent to, or received from, the
memory along the bidirectional data bus.

AC- The Accumulator is used to store data that is being worked on by the ALU, and is the key
register in the data section of the cpu. Notice that the memory can’t access the AC directly. The
MBR is an intermediary.

PC -Connected to the internal address bus, the Program Counter holds the address in memory
of the next program instruction. Notice that it doesn’t connect directly to the memory, but must
go via the MAR. (The PC is special in that it is both a register and a counter).
IR -When memory is read, the data first goes to the MBR. If the data is an
instruction it gets moved to the Instruction Register. The IR has two parts:
1. IR (opcode)- The most significant bits of the instruction make up the opcode.
• This the genuine instruction part of the instruction, that tells the cpu what to do.
The instruction in IR (opcode) gets decoded and executed by the control unit.
2. IR (address)- The least significant bits of the instruction are actually data.
• They get moved to IR (address). As the name suggests they usually form all or
part of an address for later use in the MAR. (However, in immediate addressing
they are sent to the AC.)
CONTROL BUS carries control signals supplied by the CPU to synchronize
the movement of information on the address and data bus

CONTROL DEVICES are outputs, or actuators, that can affect the world
around them when supplied with a voltage or current.

MONITORING DEVICES are inputs, or sensors, that are stimulated by


temperature, pressure, light, motion, etc. and convert this to voltage or
current read by the computer.

Note: The interface circuitry converts the voltage or current to binary


data, or vice versa.
 The ALU takes two inputs and returns the result of the operation as its output.
 Source and destination are taken from registers or from memory.
 In addition, the ALU stores some information about the nature of the result in the status
register (also called condition code register):
Z (Zero): The result of the operation is zero.
N (Negative): The result of the operation is negative, that is, the most significant bit
(msb) of the result is set (1).
O (Overflow): The operation produced an overflow, that is, there was a change of sign
in a two’s complement operation.
C (Carry): The operation produced a carry.
Machine Cycle
To execute an instruction–the processor must:
1. Fetch the instruction from memory
2. Decode the instruction
3. Execute the instruction
4. Store the result back in the memory. These four steps refer to Machine Cycle.
 Generally one machine cycle = X clock cycles (X depends on the particular instruction being
executed).
 Shorter the clock cycle, lesser the time it takes to complete one machine cycle, so instructions
are executed faster. Hence, faster the processor.
FETCHING AND EXECUTING AN INSTRUCTION
Fetching cycle involves the following steps:
At the beginning of the fetch cycle, the address of the next instruction to be executed is in the Program
Counter(PC).

 Step 1: The address in the program counter is moved to the memory address register(MAR), as this
is the only register which is connected to address lines of the system bus.
 Step 2: The address in MAR is placed on the address bus, now the control unit
issues a READ command on the control bus, and the result appears on the data bus
and is then copied into the memory buffer register(MBR).
 Program counter is incremented by one, to get ready for the next instruction.
 (These two action can be performed simultaneously to save time)
Step 3: The content of the MBR is moved to the instruction register(IR)

Thus, a simple Fetch Cycle consist of three steps and four micro-operation.
Symbolically, we can write these sequence of events as follows
Executing an instruction
• During the instruction fetch, an opcode is put into the IR (opcode), and is
decoded by the control unit.
• The CU now “knows” which instruction it should execute, and can therefore
output a sequence of Levels and Pulses to set up paths and effect the desired the
register transfers.
Example of LDA x fetch and execute.
• Example of the Fetch and execute of the LDA x instruction with x=5
and starting with PC =2. The steps follow a,b,c, ...,i.
2. Memory
 Based on the way the memory is used.

1. Register File: A (usually) relatively small memory embedded on the CPU.


• It is used as a scratchpad for temporary storage of values the CPU is working with - you could
call it the CPU’s short term memory.
2. Data Memory: For longer term storage, generic CPUs usually employ an external memory
which is much larger than the register file.
• Data that is stored there may be short-lived, but may also be valid for as long as the CPU is
running.
• Of course, attaching external memory to a CPU requires some hardware effort and thus incurs
some cost. For that reason, microcontrollers usually sport on-chip data memory.
3. Instruction Memory:
 Like the data memory, the instruction memory is usually a relatively large external memory (at
least with general CPUs).
 Actually, with von-Neumann-architectures, it may even be the same physical memory as the data
memory.
 With microcontrollers, the instruction memory, too, is usually integrated right into the MCU.

 Based on physical properties of the electronic parts the memory is made of.

1. Volatile memory. In this context, volatile means that the contents of the memory are lost as soon
as the system’s power is switched off. Volatile memory can be static or dynamic,
2. Non-volatile memory types:
 Unlike volatile memory, non-volatile memories retain their content even when power is cut.

 Then why should you use volatile memory at all, when non-volatile memory is readily available?
 The problem here is that non-volatile memory is usually a lot slower, more involved to work
with, and much more expensive.
 While the volatile memory in your PC has access times in the nanosecond range, some types
of non-volatile memory will be unavailable for milliseconds after writing one lousy byte to
them.
 Compare and contrast the following memories in accordance to their functions and
applications
• SRAM (Static Random Access Memory)
• DRAM (Dynamic Random Access Memory)
• ROM (Read Only Memory)
• PROM (Programmable Read Only Memory)
• EPROM (Erasable Programmable ROM)
• EEPROM (Electrically Erasable and Programmable ROM)
• Flash
3. I/O PORTS
 Digital I/O
 I/O pins are grouped into ports

of 8 pins, which can be


accessed with a single
byte access.
 Pins can either be input

only, output only, or most


commonly, bidirectional,
that is, capable of both
input and output.
• When we read the voltage level of a pin with a voltmeter (with respect to GND), we will see an
analog voltage.
• However, the microcontroller digitizes this voltage by mapping it to one of two states, logical 0
or logical 1.
• So when we talk about digital I/O, we mean that the value of the pin, from the controller’s
perspective, is either 1 or 0.
• Note that in positive-logic, 1 corresponds to the “high” state (the more positive resp.
• less negative state) of the line, whereas 0 corresponds to the “low” state (the less positive
resp. more negative state).
• In negative-logic, 1 corresponds to “low” and 0 to “high”. Microcontrollers generally use
positive-logic.
As far as digital I/O is concerned, three registers control the behavior of the pins:
1. Data Direction Register (DDR): Each bidirectional port has its own DDR, which contains one
bit for each pin of the port.
 The functionality of a pin (input or output) is determined by clearing or setting its bit in the
DDR. Different pins of a port may be configured differently.
Example, three pins configured to output and the other five as inputs.
 After a reset, the DDR bits are generally initialized to input.

2. Port Register (PORT): This register is used to control the voltage level of output pins.
 Assuming a pin has been configured to output, then if its bit in the PORT register is set, the pin
will be high; if the bit is cleared, the pin will be low.
 For output pins, reading the register returns the value you have written.
 For input pins, the functionality depends on the controller.
 Some controllers allow you to read the state of input pins through the port register.
 Other controllers, e.g. the ATmega16, use the port bits for other purposes if the corresponding
pins are set to input, so here you will read back the value you have written to the register.
3. Port Input Register (PIN): The PIN register is generally read-only and contains the current state
(high or low) of all pins, whether they are configured as output or as input.
 It is used to read the state of input pins, but it can also be used to read the state of output
pins to verify that the output was taken over correctly.
A write to this register generally has no effect.
Classification of microcontrollers
1. Classification of MCs by architecture.

There are two MC architectures Von Neiman and Harvard.


 The MC developed using Von Neiman architecture has common memory for storage of
data and programs and, as a consequence, the common bus for transferring of
instructions addresses and data.
 The MC developed using Harvard architecture has separate memory units for program
and data storage and separate busses for transferring of instructions addresses and data.
 Harvard architecture allows us to reach higher data transfer speed.

 The single instruction can be executed during one machine cycle using the MC based on
the Harvard architecture.
 Most MC families are created using Harvard architecture.
Harvard architecture block diagram
Von-neuman architecture block diagram
2. Classification of MCs by instruction set.
The MCs are divided into two groups by instruction set.
 There are MCs that belong to the reduced instruction set computer (RISC) group and MC that
belong to the complex instruction set computer (CISC) group.
 Majority of Microcontrollers are based on the RISC ideology.
 CISC ideology is mostly used in microprocessors.
 RISC: The RISC architecture has simple, hard-wired instructions which often take only one or a
few clock cycles to execute.
 RISC machines feature a small and fixed code size with comparatively few instructions and few
addressing modes.
 As a result, execution of instructions is very fast, but the instruction set is rather simple.
CISC: The CISC architecture is characterized by its complex micro coded instructions which take
many clock cycles to execute.
The architecture often has a large and variable code size and offers many powerful instructions
and addressing modes. but the instruction set is more powerful.
3. Classification of MCs by family (ideology).
According to ideology MC are distributed into the families.
The most popular families of 8-bit MCs are:
1. 8051 family (Intel ideology);
2. 68HC05 family (Motorola ideology);
3. AVR family (Atmel ideology);
4. PIC family (Microchip ideology).
IDEOLOGY. INSTRUCTION SET ARCHITECTURE MANUFACTURER

8051 family RISC MCs Harvard Intel, Atmel, Dallas Semiconductor,


architecture Philips, Siemens, ISIS (Integrated
Silicon Solutions).

68HC05 CISC type. Von Neiman Motorola


family architecture

AVR family RISC type Harvard Atmel


architecture

PIC family RISC type Harvard Microchip


architecture

You might also like