You are on page 1of 10

2021:

PART A:

1.

(a) What are program lock bits?

Lock bits are set of bits to enable or disable some special security features of a microcontroller. For
example, in some cases you might want to disable the memory read functionality of the
microcontroller, so that the code you have written cannot be stolen by others.

(b) Draw the Power On Reset Circuit. What is the purpose of it?

A power-on reset (PoR) is a circuit that provides a predictable, regulated voltage to a microprocessor
or microcontroller with the initial application of power. The PoR system ensures that the
microprocessor or microcontroller will start in the same condition every time that it is powered up.

(c) What is the purpose of port registers?

- the main purpose of the port register is, it is used as the input-output port.

- also some specific ports (port 0 and port 2) are used to access the external memory.

(d) What is the difference between CY and OV flags of PSW related to MCS-51?

In the MCS-51 microcontroller architecture, the PSW (Program Status Word) is a register that
contains various status flags. Among these flags, there are two specific flags called CY (Carry) and OV
(Overflow). Here's the difference between them:

Carry Flag (CY): The Carry flag, also known as the CY flag, is used to indicate a carry or borrow during
arithmetic or logical operations. It reflects the carry or borrows resulting from the most significant bit
(bit 7) of an operation.

Overflow Flag (OV): The Overflow flag, also known as the OV flag, is used to indicate signed
arithmetic overflow. It reflects an overflow of the signed result when performing arithmetic
operations.

(e) Which part of the internal RAM is related to PUSH and POP instructions?

Stack: The role of stack memory includes storage of temporary data when handling function calls
(normal stack PUSH and POP operations), storage for local variables, passing of parameters in
function calls, saving of registers during exception sequences, etc.

(f) What would be the content of DPH after execution of MOV DPTR, #1234H instruction?

Justify your answer.

The instruction, MOV DPTR, 1234H will load the value 1234H into the Data Pointer. DPH will
hold 12H and DPL will hold 34H.
(g) How many bytes of forward jump are possible for any DJNZ instruction?

Explanation: DJNZ is 2-byte instruction. This means jump can be of -128 to +127 locations with
respect to PC.

(h) Highlight the main differences between PAL and FPGA.

PART B:

2. (a) Explain the operation of LCALL instruction of MCS-51 with a suitable example.
LCALL (long call)
In this 3-byte instruction, the first byte is the opcode and the second and third bytes are used
for the address of the target subroutine. Therefore, LCALL can be used to call subroutines
located anywhere within the 64K-byte address space of the 8051. To make sure that after
execution of the called subroutine the 8051 knows where to come back to, the processor
automatically saves on the stack the address of the instruction immediately below the
LCALL. When a subroutine is called, control is transferred to that subroutine, and the
processor saves the PC (program counter) on the stack and begins to fetch instructions from
the new location. After finishing execution of the subroutine, the instruction RET (return)
transfers control back to the caller. Every subroutine needs RET as the last instruction.

(b) What is the purpose of SETB instruction?


- The SETB instruction sets the bit operand to a value of 1.
- This instruction can operate on the carry flag or any other directly addressable bit.
- No flags are affected by this instruction.
3. (a) Implement the following using a PLD circuit. Where O1, O2, O3 and O4 are outputs.
O1 = A.B + A.B
O2 = A.B
O3 = 0
O4 = 1
Explain it with suitable circuit diagram.

(b) What is VHDL? 7+3


- VHDL is one of the commonly used Hardware Description Languages (HDL) in digital circuit design.
- VHDL stands for VHSIC Hardware Description Language. In turn, VHSIC stands for Very-High-Speed
Integrated Circuit.
- VHDL can be used for designing hardware and for creating test entities to verify the behavior of
that hardware.
4. (a) Write a short note on SFRs (Special Function Registers) of MCS-51.
• A Special Function Register (or Special Purpose Register, or simply Special Register) is a
register within a microprocessor that controls or monitors the various functions of a
microprocessor.
• As the special registers are closely tied to some special function or status of the processor,
they might not be directly writable by normal instructions (like add, move, etc.). Instead,
some special registers in some processor architectures require special instructions to
modify them.
• In the 8051, register A, B, DPTR, and PSW are a part of the group of registers commonly
referred to as SFR (special function registers). An SFR can be accessed by its name or by its
address.
• A special function register can have an address between 80H to FFH. These addresses are
above 80H, as the addresses from 00 to 7FH are the addresses of RAM memory inside the
8051.
• A special function register can have an address between 80H to FFH. These addresses are
above 80H, as the addresses from 00 to 7FH are the addresses of RAM memory inside the
8051.
• SFRs are bit addressable registers.

(b) Write an Assembly language program with algorithm for MCS-51 to shift a block of 8 bytes of
data, presently located from 60H to 67H, 1-byte up, so that the data is available from 61H to 68H.

Algorithm:

1. Initialize the source memory address to 60H.

2. Initialize the destination memory address to 61H.

3. Load the first byte of data from the source address.

4. Store the loaded byte to the destination address.

5. Increment the source and destination addresses by 1.

