It_(r22)_3-2_embedded Systems Design Digital Notes
It_(r22)_3-2_embedded Systems Design Digital Notes
ON
EMBEDDED SYSTEMS DESIGN (R22A6904)
For
IT
Prepared by
Mrs. G. Vaidehi
Assistant Professor, Dept. of ECE
(2024-2025)
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
MALLA REDDY COLLEGE OF ENGINEERING & TECHNOLOGY
(Autonomous Institution – UGC, Govt. of India)
(Affiliatedto JNTUH, Hyderabad, Approved byAICTE - Accredited byNBA & NAAC – ‘A’ Grade - ISO 9001:2015 Certified)
Maisammaguda, Dhulapally (Post Via. Hakimpet), Secunderabad – 500100, Telangana State, India
MALLAREDDYCOLLEGEOFENGINEERING&TECHNOLOGY
UNIT-I:
INTRODUCTION TO MICROCONTROLLERS:
8051 Microcontroller:
Overview of 8051 Microcontroller, 8051 Architecture, Pin diagram, Memory Organization,
Addressing Modes, and Instruction setof8051.
Arduino: Overview of Arduino, Introduction to ATMEGEA 328P, Arduino board. Introduction
Arduino Programming: Setup (), loop (), Digital Read (), Digital Write ()
AnalogRead(), AnalogWrite().
UNIT-III: TYPICAL EMBEDDED SYSTEM: Core of the embedded system, Sensors and
actuators, Onboard communication interfaces-I2C,SPI,parallel interface;External communication
interfaces-RS232,USB,infrared,Bluetooth,Wi-Fi,ZigBee,GPRS.
TEXTBOOKS:
1. Introduction to Embedded Systems-shibukv, McGraw Hill Education.
2. Kenneth. J.Ayala, The 8051 Microcontroller, 3rd Edition Cengage Learning
REFERENCEBOOKS:
1. The 8051 Microcontroller and Embedded Systems Second Edition Muhammad Ali
Mazidi Janice GillispieMazidiRolin D. McKinlay
2. Embedded Systems- An integrated approach - Lyla B Das, Pearsoneducation2012.
COURSEOUTCOMES:
After going through this course, the student will be able to
1. The student will learn the internal organization of popular 8051 microcontrollers.
2. Understand the core of the embedded systems
3. Understand the internal and external communication interface
4. Understand Embedded Firmware design approaches
5. Understand embedded programming concepts
Unit-1
CONTENTS
INTRODUCTION TO MICROCONTROLLERS:
8051 Microcontroller:
Overview of 8051 Microcontroller
8051 Architecture
Pin diagram
Memory Organization
Addressing Modes
Instruction setof8051.
Arduino:
Overview of Arduino.
Introduction to ATMEGEA 328P.
Arduinoboard:Introduction
Arduino Programming:
Setup (), loop (), Digital Read (), Digital Write () AnalogRead (), Analog Write ().
Introduction
THE 8086 MICROPROCESSOR:
A microprocessor is an electronic component that is used by a computer to do its work. It is a central
processing unit on a single integrated circuit chip containing millions of very small components
including transistors, resistors, and diodes that work together. An Integrated circuit that contains all
the functions of a central processing unit (CPU) of a computer is called Microprocessor.
• Instruction Queue
• Segment Registers
• Control Unit
A microcontroller is a highly integrated single chip, which consists of on chip CPU (Central
Processing Unit), RAM (Random Access Memory), EPROM/PROM/ROM (Erasable
Programmable Read Only Memory), I/O (input/output) Ports – serial and parallel, timers,
interrupt controller etc..
The 8051 microcontroller is a very popular 8-bit microcontroller introduced by Intel in the
year 1981
8051 is one of the first most popular microcontroller also known as MCS-51
It is an 8-bit microcontroller which means data bus is of 8-bits. Therefore, it can process 8-
bits at a time. It is used in wide variety of embedded systems like robotics, remote controls,
automotive industry, telecom applications, power tools etc.
These microcontrollers were named as 80C51, where C in the name tells that it is based on
CMOS technology.
Development/Classification of microcontrollers
Development of some popular microcontrollers is given as follows.
Difference betweenMicroprocessorandMicrocontroller:
3 Memory and I/O has to be connected Memory and I/O are already present,
externally, so the ciruit becomes and the internal circuit is small
large.
4 You can’t use it in compact systems You can use it in compact systems
6 Cost of the entire system is high Cost of the entire system is low
7 Due to external components, the total As external components are low, total
power consumption is high. power consumption is less. So it can be
Therefore, it is not ideal for the used with devices running on stored
devices running on stored power like power like batteries.
batteries.
10 It’s complex and expensive, with a It’s simple and inexpensive with less
large number of instructions to number of instructions
process. to process.
Features of 8051Microcontroller:
Eight-bit CPU with registers A (the accumulator) and B
8-bit data bus and 16-bit address bus
Eight-bit program status word (PSW)
Eight-bit stack pointer (SP)
Four register banks, each containing eight registers
4 KB on chip program memory (ROM or EPROM)).
128 bytes on chip data memory(RAM).
Two -16 bit timers T0 and T1
Five Interrupts (3 internal and 2 external).
Four Parallel ports each of 8-bits (PORT0, PORT1,PORT2,PORT3) with a total of 32 I/O
lines.
One 16-bit program counter and One 16-bit DPTR ( data pointer).
ROM (on- 4 KB 4 KB 0 KB
chip)
Number of 2 3 2
Timer
Interrupt 6 8 6
Sources
Serial Port 1 1 1
Number of 32 32 32
I/O Ports
8031
8031 is referred to as ROM-less microcontroller chip because it has 0 K byes of on-chip ROM. For
it’s operation, 8031 requires external ROM which aids it in fetch and execute operations. Apart from
this, it shares almost all the features of 8051
4. Memory
The next part of the 8051 microcontroller architecture is the memory. For any data manipulation to
occur, we require a set of instructions.
A program is a set of commands, which is needed by the Microcontroller to perform a
particular task. These programs need a storage space where they can be stored and later the
microcontroller interpret them and perform the specific task.
8051 microcontroller architecture include two types of memory, such as : program memory
and data memory.
The instructions of the CPU are stored in the Program Memory. It is usually implemented as
Read-Only Memory or ROM, where the Program written into it will be retained even when
the power is down or the system is reset.
Data Memory in a Microcontroller is responsible for storing values of variables, temporary
data, intermediate results, and other data for the proper operation of the program.
In the 8051 microcontroller architecture, the microcontroller has 4KB ROM and 128 bytes of
RAM.
5. Bus
A bus is a group of wires. Communication within the microcontroller happens through this bus. There
are either 8 or 16 or more wires in the bus. If the 8051 microcontroller architecture has 8 wires, it can
carry 8 bits of data. If the 8051 microcontroller architecture has 16 wires, it can carry16 bits of data.
The bus further falls into two categories:
Address Bus: The address bus in the 8051 microcontroller architecture is of 16 bits. This bus transfers
data from the CPU to the memory. There are different addressing modes in this bus:
Immediate addressing modes.
Register addressing mode.
Direct Addressing mode.
Register indirect addressing mode.
Data Bus: In 8051 microcontroller architecture, the data bus is 8 bits. It helps in carrying the
data from one place to another.
6. Input/output Ports
A microcontroller controls small operations for a system. It is embedded in the systems. We
might sometimes need to connect the microcontroller to other devices. In the 8051
microcontroller architecture, we have 4 input/output ports. We connect other input/output
peripherals using these ports.
All the 4 ports function bidirectionally i.e., either input or output according to the software
control.
7. Timers/Counters
In the 8051 microcontroller architecture, we have two timers. They are each 16 bits. We have
the timers to generate gaps between two events. The two timers generate two delays(gaps),
and the suitable one is chosen.
The timer produces the delay according to the demand of the processor and sends the signal to
the processor once the respective delay gets produced.
Microcontroller 8051 is incorporated with two 16 bit counters & timers. The counters are
separated into 8-bit registers. The timers are utilized for measuring the intervals, to find out
pulse width, etc.
The microcontroller also includes a program counter, data pointer, stack & stack pointer, instruction
registers including latches, temporary registers & buffers for the I/O ports.
8. A and B Registers: The A and B registers are special function registers which hold the results of
many arithmetic and logical operations of 8051
A register is also called the Accumulator and as its name suggests, is used as a general register to
accumulate the results of a large number of instructions
9. The R registers: The "R" registers are a set of eight registers that are named R0, R1, etc. up to
and including R7.
These registers are used as auxiliary registers in many operations.
The "R" registers are also used to temporarily store values.
10. STACK in 8051 Microcontroller
The stack is a part of RAM used by the CPU to store information temporarily. This information
may be either data or an address
In 8051 the RAM locations 08 to 1F (24 bytes) can be used for the Stack
The register used to access the stack is called the Stack pointer which is an 8-bit register.
There are two important instructions to handle this stack. One is the PUSH and the other is the
POP.
The loading of data from CPU registers to the stack is done by PUSH and the loading of the
contents of the stack back into a CPU register is done by POP.
11. Stack Pointer (SP)
Stack Pointer (SP) – it contains the address of the data item on the top of the stack. Stack may reside
anywhere on the internal RAM. On reset, SP is initialized to 07 so that the default stack will start from
address 08 onwards.
12. Data Pointer Register (DPTR) :
It is a 16-bit register which is the onlyuser-accessible.
DPTR, as the name suggests, is used to point to data.
It is used by a number of commands which allow the 8051 to access external memory.
When the 8051 accesses external memory it will access external memory at the address
indicated by DPTR.
This DPTR can also be used as two 8-registers DPH and DPL
Data Pointer (DPTR) – DPH (Data pointer higher byte), DPL (Data pointer lower byte).
13. PSW (Program Status Word)
The program status word (PSW) register is an 8-bit register. It is also referred to as the flag register.
Although the PSW register is 8 bits wide, only 6 bits of it are used by the 8051.The two unused
bits are user-definable flags.
Four of the flags are called conditional flags, meaning that they indicate some conditions that
result after an instruction is executed. These four are CY (carry), AC (auxiliary carry), P (parity),
and OV (overflow).
As seen from below figure, the bits PSW.3 and PSW.4 are designated as RS0 and RS1 as register
selection bit, respectively, and are used to change the bank registers.
The PSW.5 and PSW.l bits are general-purpose status flag bits and can be used by the programmer
for any purpose. In other words, they are user definable. See below Figure for the bits of the PSW
register
Port 1: The pins in this port are bi-directional and can be used for input and output. The pins are
individually controlled; some are used for input while others are used for output purposes.
Pin 9
This pin is also called ‘Reset Pin’. This is used for resetting the microcontroller to its initial values.
If the pin is set at logic 0, the chip runs normally. When the oscillator is running, setting the pin at
logic 1 for more than two machine cycles will reset the microcontroller.
PORT 3: These pins are same as pins in port 1 because of their bidirectional input port.
Pin 10 and Pin 11 perform receiving and transmitting operation of serial data using ‘RS-
232’ protocol.
Pin 12 and Pin 13 are used to interrupt inputs.
Pin 14 and Pin 15 perform alternative functions linked with Timer 0 and Timer 1.
Pin 16 and Pin 17 are used when working with external memory.
The pins are used for connecting an external crystal oscillator module with the microcontroller.
Pin 20
Also called Vss. This is the ground pin that represents 0V.
PORT 2: These are another set of bidirectional input port, they are used when processing external
memory. Higher order address bus signals are multiplexed with this quasi-bidirectional port.
Pin 29
Also called PSEN (Program Store Enable) it controls and manages the access to external CODE
memory.
Pin 30
Named as Address Latch Enable (ALE). It is used when working with external memory. ALE
activity is disabled in some devices where external memory is not used. Thus helping in reducing
the electromagnetic interference generated by the product.
Pin 31
Named as External Access (EA). In order to execute code from internal memory this pin is
connected to Vcc. To execute code from external memory the pin must be grounded.
Port 0: These are set of another bidirectional input port. Unlike Port 1, Port2 and Port 3 this port
lacks pull-up resistors.
Pin 40
I/O Pins
The 8051 microcontrollers are mostly 8-bit ports, thus giving a total of 32 pins which you can use
to read input and control output. All of them are bidirectional in nature so they can perform as both
input and output. Some of the ports perform alternate functions as discussed above such as to
support access to external memory. This is done to reduce the size of the microcontroller device.
When these ports are busy in performing their alternate functions, they can not be made toact as
input-output ports.
Memory organization :
The 8051 microcontroller has 128 bytes of Internal RAMand 4kB of on chip ROM .The RAM is
also known as Data memory and the ROM isknownasprogrammemory.
The Program Memory or ROM is a type of non-volatile memory used in microcontrollers where
the code or the program to be executed is stored using the program counter (PC), like tables or
initialization program.
Intel 8051 has an internal/ built-in ROM of 4KB and can be extended up to 64KB by using an
external program memory. The program memory allocation can be done in two ways depending
on the status of the EA pin (External Access Pin), which is an active low pin (i.e., activates when
low-signal is provided).
Program memory:
b) If EA is low, only external program memory accessed from 0000H to FFFFH memory locations.
The Data Memory or RAM is a volatile memory since cutting off power to the IC will result in loss
of information or data. RAM is used for temporarily storing the data and the auxiliary results
generated during the runtime.
Older version of 8051 used to consist built-in 256 bytes of RAM now, and it consists of an
additional 128 bytes, which are accessed by indirect addressing.
1. Lower 128 bytes (00H – 7FH), which are addressed b either Direct or Indirect addressing.
Further, the Lower 128 bytes are divided into three parts,
2. Upper 128 bytes (80H – 0FFH) for the Special Function Register (SFRs) which includes I/O
ports (P0, P1, P2, P3), Accumulator (A), Timers(THx, TLx, TMOD, TCON, PCON), Interrupts(IE,
IP), Serial Communication controls(SBUF, SCON), Program Status Word (PSW). These are
addressed using Direct addressing.
Register Banks:
The 8051 has four Register Banks with each bank having 8 “R” registers, which are used in many
of its instructions. These R registers are numbered from 0 through 7 (R0, R1, R2, R3, R4, R5, R6,
and R7). These registers are generally used to assist in manipulating values and moving data from
one memory location to another. For example, to add three numbers say, 0AH, 0BH, 0CH, we
would execute the following instruction:
These banks are accessed one at a time by bit addressing of D3 and D4 bits of PSW (Program Status
Word) SFR by changing the values of RS0 and RS1 by SETB, and CLR commands. For example,
“SETB PSW.3” will set PSW.3 = 1, and Bank 1 register is selected. By default, Bank 0 is selected.
16 bytes of bit addressable areaand
80 bytes of general purpose area (Scratch pad memory) as shown in the diagram below.
This area is also utilized by the microcontroller as a storage area for the operating stack.
The registers are named as R0-R7 .Each register can be addressed by its name or by its
RAM address.
16 bytes of RAM is allotted as a bit addressable memory. It consists of 16 x 8 = 128 bits. These
128 bits can be individually bit-addressed, starting from 00H to 7FH or can be byte-addressable for
20H to 2FH.
Bit addressing is very useful when we want to monitor the status of a particular pin of any port.
The rest of the RAM from 30H to 7FH, these 32 bytes can be addressed directly or indirectly using
direct or indirect addressing modes, respectively. Therefore it’s also called Scratch Pad Memory.
You may read or write a full byte (8-bit) data at these locations.
Example:-
MOV A, # 82H ; load 82H into A
MOV R4, # 100 ; load the decimal value 100 in to R4
MOV B, # 40H ; load 40H in to B
MOV P1, # 55H ; load 55H directly to port 1
MOV DPTR , # 4521 H ; DPTR =4521 H
In Register Addressing mode, one of the eight registers (R0 – R7) is specified as Operand in the
Instruction.
It is important to select the appropriate Bank with the help of PSW Register.
Example:-
MOV A,RO ;copy the contents of R0 in to A
MOV R2,A ;copy the contents of A in to R2
ADD A,R5 ;Add contents of R5 to A
MOV R7,DPL ;load R7 with contents of DPL
Based on the operation they perform, all the instructions in the 8051 Microcontroller Instruction Set
are divided into five groups. They are:
1. Arithmetic Instructions:
Using Arithmetic Instructions, you can perform addition, subtraction, multiplication and division.
The arithmetic instructions also include increment by one, decrement by one and a special
instruction called Decimal Adjust Accumulator.
Fo rexample:
ADDA, R1-Theresult of addition(A+R1) will be stored in the accumulator.
ADD-Addition Operation
ADDC-Addition with Carry
SUB-Subtract operation
SUBB-Subtract with Barrow
MUL-Multiplication Operation
DIV-Divison Operation
INC -Incrementing by one
DEC-Decreamenting by one
2. Logical Instructions: The Logical Instructions are used toperform logical operationslikeAND,
OR, XOR, NOT, Rotate, Clear and Swap. Logical Instruction are performed on Bytes of data
ona bit-by-bit basis. Logic instructions perform logic operations upon corresponding bits of
two registers. After execution, the result is stored in the first operand.
ANL-Logical AND Operation
ORL-Logical OR operation
XRL-Logical Exclusive Operation
CPL-Complement Operation
RL-Rotate Left Operation
RLC-Rotate Left Through Carry
RC-Rotate Right Operation
RRC-Rotate Right Through Carry
3. Data Transfer Instructions: Data transfer instructions move the content of one register
toanother. The register the content of which is moved remains unchanged. If they have the suffix
“X”(MOVX),thedatais exchangedwithexternal memory.
4. Boolean Variable Instructions: Boolean or Bit Manipulation Instructions will deal with bit
variables. Similar to logic instructions, bit oriented instructions perform logic operations. The
difference is that these are performed upon single bits.
Consider the below table lists the conditional jumps instruction used in 8051
Instructions Action
JC Jump if CY = 1
JNC Jump if CY ≠ 1
JB Jump if bit = 1
JZ Jump if A = 0
Arduino UNO
Arduino UNO is a basic and inexpensive Arduino board and is the most popular of all the Arduino
boards with a market share of over 50%. Arduino UNO is considered to be the best prototyping board
for beginners in electronics and coding.
Arduino UNO comes with different features and capabilities. As mentioned earlier, the microcontroller
used in UNO is ATmega328P, which is an 8-bit microcontroller based on the AVR architecture.
UNO has 14 digital input – output (I/O) pins which can be used as either input or output by connecting
them with different external devices and components. Out of these 14 pins, 6 pins are capable of
producing PWM signal. All the digital pins operate at 5V and can output a current of 20mA.
60
Arduino hardware is a PCB-mounted microcontroller that you can program and use for simple daily
tasks, mathematical computations, and prototyping and testing. An Arduino development board
consists of the core microcontroller with its supplementary components and the necessary circuitry to
communicate with the PC which we will be using for both communications as well as programming the
microcontroller.
For communication or programming purposes, we will be using a USB to TTL converter, which will
be embedded within the Arduino board.
Arduino block diagram shows the important modules on an Arduino UNO board.
In the UNO board, the main component is the ATMega328P. It is the heart of the Arduino UNO.
61
Arduino UNO-Pin diagram
Arduino board can be powered byusing the USB cable from your computer. All you need to do is
connect the USB cable to the USB connection (1).
Arduino boards can be powered directly from the AC mains power supply by connecting it to the
Barrel Jack (2).
Voltage Regulator
The function of the voltage regulator is to control the voltage given to the Arduino board and
stabilize the DC voltages used by the processor and other elements.
Crystal Oscillator
The crystal oscillator helps Arduino in dealing with time issues. How does Arduino calculate time?
The answer is, by using the crystal oscillator. The number printed on top of the Arduino crystal is
16.000H9H. It tells us that the frequency is 16,000,000 Hertz or 16 MHz.
Arduino Reset
You can reset your Arduino board, i.e., start your program from the beginning. You can reset the
UNO board in two ways. First, by using the reset button (17) on the board. Second, you can connect
an external reset button to the Arduino pin labeled RESET (5).
62
Most of the components used with Arduino board works fine with 3.3 volt and 5 volt.
GND (8)(Ground) − There are several GND pins on the Arduino, any of which can be used to ground
your circuit.
Vin (9) − This pin also can be used to power the Arduino board from an external power source, like AC
mains power supply.
Analog pins
The Arduino UNO board has six analog input pins A0 through A5. These pins can read the signal from
an analog sensor like the humidity sensor or temperature sensor and convert it into a digital valuethat
can be read by the microprocessor.
Main microcontroller
Each Arduino board has its own microcontroller (11). You can assume it as the brain of your board. The
main IC (integrated circuit) on the Arduino is slightly different from board to board. The
microcontrollers are usually of the ATMEL Company. You must know what IC your board has before
loading up a new program from the Arduino IDE. This information is available on the top of the IC.
ICSP pin
Mostly, ICSP is an AVR, a tiny programming header for the Arduino consisting of MOSI, MISO, SCK,
RESET, VCC, and GND. It is often referred to as an SPI (Serial Peripheral Interface), which could be
considered as an "expansion" of the output. Actually, you are slaving the output device to the master of
the SPI bus.
This LED should light up when you plug your Arduino into a power source to indicate that your board
is powered up correctly. If this light does not turn on, then there is something wrong with the connection.
TX and RX LEDs
On your board, you will find two labels: TX (transmit) and RX (receive). They appear in two places
on the Arduino UNO board. First, at the digital pins 0 and 1, to indicate the pins responsible for serial
communication. Second, the TX and RX led (13). The TX led flashes with different speed while sending
the serial data. The speed of flashing depends on the baud rate used by the board. RX flashes during the
receiving process.
Digital I/O
The Arduino UNO board has 14 digital I/O pins (of which 6 provide PWM (Pulse Width Modulation)
output. The pins 0 to 13 are used as a digital input or output for the Arduino board. These pins can be
configured to work as input digital pins to read logic values (0 or 1) or as digital output pins to drive
different modules like LEDs, relays, etc.
External Interrupt Pins: This pin of the Arduino board is used to produce the External interrupt
and it is done by pin numbers 2 and 3.
63
PWM Pins: This pins of the board is used to convert the digital signal into an analog by varying the
width of the Pulse. The pin numbers 3,5,6,9,10 and 11 are used as a PWM pin.
SPI Pins: This is the Serial Peripheral Interface pin, it is used to maintain SPI communication with the
help of the SPI library. SPI pins include:
AREF Pin: This is an analog reference pin of the Arduino board. It is used to provide a reference voltage
from an external power supply.
Applications
64
ATMega328 Pinout Configuration
ATMEGA328P is a 28 pin chip as shown in pin diagram above. Many pins of the chip here have more
than one function. We will describe functions of each pin in below table.
1 PC6 (RESET) Pin6 of Pin by default is used as RESET pin. PC6 can only
PORTC be used as I/O pin when RSTDISBL Fuse is
programmed.
65
4 PD2 (INT0) Pin2 of External Interrupt source 0
PORTD
66
14 PB0 (ICP1/CLKO) Pin0 of ICP1(Timer/Counter1 Input Capture Pin)
PORTB
16 PB2 (SS/OC1B) Pin2 of SS (SPI Slave Select Input). This pin is low when
PORTB controller acts as slave.
[Serial Peripheral Interface (SPI) for
programming]
19 PB5 (SCK) Pin5 of SCK (SPI Bus Serial Clock). This is the clock
PORTB shared between this controller and other system for
accurate data transfer.
[Serial Peripheral Interface (SPI) for
programming]
67
21 AREF Analog Reference Pin for ADC
22 GND GROUND
68
The program or code written in the Arduino IDE is often called as sketching. We need to connect the
Genuino and Arduino board with the IDE to upload the sketch written in the Arduino IDE software. The
sketch is saved with the extension '.ino.
Toolbar Button
The icons displayed on the toolbar are New, Open, Save, Upload, and Verify
It is shown below:
Upload
The Upload button compiles and runs our code written on the screen. It further uploads the code to the
connected board. Before uploading the sketch, we need to make sure that the correct board and ports are
selected.
We also need a USB connection to connect the board and the computer. Once all the above measures
are done, click on the Upload button present on the toolbar.
69
Open
The Open button is used to open the already created file. The selected file will be opened in the current
window.
Save
New
Verify
The Verify button is used to check the compilation error of the sketch or the written code.
Serial Monitor
The serial monitor button is present on the right corner of the toolbar. It opens the serial monitor.
Arduino Functions
The functions allow a programmer to divide a specific code into various sections, and each section
performs a particular task. The functions are created to perform a task multiple times in a program.
The function is a type of procedure that returns the area of code from which it is called.
For example, to repeat a task multiple times in code, we can use the same set of statements every time
the task is performed.
Let's discuss some advantages of using functions in programming, which are listed below:
70
BUILT IN FUNCTIONS
The Arduino programming language comes with a huge array of built in functions that are useful for
all of our projects. These built in functions allow us to save time on the programming side of our builds.
We don't have to spend time developing our own functions, we can just use the ones that are provided.
The Arduino has two common functions setup() and loop(), which are called automatically in the
background. The code to be executed is written inside the curly braces within these functions.The
Arduino void setup and void loop functions are mandatory.
Void setup ()
void setup() - It includes the initial part of the code, which is executed only once. It is called as
the preparation block.
As the void setup function is called only once at the very beginning of the program, this will be the
place to:
Depending on the complexity of your program, you may have a lot of instructions to write in that void
function. You can create new functions that you call from the void setup, no problem with that.
void loop() - It includes the statements, which are executed repeatedly. It is called the execution
block.
Now, in the void loop you’ll write your main program, knowing that the initialization is already done.
In this function, always keep in mind that the last line is followed by the first line!
Also, any variable you’ve declared inside the void loop will be lost when the program exits and enters
the function again. So, if you want to be able to keep data between 2 void loop, make sure to declare
variables in a more global scope.
As for void setup, there’s no need to write all the code directly in the function. You can create as many
other functions as you want (and classes too), and call those functions in the void loop. Ideally, the void
loop should contain just a few lines calling other functions.
71
DIGITALWRITE ()
The digital Write () function is used to control the voltage that is output from a digital pin on the
Arduino board. This is usually written in the loop() function of a sketch.
Syntax:
digitalWrite(pin, value)
Parameters:
pin: the pin number to be used
value: HIGH or LOW
When reading or writing to a digital pin there are only two possible values a pin can take/be-set-
to: HIGH and LOW. If the pin has been configured as an OUTPUT with pinMode(), its voltage will be
set to 5 volts for HIGH and 0 volts for LOW.
Example:
int ledPin = 13; // LED connected to digital pin 13
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for a second
}
DIGITALREAD ()
The digital Read () function reads the value from a specified digital pin, either HIGH or LOW. It will
read voltage connected to the digital pin as either HIGH or LOW, on or off.
Syntax:
digitalRead(pin)
Parameters:
pin: the number of the digital pin you want to read (int)
Example:
Sets pin 13 to the same value as pin 7, declared as an input.
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output
72
pinMode(inPin, INPUT); // sets the digital pin 7 as input
}
void loop()
{
val = digitalRead(inPin); // read the input pin
digitalWrite(ledPin, val); // sets the LED to the button's value
}
DELAY()
Pauses the program for the amount of time (in miliseconds) specified as parameter. (There are 1000
milliseconds in a second.)
Syntax:
delay(ms)
Parameters:
ms: the number of milliseconds to pause.
ANALOGWRITE ():
Writes an analog value (PWM wave) to a pin. Can be used to light a LED at varying brightness’s or
drive a motor at various speeds. After a call to analogWrite(), the pin will generate a steady square
wave of the specified duty cycle until the next call to analogWrite(). On the Arduino UNO, analog
pins 0 - 5, digital pins 11, 10, 9, 6, 5, 3 and use the analogWrite() function
Syntax:
analogWrite(pin, value)
Parameters:
pin: the pin to write to.
value: the dutycycle: between 0 (always off) and 255 (always on).
Example:
This example sets the output to the LED proportional to the value read from the potentiometer. Tjhis
will allow us to control the brightness of an LED using a potentiometer.
void setup()
{
pinMode(ledPin, OUTPUT); // sets the pin as output
}
void loop()
{
val = analogRead(analogPin); // read the input pin
analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to
255
}
73
ANALOGREAD ():
Reads the value from the specified analog pin. It will map input voltages between 0 and 5 volts into
integer values between 0 and 1023.
Syntax:
analogRead(pin)
Parameters:
pin: the number of the analog input pin to read from (0 to 5 on most boards)
Returns:
int (0 to 1023)
Example:
This example reads a value from a potentiometer.
void setup()
{
Serial.begin(9600); // setup serial
}
void loop()
{
val = analogRead(analogPin); // read the input pin
Serial.println(val); // debug value
}
Description
Built In function
This function is called once, when the program
starts, and when the Arduino is shut down and
setup() restarted.
This function is repeatedly called while the
Arduino program is running.
loop()
Reads the value from a digital pin. Accepts a pin
number as a parameter, and returns
digitalRead() the HIGH or LOW constant.
Writes a HIGH or LOW value to a digital output
pin. You pass the pin number
digitalWrite() and HIGH or LOW as parameters.
Sets a pin to be an input, or an output. You pass
the pin number and
pinMode() the INPUT or OUTPUT value as parameters.
74
Reads the value from an analog pin.
analogRead()
writes an analog value to a pin
analogWrite()
pauses the program for a number of
milliseconds specified as parameter
delay()
Your first Arduino program will surely involve making a led turn on the light, and then
turn off.
75
UNIT-II
INTRODUCTION TO EMBEDDED SYSTEMS
EMBEDDED SYSTEM:
An Electronic/Electro mechanical system which is designed to perform a specific function
and is a combination of both hardware and firmware (Software)
EXAMPLES:
Electronic Toys,
Mobile Handsets,
First Recognized Modern Embedded System: Apollo Guidance Computer (AGC) developed
by Charles Stark Draper at the MIT Instrumentation Laboratory. It has two modules
60
Embedded Systems Vs General Computing Systems:
First Generation: The early embedded systems built around 8-bit microprocessors
like 8085 and Z80 and 4-bit microcontrollers with simple hardware and firmware.
61
Second Generation: Embedded Systems built around 16-bit microprocessors and 8
Third Generation: Embedded Systems built around high performance 16/32 bit
Microprocessors/controllers, Application Specific Instruction set processors like
Digital Signal Processors (DSPs), and Application Specific Integrated Circuits
(ASICs).The instruction set is complex and powerful.
Small Scale:
The embedded systems built around low performance and low cost 8 or 16 bit
microprocessors/ microcontrollers. It is suitable for simple applications and
where performance is not time critical. It may or may not contain OS.
washing machine.
Oven.
Automatic Door Lock.
Motion Controlled Home Security System.
Keyboard controller.
CD Drive.
fax machine.
Medium Scale:
Embedded Systems built around medium performance, low cost 16- or 32-bit
microprocessors / microcontrollers or DSPs. These are slightly complex in hardware and
firmware. It may contain GPOS/RTOS.Various examples of medium scale embedded
62
systems are routers for networking, ATM (is. Automated Teller Machine for bank
transactional machines etc.
Large Scale/Complex:
Embedded Systems built around high performance 32- or 64-bit RISC
processors/controllers, RSoC or multi-core processors and PLD.
It requires complex hardware and software.
This system may contain multiple processors/controllers and co-units/hardware
accelerators for offloading the processing requirements from the main processor.
Event Triggered: Activities within the system (e.g., task run-times) are dynamic and depend
upon occurrence of different events.
Time triggered: Activities within the system follow a statically computed schedule (i.e., they
are allocated time slots during which they can take place) and thus by nature are predictable.
63
Banking & Retail: Automatic Teller Machines (ATM) and Currency counters,
Point of Sales (POS)
Card Readers: Barcode, Smart Card Readers, Hand held Devices etc.
Data Collection/Storage/Representation
Performs acquisition of data from the external world. The data may be text, audio, video or
any physical quantities. The collected data can be either analog or digital. Data collection is
usually done for storage, analysis, manipulation and transmission. The collected data may be
stored directly in the system or may be transmitted to some other systems or it may be
processed by the system or it may be deleted instantly.
64
Data Communication:-
Embedded Data communication systems are deployed in applications ranging from complex
satellite communication systems to simple home networking systems. Embedded Data
communication systems are dedicated for data communication. The data communication can
happen through a wired interface (like Ethernet, RS-232C/USB/IEEE1394 etc) or wireless
interface (like Wi-Fi, GSM,/GPRS, Bluetooth, ZigBee etc)
Network hubs, Routers, switches, Modems etc are typical examples for dedicated data
transmission embedded systems
65
4. Monitoring:-
Embedded systems coming under this category are specifically designed for monitoring
purpose. They are used for determining the state of some variables using input sensors.They
cannot impose control over variables. Measuring instruments like Digital CRO, Digital Multi
meter, Logic Analyzer etc used in Control & Instrumentation applications are also examples of
embedded systems for monitoring purpose. Electro Cardiogram (ECG) machine for monitoring
the heartbeat of a patient is a typical example for this. The sensors used in ECG are the different
Electrodes connected to the patient’s body
5. Control:
Embedded systems with control functionalities are used for imposing control over some
variables according to the changes in input variables. Embedded 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 an impact on
the controlling variable to bring the controlled variable to the specified range
Air conditioner for controlling room temperature is a typical example for embedded
system with „Control‟ functionality
66
Air conditioner contains a room temperature sensing element (sensor) which may be a
thermistor and a handheld unit for setting up (feeding) the desired temperature.The air
compressor unit acts as the actuator. The compressor is controlled according to the current
room temperature and the desired temperature set by the end user.
Embedded systems possess certain specific characteristics and these are unique to each
Embedded system.
Distributed
Power concerns
Each E. S has certain functions to perform and they are developed in such a manner to do the
intended functions only. They cannot be used for any other purpose.
Ex – The embedded control units of the microwave oven cannot be replaced with AC’s
embedded control unit because the embedded control units of microwave oven and AC are
specifically designed to perform certain specific tasks.
E.S are in constant interaction with the real world through sensors and user-defined input
devices which are connected to the input port of the system. Any changes in the real world are
captured by the sensors or input devices in real time and the control algorithm running inside
the unit reacts in a designed manner to bring the controlled output variables to the desired level.
E.S produce changes in output in response to the changes in the input, so they are referred as
reactive systems.
Real Time system operation means the timing behavior of the system should be deterministic
i.e the system should respond to requests in a known amount of time.
67
Example – E.S which are mission critical like flight control systems, Antilock Brake Systems
(ABS) etc are Real Time systems.
The design of E.S should take care of the operating conditions of the area where the system is
going to implement. Ex – If the system needs to be deployed in a high temperature zone, then
all the components used in the system should be of high temperature grade.Also proper shock
absorption techniques should be provided to systems which are going to be commissioned in
places subject to high shock.
4. Distributed: –
It means that embedded systems may be a part of a larger system. Many numbers of such
distributed embedded systems form a single large embedded control unit.
Ex – Automatic vending machine. It contains a card reader, a vending unit etc. Each of them
are independent embedded units but they work together to perform the overall vending
function.
Product aesthetics (size, weight, shape, style, etc) is an important factor in choosing a product.
6. Power Concerns: -
E.S should be designed in such a way as to minimize the heat dissipation by the system.
68
1. Operational quality attributes
The operational quality attributes represent the quality attributes related to the embedded
system when it is in the operational mode or online mode
Response
Throughput
Reliability
Maintainability
Security
Saftey
1. Response:
It is the measure of quickness of the system.It tells how fast the system is tracking the changes
in input variables. Most of the E.S demands fast response which should be almost real time.
2. Throughput
It deals with the efficiency of a system. It can be defined as the rate of production or operation
of a defined process over a stated period of time.The rates can be expressed in terms of
products, batches produced or any other meaningful measurements.
Ex – In case of card reader throughput means how many transactions the reader can perform
in a minute or in an hour or in a day.
3. Reliability:
It is a measure of how much we can rely upon the proper functioning of the system.
Mean Time between Failure (MTBF) and Mean Time To Repair (MTTR) are the terms used
in determining system reliability.MTBF gives the frequency of failures in hours/weeks/months.
69
MTTR specifies how long the system is allowed to be out of order following a failure.For
embedded system with critical application need, it should be of the order of minutes.
4. Maintainability:
It deals with support and maintenance to the end user or client in case of technical issues and
product failure or on the basis of a routine system checkup.Reliability and maintainability are
complementary to each other.A more reliable system means a system with less corrective
maintainability requirements and vice versa. Maintainability can be broadly classified into two
categories. Scheduled or Periodic maintenance (Preventive maintenance), Corrective
maintenance to unexpected failures
5. Security:
Confidentiality, Integrity and availability are the three major measures of information security.
Confidentiality deals with protection of data and application from unauthorized disclosure.
Integrity deals with the protection of data and application from unauthorized modification.
Availability deals with protection of data and application from unauthorized users.
6. Saftey:
Safety deals with the possible damages that can happen to the operator, public and the
environment due to the breakdown of an Embedded System. The breakdown of an embedded
system may occur due to a hardware failure or a firmware failure. Safety analysis is a must in
product engineering to evaluate the anticipated damages and determine the best course of action
to bring down the consequences of damage to an acceptable level.
70
Non Operational Quality Attributes:
The quality attributes that needs to be addressed for the product not on the basis of operational
aspects are grouped under this category.
Evolvability
Portability
Testability deals with how easily one can test the design, application and by which means
it can be done.For an E.S testability is applicable to both the embedded hardware and
firmware. Embedded hardware testing ensures that the peripherals and total hardware
functions in the desired manner, whereas firmware testing ensures that the firmware is
functioning in the expected way
Debug-ability is a means of debugging the product from unexpected behavior in the system
1. Hardware level: It is used for finding the issues created by hardware problems.
2. Software level: It is employed for finding the errors created bythe flaws in the software
2. Evolvability:-
For an embedded system evolvability refers to the ease with which the embedded
product can be modified to take advantage of new firmware or hardware technologies.
71
3. Portability: -
It is the time elapsed between the conceptualization of a product and the time at which
the product is ready for selling.
The commercial embedded product market is highly competitive and time to market
the product is critical factor in the success of commercial embedded product.
There may be multiple players in embedded industrywho develop products of the same
category (like mobile phone).
Cost is a factor which is closely monitored by both end user and product manufacturer.
Any failure to position the cost of a commercial product at a nominal rate may lead to
the failure of the product in the market.
Proper market study and cost benefit analysis should be carried out before taking a
decision on the per-unit cost of the embedded product.
The ultimate aim of the product is to generate marginal profit so the budget and total
cost should be properly balanced to provide a marginal profit.
72
MRCET ECE ES UNIT-3 Notes
UNIT-III
TYPICAL EMBEDDED SYSTEM
ELEMENTS OF EMBEDDED SYSTEMS:
An embedded system is a combination of 3 things, Hardware Software Mechanical
Components and it is supposed to do one specific task only. A typical embedded system contains
a single chip controller which acts as the master brain of the system. Diagrammatically an
embedded system can be represented as follows:
FPGA/ASIC/DSP/SoC
Embedded
Microprocessor/controller
Firmware
Memory
Communication Interface
System
I/p Ports Core O/p Ports
(Sensors) (Actuators)
Other supporting
Integrated Circuits &
subsystems
Embedded System
Real World
Embedded systems are basically designed to regulate a physical variable (such Microwave
Oven) or to manipulate the state of some devices by sending some signals to the actuators or
devices connected to the output port system (such as temperature in Air Conditioner), in
response to the input signal provided by the end users or sensors which are connected to the
input ports.
Dept. of ECE 73
MRCET ECE ES UNIT-3 Notes
The control is achieved by processing the information coming from the sensors and user
interfaces and controlling some actuators that regulate the physical variable.
Keyboards, push button, switches, etc. are Examples of common user interface input devices
and LEDs, LCDs, Piezoelectric buzzers, etc examples for common user interface output
devices for a typical embedded system.The requirement of type of user interface changes from
application to application based on domain.
Some embedded systems do not require any manual intervention for their operation. They
automatically sense the input parameters from real world through sensors which are connected
at input port. The sensor information is passed to the processor after signal conditioning and
digitization. The core of the system performs some predefined operations on input data with
the help of embedded firmware in the system and sends some actuating signals to the actuator
connect connected to the output port of the system.
The memory of the system is responsible for holding the code (control algorithm and
other important configuration details). There are two types of memories are used in any
embedded system. Fixed memory (ROM) is used for storing code or program. The user
cannot change the firmware in this type of memory. The most common types of memories
used in embedded systems for control algorithm storage are
OTP,PROM,UVEPROM,EEPROM and FLASH
An embedded system without code (i.e. the control algorithm) implemented memory has
all the peripherals but is not capable of making decisions depending on the situational as well
as real world changes.
Memory for implementing the code may be present on the processor or may be
implemented as a separate chip interfacing the processor
In a controller based embedded system, the controller may contain internal memory for
storing code such controllers are called Micro-controllers with on-chip ROM, eg. Atmel
AT89C51.
MRCET ECE ES UNIT-3 Notes
The Core of the Embedded Systems: The core ofthe embedded system falls into anyone
of the following categories.
Application Specific Integrated Circuits (ASICs)
Commercial off the shelf Components (COTS)
In general the CPU contains the Arithmetic and Logic Unit (ALU), Control Unit and
Working registers
Microprocessor is a dependant unit and it requires the combination of other hardware like
Memory, Timer Unit, and Interrupt Controller etc for proper functioning.
Intel claims the credit for developing the first Microprocessor unit Intel 4004, a 4 bit
processor which was released in Nov 1971
· Developers of microprocessors.
Intel – Intel 4004 – November 1971(4-bit)
Intel – Intel 4040.
Intel – Intel 8008 – April 1972.
Intel – Intel 8080 – April 1974(8-bit).
Motorola – Motorola 6800.
Intel– Intel 8085 – 1976.
Zilog - Z80 – July 1976
MRCET ECE ES UNIT-3 Notes
Microcontroller:
A highly integrated silicon chip containing a CPU, scratch pad RAM, Special and General
purpose Register Arrays, On Chip ROM/FLASH memory for program storage, Timer and
Interrupt control units and dedicated I/O ports
Microcontrollers can be considered as a super set of Microprocessors
Microcontroller can be general purpose (like Intel 8051, designed for generic applications
and domains) or application specific (Like Automotive AVR from Atmel Corporation.
Designed specifically for automotive applications)
Since a microcontroller contains all the necessary functional blocks for independent working,
they found greater place in the embedded domain in place of microprocessors
Microcontrollers are cheap, cost effective and are readily available in the market
Texas Instruments TMS 1000 is considered as the world‟s first microcontroller
Microprocessor Vs Microcontroller:
Microprocessor Microcontroller
A silicon chip representing a Central Processing Unit A microcontroller is a highly integrated chip that
(CPU), which is capable of performing arithmetic as contains a CPU, scratch pad RAM, Special and
well as logical operations according to a pre-defined set General purpose Register Arrays, On Chip
of Instructions ROM/FLASH memory for program storage, Timer
and Interrupt control units and dedicated I/O ports
It is a dependent unit. It requires the combination of It is a self contained unit and it doesn’t require
other chips like Timers, Program and data memory external Interrupt Controller, Timer, UART etc for
chips, Interrupt controllers etc for functioning its functioning
Most of the time general purpose in design and Mostlyapplication oriented or domain specific
operation
Doesn‟t contain a built in I/O port. The I/O Port Most ofthe processors contain multiple built-in I/O
functionality needs to be implemented with the help of ports which can be operated as a single 8 or 16 or 32
external Programmable Peripheral Interface Chips like bit Port or as individual port pins
8255
Targeted for high end market where performance is Targeted for embedded market where performance is
important not so critical (At present this demarcation is invalid)
Limited power saving options compared to Includes lot ofpower saving features
microcontrollers
MRCET ECE ES UNIT-3 Notes
General Purpose Processor (GPP) Vs Application Specific Instruction Set Processor (ASIP)
General Purpose Processor or GPP is a processor designed for general computational tasks
GPPs are produced in large volumes and targeting the general market. Due to the high
volume production, the per unit cost for a chip is low compared to ASIC or other specific
ICs
A typical general purpose processor contains an Arithmetic and Logic Unit (ALU) and Control
Unit (CU)
Application Specific Instruction Set processors (ASIPs) are processors with architecture
and instruction set optimized to specific domain/application requirements like Network
processing, Automotive, Telecom, media applications, digital signal processing, control
applications etc.
ASIPs fill the architectural spectrum between General Purpose Processors and Application
Specific Integrated Circuits (ASICs)
The need for an ASIP arises when the traditional general purpose processor are unable to meet the
increasing application needs
Some Microcontrollers (like Automotive AVR, USB AVR from Atmel), System on Chips,
Digital Signal Processors etc are examples of Application Specific Instruction Set
Processors (ASIPs)
ASIPs incorporate a processor and on-chip peripherals, demanded by the application requirement,
program and data memory
Powerful special purpose 8/16/32 bit microprocessors designed specifically to meet the
computational demands and power constraints of today's embedded audio, video, and
communications applications
Digital Signal Processors are 2 to 3 times faster than the general-purpose microprocessors
in signal processing applications
DSPs implement algorithms in hardware which speeds up the execution whereas general
purpose processors implement the algorithm in firmware and the speed of execution
depends primarily on the clock for the processors
DSP can be viewed as a microchip designed for performing high speed computational
MRCET ECE ES UNIT-3 Notes
operations for „addition‟, „subtraction‟, „multiplication‟ and „division‟
MRCET ECE ES UNIT-3 Notes
Computational Engine
I/O Unit
RISC CISC
Lesser no. of instructions Greater no. of Instructions
Instruction Pipelining and increased execution Generally no instruction pipelining feature
speed
Orthogonal Instruction Set (Allows each instruction Non Orthogonal Instruction Set (All instructions
to operate on anyregister and use anyaddressing are not allowed to operate on anyregister and
mode) use any addressing mode. It is instruction
specific)
Operations are performed on registers only, the Operations are performed on registers or
only memoryoperations are load and store memory depending on the instruction
Large number of registers are available Limited no. of general purpose registers
Programmer needs to write more code to execute a . A programmer can achieve the desired
task since the instructions are simpler ones functionalitywith a single instruction which in
turn provides the effect of using more simpler
single instructions in RISC
Single, Fixed length Instructions Variable length Instructions
Less Silicon usage and pin count More silicon usage since more additional
decoder logic is required to implement the
complex instruction decoding.
With Harvard Architecture Can be Harvard or Von-Neumann Architecture
MRCET ECE ES UNIT-3 Notes
The terms Harvard and Von-Neumann refers to the processor architecture design.
Microprocessors/controllers based on the Harvard architecture will have separate data bus
and instruction bus. This allows the data transfer and program fetching to occur
simultaneously on both buses
With Harvard architecture, the data memory can be read and written while the program
memory is being accessed. These separated data memory and code memory buses allow
one instruction to execute while the next instruction is fetched (“Pre-fetching”)
Separate buses for Instruction and Data fetching Single shared bus for Instruction and Data
fetching
Easier to Pipeline, so high performance can be Low performance Compared to Harvard
achieved Architecture
Comparatively high cost Cheaper
No memoryalignment problems Allows self modifying codes†
Since data memory and program memoryare Since data memory and program memory
stored physically in different locations, no are stored physically in same chip, chances
chances for accidental corruption of program for accidental corruption of program
memory memory
MRCET ECE ES UNIT-3 Notes
ASIC integrates several functions into a single chip and thereby reduces the system
development cost
Most of the ASICs are proprietary products. As a single chip, ASIC consumes very small
area in the total system and thereby helps in the design of smaller systems with high
capabilities/functionalities.
If the Non-Recurring Engineering Charges (NRE) is born by a third party and the
Application Specific Integrated Circuit (ASIC) is made openly available in the market, the
ASIC is referred as Application Specific Standard Product (ASSP)
Some ASICs are proprietaryproducts , the developers are not interested in revealing the
internal details.
Field Programmable Gate Arrays (FPGAs) and Complex Programmable Logic Devices
(CPLDs) are the two major types of programmable logic devices
FPGA:
FPGA is an IC designed to be configured bya designer after manufacturing.
FPGAs offer the highest amount of logic density, the most features, and the highest
performance.
These advanced FPGA devices also offer features such as built-in hardwired processors
(such as the IBM Power PC), substantial amounts of memory, clock management systems,
and support for many of the latest, very fast device-to-device signaling technologies
These advanced FPGA devices also offer features such as built-in hardwired processors,
substantial amounts of memory, clock management systems, and support for many of the
latest, very fast device-to-device signaling technologies.
FPGAs are used in a wide variety of applications ranging from data processing and
storage, to instrumentation, telecommunications, and digital signal processing
CPLD:
A complex programmable logic device (CPLD) is a programmable logic device with
complexity between that of PALs and FPGAs, and architectural features of both.
CPLDs, by contrast, offer much smaller amounts of logic - up to about 10,000 gates.
CPLDs offer verypredictable timing characteristics and are therefore ideal for critical
control applications.
MRCET ECE ES UNIT-3 Notes
CPLDs such as the Xilinx CoolRunner series also require extremely low amounts of power
and are very inexpensive, making them ideal for cost-sensitive, battery-operated, portable
applications such as mobile phones and digital handheld assistants.
ADVANTAGES OF PLDs:
• PLDSs do not require long lead times for prototype or production-the PLDs are already
on a distributor‟s self and ready for shipment
• PLDs do not require customers to pay for large NRE costs and purchase expensive mask
sets
• PLDs allow customers to order just the number of parts required when they need them.
allowing them to control inventory.
• The manufacturers able to add new features or upgrade the PLD based products that are
in the field by uploading new programming file
COTS products are designed in such a wayto provide easy integration and
interoperability with existing system components
MRCET ECE ES UNIT-3 Notes
Typical examples for the COTS hardware unit are Remote Controlled Toy Car control unit
including the RF Circuitry part, High performance, high frequency microwave electronics
(2 to 200 GHz), High bandwidth analog-to-digital converters, Devices and components for
operation at very high temperatures, Electro-optic IR imaging arrays, UV/IR Detectors etc
The major advantage of using COTS is that they are readily available in the market,
cheap and a developer can cut down his/her development time to a great extend.
There is no need to design the module yourself and write the firmware .
• The changes in the system environment or variables are detected bythe sensors
connected to the input port of the embedded system.
• If the embedded system is designed for any controlling purpose, the system will produce
some changes in controlling variable to bring the controlled variable to the desired value.
• It is achieved through an actuator connected to the out port of the embedded system.
Sensor:
A transducer device which converts energy from one form to another for any
measurement or control purpose. Sensors acts as input device
Eg. Hall Effect Sensor which measures the distance between the cushion and magnet in
the Smart Running shoes from adidas
Actuator:
Examples: Serial interfaces like I2C, SPI, UART, 1-Wire etc and Parallel bus interface
Examples for wireless communication interface: Infrared (IR), Bluetooth (BT), Wireless
LAN (Wi-Fi), Radio Frequency waves (RF), GPRS etc.
Examples for wired interfaces: RS-232C/RS-422/RS 485, USB, Ethernet (TCP-IP), IEEE
1394 port, Parallel port etc.
87
MRCET ECE ESD UNIT-3 NOTES
88
MRCET ECE ESD UNIT-3 NOTES
The I2C bus is comprised of two bus lines, namely; Serial Clock – SCL and Serial Data – SDA.
SCL line is responsible for generating synchronization clock pulses and SDA is responsible
for transmitting the serial data across devices.I2C bus is a shared bus system to which many
number of I2C devices can be connected. Devices connected to the I2C bus can act as either
„Master‟ device or „Slave‟ device.
The „Master‟ device is responsible for controlling the communication by
initiating/terminating data transfer, sending data and generating necessary synchronization clock
pulses.
89
MRCET ECE ESD UNIT-3 NOTES
Slave devices wait for the commands from the master and respond upon receiving the
commands. Master and „Slave‟ devices can act as either transmitter or receiver. Regardless
whether a master is acting as transmitter or receiver, the synchronization clock signal is generated
by the „Master‟ device only.I2C supports multi masters on the same bus.
The sequence of operation for communicating with an I2C slave device is:
1. Master device pulls the clock line (SCL) of the bus to „HIGH‟
2. Master device pulls the data line (SDA) „LOW‟, when the SCL line is at logic
„HIGH‟ (This is the „Start‟ condition for data transfer)
3. Master sends the address (7 bit or 10 bit wide) of the „Slave‟ device to which it wants to
communicate, over the SDA line.
4. Clock pulses are generated at the SCL line for synchronizing the bit reception by the
slave device.
5. The MSB of the data is always transmitted first.
6. The data in the bus is valid during the „HIGH‟ period of the clock signal
7. In normal data transfer, the data line onlychanges state when the clock is low.
8. Master waits for the acknowledgement bit from the slave device whose address is sent on
the bus along with the Read/Write operation command.
90
MRCET ECE ESD UNIT-3 NOTES
9. Slave devices connected to the bus compares the address received with the address
assigned to them
10. The Slave device with the address requested bythe master device responds by sending an
acknowledge bit (Bit value =1) over the SDA line
11. Upon receiving the acknowledge bit, master sends the 8bit data to the slave device over
SDA line, if the requested operation is „Write to device‟.
12. If the requested operation is „Read from device‟, the slave device sends data to the
master over the SDA line.
13. Master waits for the acknowledgement bit from the device upon byte transfer complete for
a write operation and sends an acknowledge bit to the slave device for a read operation
14. Master terminates the transfer bypulling the SDA line „HIGH‟ when the clock line SCL
is at logic „HIGH‟ (Indicating the „STOP‟ condition).
91
MRCET ECE ESD UNIT-3 NOTES
92
MRCET ECE ESD UNIT-3 NOTES
Serial Clock (SCLK): Signal line carrying the clock signals
Slave Select (SS): Signal line for slave device select. It is an active low signal.
The master device is responsible for generating the clock signal.
Master device selects the required slave device by asserting the corresponding slave devices
slave select signal „LOW‟.
The data out line (MISO) of all the slave devices when not selected floats at high impedance
state
The serial data transmission through SPI Bus is fully configurable.
SPI devices contain certain set of registers for holding these configurations.
The Serial Peripheral Control Register holds the various configuration parameters like
master/slave selection for the device, baudrate selection for communication, clock signal
control etc.
The status register holds the status of various conditions for transmission and reception.SPI
works on the principle of „Shift Register‟.
The master and slave devices contain a special shift register for the data to transmit or receive.
The size of the shift register is device dependent. Normally it is a multiple of 8.
During transmission from the master to slave, the data in the master‟s shift register is
shifted out to the MOSI pin and it enters the shift register of the slave device through the
MOSI pin of the slave device.
93
MRCET ECE ESD UNIT-3 NOTES
At the same time the shifted out data bit from the slave device’s shift register enters the
shift register of the master device through MISO pin
94
MRCET ECE ESD UNIT-3 NOTES
PARALLEL COMMUNICATION:
In data transmission, parallel communication is a method of conveying multiple binary
digits (bits) simultaneously. It contrasts with communication. The communication channel is the
number of electrical conductors used at the physical layer to convey bits.
Parallel communication implies more than one such conductor. For example, an 8-bit
parallel channel will convey eight bits (or a byte) simultaneously, whereas a serial channel would
convey those same bits sequentially, one at a time. Parallel communication is and always has been
widely used within integrated circuits, in peripheral buses, and in memory devices such as RAM.
1. RS-232C/RS-422/RS 485
2. USB
95
MRCET ECE ESD UNIT-3 NOTES
RS-232C:
RS-232 C (Recommended Standard number 232, revision C from the Electronic Industry
Association) is a legacy, full duplex, wired, asynchronous serial communication interface
RS-232 extends the UART communication signals for external data communication.
UART uses the standard TTL/CMOS logic (Logic „High‟ corresponds to bit value 1 and
Logic „LOW‟ corresponds to bit value 0) for bit transmission whereas RS232 use the EIA
standard for bit transmission.
As per EIA standard, a logic „0‟ is represented with voltage between +3 and +25V and a
logic „1‟ is represented with voltage between -3 and -25V.
In EIA standard, logic „0‟ is known as „Space‟ and logic „1‟ as „Mark‟.
The RS232 interface define various handshaking and control signals for communication
apart from the „Transmit‟ and „Receive‟ signal lines for data communication
RS-232 supports two different types of connectors, namely; DB-9: 9-Pin connector and DB-25:
25-Pin connector.
96
MRCET ECE ESD UNIT-3 NOTES
97
MRCET ECE ESD UNIT-3 NOTES
98
MRCET ECE ESD UNIT-3 NOTES
Ring Indicator (RI) is a modem specific signal line for indicating an incoming call on the
telephone line.
As per the EIA standard RS-232 C supports baudrates up to 20Kbps (Upper limit 19.2Kbps).
The commonly used baudrates by devices are 300bps, 1200bps, 2400bps, 9600bps,
11.52Kbps and 19.2Kbps.
The maximum operating distance supported in RS-232 communication is 50 feet at the
highest supported baudrate.
Embedded devices contain a UART for serial communication and they generate signal levels
conforming to TTL/CMOS logic.
A level translator IC like MAX 232 from Maxim Dallas semiconductor is used for converting
the signal lines from the UART to RS-232 signal lines for communication.
On the receiving side the received data is converted back to digital logic level by a converter
IC.
Converter chips contain converters for both transmitter and receiver.
RS-232 uses single ended data transfer and supports only point-to-point communication and
not suitable for multi-drop communication.
99
MRCET ECE ESD UNIT-3 NOTES
480 Mb/s signaling bit rate
There exist two pre-defined connectors in any USB system - Series “A” and Series “B”
Connectors.
Bus Topology:
Four wire cable serves as interconnect of system - power, ground and two differential
signaling lines.
USB is a polled bus-all transactions are initiated by host.
100
MRCET ECE ESD UNIT-3 NOTES
USB HOST: Device that controls entire system usually a PC of some form. Processes data arriving
to and from the USB port.
USB HUB: Tests for new devices and maintains status information of child devices.Serve as
repeaters, boosting strength of up and downstream signals. Electrically isolates devices from one
another - allowing an expanded number of devices.
2. Wireless communication interface : Wireless communication interface is an interface used to
transmission of information over a distance without help of wires, cables or any other forms of
electrical conductors.
1. Infrared
2. Bluetooth
3. Wi-Fi
4. Zigbee
5. GPRS
INFRARED:
Measure of heat
Most of the thermal radiation emitted by objects near room temperature is infrared. Infrared
radiation is used in industrial, scientific, and medical applications. Night-vision devices using
active near-infrared illumination allow people or animals to be observed without the observer
being detected.
101
MRCET ECE ESD UNIT-3 NOTES
IR transmission:
The transmitter of an IR LED inside its circuit, which emits infrared light for every electric pulse
given to it. This pulse is generated as a button on the remote is pressed, thus completing the circuit,
providing bias to the LED.
The LED on being biased emits light of the wavelength of 940nm as a series of pulses,
corresponding to the button pressed. However since along with the IR LED many other sources
of infrared light such as us human beings, light bulbs, sun, etc, the transmitted information can be
interfered. A solution to this problem is by modulation. The transmitted signal is modulated using
a carrier frequency of 38 KHz (or any other frequency between 36 to 46 KHz). The IR LED is
made to oscillate at this frequency for the time duration of the pulse. The information or the light
signals are pulse width modulated and are contained in the 38 KHz frequency.
BLUETOOTH:
Bluetooth is a wireless technology standard for short distances (using short-wavelength UHF
band from 2.4 to 2.485 GHz)for exchanging data over radio waves in the ISM and mobile
devices, and building personal area networks (PANs).Invented by telecom vendor Ericsson in
1994, it was originally conceived as a wireless alternative to RS- 232 data cables.
102
MRCET ECE ESD UNIT-3 NOTES
Bluetooth uses a radio technology called frequency- hopping spread spectrum. Bluetooth
divides transmitted data into packets, and transmits each packet on one of 79 designated Bluetooth
channels. Each channel has a bandwidth of 1 MHz. It usually performs 800 hops per second, with
Adaptive Frequency-Hopping (AFH) enabled
Originally, Gaussian frequency-shift keying (GFSK) modulation was the only modulation
scheme available. Since the introduction of Bluetooth 2.0+EDR, π/4-DQPSK (Differential
Quadrature Phase Shift Keying) and 8DPSK modulation may also be used between compatible
devices. Bluetooth is a packet-based protocol with a master- slave structure. One master may
communicate with up to seven slaves in a piconet. All devices share the master's clock. Packet
exchange is based on the basic clock, defined by the master, which ticks at312.5 µs intervals.
A master BR/EDR Bluetooth device can communicate with a maximum of seven devices
in a piconet (an ad-hoc computer network using Bluetooth technology), though not all devices
reach this maximum. The devices can switch roles, by agreement, and the slave can become the
master (for example, a headset initiating a connection to a phone necessarily begins as master—
as initiator of the connection—but may subsequently operate as slave).
Wi-Fi:
Wi-Fi is the name of a popular wireless networking technology that uses radio waves to
provide wireless high-speed Internet and network connections
Wi-Fi follows the IEEE 802.11 standard
Wi-Fi is intended for network communication and it supports Internet Protocol (IP) based
communication
Wi-Fi based communications require an intermediate agent called Wi-Fi router/Wireless
Access point to manage the communications.
The Wi-Fi router is responsible for restricting the access to a network, assigning IP address to
devices on the network, routing data packets to the intended devices on the network.
103
MRCET ECE ESD UNIT-3 NOTES
Wi-Fi enabled devices contain a wireless adaptor for transmitting and receiving data in the
form of radio signals through an antenna.
Wi-Fi operates at 2.4GHZ or 5GHZ of radio spectrum and they co-exist with other ISM
band devices like Bluetooth.
A Wi-Fi network is identified with a Service Set Identifier (SSID). A Wi-Fi device can
connect to a network by selecting the SSID of the network and by providing the credentials
if the network is security enabled
Wi-Fi networks implements different security mechanisms for authentication and data
transfer.
Wireless Equivalency Protocol (WEP), Wireless Protected Access (WPA) etc are some of
the security mechanisms supported by Wi-Fi networks in data communication.
ZIGBEE:
Zigbee is an IEEE 802.15.4-based specification for a suite of high- level communication protocols
used to create personal area networks with small, low-power digital radios, such as for home
automation, medical device data collection, and other low-power low-bandwidth needs, designed
for small scale projects which need wireless connection.Hence, zigbee is a low-power, low data
rate, and close proximity (i.e., personal area) wireless ad hoc network.The technology
104
MRCET ECE ESD UNIT-3 NOTES
defined by the zigbee specification is intended to be simpler and less expensive than other
wireless personal area networks (WPANs), such as Bluetooth or Wi-Fi . Applications include
wireless light switches, electrical meters with in-home-displays, traffic management systems, and
other consumer and industrial equipment that require short-range low- rate wireless data transfer.
Its low power consumption limits transmission distances to 10– 100 meters line-of-sight,
depending on power output and environmental characteristics. Zigbee devices can transmit data
over long distances by passing data through a mesh network of intermediate devices to reach
more distant ones.
Zigbee Coordinator: The zigbee coordinator acts as the root of the zigbee network. The ZC is
responsible for initiating the Zigbee network and it has the capability to store information about
the network.
Zigbee Router: Responsible for passing information from device to another device or to another
ZR.
Zigbee end device:End device containing zigbee functionality for data communication. It can talk
only with a ZR or ZC and doesn’t have the capability to act as a mediator for transferring data
from one device to another.
Zigbee supports an operating distance of up to 100 metres at a data rate of 20 to 250 Kbps.
105
MRCET ECE ESD UNIT-3 NOTES
General Packet Radio Service (GPRS) is a packet oriented mobile data service on the 2G and
3G cellular communication system's global system for mobile communications (GSM).GPRS was
originally standardized by European Telecommunications Standards Institute (ETSI) GPRS usage
is typically charged based on volume of data transferred, contrasting with circuit switched data,
which is usually billed per minute of connection time. Sometimes billing time is broken down to
every third of a minute. Usage above the bundle cap is charged per megabyte, speed limited, or
disallowed.
Services offered:
GPRS extends the GSM Packet circuit switched data capabilities and makes the
following services possible:
SMS messaging and broadcasting
"Always on" internet access
Multimedia messaging service (MMS)
Push-to-talk over cellular (PoC)
Instant messaging and presence-wireless village Internet applications for smart devices
through wireless application protocol (WAP).
Point-to-point (P2P) service: inter-networking with the Internet (IP).
Point-to-multipoint (P2M) service]: point-to- multipoint multicast and point-to-multipoint
group calls.
Text Book:-
106
Embedded Systems Unit-4 Notes
Introduction
The control algorithm (Program instructions) and or the configuration settings
that an embedded system developer dumps into the code (Program) memory
of the embedded system
It is an un-avoidable part of an embedded system.
The embedded firmware can be developed in various methods like
o Write the program in high level languages like Embedded C/C++ using
an Integrated Development Environment (The IDE will contain an
editor, compiler, linker, debugger, simulator etc. IDEs are differentfor
different family of processors/controllers.
o Write the program in Assembly Language using the Instructions
Supported by your application’s target processor/controller
The product starts functioning properly once the intelligence imparted to the
product by embedding the firmware in the hardware.
The product will continue serving the assigned task till hardware breakdown
occurs or a corruption in embedded firmware.
107
Embedded Systems Unit-4 Notes
and it is non alterable by end users.
There exist two basic approaches for the design and implementation of
embedded firmware, namely;
108
Embedded Systems Unit-4 Notes
The task listed on top on the program code is executed first and the tasks just
below the top are executed after completing the first task
void main ()
{
Configurations ();
Initializations ();
while (1)
{
Task 1 ();
Task 2 ();
:
:
Task n ();
}
}
109
Embedded Systems Unit-4 Notes
Pros:
Doesn’t require an Operating System for task scheduling and monitoring and
free from OS related overheads
Simple and straight forward design
Reduced memory footprint
Cons:
Non Real time in execution behavior (As the number of tasks increases the
frequency at which a task gets CPU time for execution also increases)
Any issues in any task execution may affect the functioning of the product
(This can be effectively tackled by using Watch Dog Timers for task
execution monitoring)
Enhancements:
Combine Super loop based technique with interrupts
Execute the tasks (like keyboard handling) which require Real time attention
as Interrupt Service routines.
110
Embedded Systems Unit-4 Notes
Point of Sale (PoS) terminals, Gaming Stations, Tablet PCs etc are examples
of embedded devices running on embedded GPOSs
Mobile Phones, PDAs, Flight Control Systems etc are examples of embedded
devices that runs on RTOSs
o Subset of C (Embedded C)
o Subset of C++ (Embedded C++)
o Any other high level language with supported Cross-compiler
Mix of Assembly & High level Language
o Mixing High Level Language (Like C) with Assembly Code
o Mixing Assembly code with High Level Language (Like C)
o Inline Assembly
111
Embedded Systems Unit-4 Notes
It is not necessary that all opcode should have Operands following them.
Some of the Opcode implicitly contains the operand and in such situation no
operand is required. The operand may be a single operand, dual operand or
more
MOV A, #30
Moves decimal value 30 to the 8051 Accumulator register. Here MOV A is the
Opcode and 30 is the operand (single operand). The same instruction when written
in machine language will look like
112
Embedded Systems Unit-4 Notes
01110100 00011110
The first 8 bit binary value 01110100 represents the opcode MOV A and the second
8 bit binary value 00011110 represents the operand 30.
;###############################################################
; SUBROUTINE FOR GENERATING DELAY
; DELAY PARAMETR PASSED THROUGH REGISTER R1
; RETURN VALUE NONE,REGISTERS USED: R0, R1
;###############################################################
##### DELAY: MOV R0, #255 ; Load Register R0 with 255
113
Embedded Systems Unit-4 Notes
114
Embedded Systems Unit-4 Notes
Each source file can be assembled separately to examine the syntax errors
and incorrect assembly instructions
3.Non portable:
Target applications written in assembly instructions are valid only for
that particular family of processors and cannot be re-used for another
target processors/controllers.
If the target processor/controller changes, a complete re-writing of the
application using assembly language for new target
processor/controller is required.
2. Embedded firmware Development Languages/Options – High Level
Language
The embedded firmware is written in any high level language like C, C++
116
Embedded Systems Unit-4 Notes
Library Files
Source File 1
Module
(.c /.c++ etc) Object File 1
(Module-1) Cross-compiler
Source File 2
Module
(.c /.c++ etc) Object File 2
Cross-compiler
(Module-2)
Machine Code
(Hex File)
117
Embedded Systems Unit-4 Notes
Advantages:
Drawbacks:
118
Embedded Systems Unit-4 Notes
High Level language and low level language can be mixed in three different
ways
In line Assembly
The passing of parameters and return values between the high level and low
level language is cross-compiler specific
If the programmer wants to take advantage of the speed and optimized code
offered by the machine code generated by hand written assembly rather than
cross compiler generated machine code.
For accessing certain low level hardware ,the timing specifications may be
very critical and cross compiler generated machine code may not be able to
offer the required time specifications accurately.
The programmer must be aware of how to pass parameters from the ‘C’
routine to assembly and values returned from assembly routine to ‘C’ and how
Assembly routine is invoked from the ‘C’ code.
119
Embedded Systems Unit-4 Notes
Passing parameter to the assembly routine and returning values from the
assembly routine to the caller ‘C’ function and the method of invoking the
assembly routine from ‘C’ code is cross compiler dependent.
The entire source code is planned in Assembly code for various reasons like
optimized code, optimal performance, efficient code memory utilization and
proven expertise in handling the assembly.
The functions written in ‘C’ use parameter passing to the function and returns
values to the calling functions.
The programmer must be aware of how parameters are passed to the function
and how values returned from the function and how function is invoked from
the assembly language environment.
Passing parameter to the function and returning values from the function using
CPU registers , stack memory and fixed memory.
120
Embedded Systems Unit-4 Notes
3. In line Assembly:
• Inline assembly is another technique for inserting the target
processor/controller specific assembly instructions at any location of source
code written in high level language ‘C’
• Inline Assembly avoids the delay in calling an assembly routine from a ‘C’
code.
• Special keywords are used to indicate the start and end of Assembly
instructions
Mov A,#13H
#pragma ensasm
• Keil C51 uses the keywords #pragma asm and #pragma endasm to indicate
a block of code written in assembly.
Text Books:
121
EMBEDDED PROGRAMMING
Assembly language is introduced for providing mnemonics or symbols for the machine level code
instructions. Assembly language program is consisting of mnemonics that is translated into
machine code. A program that is used for this conversion is known as assembler.
Assembly language is also called as low-level language because it directly works with the internal
structure of CPU. For programming in assembly language, a programmer must have the knowledge
of all the registers in a CPU.
Different programming languages like C, C++, Java and various other languages are called as
high-level languages because they are not dealing with the internal details of CPU.
In contrast, an assembler is used to translate an assembly language program into machine code
(sometimes also called object code or opcode). Similarly, a compiler translates a high-level
language into machine code. For example, to write a program in C language, one must use a C
compiler to translate the program into machine language.
An assembly language program is a series of statements, which are either assembly language
instructions such as ADD and MOV, or statements called directives.
An instruction tells the CPU what to do, while a directive (also called pseudo-instructions) gives
instruction to the assembler. For example, ADD and MOV instructions are commands which the
CPU runs, while ORG and END are assembler directives. The assembler places the opcode to the
memory location 0 when the ORG directive is used, while END indicates to the end of the source
code. A program language instruction consists of the following four fields –
Let's see the steps for creating, assembling and running an assembly language program are as
follows:
o Editor Program : At first, we use an editor for type in a program. Editors like MS-DOS
program that comes with all Microsoft operating systems can be used for creating or edit
a program. The editor produces an ASCII file. The ?asm? extension for a source file is used
by an assembler during next step.
o Assembler Program: The "asm" source file contain the code created in Step 1. It is
transferred to an 8051 assembler. The assembler is used for converting the assembly
language instructions into machine code instructions and it produced the .obj file (object
file) and .lst file (list file). It is also called as source file because some assembler requires
that this file must have "src" extension.
o Linker Program: The linker program is used for generating one or more object files and
produces an absolute object file with an extension "abs".
o OH Program: The OH program fetches the "abs" file and fed it to a program called "OH".
OH is called as object to hex converter it creates a file with an extension "hex" thatis ready
for burn in to the ROM.
All labels used in assembly language follow the certain rules as given below:
o Each label name should be unique. The name used as label in assembly language
programming consist of alphabetic letters in both lowercase and uppercase, numbers from
0 to 9, and special characters such as at the rate (@), question mark (?), underscore(_), and
dollar ($) etc.
o Reserved words are not allowed to be used as a label in the program. For example, MOV
and ADD words are reserved words.
o The first character must be an alphabetical character, it cannot be a number.
Data Type
The 8051 microcontroller contains a single data type of 8-bits, and each register is also of 8-bits
size. The programmer has to break down data larger than 8-bits (00 to FFH, or to 255 in decimal)
so that it can be processed by the CPU.
DB (Define Byte)
The DB directive is the most widely used data directive in the assembler. It is used to define the
8-bit data. It can also be used to define decimal, binary, hex, or ASCII formats data. For decimal,
the "D" after the decimal number is optional, but it is required for "B" (binary) and "Hl"
(hexadecimal).
To indicate ASCII, simply place the characters in quotation marks ('like this'). The assembler
generates ASCII code for the numbers/characters automatically. The DB directive is the only
directive that can be used to define ASCII strings larger than two characters; therefore, it should
be used for all the ASCII data definitions. Some examples of DB are given below −
ORG 500H
DATA1: DB 28 ;DECIMAL (1C in hex)
DATA2: DB 00110101B ;BINARY (35 in hex)
DATA3: DB 39H ;HEX
ORG 510H
DATA4: DB "2591" ;ASCII NUMBERS
ORG 520H
DATA6: DA "MY NAME IS Michael" ;ASCII CHARACTERS
Either single or double quotes can be used around ASCII strings. DB is also used to allocate
memory in byte-sized chunks.
Assembler Directives
All labels used in assembly language follow the certain rules as given below:
o Each label name should be unique. The name used as label in assembly language
programming consist of alphabetic letters in both lowercase and uppercase, numbers from
0 to 9, and special characters such as at the rate (@), question mark (?), underscore(_), and
dollar ($) etc.
o Reserved words are not allowed to be used as a label in the program. For example, MOV
and ADD words are reserved words.
o The first character must be an alphabetical character, it cannot be a number.
Compiler
A compiler is a computer program (or a set of programs) that transforms the source code written
in a programming language (the source language) into another computer language (normally
binary format). The most common reason for conversion is to create an executable program. The
name "compiler" is primarily used for programs that translate the source code from a highlevel
programming language to a low-level language (e.g., assembly language or machine code).
Cross-Compiler
If the compiled program can run on a computer having different CPU or operating system than the
computer on which the compiler compiled the program, then that compiler is known as a cross-
compiler.
Decompiler
A program that can translate a program from a low-level language to a high-level language is
called a decompiler.
Language Converter
A program that translates programs written in different high-level languages is normally called a
language translator, source to source translator, or language converter.
A compiler is likely to perform the following operations −
Preprocessing
Parsing
Semantic Analysis (Syntax-directed translation)
Code generation
Code optimization
Assemblers
An assembler is a program that takes basic computer instructions (called as assembly language)
and converts them into a pattern of bits that the computer's processor can use to perform its basic
operations. An assembler creates object code by translating assembly instruction mnemonics into
opcodes, resolving symbolic names to memory locations. Assembly language uses a mnemonic
to represent each low-level machine operation (opcode).
Debugging Tools in an Embedded System
Debugging is a methodical process to find and reduce the number of bugs in a computer program
or a piece of electronic hardware, so that it works as expected. Debugging is difficult when
subsystems are tightly coupled, because a small change in one subsystem can create bugs in
another. The debugging tools used in embedded systems differ greatly in terms of their
development time and debugging features. We will discuss here the following debugging tools −
Simulators
Microcontroller starter kits
Emulator
Simulators
Code is tested for the MCU / system by simulating it on the host computer used for code
development. Simulators try to model the behavior of the complete microcontroller in
software.
Functions of Simulators
A simulator performs the following functions −
Defines the processor or processing device family as well as its various versions for the
target system.
Monitors the detailed information of a source code part with labels and symbolic
arguments as the execution goes on for each single step.
Provides the status of RAM and simulated ports of the target system for each single step
execution.
Monitors system response and determines throughput.
Provides trace of the output of contents of program counter versus the processor registers.
Provides the detailed meaning of the present command.
Monitors the detailed information of the simulator commands as these are entered from
the keyboard or selected from the menu.
Supports the conditions (up to 8 or 16 or 32 conditions) and unconditional breakpoints.
Provides breakpoints and the trace which are together the important testing and debugging
tool.
Facilitates synchronizing the internal peripherals and delays.