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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/04/06 23:27
Read: times


 
#106530 - more than a couple of comments...
Responding to: ???'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            01/01/70 00:00      
   Couple of ideas            01/01/70 00:00      
   Missing            01/01/70 00:00      
      the source...            01/01/70 00:00      
         Stupid EIA            01/01/70 00:00      
      Maybe a Name change?            01/01/70 00:00      
         minor but annoying ...            01/01/70 00:00      
   USB            01/01/70 00:00      
      Limited Experience            01/01/70 00:00      
      known bad USB/serial            01/01/70 00:00      
      FYI - Targus PA088            01/01/70 00:00      
   thoughts            01/01/70 00:00      
      I am so stupid            01/01/70 00:00      
         Kickstart            01/01/70 00:00      
   attribution            01/01/70 00:00      
   The ONE thing I always have to look up a            01/01/70 00:00      
   Ok - Second revision, but still working,            01/01/70 00:00      
      Nice            01/01/70 00:00      
         OK            01/01/70 00:00      
         MAX202 vs. MAX232A            01/01/70 00:00      
         or the 232A            01/01/70 00:00      
      Polled; Interrupt            01/01/70 00:00      
         polled tx            01/01/70 00:00      
            Assorted small ideas            01/01/70 00:00      
               Not a good idea            01/01/70 00:00      
                  Serial speeds?            01/01/70 00:00      
                     Enhanced specifications            01/01/70 00:00      
                        That's a strange spec            01/01/70 00:00      
      formal stuff            01/01/70 00:00      
         formal            01/01/70 00:00      
            who's the intended audience            01/01/70 00:00      
   3rd Revision            01/01/70 00:00      
      Busy?            01/01/70 00:00      
         more than a couple of comments...            01/01/70 00:00      
            So.....            01/01/70 00:00      
               what I like or not...            01/01/70 00:00      
                  comments            01/01/70 00:00      
                     Comments on Comments            01/01/70 00:00      
                        bah...            01/01/70 00:00      
                           more problems            01/01/70 00:00      
                              RE: Problems            01/01/70 00:00      
                              Something Strange            01/01/70 00:00      
                                 Nope....            01/01/70 00:00      
                                    interrupt            01/01/70 00:00      
   All members will enjoy            01/01/70 00:00      
   Intel serial intro app note            01/01/70 00:00      

Back to Subject List