beautypg.com

Step 5: service the interrupt – Ocean Optics PC2000-PC_104 User Manual

Page 14

background image

PC2000-PC/104 Data Sheet

outport_byte(port,cmd)

set command to PC2000-PC104

cmd = cmd | 0x41

enable interrupts and triggers

if external software triggering then
while inport_byte(baseadd + 5) & 8)
== 0 wait on this line

if you are external triggering, constantly query the
digital input on pin 26 of the 26 pin connector to check
for it to go high (+5VDC)

CheckTriggerMode()

check the external trigger mode

if not scanning a dark spectrum or
using external triggering then
cmd = cmd | 2

if you are scanning a dark spectrum or using an external
trigger mode do not turn on the flash

outport_byte(port,cmd)

set command to PC2000-PC104

This function does a lot. First, it identifies the PC2000-PC104 control port as baseadd + 4. It then
clears the MUX address of the A/D, sets the MUX address of the A/D, turns off the flash-during-scan,
resets the FIFO buffer, cancels the FIFO reset, enables the triggers and interrupt (this is VERY
IMPORTANT, as it is
what makes it all work), and waits for an external software trigger on pin 8
of the DSUB15 connector, if requested. The function then triggers a scan.

Step 5: Service the Interrupt

When a scan is completed, your program is notified by an interrupt. You MUST service this interrupt
IMMEDIATELY. The interrupt service routine (ISR) must be as short as possible. Do as little
processing as possible in the ISR. The following is our ISR.

cmd = cmd & 0xbe

turn interrupts and triggers off

CheckTriggerMode()

check the external trigger mode

outport_byte(baseadd + 4,cmd)

stop the acquisition

enable()

restart interrupts

for i = 0 to 2047
indata(i) = (inport_word(baseadd + 6)
^ 0x0800) & 0x0fff
next i

read 2048 data points from the FIFO buffer, convert to
unsigned values and mask off upper 4 bits (0-4095
value)

cmd = cmd & 0xbe

turn interrupts and triggers off

cmd = cmd | 0x20

reset the A/D cards FIFO

CheckTriggerMode()

check the external trigger mode

outport_byte(baseadd + 4,cmd)

issue the command

cmd = cmd & 0xdf

cancel the reset

CheckTriggerMode()

check the external trigger mode

outport_byte(baseadd + 4,cmd)

issue the command

outport_byte(0x20,0x20)

send a non-specific EOI (end of interrupt) to the 8259
interrupt controller chip

14

000-00000-000-05-0704