Jump to content
IGNORED

AUTOBAUD DETECTION FOR 9902


TheBF

Recommended Posts

I found this code in an old book from TI circa 1981.

 

I thought the gang here might find it interesting. Apologies. I have not assembled it and the tabs are all wrong but it's a neat idea.

It appears to work by measuring the time between mark and space in the signal and then looking up the rate interval for that measurement in the table.

Smart people at TI in 1981.

 

Minor edits per Stuart's comments

* autobaud for 9902
* Software Development, Texas Instruments 1981

           LI      R12,BASE
           SBO     31
           LI      R1,6200
           LDCR    R1,8
           SBZ     13
           CLR     R3

* wait for start bit
SBAUD      TB      15
           JEQ     SBAUD

* wait until rin goes back to space condition
SBAUD1     INC     R3
           TB      15
           JNE     SBAUD1

* FIND THE BAUD RATE
           LI      R4,BAUDTB-2
SBAUD2     INCT    R4
           C       R3 *R4+
           JH      SBAUD2

* baud rate found - set recieve and transmit data interval
* read a char and throw it away

           LDCR *R4,12
SBAUD3     TB   21
           JNE SBAUD3
           SBZ 18

BAUDTB     DATA >0007,>001A     * 19200
           DATA >000E,>0034     *  9600
           DATA >001D,>0068     *  4800
           DATA >003B,>00D0     *  2400
           DATA >0075,>01A0     *  1200
           DATA >00EA,>0340     *   600
           DATA >0246,>04D0     *   300
           DATA >7FFF,>0638     *   110
Edited by TheBF
  • Like 2
Link to comment
Share on other sites

I just discovered that you don't have to turn on the RS232 CARD to access the 9902 chips!

 

The CRU address can be set to >1340 and you can read and write the 9902 bits and send and receive data just fine.

 

Does anyone know of a downside if you are not using the DSR code?

  • Like 1
Link to comment
Share on other sites

 

I found this code in an old book from TI circa 1981.

 

I thought the gang here might find it interesting. Apologies. I have not assembled it and the tabs are all wrong but it's a neat idea.

It appears to work by measuring the time between mark and space in the signal and then looking up the rate interval for that measurement in the table.

Smart people at TI in 1981.

 

 

Tiny little typo in the listing:

 

LI R4,BAUDTB=2 should be LI R4,BAUDTB-2 (minus 2, not equals 2)

 

Note that the values in the Baud rate table are for no-wait state memory. The values in the first column will need recalculating if the code is run from memory with wait states. The Baud rates, from the top to the bottom of the table, are 19200, 9600, 4800, 2400, 1200, 600, 300, 110 Baud.

  • Like 1
Link to comment
Share on other sites

Thanks Stuart,

 

Any thoughts on the multiple that we should use for those times in column 1?

I suppose I could just load the code and hit it with a known BPS rate and look at R3.

 

I need to write this up in RPN assembler and try it.

  • Like 1
Link to comment
Share on other sites

  • 4 years later...

Recently I read the TI Software Development Handbook for the first time.  RKN's scan of the TI RX "Real-time Executive" was a big deal as well. 

 

So Dave Pitts (sim990) has some MPP disks, Microprocessor Pascal, which targets the TM990/101.  On disk 7 is some source to RX, because it is the base of MPX, the Microprocessor Pascal Executive. 

 

In the source, I noticed an (older?) version of the auto baud code posted earlier.  

 

debug.src

 

* REVISION: 03/28/80          ORIGINAL: 01/20/80
* ABSTRACT:
**************************************************************************
*                                                                  
*     STAND-ALONE DEBUGGER PACKAGE FOR Rx.                         
*                                                                  
**************************************************************************

 

 

INIT02 BYTE >62          CHARACTER USED TO INITIALLIZE 9902

 

Lines 110-168

 

****************************************************************
*      SET THE BAUD RATE OF A PORT.                            *                
*           THIS ROUTINE SETS THE BAUD RATE OF ONE OF THE      *                
*      9902'S OF THE 990/101M BOARD.  THE PROPER BAUD RATE     *
*      IS CALCULATED BY WAITING FOR AN 'A' OR 'CR' INPUT       *
*      AND THEN LOOKING UP THE PROPER REGISTER VALUE.          *
*                                                              *
*      CALLING SEQUENCE:      BL   @SETBD1 (OR SETBD2)         *
*                                                              *
*      PARAMETERS:    NONE                                     *
*                                                              *
*      REGISTER USAGE:                                         *
*           R3 - SCRATCH.  POINTS TO THE BAUD RATE FLAG FOR    *
*                        9902 IN USE.                          *
*           R7 - SCRATCH.  POINTER TO BAUD RATE TABLE.         *
*           R8 - SCRATCH.  USED AS TIME COUNTER.               *
*           R11 - RETURN VECTOR.                               *
*           R12 - SET TO CRU BASE FOR THE 9902 USED.           *
*                                                              *
*      SUBROUTINES USED:      NONE                             *
*                                                              *
****************************************************************
*
SETBD1 LI   R12,>80      SET THE BAUD RATE FOR THE FIRST PORT
       LI   R3,CTTY      LOAD ADDRESS OF THE BAUD RATE FLAG
       JMP  SETRT        JUMP TO THE SET RATE
