Skip to content

Commit 9c17a89

Browse files
authored
Add files via upload
1 parent 4366d07 commit 9c17a89

File tree

5 files changed

+61
-0
lines changed

5 files changed

+61
-0
lines changed

LED_Interface/led.asm

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
ORG 00h ;The ORG directive is used to indicate the beginning of the address
2+
;The number that comes after ORG can either be in hex or decimal
3+
;If the number is not followed by H, it is deimal and the assembler will convert it to hex
4+
5+
6+
HERE: MOV P1,#0FFH ; led P1 ,# Indicates that 0FF is a data and not an address
7+
LCALL DELAY ; Function call for subroutine DELAY
8+
MOV P1,#00H
9+
LCALL DELAY
10+
SJMP HERE ; SHORT JUMP to HERE
11+
12+
13+
; delay = 2 x 7 x 255 x 255 x 1.085us =0.99s = total delay duration in microseconds
14+
DELAY: MOV R0,#07
15+
HERE3: MOV R1,#255
16+
HERE2: MOV R2,#255
17+
HERE1: DJNZ R2,HERE1
18+
DJNZ R1,HERE2
19+
DJNZ R0,HERE3
20+
21+
RET ; return helps to return program counter from subroutine and back to main code
22+
23+
END
24+
; this indicates end of code and if any code is written beyond this is ignored by the assembler
25+
26+
; for continious preview of values
27+
; goto peripherals --> port 1(P1) --> port window opens -->goto Run or press F5 key

LED_Interface/led.c

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// This is a code for 8051 microcontroller using Keil Software
2+
3+
// blink led P1
4+
5+
#include<reg52.h> // include header file
6+
7+
// declare a function
8+
void ms_delay( unsigned int time); // unsigned as time does not come with '+' or '-' sign.
9+
10+
void main()
11+
{
12+
13+
while(1)
14+
{
15+
P1= 0x0ff; // on led (giving logic 1 to port P1)
16+
ms_delay(1000); // delay 1s
17+
P1=0x00; // off led (giving logic 0 to port P1)
18+
ms_delay(1000);
19+
}
20+
}
21+
22+
void ms_delay(unsigned int time)
23+
{
24+
unsigned int i,j;
25+
26+
// time X 1ms
27+
for(i=0;i<time;i++)
28+
{
29+
for(j=0;j<113;j++); // creates delay of 1ms
30+
}
31+
}
32+
33+
// use Analysis Window button to verify delay time --> setup -->enter port name--> press enter --> check the analysis(zoom out the window)
34+
// to debug start debugger --> peripherals --> choose port -->step over /step out(come out of loop) /run(for running whole code)

LED_Interface/led_asm_output.png

61.9 KB
Loading

LED_Interface/led_blinking.png

199 KB
Loading
Loading

0 commit comments

Comments
 (0)