#define REDDDS 0 #define BLUEDDS 1 #define IRDIGOUT 7 #define IRON 8 #define IROFF 0 var F_blueon 231 var A_blueon 60 var ZERO 0 var memstart 3900 var memend 4000 var mempointer 0 # Number of memory bins to fill var databins 100 var bincounter 0 # Timing information. Remarks: # - Each phase is countloop*ms_counttime long # - Modify 'countloop', not 'ms_counttime'! var ms_counttime 1 #var countloop 1 var countpointer 0 # Internal register var datacounts 0 function main() { DIGOUT IRDIGOUT, IRON LDWR memstart STWR mempointer # zero the memory zloop: LDINDF mempointer LDWR ZERO STWI # stores data to wherever INDF is pointing INC mempointer STWR mempointer (CMP memend) ? NOP : JMP zloop #------------------------------------------------------------ # IR STROBE SEQUENCE: # Fill 50 pairs of (IRon,IRoff) PMT counts #------------------------------------------------------------ # Reinitialize memory pointer LDWR memstart STWR mempointer LDWR databins # Total number of cycles STWR bincounter # Index variable DIGOUT IRDIGOUT, IROFF DDSFRQ BLUEDDS, ZERO DDSAMP BLUEDDS, ZERO # loop: Single cycle of IR strobe (on, then off) # Note the use of two memory locations per cycle loop: NOP #---------------------------------------- # SHUTTER ON PHASE #---------------------------------------- DIGOUT IRDIGOUT, IRON DDSFRQ BLUEDDS, F_blueon DDSAMP BLUEDDS, A_blueon # 1) Load current memory location 'mempointer' into INDF reg # 2) Load existing PMT counts into 'datacounts'. # (At the beginning, 'datacounts'==0) LDINDF mempointer LDWI STWR datacounts # Initialize 'countpointer' indexing variable LDWR countloop STWR countpointer # loop1: Count PMT 'countloop' times of 'ms_counttime' intervals loop1: COUNT ms_counttime # Store count results in W ADDW datacounts # W = W(newcounts) + datacounts(old) STWR datacounts # datacounts = W STWI # Write W into location of 'mempointer' DEC countpointer STWR countpointer JMPNZ loop1 INC mempointer # Done with current mem location ("bin") STWR mempointer DEC bincounter # Tick off one bin STWR bincounter #---------------------------------------- # SHUTTER OFF PHASE #---------------------------------------- DIGOUT IRDIGOUT, IROFF DDSFRQ BLUEDDS, ZERO DDSAMP BLUEDDS, ZERO LDINDF mempointer LDWI STWR datacounts LDWR countloop STWR countpointer loop2: COUNT ms_counttime ADDW datacounts STWR datacounts STWI DEC countpointer STWR countpointer JMPNZ loop2 INC mempointer STWR mempointer DEC bincounter STWR bincounter JMPNZ loop # Repeat cycle if there are bins remaining # switch the laser to the setup frequency and amplitude DIGOUT IRDIGOUT, IRON DDSFRQ BLUEDDS, F_blueon DDSAMP BLUEDDS, A_blueon }