0% found this document useful (0 votes)
31 views7 pages

22BHI10090 Embedded Practical File

The document discusses the ARM instruction set including data processing, load/store, branch, multiply/divide and coprocessor instructions. It provides code examples demonstrating ARM instructions like MOV, ADD, SUB, LDR, STR, B, SWI. The output sections contain code for applications like toggling an LED, counting bits in a number, reading an ADC, controlling a DC motor speed using PWM and button, reading RFID tags.

Uploaded by

adityakolhelite
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)
31 views7 pages

22BHI10090 Embedded Practical File

The document discusses the ARM instruction set including data processing, load/store, branch, multiply/divide and coprocessor instructions. It provides code examples demonstrating ARM instructions like MOV, ADD, SUB, LDR, STR, B, SWI. The output sections contain code for applications like toggling an LED, counting bits in a number, reading an ADC, controlling a DC motor speed using PWM and button, reading RFID tags.

Uploaded by

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

Aditya Kolhe

22BHI10090
Embedded system Lab Practical
Q.1.

Study of complete instruction set of ARM processor:


1. The ARM processor instruction set includes the following types of
instructions:
2. Data processing instructions: These instructions perform arithmetic and
logical operations on data in the registers. Examples include ADD, SUB, AND,
ORR, EOR, etc.
3. Load and store instructions: These instructions transfer data between the
registers and memory. Examples include LDR, STR, LDM, STM, etc.
4. Branch instructions: These instructions change the flow of control in a
program. Examples include B, BL, BX, etc.
5. Multiply and divide instructions: These instructions perform multiplication
and division operations. Examples include MUL, MLA, SMLAL, etc.
6. Coprocessor instructions: These instructions are used to access the
coprocessor. Examples include CDP, MCR, MRC, etc.

An example code that demonstrates some of the ARM instruction set:

.global _start

_start:
mov r0, #1 // Move the value 1 into register r0
mov r1, #5 // Move the value 5 into register r1
add r2, r0, r1 // Add the values in r0 and r1 and store the result in r2
mov r0, #1 // Move the value 1 into register r0 (for write syscall)
mov r1, r2 // Move the value in r2 into register r1 (for write syscall)
mov r2, #14 // Move the value 14 into register r2 (for write syscall)
swi 0 // Call the SWI instruction to perform the write syscall

mov r0, #0 // Move the value 0 into register r0 (for exit syscall)
swi 0 // Call the SWI instruction to perform the exit syscall
Q.2.

AREA Arithmetic, CODE, READONLY


ENTRY
MOV R0, #10 ; Load the value 10 into R0
MOV R1, #5 ; Load the value 5 into R1
ADD R2, R0, R1 ; Add the values in R0 and R1 and store the result in
R2
MOV R3, #20 ; Load the value 20 into R3
SUB R4, R3, R2 ; Subtract the value in R2 from R3 and store the result in R4
SWI &11 ; Exit the program
END

OUTPUT:

Q.3.

AREA FlashLED, CODE, READONLY


ENTRY
LDR R0, =GPIO_BASE ; Load the base address of the GPIO port into R0
LDR R1, =GPIO_OUT ; Load the offset of the output register into R1
LDR R2, [R0, R1] ; Load the value of the output register into R2
EOR R2, R2, #1 ; Toggle the value of the LED bit in R2
STR R2, [R0, R1] ; Store the new value of the output register
MOV R3, #1000000 ; Load the delay value into R3
Delay SUBS R3, R3, #1 ; Decrement the delay value
BNE Delay ; Branch to Delay if the delay value is not zero
B FlashLED ; Branch to FlashLED to repeat the process
END

OUTPUT:

Q.4.
AREA CountBits, CODE, READONLY
ENTRY
MOV R0, #0x12345678 ; Load the 32-bit number into R0
MOV R1, #0 ; Initialize the count of zeros to zero
MOV R2, #0 ; Initialize the count of ones to zero
Count LSRS R3, R0, #1 ; Shift the bits of R0 to the right by one position
BCC Zero ; Branch to Zero if the carry flag is clear
ADD R2, R2, #1 ; Increment the count of ones
B Count ; Branch to Count to continue the process
Zero ADD R1, R1, #1 ; Increment the count of zeros
B Count ; Branch to Count to continue the process
SWI &11 ; Exit the program
END

OUTPUT:
Q.5.

AREA ADC, CODE, READONLY


ENTRY
LDR R0, =ADC_BASE ; Load the base address of the ADC into R0
L

OUTPUT:

Q.6.

#define PWM_PIN 12 // PWM pin connected to the DC motor


#define BUTTON_PIN 13 // Button pin to change the motor speed

int motor_speed = 0; // Variable to store the motor speed

void setup() {
pinMode(PWM_PIN, OUTPUT); // Set the PWM pin as output
pinMode(BUTTON_PIN, INPUT_PULLUP); // Set the button pin as input with
pull-up resistor
analogWrite(PWM_PIN, motor_speed); // Set the initial motor speed
}

void loop() {
if (digitalRead(BUTTON_PIN) == LOW) { // Check if the button is pressed
motor_speed += 10; // Increase the motor speed by 10
if (motor_speed > 255) { // Check if the motor speed is at maximum
motor_speed = 0; // Reset the motor speed to zero
}
analogWrite(PWM_PIN, motor_speed); // Set the new motor speed
delay(100); // Wait for 100 milliseconds
}
}

OUTPUT:

Q.7.

#include <SPI.h>
#include <MFRC522.h>

#define RST_PIN 9 // Reset pin connected to the RFID module


#define SS_PIN 10 // Slave select pin connected to the RFID module

MFRC522 rfid(SS_PIN, RST_PIN); // Create an instance of the MFRC522 library


void setup() {
Serial.begin(9600); // Initialize serial communication
SPI.begin(); // Initialize SPI communication
rfid.PCD_Init(); // Initialize the RFID module
}

void loop() {
if (rfid.PICC_IsNewCardPresent()) { // Check if a new card is present
if (rfid.PICC_ReadCardSerial()) { // Check if the card data can be read
Serial.print("UID: ");
for (int i = 0; i < rfid.uid.size; i++) { // Print the UID of the card
Serial.print(rfid.uid.uidByte[i] < 0x10 ? "0" : "");
Serial.print(rfid.uid.uidByte[i], HEX);
}
Serial.println();
rfid.PICC_HaltA(); // Halt the card
rfid.PCD_StopCrypto1(); // Stop encryption on the RFID module
}
}
}

OUTPUT:

You might also like