-
Notifications
You must be signed in to change notification settings - Fork 0
/
strobeTest2.spin
52 lines (41 loc) · 985 Bytes
/
strobeTest2.spin
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
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000 ' External oscillator = 5 MHz
OBJ
qsb: "Quickstart Buttons"
PUB strobeTest2 | pulseLength, hz, waitTime, nextTime
dira[12..13]~~
qsb.start
ctra[30..26]:=%00100
ctrb[30..26]:=%00100
ctra[5..0]:=12
ctrb[5..0]:=13
frqa:=1
frqb:=1
pulseLength:=clkfreq>>10
hz:=1
waitTime:=clkfreq
nextTime:=waitTime+cnt
repeat
phsa:=-pulseLength
phsb:=-pulseLength
if qsb.testAndClear(1<<7)
hz+=1
waitTime:=clkfreq/hz
if qsb.testAndClear(1<<6)
hz-=1
waitTime:=clkfreq/hz
if qsb.testAndClear(1<<5)
waitTime-=800_000
if qsb.testAndClear(1<<4)
waitTime+=800_000
if qsb.testAndClear(1<<3)
waitTime-=80_000
if qsb.testAndClear(1<<2)
waitTime+=80_000
if qsb.testAndClear(1<<1)
pulseLength<<=1
if qsb.testAndClear(1<<0)
pulseLength>>=1
waitcnt(nextTime)
nextTime:=waitTime+nextTime