Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
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.

List of 26 messages in thread
TopicAuthorDate
Is this Code Correct for 16 Bit Serial Transmission            01/01/70 00:00      
   No.            01/01/70 00:00      
      Sir            01/01/70 00:00      
         Insert program code            01/01/70 00:00      
            How to post legible source code            01/01/70 00:00      
            Who would bother to read uncommented code?            01/01/70 00:00      
               Worse than that            01/01/70 00:00      
         So you will understand            01/01/70 00:00      
   what code?            01/01/70 00:00      
      Program with comments            01/01/70 00:00      
         The first after it            01/01/70 00:00      
            Second after it.......            01/01/70 00:00      
               Simulators            01/01/70 00:00      
               Remove all the silly code lines!            01/01/70 00:00      
                  Comments first, then discussing intention/reality            01/01/70 00:00      
                     Careful Commenting Catches Cruddy Coding!            01/01/70 00:00      
            So where did all the comments go?!            01/01/70 00:00      
               To achieve 16 bit communication            01/01/70 00:00      
                  Exactly what was your "target"?            01/01/70 00:00      
                  How?            01/01/70 00:00      
            Return from interrupt            01/01/70 00:00      
               Of course not            01/01/70 00:00      
                  But how it could be different            01/01/70 00:00      
                     Any more information required            01/01/70 00:00      
                        As previously stated            01/01/70 00:00      
                           and summarised...            01/01/70 00:00      

Back to Subject List