0% found this document useful (0 votes)
16 views4 pages

VJ MP2m

The document contains various assembly language programs and applications for microcontrollers, including 8051 and PIC. It covers tasks such as calculating the square and cube of a number, generating square and staircase waves, initializing an LCD, and implementing a fire detection system. Additionally, it discusses the differences between RISC and CISC architectures, the role of Arduino, and timing calculations for machine cycles.

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)
16 views4 pages

VJ MP2m

The document contains various assembly language programs and applications for microcontrollers, including 8051 and PIC. It covers tasks such as calculating the square and cube of a number, generating square and staircase waves, initializing an LCD, and implementing a fire detection system. Additionally, it discusses the differences between RISC and CISC architectures, the role of Arduino, and timing calculations for machine cycles.

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/ 4

1.

Program to Find Square and Cube of a Given Number Using


8051 Microcontroller

ORG 0000H
MOV A, #05H ; Load the number (e.g., 5) into accumulator
MOV B, A ; Copy the number to register B
MUL AB ; A = A * B (Square)
MOV R0, A ; Store square in R0
MOV A, B ; Reload the original number
MOV B, R0 ; Move square to B
MUL AB ; A = A * B (Cube)
MOV R1, A ; Store cube in R1
END

2. 8051 ALP to Generate Square Wave on Port 1 Using DAC

ORG 0000H ; Start of program

START:
MOV P1, #0FFH ; Set Port 1 high (5V)
ACALL DELAY ; Call delay subroutine
MOV P1, #00H ; Set Port 1 low (0V)
ACALL DELAY ; Call delay subroutine
SJMP START ; Repeat indefinitely

DELAY:
MOV R0, #0FFH ; Delay loop
DJNZ R0, $
RET

END

3. Application for Sensor-Based 8051 Microcontroller


Application: Fire Detection and Alarm System
A sensor-based 8051 microcontroller can be used in a fire detection system where a
temperature or smoke sensor detects abnormal conditions. The microcontroller processes
the sensor data and activates an alarm or sprinkler system to prevent fire hazards.

4. Convert BCD to Hex Using PIC Microcontroller Instructions

5. Differentiate RISC & CISC


RISC (Reduced Instruction Set Computer):
Fewer, simpler instructions.
Fixed instruction length.
Emphasis on software optimization.
CISC (Complex Instruction Set Computer):
More, complex instructions.
Variable instruction length.
Emphasis on hardware optimization.

6. Initiate LCD for 20x2 Matrix, 8-Bit Character

ORG 0000H ; Start of program

; Initialize LCD
MOV A, #38H ; 2 lines, 5x7 matrix, 8-bit mode
ACALL COMMAND ; Send command to LCD
MOV A, #0CH ; Display ON, cursor OFF
ACALL COMMAND
MOV A, #01H ; Clear display
ACALL COMMAND

; Main program loop


MAIN:
SJMP MAIN ; Infinite loop

; Subroutine to send command to LCD


COMMAND:
MOV P1, A ; Send command to Port 1 (LCD data pins)
CLR P3.0 ; RS = 0 (command mode)
SETB P3.1 ; EN = 1 (enable pulse)
CLR P3.1 ; EN = 0 (latch command)
RET

END

7. Function of Pin No. 5 & 6 in LCD


1. Pin 5 (R/W - Read/Write):
Determines the direction of data flow between the microcontroller and the LCD.
When R/W = 0, the microcontroller writes data or commands to the LCD.
When R/W = 1, the microcontroller reads data (e.g., status or busy flag) from the
LCD.

1. Pin 6 (EN - Enable):


Acts as a control signal to latch data into the LCD.
A high-to-low pulse (falling edge) on this pin is required to execute the command or
display the data present on the data pins (D0-D7).
It ensures synchronization between the microcontroller and the LCD.

8. Role of Arduino Microcontroller


The Arduino microcontroller is a versatile platform used for:
Prototyping electronics projects.
Interfacing with sensors and actuators.
Building IoT and robotics systems.
Automation and control applications.
Education due to its simplicity and open-source ecosystem.

9. Time Duration for One State and One Machine Cycle with 6
MHz Crystal
One State Duration:
Time=1 / 6MHz=0.1667 μs
One Machine Cycle:
The 8051 takes 12 states for one machine cycle.
Time=12×0.1667 μs=2

10. Generate Staircase Wave Using DAC

ORG 0000H ; Start of program

START:
MOV A, #00H ; Start with 0
MOV P1, A ; Output to DAC (connected to Port 1)
ACALL DELAY ; Call delay subroutine
ADD A, #20H ; Increment by 20H (next step)
CJNE A, #0FFH, START ; Repeat until A reaches FFH
SJMP START ; Repeat indefinitely

DELAY:
MOV R2, #0FFH ; Delay loop
DJNZ R2, $
RET

END

11. C18 Program to Set Bit RB0 and Send Inverted to RC7

#include <p18f4550.h>

void main() {
TRISBbits.TRISB0 = 0; // Set RB0 as output
TRISCbits.TRISC7 = 0; // Set RC7 as output

LATBbits.LATB0 = 1; // Set RB0 high


LATCbits.LATC7 = ~LATBbits.LATB0; // Invert RB0 and send to RC7
}

You might also like