Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

5131 - EMBEDDED SYSTEM & REALTIME OPERATING SYSTEM

MODULE 1

INTRODUCTION
An embedded system is an electronic/ electro-mechanical system designed to perform a specific function
and is a combination of both hardware and firmware (software).
Every embedded system is unique, and the hardware as well as the firmware is highly specialized to the
application domain. Embedded systems are becoming an inevitable part of any product or equipment in
all fields including household appliances, telecommunications, medical equipment, industrial control,
consumer products, etc.

EMBEDDED SYSTEMS VS GENERAL COMPUTING SYSTEMS


Embedded Systems General Computing Systems
A system which is a combination of a A system which is a combination of special purpose
generic hardware and a General Purpose hardware and embedded OS for executing a specific set of
Operating System for executing a variety applications.
of applications.
Contains a General Purpose Operating May or may not contain an operating system for
System (GPOS) functioning.
Applications are alterable (programmable) The firmware of the embedded system is preprogrammed
by the user. and it is non-achievable by the end-users. (There may be
(It is possible for the end user to re-install exceptions for systems supporting OS kernel image flashing
the operating system, and also add or through special hardware settings.)
remove user applications)
Performance is the key deciding factor in Application specific requirements (like performance,
the selection of the system. Always, 'Faster power requirements, memory usage, etc.) are the key
is Better' deciding factors.
Less/ not at all tailored towards reduced Highly tailored to take advantage of the power saving
operating power requirements. Options for modes supported by the hardware anf the operating system.
different levels of power management.
Response requirements are not time- For certain category of embedded systems like mission
critical. critical systems, the response time requirement is highly
critical.
Need not be deterministic in execution Execution behavior is deterministic for certain types of
behavior. embedded systems like ‘Hard Real Time’ systems.

CLASSIFICATION OF EMBEDDED SYSTEMS


Some of the criteria used in the classification of embedded systems are:
1. Based on generation
2. Complexity and performance requirements
3. Based on deterministic behavior
4. Based on triggering
Classification Based on Generation
1. First Generation: The early embedded systems were built around 8 bit microprocessors like 8085
and Z80, and 4bit microcontr0llers. Simple in hardware circuits with firmware developed in Assembly
code. Digital telephone keypads. stepper motor control units etc. are examples of this.

2. Second Generation: These are embedded systems built around 16 bit microprocessors and 8 or 16 bit
microcontrollers, following the first generation embedded systems. The instruction set for the second
generation processors/controllers were much more complex and powerful than the first generation
processors/controllers. Some of the second generation embedded systems contained embedded operating
systems for their operation. Data Acquisition Systems, SCADA systems. etc. are examples of second
generation embedded systems.

3. Third Generation: With advances in processor technology, embedded system developers


started making use of powerful 32 bit processors and 16 bit microcontrollers for their design. A new
concept of application and domain specific processors/controllers like Digital Signal Processors (DSP)
and Application Specific Integrated Circuits (ASICs) came into the picture. The instruction set of
processors became more complex and powerful and the concept of instruction pipelining also evolved.
Processors like Intel Pentium, Motorola 68K, etc. gained attention in high performance embedded
requirements. Dedicated embedded real time and general purpose operating systems entered into the
embedded market. Embedded systems spread its ground to areas like robotics, media, industrial process
control, networking, etc.

4. Fourth Generation: The advent of System on Chips (SoC), reconfigurable processors and multicore
processors are bringing high pcrfom1nnce, tight integration and miniaturization into the embedded device
market The SoC technique implements a total system on a chip by integrating different functionalities
with a processor core on no integrated circuit. The fourth generation embedded systems are making use of
high performance real time embedded operating systems for their functioning. Smart phone devices,
mobile internet devices (MIDs), etc. are examples of fourth generation embedded systems.

Classification Based on Complexity and Performance


1. Small-Scale Embedded Systems: Embedded systems which are simple in application needs and
where the performance requirements are not time critical fall under this category. An electronic toy is a
typical example of a small-scale embedded system. Small-scale embedded systems are usually built
around low performance and low cost 8 or 16 bit microprocessor/microcontrollers. A small-scale
embedded system may or may not contain an operating system for its functioning.
2. Medium-Scale Embedded Systems: Embedded systems which are slightly complex in hardware and
firmware (software) requirements fall under this category. Medium-scale embedded systems are usually
built around medium performance, low cost 16 or 32 bit microprocessors/ microcontrollers or digital
signal processors. They usually contain an embedded operating system (either general purpose or real
time operating system) for functioning.
3. Large-Scale Embedded Systems/Complex Systems: Embedded systems which involve highly
complex hardware and firmware requirements fall under this category. They are employed in mission
critical applications demanding high performance. Such systems ore commonly built around high
performance 32 or 64 bit RISC processors/controllers or Reconfigurable System on Chip (RSoC) or
multi-core processors and programmable logic devices. They may contain multiple processors/ controllers
and co-units/ hardware accelerators for offloading the processing requirements from the main processor
of the system. Decoding/encoding of media, cryptographic function implementation, etc. are examples for
processing requirements which can be implemented using a coprocessor/ hardware accelerator. Complex
embedded systems usually contain a high performance Real Time Operating System (RTOS) for task
scheduling, prioritization and management.

Classification Based on deterministic behavior


The classification based on deterministic system behavior is applicable for 'Real Time' sys1ems.The
application/task execution behavior for an embedded system can be either deterministic or
non­deterministic.

Classification Based on the execution behavior


Based on the execution behavior, Real Time embedded systems are classified into Hard and Soft.
Embedded Systems which are 'Reactive’ in nature (Like process control systems in industrial control
applications} can be classified based on the trigger. Reactive systems can be either event triggered or time
triggered.

