2019 Summer Model Answer Paper (Msbte Study Resources)
2019 Summer Model Answer Paper (Msbte Study Resources)
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER – 19 EXAMINATION
Subject Name: Embedded System Model Answer Subject Code: 17626
Important Instructions to examiners:
1) The answers should be examined by key words and not as word-to-word as given
in the model answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner
may try to assess the understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more
Importance (Not applicable for subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components
indicated in the figure. The figures drawn by candidate and model answer may
vary. The examiner may give credit for any equivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the
assumed constant values may vary and there may be some difference in the
candidate’s answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner
of relevant answer based on candidate’s understanding.
7) For programming language papers, credit may be given to any other program
based on equivalent concept.
GATE C/ T M1 M0 GATE C/ T M1 M0
TIMER1 TIMER0
Bit D7 and D3 (Gate):
It is set by programmer to control timer/counter by external hardware
interrupts INT1 and INT 0
If Gate =0 respective timer/counter operation is independent of external
hardware interrupt inputs such as INT1 and INT 0
Page No: 1 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
b State various addressing modes available in 8051 with two examples each. 4M
Ans 8051 supports following addressing modes. Any four
Addressing
1. Immediate Addressing Mode: In this addressing mode the operand/data modes
is specified within an instruction itself.
Each
Examples: Addressing
Mode with
MOV A, #20H This instruction moves immediate data 20H into Accumulator.
correct
MOV R5, #88H This instruction moves immediate data 88H into R5 register.
example : 1M
Page No: 2 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Page No: 3 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
External timer /
Input pin gives pulse
counter 0 to T0, register of the
P3.4 T0 -
timer 0 to increase N
by 1
External timer / Input pin gives pulse
counter 1 to T1, register of the
P3.5 T1 -
timer 0 to increase
by 1
It is an external Pulse it is an active
P3.6 WR - memory writer low pulse
It is an external Pulse whenever data
P3.7 RD - memory reader from memory is read
d Draw labelled diagram to interface 4 x 4 keyboards to 8051. 4M
Ans Correct
Diagram :
4M
e State four features of embedded systems and state any four applications. 4M
Ans 1) Embedded systems are designed to do some specific task, rather than be a Any four
general-purpose computer for multiple tasks. Some also have real-time feature &
performance constraints that must be met, for reasons such as safety and Application
usability; others may have low or no performance requirements, allowing the
system hardware to be simplified to reduce costs. Each feature
2) Embedded systems are not always standalone devices. Many embedded ½M
systems consist of small, computerized parts within a larger device that serves a
Each
more general purpose
Application
3) The program instructions written for embedded systems are referred to as
firmware, and are stored in read-only memory or Flash memory chips. They run ½M
with limited computer hardware resources: little memory, small or non-existent
keyboard and/or screen.
Page No: 4 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Page No: 5 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Page No: 6 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
iv) END:
This directive must be at the end of every program meaning that in the source
code anything after the END directive is ignored by the assembler.
This indicates to the assembler the end of the source file (asm).
Once it encounters this directive, the assembler will stop interpreting program
into machine code. e.g. END; End of the program.
b Draw the format of IE SFR. Explain the function of each bit. 4M
(MSB) (LSB)
Bit D7 (EA) :
Page No: 7 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Page No: 8 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Ans Diagram : 2M
Program : 2M
Program in C
#include<reg51.h>
void delay(unsigned int);
unsigned int d;
void main(void)
{
while(1)
{
for(d=0; d<256; d++)
{
P1 = d;
Delay(2);
}
}
}
void delay(unsigned int i)
{
Unsigned int x,y;
for(x=0; x<i; x++)
for(y=0; y<100;y++);
}
Program in Assembly
ORG 0000H
REPEAT:CLR A
UP: MOV P1,A
INC A
LCALL DELAY
Page No: 9 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
CJNE A,#0FFH,UP
SJMP REPEAT
MOV R2, #100
DJNZ R2, $
RET
d Draw and explain the format of TCON register. 4M
Page No: 10 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Ans Software is the basic building block of RTOS. Task is a simply subroutine. Correct
Task must be able to communicate with one another to coordinate their explanation :
activities or to share the data. Kernel object is used for inter task/process 4M
communication. Kernel objects uses message queue, mail box and pipes,
Shared Memory, Signal Function and RPC 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.
Signal Function: Operating system provides the signal function for messaging
among task (process).
Remote Procedure Call (RPC) and Sockets: RPC is a mechanism used by
process (task) to call the procedure of another process running on same or
different CPU in the network. Sockets are used for RPC communication and
establish full duplex communication between tasks.
Page No: 11 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
(iv)Device programmer
Ans (i)In Circuit Emulator (ICE): In-circuit emulator (ICE) is one of the oldest Correct
embedded debugging tools, and is still unmatched in power and capability. function 1M
It is only tool that substitutes its own internal processor for the one in the target for each
system
Using one of a number of hardware tricks, the emulator can monitor everything
that goes on in this on-board CPU, giving a complete visibility into the target
code’s operation. The emulator is bridge between the target and workstation
giving an interactive terminal peering deeply into the target and a rich set of
debugging resources. ICE uses another circuit with a card that connects to
target processor (circuit) through a socket.
(iii)Target Board:
a. In the embedded world, most programming work is done on a computer
system on which all the programming tools run.
b. Only after the program has been written, complied assembled and linked it is
moved to the final system. This is called the target system which is developed
for customer.
c. The host computer is therefore called as the development processor and the
final system developed is called as the target processor system.
d. In the development phase, the code of the application software has to be
written in flash memory. These codes repeatedly written \ modified & tested
using simulation & debugging tools till final phase (work according to
specification)
e. Once the application software finally working they may down load to ROM
instead of flash memory in the target system.
Page No: 12 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Message queue.
Mutual exclusion.
Page No: 13 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Dead lock.
Mailboxes.
Message Queues.
Mutual Exclusion:-
The easiest way for threads to communicate with each other is through shared
data structures. This is especially easy when all threads exist in single address
space and can reference global variables, pointers, buffers, linked lists, FIFOs
etc.
When two or more task access shared resources without corrupting data is
called Mutual Exclusion.
It can be performed in the following ways:
• Disabling the scheduler
• Disabling the interrupts
Page No: 14 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Page No: 15 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
2. Translating the Code Next the source code needs to be translated into
instructions the microcontroller can actually execute. A microcontroller’s
instruction set is represented by "op codes". Op codes are a unique sequence of
bits ("0" and "1") that are decoded by the controller's instruction decode logic
and then executed. Instead of writing opcodes in bits, they are commonly
represented as hexadecimal numbers, whereby one hex number represents 4 bits
within a byte, so it takes two hex numbers to represent 8 Bits or 1 byte. For that
reason a microcontroller's firmware in machine readable form is also called
Hex-Code and the file that stores that code Hex-File. Assemblers, Compilers,
Linkers and Librarians Assemblers or (C-) Compilers translate the human
readable source code into "hex code" that represents the machine instructions
(op codes)
3. Debugging the Code A debugger is a piece of software running on the PC,
which has to be tightly integrated with the emulator that you use to validate
your code. For that reason all emulator manufacturers ship their own debugger
software with their tools, but also compiler manufacturers frequently include
debuggers, which work with certain emulators, into their development suites.
4. OTP and Flash Programming It can't be stretched enough: A starter kit or
emulators are no substitute for a production grade programmer. Using the
microcontroller sockets on starter kit boards is ok to program one or two
Samples in the lab, but those sockets cannot withstand hundreds or thousands of
insertions. You will also find that starter kits do not include any sockets for
surface mount devices, as those sockets are extremely expensive.
Page No: 16 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
There are 256 bytes of internal RAM on the 8051. 28 = 256, therefore the
internal RAM address bus is 8 bits wide and internal RAM locations go from
00H to FFH.The first 128 locations (00H to 7FH) of internal RAM are used by
the programmer for storing data while the second 128 locations (80H to FFH)
are the Special Function Registers (SFRs).The diagram below is a summary of
the 8051 on-chip RAM.
Page No: 17 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Register Banks There are four register banks from 00H to 1FH. On power-up,
registers R0 to R7 are located at 00H to 07H. However, this can be changed so
that the register set points to any of the other three banks (if you change to Bank
2, for example, R0 to R7 is now located at 10H to 17H). Bit-addressable
Locations The 8051 contains 210 bit-addressable locations of which 128 are at
locations 20H to 2FH while the rest are in the SFRs. Each of the 128 bits from
20H to 2FH have a unique number (address) attached to them, as shown in the
table above. The 8051 instruction set allows you to set or reset any single bit in
this section of RAM. With the general purpose RAM from 30H to 7FH and the
register banks from 00H to 1FH, you may only read or write a full byte (8 bits)
at these locations.
However, with bit-addressable RAM (20H to 2FH) you can read or write any
single bit in this region by using the unique address for that bit. We will later
see that this is a very powerful feature. Special Function Registers (SFRs)
Locations 80H to FFH contain the special function registers. As you can see
from the diagram above, not all locations are used by the 8051 (eleven locations
are blank). These extra locations are used by other family members (8052, etc.)
for the extra features these microcontrollers possess.
Also note that not all SFRs are bit-addressable. Those that are having a unique
address for each bit.
2. SWAP A :- This instruction swaps bits 0-3 of the Accumulator with bits
4-7 of the Accumulator.
Page No: 18 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Fout = 1 KHz
Ton= 1/ 1X 103
NOTE: Students can consider any frequency with 50% duty cycle. Accordingly
TH0 and TL0 will change. They can consider even timer 1.
ORG 0000
ACALL DELAY;
Page No: 19 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SJMP HERE;
CLR TF0 ;
RET
f Draw labelled diagram to interface Analog to Digital converter (ADC) 4M
0808 to 0851.
Ans Interfacing of ADC with 8051: Diagram :
4M
Note : any
relevant
diagram give
marks
The concept of interrupt service routine is used to address & service the
device I/Os and interrupts
Page No: 20 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Sjmp start
Org 0030h
DJNZ R2,H1
RET
End
c Explain the need and requirement of RTOS in an embedded system. 4M
Ans Need of RTOS: Need : 2M
Requirement:
1. Scheduling, Synchronization: RTOS provides effective scheduling and 2M
Page No: 21 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
2. Fast Execution: it provides running the user threads in Kernel space so that
they execute fast. RTOS also provides faster memory allocation.
Requirement of RTOS:
ii) Predictability Because many embedded systems are also real-time systems,
meeting time requirements is key to ensuring proper operation. The RTOS used
in this case needs to be predictable to a certain degree. The term deterministic
describes RTOS with predictable behavior, in which the completion of
operating system calls occurs within known timeframes.
Page No: 22 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
9. One 16-bit program counter and One 16-bit DPTR ( data pointer)
Page No: 23 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
END
f Describe the functions of part 1 of 8051 microcontroller and also draw the 4M
internal structure of part 1.
Ans Diagram : 3M
Function :1M
Page No: 24 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
8051 architecture handles 5 interrupt sources, out of which two are internal
(Timer Interrupts), two are external and one is a serial interrupt. Each of these
interrupts has their interrupt vector address. Highest priority interrupt is the
Page No: 25 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Reset is the highest priority interrupt, upon reset 8051 microcontroller start
executing code from 0x0000 address.
Serial interrupt
8051 has serial communication port and have related serial interrupt flags
(TI/RI). When the last bit (stop bit) of a byte is transmitted, TI serial interrupt
flag is set and when last bit (stop bit) of receiving data byte is received, RI flag
get set.
c Draw the block diagram of embedded system. Explain various hardware 4M
units.
Ans The various elements included in embedded system are: Block
diagram : 2M
Explanation :
2M
Page No: 26 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Page No: 27 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Clock Oscillator Circuit and Clocking units: For the processing units, a
highly stable oscillator is required and the processor clock out signal provides
the clock for synchronizing all the system units.
Reset Circuit, Power up reset and Watch dog timer: A program that is reset
and runs on a power up can be one of the following:
A system program that executes from the start.
A system boot up program.
A system initialization program.
The watch dog timer reset is used in control applications.
LCD and LED displays: For displaying and messaging, the LCD matrix
displays and LED arrays are used in a system. The system must provide
Page No: 28 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
necessary interfacing circuit and software for the output to LCD display
controller and LED interfacing ports.
Task States:
Ready State: When a task is first created and made ready to run, the kernel puts
it into the ready state. In this state, the task actively competes with all other
ready tasks for the processor's execution time. As Figure shows, tasks in the
ready state cannot move directly to the blocked state. Task first needs to run so
it can make a blocking call, which is a call to a function that cannot
immediately run to completion, thus putting the task in the blocked state. Ready
tasks, therefore, can only move to the running state. Because many tasks might
be in the ready state, the kernel's scheduler uses the priority of each task to
determine which task to move to the running state.
For a kernel that supports only one task per priority level, the scheduling
algorithm is straightforward-the highest priority task that is ready runs next. In
this implementation, the kernel limits the number of tasks in an application to
the number of priority levels.
However, most kernels support more than one task per priority level, allowing
many more tasks in an application. In this case, the scheduling algorithm is
more complicated and involves maintaining a task-ready list. Some kernels
maintain a separate task-ready list for each priority level; others have one
combined list.
Page No: 29 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Running State: On a single-processor system, only one task can run at a time. In
this case, when a task is moved to the running state, the processor loads its
registers with this task's context. The processor can then execute the task's
instructions and manipulate the associated stack.
As discussed in the previous section, a task can move back to the ready state
while it is running. When a task moves from the running state to the ready state,
it is pre-empted by a higher priority task. In this case, the pre-empted task is put
in the appropriate, priority-based location in the task-ready list, and the higher
priority task is moved from the ready state to the running state.
Unlike a ready task, a running task can move to the blocked state in any of the
following ways:
By making a call that requests an unavailable resource,
By making a call that requests to wait for an event to occur, and
By making a call to delay the task for some duration.
In each of these cases, the task is moved from the running state to the
blocked state.
Page No: 30 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Page No: 31 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
C language Program:
#include <reg51.h>
void main (void)
{
unsigned int x,y;
unsigned char mybyte = 0x29;
x= mybyte & 0x0f; ----- Mask lower 4 bits.
P1=x;
y= mybyte & 0xf0; ------------Mask upper 4 bits.
y= y >> 4; ------------Shift it to lower 4 bits.
P2 = y;
}
Page No: 32 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
ORG 0003H
SETB P1.7 ; Turn on the LED.
MOV R0, 200 ; Delay
WAIT: DJNZ R0, WAIT
CLR P.7 ; Turn off the LED
RETI
ORG 30H
MAIN: SETB IT0
MOV IE, #84H
WAIT2: SJMP WAIT2
END
Page No: 33 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
In this example, process 1 wants the resource 2 ex; scanner while holding the
resource 1 ex: printer. Process 1 cannot proceed until both the printer and the
scanner are in its possession.
Process 2 wants the printer while holding the scanner. Process 2 cannot
continue until it has the printer and the scanner.
Because neither process 1 nor process 2 is willing to give up what it already
has, the two tasks are now deadlocked because neither can continue.
Page No: 34 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
(d) ANL C,! (P1.4); AND inverted bit on P1.4 with carry
Page No: 35 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Ans Diagram : 4M
Page No: 36 | 3 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Page No: 37 | 3 7