0% found this document useful (0 votes)
13 views23 pages

MP MC PT-2 Ans

The document provides assembly language programs for the 8051 microcontroller to perform various tasks, including finding the maximum and minimum values in an array, generating a 2 kHz square wave, and controlling LEDs. It also explains the architecture of the Arduino microcontroller, detailing its components and functionalities, and includes code for interfacing an LCD with Arduino. Additionally, it covers arithmetic and logical operations in Arduino programming with examples, and presents a program to move data from external program memory to external data memory in the 8051 architecture.

Uploaded by

magalveera
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views23 pages

MP MC PT-2 Ans

The document provides assembly language programs for the 8051 microcontroller to perform various tasks, including finding the maximum and minimum values in an array, generating a 2 kHz square wave, and controlling LEDs. It also explains the architecture of the Arduino microcontroller, detailing its components and functionalities, and includes code for interfacing an LCD with Arduino. Additionally, it covers arithmetic and logical operations in Arduino programming with examples, and presents a program to move data from external program memory to external data memory in the 8051 architecture.

Uploaded by

magalveera
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

MP MC PT-2 Answers

2. An array of 20 numbers is stored in the internal data RAM starting from the location 30H.
Write a program to find the maximum and minimum numbers in the array.

✅ Program Explanation:

• The array starts from 30H and has 20 elements.


• We'll use registers to hold:
o R0 as a pointer to traverse the array.
o A as an accumulator to load values.
o MAX and MIN locations in RAM to store the maximum and minimum values
found.

✅ Final Program in Assembly (8051):

ORG 0000H ; Program start

MOV R0, #30H ; Point R0 to start of array


MOV A, @R0 ; Load first element of array
MOV 40H, A ; Assume first element as MAX (40H stores MAX)
MOV 41H, A ; Assume first element as MIN (41H stores MIN)
MOV R2, #19D ; Loop counter (remaining 19 elements)

NEXT:
INC R0 ; Move to next array element
MOV A, @R0 ; Load array element into accumulator

; --- Check for MAX ---


MOV B, 40H ; Load current MAX
CJNE A, B, CHECK_MAX
SJMP SKIP_MAX

1
CHECK_MAX:
JC SKIP_MAX ; If A < MAX, skip updating
MOV 40H, A ; Else, update MAX
SKIP_MAX:

; --- Check for MIN ---


MOV B, 41H ; Load current MIN
CJNE A, B, CHECK_MIN
SJMP SKIP_MIN
CHECK_MIN:
JNC SKIP_MIN ; If A > MIN, skip updating
MOV 41H, A ; Else, update MIN
SKIP_MIN:

DJNZ R2, NEXT ; Repeat for all elements

HERE: SJMP HERE ; Endless loop to stop execution

END

✅ Explanation of Registers Used:

Register/Memory Purpose
R0 Pointer to traverse array (30H onward)
A Accumulator to load array elements
B Temporary register for comparison
40H Memory location to store MAX
41H Memory location to store MIN
R2 Loop counter for 19 iterations

2
✅ Working:

1. Initialize MAX and MIN as the first element.


2. Loop through the next 19 elements:
o Compare and update MAX if a larger element is found.
o Compare and update MIN if a smaller element is found.
3. Final MAX and MIN are stored at memory locations 40H and 41H.

✅ Result:

• Maximum number stored at 40H.


• Minimum number stored at 41H.

1. Write a program to generate a square wave of frequency 2 kHz on any one port
pins, using timer 0, Assuming that clock frequency of the 8051 system is 12 MHz.

1. Frequency Analysis:

• Square wave frequency f=2 kHzf = 2\,kHzf=2kHz → Period T=12000=500 μsT = \frac{1}{2000}
= 500\,\mu sT=20001=500μs
• Since it's a square wave, the high and low times are equal: 500 μs2=250 μs\frac{500\,\mu
s}{2} = 250\,\mu s2500μs=250μs each.

2. 8051 Machine Cycle Frequency:

• Clock = 12 MHz
• Machine cycle = 12 MHz12=1 MHz\frac{12\,MHz}{12} = 1\,MHz1212MHz=1MHz
• So, 1 machine cycle = 1 µs

3. Timer Delay Needed:

• Delay for half period = 250 µs

4. Calculate Timer Count:

• For delay of 250 µs: Timer counts=65536−250=65286\text{Timer counts} = 65536 - 250 =