APPLICATION OF EMBEDDED SYSTEMS


1. Consumer electronics: Camcorders, cameras, etc.
2. Household appliances: Television, DVD players, washing machine, fridge, microwave oven, etc.
3. Home automation and security systems: Air conditioners, sprinklers, intruder detection alarms,
closed circuit television cameras, fire alarms, etc.
4. Automotive industry: Anti-lock breaking systems (ABS), engine control, ignition systems,
automatic navigation systems, etc.
5. Telecom: Cellular telephones, telephone switches, handset multimedia applications, etc.
6. Computer peripherals: Printers, scanners, fax machines, etc.
7. Computer networking systems: Network routers; switches, bubs, firewalls, etc.
8. Healthcare: Different kinds of scanners, EEG, ECG machines etc.
9. Measurement & instrumentation: Digital multi meters, digital CROs, logic analyzers, PLC
systems, etc.
10. Banking & Retail: Automatic teller machines (ATM) and currency counters, point of sales (POS)
11. Card Readers: Barcode, smart card readers, band held devices, etc.

PURPOSE OF EMBEDDED SYSTEMS


Each embedded system is designed 10 serve the purpose of any one or a combination of the following
tasks:
1. Data collection/Storage/Representation
2. Data communication
3. Data (Signal) processing
4. Monitoring
5. Control
6. Application specific user interface
Data collection/Storage/Representation
Embedded systems designed for the purpose of data collection performs acquisition of data from the
external world. Data collection is usually done for storage, analysis, manipulation and transmission. The
term "data'' refers all kinds of information, viz. text, voice, image. video, electrical signals and any other
measurable quantities. Data can be either analog (continuous) or digital (discrete). Embedded systems
with analog data capturing techniques: collect data directly in the form of analog signals whereas
embedded systems with digital data collection mechanism converts the analog signal to corresponding
digital signal using analog to digital (A/D) converters and then collects the binary equivalent of the analog
data. If the data is digital, it can be directly captured without any additional interface by digital embedded
systems.

