0% found this document useful (0 votes)
84 views98 pages

CPE109 Module 1

Uploaded by

Hakdog Hakdog
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)
84 views98 pages

CPE109 Module 1

Uploaded by

Hakdog Hakdog
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/ 98

HISTORY AND OVERVIEW

1960
Apollo Guidance Computer was
developed by Charles Stark
Draper at MIT

• One of the first IC-based


computers
1965
Autonetics developed the D-17B

• Built from transistor logic


• Had a hard disk for main
memory
1968
The first automobile using the
embedded systems, Volkswagen
was invented.
1971
Texas Instruments developed
the first microcontroller (MCU)
called the TMS1802NC
1987
The first embedded OS,
VxWorks, was released by Wind
River
1996
Microsoft Windows CE was
released.

• A customizable operating
system for embedded
applications
1999
The first embedded Linux
system appeared called the
uCsimm which runs an
embedded microcontroller OS
called uClinux.
2013
The embedded market reached
$140 Billion
Future
By 2030, Analysts are projecting
an Embedded market larger
than $140 Billion
OVERVIEW
What is Embedded System?
◦ A microcontroller based system which is designed to perform a
specific task.
◦ Can be an independent system or a part of a large system
OVERVIEW
What is Microcontroller?
◦ A single-chip VLSI unit which is also called microcomputer
◦ It contains all the memory and I/O interfaces needed

What is Microprocessor?
◦ A single chip semiconductor device
◦ Contains a program counter, an ALU, a stack pointer, working register and a clock
timing circuit
◦ Also includes ROM and RAM, memory decoder and many serial and parallel
ports
Embedded System components

Hardware Application Software Real Time Operating System


(RTOS)
Basic Structure of an Embedded System

A-D Processor D-A


Sensor Actuator
Converter & ASIC Converter

Memory
Types of Embedded Systems
Advantages of Embedded System
Covers a wide variety of environments Useful for mass production

Less likely to encore errors Highly reliable

Reduced cost Small in size

Offers an enhanced performance Low power operation


Disadvantages of Embedded System
It doesn’t offer any technological
Needs high development effort
improvement

It needs a long time to market It is difficult to backup embedded files

Can’t be programmed to do different


things

Offers very limited resources for


memory
Applications of Embedded System

Microwave oven Television

Remote control Scientific Calculator Refrigerator


RELEVANT TOOLS,
STANDARDS AND
ENGINEERING CONSTRAINTS
Embedded Languages

◦C
◦ C++
◦ Assembly
Microcontrollers RELEVANT
◦ ATMega328P TOOLS
◦ ATTiny84
In-Circuit Programmer/ In-System
Programmer/ In-Circuit Serial Programmer

◦ Arduino
Performance Safety
STANDARDS
Efficiency Security
AND
ENGINEERING
CONSTRAINTS
Reliability Usability

Robustness
CHARACTERISTICS OF EMBEDDED SYSTEM
BASIC SOFTWARE TECHNIQUES FOR EMBEDDED
APPLICATIONS
CHARACTERISTICS OF
EMBEDDED SYSTEM
1. Single-functioned
◦ Performs a specialized operation
◦ Simple
◦ Low cost
◦ Less complex
2. Tightly Constrained

Cost Size Performance Battery power


3. 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 any delay.
• Reactive System
They only react on input
There is no time limit to perform
the system
• Real-Time System
Performs in given time frame
Categorized in:
• Soft Real-time Systems
• Hard Real-time Systems
Soft Real-
Time Systems
Timing is less critical

Examples:
◦ Personal Computer
Failure to meet deadline results in ◦ Audio and Video
degraded performance
Systems
Timing is critical

Hard Real-
Failure to meet deadline can result in
Time Systems
disaster
4. Perform Specific Task
◦ Total focus of the processor is to perform a single dedicated task
5. User Interface
◦ Used by user to interact with the system
◦ Touchscreen or LCD
6. Processors in Embedded Systems

Processor-Based Embedded Microcontroller Based


