Question Bank (I scheme)
Embedded Systems (22532)
                     Unit- I (12 marks)
             Introduction to Embedded Systems
 _______________________________________________________
1. Compare Harvard and Von Neuman architecture.
Ans:
2. State any two applications for following i) Small scale embedded system. ii) Medium
scale embedded system.
Ans: Small scale:-
     8 bit or 16 bit microcontroller is used. These types of embedded systems are designed
        with a single 8 or 16-bit microcontroller that may even be activated by a battery.
     For developing embedded software for small scale embedded systems, the main
        programming tools are an editor, assembler, cross assembler and integrated
        development environment (IDE).
     Application : Washing Machine , Digital Camera, Industrial Robots Home Security
        System
Medium scale:-
     16 bit or 32 bit microcontroller or microprocessor is used, such as DSP, RISC. These
        types of embedded systems design with a single or 16 or 32 bit microcontroller,
        RISCs or DSPs.
     These types of embedded systems have both hardware and software complexities.
     For developing embedded software for medium scale embedded systems, the main
        programming tools are C, C++, and JAVA, Visual C++, and RTOS, debugger, source
        code engineering tool, simulator and IDE.
        Application : Routers for networking, ATM
3. Explain six characteristics of embedded system.
Ans:
         Processing Power: Selection of processor is based on the amount of processing
         power to get the job done and also on the basis of register width required.
OR
     o   Processor power: The embedded systems are controlled by microcontrollers or
         digital signal processor (DSP). It can handle one or many specific task which require
         very powerful processor.
     1. Memory: Hardware design must make the best estimate of the memory requirement
        and must make the provision for expansion.
OR
     o  Memory: The program developed for the embedded systems are treated as firmware
        and stored in ROM or flash memory chips.
     2. Power consumption: Systems generally work on battery and design of both software
        and hardware must take care of power saving techniques.
     3. Operating system: The embedded operating system is needed in embedded system to
        limit the function depending on the embedded device and may only run a single
        application which is crucial to the devices operation. Due to this the operating system
        must be reliable and able to run with tight constraints on memory, size, time and
        processing power.
    4. Reliability: It is always required that the system designed must give the output for
        which it is designed.
       OR
Reliability: The embedded system should be much reliable to achieve a better performance
for long duration of time during its complete life cycle.
    5. Performance: The performance of the system measures by the execution time or
        throughput the system.
    6. Power Consumption
        It is the amount of power consumed by the system, which may determine the lifetime
        of a battery, or the cooling requirements of the IC, since more power means more
        heat.
         OR
Power consumption: This is a very important factor for all embedded system which are
powered by batteries. So the amount of power will be consumed by the system, which
decides the capacity or lifetime of battery.
   1. NRE cost (nonrecurring engineering cost)
      It is one-time cost of designing the system. Once the system is designed, any number
      of units can be manufactured without incurring any additional design cost; hence the
      term nonrecurring.
   2. Unit cost
      The monetary cost of manufacturing each copy of the system, excluding NRE cost.
    Size
    The physical space required by the system, often measured in bytes for software, and
    gates or transistors for hardware.
4. Draw the block diagram of embedded system and explain with hardware component.
Ans:
Processor: The processor is the heart of embedded system. The selection of processor is
based on the
Processor: The processor is the heart of embedded system. The selection of processor is
based on the following consideration
    Instruction set
    Maximum bits of operation on single arithmetic and logical operation
    Speed
    Algorithms processing and capability
    Types of processor( microprocessor, microcontroller, digital signal processor,
       application specific processor, general purpose processor)
Power source:
Internal power supply is must. Es require from power up to power down to start time task.
Also it can run continuously that is stay “On’ system consumes total power hence efficient
real time programming by using proper ‘wait’ and ‘stop’ instruction or disable some unit
which are not in use can save or limit power consumption.
Clock / oscillator Circuits:
The clock ckt is used for CPU, system timers, and CPU machine cycles clock controls the
time for executing an instruction. Clock oscillator may be internal or external .It should be
highly stable.
Real time clock(RTC):
It require to maintain scheduling various tasks and for real time programming RTC also use
for driving timers, counters needs in the system.
Resets Circuit and power on reset:
Reset process starts executing various instruction from the starting address. The address is set
by the processor in the program counter. The reset step resent and runs the program in the
following way
     System program that execute from beginning
     System boot up program
     System initialization program