65286Timer counts=65536−250=65286
• In Hex: 6528610=FF061665286_{10} = \text{FF06}_{16}6528610=FF0616
• So, TH0 = 0xFF, TL0 = 0x06

3
✅ Final Program in Assembly (8051):

ORG 0000H ; Origin

MAIN:
MOV P1, #00H ; Make P1 initially 0 (Square wave output pin P1.0)

TOGGLE:
MOV TMOD, #01H ; Timer 0, Mode 1 (16-bit timer)

MOV TH0, #0FFH ; Load higher byte


MOV TL0, #06H ; Load lower byte

SETB TR0 ; Start Timer 0

WAIT:
JNB TF0, WAIT ; Wait until Timer 0 overflows (TF0=1)

CLR TR0 ; Stop Timer 0


CLR TF0 ; Clear overflow flag

CPL P1.0 ; Toggle P1.0 pin (Square wave generation)

SJMP TOGGLE ; Repeat forever

END

✅ Explanation:

• Timer 0 is configured in 16-bit mode (Mode 1).


• TH0 and TL0 are loaded to give a delay of 250 µs.
• After timer overflows, P1.0 pin is toggled.
• Infinite loop to continue generating square wave.
• Since each toggle happens every 250 µs, a complete cycle (HIGH + LOW) takes 500
µs, corresponding to 2 kHz frequency.

✅ Output:

• A 2 kHz square wave on Pin P1.0.

4
6. Interface 8 LEDs with 8051 port 0 and write assembly language programs to a) Glow all the
LEDs continuously. b)Flash all the LEDs on and off for 1 second each.

✅ Assumptions:

• 8 LEDs are connected to Port 0 (P0.0 to P0.7).


• LEDs are active HIGH — meaning if we send 1, LED will glow.

🌐 Part (a): Glow all the LEDs continuously

✅ Program:

ORG 0000H ; Program start address

MOV P0, #0FFH ; Send all 1's to Port 0 to turn ON all LEDs

HERE: SJMP HERE ; Infinite loop to keep LEDs ON

END

✅ Explanation:

• MOV P0, #0FFH: This turns ON all 8 LEDs.


• Infinite loop (HERE: SJMP HERE) keeps the LEDs continuously ON.

🌐 Part (b): Flash all the LEDs ON and OFF for 1 second each

✅ Program:
ORG 0000H ; Program start address

MAIN:
MOV P0, #0FFH ; Turn ON all LEDs
ACALL DELAY ; 1-second delay

MOV P0, #00H ; Turn OFF all LEDs


ACALL DELAY ; 1-second delay

SJMP MAIN ; Repeat forever

; --- 1-second delay subroutine ---


DELAY:
MOV R2, #20 ; Outer loop (approximation)
LOOP1:
MOV R1, #255 ; Middle loop
LOOP2:
MOV R0, #255 ; Inner loop
LOOP3:
DJNZ R0, LOOP3 ; Inner loop countdown

5
DJNZ R1, LOOP2 ; Middle loop countdown
DJNZ R2, LOOP1 ; Outer loop countdown
RET ; Return from delay

END

✅ Explanation:

Instruction Description
MOV P0, #0FFH Turn ON all LEDs
ACALL DELAY Call delay subroutine (approx 1 second)
MOV P0, #00H Turn OFF all LEDs
ACALL DELAY Call delay subroutine again (1 second OFF)
SJMP MAIN Repeat the ON-OFF cycle forever

✅ Delay Subroutine:

• The nested loops create a software delay.


• Adjust R2, R1, and R0 if precise timing is needed — depends on clock frequency (assumed 12
MHz).

7. With a neat diagram explain in detail about the architecture of arduino


microcontroller.

1. Introduction to Arduino Microcontroller Architecture

The Arduino microcontroller is a compact integrated circuit that performs computations


and controls electronic devices. It is built around the ATmega series and includes essential
components like a CPU, memory, I/O modules, and communication interfaces for
processing instructions and interacting with peripherals.

6
Architectural Representation – Diagram Explanation:

3. In-Depth Breakdown of Architecture

A. Instruction Processing Unit

🔹 Flash Program Memory – Stores preloaded programs that execute on the


microcontroller. Retains data even after power loss.
🔹 Instruction Register & Decoder – Decodes fetched instructions and generates control
signals to execute them.
🔹 Program Counter (PC) – Holds the address of the next instruction to be executed,
ensuring sequential processing.

