0% found this document useful (0 votes)
68 views80 pages

ESunit 1

The document discusses embedded systems and microcontrollers. It begins by defining a microprocessor and microcontroller, noting that a microcontroller integrates CPU, memory, and peripherals onto a single chip. It then explains the basic concepts and components of microprocessors and microcontrollers. The document discusses the need for microcontrollers in applications where space, power, and cost are critical considerations. It provides examples of microcontroller applications and characteristics of embedded systems. Finally, it discusses AVR microcontrollers in more detail, covering their features, registers, memory, and comparison to other microcontrollers.

Uploaded by

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

ESunit 1

The document discusses embedded systems and microcontrollers. It begins by defining a microprocessor and microcontroller, noting that a microcontroller integrates CPU, memory, and peripherals onto a single chip. It then explains the basic concepts and components of microprocessors and microcontrollers. The document discusses the need for microcontrollers in applications where space, power, and cost are critical considerations. It provides examples of microcontroller applications and characteristics of embedded systems. Finally, it discusses AVR microcontrollers in more detail, covering their features, registers, memory, and comparison to other microcontrollers.

Uploaded by

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

Embedded system

Unit 1
What is
Microprocessor
Central Processing Unit
?
(CPU): Control the
operation of the computer
and performs its data CPU
processing functions;
often simply referred to
as PROCESSPR
Microprocessor – Basic concept
Addres
s
Control

Boot
CPU Instruction
Data Input/ External
ROM (program)
RAM Output Comm.
Used at ROM
startup

Data

Microprocessor, by-itself, completely useless – must have


external peripherals to
Interact with outside world
Microcontroller – Basic concept
Microcontroller – Basic concept
Addres
s
Control

Boot Program Data Input/ External


ROM Output Comm.
CPU
ROM RAM

Dat
a

Microcontroller - put a limited amount of most commonly used resources


inside one chip
Microprocessor vs Microcontroller

• Microprocessor: • Microcontroller:

– A chip that contains all the


– A chip that contains only components of a computer
the processor – processor, memory,
input/output, and essential
– Need other chips to peripherals.
make a working system – Less flexibility
– Less component count in
– More flexible system
– Can have very few I/O or – Processing power is the
same as long as using same
many I/O devices using processor
the same processor chip
Need for microcontroller
• A designer using a general purpose microprocessor
such as Pentium or PowerPc must add RAM, ROM,
I/O ports to make them functional
• Although it becomes bulkier and costlier still they
have the advantage of versatility
• But for the microcontroller all are integrated in a
single chip, so it is sometimes called “single chip
computer”
• In many applications, the space used, the power
consumed and the price per unit is much more
critical consideration than the computing power
• In those applications, microcontrollers are used
Application of Microcontrollers
• Consumer electronics -- cell phones, pagers, digital
cameras, camcorders, video cassette recorders, portable
video games, calculators, and personal digital assistants;
• Home appliances -- microwave ovens, answering machines,
thermostat, home security, washing machines, and lighting
systems;
• Office automation -- fax machines, copiers, printers, and
scanners;
• Business equipment -- cash registers, curbside check- in,
alarm systems, card readers, product scanners, and
automated teller machines;
• Automobiles -- transmission control, cruise control, fuel
injection, anti-lock brakes, and active suspension.
What is an Embedded System?
• a microprocessor-based system
• built to control a function or range of functions
• not designed to be programmed by the end user in the same way
that a PC is
• Usually embedded as part of a complete device
including hardware and mechanical parts

System

SOFTWARE PROGRAM
#include <16f876a.h>
#use delay (clock=20000000)
#byte P ORT B = 6
main()
{
set_tris_b(0);
portb=255; //decimal
d e la y _ m s ( 1 0 0 0 ) ;
portb=0x55; //hexadecimal
d e la y _ m s ( 1 0 0 0 ) ;
portb=0b10101010; //binary
delay_ms(500);
}
Characteristics of Embedded Systems

• Single-functioned: An embedded system


usually executes only one program, repeatedly
• Tightly constrained: All computing systems
have constraints on design metrics, but those
on embedded systems can be especially tight
• Reactive and real-time: Many embedded
systems must continually react to changes in
the system’s environment, and must compute
certain results in real time without delay
Microcontroller for embedded
system
• Microprocessors and microcontrollers are widely used
in embedded system products
• An embedded system is controlled by its own internal
microprocessor (or microcontroller) as opposed to
external controller
• Printer is an example of embedded system, it does only
one task, taking data from the PC and print it
• In a mouse, there is a microcontroller which tracks the
mouse’s position and sends the information to the PC
• In an embedded system, typically only one application
software is burned into ROM
High end embedded system

