home *** CD-ROM | disk | FTP | other *** search
/ Peanuts NeXT Software Archives / Peanuts-2.iso / Developer / hardware / dsp / drbub / board / note7 < prev    next >
Encoding:
Text File  |  1991-09-07  |  8.7 KB  |  233 lines

  1. Building a DSP board, Part Seven: Serial Loader Bootstrap
  2. ---------------------------------------------------------
  3.  
  4. This is the seventh in a series on how I went about building
  5. a dual Motorola DSP56000 sampling board.
  6.  
  7. Okay, first off, how did I make this board two channel in,
  8. four channel out?  Well, I told you how to make a single DSP
  9. board (two in, two out).  All you have to do is hook the
  10. second DSP to same input section you made for the first one,
  11. and make another completely new output section for the second
  12. one.
  13.  
  14. Now we have to make the board boot.  Since I'm using two DSPs,
  15. I'll have to burn two EPROMs.  First, let's find out how the
  16. built-in bootstrap ROM on the 56000 works.
  17.  
  18. When the 56000 boots, it loads its original operating mode from
  19. some external pins.  There are four different modes.  We want
  20. to set the chip up for a mode 1 initialization.  Mode 1 loads
  21. an external program into internal program RAM (PRAM) and then
  22. switches to mode 2 and starts executing from internal PRAM.
  23. Mode 2 is the standard operating mode.  Mode 1 is a fairly
  24. whacked out operating mode.  The 56000 executes from internal
  25. PROM, reads from external PROM, and then writes to internal PRAM.
  26.  
  27. The first thing the 56000 does is decide whether to load from
  28. an external byte-wide PROM or load from the byte-wide host
  29. port.  It does this by checking the MSBit of P:$C000 (the P:
  30. prefix means a reference to the program memory, as opposed to
  31. the X: and Y: memories).  We set this bit high (we want it to
  32. boot from EPROM) by tying D23 to +5V through a 10k resistor.
  33. The 56000 then selects 15 wait states (more than enough for our
  34. slow 250ns EPROM) and begins loading the PRAM from the EPROM.
  35.  
  36. Now, how does the 56000 map 8 bit-wide bytes into 24 bit-wide
  37. words?  Let's have a look:
  38.  
  39. EPROM        PRAM
  40. $C000        $0000 low byte
  41. $C001        $0000 middle byte
  42. $C002        $0000 high byte
  43.   .          .
  44. $C5FD        $01FF low byte
  45. $C5FE        $01FF middle byte
  46. $C5FF        $01FF high byte
  47.  
  48. Note that the PRAM loading is the Intel bassackwards method of
  49. LSB MSB instead of the awesome Motorola method of MSB LSB.  Go
  50. figure...
  51.  
  52. Now, I didn't feel like dealing with the $C000 decoding, so I
  53. just hooked up the lower address bits to the EPROM (I used a
  54. 2716) plus the P address bank selector.
  55.  
  56. So, after the 56000 is done loading from the EPROM, it switches
  57. to operating mode 2 (maps PRAM to program fetching as well as
  58. P: writing) and boots the program it just loaded from P:$0000.
  59.  
  60. Here is the program that I blasted into my EPROM.  I think it
  61. is documented fairly okay, so I won't say anything else.
  62.  
  63. Next time: initializing all of your hardware
  64.  
  65. ----------------------------------------------------------------------
  66. ; sloader.asm
  67. ; Wed Aug  2 23:56:14 PDT 1989
  68. ; This file originally came from Motorola's Dr. BuB DSP board.
  69. ; Slightly modified by Todd Day (todd@ivucsb.sba.ca.us)
  70. ;    to echo characters received.
  71.  
  72. ;       Serial Loader for the DSP56000.
  73. ;       This loader initializes the serial communications interface (SCI)
  74. ;       on the DSP56001 for 9600 baud and then loads OMF records (output
  75. ;       by the DSP56000 assembler) into internal memory.  The loader takes
  76. ;       the upper 128 bytes of P memory allowing the lower memory from
  77. ;       $0000-(LDRMEM-1) to be used by the user.  The following records are
  78. ;       interpreted:
  79. ;           _DATA X ADDR
  80. ;           _DATA Y ADDR
  81. ;           _DATA P ADDR
  82. ;           _END ADDR
  83. ;       After the END record is encountered, the loader jumps to the address
  84. ;       in the END record.  Note that an address MUST be present in the
  85. ;       END record (the program must contain at least one P segment).
  86. ;
  87. ;       To generate a EPROM of this loader (8Kx8), perform the following:
  88. ;       $ asm56000 -b -l -a sloader
  89. ;       $ srec sloader
  90. ;
  91. ;       The EPROM is in file SLOADER.P.  To program the EPROM, set the
  92. ;       programmer to MOTOROLA S record format, download the file with
  93. ;       a zero address offset and program the part.
  94. ;
  95. ;    BTW, S record format is LSB MidSB MSB (what! Intel format? :-)
  96. ;    Took me a few hours to figure this one out!
  97. ;
  98. ;    If you don't have the program srec (where can I get this?),
  99. ;    you have to do some gnarly contortions on the .LOD file.
  100. ;
  101. ;    So, if your .LOD file resulting from compiling this program
  102. ;    looks like this:
  103. ;
  104. ;    _START SLOADER 0000 0000
  105. ;
  106. ;    _DATA P 0020
  107. ;    010203 040506 070809
  108. ;    _END 0020
  109. ;
  110. ;    then, program your PROM with this sequence:
  111. ;    $0020    0302  0106  0504  0908  07..... etc. (Fun, eh? :)
  112. ;
  113. ;
  114. ;       The loader loads the following memory spaces:
  115. ;           X - 0 to FF
  116. ;           Y - 0 to FF
  117. ;           P - 0 to LDRMEM-1
  118. ;
  119.         PAGE    68,66,1,1
  120.  
  121. SCR     EQU     $FFF0           ;SCI CONTROL REGISTER
  122. SCCR    EQU     $FFF2           ;SCI CLOCK CONTROL REGISTER
  123. PCC     EQU     $FFE1           ;PORT C CONTROL REGISTER
  124. RDRF    EQU     $2              ;RECEIVE DATA REGISTER FULL FLAG
  125. SSR     EQU     $FFF1           ;SCI STATUS REGISTER
  126. SRXH    EQU     $FFF6           ;SCI RECEIVE IN HIGH BYTE
  127. LDRMEM  EQU     $19D            ;START OF LOADER IN P MEMORY
  128.  
  129.         ORG     P:$0000         ;RESET VECTOR FOR BOOTING
  130. RVEC
  131.         JMP     LOAD            ;GO EXECUTE LOADER
  132.  
  133.         ORG     P:LDRMEM,P:3*LDRMEM
  134. LOAD
  135.         MOVEP   #$0302,X:SCR    ;ENABLE TX,RX: 8 BIT 1 START, 1 STOP
  136.  
  137.                 ; *** You will probably have to
  138.                 ; *** change the line below!
  139.         MOVEP   #$0020,X:SCCR   ;CD=32 (/33), INT CLK @ 9600 BAUD
  140.         MOVEP   #$0007,X:PCC    ;ENABLE SCI
  141. WTUS
  142.         JSR     GETCH           ;INPUT CHARACTER
  143.         MOVE    #'_',X0         ;GET UNDERSCORE CHARACTER
  144.         CMP     X0,A            ;SEE IF "_" YET
  145.         JNE     WTUS            ;NO
  146. GOTUS
  147.         JSR     GETCH           ;GET A CHARACTER
  148.         MOVE    #'D',X0         ;GET A D FOR DATA
  149.         CMP     X0,A    #'E',X0 ;COMPARE TO D, GET E
  150.         JEQ     DATAREC         ;IF "D", THEN DATA RECORD
  151.         CMP     X0,A            ;SEE IF END RECORD
  152.         JNE     WTUS            ;NO, GO WAIT FOR ANOTHER UNDERSCORE
  153. _WTSPC
  154.         JSR     GETCH           ;GET CHARACTER
  155.         MOVE    #$20,X0         ;GET SPACE
  156.         CMP     X0,A            ;WAIT FOR SPACE AFTER "END"
  157.         JNE     _WTSPC          ;WAIT FOR SPACE
  158.         JSR     IN4             ;GET TRANSFER ADDRESS
  159.         MOVE    B1,R0           ;MOVE TRANSFER ADDRESS
  160.         NOP                     ;CLEAR ADDRESS PIPE
  161.         JMP     (R0)            ;GO EXECUTE USER CODE
  162. DATAREC
  163.         JSR     GETCH           ;GET CHARACTER
  164.         MOVE    #$20,X0         ;GET SPACE
  165.         CMP     X0,A            ;SEE IF SPACE
  166.         JNE     DATAREC         ;NO
  167.         JSR     GETCH           ;GET [P,X,Y]
  168.         MOVE    A1,Y0           ;SAVE CHARACTER
  169.         JSR     IN4             ;GET ADDRESS OF DATA RECORD
  170.         MOVE    B1,R0           ;SAVE ADDRESS
  171.         MOVE            #'X',A  ;GET X
  172.         CMP     Y0,A    #'Y',A  ;SEE IF X, GET Y
  173.         JEQ     _LDX            ;LOAD DATA INTO X MEMORY
  174.         CMP     Y0,A            ;SEE IF Y
  175.         JEQ     _LDY            ;LOAD DATA INTO Y MEMORY
  176. _LDP
  177.         JSR     IN6             ;GET DATA
  178.         MOVE    B1,P:(R0)+      ;LOAD P MEMORY
  179.         JMP     _LDP
  180. _LDX
  181.         JSR     IN4             ;GET DATA
  182.         MOVE    B1,X:(R0)+      ;LOAD X MEMORY
  183.         JMP     _LDX
  184. _LDY
  185.         JSR     IN4             ;GET DATA
  186.         MOVE    B1,Y:(R0)+      ;LOAD Y MEMORY
  187.         JMP     _LDY
  188.  
  189. GETCH
  190.         JCLR    #RDRF,X:SSR,*   ;WAIT FOR DATA IN SCI
  191.         MOVEP   X:SRXH,A        ;GET SCI DATA IN HIGH BYTE
  192.         LSL     A               ;SHIFT OUT PARITY
  193.         LSR     A               ;PUT 0 IN PARITY BIT
  194.         MOVE    A1,A            ;SIGN EXTEND AND ZERO
  195.     MOVEP    A,X:SRXH    ;put sci data in high byte
  196.         RTS
  197.  
  198. IN4
  199.         CLR     B       #>4,X0  ;CLEAR VALUE, GET 4
  200.         JMP     READHEX         ;READ 4 HEX CHARACTERS
  201. IN6
  202.         CLR     B       #>6,X0  ;CLEAR VALUE, GET 6
  203. READHEX
  204.         DO      X0,_READHEX     ;READ ASCII HEX AND CONVERT TO BINARY
  205. _GET
  206.         JSR     GETCH           ;GET A CHARACTER
  207.         MOVE    #'_',X0         ;GET UNDERSCORE
  208.         CMP     X0,A    #'F',X0 ;SEE IF UNDERSCORE
  209.         JNE     _NOTUS          ;NO
  210.         ENDDO                   ;EXIT LOOP
  211.         MOVE    SSH,X0          ;POP RETURN ADDRESS
  212.         JMP     GOTUS           ;GO PROCESS NEW INPUT RECORD
  213. _NOTUS
  214.         CMP     X0,A    #'0',X0 ;SEE IF GREATER THAN F
  215.         JGT     _GET            ;YES, IGNORE
  216.         CMP     X0,A            ;SEE IF LESS THAN 0
  217.         JLT     _GET            ;YES, IGNORE
  218.         SUB     X0,A    #10,X0  ;ADJUST FOR ASCII TO BINARY
  219.         CMP     X0,A    #7,X0   ;SEE IF A-F
  220.         JLT     _NOTALPHA       ;NO
  221.         SUB     X0,A            ;ADJUST FOR 1-F
  222. _NOTALPHA
  223.         REP     #4              ;SHIFT OLD VALUE LEFT 1 NIBBLE
  224.         LSL     B
  225.         REP     #16             ;SHIFT NEW NIBBLE DOWN TO LSB
  226.         LSR     A
  227.         ADD     A,B             ;ADD NEW NIBBLE IN
  228. _READHEX
  229.         RTS
  230.  
  231.         END
  232.  
  233.