Systems Embedded Systems
Factors in selecting processor or
microcontroller
8-bit, 16-bit or Amount of
Number of
32-bit RAM and Speed
I/O pins
Architecture ROM

On-Chip
Packaging Cost Performance
Features

Size
7. Ready-Made Boards
◦ Arduino Board
◦ Raspberry Pi
◦ Banana Pi
◦ Intel Galileo
◦ Beaglebone
BASIC SOFTWARE TECHNIQUES FOR
EMBEDDED APPLICATIONS
Embedded Software

SOFTWARE THAT CONTROLS LOADED IN THE


AN EMBEDDED SYSTEM MICROCONTROLLER
Tools used in
developing
embedded software
• Editor
• Compiler
• Assembler
• Debugger
This is where the code is written

The code is written in some 1. Editor


programming language (ex. C or C++)

Also referred to as source code


Converts the source code to
object code

2. Compiler
Object code is in low level
programming language therefore
it is understandable by computer
Converts an assembly
language code into machine
language
3. Assembler
All mnemonics and data is
converted to op codes and
bits
Used to debug code

4. Debugger
Tests for errors and bugs
◦ Combines one or more object
code files and library files 5. Linker
together in executable program
Pre-written program that is ready
to use and provides specific
functionality

6. Libraries
File written in C or C++ and can
be used by different programs
and users
Helps to see how the code will
work in real time
7. Simulator
Input values can be changed to
see corresponding outputs
Integrated
Development
Environment (IDE)

• MPLAB and
PICKIT
• Arduino Software
• MATLAB
• LabVIEW
• Visual Studio
MPLAB
◦ is a proprietary freeware integrated development
environment for the development of embedded
applications on PIC and dsPIC microcontrollers, and
is developed by Microchip Technology.

MPLAB® X Integrated Development Environment (IDE)


is an expandable, highly configurable software program
that incorporates powerful tools to help you discover,
configure, develop, debug and qualify embedded
designs for most of Microchip’s microcontrollers and
digital signal controllers.
Arduino Software
◦ Used if working with Arduino
microcontroller
◦ Open source software
◦ User-friendly and has a lot of
features
MATLAB
◦ Can solve computational
problems
◦ Can be used to interface
programs written in other
programming languages
◦ Includes an additional software
called Simulink for simulation
LabVIEW
◦ Stands for Laboratory Virtual
Instrument Engineering
Workbench
◦ Used for Data Acquisition,
Industrial Automation and
Instrument Control
Visual Studio
◦ Integrated Development
Environment provided by
Microsoft
◦ Supports different
programming languages
◦ Can be used to build mobile
apps, window apps, and more
Thank you for listening…
PARALLEL INPUT AND
OUTPUT
PARALLEL COMMUNICATION
◦ A method of sending several data signals simultaneously over a
transmission link at one time.
◦ It comprises of several wired channels in parallel.
How Parallel Communication Works
Characteristics of
Parallel
Communication
• High Speed Data Transfer
• Limited Cable Length
• Easy Installation
When to Use
Parallel
Communication
• Large Data needs to
be transferred
• Data to be sent is time
sensitive
• Data is required to be
transferred quickly or
in real time
EXAMPLES OF
PARALLEL
COMMUNICATION
ASYNCHRONOUS AND
SYNCHRONOUS SERIAL
COMMUNICATION
SERIAL COMMUNICATION
◦ The process of sending or receiving data one bit at a time
Asynchronous
Communication
• Data moves in a half-paired
approach, 1 byte or 1
character at a time. It sends
the data in a constant current
of bytes
Characteristics of Asynchronous Transmission

Each character is
headed by a beginning There may be gaps or
bit and concluded spaces in between
with one or more end characters.
bits.
Emails

Forums

Examples of
Letters
Asynchronous
Transmission
Radios

Televisions
Synchronous
Transmission

• Data moves in a
completely paired
approach, in the
form of chunks or
frames
Characteristics of Synchronous Transmission

There are no spaces Timing is provided by The syn characters are


in modems or other Special ’syn’ characters included between
between characters devices at the end of goes before the data chunks of data for
being sent. the transmission. being sent. timing functions.
Chatrooms