SETBD2 LI   R12,>180     SET THE BAUD RATE ON THE SECOND PORT
       LI   R3,CTTY+2    LOAD ADDRESS OF BAUD RATE FLAG
*
SETRT  SBO  31           RESET THE 9902
       LDCR @INIT02,8    INITIALLIZE THE 9902
       SBZ  13           SKIP THE INTERNAL TIMER
       CLR  R8           RESET LOOP COUNT
TSTSP  TB   15           SPACE?
       JEQ  TSTSP        NO, TEST AGAIN
SPLOOP INC  R8           TIME START BIT
       TB   15           FALL OUT ON MARK
       JNE  SPLOOP       CONTINUE IF NOT
*
*      TABLE LOOK-UP FOR BAUD RATE
*
       LI   R7,TABLE     SET POINTER TO TABLE
BDLOOP C    R8,*R7+      SEE IF MATCH
       JLE  MATCH        YES, SET BAUD RATE
       INCT R7           NO, UPDATE POINTER
       JMP  BDLOOP       LOOK AGAIN
MATCH  LDCR *R7,12       SET THE BAUD RATE
       MOV  *R7,*R3
       RT
TABLE  DATA 7,>1A        BAUD = 19200
       DATA 14,>34       BAUD = 9600
       DATA 29,>68       BAUD = 4800
       DATA 59,>D0       BAUD = 2400
       DATA 117          BAUD = 1200
BD1200 DATA >1A0
       DATA 117          BAUD = 1200
BD1200 DATA >1A0
       DATA 234,>340     BAUD = 600
       DATA 582,>4D0     BAUD = 300
       DATA 32767,>638   BAUD = 110
       PAGE

 

These baud rate tables would be for the TMS9900 using static RAMs on a TM990/100 single-board computer.  Lo, they are the same as above. 

 

Tragically, the Pascal mpp7.fpy is part 2 of the RX source code. Part 1 is lost. (I found that half the REFS have no DEFS)  mpp6.fpy does have the object code. 

 

  • Like 1
Link to comment
Share on other sites

No, the comments are correct. They describe the purpose of the instruction, or rather the whole block of instructions following. This is not a tutorial of how to write instructions for the TMS 9900, it's about how to get something done. The target audience is assumed (and rightly so) to know that you load the CRU base address to R12, so they will see that the purpose of this code is to set the baudrate for port one (and right below port two) and can see that different CRU addresses are loaded for that. The audience is also supposed to be knowledgeable enough to understand the meaning of this.

 

So, on the contrary, it's a comment very much on the mark. Unlike some you see, like this one:
INC R1 * Increment R1 by 1

Completely unnecessary for anyone except when learning the instructions themselves. This is a better comment:
INC R1 * Count the entered characters

The only objection I have to the comment is that I would probably have formatted it like this:

* Set the baud rate for the first port

SETBD1 LI    R12,>80

to more clearly indicate that this comment is a headline for a code segment, not a comment about a single instruction.

 

There is an error in the code, though, and that's that label BD1200 is defined twice and the data for 1200 bits/s is given twice.

Edited by apersson850
  • Like 3
Link to comment
Share on other sites

1 hour ago, apersson850 said:

No, the comments are correct. They describe the purpose of the instruction, or rather the whole block of instructions following. This is not a tutorial of how to write instructions for the TMS 9900, it's about how to get something done. The target audience is assumed (and rightly so) to know that you load the CRU base address to R12, so they will see that the purpose of this code is to set the baudrate for port one (and right below port two) and can see that different CRU addresses are loaded for that. The audience is also supposed to be knowledgeable enough to understand the meaning of this.

 

So, on the contrary, it's a comment very much on the mark. Unlike some you see, like this one:
INC R1 * Increment R1 by 1

Completely unnecessary for anyone except when learning the instructions themselves. This is a better comment:
INC R1 * Count the entered characters

The only objection I have to the comment is that I would probably have formatted it like this:

* Set the baud rate for the first port

SETBD1 LI    R12,>80

to more clearly indicate that this comment is a headline for a code segment, not a comment about a single instruction.

 

There is an error in the code, though, and that's that label BD1200 is defined twice and the data for 1200 bits/s is given twice.

I am of the same opinion.  A comment to the right of an instruction should pertain to the instruction. 

Comments for a block of code should be on the line preceding the code. 

 

Good catch on the duplicate label and data.  Better minds than mine...

  • Like 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...