Memory:
A system embeds either in the internal flash or ROM, PROM or in an external flash or ROM
or PROM of the microcontroller.
5. Compare features of PIC and AVR microcontrollers (any four).
Ans:
6. Compare RISC with CISC processor.
Ans:
                            Unit- II (16 marks)
                      Programming using Embedded ‘C’
1. Write C language program to toggle all bits of P0, P1, P2 and P3 continuosly with certain
delay.
Ans: #include < reg51.h>
void Add_delay (unsigned int);
void main (void)
while(1) //repeat loop
{
   P0=0xff;                 //toggle all bits of port 0
   Add_delay (200);                  // add delay
   P0=0x00;                                  //toggle all bits of port 0
   Add_delay (200);                  //add delay
   P1=0xff;                                                  //toggle all bits of port 1
   Add_delay (200);                          //add delay
   P1=0x00;                                                  //toggle all bits of port 1
   Add_delay (200);                                           //add delay
   P2=0xff;                                  //toggle all bits of port 0
   Add_delay (200);                                          //add delay
   P2=0x00;                                                          //toggle all bits of port 2
   Add_delay (200);                                   //add delay
   P3=0xff;                          //toggle all bits of port 3
   Add_delay (200);                                  //add delay
   P3=0x00;                                          //toggle all bits of port 3
   Add_delay (200);                                  //add delay
}
void Add_delay (unsigned int delay)
{
   unsigned int x,y;
   for(x=0; x< delay; x++)
   for (y=0; y<1275; y++);
}
2. Write a C language program to transfer message “MSBTE” serially at 9600 band rate.
Assume crystal frequency 12 MHz.
Ans: #include <stdio.h>
 #include <reg51.h>
 void sertext (unsigned char) ;
void main( )
 { TMOD = 0x20 ;
   SCON = 0x50 ;
  TH1=0xFA ;
  TR1 = 1 ;
 sertext ('M') ;
sertext ('S') ;
sertext ('B') ;
sertext ('T') ;
sertext ('E') ;
  while (1)
  {
 }
  }
void sertext (unsigned char x)
   {    SBUF = x ;
   while (TI = = 0) ;
      {
TI = 0 ;
    }
  }
3. Estimate hex data values of THO and TLO if 89C51 microcontroller operating at crystal
frequency of 11.0592 MHz and need to generate delay of 5 milliseconds.
Ans:
Let’s generate a square wave of 2mSec time period using an AT89C51 microcontroller with
timer0 in mode1 on the P1.0 pin of port1. Assume Xtal oscillator frequency of 11.0592 MHz.
As Xtal is 11.0592 MHz we have a machine cycle of 1.085uSec.
Hence, the required count to generate a delay of 1mSec. is,
                             Count =(1×10^(-3)) / (1.085×10^(-6) ) ≈ 921
And mode1 has a max count is 2^16 (0 - 65535) and it increments from 0 to 65535 so we
need to load value which is 921 less from its max. count i.e. 65535. Also, here in the below
program, we need an additional 13 MC (machine cycles) from call to return of delay
function. Hence value needed to be loaded is,
                   Value=(65535-Count)+Function_MCycles+1 =64615= (FC74)Hex
So we need to load FC74 Hex value higher byte in TH0 and lower byte in TL0 as,
TH0 = 0xFC & TL0 = 0x74
4. Write C language program to generate square wave of 5 KHz on pin P1.5 of 89C51.
Ans:
I/P clock=11.0592 X 106 =11.0592MHz
1/12x11.0592Mhz= 921.6Khz
Tin =1.085μsec
For5 kHzsquarewave
Fout = 5KHz
Tout=1/5×103
Tout =200μsec
Consider half ofit=Tout = 100μ sec
N =Tout / Tin =100/1.085= 92.16
65536-92= 65444(10)=FFA5 H
Prog-
#include< reg51.h>
void delay(void);
sbit p=P3^5;
void main (void)
    while (1)
        $\ \ \ $ p=~p;
        delay();
