waitpne/waitpeq issue
JazzD
Posts: 13
this is probably pretty easy but i havent found a solution yet: I'm measuring a frequency by sampling, just like the object that you find in the obex.
the method is pretty simple and uses WAITPNE to get the positive edge of the flank and WAITPEQ to get the negative. now if there is NO change in voltage/no signal on the pin it will simply block. What would be a simply way of getting a timeout into this assembler piece?
the method is pretty simple and uses WAITPNE to get the positive edge of the flank and WAITPEQ to get the negative. now if there is NO change in voltage/no signal on the pin it will simply block. What would be a simply way of getting a timeout into this assembler piece?
detector :mainloop MOV :t1, par ' get buffer pointer MOV :lock, :t1 ' set lock pointer ADD :t1, #4 ' offset for lock WRLONG :one, :lock ' assert waiting state :wait RDLONG :t2, :lock TJNZ :t2, #:wait ' wait for clear RDLONG [img]http://forums.parallax.com/images/smilies/tongue.gif[/img]in, :t1 ' set pin mask ADD :t1, #4 ' offset for pin mask MOV :ctr, #SAMPLESIZE ' set counter :loop WAITPNE :zero, [img]http://forums.parallax.com/images/smilies/tongue.gif[/img]in ' wait for pos edge WAITPEQ :zero, [img]http://forums.parallax.com/images/smilies/tongue.gif[/img]in ' wait for neg edge (pulse) MOV :t2, cnt ' capture time WRLONG :t2, :t1 ADD :t1, #4 ' next buffer position DJNZ :ctr, #:loop ' capture loop JMP #:mainloop ' main loop
Comments