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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/13/11 18:06
Read: times


 
#183354 - Even Better....
Responding to: ???'s previous message
Andy Neil said:
Maarten Brock said:
	MOV	SBUF, A      ; <=== It is better to check before sending instead of waiting
H_1:	JNB	TI, H_1      ; <=== for the transmission to complete. This way you can do other
	CLR	TI           ; <=== things in the meantime.
	RET
	END

 

In fact, it is essential to check before sending - otherwise you risk corrupting the byte currently being transmitted!


Even better is to put each byte being sent into say an 8 byte FIFO circular queue. Then let the occurrence of an interrupt from the TI bit getting set cause the next byte to be drawn out of the queue and get loaded into SBUF. This way only when you are sending more bytes than the size of the queue do you end up spinning in a polling loop wasting time that could be used for other activities. Short transmits in bursts can benefit greatly with this scheme. You pay a small amount of overhead checking and managing the index pointers for the queue but it is normally a small overhead compared to what you gain in being able to let a multifaceted application run on the MCU.

Michael Karas


List of 17 messages in thread
TopicAuthorDate
need help to display timer count on hyperterminal and LED'S            01/01/70 00:00      
   Attention to Details            01/01/70 00:00      
      divide by 10            01/01/70 00:00      
         Hundredth digit is quotient of division by 100            01/01/70 00:00      
            thanks            01/01/70 00:00      
               Debugged with pen and paper?            01/01/70 00:00      
                  Debugged            01/01/70 00:00      
                     Decimal or hexadecimal?            01/01/70 00:00      
                        decision            01/01/70 00:00      
                           So take up the challenge then            01/01/70 00:00      
                              agreed            01/01/70 00:00      
                        Actually BCD!!            01/01/70 00:00      
   Oh Details Details            01/01/70 00:00      
      update            01/01/70 00:00      
         Issues            01/01/70 00:00      
            better to check before sending            01/01/70 00:00      
               Even Better....            01/01/70 00:00      

Back to Subject List