• Sometimes microcontroller is inadequate for a


certain embedded system
• So, some manufacturers like Intel, AMD, Freescale
targeted their microprocessors for the high end
embedded market
• For example, PowerPC microprocessor
manufactured jointly by IBM and Freescale is
targeted for that market
• Another chip called ARM (Advanced Risk
machine) is used for high end embedded system
Selecting a Microprocessor
• Choose the right one for your application
– Primary criteria: Cost, Power, Size, Speed
– Others: package options, integrated peripherals, potential for
future growth

• Choose one with good software development support


– development environment - good compiler and debugger availability
– evaluation boards
– in-circuit emulators for those with deep pockets
– Operating system availability

• Other considerations
– Code density: affects power consumption, performance and system cost
– Hardware availability: make sure you can actually
purchase the microcontroller before designing it in
– Prior expertise, licensing, etc
• Many kinds of AVR with different properties
• Except for AVR32 which is 32bit all AVRs are 8
bit meaning that the CPU can work on only 8
bit of data.
• Data larger than 8 bit is broken in to 8 bit
pieces
• Programs written for one family is not 100%
compatible for other family
• AVRs are classified into four
• Mega
• Tiny
• Special purpose
• Classic
• Mega family is widely used as they are
powerful.widely available and comes in Dip
packages
AVR Features
Program ROM
• ROM is used to store program and is called
program ROM or code ROM
• Program ROM size 1k to 256k
• AVR was one of first microcontrollers to use
on-chip Flash memory for program storage
• For fast development flash memory is ideal
as it can erase the data within seconds
Data RAM and EEPROM
• RAM space is for data storage
• AVR has maximum of 64k of data RAM space
• RAM space has three components
1. General purpose registers
2. I/O memory
3. Internal SRAM- used for a read/write
scratch pad
• 32 General purpose registers but the SRAM
size and the I/O memory size varies from chip
to chip
• It contains a small amount of EEPROM to store
critical data that does not need to be changed
very often
I/O pins
• 3 to 86 pins for I/O
• Number of I/O depends on the number of pins
in the package
Peripheral
s
• AVR comes with
1. ADC
2. Timers
3. USART
Special capabilities are:- LCD
controller. USB controller,
Ethernet controller etc
AVR with other Microcontrollers
• AVR have many registers for arithmetic and
logic operation
• CPU uses many registers to store data
temporarily
• That information can be byte of data to be
processed or address pointing to the data to
be fetched
• AVR registers are 8 bit registers
8 bit register ranging form MSB to LSB
• With an 8 bit data type , any data
larger than 8 bits must be
broken into 8 bit chunks before
it is processed.
• In AVR there are 32 general purpose registers
• They are R0-R31and are located in the lowest
location of memory address
• GPRs in AVR are the same as accumulator in
other microprocessor
• GPRs are used by all arithmetic and logic
instruction
• To understand the use of GPRs we can see two
instruction
1. LDI Rd, k; load Rd (destination)
with immediate value K
• D must be between 16 and 31
• K is an 8-bit value that can be 0-255
in decimal
• I stands for immediate value
• LDI R31,0X25
R31=0X25
• We cannot load values into registers
R0- R15using the LDI instruction
ADD instruction
2. ADD Rd, Rr ;add Rr to Rd and store the
result in Rd
• LDI R16, 0X25 ;load 0x25 into R16
• LDI R17,0x34 ; load 0x34 into R17
• ADD R16,R17;add the values in R16 and R17
AVR data memory
• In AVR there are two kinds of memory
• Code memory space and data memory space
• Data memory space is composed of three
parts
➢ GPRs
➢I/O memory
➢internal data SRAM
GPRs
• GPRs use 32 byte of data memory space
• They always take the address location $00-$1F
I/O memory (SFRs)
• The I/O memory is dedicated to specific
function such as status register, timers,serial
communication, I/O ports. ADC, and so on
• The function of each I/O memory location is
fixed by the CPU designer at the time of
design because it is used for control of the
microcontroller or peripherals
• The AVR I/O memory is made of 8-bit registers
• The number of location in the data memory
for I/O depends on the pin numbers and
peripheral functions supported by that chip
• All AVRs have 64 bytes of I/O memory
location
• This 64 byte section is called standard I/O
memory
• In AVR with more than 32 I/O pins there is
also an extended I/O memory which
contains registers for controlling extra ports
and extra peripherals
• In other microcontrollers I/O registers are
called Special Function Registers (SFR)
Internal data SRAM
• Internal data SRAM is widely used for storing
data parameters by AVR programmers and
compilers
• Generally it is called scratch pad
• Each location of SRAM can be accessed by its
address
• Each location is 8 bit wide and can be used to
store any data .
SRAM vs EEPROM
• AVR as an EEPROM memory that is used for storing
data.
• EEPROM does not lose it’s data when power id off
where as SRAM lose its data when power is on
• EEPROM is used for storing data that should rarely be
changed whereas the SRAM is used for storing data
and parameters that are changed frequently.
• In AVR data sheet EEPROM refers to EEPROM’s size
and SRAM is the internal SRAM’s size.
AVR Status register
• Status register is an 8 bit register also
known a flag register.
-status register indicate the arithmetic
condetion or the current status of the
processor.
-the I/O address of the status register is
$3F(memery address $5F).
• All the bits are cleared to logic 0 at reset and
can be read from or written to by the program.
• The bits C,Z,N,V,S, and H are called
conditional flag meaning that they indicate some
condition that result after an instruction is
executed.
Carry Flag c
• This flag is set whenever there is a carry out
from the D7 bit.
• This flag bit is affected after an 8 bit addition
or subtraction.
ZERO flag z
• This flag reflect the result of an arithmetic or
logic operation .
• If the result is 0 then Z=1
• If the result is not = 0 then Z=0
Negative flag N
• Binary representation of signed numbers uses
D7 as the sign bit.
• Negative flag reflect the result of an
arithmetic operation .
• If the D7 bit of the result is 0, then N=0 and
the result is positive.
• If the D7 bit of the result is 1, then N=1 and
the result is negative.
• The negative(N) and V flags are used for the
signed number arithmetic operations.
Overflow Bit v
• This flag is set whenever the result of an
signed number operation is too large.
• The higher-order bit is overflow into the
sign bit.
• The carry fag is used to detect errors in
unsigned arithmetic operations .
• While overflow fag is used to detect
errors in signed arithmetic operations.
Sign Bit s