6. Repeat steps 3-5 for a total of 8 times to shift all 8 bytes.

7. End the program.

Assembly Language Program:

MOV R0, #8 ; Initialize loop counter to 8

MOV R1, #60H ; Initialize source address to 60H

MOV R2, #61H ; Initialize destination address to 61H

SHIFT_LOOP:

MOV A, @R1 ; Load byte from the source address

MOV @R2, A ; Store byte to the destination address

INC R1 ; Increment source address

INC R2 ; Increment destination address

DJNZ R0, SHIFT_LOOP ; Decrement loop counter and repeat if not zero

END:

SJMP END ; End the program

5. (a) Explain the working of Port - 0 of MCS-51 with suitable diagram.

Port 0 is one of the four I/O ports (Port 0, Port 1, Port 2, and Port 3) available in the MCS-51
microcontroller architecture. It is an 8-bit bidirectional I/O port, meaning it can be used for both
input and output operations. Port 0 is commonly used for various general-purpose I/O operations.

Here is a suitable diagram illustrating the working of Port 0 in the MCS-51 microcontroller:
_____________

P0.0 ----| |

P0.1 ----| |

P0.2 ----| |

P0.3 ----| |

P0.4 ----| Port 0 |

P0.5 ----| |

P0.6 ----| |

P0.7 ----|___________|

In this diagram:

- P0.0 through P0.7 represent the individual pins of Port 0. These pins can be used for connecting
external devices or for internal I/O operations.

- Each pin can be configured as either an input or an output based on the software settings.

- When configured as an input, the pins can be used to read external signals or data.

- When configured as an output, the pins can be used to drive signals or data to external devices.

The working of Port 0 is controlled by the associated SFRs (Special Function Registers) in the MCS-51
architecture. Specifically, two SFRs are used to control Port 0:

1. P0 (Port 0): This SFR is used to read the current status of Port 0 pins when they are configured as
inputs. Writing to this SFR has no effect.

2. P0 (Port 0): This SFR is used to write data to Port 0 pins when they are configured as outputs. Each
bit of this SFR corresponds to a pin of Port 0. Writing a logic high (1) to a bit will set the
corresponding pin to a high level (Vcc), and writing a logic low (0) will set the corresponding pin to a
low level (GND).

To use Port 0 in an MCS-51 assembly language program, the programmer can read or write data to
Port 0 by accessing the appropriate SFRs. For example, to read the input data from Port 0, the
programmer can read the P0 SFR. To write data to Port 0, the programmer can write the desired
value to the P0 SFR.

It is important to note that Port 0 has an internal pull-up resistor feature. When a pin of Port 0 is
configured as an input and left unconnected or not driven externally, the internal pull-up resistor can
be enabled via software to ensure a defined logic level.

Overall, Port 0 in the MCS-51 microcontroller provides a flexible and versatile 8-bit I/O interface,
allowing communication with external devices and facilitating various I/O operations in embedded
systems and applications.

(b) What is SBUF? Explain its function. 6+4


SBUF (Serial Buffer) is a Special Function Register (SFR) in the MCS-51 microcontroller architecture. It
is specifically used for serial communication, providing a buffer for data transmission and reception
through the microcontroller's serial port.

The SBUF register serves as a temporary storage location for data being transmitted or received via
the serial port. It plays a crucial role in facilitating serial communication protocols such as UART
(Universal Asynchronous Receiver-Transmitter).

Here's a detailed explanation of the function of SBUF in the MCS-51 architecture:

1. Serial Data Transmission: When the microcontroller needs to transmit data serially, it writes the
data byte to be transmitted into the SBUF register. The data is then transmitted bit by bit, typically
using a specific protocol such as UART, over the serial port.

2. Serial Data Reception: When the microcontroller receives serial data, the data is received through
the serial port and stored in the SBUF register.

3. Buffering: The SBUF register acts as a buffer, allowing the microcontroller to handle data
transmission and reception asynchronously.

4. Interrupts: The SBUF register is often associated with interrupts to notify the microcontroller when
data transmission or reception is complete or requires attention.

5. Configuration and Control: In addition to data storage, the SBUF register may also have control or
configuration bits associated with it. These bits can be used to enable or disable specific features or
to set parameters for serial communication, such as baud rate or data format.

Overall, the SBUF register in the MCS-51 microcontroller architecture serves as a temporary storage
location for serial data transmission and reception. It facilitates asynchronous serial communication,
provides buffering capabilities, and allows the microcontroller to efficiently transmit and receive data
through its serial port.

6. (a) What are the different types of Unconditional jumps in MCS-51? Explain in brief with suitable

example and diagram.

In the MCS-51 microcontroller architecture, there are three types of unconditional jump instructions
that can be used for altering the program flow: AJMP, LJMP, and SJMP. These instructions allow the
program to transfer control to a different memory location unconditionally, without any conditions or
flags affecting the jump.

1. AJMP (Absolute Jump):

The AJMP instruction is used for an absolute jump within the same 2K-byte page of memory. It
provides a jump range of ±2K bytes from the current program counter (PC).

Example:

Let's assume we have the following code:


