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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Jan Waclawek
01/04/06 16:27
Read: 689 times
Bratislava
Slovakia


 
#106530 - more than a couple of comments...
Responding to: Jon Ledbetter's previous message
Dear Jon,

You will certainly hate me but... I first wanted to comment on it line by line and also on the text, just it turned out to be really too much... To ease it a little bit, let me say that the formatting is really now very nice.

I throw in the following (leaving the commenting to the reader):


CR           EQU   13
LF           EQU   10

RX_TAIL      EQU   08H
RX_HEAD      EQU   09H
TX_TAIL      EQU   0AH
TX_HEAD      EQU   0BH
RX_BUFF      EQU   0CH
RX_BUFF_END  EQU   13H
TX_BUFF      EQU   RX_BUFF_END+1  ;14H
TX_BUFF_END  EQU   1FH

NEEDTI   BIT   01H   ;20H.1

SP_INIT  EQU   30H



   ORG   0
   LJMP  MAIN

   ORG   23H
   LJMP  SER_ISR


   ORG   40H
MAIN:
   MOV   SP,#SP_INIT
SER_INIT:
   MOV   SCON,#01010000B    ;8N1
   MOV   TMOD,#00100001B
   MOV   TH1,#-3            ;9600Bd @ XTAL=11.0592MHz
   SETB  TR1
;
   MOV   RX_TAIL,#RX_BUFF
   MOV   RX_HEAD,#RX_BUFF
   MOV   TX_TAIL,#TX_BUFF
   MOV   TX_HEAD,#TX_BUFF
   SETB  NEEDTI
;
   SETB  ES
   SETB  EA
;
   MOV   DPTR,#SINIT
   LCALL TEXT_OUT
;
LOOP:
   LCALL GET_RX_NR
   CJNE  A,#4,MAIN_X2
MAIN_X2:
   JC    LOOP

   MOV   R2,A
MAIN_X3:
   LCALL GET_CHAR
   LCALL PUT_CHAR_WAIT
   DJNZ  R2,MAIN_X3
   
   SJMP  LOOP
;
;
SINIT:
   DB    CR,LF
   DB    'SERIAL PORT INITIALISED!'
   DB    CR,LF,0

;***************************
GET_RX_NR:
   CLR   C
   MOV   A,RX_HEAD
   SUBB  A,RX_TAIL
   JNC   GET_RX_NR_X1
   CPL   A
   INC   A
GET_RX_NR_X1:
   RET
;***************************
GET_CHAR_WAIT:
;   LCALL GET_CHAR
;   JC    GET_CHAR_WAIT
;   RET
   MOV   A,RX_TAIL
   CJNE  A,RX_HEAD,GET_CHAR_X1
   SJMP  GET_CHAR_WAIT


GET_CHAR:
   MOV   A,RX_TAIL
   CJNE  A,RX_HEAD,GET_CHAR_X1
   SETB  C
   RET
GET_CHAR_X1:
   INC   A
   CJNE  A,#RX_BUFF_END+1,GET_CHAR_X2
   MOV   A,#RX_BUFF
GET_CHAR_X2:
   XCH   A,RX_TAIL
   MOV   R0,A
   MOV   A,@R0
   CLR   C
   RET
;***************************   
PUT_CHAR_WAIT:
;   LCALL PUT_CHAR
;   JC    PUT_CHAR_WAIT
;   RET
   MOV   R0,A
   MOV   A,TX_HEAD
   INC   A
   CJNE  A,#TX_BUFF_END+1,PUT_CHAR_WAIT_X1
   MOV   A,#TX_BUFF
PUT_CHAR_WAIT_X1:
   CJNE  A,TX_TAIL,PUT_CHAR_X2
   SJMP  PUT_CHAR_WAIT_X1

PUT_CHAR:
   MOV   R0,A
   MOV   A,TX_HEAD
   INC   A
   CJNE  A,#TX_BUFF_END+1,PUT_CHAR_X1
   MOV   A,#TX_BUFF
PUT_CHAR_X1:
   CJNE  A,TX_TAIL,PUT_CHAR_X2
   MOV   A,R0
   SETB  C
   RET
PUT_CHAR_X2:
   XCH   A,TX_HEAD
   XCH   A,R0
   MOV   @R0,A
   JNB   NEEDTI,PUT_CHAR_X3
   CLR   NEEDTI
   SETB  TI
PUT_CHAR_X3:
   CLR   C
   RET
;***************************
TEXT_OUT:
   CLR   A
   MOVC  A,@A+DPTR
   INC   DPTR
   JZ    TEXT_OUT_X1
   LCALL PUT_CHAR_WAIT
   SJMP  TEXT_OUT
TEXT_OUT_X1:
   RET
;***************************
SER_ISR:
   PUSH  PSW
   PUSH  ACC
   MOV   A,R0
   PUSH  ACC

   JNB   RI,SER_ISR_TX
