PASM waitpeq not working as expected
in Propeller 1
The code gates one pin of 500Hz oscillation with another pin (high/low).
The SPIN code works with `waitpeq(|<TRIG1, |<TRIG1, 0)`.
However the PASM code doesn't. T_PIN stays high, even though R_PIN changes.
Comment out `waitpeq R_PIN, R_PIN` makes T_PIN toggles at 500Hz.
The SPIN code works with `waitpeq(|<TRIG1, |<TRIG1, 0)`.
However the PASM code doesn't. T_PIN stays high, even though R_PIN changes.
Comment out `waitpeq R_PIN, R_PIN` makes T_PIN toggles at 500Hz.
CON
_clkmode = xtal1 + pll16x ' Crystal and PLL settings.
_xinfreq = 5_000_000 ' 5 MHz crystal (5 MHz x 16 = 80 MHz).
CON
TRIG1 = 20
PUB main
cognew(@T1,0)
dira[22]~~
repeat
waitpeq(|<TRIG1, |<TRIG1, 0)
outa[22] := 0
waitcnt(clkfreq/1000 + cnt)
outa[22] := 1
waitcnt(clkfreq/1000 + cnt)
DAT
org
T1
'SET AS OUPUT
OR dira, T_PIN
mov time, cnt
add time, delay_t
loop
waitpeq R_PIN, R_PIN
or outa, T_PIN
waitcnt time, delay_t
andn outa, T_PIN
waitcnt time, delay_t
jmp #loop
R_PIN long |< 20
T_PIN long |< 21
delay_t long 1_000
time res 1

Comments
mov time, cnt add time, delay_tafter the or outa,T_Pin.
-Phil
The CNT increment in the Spin loop is 2 * 80MHz/1000 == 160K, but the CNT increment in PASM is only 2 * 1000 = 2K,
Change delay_t to long 80000.
Thanks Phil. I fell into the WAITCNT trap. You saved me there.