-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtim.asm
More file actions
396 lines (332 loc) · 11.8 KB
/
tim.asm
File metadata and controls
396 lines (332 loc) · 11.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
COMMENT *
This file is used to generate boot DSP code for the 250 MHz fiber optic
timing board using a DSP56303 as its main processor. It supports
split serial and frame transfer, but not split parallel nor binning.
*
PAGE 132 ; Printronix page width - 132 columns
; Include the boot and header files so addressing is easy
INCLUDE "timhdr.asm"
INCLUDE "timboot.asm"
ORG P:,P:
CC EQU CCDVIDREV5+TIMREV5+TEMP_POLY+UTILREV3+SPLIT_SERIAL+SUBARRAY+BINNING+SHUTTER_CC
; Put number of words of application in P: for loading application from EEPROM
DC TIMBOOT_X_MEMORY-@LCV(L)-1
; Define CLOCK as a macro to produce in-line code to reduce execution time
CLOCK MACRO
JCLR #SSFHF,X:HDR,* ; Don't overfill the WRSS FIFO
REP Y:(R0)+ ; Repeat # of times at address Y:(R0)+
MOVEP Y:(R0)+,Y:WRSS ; Write the waveform to the FIFO
ENDM
; Set software to IDLE mode
START_IDLE_CLOCKING
MOVE #IDLE,R0
NOP
MOVE R0,X:<IDL_ADR
BSET #IDLMODE,X:<STATUS ; Idle after readout
JMP <FINISH ; Need to send header and 'DON'
; Keep the CCD idling when not reading out
IDLE
MOVE Y:<NSRI,A ; NSERIALS_READ = NSR
JCLR #SPLIT_S,X:STATUS,*+3
ASR A ; Split serials requires / 2
NOP
DO A,IDL1 ; Loop over number of pixels per line
MOVE Y:SERIAL_IDLE,R0 ; Serial transfer on pixel
CLOCK ; Go to it
MOVE #COM_BUF,R3
JSR <GET_RCV ; Check for FO or SSI commands
JCC <NO_COM ; Continue IDLE if no commands received
ENDDO
JMP <PRC_RCV ; Go process header and command
NO_COM NOP
IDL1
DO Y:<N_PARALLEL_CLEARS,PAR
MOVE Y:<PARALLEL_CLEAR,R0 ; Address of parallel clocking waveform
CLOCK ; Go clock out the CCD charge
PAR
JMP <IDLE
; ***************** Exposure and readout routines *****************
; Overall loop - transfer and read NPR lines
RDCCD
JSSET #ST_SYNC,X:STATUS,SYNCH_CONTROLLER ; Sync up two controllers
; Add user-input to built-in serial skip
MOVE Y:<NS_SKIP,X0
MOVE Y:<NSEXTENDED,A
ADD X0,A
NOP
MOVE A1,Y:<NS_SKP1 ; total number of serial pre-skips
MOVE A1,Y:<NS_SKP2 ; total number of serial post-skips
; Calculate some readout parameters
MOVE Y:<NBOXES,A ; NBOXES = 0 => full image readout
NOP
TST A
JNE <SUB_IMG
MOVE A1,Y:<NP_SKIP ; Zero these all out
MOVE Y:<NSR,A ; NSERIALS_READ = NSR
JCLR #SPLIT_S,X:STATUS,*+3
ASR A ; Split serials requires / 2
NOP
MOVE A,Y:<NSERIALS_READ ; Number of columns in each subimage
JMP <WT_CLK
; Loop over the required number of subimage boxes
SUB_IMG
MOVE #BOI_TABLE,R7 ; Parameter table for subimage readout
DO Y:<NBOXES,L_NBOXES ; Loop over number of boxes
MOVE Y:(R7)+,X0
MOVE X0,Y:<NP_SKIP
MOVE Y:(R7)+,X0
MOVE X0,Y:<NP_READ
; Start the loop for parallel shifting desired number of lines
;WT_CLK JSR <GENERATE_SERIAL_WAVEFORM
WT_CLK NOP ; not using the binning waveform generation at the moment.
JSR <WAIT_TO_FINISH_CLOCKING
; Skip over the required number of rows for subimage readout
MOVE Y:<NP_SKIP,A ; Number of rows to skip
TST A
JEQ <CLR_SR
DO Y:<NP_SKIP,L_PSKP
MOVE Y:<PARALLEL,R0 ; Couldn't this be above the start of the do loop?
CLOCK
L_PSKP
; Clear out the accumulated charge from the serial shift register
CLR_SR
DO Y:<NSCLR,L_CLRSR ; Loop over number of pixels to skip
MOVE Y:<SERIAL_SKIP,R0
CLOCK ; Go clock out the CCD charge
L_CLRSR ; Do loop restriction
; Parallel shift the image into the serial shift register
MOVE Y:<NPR,A ; Number of rows set by host computer
NOP
MOVE Y:<NBOXES,B ; NBOXES = 0 => full image readout
TST B
JEQ *+2
MOVE Y:<NP_READ,A ; If NBOXES .NE. 0 use subimage table
NOP
JCLR #SPLIT_P,X:STATUS,P_CLK
MOVE Y:<NPR,A
ASR A
NOP
; This is the main loop over each line to be read out
P_CLK DO A1,LPR ; Number of rows to read out
; Exercise the parallel clocks, including binning if needed
DO Y:<NPBIN,L_PBIN
MOVE Y:<PARALLEL,R0
CLOCK
L_PBIN
; Check for a command once per line. Only the ABORT command should be issued.
MOVE #COM_BUF,R3
JSR <GET_RCV ; Was a command received?
JCC <CONTINUE_READ ; If no, continue reading out
JMP <PRC_RCV ; If yes, go process it
; Abort the readout currently underway
ABR_RDC JCLR #ST_RDC,X:<STATUS,ABORT_EXPOSURE
ENDDO ; Properly terminate readout loop
MOVE Y:<NBOXES,A ; NBOXES = 0 => full image readout
TST A
JEQ *+2
ENDDO ; Properly terminate readout loop
JMP <ABORT_EXPOSURE
; Skip over NS_SKP1 columns for subimage readout
CONTINUE_READ
MOVE Y:<NS_SKP1,A ; Number of columns to skip
TST A
JLE <L_READ
DO Y:<NS_SKP1,L_SKP1 ; Number of waveform entries total
MOVE Y:<SERIAL_SKIP,R0 ; Waveform table starting address
CLOCK ; Go clock out the CCD charge
L_SKP1
; Finally read some real pixels
L_READ
DO Y:<NSR,L_RD
MOVE Y:<NSBIN,A
SUB #>1,A
NOP
DO A1,SER_BIN_LOOP
MOVE Y:<SERIAL_BIN,R0
CLOCK
SER_BIN_LOOP
MOVE Y:<SERIAL_READ,R0
CLOCK ; Go clock out the CCD charge
L_RD
; Skip over NS_SKP2 columns if needed for subimage readout
MOVE Y:<NS_SKP2,A ; Number of columns to skip
TST A
JLE <L_BIAS
DO Y:<NS_SKP2,L_SKP2
MOVE Y:<SERIAL_SKIP,R0 ; Waveform table starting address
CLOCK ; Go clock out the CCD charge
L_SKP2
; And read the bias pixels if in subimage readout mode
L_BIAS
MOVE Y:<NBOXES,A ; NBOXES = 0 => full image readout
TST A
JLE <END_ROW
MOVE Y:<NR_BIAS,A ; NR_BIAS = 0 => no bias pixels
TST A
JLE <END_ROW
JCLR #SPLIT_S,X:STATUS,*+3
ASR A ; Split serials require / 2
NOP
DO A1,L_BRD ; Number of pixels to read out
MOVE #PXL_TBL,R0
CLOCK ; Go clock out the CCD charg
L_BRD NOP
END_ROW NOP
LPR NOP ; End of parallel loop
L_NBOXES NOP ; End of subimage boxes loop
; Restore the controller to non-image data transfer and idling if necessary
RDC_END JCLR #IDLMODE,X:<STATUS,NO_IDL ; Don't idle after readout
MOVE #IDLE,R0
MOVE R0,X:<IDL_ADR
JMP <RDC_E
NO_IDL MOVE #NO_PAR_IDLE,R0
MOVE R0,X:<IDL_ADR
RDC_E JSR <WAIT_TO_FINISH_CLOCKING
BCLR #ST_RDC,X:<STATUS ; Set status to not reading out
JMP <START
; ****** Include many routines not directly needed for readout *******
INCLUDE "timCCDmisc.asm"
TIMBOOT_X_MEMORY EQU @LCV(L)
; **************** Setup memory tables in X: space ********************
; Define the address in P: space where the table of constants begins
IF @SCP("DOWNLOAD","HOST")
ORG X:END_COMMAND_TABLE,X:END_COMMAND_TABLE
ENDIF
IF @SCP("DOWNLOAD","ROM")
ORG X:END_COMMAND_TABLE,P:
ENDIF
; Application commands
DC 'PON',POWER_ON
DC 'POF',POWER_OFF
DC 'SBV',SET_BIAS_VOLTAGES
DC 'IDL',START_IDLE_CLOCKING
DC 'OSH',OPEN_SHUTTER
DC 'CSH',CLOSE_SHUTTER
DC 'RDC',RDCCD ; Begin CCD readout
DC 'CLR',CLEAR ; Fast clear the CCD
; Exposure and readout control routines
DC 'SET',SET_EXPOSURE_TIME
DC 'RET',READ_EXPOSURE_TIME
; DC 'SEX',START_EXPOSURE
DC 'PEX',PAUSE_EXPOSURE
DC 'REX',RESUME_EXPOSURE
DC 'AEX',ABORT_EXPOSURE
DC 'ABR',ABR_RDC
DC 'CRD',CONTINUE_READ
DC 'WSI',SYNTHETIC_IMAGE
DC 'SSM',SET_SYNC_MODE
; DC 'STR',STR_RDC
; New commands for NGPS
DC 'SRE',START_READOUT
DC 'FRT',FRAME_TRANSFER
DC 'SPC',STOP_PARALLEL_CLOCKING
DC 'SBP',SET_BIN_PARAMETERS
DC 'GEO',GEOMETRY_PARAMETERS
DC 'BOI',BAND_OF_INTEREST
; Support routines
DC 'SGN',ST_GAIN
DC 'SBN',SET_BIAS_NUMBER
DC 'SMX',SET_MUX
DC 'CSW',CLR_SWS
DC 'SOS',SELECT_OUTPUT_SOURCE
DC 'SSS',SET_SUBARRAY_SIZES
DC 'RCC',READ_CONTROLLER_CONFIGURATION
DC 'RAW',RAW_COMMAND ; So I can set voltages as I please
DC 'ERS',ERASE ;Persistent image erase
DC 'EPG',EPURGE ; E-Purge procedure
DC 'TAD',TEST_AD
DC 'CID',CHANGE_IDLE_DIRECTION
DC 'CIR',CHANGE_IDLE_READ_DIRECTION
DC 'CPC',CHANGE_NUMBER_PARALLEL_CLEARS
DC 'NPS',NO_POLARITY_SHIFT
DC 'CFS',CLR_FS
; DC 'CVS',CHANGE_VSUB
; DC 'FSC',FRAME_STORE_CLEAR
DC 'PCK',POWER_CHECK
END_APPLICATION_COMMAND_TABLE EQU @LCV(L)
IF @SCP("DOWNLOAD","HOST")
NUM_COM EQU (@LCV(R)-COM_TBL_R)/2 ; Number of boot +
; application commands
EXPOSING EQU CHK_TIM ; Address if exposing
CONTINUE_READING EQU CONT_RD ; Address if reading out
ENDIF
IF @SCP("DOWNLOAD","ROM")
ORG Y:0,P:
ENDIF
; Now let's go for the timing waveform tables
IF @SCP("DOWNLOAD","HOST")
ORG Y:0,Y:0
ENDIF
GAIN DC END_APPLICATON_Y_MEMORY-@LCV(L)-1
NSR DC 4200 ; Number Serial Read, prescan + image + bias
NPR DC 2100 ; Number Parallel Read
NSCLR DC NS_CLR ; To clear the serial register
NPCLR DC NP_CLR ; To clear the parallel register
NSBIN DC 1 ; Serial binning parameter
NPBIN DC 1 ; Parallel binning parameter
NPFS DC NP_FS ; number of rows in frame store area
SHDEL DC SH_DEL ; Delay in milliseconds between shutter closing
; and image readout
CONFIG DC CC ; Controller configuration
NSERIALS_READ DC 4200 ; Number of serials to read
; Waveform parameters
OS DC '__2' ; Output source
FIRST_CLOCKS DC 0 ; Address of first clocks waveforms
CLOCK_LINE DC 0 ; Clock one complete line of charge
; Readout peculiarity parameters. Default values are selected here.
SERIAL_READ DC SERIAL_READ_SPLIT ;14 ; Serial readout waveforms
SERIAL_SKIP DC SERIAL_SKIP_SPLIT ;15 ; Serial skipping waveforms
PARALLEL DC PARALLEL_2 ;16 ; Parallel shifting waveforms
PARALLEL_CLEAR DC PARALLEL_CLEAR_2 ;17
FS_CLEAR DC FS_CLEAR_2 ;18 Frame Store clearing waveforms
PC_1 DC PARALLEL_CLEAR_1 ;19
PC_2 DC PARALLEL_CLEAR_2 ;20
SERIAL_IDLE DC SERIAL_IDLE_SPLIT ;21
SI_L DC SERIAL_IDLE_LEFT ;22
SI_R DC SERIAL_IDLE_RIGHT ;23
BYTE_1 DC 0 ;24
BYTE_2 DC 0 ;25
SR_L DC SERIAL_READ_LEFT ;26
SR_R DC SERIAL_READ_RIGHT ;27
P_1 DC PARALLEL_1 ;28
P_2 DC PARALLEL_2 ;29
N_PARALLEL_CLEARS DC 1 ;30
SR_S DC SERIAL_READ_SPLIT ;31
TMP_1 DC TMP_PXL_TBL1 ;32 stuff where I can load a idle without resetting.
TMP_2 DC TMP_PXL_TBL2 ;33
TMP_3 DC TMP_PXL_TBL3 ;34
PC_S DC PARALLEL_CLEAR_SPLIT ;35
NSRI DC 4200
IN_FT DC 0 ; 37 (0x25) InFrameTransfer: 0=no, 1=yes, 2=pending
PARALLEL_FT DC PARALLEL_FRAME_1 ; 38 (0x26) parallel frame transfer waveform
NSERIAL_BIN DC 1 ; 0x27
SERIAL_BIN DC SERIAL_BIN_SPLIT
INT_TIME DC 0 ; 0x29
TIME1 DC 0
TIME2 DC 0
; These three parameters are read from the BOI_TABLE when needed by the
; RDCCD routine as it loops through the required number of boxes
NP_SKIP DC 0 ; user-selected number of rows to skip 0x2c
NS_SKIP DC 0 ; user-selected number of cols to skip
NS_SKP1 DC 0 ; Number of serials to clear before read
NS_SKP2 DC 0 ; Number of serials to clear after read
NPBIAS DC 0 ; number of parallel bias (overscan) pixels
NSBIAS DC 0 ; number of serial bias (overscan) pixels
NSEXTENDED DC 7 ; built-in number of serial extended pixels
; Subimage readout parameters. Ten subimage boxes maximum.
NBOXES DC 0 ; Number of boxes to read 30
NR_BIAS DC 0 ; Number of bias pixels to read 31
NS_READ DC 0 ; Number of columns in subimage read 32
NP_READ DC 0 ; Number of rows in subimage read 33
BOI_TABLE DC 0,0 ; #1=rows_to_skip, #2=rows_to_read 34,35
; Include the waveform table for the designated type of CCD
INCLUDE "WAVEFORM_FILE" ; Readout and clocking waveform file
ORG Y:@LCV(L)+50,Y:@LCV(L)+50
TMP_PXL_TBL1 DC 0
ORG Y:@LCV(L)+50,Y:@LCV(L)+50
TMP_PXL_TBL2 DC 0
ORG Y:@LCV(L)+50,Y:@LCV(L)+50
TMP_PXL_TBL3 DC 0
END_APPLICATON_Y_MEMORY EQU @LCV(L)
; End of program
END