{Project Apollo Injector Control Program} CON _clkmode = xtal1 + pll16x 'Standard clock mode * crystal frequency = 80 MHz _xinfreq = 5_000_000 PUB Main cognew(@Output, 0) cognew(@Cycle, 0) DAT org 0 Output mov dira, #$7 mov inputs, #$FF and inputs, ina sar inputs, #3 cmp zClear, zero wz cmp inputs, #$3 wz if_z mov injector, #$1 if_z jmp #Shift 'cmp zClear, zero wz 'Adding these commented out lines of code causes the program to act weird 'cmp inputs, #$1 wz ' 'if_z shl injector, #1 ' 'if_z jmp #Shift ' jmp #Output Shift mov save, injector 'injector input value mov iterA, #0 Loop mov mask, #$1 and mask, save xor outa, mask xor outa, #$2 nop xor outa, #$2 and outa, #$0 sar save, #1 add iterA, #1 cmp zClear, zero wz cmp iterA, #8 wz if_z jmp #Latch jmp #Loop Latch xor outa, #$4 nop xor outa, #$4 jmp #Output '''''''''''''''''''''''''''''''''''''''''''''''''''''''' org 0 Cycle mov dira, Pin mov iter, #0 Start xor outa, Pin mov Time, cnt add Time, Pulse waitcnt Time, Pulse xor outa, Pin mov Time, cnt add Time, Delay waitcnt Time, Delay add iter, #1 LoopA xor outa, #$8 mov Time, cnt add Time, Pulse waitcnt Time, Pulse xor outa, #$8 mov Time, cnt add Time, Delay waitcnt Time, Delay add iter, #1 cmp iter, #8 wz if_z jmp #Cycle jmp #LoopA Pin long $18 Pulse long 300 'Pulsewidth ~ Pulse*12.5 Delay long 180_000 'Delay between pulses ~ Delay*12.5 zClear long $FFFF_FFFF zero long $0000_0000 injector long 0 inputs res 1 iter res 1 Time res 1 iterA res 1 save res 1 mask res 1