Appendix C
Sample Programs
© National Instruments Corporation
C-15
GPIB-1014 User Manual
|
68000 Code
| Comments
--------------------------------------------------------------------------------------------------------------------------------------------
|
DSEND:
movb
#TMODE,DCR0
| Set DMA transfer mode
movb
#TMODE,DCR1
|
|
movb
#MTG,OCR0
| Set control registers
movb
#MCU,SCR0
|
|
movb
#FF,CSR0
| Clear status registers
movb
#FF,CSR1
|
|
movl
a0,MAR0
| Point channel 0 to buffer
tstb
vseoi
| Send END with last byte?
beq
DSEND1
|
|
| Yes, enable carry cycle feature
|
movb
#MTG+ACHN,OCR1
| - Enable chaining on channel 1
|
movw
d0,d1
|
- Channel 0 transfer all but the
subw
#1,d1
|
last data byte
movw
d1,MTC0
|
|
movl
#ccary,BAR1
|
- Point channel 1 to ccary
|
movw
#2,BTC1
|
- 2 elements in ccary
|
movl
#SEOI,ccary
| - First ccary address points to SEOI
|
movl
a0,d2
|
- Second ccary address points to last
addl
d2,d1
|
data byte
movl
d1,ccary+6
|
|
movb
#BRG+ECC+OUT,CFG1 | - Set CFG2 for carry cycle
movb
#G0,CCR1
| - Start channel 1
bra
DSEND2
|
|
|
DSEND1: movb
#BRG+OUT,CFG2
| No--Configure CFG2 without ECC
|
movw
#d0,MTC0
| Channel 0 transfers all bytes
|
DSEND2:
movb
#GO,CCR0
| Start channel 0
|
movb
#DMAO,IMR2
| Enable DMA to the CDOR
|
DSEND3:
btst
#PCT,CSR1
| Loop waiting for GPIB error or DMA done
bne
DSEND4
|
btst
#ERR,ISR1
|
beq
DSEND3
|
movw
#-1,d0
| Set count to -1 if error occurred
bra
DSEND6
|
|