void delay()
    TMOD=0X10; $\ \ \ \ \ \ \ \ \ $//set timer 1 in mode 1 i.e. 16 bit number
    TL0=0XA5H; $\ \ \ \ \ \ \ \ \ $//load TL register with LSB of count
    TH0=0XFFH ; $\ \ \ \ \ \ \ \ \ $//Load TH register with MSB of count
    TR1 =1 ; $\ \ \ \ \ \ \ \ \ $//Start timer 0
    While(TF1==0) $\ \ \ \ \ \ \ \ \ $//wait until timer rolls over
    TR1=0; $\ \ \ \ \ \ \ \ \ $//Stop timer 0
    TF1=0; $\ \ \ \ \ \ \ \ \ $//Clear timer flag 0
5. Find the contents of port after execution of following code i) P2=0×74>>3; ii)
P3=0×040×68;
Ans: Ans:
i) P2=0×74>>3;
=
ii) P3=0×04!0×68;
=0x04=0000 0100,0x68=0110 1000
0000 0100
                                            +
0110 1000
01101100
6C
P3=0×04!0×68=0X6C
6. Write a C program to toggle all bits of port 1 continuously with 60 ms delay in between.
Use timer 0 in mode 1 to generate the delay. The XTAL frequency is 11.0592 MHz.
Ans: #include <reg51.h>
void T0Delay(void);
void main(void){
while (1) {
P1=0x55;
T0Delay();
P1=0xAA;
T0Delay();
} }
void T0Delay()
{
TMOD=0x01;
TL0=0x00;
TH0=0x35;
TR0=1;
while (TF0==0);
TR0=0;
TF0=0;
Calculating delay:
FFFFH – 3500H = CAFFH
= 51967 + 1 = 51968
=51968 × 1.085 μs = 56.384 ms is the approximate delay.
7. Write 89C51 C program to mask the lower 4 bits of P2 and upper 4 bits of P0. Using
logical operator.
Ans: #include <stdio.h>
#include <reg51.h>
void main( )
{
    P2 = P2 &0xF0;
    P0=P0&0x0F;
    while(1);
8. Write a C language program to operate port 0 and port 2 as output port and port 1 and
port3 as input port.
Ans:
#include<reg51.h>
void main (void )
 {
unsigned char X,Y
 P0=0X00;              // P0 as output port
 P2=0X00;             // P2 as output port
P1=0XFF;             //P1 as input port
 P3=0XFF;            // P3 as input port
while(1)
{
X= P1;
 Y=P3;
P0=X;
P2=Y;
}                //end of while
}               //end of main
                        Unit- III (12 marks)
                 Communication Standards and Protocols
1. Draw 9 pin RS 232C connector and state significance of DTR and DSK signals.
Ans:
Data Terminal Ready – A positive voltage is applied to the data terminal ready (DTR) line,
a sign that the data terminal is prepared for the transmission of data
Data Set Ready – A positive voltage is applied to the data set ready (DSR) line, which
ensures the serial communications between a data terminal and a data set can be completed.
2. Compare between CAN and I2C protocols on the following points. i) ii) iii) iv) Data
Transfer rate Number of fields addressing bits Applications.
Ans:
Sr No                  Parameter                I2C                       CAN
1                      Data transfer rate       Synchronous with 3        Asynchronous with
                                                speeds                    250kbps upto 1mbps
                                                100kbps,400kbps and
                                                3.4mbps
2                      Number of fields         07                        08
3                      Addressing bits          7 bit or 10 bit address   11 bit
4                      Application              To interface devices like Elevator
                                                watchdog,flash and        controllers,medical
                                                RAM memory,Real time instruments,production
                                                clock and                 limit control system
                                                  microcontrollers
3. Draw and explain USB protocol also architecture of IrDA protocol.
Ans:
Universal Serial Bus is an industry standard used to define the cables, connectors and
communication protocols used in a bus for connection, communication and power supply
between computers and electronic devices.
➢ USB was designed to support data transfer and supply electric power between peripheral
devices such as mouse, keyboard, printer, portable media players, disk drive etc.
➢ A USB is a common computer port, which shorts for Universal Serial Bus and allows
communication between a computer and peripheral or other devices. It is the most common
interface used in today's computers, which can be used to connect printers, scanners,
keyboards, mice, game controllers, digital cameras, external hard drives and flash drives.
 Multiple device connection: Upto 127 different devices can be connected on single USB
