Sunteți pe pagina 1din 21

Embedded System

Embedded Systems: G P Computer System:


Electronics system that contains contains general purpose (GP)
processor (uP/uC/DSP/ASIP etc.) microprocessor, primary &
and peripherals which is
configured to perform specific secondary memories, keyboards,
dedicated application printer, scanner, monitor etc.

Software embeds in ROM and  Programmed for GP applications


not accessible to the user
that includes word processing,
accounting, scientific computing,
 Mostly designed for time
constrained applications (real time email, multimedia, database system
systems) etc.

either independent system or a  user does have access to


part of larger system.
software and decides which OS to
run and which application to launch.
Characteristics of Embedded Systems
 Single functioned – doing dedicated task repetitively
 Tightly Constrained – area, power, cost
 Reactive and Real time – react to signals
 Dependable (safety critical) system – Flight control, Fire control, Atomic
power plant
 Interacting with harsh physical environment

Design Metrics:
 cost (NRE and unit)
 Time to market
 Power, Performance, Size
 Flexibility
 Maintainability
 Safety and Security
Classification of Embedded Systems
 Small scale
 electronic toy, digital watch, home security system, barcode reader,
data acquisition system, lighting control, elevator control
 Medium scale
 audio/video compression, image processing, digital camera, portable
video games, ATM, TV set top box, medical instruments
 Sophisticated (Cutting edge)
 Smart Phone, High speed routers, Flight control, Sophisticated industrial
control & Automation
 Example (Telegraph) :

 Network Data may be out of order, lost or arrive twice


 Other computers on Network also want to print
 Need to provide status of printer to computers
 It has to work with different type of printer
 It need to respond quickly and keep track of time
 Aspects : correctness, throughput, response, handling uncommon
events
Example (Digital Camera):
Elements of embedded systems

(1) Processors:
 General Purpose Processors : e.g.68HCxxx, intel 80x86, SPARC,
PowerPC
 Enhanced Computing Capability
 Graphics processing

 Microcontrollers : 68HC11xx, 8051 family, PIC series, ARM series


 Moderate Computing but enhanced I/O capability
 On chip Memory, Peripherals and Debug hardware
 Used for => Control and Communication

 DSP : TMS series, SHARC


 Fast Multiply-Accumulate, Multi-access memory, SIMD/MIMD processing
 Digital filtering, Image/Audio processing, Cryptography, Noise shaping

 ASSP/ASIP :
 processor with hardwired logic customized to an application
Elements of embedded systems

(2) Memories:
 ROM variants (masked ROM, OTPROM, EEPROM, FLASHROM):
 Stores firmware (codes for initializing hardware and loading embedded OS),
code for embedded OS and application software

 RAM (SRAM, DRAM, NVRAM):


 Stores variables, temporary results during program run, stack data
 SRAM is common in embedded systems

 On Chip Cache in CPU:


 Small SRAM tightly coupled to CPU
 Contains copies of recently access instructions and data
Elements of embedded systems

(3) Comm. Interfaces:


 On board / On chip => I2C, SPI
 External => RS232, RS485, USB, Ethernet etc.

(4) Other Components:


 Keyboard, LED, LCD, GLCD
 ADC/DAC, PWM, Watchdog timer, RTC etc.
 Sensors
 actuators (motors, relays, valves, solenoids)
Reset and Brown Out Circuits

Reset Circuit Brown Out Circuit


RTC
 Keeps track of real time (seconds, minutes, hour, date, month, year, day of the
week etc.). It has to work in the absence of power (mostly using on chip
battery)
 Alarm mode → RTC interrupts microprocessor when a particular time is
reached
 Periodic interrupt mode → RTC generates interrupt periodically
(Periodic interrupt may be used by embedded OS to perform operations such
as system time update, managing software timers, scheduling periodic tasks
etc.)
 Advanced features of RTC:
 Digital calibration
 Synchronizing RTC
 Low power modes
WATCHDOG TIMER
 It is a hardware timer that monitors the execution of critical part of embedded
software
 In down counting, initially embedded software loads it with count value #n before
executing critical piece of code.
# n is decided considering the worst case delay of this piece of code.
 Under normal conditions, critical piece of software reloads (or resets) watchdog timer
