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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/13/07 12:51
Read: times


 
#137152 - this is what I mean
Responding to: ???'s previous message
A serial interrupt does not execute until RI or TI or both are set.

Let's assume TI and RI are clear, and 500,000 characters have been sent down the serial line to the micro.

As soon as the micro finds out that a byte is received, RI will be set and proceed into the interrupt routine.

HOWEVER, because another character is being sent down the serial line, there are so many machine cycles that could be processed before the next reception (RI set) occurs.

According to a poster, setting the serial port in mode 1 with TH1 and TL1 set to 255 will allow up to 160 machine cycles between the times that RI is set by hardware. For the rest of this message, I will make the assumption that we have 160 machine cycles available.

Any machine cycles being processed in the serial interrupt must be subtracted from the maximum available, and the result must be greater than 0.

If the result is exactly zero, then the interrupt will constantly get called.

If the result is less than zero, then there is a good chance your characters will be lost.

check this code out for a serial routine:

serisr:
jnb RI,skipri
mov A,SBUF
wait3:
wait2:
djnz R6,$
djnz R5,wait2
djnz R4,wait3
skipri:
reti

Obviously it won't work well, because the wait routine consumes about 16777216 machine cycles. The rest of the code only consumes 3!

So if our cycles were limited to 160, he would lose well over 10,000 characters on the serial port since he is in a middle of a wait routine and in a middle of a serial interrupt.

now check this code out for a serial routine:

serisr:
jnb RI,skipri
mov A,SBUF
skipri:
reti

It is alot better, and now the other routine (that was running before the serial interrupt was called) has a chance to process data.

because 160 - 3 (number of cycles used by the serial interrupt routine) = 157 cycles. This means that your other routines can process up to 157 cycles worth of instructions at any one time before the serial interrupt is processed again.



List of 34 messages in thread
TopicAuthorDate
RxD to LCD problems            01/01/70 00:00      
   Serial ISR            01/01/70 00:00      
   work needed.            01/01/70 00:00      
   you need to control flow            01/01/70 00:00      
      confused            01/01/70 00:00      
         this is what I mean            01/01/70 00:00      
            OK            01/01/70 00:00      
               yes            01/01/70 00:00      
            Non-useful Serial ISR            01/01/70 00:00      
               AND it's stuck            01/01/70 00:00      
                  thanks            01/01/70 00:00      
               I was going for optimization.            01/01/70 00:00      
      It's functioning            01/01/70 00:00      
         now stay consistent            01/01/70 00:00      
            Terminating code?            01/01/70 00:00      
               .            01/01/70 00:00      
                  correct terminology            01/01/70 00:00      
                  Missing the point            01/01/70 00:00      
                     i get it now            01/01/70 00:00      
                        Most, but not all            01/01/70 00:00      
                        why on earth            01/01/70 00:00      
                        if it\'s almost correct, it\'s still wrong :-)            01/01/70 00:00      
                           ok            01/01/70 00:00      
                              Not R6 and R7            01/01/70 00:00      
                                 well it happend again            01/01/70 00:00      
                                    Q.E.D.            01/01/70 00:00      
                                       One further comment is needed            01/01/70 00:00      
                              Hey            01/01/70 00:00      
                        Dangerous recommendation            01/01/70 00:00      
                           good point            01/01/70 00:00      
                              they all do            01/01/70 00:00      
                  it 'trust' the same as 'experiment'?            01/01/70 00:00      
   more issues            01/01/70 00:00      
      Joe, please read this            01/01/70 00:00      

Back to Subject List