B. Processing & Control Mechanism

🔹 Status & Control Unit – Monitors execution status, handling flags and interrupts.
🔹 32 × 8 General Purpose Registers – Small, high-speed storage locations used for quick
computations.
🔹 Arithmetic Logic Unit (ALU) – Performs arithmetic (addition, subtraction) and logical
(AND, OR, XOR) operations essential for data processing.

C. Memory Organization

🔹 Data SRAM (Static RAM) – Temporarily holds variable data during program execution.
🔹 EEPROM (Electrically Erasable Programmable ROM) – Retains non-volatile user

7
data, such as configurations.
🔹 I/O Lines – Connects input devices (e.g., sensors) and output devices (e.g., LEDs,
motors) for interaction.

D. Communication & Peripheral Control

🔹 Interrupt Unit – Handles external and internal events, pausing execution to process
higher-priority tasks.
🔹 SPI (Serial Peripheral Interface) Unit – Manages high-speed data exchange with
external devices like sensors.
🔹 Watchdog Timer – Resets the system if a malfunction occurs, preventing failures.

E. Input/Output Modules & Interfaces

🔹 Analog Comparator – Compares voltage levels to trigger digital events.


🔹 I/O Modules (1, 2, n) – Allow interfacing with buttons, LEDs, displays, and external
peripherals.

4. Core Technologies and Applications

🛠 Technologies Integrated

• Uses RISC (Reduced Instruction Set Computing) for efficient processing.


• Supports Pulse Width Modulation (PWM) for analog signal control.
• Interfaces with UART, I2C, and SPI for seamless device communication.

🚀 Where It’s Used?

• IoT Applications – Smart home automation, remote sensing.


• Embedded Systems – Industrial automation, security systems.
• Robotics & AI – Self-driving cars, robotic arms.

9. Interface LCD with arduino microcontroller and develop code for the same.

1. Definition

Interfacing an LCD (Liquid Crystal Display) with an Arduino microcontroller allows us


to visually display text, numbers, and sensor values. The commonly used 16x2 LCD (16
characters per line, 2 lines) is driven by an HD44780 controller and communicates with
Arduino using either 4-bit or 8-bit parallel mode.

8
2. Interfacing Diagram:

3. Arduino Code for LCD Display

This code displays a simple message "Hello, World!" on a 16x2 LCD screen.

#include <LiquidCrystal.h> // Include LCD library

