0% found this document useful (0 votes)
11 views15 pages

Embedded System Arm Lab Programs for Mid 2

The document outlines various experiments and programming tasks related to embedded systems using ARM architecture, including programming with the 8051 microcontroller and ARM assembly language. It covers topics such as timer and counter programming, interfacing with sensors and motors, and generating random numbers. Each experiment includes code snippets and expected outputs, providing a comprehensive guide for practical applications in embedded systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views15 pages

Embedded System Arm Lab Programs for Mid 2

The document outlines various experiments and programming tasks related to embedded systems using ARM architecture, including programming with the 8051 microcontroller and ARM assembly language. It covers topics such as timer and counter programming, interfacing with sensors and motors, and generating random numbers. Each experiment includes code snippets and expected outputs, providing a comprehensive guide for practical applications in embedded systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

S.No.

Experimentstobecovered Mapped
CO
1 Introductiontoembeddedsystemslabcontent. --
2 ProgrammingusingArithmeticandlogicalinstructionsof8051. CO1&2
3 Timerprogrammingof8051. CO1&2
4 Counterprogrammingof 8051. CO1&2
5 Serialportprogrammingof 8051. CO1&2
6 InterfacingofSteppermotor CO3&4
7 InterfacingofTemperaturesensorandRelaycontrol. CO3&4
8 Usingof morecomplexmemoryandbranch type instructions such as CO1&2
LDMFD/STMFD,BandBL.
9 Basicreg/mem visitingandsimplearithmetic/logiccomputing. CO1&2
10 ChangingARMstatemodebyusingMRS/MMSRinstructionandspecifyastart CO1&2
addressof thetextsegmentbyusingcommandline.
11 ARMprogramminginClanguageusingKEILIDE CO1&2
12 Write a random number generation function using assembly language. Call this CO1&2
function fromaCprogramtoproduceaseriesofrandomnumbersandsavethemin
thememory
13 Configureandread/writethememoryspace.UseassemblyandC language to CO3&4
read/writewords,half-words,bytes,halfbytesfrom/toRAM.
14 ImplementthelightingandwinkingLEDsoftheARMI/Oportviaprogramming. CO3&4
15 ISR(InterruptServiceRoutine)programminginARMbasedsystemswithI/Oport. CO3&4
EMBEDDED SYSTEM ARM LAB PROGRAMS
1. Basicreg/mem visitingandsimplearithmetic/logiccomputing.
(ARMprogramminginClanguageusingKEILIDE)
AREA prog,code,readonly;
MOV R1,#10
MOV R2,#20
MOV R3,#10
MOV R4,#20
MOV R5,#10
MOV R6,#20
add R7,R1,R2
sub R8,R3,R4
RSB R9,R3,R4
Mul R10,R5,R6
MOV R11, #0xff
MOV R12,r11,lsr #4
Loop b loop
end
OUTPUT
R0 0x00000000
R1 0x0000000a
R2 0x00000014
R3 0x0000000a
R4 0x00000014
R5 0x0000000a
R6 0x00000014
R7 0x0000001e
R8 0xdffffff6
R9 0x00000000
R10 0x000000c8
R11 0x00000000
R12 0x00000000
R13(SP) 0x00000000
R14(LR) 0x00080004
R15(PC) 0x0000000c
CPSR 0x000000d7
SPSR 0x000000d7
2. Simple ADD INSTRUCTION ARMprogramminginClanguageusingKEILIDE
AREA prog,code,readonly;
MOV R1,# 0x00000002
MOV R2,# 0x00000004
ADD R3,R1,R2
END
OUTPUT
R0 0x00000000
R1 0x00000002
R2 0x00000004
R3 0x00000006
R4 0x00000000
R5 0x00000000
R6 0x00000000
R7 0x00000000
R8 0x00000000
R9 0x00000000
R10 0x00000000
R11 0x00000000
R12 0x00000000
R13(SP) 0x00000000
R14(LR) 0x00080004
R15(PC) 0x00004CB0
CPSR 0x000000D7
SPSR 0x000000D7
3. Simple DELAY ARMprogramminginClanguageusingKEILIDE