bus.
 Transfer rate: The initial USB supported 12 MBps transfer rate where USB 2.0 supports
higher rate currently 60 MB/sec.
IrDA Architecture-
    Protocol Architecture
The IrDA Data Protocol consists of a mandatory set of protocols and a set of optional
protocols.
Mandatory Protocols
1. IrPHY(Physical signaling layer)
2. IrLAP(Link Access Protocol)
3. IrLMP(Link Management Protocol)
4. IAS(Information Access Protocol)
Optional Protocols
1. IrCOMM (IR communication protocol)
2. Tiny-TP (Tiny transport protocol)
3. IrOBEX (IR object exchange protocol)
4. IrLAN (IR local area network protocol)
IrPHY
• Basic level of IrDA specifications
• Necessary in all IrDA devices
• Lays out the angle limits, speed range, distance range and modulation
IrLAP
• Responsible for performing device discovery and negotiation
• Provides a reliable transmission medium on which to build additional communications
• Based on HDLC protocol
• Responsible for preserving the physical connection
• Facilitates error detection, retransmission of lost or damaged packets & rudimentary flow
control
IrLMP
• Allows one or more IrDA services to run over a single IrLAP connection
4. State any four features of ZigBee. Draw and explain CAN bus with frame format.
Ans:
1) IEEE Standard 802.15.4
2) Frequency (GHz) 0.868, 0.915, 2.4
3) Maximum raw bit rate (Mbps) 0.250
4) Typical data throughput (Mbps) 0.2
5) Maximum (Outdoor) Range (Meters) 10-100
6) Relative Power Consumption Very low
5. Draw the frame format of I2C and explain fields therein.
Ans: CAN Standard Frame
        Various fields in standard CAN are as follows-
SOF - Start of Frame bit. It indicates start of message and used to synchronize the nodes on a
bus. A dominant bit in the field marks the start of frame.
IDENTIFIER - It serves dual purpose one, to determine which node has access to the bus and
second to identify the type of message.
RTR - Remote Transmission Request. It identifies whether it’s a data frame or a remote
frame .RTR is dominant when it is a data frame and recessive when it is a remote frame.
IDE – Identifier Extension. It is used to specify the frame format. Dominant bit is for standard
frame and recessive for extended frame.
R0 - Reversed bit. Not used currently and kept for future use.
DLC – Data Length Code. It is 4 bit data length code that contains the number of bytes being
transmitted.
DATA– Used to store up to 64 data bits of application data to be transmitted.
CRC– Cyclic Redundancy Check. The 16-bit (15 bits plus delimiter) cyclic redundancy check
(CRC) contains the checksum of the preceding application data for error detection.
ACK – Acknowledge (ACK) field. It compromises of the ACK slot and the ACK delimiter.
When the data is received correctly the recessive bit in ACK slot is overwritten as dominant bit
by the receiver.
EOF– End of Frame (EOF). The 7-bit field marks the end of a CAN frame (message) and
disables
Bit - stuffing, indicating a stuffing error when dominant.
IFS - Inter Frame Space that specifies minimum number of bits separating consecutive messages.
It provides the intermission between two frames and consists of three recessive bits known as
intermission bits. This time allows nodes for internal processing before the start of next frame.
                              Unit- IV (18 marks)
                     Interfacing Input and Output devices
1. Draw interfacing of ADC with 89C51 and explain function of SOC, EOC and OE.
Ans:
   ADC808/809 Chip with 8 analogchannel. This means this kind of chip allows
