??? 10/08/11 08:30 Read: times |
#184138 - While analysing the problem Responding to: ???'s previous message |
Hi,
Here I am analysing the problems which I find while studying the code which will result in not getting the desired speed. The main problem is you are not restricting R4 in between 0 to 6.because you assign the speed only from 0 to 6 of R4.Then how will it work for another value. So first restrict the value of R4. The other reason is you write clause for r4 = 3,r4 = 5,r4 = 6 in increment button & r4 = 0,r4 = 1 & r4 = 2 in decrement button.But when you increment the r4 from 3 to 6 and now press decrement then the value of r4 = 5.So the speed for r4 = 5 would also reflects in decrement routine too.same way r4 = 0,r4= 1 sholud also reflects in increment too. See the following code of delay NOR_DEL: MOV R0,#0FFH m1: MOV R1,#0FFH INLOP: MOV R2,#01H m2: DJNZ R2,m2 DJNZ R1,INLOP DJNZ R0,m1 RET In this code the value of speed loaded as r0,#0ffh.So your speed,you decide by pressing inc. & dec,. button will become null & void after furnishing one time only & then it will work on the original speed.For avoiding these situatioan you should use register for that. Your code shoude be NOR_DEL: MOV R0,dly1 m1: MOV R1,dly2 INLOP: MOV R2,#01H m2: DJNZ R2,m2 DJNZ R1,INLOP DJNZ R0,m1 RET define dly1 & dly2 in the beggining & load the value in dly1 & dly2 while pressing the Increment & decrement button. Your processor would become also hang because of the following code NXT5: CJNE R4,#00H, NXT5 MOV R0,#0FFH ;Speed--- AJMP NXT5 if R4 is not equl to zero while you press decrment the down key the controller stuck on NXT5: label.isn't the case ? So first consider all these points in this code for getting the desired speed. Regards Maunik |