Embedded systems

77
EMBEDDED SYSTEMS Prepared by G.Manjunathan ME.,

Transcript of Embedded systems

Page 1: Embedded systems

EMBEDDED SYSTEMS

Prepared by

G.Manjunathan ME.,

Page 2: Embedded systems

What is general purpose system?• A computer system that can do many

functionalities depending on • Available hardware

• Installed programs

Examples

• PCs

• Laptops

• Servers

Page 3: Embedded systems

What is an Embedded systems ?

• An embedded system is a special-purposecomputer system designed to perform adedicated function

• A combination of hardware and softwarewhich together form a component of a largermachine.

Page 4: Embedded systems

Block Diagram of an Embedded System

Page 5: Embedded systems

Essential Components

• Microprocessor / Microcontroller

• Sensors

• Converters (A-D and D-A)

• Actuators

• Memory (On-chip and Off chip)

• Communication path with the interacting environment

5

Page 6: Embedded systems

Important Units Of Microprocessor/Controller

• CPU: Central Processing Unit• I/O: Input /Output• Bus: Address bus & Data bus• Memory: RAM & ROM• Timer• Interrupt

Page 7: Embedded systems

CPUGeneral-Purpose Micro-

processorRAM ROM I/O Port Timer

Serial COM Port

Data Bus

Address Bus

General-Purpose Microprocessor System

• CPU for Computers• No RAM, ROM, I/O on CPU chip itself• Example--Intel’s x86: 8086,8088,80386,80486,

PentiumMany chips on mother board

General-purpose Microprocessor

Page 8: Embedded systems

RAM ROM

I/O PortTimerSerial COM Port

Microcontroller

CPU

• A smaller computer.• On-chip RAM, ROM, I/O ports...• Example:- Motorola’s 6811, Intel’s 8051 and

PIC 16X

A single chip

Microcontroller

Page 9: Embedded systems

Microprocessor Vs Microcontroller

Page 10: Embedded systems

Microprocessor

• CPU is stand-alone, RAM, ROM, I/O, timer are separate

• designer can decide on the amount of ROM, RAM and I/O ports.

• expensive• general-purpose• Ex. 8085,8086 mp, Motorola 6800,

Intel’s 8086, etc.

Microcontroller

• CPU, RAM, ROM, I/O and timer are all on a single chip

• fix amount of on-chip ROM, RAM, I/O ports

• for applications in which cost, power and space are critical

• single-purpose• Ex. 8051, PIC mc, Motorola

MC’s, Phillips, etc.

Microprocessor v/s Microcontroller

Page 11: Embedded systems

ARCHITECTURE

Instruction Set Based

CISC & RISC

Memory Access Based

HARVARD &

VON-NUEMANN

Architecture

Page 12: Embedded systems

CISC Vs RISC

CISC

• hardware complexity is

high

• multi clock complex

instructions

• Small codes sizes

• Transistors used for

storing complex

instructions

• pipelining is not possible

due to uneven process

time

RISC

• hardware complexity is low

• Single clock Reduced

instructions only

•Low cycles/sec

• Spends more transistors on

memory registers

• instructions execute in a

uniform amount of time (i.e. one

clock), pipelining is possible.2444

Page 13: Embedded systems
Page 14: Embedded systems

Application areas

Automotive electronics

Aircraft electronics

Trains

Telecommunication

14

Page 15: Embedded systems

Automobiles

Page 16: Embedded systems
Page 17: Embedded systems

Consumer electronics

Page 18: Embedded systems

Industry Automation

Page 19: Embedded systems

Telecommunication

Page 20: Embedded systems

Medical systems

Page 21: Embedded systems

Embedded Medical Equipment

Page 22: Embedded systems

Application areas

22

• Authentication

• Military applications

• Medical systems

Page 23: Embedded systems

Application areas

Consumer electronics

23

• Smart buildings

• Fabrication equipment

Page 24: Embedded systems

Traffic LightDVD player

Digital clockMoving message display

Page 25: Embedded systems

Characteristics of Embedded Systems - Dependability

• Reliability: R(t) = probability of system workingcorrectly provided that it was working at t=0

• Maintainability: M(d) = probability of systemworking correctly d time units after error occurred.

• Availability: probability of system working at time t

• Safety: no harm to be caused

• Security: confidential and authentic communication