to monitor 8 different transducers.
• ADC804 has only ONE analog input: Vin(+).
• ALE: Latch in the address
• Start : Start of conversion (same as WR in 804)
• OE: output enable (same as RD in 804)
• EOC: End of Conversion (same as INTR in 804)
2. Draw interfacing diagram of 4 × 4 matrix keyboard with 89C51.
Ans:
3. Write a ‘C’ language program to rotate stepper motor by 90° clockwise. Assume step
angle of 1.8° and 4 step sequences.
Ans: To rotate stepper motor for 900
Assuming step angle as 1.80
No. of steps = 90/1.8 = 50
The for loop should be executed 48/4=12 times and the pattern should be
given two times after the for loop
# include <reg51.h>
void Msdelay (unsigned int);
unsigned char x;
void main (void)
{
for(x=0;x<12;x++)
{
P1=0x09;
Msdelay (100)
P1=0x0C;
Msdelay(100)
P1=0x06;
Msdelay(100)
P1=0x03;
Msdelay(100)
}
P1=0x09;
Msdelay (100)
P1=0x0C;
Msdelay(100)
}
Void Msdelay(unsigned int k)
{
Unsigned int x,y;
For (x=0;x<k;x++)
For (y=0;y<1275;y++);
}
4. Draw interface diagram of 7 segment LED display to 89C51 and write a C program
to display 0-9 continuously.
Ans:
#include <reg51.h>
 void msdelay(unsigned int);
 unsigned Char disp_code[]=
{0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
 unsigned char x;
 void main(void)
 {
 while (1)
 {
 for (x = 0; x<= 9; x++) // loop to display 0-9
 {
P2=disp_code[x];
 msdelay(100);
 }
 }
 }
 void msdelay(unsigned int k)
 {
 unsigned int I,j;
for(i=0;i<k;i++)
 {
 for(j=0;j<1275;j++);
 }
 }
5. Sketch the diagram to interface DAC 0808 to port O of microcontroller 89C51 and
write a Embedded C language program to generate square wave to 50% duty cycle.
Ans:
6. Draw the interfacing diagram for temperature measurement using LM35, ADC 0808
with microcontroller 89C51.
Ans:
Temperature sensor are basically classified into two types
• Non Contact Temperature Sensors: These temperature sensors use
convection & radiation to monitor temperature
• Contact Temperature Sensors: Contact temperature sensors are then
further sub divided into three type
• Electro-Mechanical(Thermocouples).
• Resistive Resistance Temperature Detectors (RTD).
• Semiconductor based. (LM35, DS1820 etc).
LM35 is an integrated analog temperature sensor whose electrical output is
proportional to Degree Centigrade. LM35 Sensor does not require any
external calibration or trimming to provide typical accuracies. The LM35’s
low output impedance, linear output, and precise inherent calibration make
interfacing to readout or control circuitry especially easy. Prefix LM stands
for linear monolithic.
\
7. Draw labelled diagram to interface 16 × 2 LCD with 89C51. State function of pins i)
ii) iii) RS RIW EN
       Ans:
                     Unit- V (12 marks)
           Real Time Operating Systems (12 marks)
 ________________________________________________________
 1.Explain watchdog timer and semaphore in detail.
 Ans:
 1.watchdog timer-
  Most embedded systems need to be self-reliant. It’s not usually possible to wait for someone
to reboot them if the software hangs. Some embedded designs, such as space probes, are
simply not accessible to human operators. If their software ever hangs, such systems are
permanently disabled. In other cases, the speed with which a human operator might reset the
system would be too slow to meet the uptime requirements of the product.
     A watchdog timer (WDT) is a piece of hardware that can be used to automatically detect
software anomalies and reset the processor if any occur. Generally speaking, a watchdog timer
is based on a counter that counts down from some initial value to zero. The embedded software
selects the counter’s initial value and periodically restarts it. If the counter ever reaches zero
before the software restarts it, the software is presumed to be malfunctioning and the
processor’s reset signal is asserted. The processor (and the embedded software it’s running)
will be restarted as if a human operator had cycled the power.
 Figure 1 shows a typical arrangement. As shown, the watchdog timer is a chip external to the
processor. However, it could also be included within the same chip as the CPU. This is done in
many microcontrollers. In either case, the output from the watchdog timer is tied directly to the
processor’s reset signal.
  2.Semaphore: a signal between tasks/interrupts that does not carry any additional data. The