Data Communication
Embedded data communication systems are deployed in applications ranging from complex satellite
communication systems to simple home networking systems. The data collected by an embedded terminal
may require transferring of the same to some other systems located remotely. The transmission is
achieved either by a wire-line medium or by a wire­less medium. Wireless medium was the most common
choice in all olden days embedded systems. As technology is changing, wireless medium is becoming the
de-facto standard for data communication in embedded systems. A wireless medium offers cheaper
connectivity solutions and make the communication link free from the hassle of wire bundles. Data can
either be transmitted by analog means or by digital means. Modern industry trends are settling towards
digital communication.

Data (Signal) Processing


The data collected by embedded systems may be used for various kinds of data processing. Embedded
systems with signal process­ing functionalities are employed in applications demand­ing signal
processing like speech coding, synthesis, audio video codec, transmission applications. etc. A-digital
bearing aid is a typical example of an embedded system employing data processing.

Monitoring
Embedded systems falling under this category are specifically designed for monitoring purpose. Almost
all embedded products coming under the medical domain are with monitoring functions only. They are
used for determining the state of some variables using input sensors. They cannot impose control over
variables. A very good example is the electro cardiogram (ECG) machine for monitoring the heartbeat of
a patient. The machine is intended to do the monitoring of the heartbeat. It cannot impose control over the
heartbeat. Some other examples of embedded systems with monitoring function are measuring
instruments like digital CRO, digital multimeters, logic analyzers, etc. used in Control & instrumentation
applications.

Control
Embedded systems with control functionalities impose control over some variables according to the
changes in input variables. A system with control functionality contains both sensors and actuators.
Sensors are connected to the input port for capturing the changes in environmental variable or measuring
variable. The actuators connected to the output port are controlled according to the changes in input
variable to put on impact on the controlling variable to bring the controlled variable to the specified range.
Air conditioner system used in our home to control the room temperature to a specified limit is a typi­cal
example for embedded system for control purpose.

Application Specific User Interface


These are embedded systems with application-specific user interfaces like buttons, switches, keypad,
lights, bells, display units, etc. Mobile phone is an example for this.

CRITERIA FOR CHOOSING A MICROCONTROLLER


Three criteria in choosing microcontrollers are as follows:
1. Meeting the computing needs of the task at hand efficiently and cost effectively.
2. Availability of software and hardware development tools such as compilers, assemblers,
debuggers and emulators.
3. Wide availability and reliable sources of the microcontroller.

1. Meeting the task at hand efficiently and cost effectively


• 8-bit, 16-bit or 32-bit microcontroller.
• Speed.
• Packaging.
• Power consumption.
• Amount of RAM and ROM on the chip.
• The number of I/O pins and the timer on the chip.
• Ease of upgrade to higher performance or lower power consumptions versions.
• Cost per unit.

2. Availability of software and hardware development tools


• Assembler.
• Debugger.
• C Compiler.
• Emulator.
• Technical support.
• In-house and out-house expertise.
• Third party vendor support.

3. Wide availability and reliable sources of the microcontroller


BLOCK DIAGRAM OF AVR MICROCONTROLLER

Data RAM and EEPROM


RAM memory is used for data storage. The maximum size of RAM memory in AVR is 64KB. The data
RAM of AVR contains three components. They are:
• General-purpose registers
• I/O memory
• Internal SRAM
There are 32 general-purpose registers. All are 8 bit wide. The size of I/O memory and SRAM are
variable. It depends on the type of AVR.

I/O Pins
In AVR, there are 3 to 86 pins for I/O. The number of I/O pins depends on the number of pins in the
package.

Peripherals
The standard peripherals included in AVR are ADC, timers and USART. In AVR, the ADC is 10-bit.
Depends on the AVR family, the number of ADC channels varies up to 16. There are up to 6 timers
besides the watchdog timer. Most AVRs have I2C and SPI buses. Some of them have USB and CAN
interface.

DATA MEMORY
There are two kinds of memory space in AVR:
• Code memory space
• Data memory space
Data memory is composed of three parts
• GPRs (general-purpose registers)
• I/O memory
• Internal data SRAM