Page 26: Embedded systems

Characteristics of Embedded Systems-Efficiency

• Energy efficient

• Code-size efficient (especially for systems on a chip)

• Run-time efficient

• Weight efficient

• Cost efficient

• Dedicated user interface (no mouse, keyboard andscreen).

Page 27: Embedded systems

Characteristics of Embedded Systems

• Many ES must meet real-time constraints:

• A real-time system must react to stimuli from the controlled object (or the operator) within the time interval.– For real-time systems, right answers arriving too

early or too late are wrong.

– An embedded system can be a• Hard real-time system

• Soft real-time system

Page 28: Embedded systems

Hard real-time system

• In hard real-time systems the tasks should be run in on time , time is major constraints.

• The response time requirements of hard real-time systems are in the order of milliseconds or less and can result in a catastrophe if not met.

• Examples for hard real-time systems is– Missile – Industrial Automation– Automobiles– video transmission, each picture frame and audio

must be transferred at fixed rate

Page 29: Embedded systems

Soft real-time system

• The response time requirements of soft real-time systems are higher and not very stringent.

• The soft real-time systems will slow down their response time if the load is very high

• Examples are

– DVD Player

– Mobile phones

– digital cameras

– playing robots

Page 30: Embedded systems

Comparison

General Purpose Computing• Few applications that are

known at design-time.

• Not programmable by end user.

• Fixed run-time requirements (additional computing power not useful).

• Criteria:

– cost

– power consumption

• Broad class of applications.

• Programmable by end user.

• Faster is better.

• Criteria:– Cost

– average speed

Embedded Systems

Page 31: Embedded systems

Features of Embedded system• Embedded Systems are the modern compacted

devices with multifunction capabilities.• An embedded system performs pre-defined tasks,

unlike a general-purpose personal computer.• An embedded system is a programmed hardware

device. A programmable hardware chip is theplatform and it is programmed with particularapplications.

• Embedded systems are not always standalonedevices. Many embedded systems consist of small,computerized parts within a larger device thatserves a more general purpose.

Page 32: Embedded systems

Features of Embedded system

• The program instructions written for embedded systems are referred to as firmware,

• The program stored in read-only memory or Flash memory chips.

• They run with limited computer hardware resources: little memory, small or non-existent keyboard and/or screen.

Page 33: Embedded systems

Embedded System Architecture

Page 34: Embedded systems

development process of BASIC embedded System

1. Requirements (application)

2. Select microcontroller and H/W

3. Design hardware for your application

4. Write software

5.Write your HEX code to microcontroller

6. Test your proto type product

7. You start your product production

Page 35: Embedded systems

Requirements

• Gather an informal description from the customers known as requirements.

• After getting enough information to begin designing the system architecture.

• Consumers of embedded systems are usually not embedded system designers.

• Example consider for designing washing machine

– Less power

– High efficiency

Page 36: Embedded systems

Select microcontroller

• Select suitable microcontroller for required system design.

• Select special purpose processors if needed for the system like DSP processor

• We can classified like

– 8 bit microcontroller

– 16 bit microcontroller

– 32 bit microcontroller

Page 37: Embedded systems

8 bit microcontroller

• It can perform 8 bit arithmetic and logical operations.

• Examples – 8051

– PIC16XX

• MB90890 Manufactured by Fujitsu .

• It performs all 16-bit Data operations

16 bit microcontroller

Page 38: Embedded systems

•LPC2148 (ARM)Manufactured by

Philips.

•It performs all 32-bit as well as 16-

bit operations

32-bit Microcontroller

Page 39: Embedded systems

Select Hardware

• Select required hardware components for the systems.

• Examples

– Transducers

– Reactors

– Communication protocols

– Input and Output interfaces

– ADCs

Page 40: Embedded systems

Hardware's required for washing machine

Page 41: Embedded systems

Hardware Design

• Design printed circuit board using some computer aided design tools

• Two steps are

– Design schematic

– Design corresponding layout

– Examples

• Orcad

• Proteous

• Express PCB

Page 42: Embedded systems

Schematic diagram

Page 43: Embedded systems

Layout format

Page 44: Embedded systems

Software Design

Page 45: Embedded systems

Developments Tools

• Assembler

• C compiler

• Editors

• RTOS (Real Time Operating System)

• Flash programmer

• Simulator

Page 46: Embedded systems