meaning of the signal is implied by the semaphore object, so you need one semaphore for each
purpose. The most common type of semaphore is a binary semaphore, that triggers activation
of a task. The typical design pattern is that a task contains a main loop with an RTOS call to
“take” the semaphore. If the semaphore is not yet signaled, the RTOS blocks the task from
executing further until some task or interrupt routine “gives” the semaphore, i.e., signals it.
 2.Compare general purpose operating system and RTOS (four points)
 Ans:
  Sr    OS                                                        RTOS
  no
  1     Non-Deterministic time behavior.                          Deterministic time behavior.
  2     Used in general desktop computer system.                  Used in embedded system
  3     Generalized Kernel.                                       Real time kernel.
  4     OS services can inject random delays into application     OS services consumes only known and
        software, may cause slow responsiveness of an             expected amounts of time regardless the
        application at unexpected time.                           number of services.
  5     Slow context switching                                    fast context switching
  6     More memory requirements                                  Less memory requirements
  7     Ex: Windows XP, MS-DOS                                    Ex: Windows CE, VxWorks
 3. Describe inter task communication with reference to RTOS. Explain pre-emptive and
 round robin scheduling algorithm in RTOS.
 Ans:
      Software is the basic building block of RTOS. Task is a simply subroutine. Task must
       be able to communicate with one another to coordinate their activities or to share the
       data.
    Kernel object is used for inter task communication. Kernel objects uses message
       queue, mail box and pipes, Shared Memory, Signal Function and RPC a for inter task
       communication.
Message queue:-
    A message queue is a buffer like data structure, through which tasks and ISRs
       communicate with each other by sending and receiving messages and synchronize
       with data.
    It temporarily stores the message from a sender until the intended receiver is ready to
       read them.
    A message queue has queue control block, queue name, unique ID, memory buffers, a
       queue length. Kernel allocates the memory for message queue, ID, control block etc.
Mail box:-
    In general, mailboxes are similar to message queues. Mail box technique for inter task
       communication in RTOS based system used for one way messaging.
    The task/thread creates mail box to send the message. The receiver task can subscribe
       the mail box. The thread which creates the mail box is known as mailbox server.
    The others are known as client. RTOS has function to create, write and read from mail
       box. No of messages (limited or unlimited) in mail box have been decided by RTOS.
Pipes :-
    Pipes are kernel objects used for unstructured data exchange between tasks facilities
       synchronization among tasks. Pipe provides a simple data transfer facility.
Shared Memory :-
    Shared memory is simplest way of inter process communication. The sender process
       writes data into shared memory and receiver process reads data.
Preemptive scheduling :-
    Preemptive scheduling ensures that every task will get CPU time for execution . The
     allotment of CPU time depends on the preemptive scheduling algorithm.
    It allows a process to be interrupted in the middle of its execution, taking the CPU
     away and allocating it to another process. The scheduling algorithm has high
     overhead. System is costly and complex in design.
Round-robin scheduling:-
      In the round robin algorithm, each process gets a small unit of CPU time (a time
         quantum), usually 10-100 milliseconds.
      After this time has elapsed, the process is pre empted and added to the end of the
         ready queue. If there are ‘ n’ processes in the ready queue and the time quantum is
         ‘q’, then each process gets ‘1/n’ of the CPU time in chunks of at most ‘q’ time units at
         once.
      No process waits more than ‘ (n-1)q’ time units.
      Performance of the round robin algorithm
 - q large then FCFS
 - q small then q must be greater than the context switch time; otherwise, the overhead is too
high
      One rule of thumb is that 80% of the CPU bursts should be shorter than the time
         quantum
      This algorithm is very simple to implement but there is no priorities for any task. All
       tasks are considered of equal importance . If time critical operation are not
       involved then this algorithm will be sufficient . Digital millimeter , microwave oven
       has this algorithm.
4. Sketch architecture of RTOS and explain function of kernel and device drivers. List
out characteristics of RTOS
Ans:
      For simple applications, RTOS is usually a kernel but as complexity increases,
       various modules like networking protocol, debugging facilities, device I/Os are
       included in addition to the kernel.
      The general architecture of RTOS is shown in the figure:
      An operating system generally consists of two ports: kernel space and user space.
   RTOS kernel acts as an observation layer between the hardware and the applications.
   Kernel is the smallest and central component of an operating system. Its services
    include managing memory and devices and to provide an interface for software
    applications to use the resources.
   Six types of common services provided by the kernel are shown below in the figure:
                  _________________***_______________