MOV P0,#0FFH
MOV P1,#00H
use port P0 for input
use port P1 for output
8 led connected to P0
8 switch connected to P1
ORG 000H ; START AT 0 LOCATION
AGAIN: MOV A, #FFH ; A=FF
MOV P0,A ; P0 AS INPUT PORT WHERE SWITCHES ARE CONNECTED
SETB P0 ; SET LOGIC 1 FOR EVERY PIN OF PORT P0
ACALL DEALY ; WAIT
CLR A ; A=000
MOV P1,A ; P1 AS OUTPUT PORT WHERE LED ARE CONNECTED
SETB P1 ;SET LOGIC 0 FOR EVERY PIN OF PORT P1
SJMP AGAIN ; JUMP AGAIN KEEP DOING
END ; END THE PROGRAM
ORG 00H ;Start from vector 0
MOV P0,#0FFH ;Moving value of FF to port 0 and making it input
MOV P1,#00H ;Same as above, making it output
In your code, moving the value of FF to A (accumulator), then moving the value of A to P0 is unnecessary. You can directly move the value FF to P0, but remember, ALWAYS put '0' (zero) before any hex value. So you write, MOV P0,#0FFH.
'SETB P0' is not a code. You can only set any PIN, not the whole port. And you don't need it after moving value of FF to that port.
There is no "DEALY" subroutine in your code. So you cannot call such. And always pay attention to the spellings. Its 'DELAY'.
Same will go with P1 port.
After making them input & output, you no need to jump back to "AGAIN" subroutine, or else you will keep looping and doing same work again & again.
So your code just to make ports input & output will be..
Code:ORG 00H ;Start from vector 0 MOV P0,#0FFH ;Moving value of FF to port 0 and making it input MOV P1,#00H ;Same as above, making it output
Now if you want to control LEDs with the switches, then, as Mr. Jayant said, you have to connect LEDs to P1 port and switches to P0. You have to keep scanning P0 for switch input & turn ON or OFF its consecutive LEDs.
Code ASM - [expand] 1 2 setb P1.0 clr P2.1
I have no idea how to make loop but I am tryingYou have to use 2 loops (nested loops). The inner should give a delay of 1 ms. The out will give desired delay. If outer is set to 100 then inner loop should be executed 100 times and you will get 100 ms delay.
Loop1:
mov r1,#100
loop2:
mov r2,#250
loop3:
nop
nop
djnz r2,loop3
djnz r1,loop2
start:
setb p1.0
acall delay
clr p1.0
.
.
.
.
.
.
delay:
mov r1,#100
loop2:
mov r2,#250
loop3:
nop
nop
djnz r2,loop3
djnz r1,loop2
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?