Video conferencing
Examples of
synchronous
Telephonic conversations Transmission

Face-to-face interactions
PERIODIC INTERRUPTS,
WAVEFORM GENERATION,
TIME MEASUREMENT
A signal to the
processor emitted
by hardware or
software
INTERRUPTS indicating an
event that needs
immediate
attention.
Low level programming concept

INTERRUPTS Extremely important

Irreplaceable
ORIGIN OF INTERRUPTS
 Normal view of a computer program: sequence of
instructions executed serially, jumps are allowed.
 This view isn’t good enough for the real world.
 Programs for embedded systems usually service
real-life demands.
 Real-life demands don’t wait for anything.
 Consider a typical embedded system program: it
usually consists of an infinite loop, called the
“program loop”.
 In each iteration, the program checks whether
events have occurred, gives suitable responses and
performs periodic tasks.
 This model is sufficient if processor is extremely
fast with respect to real world.
We need a method to handle
events the moment they occur, and
not after some delayed time.

Why Interrupts are special events that


can “interrupt” the normal flow of
Interrupts? a program.

The processor stops the normal


program, handles the interrupt,
and then resumes its normal work.
Hardware
Interrupts
 An electronic
alerting signal sent
from the processor
from an external
device, like a disk
controller or an
external peripheral
Software
Interrupts
 Caused either by an
exceptional
condition or a special
instruction in the
instruction set which
causes an interrupt
when it is executed
by the processor.
Polling

 The state of continuous


monitoring
 The microcontroller
keeps checking the
status of other devices
 For every interrupt, there must be
an interrupt service routine (ISR),
or interrupt handler. When an
interrupt occurs, the
microcontroller runs the interrupt
service routine. For every
Interrupt
interrupt, there is a fixed location Service
in memory that holds the address
of its interrupt service routine, Routine
ISR. The table of memory locations
set aside to hold the addresses of
ISRs is called as the Interrupt
Vector Table.
Example of Interrupt Vector Table
 Interrupt Vector Table (8051)
When an interrupt gets active, the microcontroller goes through the
following steps −
The microcontroller closes the currently executing instruction
and saves the address of the next instruction (PC) on the
stack.

It also saves the current status of all the interrupts internally


(i.e., not on the stack).

Steps to It jumps to the memory location of the interrupt vector table

Execute an that holds the address of the interrupts service routine.

Interrupt The microcontroller gets the address of the ISR from the
interrupt vector table and jumps to it. It starts to execute the
interrupt service subroutine, which is RETI (return from
interrupt).

Upon executing the RETI instruction, the microcontroller


returns to the location where it was interrupted. First, it gets
the program counter (PC) address from the stack by popping
the top bytes of the stack into the PC. Then, it start to
execute from that address.
Two types of Interrupt modules

LEVEL TRIGGERED EDGE TRIGGERED


Enabling and Disabling an
Interrupt

Upon Reset, all the


interrupts are disabled even IE (interrupt enable)
if they are activated. The register is responsible for
interrupts must be enabled enabling and disabling the
using software in order for interrupt. IE is a bit-
the microcontroller to addressable register.
respond to those interrupts.
Interrupt Enable Register

ET2 − Enable ES − Enable


EA − Global
- − Undefined. Timer 2 Serial port
enable/disable.
interrupt. interrupt.

ET1 − Enable EX1 − Enable ET0 − Enable EX0 − Enable


Timer 1 External 1 Timer 0 External 0
interrupt. interrupt. interrupt. interrupt.
Interrupt Priority in 8051
Interrupt inside Interrupt
What happens if the 8051 is executing an ISR that
belongs to an interrupt and another one gets
active?

In such cases, a high-priority interrupt can


interrupt a low-priority interrupt. This is known
as interrupt inside interrupt. In 8051, a low-
priority interrupt can be interrupted by a high-
priority interrupt, but not by any another low-
priority interrupt.
Timers
 A timer is a register. Recall that
registers are special, fixed-size
variables with hardware
implications.
 The timer, when started,
