??? 10/11/09 20:08 Read: times Msg Score: +2 +2 Good Answer/Helpful |
#169642 - So you will understand Responding to: ???'s previous message |
Ghulam Mustafa said:
I couldnt understand you comment. I mean that it is obvious to me that it does not work. It also should have been obvious to you that it did not work after you tested it. You did test it, right? Testing can even include "playing computer" in your head. So let's run this program in our heads. We'll assume that you've got the serial port initialized properly, so the fun starts at line 16. I have numbered your program lines for our convenience. 1 ORG 000H 2 JMP MAIN 3 4 ORG 023H 5 JMP SERIAL 6 7 ORG 030H 8 MAIN: 9 MOV SCON,#50H 10 MOV TMOD,#20H 11 MOV TH1,#-24 12 SETB TR1 13 SETB EA 14 SETB ES 15 MOV R1,#01 16 MOV DPTR,#0000H 17 MOV SBUF,DPH 18 JMP$ 19 20 SERIAL: 21 CLR TI 22 DJNZ R2,SKIP 23 MOV R2,#02 24 MOV SBUF,DPL 25 INC DPTR 26 RETI 27 28 SKIP: 29 MOV SBUF,DPH 30 RETI 31 32 END#16: Write zero into DPH and DPL. #17: Write the contents of DPH into SBUF. That is, write zero into SBUF. #18: Sit on it and spin, all further work is performed in the ISR. #22: Since R2 was never initialized, decrement whatever arbitrary value R2 holds and jump to SKIP. #29: Write the contents of DPH into SBUF. That is, write zero into SBUF. .... Continue transmiting zeroes until R2 finally decrements to zero. #23: Ah, finally R2 gets a value programmatically. #24: Write the contents of DPL into SBUF. That is, write zero into SBUF. #25: DPTR = 1 #22: Decrement R2 to 1. #29: Write the contents of DPH into SBUF. That is, write zero into SBUF. #22: Decrement R2 to 0. #23: R2 = 2 #24: Write the contents of DPL into SBUF. That is, write 1 into SBUF. #25: DPTR = 2 .... And so on, and on, and on, forever .... Now we've tested it. It does not work. Now you understand. |