// Initialize the library with the numbers of the interface pins

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {

lcd.begin(16, 2); // Set up the LCD's number of columns and rows

lcd.print("Hello, World!"); // Print message to LCD

9
void loop() {

lcd.setCursor(0, 1); // Set cursor to column 0, row 1 (2nd row)

lcd.print("LCD Interface!"); // Print second line

delay(1000); // Wait for 1 second

lcd.clear(); // Clear the display

delay(1000); // Wait for 1 second

lcd.setCursor(0, 0); // Reset to first row

lcd.print("Arduino LCD"); // Display another message

lcd.setCursor(0, 1); // Second row

lcd.print("Example"); // Another line

delay(2000); // Wait for 2 seconds

lcd.clear(); // Clear for next cycle

4. Work-Flow of Code Execution

🔹 Step 1: Library Inclusion

• <LiquidCrystal.h> is included to interface the LCD.

🔹 Step 2: Pin Configuration

• The LCD is initialized using digital pins 7, 8, 9, 10, 11, and 12 for control and data
communication.

🔹 Step 3: LCD Initialization

• lcd.begin(16,2) sets the display size to 16 columns and 2 rows.

🔹 Step 4: Message Display

• lcd.print("Hello, World!") prints text on the first row.

10
🔹 Step 5: Loop Execution

• Since the message is static, no additional code is required in the loop.

✅ Output:

• LCD will alternate between displaying "Hello, World!" and "LCD Interface!", then "Arduino
LCD" and "Example", each displayed for a few seconds.

8. Explain the function of arduino microcontroller instructions for performing


arithmetic and logical operations with suitable example

✅ 1. Arithmetic Operations

Arithmetic operations are used to perform mathematical calculations like addition,


subtraction, multiplication, and division.

⭐ Examples of Arithmetic Operations:

Operation Symbol Example Result


Addition + c = a + b; Sum of a and b stored in c
Subtraction - c = a - b; Difference between a and b
Multiplication * c = a * b; Product of a and b
Division / c = a / b; Quotient of a divided by b
Modulus (Remainder) % c = a % b; Remainder of a / b

✅ Example Code for Arithmetic Operations:

int a = 10, b = 3;

int sum, diff, prod, quot, rem;

void setup() {

Serial.begin(9600); // Initialize Serial Monitor

sum = a + b;

11
diff = a - b;

prod = a * b;

quot = a / b;

rem = a % b;

Serial.println(sum); // Output: 13

Serial.println(diff); // Output: 7

Serial.println(prod); // Output: 30

Serial.println(quot); // Output: 3

Serial.println(rem); // Output: 1

void loop() { // Empty loop}

✅ 2. Logical Operations

Logical operations are used for decision-making based on conditions. They return boolean
results: true (1) or false (0).

⭐ Examples of Logical Operations:

Operation Symbol Example Result

Logical AND && (a > 5) && (b < 10) true if both conditions are true

Logical OR ` `

Logical NOT ! !(a == b) true if a is not equal to b

12
✅ Example Code for Logical Operations:

int a = 10, b = 5;

void setup() {

Serial.begin(9600); // Initialize Serial Monitor

if ((a > 5) && (b < 10)) {

Serial.println("Both conditions are True");

if ((a > 5) || (b > 10)) {

Serial.println("At least one condition is True");

if (!(a == b)) {

Serial.println("a is not equal to b");

void loop() { // Empty loop}

13
✅ Conclusion:

• Arithmetic operations help in mathematical computations like counting, timing.


• Logical operations help in decision-making (e.g., when to turn on an LED).
• Bitwise operations are useful for efficient memory and hardware control (e.g., setting
or clearing specific bits in a register).

12. Develop 8051 program to move a block of data from external program
memory to external data memory

✅ 8051 Program to Move a Block of Data from External Program Memory


to External Data Memory

📌 Problem Statement:

• Move a block of data (e.g., 10 bytes) from external program memory (code
memory) starting at address 2000H to external data memory starting at address
4000H.
• This operation involves reading data from ROM and writing it to RAM externally.

✅ 8051 Assembly Language Program:

ORG 0000H ; Origin address

MOV R7, #0AH ; Load counter with 10 (number of bytes to move)

MOV DPTR, #2000H ; Initialize DPTR to source address in program memory


MOV R0, #00H ; R0 used as offset for source address

MOV R1, #00H ; R1 used as offset for destination address (data memory)

; ---- Loop to move 10 bytes ----


LOOP:
MOV DPTR, #2000H ; Load base address of source
ADD A, R0 ; Add offset to DPTR (DPTR = 2000H + R0)
14
MOVC A, @A+DPTR ; Read byte from program memory to accumulator

MOV DPTR, #4000H ; Load base address of destination


ADD A, R1 ; Add offset to DPTR (DPTR = 4000H + R1)
MOVX @DPTR, A ; Store byte into external data memory

INC R0 ; Increment source offset


INC R1 ; Increment destination offset
DJNZ R7, LOOP ; Decrement counter and repeat until done

SJMP $ ; Infinite loop (end of program)

END

✅ Explanation of Instructions:

Instruction Purpose
MOV R7, #0AH Load counter to move 10 bytes
MOV DPTR, #2000H Set DPTR to source program memory address
MOV DPTR, #4000H Set DPTR to destination data memory address
MOVC A, @A+DPTR Read data from program (code) memory
MOVX @DPTR, A Write data to external data memory
INC R0, INC R1 Increment offsets for next byte
DJNZ R7, LOOP Loop until all bytes are moved

✅ Final Result:
• Data block from 2000H to 2009H (program memory) is copied to 4000H to 4009H
(data memory).
• Useful for applications like bootloading, initial data setup, or updating runtime
variables from stored ROM constants.

15
13. With neat circuit diagram explain how 4x4 keyboards is interfaced with 8051
microcontroller.

✅ Interfacing 4x4 Matrix Keyboard with 8051 Microcontroller

📌 Introduction:

A 4x4 matrix keyboard contains 16 keys arranged in 4 rows and 4 columns. It is widely
used as an input device to give commands or data to the microcontroller. It reduces the
number of I/O pins required for interfacing.

⭐ Circuit Diagram:

16
✅ Explanation of Circuit Diagram:

1. Rows (R1 to R4) of the keypad are connected to P1.0 to P1.3 of Port 1 of 8051.
2. Columns (C1 to C4) of the keypad are connected to P1.4 to P1.7 of Port 1 of 8051.
3. Each key is located at the intersection of a row and a column.
4. Pull-up resistors are generally connected to Port 1 (if needed, internal pull-ups can
also be enabled).

✅ Working Principle:

• Normal condition: All columns are high (logic 1).


• When a key is pressed: A connection is established between a row and a column,
pulling the column line low (logic 0).
• The microcontroller scans rows one by one to detect which key is pressed.

✅ Steps for Key Detection (Algorithm):

1. Set all column lines as input (high) and set one row line low at a time.
2. Scan the column lines:
o If a key is pressed in the active row, corresponding column will show low.
3. Identify the pressed key by checking which row and column are connected.
4. Debounce the keypress (software delay).
5. Return/Process the key value.

✅ Example Code (8051 Assembly):

MOV P1, #0FFH ; Set all pins of Port 1 as high (input mode)

SCAN_ROW:
MOV P1, #0FEH ; Set Row 1 low, others high
JB P1.4, NEXT1 ; Check Column 1
; If P1.4 is low, key at R1C1 is pressed
SJMP KEY_FOUND

NEXT1:
JB P1.5, NEXT2 ; Check Column 2
; If P1.5 is low, key at R1C2 is pressed

17
SJMP KEY_FOUND

NEXT2:
; Continue for other columns and rows
MOV P1, #0FDH ; Set Row 2 low, others high
; Repeat similar checks...

SJMP SCAN_ROW ; Repeat scan

KEY_FOUND:
; Handle keypress
SJMP $

✅ Advantages of Matrix Keypad Interface:

• Efficient use of I/O pins: 16 keys using only 8 pins.


• Scalable: Can be extended to larger keypads (e.g., 4x3, 5x4).
• Simple hardware setup with flexible software control.

✅ Applications:

• Password input systems


• Control panels
• Menu navigation systems

✅ Conclusion:

• The 4x4 matrix keypad interface with 8051 allows effective human-machine
interaction.
• Proper scanning and debounce handling ensure reliable input detection.
• Easy to implement with minimal hardware complexity.

18
19. Explain about the various addressing modes of aurdino microcontroller

Addressing Modes in Arduino Microcontroller

Addressing modes define how the Arduino microcontroller (ATmega328P) accesses


operands. These modes help optimize execution speed and memory usage.

1. Immediate Addressing Mode

• Definition: The operand is directly embedded within the instruction. The CPU does not fetch
it from memory.
• Usage: Used for initializing registers with constants.
• Example (Assembly):
• LDI R16, 0x25 ; Load immediate value 0x25 into register R16

2. Direct Addressing Mode

• Definition: The instruction specifies the exact memory address where the operand is stored.
• Usage: Useful when accessing specific memory locations.
• Example (Assembly):
• LDS R18, 0x100 ; Load value from memory address 0x100 into R18

3. Indirect Addressing Mode

• Definition: A register holds the address of the operand, and the data is fetched from that
address.
• Usage: Commonly used for arrays and pointer-based operations.
• Example (Assembly):
• LD R19, X ; Load value from memory address stored in register X into
R19

4. Register Addressing Mode

• Definition: The operand is stored in a register, making data access faster.


• Usage: Frequently used for arithmetic and logic operations.
• Example (Assembly):
• MOV R20, R19 ; Copy value from register R19 to R20

5. Indexed Addressing Mode

• Definition: Uses a base register with an offset to access memory.


• Usage: Helpful in array indexing and table lookups.

19
• Example (Assembly):
• LD R21, Y+2 ; Load value from memory at (Y + 2) into R21

6. Relative Addressing Mode

• Definition: The address is relative to the program counter (PC). Used for branching
instructions.
• Usage: Applied in loops and conditional jumps.
• Example (Assembly):
• RJMP NEXT ; Jump to label "NEXT" relative to current PC

7. Bit Addressing Mode

• Definition: Operates on individual bits in special function registers (SFRs).


• Usage: Useful for I/O port control and flag manipulation.
• Example (Assembly):
• SBI PORTB, 3 ; Set bit 3 of PORTB (turn on LED at PB3)

Conclusion

These addressing modes help in efficient memory access, data handling, and instruction
execution in Arduino microcontrollers (ATmega328P). 🚀

Three Marks:

1. Program to Find Square and Cube of a Number Using 8051


Microcontroller

MOV A, #05H ; Load number 5 into accumulator


MOV B, A
MUL AB ; A = A * B (Square of 5)
MOV R1, A ; Store Square result in R1

MOV B, R1
MUL AB ; A = A * B (Cube of 5)
MOV R2, A ; Store Cube result in R2

Explanation:

• First, we multiply the number by itself to get the square.


• Then, we multiply the square by the number again to get the cube.

20
2. 8051 ALP to Generate Square Wave on Port 1 Using DAC
MOV P1, #00H ; Output LOW
ACALL DELAY
MOV P1, #FFH ; Output HIGH
ACALL DELAY
SJMP HERE ; Repeat loop

Explanation:

• Port 1 is toggled between HIGH and LOW to generate a square wave.


• A delay subroutine ensures the correct frequency.

3. Application of Sensor-Based 8051 Microcontroller

• Definition: The 8051 microcontroller can be interfaced with sensors to monitor and control
physical parameters.
• Example: Temperature sensor-based automatic fan control.
• Uses:
o Temperature monitoring
o Smart security systems
o Industrial automation

4. Convert BCD to HEX Using PIC Microcontroller


MOVLW 0x27 ; Load BCD value
MOVWF TEMP ; Store in TEMP
SWAPF TEMP, W ; Swap nibbles
ANDLW 0x0F ; Convert to HEX
MOVWF HEX_OUT ; Store HEX value

Explanation:

• The instruction SWAPF swaps the nibbles of the BCD value, and ANDLW 0x0F extracts the
lower nibble to get the HEX equivalent.

5. Difference Between RISC and CISC

Feature RISC (Reduced Instruction Set) CISC (Complex Instruction Set)


Instruction Set Simple and fewer instructions Large and complex instructions
Execution Time Faster due to pipelining Slower due to complex decoding
Registers More registers available Fewer registers
Memory Access Load/Store architecture Memory access within instructions
Example ARM, PIC x86, 8051

21
6. Program to Find Square and Cube of a Given Number (Same as Q1)

(Refer to Q1 above for assembly code and explanation.)

7. Initiate LCD for 20x2 Matrix, 8-bit Character


Lcd_Command(0x38); // 8-bit mode, 2 lines, 5x7 matrix
Lcd_Command(0x0C); // Display ON, Cursor OFF
Lcd_Command(0x06); // Increment cursor
Lcd_Command(0x01); // Clear screen

Explanation:

• 0x38: Configures LCD in 8-bit mode, 2-line display.


• 0x0C: Turns ON display without cursor.
• 0x06: Moves cursor right.

8. Function of Pin 5 & 6 in LCD

• Pin 5 (R/W): Read/Write control (0 = Write, 1 = Read).


• Pin 6 (E): Enable pin (Used to latch data to LCD).

9. Convert BCD to HEX Using PIC (Same as Q4)

(Refer to Q4 for assembly code and explanation.)

10. Role of Arduino Microcontroller

• Definition: Arduino is an open-source microcontroller platform for embedded system


applications.
• Example: Used in IoT, automation, robotics.
• Uses:
o Sensor-based applications
o Home automation
o Motor control

22
11. Calculate Time Duration for One State and Machine Cycle (8051, 6 MHz)

• Time for one machine cycle:


o Machine Cycle=12/Clock Frequency=12/6 MHz=2 µs
• Time for one state:
o State Time=Machine Cycle/6=2/6=0.333 µs

12. Generate Staircase Wave Using DAC (8051)


MOV A, #00H
MOV P1, A
ACALL DELAY
MOV A, #10H
MOV P1, A
ACALL DELAY
MOV A, #20H
MOV P1, A
ACALL DELAY

Explanation:

• Increments DAC output in steps to generate a staircase waveform.


• Delay ensures proper timing between steps.

13. Function of Pin 5 & 6 in LCD (Same as Q8)

(Refer to Q8 for answer.)

14. C18 Program to Set Bit RB0 and Send It to RC7 After Inverting
LATBbits.LATB0 = 1; // Set RB0 HIGH
LATCbits.LATC7 = ~LATBbits.LATB0; // Invert RB0 and send to RC7

Explanation:

• Sets RB0 HIGH.


• Inverts the value and assigns it to RC7.

15. Role of Arduino Microcontroller (Same as Q10)

(Refer to Q10 for answer.)

23

You might also like