begins at 0. After every time t,
its value increases by 1.
 This process is independent of
the CPU.
 When the timer reaches its
maximum value, in the next
cycle, its value becomes 0
again and the process repeats
itself.
Timers
 If the maximum value of a timer
is n and clock period is t, then:
1. Timer cycle period = (𝑛 + 1) × 𝑡
2. Frequency of timer = 𝑓 = 1/𝑡
3. Frequency of timer cycle =
1/(𝑛+1)× 𝑡
Timers and Interrupts

TIMERS CAN GENERATE CERTAIN THESE ARE CALLED OVERFLOW


INTERRUPTS: TWO, TO BE PRECISE. INTERRUPT AND COMPARE MATCH
INTERRUPT.
The interrupt may or
may not have a
OVERFLOW is The name is derived
handler. In either
generated when a from the fact that
case, the timer
timer tries to exceed the timer has
continues to run;
its maximum value “overflowed” its
remember: timers
and resets to 0. limit.
are independent of
the CPU

OVERFLOW interrupt
Suppose a timer of maximum value n has a
time period t (also called as clock period).

Then the timer cycle frequency = 1/ (𝑛+1)×𝑡


OVERFLOW
interrupt If OVERFLOW interrupt is enabled, then an
interrupt is generated in every cycle.

Thus, OVERFLOW interrupt frequency = 1/


(𝑛+1)× 𝑡
COMPARE MATCH interrupt
 There is a register called as OCR
(Output Compare Register), whose
value we can set.
 After every clock period, the timer
is incremented by 1 (or reset to 0 in
case it is at maximum value).
 Before incrementing, the value of
the timer is compared to OCR. If the
two are equal, a COMPARE MATCH
interrupt is generated.
Suppose a timer of maximum value n has a
time period t (also called as clock period).

COMPARE Then the timer cycle frequency = 1/(𝑛+1)×𝑡


MATCH If COMPARE MATCH interrupt is enabled, then
interrupt an interrupt is generated in every cycle.

Thus, COMPARE MATCH interrupt frequency =


1/(𝑛+1)×𝑡
Timer Modes

All three modes are


A timer works in The timer mode used
again unaffected by
three modes: so far in this
interrupts, but all
Normal, CTC and presentation is
three modes can
PWM. normal mode.
generate interrupts.
Normal Mode
 Standard mode: Timer
starts at 0, goes to
maximum value and
then resets itself.
 OVERFLOW and
COMPARE MATCH
interrupts generated as
normal.
CTC (Clear Timer on Compare)
Mode
 Timer starts at 0 as usual, but instead of resetting
after maximum value, it resets after reaching
value specified in OCR register.
OCR Maximum Value
OCR – 1
.
.
0 Starting Value
CTC (Clear Timer on
Compare) Mode

 If clock time period is t:


1. Timer cycle time period = (𝑂𝐶𝑅 + 1) × 𝑡
2. Frequency = 1 /(𝑂𝐶𝑅+1)×𝑡
 COMPARE MATCH interrupt will work
normally, but OVERFLOW interrupt will
not work.
Thank you
very much
Simple method of obtaining analog
output of any value between 0 and 5V.

PWM (Phase
Suppose desired output is x% of 5V. If,
Width for a time period t, the output is 5V for
x% time and is 0 for the remaining time,
then average voltage is x% of 5V.
Modulation)
Mode If this time period is extremely small
and the process is repeated
continuously, then output behaves as
analog value.
PWM (Phase Width Modulation)
Mode
 If clock time period is t and maximum timer value
PWM (Phase 1.
is n:
Timer cycle time period = (𝑛 + 1) × 𝑡
Width 2. Frequency = 1 /(𝑛+1)×𝑡
3. Duty cycle = 𝑂𝐶𝑅+1 /𝑛+1 × 100%
Modulation) 4. Output voltage = (𝑂𝐶𝑅+1/ 𝑛+1 ) × 5𝑉

Mode  COMPARE MATCH interrupt and OVERFLOW


interrupt will work properly.
Thank you
very much

You might also like