plz , little help , on small project
Wed Jan 16 2008, 11:39 am
okay ,, mabey i need to insert the rotate instruction .. RR = rotate right
RF = rotate left
but i dont know where , so can u help me
RF = rotate left
but i dont know where , so can u help me
Wed Jan 16 2008, 01:52 pm
in your code..you are directly moving data to ports..
without rotating it.. so before moving the data you should rotate it.. like this...
The above code you can take as a sample for you..
without rotating it.. so before moving the data you should rotate it.. like this...
keep_rotating: mov A,#55H ;move 0x55 to A rr A ;rotate right A mov P1, A sjmp keep_rotating
The above code you can take as a sample for you..
Wed Jan 16 2008, 08:29 pm
THANKS FOR RESPONDING . i rewrite it ..t can u tell me is it right ,,
MAIN: SETB P2.7 ;make P2.7 as input MOV P1,#0FFH ;Switch off LED JB P2.7,DOWN ;jump if 1 MOV A ,#055H RR A MOV P1,A ACALL DELAY MOV A ,0AAH RR A MOV P1,A ACALL DELAY MOV A,#55H RR A MOV P1,A ACALL DELAY MOV A ,0AAH RR A MOV P1,A JNB P2.7,$ ;wait until it goes 1 DOWN: MOV A,#55H RR A MOV P1,A ACALL DELAY MOV A ,0AAH RR A MOV P1,A ACALL DELAY MOV A,#55H RR A MOV P1,A ACALL DELAY MOV A ,0AAH RR A MOV P1,A JB P2.7,$ ;wait until it goes 0 AJMP MAIN delay: mov r7, #7H wait2: mov r6, #0FFH wait1: mov r5, #0FFH wait: djnz r5, wait djnz r6, wait1 djnz r5, wait2 ret
[ Edited Wed Jan 16 2008, 10:03 pm ]
Wed Jan 16 2008, 10:13 pm
well its correct.. but..
the shifting will be done only once.. after that you will see LED not moving..
if you want to make them moving then..
Similarly at the start..
One thing is.. you are using RR in both cases.. so you hardly feel any difference when you press the key.. so use RR in one case and RL in other.. if you want.. so when you press button, you will see the direction of LED moving changes.
the shifting will be done only once.. after that you will see LED not moving..
if you want to make them moving then..
DOWN: MOV A,#55H RR A MOV P1,A ACALL DELAY MOV A ,0AAH RR A MOV P1,A ACALL DELAY MOV A,#55H RR A MOV P1,A ACALL DELAY MOV A ,0AAH RR A MOV P1,A JB P2.7,DOWN ; we are jumping back again to give a moving LED look AJMP UP ; jump back again..
Similarly at the start..
MAIN: SETB P2.7 ;make P2.7 as input MOV P1,#0FFH ;Switch off LED UP: JB P2.7,DOWN ;jump if 1 MOV A ,#055H RR A MOV P1,A ACALL DELAY MOV A ,0AAH RR A MOV P1,A ACALL DELAY MOV A,#55H RR A MOV P1,A ACALL DELAY MOV A ,0AAH RR A MOV P1,A JNB P2.7,UP
One thing is.. you are using RR in both cases.. so you hardly feel any difference when you press the key.. so use RR in one case and RL in other.. if you want.. so when you press button, you will see the direction of LED moving changes.
Wed Jan 16 2008, 10:23 pm
okay thanks man ,, ya i have noticed that .. ... so the overall program will look like this right
MAIN: SETB P2.7 ;make P2.7 as input MOV P1,#0FFH ;Switch off LED UP: JB P2.7,DOWN ;jump if 1 MOV A ,#055H RR A MOV P1,A ACALL DELAY MOV A ,0AAH RR A MOV P1,A ACALL DELAY MOV A,#55H RR A MOV P1,A ACALL DELAY MOV A ,0AAH RR A MOV P1,A JNB P2.7,UP DOWN: MOV A,#55H RL A MOV P1,A ACALL DELAY MOV A ,0AAH RL A MOV P1,A ACALL DELAY MOV A,#55H RL A MOV P1,A ACALL DELAY MOV A ,0AAH RL A MOV P1,A JB P2.7,DOWN ; we are jumping back again to give a moving LED look AJMP UP ; jump back again.. delay: mov r7, #7H wait2: mov r6, #0FFH wait1: mov r5, #0FFH wait: djnz r5, wait djnz r6, wait1 djnz r5, wait2 ret
[ Edited Wed Jan 16 2008, 11:18 pm ]
Wed Jan 16 2008, 10:57 pm
CAN U PLZ ANSWER ME IS RIGHT NOW OR NOT . CUZ I NEED TO GIVE IT TO THE DOCTOR TOMOROW ...
Powered by e107 Forum System