GENERAL-PURPOSE REGISTERS
CPU uses many registers to store data temporarily. The information could be a byte of data or an address
pointing to the data to be fetched. Majority of AVR registers are 8 bit registers. The only data type that
supports in AVR is 8-bit. Any data larger than 8 bits must be broken into 8-bit chunks before it is
processed.
There are 32 general purpose registers in AVR. They are R0 – R31. These registers are located in the
lowest area of the memory address. All the general purpose registers are 8-bit registers. They are same as
accumulator in other microprocessors. They can be used by all arithmetic and logic instructions.

I/O MEMORY
I/O memory is dedicated to specific functions such as status register, timers, serial communication, I/O
ports, ADC and so on. Function of each I/O memory location is fixed at the time of design because it is
used for control of the microcontroller or peripherals. I/O memory is made of 8 bit registers. All AVRs
have at least 64 bytes of I/O memory. The first 64 bytes of I/O memory is called Standard I/O
memory. AVRs with more than 32 I/O pins have an extended I/O memory – registers for controlling the
extra ports and the extra peripherals. I/O registers are also called Special Function Registers (SFRs).

AVR STATUS REGISTER

The AVR has a flag register called Status Register (SReg), which indicates the arithmetic conditions. It is
an 8 bit register. The flag bits are C, Z, N, V, S, H, T and I. The bits C, Z, N, V, S and H are conditional
flags.

The carry flag will be set (C = 1) if a carry occurred in addition or borrow from a subtraction; otherwise
carry flag is clear (C = 0). Zero flag is set (Z = 1) when the result of the arithmetic operation zero;
otherwise zero flag is clear (Z = 0). Negative flag is set (N = 1) when bit 7 of the previous operation is set
(i.e. the result is negative); otherwise N is cleared. Overflow flag is set (V = 1) whenever the result of a
signed number operation is too large (i.e. causing the high-order bit to overflow into the sign bit). Sign flag
(S) is is the result of Exclusive-ORing of N and V flags. Hal carry flag is set (H = 1) If there is a carry from
D3 to D4 during an ADD or SUB operation; otherwise, it is cleared. This flag bit is used by instructions
that perform BCD (binary coded decimal) arithmetic. The Bit Copy instructions Bit Load (BLD) and Bit
Store (BST) use the T-bit as a source or destination for the operated bit. A bit from a register in the register
file can be copied into T by the BST instruction and a bit in T can be copied into a bit in a register in the
register file by the BLD instruction. The Global Interrupt Enable bit (I) must be set for the interrupts to be
enabled. If the Global Interrupt Enable register is cleared, none of the interrupts are enabled independently
of the individual interrupt enable settings. The I-bit can be set and cleared by the application with the Set
Global Interrupt Flag (SEI) and Clear Global Interrupt Flag (CLI) instructions.

THE PROGRAM COUNTER AND PROGRAM ROM SPACE IN THE AVR


Program Counter
The Program counter is used by the CPU to point to the next instruction to be executed. In AVR
microcontroller each flash location is 2 byte wide. In ATmega32, the flash is 32K, it is organized as 16 x
16, its program counter is 14 bits wide (214 = 16K memory locations).

ROM memory map


The program counter in the AVR can be a maximum of 22 bits wide. So No member in the AVR family can
access more than 4M locations. The first location of program ROM inside the AVR has 000000, the last
location can be different depending on the size of the ROM on the chip.

ROM width in the AVR


The AVR is word addressable. Each location of the address bus is 2 byte wide. The width of the data bus
is 16 bits wide. So two bytes from the code memory can fetch to CPU at a time. The vast majority of the
instructions are 2 byte instructions. This makes instruction fetch in a single cycle. The AVR designers
made all the instructions either 2 byte or 4 byte. There is no 1 byte or 3 byte instructions. So all the AVR
instruction can be fetched either in one cycle or two cycles. The data memory SRAM in the AVR
microcontroller is 8 bit and it is byte addressable.