SER_ISR_RX:
   CLR   RI
   MOV   A,RX_HEAD
   INC   A
   CJNE  A,#RX_BUFF_END+1,SER_ISR_RX1
   MOV   A,#RX_BUFF
SER_ISR_RX1:
   CJNE  A,RX_TAIL,SER_ISR_RX2
                      ;in PC, a beep comes here...
   SJMP  SER_ISR_TX
SER_ISR_RX2:
   XCH   A,RX_HEAD
   MOV   R0,A
   MOV   @R0,SBUF
   
SER_ISR_TX:
   JNB   TI,SER_ISR_END
   CLR   TI
   MOV   A,TX_TAIL
   CJNE  A,TX_HEAD,SER_ISR_TX1
   SETB  NEEDTI
   SJMP  SER_ISR_END
SER_ISR_TX1:
   INC   A
   CJNE  A,#TX_BUFF_END+1,SER_ISR_TX2
   MOV   A,#TX_BUFF
SER_ISR_TX2:
   XCH   A,TX_TAIL
   MOV   R0,A
   MOV   SBUF,@R0
   
SER_ISR_END:
   POP   ACC
   MOV   R0,A
   POP   ACC
   POP   PSW
   RETI

   END




Just one more remark for the hardware part, you mentioned you will replace the DTE/DCE by PC/modem...
And I would spare down the 25-pin DSUB description, I think it is really rarely used today.


Jan Waclawek


List of 46 messages in thread
TopicAuthorDate
Feedback needed        Jon Ledbetter      12/12/05 13:29      
   Couple of ideas      Sasha Jevtic      12/12/05 14:24      
   Missing      Andy Neil      12/12/05 15:28      
      the source...      Jan Waclawek      12/12/05 16:10      
         Stupid EIA      Andy Neil      12/13/05 00:52      
      Maybe a Name change?      Jon Ledbetter      12/12/05 22:30      
         minor but annoying ...      Richard Erlacher      03/17/06 09:33      
   USB      Ian Bell      12/12/05 16:06      
      Limited Experience      Jon Ledbetter      12/12/05 22:43      
      known bad USB/serial      Jan Waclawek      12/13/05 01:56      
      FYI - Targus PA088      Jon Ledbetter      12/13/05 09:46      
   thoughts      Jan Waclawek      12/12/05 16:17      
      I am so stupid      Jan Waclawek      12/13/05 02:02      
         Kickstart      Jon Ledbetter      12/13/05 07:36      
   attribution      Steve M. Taylor      12/13/05 03:41      
   The ONE thing I always have to look up a      Erik Malund      12/13/05 08:03      
   Ok - Second revision, but still working,      Jon Ledbetter      12/15/05 14:16      
      Nice      Steve M. Taylor      12/15/05 15:12      
         OK      Jon Ledbetter      12/15/05 15:33      
         MAX202 vs. MAX232A      Jan Waclawek      12/16/05 02:32      
         or the 232A      Erik Malund      12/16/05 06:32      
      Polled; Interrupt      Andy Neil      12/16/05 00:39      
         polled tx      Jon Ledbetter      12/16/05 07:48      
            Assorted small ideas      Sasha Jevtic      12/17/05 00:19      
               Not a good idea      Kai Klaas      12/17/05 06:46      
                  Serial speeds?      Sasha Jevtic      12/17/05 08:41      
                     Enhanced specifications      Kai Klaas      12/18/05 06:38      
                        That's a strange spec      Sasha Jevtic      12/20/05 15:04      
      formal stuff      Jan Waclawek      12/16/05 02:59      
         formal      Jon Ledbetter      12/16/05 08:23      
            who's the intended audience      Jan Waclawek      12/16/05 09:15      
   3rd Revision      Jon Ledbetter      12/27/05 08:47      
      Busy?      Jon Ledbetter      01/03/06 12:23      
         more than a couple of comments...      Jan Waclawek      01/04/06 16:27      
            So.....      Jon Ledbetter      01/05/06 15:01      
               what I like or not...      Jan Waclawek      01/06/06 08:25      
                  comments      Jan Waclawek      02/28/06 05:18      
                     Comments on Comments      Jon Ledbetter      02/28/06 09:37      
                        bah...      Jan Waclawek      02/28/06 11:25      
                           more problems      Jan Waclawek      02/28/06 13:20      
                              RE: Problems      Jon Ledbetter      02/28/06 13:36      
                              Something Strange      Jon Ledbetter      02/28/06 13:57      
                                 Nope....      Jon Ledbetter      02/28/06 14:28      
                                    interrupt      Jan Waclawek      02/28/06 15:30      
   All members will enjoy      Ralph Sack      03/16/06 21:55      
   Intel serial intro app note      Sasha Jevtic      03/28/06 15:16      

Back to Subject List