• This flag is the result of exclusive ORing of N


&V flags.
Half carry flag H
• If there is a carry from D3 to D4 during ADD or
SUB operation ,this bit is set, otherwise it is
cleared.
• This bit is used by instruction that performs
BCD operation,
• It is also called auxiliary carry flag
Bit copy storage
Used with BLD (bit load) and BST(bit store)instructions for loading
and storing bit from one register to another.
Global Interrupt Enable

• Setting this bit enabled all the interrupt.


• Resetting this disables all interrupts
Data memory I/O registers SRAM GPRS
ATtiny25 224 64 128 32
ATtiny85 608 64 512 32
ATmega8 1120 64 1024 32
ATmega16 1120 64 1024 32

ATmega32 2144 64 2048 32

ATmega128 4352 64+160 4096 32


ATmega2560 8704 64+416 8192 32
The program counter program
ROM space in the AVR
The most important register in the AVR microcontroller is
the program counter (PC)
• It is used by the CPU to point to the address of the next
instruction to be executed
• As CPU fetches opcode from the program ROM, the
program counter is incremented automatically to point to
the next instruction
• The wider the program counter the more memory
locations a CPU can access; a 14 bit program counter can
access 214 = 16K byte of program Memory
-address space occupies the range from 00000-$01FFF
• In AVR each flash mamory location is 2 byte (16 bit)wide.

• ATmega32,whose program ROM is 32K flash memory, is


organized as 16kX2 and its program counter is 14 bits wide
.
• Atmega64 has 64K program ROM which is organized as
32KX2bytes,so the program counter is 15 bits.

• i.e it has 32K locations (215 =32K )with each containing 2


bytes(32Kx2 bytes=.64Kbytes)
• In the case of a 16 bit PC,the code space is 64K.
• The program counter in AVR family can be upto 22bit wide.
• The maximum code space supported is 8M bytes.,
• Since each flash location is 2 byte wide, it has a total of 4M
locations.
• AVR family can access program address 000000-$3FFFFF
range.
• The first location of the program ROM inside the AVR has
the address of 000000,and the last location is different
depending on the size of the ROM on the chip.
AVR’s wakeup location
• In the case of AVR, it wakes up at 0x0000
location when it is powered up
• When AVR is powered up ,PC has a value
00000 in it.
• That means it expects the first opcode to be
stored in the 0x00000 location
• We achieve this by using .ORG statement in
the source program.
I/O PORTS

You might also like