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

  1. Building a DSP board, Part Eight: Initializing the Hardware
  2. -----------------------------------------------------------
  3.  
  4. This is the eighth in a series on how I went about building
  5. a dual Motorola DSP56000 sampling board.
  6.  
  7. We left off with a program bootstrapped into memory from the
  8. serial port and all ready to run.  But before we begin execution,
  9. we must make sure that the DSP registers and ports are full
  10. initialized.
  11.  
  12. At this point, I will insert a file that I include at the top
  13. of all of my programs called SETUP.ASM.  I will be adding my
  14. comments to the file.  The extra stuff will be set off by the
  15. `#' character.
  16.  
  17. ; setup.asm
  18. ; setup the SRAMS
  19. ; setup the ssi port to talk to the 5805s
  20. ; setup the sci port to talk to host
  21.  
  22. # The first thing we must do is make sure that no interrupts are running.
  23. # Actually, at this point, the interrupts should already be masked, but
  24. # I never take any chances.
  25.  
  26. ; set up mode register
  27. ; LF  **  TM  **  S1  S0  I1  I0
  28. ;  0   0   0   0   0   0   1   1
  29. ;    No loop flag (LF)
  30. #        ^        This should be obvious
  31. ;    No trace mode (TR)
  32. #        ^        Ever the cautious one!
  33. ;    No scaling (Sn)
  34. #        ^        Don't want automatic scaling done.
  35. #                (Mainly used for floating point.)
  36. ;    Mask Interrupts (In)
  37. #        ^        Set bits for masking.
  38.  
  39.     ori    #$03,mr
  40. # If you think about it, the above is pointless because of the `or' except
  41. # for the masking of the interrrupts.  I really should put
  42. #     andi    #$03,mr
  43. # before it.
  44.  
  45. # Now we must set the wait states for the SRAMS.  Remember that we need
  46. # only one wait state.  Also, we can have a max of 15 wait states (4 bits
  47. # per type of memory).
  48.  
  49. ; set bus control register for one wait state for X and Y mem (SRAMS)
  50. ; XMEM YMEM PMEM EXIO
  51. ;  $1   $1   $0   $0
  52. ;    Number of wait states for each type of memory
  53.  
  54.     movep    #$1100,x:m_bcr
  55.  
  56. # Now we must assign priority levels to the types of interrupts.
  57. # Remember that we hooked up the serial ADCs and DACs to the
  58. # synchronous serial ports.  We want to start processing audio data
  59. # the nanosecond it gets in.  Therefore, we'll assign it the highest
  60. # priority.  As far as the asynchronous serial port goes, we won't
  61. # generally be using while we are doing DSP work.  However, it is
  62. # handy to be able to send changes to the chip on the fly.  But, do
  63. # we really want to use interrupts to read the asynch serial port?
  64. # Interrupts will already be servicing the audio data, so the main
  65. # loop of the processing programs will simply be an infinite loop.
  66. # Why not have the main loop of the program be on the lookout for
  67. # asynch serial data?  I think it's a good idea, so I don't assign
  68. # any interrupts to the asynch port.
  69.  
  70. ; set interrupt priority levels
  71. ; SCL1 SCL0 SSL1 SSL0 HPL1 HPL0 **** ****
  72. ;   0    0    1    1    0    0    0    0
  73. ; **** **** IBL2 IBL1 IBL0 IAL2 IAL1 IAL0
  74. ;   0    0    0    0    0    0    0    0
  75. ;    No SCI interrupts {we'll poll} (SCLn=0)
  76. ;    Priority 2 for SSI (SSLn=1)
  77. ;    No Host interrrupts (HPLn=0)
  78. #        ^            Not using the host port here.  If
  79. #                    you build a card into the IBMPC, you
  80. #                    might want to read from host port
  81. #                    instead of asynch port.
  82. ;    No IRQx interrups (IxLn=0)
  83.  
  84.     movep    #$3000,x:m_ipr
  85.  
  86. # One of the wonderful things about the synchronous serial port is that
  87. # you can set it to accept word lengths of 24, 16, 12, and 8 bits.  If
  88. # you hook into the data stream of a CD player, you'll need to use 24
  89. # bits.  (Surprise!  This is the standard, even though the bottom 8 bits
  90. # are zeros.  I don't think these are actually encoded on the disc, just
  91. # inserted by the circuitry.)  Remember, we are using an external clock,
  92. # so no scaling is required.
  93.  
  94. ; initialize ssi port
  95. ; setup Control Register A (CRA)
  96. ; PSR WL1 WL0 DC4 DC3 DC2 DC1 DC0 PM7 PM6 PM5 PM4 PM3 PM2 PM1 PM0
  97. ;  0   1   0   0   0   0   0   0   0   0   0   0   0   0   0   0
  98. ;    No prescaler (PMn)
  99. #        ^            We use external clock.
  100. ;    No frame rate (DCn)
  101. #        ^            We use external clock.
  102. ;    Word length = 16 (WL1=1, WL0=0)
  103. ;    No prescaler range (PSR)
  104. #        ^            We use external clock.
  105.  
  106.     movep    #$4000,x:m_cra
  107.  
  108. # There are a lot of fancy ways to set up external and internal data
  109. # clocks for the SSI.  I just put zeros here 'cause I'm not using them.
  110.  
  111. ; setup Control Register B (CRB)
  112. ; RIE TIE RE TE MOD GCK SYN FSL *** *** SCKD SCD2 SCD1 SCD0 OF1 OF0
  113. ;  0   0   1  1  0   0   1   0   0   0   0    0    0    0    0   0
  114. ;    No output flags (OFn)
  115. ;    SCn and SCK are all inputs (SCxx=0)
  116. #                    SC0 is our L/R clock
  117. #                    SC2 is data fram clock
  118. ;    Frame length = data word (FSL=0)
  119. #                    Use Word length, not Bit length
  120. ;    Synchronous (SYN=1)
  121. #                    We're all running off the same
  122. #                    clock, so better use synchronous
  123. #                    input and output frames.
  124. ;    No gated glock (GCK=0)
  125. #                    That's gated CLOCK!  The clock is
  126. #                    continously running, not gated.
  127. ;    Normal Mode (MOD=0)
  128. #                    We're not using network mode.
  129. ;    Transmit on Frame Sync (TE=1)
  130. ;    Receive on Frame Sync (RE=1)
  131. #        ^            Sync with frames.
  132. ;    No transmit interrupt (TIE=0)
  133. #                    We don't need this, as we know
  134. #                    it will be clear when we are
  135. #                    ready to write to it.  This is
  136. #                    because we are not generating
  137. #                    more data than we are provided with.
  138. ;    No receive interrupt, yet (RIE=0)
  139. #                    Hey!  No interrupts yet!  Later!
  140.  
  141.     movep    #$3200,x:m_crb
  142.  
  143. # Now we set up the asynchronous serial port.  We'll do standard N81
  144. # and 4800 baud (because 9600 doesn't divide down from 20MHz by integers
  145. # very well.
  146.  
  147. ; initialize SCI port
  148. ; setup SCI Interface Control Register (SCR)
  149. ; **** **** TMIE  TIE  RIE ILIE  TE   RE
  150. ;   0    0    0    0    0    0    1    1
  151. ; WOMS  RWU WAKE  SBK **** WDS2 WDS1 WDS0
  152. ;   0    0    0    0    0    0    1    0
  153. ;    1 start-8 data-1 stop (WDS2,WDS1,WDS0=0,1,0)
  154. ;    No send break (SBK=0)
  155. ;    No wake-up (WAKE,RWU=0)
  156. #                    ??? Something to do will idle line?
  157. ;    No open-collector output (WOMS=0)
  158. ;    Enable receiver (RE=1)
  159. ;    Enable transmitter (TE=1)
  160. ;    No idle line interrupt (ILIE=0)
  161. #                    ??? See above?
  162. ;    No receive interrupt {we'll poll} (RIE=0)
  163. ;    No transmit interrupt (TIE=0)
  164. #                    We'll make sure it's ready
  165. ;    No timer interrupt (TMIE=0)
  166.  
  167.     movep    #$0302,x:m_scr
  168.  
  169. ; setup SCI Clock Control Register (SCCR)
  170. ;  TCM  RCM  SCP  COD CD11 CD10  CD9  CD8
  171. ;   0    0    0    0    0    0    0    0
  172. ;  CD7  CD6  CD5  CD4  CD3  CD2  CD1  CD0
  173. ;   0    1    0    0    0    0    0    1
  174. ;    We need a baud rate of 4800
  175. #                    For fun, let's try 9600
  176. ;    Divider = 20,000,000 / (2*1*2*16*4800) = 65
  177. #                     9600  = 32 or 33
  178. ;    Baud rate really is 4808 (< 0.2% error)
  179. #                9766 (1.7% err) or 9470 (1.4% err)
  180. ;    CD11-CD0 = 000001000001
  181. #                    This is 65 binary
  182. ;    No clock output (COD=0)
  183. #                    We need no output clock
  184. ;    No prescaler (SCP=0)
  185. #                    This puts a 1 instead of 8 in
  186. #                    the divider equation
  187. ;    Use internal clock for receive (RCM=0)
  188. ;    Use internal clock for transmit (TCM=0)
  189.  
  190.     movep    #$0041,x:m_sccr
  191.  
  192. # Now we have to enable all of the input and output pins for
  193. # our serial interfaces.
  194.  
  195. ; enable SSI and SCI pins (Port C Control Register - PCC)
  196. ; CC8 CC7 CC6 CC5 CC4 CC3 CC2 CC1 CC0
  197. ;  1   1   1   1   0   1   0   1   1
  198. ;    STD enable (CC8=1)
  199. #                Asynch transmit data
  200. ;    SRD enable (CC7=1)
  201. #                Asynch receive data
  202. ;    SCK enable (CC6=1)
  203. #                Synch bit clock
  204. ;    SC2 enable (CC5=1)
  205. #                Synch word clock
  206. ;    No SC1 (CC4=0)
  207. ;    SC0 enable (CC3=1)
  208. #                Synch L/R clock
  209. ;    No SCLK (CC2=0)
  210. #                No clock output
  211. ;    TXD enable (CC1=1)
  212. #                Synch transmit data
  213. ;    RXD enable (CC0=1)
  214. #                Synch receive data
  215.  
  216.     movep    #$01EB,x:m_pcc
  217.  
  218. Now, to use the above file, you'd put this into the top
  219. of your program:
  220.  
  221.     include    'defs.inc'
  222.     include    'ioequ.inc'
  223.     include    'intequ.inc'
  224.  
  225.     org    p:pgmram
  226.     include    'setup.asm'
  227.  
  228. The above top three files are available via my archive server
  229. and include all the definitions used in 'setup.asm'.
  230.  
  231. Then, you do all your initialization and add
  232.  
  233. ; start interrupts
  234.     movep    #$b200,x:m_crb
  235.     andi    #$00,mr
  236.  
  237. The first line starts enables the synchronous serial interrupts and the
  238. second line enables all interrupts.
  239.  
  240.