IO PORTS
The number of ports in the AVR family varies depending on the number of pins on the chip. AtMega32
has four ports. They are PORTA, PORTB, PORTC and PORTD. To use any of these ports as an input or
output port, it must be programmed. In addition to being used as simple I/O, each port has some other
functions such as ADC, timers, interrupts and serial communication pins. Each port has three I/O registers
associated with it as shown in the following table:
Port Address Usage
PORTA 0x3B Output
DDRA 0x3A Direction
PINA 0x39 Input
PORTB 0x38 Output
DDRB 0x37 Direction
PINB 0x36 Input
PORTC 0x35 Output
DDRC 0x34 Direction
PINC 0x33 Input
PORTD 0x32 Output
DDRD 0x31 Direction
PIND 0x30 Input

The port registers are designated as PORTx, DDRx and PINx. For example, for Port B we have PORTB,
DDRB and PINB. DDR stands for Data Direction Register and PIN stands for Port INput. Each of the I/O
registers is 8 bits wide and each port has a maximum of 8 pins. Therefore each bit of the I/O registers
affects one of the pins. The following figure shows the relationship between the registers and the pins:

I/O REGISTERS ASSOCIATED WITH PORTS

DDRx Register
Each of the ports in the AtMega32 can be used for input or output. The DDRx register is used solely for
the purpose of making a given port an input or output port. To make a port an output, We write 1s to the
DDRx register. To make a port an input port, we must put 0s into the DDRx register. Upon reset, all ports
have the value 0x00 in their DDR registers. This means that all ports are configured as input.

PIN Register
To read the data present at the pins, we should read the PIN register. To bring data into CPU from pins we
read the contents of PINx register.
PORT Register
To send data out to pins we use the PORTx register. There is a pull-up resister for each of the AVR pins.
If we put 1s into bits of the PORTx register, the pull-up resisters are activated. In cases in which nothing
is connected to the pin or the connected devices have high impedence, the resister pulls up the pins.

If we put 0s into the bits of the PORTx register, the pull-up resister is inactive. The pins of AVR
microcontrollers can be in four different states according to the values of PORTx and DDRx as shown in
the following figure:

Synchronizer delay
The input circuit of the AVR has a delay of 1 clock cycles. In other words, the PIN register represents the
data that was present at the pins one clock ago.

Port A
Port A occupies a total of 8 pins (PA0 - PA7). To use the pins of Port A as input or output ports, each bit
of the DDRA register must be set to the proper value. The alternate functions of the pins of Port A are:
Bit Function
PA0 ADC0
PA1 ADC1
PA2 ADC2
PA3 ADC3
PA4 ADC4
PA5 ADC5
PA6 ADC6
PA7 ADC7

Port B
Port B occupies a total of 8 pins (PB0 - PB7). To use the pins of Port B as input or output ports, each bit
of the DDRB register must be set to the proper value. The alternate functions of the pins of Port B are:
Bit Function
PB0 XCK/ T0
PB1 T1
PB2 INT2/ AIN0
PB3 OC0/ AIN1
PB4 SS
PB5 MOSI
PB6 MISO
PB7 SCK
Port C
Port C occupies a total of 8 pins (PC0 - PC7). To use the pins of Port C as input or output ports, each bit
of the DDRC register must be set to the proper value. The alternate functions of the pins of Port C are:
Bit Function
PC0 SCL
PC1 SDA
PC2 TCK
PC3 TMS
PC4 TD0
PC5 TD1
PC6 TOSC1
PC7 TOSC2

Port D
Port D occupies a total of 8 pins (PD0 - PD7). To use the pins of Port D as input or output ports, each bit
of the DDRD register must be set to the proper value. The alternate functions of the pins of Port D are:
Bit Function
PD0 PSP0/ C1IN+
PD1 PSP1/ C1IN-
PD2 PSP2/ C2IN+
PD3 PSP3/ C2IN-
PD4 PSP4/ ECCP1/ P1A
PD5 PSP5/ P1B
PD6 PSP6/ P1C
PD7 PSP7/ P1D

You might also like