waitpeq/waitpne help please
Hi, can you help me please?
Why waitpeq don't work?
Function: waiting 0 -> 1 -> 0 on P6.
Very thanks, Lafet
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
in_pin = 6
VAR
long Index
PUB start
Index := 0
dira[noparse][[/noparse]20]~~
outa[noparse][[/noparse]20]~
coginit(6,@entry, @index)
repeat
DAT
ORG 0
entry
:det_pulse
mov _count, #6
mov _tmp_count, _count
jmp #:det_pulse_loop
:det_pulse_cnt
cmp _tmp_count, #6 wz
if_z mov _count, #7
if_nz mov _count, #6
mov _tmp_count, _count
:det_pulse_loop
waitpeq _null, #in_pin
waitpne _null, #in_pin
djnz _count, #:det_pulse_loop
rdbyte _temp, par
add _temp, #1
cmpsub _temp, #6
wrbyte _temp, par
jmp #:det_pulse_cnt
_null long 0
_temp res 1
_count res 1
_tmp_count res 1
Why waitpeq don't work?
Function: waiting 0 -> 1 -> 0 on P6.
Very thanks, Lafet

Comments
When using I/O #6 you can still use immediate addressing #%100_0000 or - better! - # |<in_pin
...don't work
Post Edited (Lafet) : 10/24/2007 10:10:50 PM GMT
You need a register in the destination field ...
Alas, it is possible to write things like:
although it will make little sense to the human reader, except he is very unexperienced with the SPIN assembly language
For the assembler this is the clear instruction to use the mask stored at address number 64 of the COG - why not?
A VERY GOOD assembler would issue a
"WARNING: Unrecommended and most likely erronious use of bit-literal as register number!"
What do we learn from this? Don't use I/O pins below number 9
Post Edited (deSilva) : 10/24/2007 11:22:11 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter
tdswieter.com
One little spark of imagination is all it takes for an idea to explode
This is the real reason why it won't even work with the latest try - and hippy and me would have been very, very surprised
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter
tdswieter.com
One little spark of imagination is all it takes for an idea to explode
entry mov det_pin, #1 shl det_pin, #6 andn dira, det_pin :det_pulse ... :det_pulse_loop waitpeq det_pin, det_pin waitpne det_pin, det_pin djnz _count, #:det_pulse_loop ... det_pin long 0 _tmp_count res 1Hardware connected to wrong pin ?
Signal not toggling ?
Signal toggling too fast ?
Incorrect signal voltages ?
_count not initialised correctly ?
That code not being executed ?
Other code error ?
Error in your data definitions ( res before long or before code ) ?
one mov _temp, ina and _temp, det_pin wz if_z jmp #one null mov _temp, ina and _temp, det_pin wz if_nz jmp #nulland this way it works OK.
(a) You are now waiting the other way round 0->1 rather than 1-> 0 in your first postings
(b) You do not need the _temp
one and det_pin, INA wz,NR if_z jmp #one null and det_pin, INA wz,NR if_nz jmp #null(b) But why didn't this work?
waitpeq det_pin, det_pin waitpne det_pin, det_pinone mov _temp, ina and _temp, det_pin wz if_z jmp #one null mov _temp, ina and _temp, det_pin wz if_nz jmp #nullApparently doesn't work ...
waitpeq det_pin, det_pin waitpne det_pin, det_pinI have to admit that I cannot see the difference.
In the first case the 'one' loop is only left when ( INA & det_pin ) <> 0 and the 'null' loop is only left when ( INA & det_pin ) == 0. So it waits firstly for pin high then pin low.
I do not see any difference to how the waitpeq/waitpne proceeds - waits for pin high then waits for pin low, so I'm at a loss to explain why the first works but the second does not.
There must be something else going on that you can't see from these fragments.
Are you literally substituting one for the other?
Both will wait for 1 -> 0
Sorry for having been slop(p)y!
Edit:
But I was a little bit confused as the very first solution was this:
I have to look it up from time to time, "who is who":
its:
WAITP value, mask.
So this (reported: not working) example looked for 0 -> 1
Then it became a little bit confused... In fact DIRA wil have nothing to do with it, as input is default and - contrary to my former posting - this had no influence on it.....
Remains the last riddle: Two obviously equivalent programs behave differently...
Post Edited (deSilva) : 10/27/2007 1:23:31 PM GMT
There has to be something else which is not being revealed. My gut suspicion is that the "waitpeq/waitpne" is not in the same order used in the code test.