```assembly

ORG 0H

START: ; Starting point of the program

...

AJMP LOOP ; Absolute jump to the label 'LOOP'

...

LOOP: ; Target label

...

In this example, the AJMP instruction is used to perform an absolute jump from the `START` label to
the `LOOP` label. The program execution will continue from the memory location of the `LOOP` label.

Diagram:

______________

| |

----->| START |

| |

|______________|

___________________

| |

----->| LOOP |

| |

|___________________|

2. LJMP (Long Jump):

The LJMP instruction is used for a long jump to any address within the 64K-byte address space. It
allows the program to jump to any memory location without any limitations.

Example:

``` assembly

ORG 0H

START: ; Starting point of the program

...
LJMP TARGET ; Long jump to the memory address specified by 'TARGET'

...

ORG 100H

TARGET: ; Target address

In this example, the LJMP instruction is used to perform a long jump from the `START` label to the
memory address specified by `TARGET`. The program execution will continue from the memory
location of the `TARGET` address.

Diagram:

______________

| |

-----> | START |

| |

|______________|

___________________

| |

----->| TARGET |

| |

|___________________|

3. SJMP (Short Jump):

The SJMP instruction is used for a short jump within the -128 to +127 bytes range from the current
program counter (PC). It allows for relative jumps within a limited range.

Example:

```assembly

ORG 0H

START: ; Starting point of the program

SJMP NEXT ; Short jump to the label 'NEXT'

NEXT: ; Target label

...
Diagram:

______________

| |

-----> | START |

| |

|______________|

___________________

| |

----->| NEXT |

| |

|___________________|

These unconditional jump instructions provide flexibility in altering the program flow within the
MCS-51 microcontroller. The choice of which instruction to use depends on the range and type of
jump required for a particular program scenario.

(b) What is an interrupt? Which SFRs are directly related to external interrupts of MCS-51? 7+3

An interrupt is a mechanism used in microcontrollers and other computer systems to suspend the
normal program execution temporarily and transfer control to a specific interrupt service routine
(ISR) when a particular event or condition occurs. Interrupts allow the microcontroller to respond
quickly to external events and handle time-critical tasks.

In the MCS-51 microcontroller architecture, there are two SFRs (Special Function Registers) directly
related to external interrupts:

1. IE (Interrupt Enable): The IE SFR is used to enable or disable interrupts in the MCS-51
microcontroller. It has individual bits that control the enable/disable state of different
interrupt sources. Specifically, bit 0 (EA) of the IE SFR is responsible for enabling or disabling
all interrupts globally. When EA is set to 1, interrupts are enabled, and when it is cleared to
0, interrupts are disabled.

2. IP (Interrupt Priority): The IP SFR is used to set the priority levels of interrupts in the MCS-51
microcontroller. It has individual bits for each interrupt source that determine the priority
level of that particular interrupt. The IP SFR allows the programmer to assign higher or lower
priority to different interrupt sources based on the application's requirements.

7. (a) Show with a simple circuit to interface a LED to port 1.0 of a MCS-51 and make it to blink
using

an assembly language program.


Here's a simple circuit diagram that shows how to interface an LED to Port 1.0 of an MCS-51
microcontroller and make it blink using an assembly language program:

+5V

R1

+---[LED]--- P1.0

GND

In this circuit:

• The LED is connected in series with a current-limiting resistor (R1) between the +5V power
supply and ground (GND).

• The anode (longer leg) of the LED is connected to the microcontroller's Port 1.0 (P1.0) pin,
and the cathode (shorter leg) is connected to the resistor and ground.

Now, let's write an assembly language program to blink the LED connected to Port 1.0:

ORG 0H

MAIN:

MOV P1, #00000001B ; Set P1.0 to high (LED on)

ACALL DELAY ; Call a delay subroutine

MOV P1, #00000000B ; Set P1.0 to low (LED off)

ACALL DELAY ; Call a delay subroutine

SJMP MAIN ; Jump back to the MAIN label

DELAY:

MOV R0, #255 ; Load a delay value to R0 (adjust as needed)

LOOP:

DJNZ R0, LOOP ; Decrement R0 and jump to LOOP if not zero

RET ; Return from the subroutine

END

(b) What is function of RET? 8+2

The RET instruction pops the high-order and low-order bytes of the PC from the stack (and
decrements the stack pointer by 2). Program execution resumes from the resulting address which is
typically the instruction following an ACALL or LCALL instruction. No flags are affected by this
instruction.
8. (a) What is the difference between Timer and a Counter?

Timer Counter

The register is incremented for every The register is incremented considering 1 to 0 transition at
machine cycle. its corresponding to an external input pin (T0, T1).

The maximum count rate is 1/12 of The maximum count rate is 1/24 of the oscillator
the oscillator frequency. frequency.

A timer uses the frequency of the A counter uses an external signal to count pulses.
internal clock and generates delay.

(b) Explain with the help of simple hardware interfacing circuit with port 1.0 and P1.1 of MCS-51

connected to DC motor through a controlling module for direction control through software for a

DC motor. 2+8

You might also like