#include<LPC21xx.h>
int main()
{
int a.i;
a=0;
for(i=0;i<10;i++){}
a=1;
for(i=0;i<10;i++){printf(“%d”,a);}
a=0;
}
OUTPUT
R0 0x00001004
R1 0x400000f0
R2 0x00000070
R3 0x00000000
R4 0x00000000
R5 0x00000000
R6 0x00000000
R7 0x00000fd3
R8 0x00000000
R9 0x00000000
R10 0x00000ff4
R11 0x00000ff4
R12 0x00000000
R13(SP) 0x40000140
R14(LR) 0x0000001c
R15(PC) 0x00000084
CPSR 0x200000d3
SPSR 0x200000d3
4. ARM LOAD STORE ARMprogramminginClanguageusingKEILIDE
AREA prog,code,readonly;
MOV R1,#256
MOV R2,#2
MOV R3,#3
MOV R4,#4
MOV R5,#5
MOV R13,#0
LDR R0,=0x10000000
STR R1, [R0]
STR R2, [R0, #4]
STR R3, [R0, #1]
STR R4, [R0, #12]
STR R5, [R0, #14]
LDR R6, [R0]
LDR R9, [R0, #4]
LDR R10, [R0, #5]
LDR R11, [R0, #12]
LDR R12, [R0, #14]
ADD R13,R0
ADD R13,R9
ADD R13,R10
ADD R13,R11
ADD R13,R12
LOOP B LOOP
END
OUTPUT
R0 0x10000000
R1 0x00000100
R2 0x00000002
R3 0x00000003
R4 0x00000004
R5 0x00000005
R6 0x00000000
R7 0x00000000
R8 0x00000000
R9 0x00000000
R10 0x00000000
R11 0x00000000
R12 0x00000000
R13(SP) 0x00000000
R14(LR) 0x00000024
R15(PC) 0x00000010
CPSR 0x000000d7
SPSR 0x000000d7
5. Write a random number generation function using assembly language. Call this function
from a C program to produce a series of random numbers and save them in the memory.

Assembly language program to generate random number

AREA prog , CODE, READ ONLY


EXPORT generate_random_number
generate_random_number Implementation of a simple linear
congruential generator
LDR r1, =SEED Load address of seed
LDR r0, [r1] Load current seed value
MOV r2, #1664525 Linear Congruential Generator(LCG)
MUL r0, r0, r2 parameters
ADD r0, r0, #1013904223
STR r0, [r1] Store new seed
Bx lr Return with result in r0

AREA data, DATA, READWRITE


Seed DCD 0x12345678 Initial seed
END

C program to produce a series of random numbers and save them in the memory.
#include<stdio.h>
extern unsigned int
generate_random_number(void);
int main0 {
Unsigned int numbers[10];
For(int i=0; i<10; i++)
{
Numbers[i]= generate_random_number();
Printf(“Random number %d: %u\n”,i+1, numbers[i]);
}
return 0;
}

OUTPUT:
Random Number 1 328038710
Random Number 2 136845572
Random Number 3 1830386293
Random Number 4 174031102
Random Number 5 1852677725
Random Number 6 228830896
Random Number 7 1452020735
Random Number 8 1971884734
Random Number 9 826809617
Random Number 10 982341442

6. Implement the lighting and winking LEDs of the ARM I/O port via programming.
#include <LPC214x.h>
void delay();
void main()
{
IOODIR |= 0XFFFFFFFF; // Port 0 is now acting as a output pin
While(1)
{
IOSET0 | = 0XFFFFFFFF; // port 0’s all pins are high now (LED is
glowing)
delay();
IOCLR0 |= 0XFFFFFFFF; // port 0’s all pins are low now (LED is OFF)
delay();
}
}
void delay()
{
unsigned int i;
for (i=0;i<30000;i++);
}

OUTPUT:
at Port 0 =0xFFFFFFFF

7. Write a C program to produce a series of random numbers.


C program to produce a series of random numbers and save them in the memory.
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
Void random_seed()
{
int random_number(int min, int max);
{
Return (rand() % (max – min +1)) + min;
}
int main()
{
int rn = random_numbers(1,10);
random_seed();
return 0;
}

OUTPUT:
R0 0x000004bc
R1 0x40000140
R2 0x80000000
R3 0x00000000
R4 0x00000000
R5 0x00000000
R6 0x00000000
R7 0x00000493
R8 0x00000000
R9 0x00000000
R10 0x000004b4
R11 0x000004b4
R12 0x00000000
R13(SP) 0x40000120
R14(LR) 0x000000d0
R15(PC) 0x000003a0
CPSR 0x600000d3
SPSR 0x200000d3

You might also like