Assembler

• It is a software that converts assembly

language program to Machine language

program understandable by microprocessor

MOV A,#CR

CALL PUTCHAR

MOV A,#LF

CALL PUTCHAR

RET

:10002600750B00750C00750D00750E007513FFD26B

:1000360083D284D282C287C286C285C281C200C2EE

:1000460001C202C203C204C205C206C20775140079

Assembly

program

Machine

Codes

Page 47: Embedded systems

C cross Compiler

• It is a software that converts High level

language program [ written in C ] to Machine

language program understandable by

microprocessor

C program Machine Codes

main()

{ unsigned int d;

int_reg(); int_var();

for(d=0; d < 50000 ;d++)

{ LCD_PORT=0; }

init_lcd();

TR0=1;

uputs(0,0,15, "Conveyer System

"); 0,15," Version 1.0 "); P0=0;

P2=0;

:10002600750B00750C00750D00750E007513FFD26B

:1000360083D284D282C287C286C285C281C200C2EE

:1000460001C202C203C204C205C206C20775140079

Page 48: Embedded systems

Editor

Page 49: Embedded systems

What is Real-Time Operating System (RTOS)?

• real-time operating system (RTOS) is an operating system that guarantees to perform certain operation (task) within a specified time constraint.

• Software that manages the time of a microprocessor, microcontroller, or a digital signal processor

Page 50: Embedded systems

Basic functions of RTOS

• Task scheduling

• Interrupt handling

• Memory management

• Task synchronization

• Avoid priority inversion

• Time management

Page 51: Embedded systems

Types of RTOS

• Hard Real-time RTOS

– This type operating systems used in hard real-time embedded systems

– Examples are

• LynxOS

• OSE

• QNX

• RTLinux

• VxWorks

• Windows CE

Page 52: Embedded systems

Types of RTOS

• Soft real-time operating system

– This type of operating systems used in soft real-time embedded systems

– Examples are

• uCOS-II

• Android

• embOS

• Symbian OS

Page 53: Embedded systems

Flash programmer

• Flash programmer used to transfer the binary image from personal computer to embedded systems.

• Separate software are used for this purpose

• Examples are– Flash magic– Philips flash utility– Win pic– Tiny bootloader

PC

Embedded system

Programmer

RS232

Page 54: Embedded systems

Test prototype product

• Multi meter

• Oscilloscope

• Logic Analyzer

• Terminal Emulation software

• Simulators & Emulators

Page 55: Embedded systems

Features of PIC16F887A

• RISC architecture– Only 35 instructions to learn– All single-cycle instructions except branches

• Operating frequency 0-20 MHz• Precision internal oscillator

– Factory calibrated

• Power supply voltage 5V– Consumption: 220uA (4MHz), 11uA (32 KHz) 50nA

(stand-by mode)

• Power-Saving Sleep Mode

Page 56: Embedded systems

Features Continue..

• Brown-out Reset (BOR) with software control option

• 33 input/output pins• 8K ROM memory in FLASH technology

– Chip can be reprogrammed up to 1,00,000 times

• In-Circuit Serial Programming Option– Chip can be programmed even embedded in the target

device

• 256 bytes EEPROM memory– Data can be written more than 1,0,00,000 times

• 368 bytes RAM memory

Page 57: Embedded systems

Features Continue..

• A/D converter:– 14-channels– 10-bit resolution

• 3 independent timers/counters• Watch-dog timer• Analogue comparator module with

– Two analogue comparators– Fixed voltage reference (0.6V)– Programmable on-chip voltage reference

• PWM output steering control• Enhanced USART module

– Supports RS-485, RS-232 and LIN2.0– Auto-Baud Detect

• Master Synchronous Serial Port (MSSP)– supports SPI and I2C mode

Page 58: Embedded systems

PIN Diagram

Page 59: Embedded systems

Pin Description

• The most pins are multi-functional.• The fifth pin specifies the following functions

– RA3 Port A third digital input/output– AN3 Third analog input– Vref+ Positive voltage reference– C1IN+ Comparator C1positive input

• trick is often used because it makes the microcontroller package more compact without affecting its functionality.

• These various pin functions cannot be used simultaneously, but can be changed at any point during operation.

Page 60: Embedded systems

Central Processor Unit (CPU)

• The CPU is manufactured with RISC technology

• The CPU can recognizes only 35 simpleinstructions (In order to program some othermicrocontrollers it is necessary to know morethan 200 instructions by heart).

• The execution time is the same for allinstructions except two.

• The Jump and Branch instructions execution timeis 2 instruction cycles.

Page 61: Embedded systems

CPU Continues..

• if the microcontroller’s operating speed is20MHz, execution time of each instruction willbe 200nS, i.e. the program will be executed atthe speed of 5 million instructions per second!

• This microcontroller has three types ofmemory- ROM, RAM and EEPROM.

• ROM memory is used to permanently save theprogram being executed.

• This is why it is often called “programmemory”.

Page 62: Embedded systems

ROM Memory

• The PIC16F887A has 8Kb of ROM (in total of8192 locations).

• This ROM is made with FLASH technology

• Its contents can be changed by providing aspecial programming voltage (13V).

• The program is stored to ICs using simpleelectronic device called the Programmer.

Page 63: Embedded systems

ROM Memory Concept

Page 64: Embedded systems

EEPROM Memory

• Similar to program memory, the contents of EEPROM is permanently saved, even the power goes off.

• However, unlike ROM, the contents of the EEPROM can be changed during operation of the microcontroller.

• That is why this memory (256 locations) is a perfect one for permanently saving results created and used during the operation.

Page 65: Embedded systems

RAM Memory

• RAM Memory consists of two parts: – general-purpose registers

– special-function registers (SFR).

• both groups of registers are cleared when power goes off.

• Their functions do not have many things in common.

Page 66: Embedded systems
Page 67: Embedded systems

General-Purpose Registers• General-Purpose registers are used for storing

temporary data and results created during operation.

• It is necessary to specify the address of some general purpose register and assign it a new function.

Page 68: Embedded systems

SFR Registers• Special-Function registers are also RAM memory

locations.• their purpose is predetermined during

manufacturing process and cannot be changed.• Since their bits are physically connected to particular

circuits on the chip.• Any change of their contents directly affects the

operation of the microcontroller or some of itscircuits.

• For example, by changing the TRISA register, thefunction of each port A pin can be changed in a wayit acts as input or output.

Page 69: Embedded systems

SFR Registers Continues..

• high-level programming language can use the list of all registers with their exact addresses, it is enough to specify the register’s name in order to read or change its contents.

Page 70: Embedded systems

RAM Memory Banks

• The data memory is partitioned into four banks.• Prior to accessing some register during program

writing (in order to read or change its contents),it is necessary to select the bank which containsthat register.

• Two bits of the STATUS register are used for bankselecting.

• the most commonly used SFRs have the sameaddress in all banks which enables them to beeasily accessed.

Page 71: Embedded systems
Page 72: Embedded systems

STACK

• A part of the RAM used for the stack consists of eight13-bit registers.

• Before the microcontroller starts to execute asubroutine (CALL instruction) or when an interruptoccurs, the address of first next instruction beingcurrently executed is pushed onto the stack, i.e. ontoone of its registers.

• In that way, upon subroutine or interrupt execution, themicrocontroller knows from where to continue regularprogram execution.

• This address is cleared upon return to the mainprogram because there is no need to save it any longer

Page 73: Embedded systems

Interrupt System

Page 74: Embedded systems

SFR Registers Continues..

• The special function registers can be classified into two categories:

– Core (CPU) registers.

• control and monitor operation and processes in the central processor.

– Peripheral SFRs

• control the operation of peripheral units (serial communication module, A/D converter etc.).

Page 75: Embedded systems

STATUS Register

RP1 RP0 Active Bank

0 0 Bank0

0 1 Bank1

1 0 Bank2

1 1 Bank3

1 - Banks 0 and 1 are active (memory location 00h-FFh)0 - Banks 2 and 3 are active (memory location 100h-1FFh)

•RP1,RP0 - Bits select register bank. They are used for direct addressing.

IRP - Bit selects register bank. It is used for

indirect addressing.

1 - Banks 0 and 1 are active (memory

location 00h-FFh)

0 - Banks 2 and 3 are active (memory

location 100h-1FFh)

RP1,RP0 - Bits select register bank. They

are used for direct addressing.

Page 76: Embedded systems

PRACTICAL SESSION

• Port programming

• Seven Segment

• LCD

Page 77: Embedded systems