Page 174 - Build Your Own Quadcopter_ Power Up Your Designs with the Parallax Elev-8
P. 174
Chapter 6: Radio-Controlled Systems and Telemetr y 153
rdlong tmp2, tmp1 ‘ get pin#
mov ctra, POS_DETECT ‘ ctra measures
phase
add ctra, tmp2
mov frqa, #1
mov ctrb, NEG_DETECT ‘ ctrb measures
phase
add ctrb, tmp2
mov frqb, #1
mov mask, #1 ‘ create pin
mask
shl mask, tmp2
andn dira, mask ‘ input in this
cog
add tmp1, #4
mov cyclepntr, tmp1 ‘ save address
of hub storage
restart waitpne mask, mask ‘ wait for 0
phase
mov phsa, #0 ‘ clear high
phase counter
highphase waitpeq mask, mask ‘ wait for pin
== 1
mov phsb, #0 ‘ clear low
phase counter
lowphase waitpne mask, mask ‘ wait for pin
== 0
mov cycles, phsa ‘ capture high
phase cycles
endcycle waitpeq mask, mask ‘ let low phase
finish
add cycles, phsb ‘ add low phase
cycles
wrlong cycles, cyclepntr ‘ update hub
jmp #restart
POS_DETECT long %01000 << 26