before it gets timed out
 If execution of critical code malfunctioned, behaved abnormally or stuck in loop, the
time out signal is generated.
 The time out signal can be used to reset/interrupt microprocessor
 Thus it rescues system from Erroneous condition by restarting embedded software
(or by jumping to safe part of software)
Embedded software development
System Software in Embedded
 System soft wares : (1) firmware (2) BSP (3) embedded OS or RTOS
[1] Firmware:
 First code that runs upon power on
 Deeply embedded and low level operation
 Typically, it contains code for hardware initialization and loading OS
 For some system, it contains complete software

[2] BSP:
 System software library to that is needed to use hardware board
 BSP a set of libraries (of h/w specific functionalities) that can be accessed
by application software
Device Drivers
 Device Driver is software that communicates with hardware peripherals
 Initializing and configuring hardware peripheral, Interrupt handling and
processing, transmitting/receiving data, handling I/O error etc.
 Low level access – Buffers, Control/Status registers & Flags of I/O chip
 Essential to know hardware interfacing, memory addresses assigned, Interrupt
used etc. to develop driver

 Where are these device drivers ?


 These drivers are in BSP that can be directly used by application software
 These drivers are in specific RTOS. Application can access drivers through
RTOS (indirect access)

 Some drivers come as a part of RTOS kernel (Built in drivers) such as


 Driver for flash memory
 USB, Ethernet, CAN drivers
 On chip Timers, RTC and Cache drivers
RTOS
 RTOS (real time operating system) is one type of embedded OS
 It performs low level operations such as servicing interrupts, managing & servicing
I/O devices (keypad, display, timers, communication ports ..), memory management,
scheduling of tasks (processes) etc.
 RTOS hides system hardware from user/application
 Applications use APIs (system calls) to access RTOS services
 Kernel Mode => Embedded system runs RTOS functions
Memory Organization
 Embedded software contains variables of different storage types: auto,
static, global and constant
 Note that global and static variables maintains updated value

Fixed memory allocation:


 In an application, if quantities have single copy and their size do not vary at
run time then cross compiler can determine memory storage requirement
well in advance. This storage is called fixed allocation.
 Fixed Memory contains => code (instructions), constant data, fixed size
alterable data (static and global variables)
Dynamic memory allocation (in RAM only):
 Heap: Variables can be allocated storage dynamically in heap area at run
time and then de-allocated when requirement is over.
 Stack: is also allocated dynamically at run time for storing local (auto)
variables of functions. However, OS prevents from growing above certain
limit.
Accessing Heap Area
Standard C functions to access heap area:
First we define pointer: char *ptr;
 malloc
e.g. ptr = (char *) malloc (50); or ptr =(char *) malloc(10*sizeof(char));
 Allocates 50 bytes of data (if available in heap) and address of first byte to ptr \.
Initializes data with random values.
 Return is NULL if fails otherwise returns pointer of type void
 realloc
realloc(ptr, 15); // modify allocation already made by malloc or calloc
 Returns pointer of type void if successfully allocated otherwise returns a NULL
 calloc
ptr = (char *) calloc (n, sizeof(int))
 Initializes allocated memory with zero values
 Returns void pointer if successfully allocated otherwise returns a NULL
 Free //free allocated area
free (ptr);
Concept of Process & Thread
Process (or Task) :
 Embedded application software can be thought of as consisting of many processes
 Process is an action of execution of the program.
 Process is defined by its own program code, data and stack
Process & Thread
 When process is created, RTOS allocates memory space and instantiates data
structure called Process Control Block (PCB)
 PCB :- Process Context (Program status word, SP, PC & other CPU registers value),
process ID, Process state, Process priority, pointers to parent and daughter process,
pointer to system resources, pointer to access permission descriptor for sharing
resources globally and with other process
 Context switching
 User mode (application) and Kernel mode (RTOS) processes
 a process can create one or more other processes (referred to as child processes) and
these processes in turn can create child processes to form process tree.

Threads:
 Threads are subunits of a process which may execute simultaneously
 Process may contain multiple threads. All threads of a process run in address space of
same process.
 Have their own PC, stack and registers which are private and never shared
 Advantages:- reduces context switching overhead, multiple control points in a
process, improves responsiveness
Process & Thread

S-ar putea să vă placă și