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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/03/04 01:01
Read: times


 
#73561 - RE: UART Without Serial Interrupt?
Responding to: ???'s previous message
I personally used it in case of a "run once" piece of program - as handshake. Disregard any line noise and junk PC may be sending and reply with an unique string to signify you were listening and you are ready to proceed.

The idea was to synchronize the microcontroller with PC. The '52 waits for a string 'RUN' from PC, then it replies with 'OK' and proceeds normally, with synchronous, interrupt-based, buffered communication, while being sure the first byte received was the first meaningful byte sent etc.

The main profit is simplifying the interrupt routines. No branches for "handshake case", no separate setting pointer to data to be sent, no communication between interrupt routine and wait loop to signal "OK to proceed" - interrupts just do their main job they were meant for in the first place and only when they are supposed to, kept clean, fast and readable, and the handshake is blocking the program flow until successfully completed, just as it was meant to.


;(do all the init stuff). No 

HANDS:
MOV A,#'R'
JNB RI,$
CJNE A,SBUF,HANDS
CLR RI

MOV A,#'U'
JNB RI,$
CJNE A,SBUF,HANDS
CLR RI

MOV A,#'N'
JNB RI,$
CJNE A,SBUF,HANDS
CLR RI

MOV SBUF,#'O' 
; I'm not sure if SETB TI is needed or not, not quite in mood to check right now.
JNB TI,$

MOV SBUF,#'K' 
; I'm not sure if SETB TI is needed or not, not quite in mood to check right now.
JNB TI,$

SETB IE
;(proceed with main loop and real "data" communication in interrupts.)


List of 29 messages in thread
TopicAuthorDate
UART Without Serial Interrupt?            01/01/70 00:00      
   Polling            01/01/70 00:00      
      RE: Polling            01/01/70 00:00      
         RE: Polling            01/01/70 00:00      
            RE: Polling            01/01/70 00:00      
               RE: Polling            01/01/70 00:00      
                  RE: Polling            01/01/70 00:00      
                     RE: Polling            01/01/70 00:00      
                        RE: Polling            01/01/70 00:00      
                           RE: Polling            01/01/70 00:00      
                              RE: one step further            01/01/70 00:00      
                                 RE: one step further            01/01/70 00:00      
                                 another step further            01/01/70 00:00      
                                    RE: another step further            01/01/70 00:00      
                                       RE: another step further caveats            01/01/70 00:00      
                                          RE: another step further caveats            01/01/70 00:00      
                     RE: Polling -- long            01/01/70 00:00      
            RE: Polling            01/01/70 00:00      
               RE: Polling            01/01/70 00:00      
   RE: UART Without Serial Interrupt?            01/01/70 00:00      
      RE: UART Without Serial Interrupt?            01/01/70 00:00      
         RE: UART Without Serial Interrupt?            01/01/70 00:00      
         RE: UART Without Serial Interrupt?            01/01/70 00:00      
            RE: UART Without Serial Interrupt?            01/01/70 00:00      
   RE: UART Without Serial Interrupt?            01/01/70 00:00      
   When is polling preferable?            01/01/70 00:00      
      RE: When is polling preferable?            01/01/70 00:00      
   RE: UART Without Serial Interrupt?            01/01/70 00:00      
   Advantage of polling            01/01/70 00:00      

Back to Subject List