Esd 1
Esd 1
Esd 1
Processor
A processor is the main brain inside any embedded systems. This is a major factor that affects the
performance of the system. There are different processors available in the market. An embedded
system may use microprocessor or microcontroller.
Memory
If we are using a microcontroller like AT89s51, AT89s52 or ATmega. The memory is available on-chip.
We generally talk about two types of memory in the embedded systems
Read-Only memory(RAM)
Random Access Memory(ROM)
Electrically Erasable Programmable Read-Only Memory (EEPROM)
Timers-Counters
If you are working in embedded systems you must have heard about
What are timer and counter
Why we use timer and counter
What is difference between timers and counter
In some application, we need to generate some delay. Like for blinking an LED, we need a delay. For
making square pulse we need a delay.
Communication Ports
Embedded systems hardware has different types of communication ports to communicate with the
other embedded devices.
Software Components
Assembler
When you program in assembly language. This assembly language program is converted into the HEX
code using this utility. Then using some hardware called as a programmer we write the chip.
Emulator
An emulator is hardware or software tool that has a similar functionality to the target system or
guest system. It enables the host system to execute the functionality and other components.
Debugger
Sometimes we are not getting expected results or output due to errors or bug. There are certain
tools that are specifically used for the debugging process. Where we can see the controls flow and
register value to identify the issue.
Compiler
A compiler is a software tool that converts one programming language into target code that a
machine can understand.
2. A microcontroller has required on-chip memory with associated peripherals. A microcontroller can
be thought of a microprocessor with inbuilt peripherals.
3. A microcontroller does not require much additional interfacing ICs for operation and it functions
as a stand alone system. The operation of a microcontroller is multipurpose, just like a Swiss knife.
4. Microcontrollers are also called embedded controllers. A microcontroller clock speed is limited
only to a few tens of MHz. Microcontrollers are numerous and many of them are application
specific.
3.A scheduler is a part of real time operating system and it keeps track of the states of each block.
Answer the following question about the scheduler and task states.
i) How does the scheduler know when a task becomes blocked or unblocked ?
ii) What happens if two states with same priority are ready ?
iii) What happens if all the tasks are locked ?
Ans:-1. : RTOS provides functions for tasks to tell scheduler:
„ what events the tasks want to wait for
„ to signal that events have happened
2. Depends on RTOS.
„ Illegal to have two tasks with same priority
„ Time-slice between the two tasks
„ Run one until blocked, then run the other
„ Backup scheduling policy: round-robin, FIFO
4. What are embedded system and explain the challenges encountered during Design.
Ans:- Embedded systems, also known as embedded computers, are small-form-factor computers
that power specific tasks.
The general microcontroller consists of the processor, the memory (RAM, ROM, EPROM), Serial
ports, peripherals (timers, counters), etc.
Types of Microcontrollers
Microcontrollers are divided into various categories based on memory, architecture,
bits and instruction sets. Following is the list of their types −
Bit
Based on bit configuration, the microcontroller is further divided into three categories.
• 8-bit microcontroller − This type of microcontroller is used to execute
arithmetic and logical operations like addition, subtraction, multiplication
division, etc. For example, Intel 8031 and 8051 are 8 bits microcontroller.
• 16-bit microcontroller − This type of microcontroller is used to perform
arithmetic and logical operations where higher accuracy and performance is
required. For example, Intel 8096 is a 16-bit microcontroller.
• 32-bit microcontroller − This type of microcontroller is generally used in
automatically controlled appliances like automatic operational machines,
medical appliances, etc.
Memory
Based on the memory configuration, the microcontroller is further divided into two
categories.
• External memory microcontroller − This type of microcontroller is designed
in such a way that they do not have a program memory on the chip. Hence, it
is named as external memory microcontroller. For example: Intel 8031
microcontroller.
• Embedded memory microcontroller − This type of microcontroller is
designed in such a way that the microcontroller has all programs and data
memory, counters and timers, interrupts, I/O ports are embedded on the chip.
For example: Intel 8051 microcontroller.
Instruction Set
Based on the instruction set configuration, the microcontroller is further divided into
two categories.
• CISC − CISC stands for complex instruction set computer. It allows the user to
insert a single instruction as an alternative to many simple instructions.
• RISC − RISC stands for Reduced Instruction Set Computers. It reduces the
operational time by shortening the clock cycle per instruction.
Microcontrollers are mainly used in devices like:
• Mobile phones
• Automobiles
• CD/DVD players
• Washing machines
• Cameras
• Security alarms
• Keyboard controllers
• Microwave oven
• Watches
• Mp3 players
Unit 4
EQU (equate)
This is used to define a constant without occupying a memory location. The EQU directive does not
set aside storage for a data item but associates a constant value with a data label so that when the
label appears in the program, itp constant value will be substituted for the label. The following uses
EQU for the counter constant and then the constant is used to load the R3 register.
END directive
Another important pseudocode is the END directive. This indicates to the assembler the end of the
source (asm) file. The END directive is the last line of an 8051 program, meaning that in the source
code anything after the END directive is ignored by the assembler. Some assemblers use “. END”
(notice the dot) instead of “END”.
2. Mention and explain the 8051 flag bits and PSW register.
Ans:- The program status word (PSW) register is an 8-bit register, also known as flag register. It is of
8-bit wide but only 6-bit of it is used. The two unused bits are user-defined flags. Four of the flags
are called conditional flags, which means that they indicate a condition which results after an
instruction is executed. These four are CY (Carry), AC (auxiliary carry), P (parity), and OV (overflow).
The bits RS0 and RS1 are used to change the bank registers. The following figure shows the program
status word register.
The PSW Register contains that status bits that reflect the current status of the CPU.
CY CA F0 RS1 RS0 OV - P
P PSW.0 Parity FLAG. Set/ cleared by hardware during instruction cycle to indicate even/odd number of 1 bit i
accumulator.
We can select the corresponding Register Bank bit using RS0 and RS1 bits.
0 0 0 00H-07H
0 1 1 08H-0FH
1 0 2 10H-17H
1 1 3 18H-1FH
• CY, the carry flag − This carry flag is set (1) whenever there is a carry out from the D7 bit. It is
affected after an 8-bit addition or subtraction operation. It can also be reset to 1 or 0
directly by an instruction such as "SETB C" and "CLR C" where "SETB" stands for set bit carry
and "CLR" stands for clear carry.
• AC, auxiliary carry flag − If there is a carry from D3 and D4 during an ADD or SUB operation,
the AC bit is set; otherwise, it is cleared. It is used for the instruction to perform binary
coded decimal arithmetic.
• P, the parity flag − The parity flag represents the number of 1's in the accumulator register
only. If the A register contains odd number of 1's, then P = 1; and for even number of 1's, P =
0.
• OV, the overflow flag − This flag is set whenever the result of a signed number operation is
too large causing the high-order bit to overflow into the sign bit. It is used only to detect
errors in signed arithmetic operations.
Interrupts
As its name suggests, Interrupt is a subroutine call that interrupts of the microcontrollers main
operations or work and causes it to execute any other program, which is more important at the
time of operation. The feature of Interrupt is very useful as it helps in case of emergency operations.
Memory
Microcontroller requires a program which is a collection of instructions. This program tells
microcontroller to do specific tasks. These programs require a memory on which these can be saved
and read by Microcontroller to perform specific operations of a particular task. The memory which is
used to store the program of the microcontroller is known as code memory or Program memory of
applications.
BUS
Basically Bus is a collection of wires which work as a communication channel or medium for transfer
of Data. These buses consists of 8, 16 or more wires of the microcontroller. Thus, these can carry 8
bits,16 bits simultaneously. Hire two types of buses that are shown in below
Address Bus
Data Bus
Oscillator
Generally, we know that the microcontroller is a device, therefore it requires clock pulses for its
operation of microcontroller applications. For this purpose, microcontroller 8051 has an on-chip
oscillator which works as a clock source for Central Processing Unit of the microcontroller.
Input/Output Port
Normally microcontroller is used in embedded systems to control the operation of machines in the
microcontroller. Therefore, to connect it to other machines, devices or peripherals we require I/O
interfacing ports in the microcontroller interface.
A counter is a device that stores (and sometimes displays) the number of times a particular event or
process occurred, with respect to a clock signal. It is used to count the events happening outside the
microcontroller. In electronics, counters can be implemented quite easily using register-type circuits
such as a flip-flop.
6. Write a short note on :1) CALL Instructions. 2) 8051 Register Banks. 3) 8051 Counter
Ans:- 1) CALL Instructions
The call instruction transfers the program sequence to the memory address given in the operand.
Before transferring, the address of the next instruction after CALL is pushed onto the stack. Call
instructions are 2 types: Unconditional Call Instructions and Conditional Call Instructions.
2) 8051 Register Banks
A total of 32 bytes of RAM are set aside for the register banks and the stack. These 32 bytes are
divided into four register banks in which each bank has 8 registers, R0–R7. RAM locations from 0 to 7
are set aside for bank 0 of R0–R7 where R0 is RAM location 0, R1 is RAM location 1, R2 is location 2,
and so on, until the memory location 7, which belongs to R7 of bank 0.
The second bank of registers R0–R7 starts at RAM location 08 and goes to locations OFH. The third
bank of R0–R7 starts at memory location 10H and goes to location to 17H. Finally, RAM locations
18H to 1FH are set aside for the fourth bank of R0–R7.
3) 8051 Counter
A counter is a device that stores (and sometimes displays) the number of times a particular event or
process occurred, with respect to a clock signal. It is used to count the events happening outside the
microcontroller. In electronics, counters can be implemented quite easily using register-type circuits
such as a flip-flop.
7.
9. The difference between. i) LCALL and ACALL ii) LJMP and SJMP
Ans:-
LCALL ACALL
It is also called long call. It is also called absolute call.
target address for LCALL can be anywhere the target address of CALL is within a 2K-byte
within the 64K-bytes address space of the 8051 range.
It is a 3-byte instruction. it is a 2-byte instruction.
LJMP SJMP
It is also called long jump. It is also called short jump.
Long jump range is 64 kb Short jump, relative address is 8 bit it support
127 location forward
It uses 16 bit address It uses 8 bit address
It is a 3 byte instruction It is a 2 byte instruction
Unit 5
3.Explain the following register of 8051 used for serial communication. i) SBUF ii) SCON.
Ans:- SBUF register
SBUF is an 8-bit register used solely for serial communication in the 8051. For a byte of data to be
transferred via the TxD line, it must be placed in the SBUF register. Similarly, SBUF holds the byte of
data when it is received by the 8051 ‘s RxD line. SBUF can be accessed like any other register in the
8051. Look at the following examples of how this register is accessed:
The moment a byte is written into SBUF, it is framed with the start and stop bits and transferred
serially via the TxD pin. Similarly, when the bits are received serially via RxD, the 8051 deframes it by
eliminating the stop and start bits, making a byte out of the data received, and then placing it in the
SBUF.
• Mode 0:
o In this mode the serial port function as half duplex serial port with fixed baud rate.
o The 8- bit serial data is received and transmitted through RxD pin and the controller output the
• Mode 1:
o In this mode the serial port function as full duplex serial port with variable baud rate.
o In this mode one data consists of 10 bits, which includes one start bit, eight data bit and one stop
bit. During reception the stop bit is stored as RB8 in SCON register.
o Baud rate in mode-1 depends on the value of SMOD bit in PCON register and the timer1overflow
rate.
• Mode 2:
o In this mode the serial port function as full duplex serial port with a baud rate of either 1/32 or
o In this mode one data consists of 11 bits which includes one start bit, eight data bit, a
o During transmission the TB8 of SCON register is added as 9th data bit and during reception the
o The baud rate depends on the value of SMOD bit in PCON register.
• Mode 3:
o In mode-3, the baud rate is variable. The baud rate depends on the value of SMOD bit in PCON
• The serial mode bit-2 (SM2) has no effect in mode-0 and when programmed for mode-0, the
• In mode-1, SM2 is used to check a valid stop bit during reception. In mode-1, if SM2 = 1, then
receive interrupt (RI) is activated only when a valid stop bit is received.
• In mode-2 and mode-3 the SM2 bit is used to enable multiprocessor communication.
connected to a common serial bus. One controller will act as a master and all other controller will
act as slave.
• A unique 8-bit address is assigned to each slave and the SM2 bit in all the slaves is set to 1.
• When SM2 bit is one, the slaves will consider the received byte as address and when SM2 bit is
zero the slaves will consider the received byte as data.
• For communication with a slave the master will first send as address byte and then a data byte.
• The master initiates communication with a slave by sending the address of the slave on the bus.
All the slaves will receive the address byte. Since SM2 = 1 initially in all the slaves, the received byte
will be considered as address and the slaves will verify whether the received address matches with
assigned address. The slave whose assigned address matches with received address will clear its
SM2 bit. Now SM2 bit of only one of the slave will be zero.
• Next the master will send a data byte which is also received by all the slave, but the data byte is
accepted by the slave whose SM2 = 0 and so the receive interrupt is activated only in one of the
• After reading the received data from SBUF register, the SM2 bit of the slave should be set to one
• The REN bit of SCON register can be used to enable or disable the serial reception. When REN =
1, the serial reception is enabled and when REN = 0, the serial reception is disabled.
• The bits TI and RI of SCON register are transmitting interrupt flag and receive interrupt flag
respectively.
• The controller will set the TI bit during the transmission of stop bit of a data character in mode 1
• The controller will set the RI bit during the reception of stop bit of a data character in mode 1 to
5. Write a program for the 8051 to transfer letter "A" serially at 4800 baud, continuously.
Unit 2
1. What is priority inversion problem in RTOS?
Ans:- Priority inversion is a operating system scenario in which a higher priority process is
preempted by a lower priority process. This implies the inversion of the priorities of the two
processes.
Problems due to Priority Inversion
Some of the problems that occur due to priority inversion are given as follows −
• A system malfunction may occur if a high priority process is not provided the required
resources.
• Priority inversion may also lead to implementation of corrective measures. These may
include the resetting of the entire system.
• The performance of the system can be reduces due to priority inversion. This may happen
because it is imperative for higher priority tasks to execute promptly.
• System responsiveness decreases as high priority tasks may have strict time constraints or
real time response guarantees.
• Sometimes there is no harm caused by priority inversion as the late execution of the high
priority process is not noticed by the system.
Solutions of Priority Inversion
Some of the solutions to handle priority inversion are given as follows −
• Priority Ceiling
All of the resources are assigned a priority that is equal to the highest priority
of any task that may attempt to claim them. This helps in avoiding priority
inversion.
• Disabling Interrupts
There are only two priorities in this case i.e. interrupts disabled and preemptible.
So priority inversion is impossible as there is no third option.
• Priority Inheritance
This solution temporarily elevates the priority of the low priority task that is
executing to the highest priority task that needs the resource. This means that
medium priority tasks cannot intervene and lead to priority inversion.
• No blocking
Priority inversion can be avoided by avoiding blocking as the low priority task
blocks the high priority task.
• Random boosting
The priority of the ready tasks can be randomly boosted until they exit the critical
section.
2.Write short note on of the following: 8 i) Semaphores ii) ii) Pipes
Ans:-
3. What is meant by task? Describe different states of task.
Ans:-
4.Explain mailbox functions and give different types of mailbox.
Ans:-
5. The following routines are called by Task A,B and C, but they don't work. How would you fix the
problem? Static int iRecordCount;
Void increment_records (int iCount)
{
OSSemGet (SEMAPHORE_PLUS);
iRecordCount + = iCount;
}
Void decrement_records (int iCount)
{
iRecordCount - = iCount;
OSSemGive (SEMAPHORE _ MINUS)
}
Ans:- . The following routines are called by Tasks A, B, and C, but they don't work. How would you fix
the problems?
static int i RecordCount;
void increment_records (int i Count)
{
OS SemGet (SEMAPHORE_PLUS);
i RecordCount +- iCount;
}
void decrement_records (int i Count)
{
i RecordCount i Count; OSSemGive (SEMAPHORE_MINUS):
)
Unit 3
1. How real time operating system differs from a normal operating system ?
Ans:-
RTOS stands for Real-Time Operating System whereas OS stands for Operating System.
1. A real-time operating system (RTOS) specializes in extremely quick reaction times, whereas a
traditional operating system (OS) concentrates on sequentially computing throughout the
whole array of processes.
2. RTOS is user and commands specific whereas an OS is generally used by everyone for daily
processes.
3. An RTOS uses a sophisticated scheduling algorithm, whereas a regular OS uses a standard
approach to solve tasks sequentially.
4. Some examples of RTOS include; Vx works, QNX, RTLinux, etc whereas examples of OS
include; macOS, Windows, ChromeOS, and android too.