View Full Version : waitcnt?
Why is it necessary to add 9 to Time when using waitcnt for a delay:
mov Time, cnt
add Time, #9
:loop waitcnt Time, Delay
I can't find an explanation in the Manual.
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
01-09-2008, 05:15 AM
Because the addition of delay to time by waitcnt doesn't occur until after the wait occurs, so you need to compute the first delay before entering the waitcnt (unless you want to wait nearly a minute).
Paul Baker (mailto:firstname.lastname@example.org)
Propeller Applications Engineer
Parallax, Inc. (http://www.parallax.com)
01-09-2008, 05:49 AM
see also deSilva's posting near the end http://forums.parallax.com/showthread.php?p=699845
01-09-2008, 05:56 AM
Thanks to Google I could also find an instructive example I posted some months ago (to a certain "Aempirei"), showing the working of the "instruction pipe"
This is something Mike addressed:
mov Time, CNT 'Calculate delay time
add Time, #9 'Set minimum delay here
waitcnt Time, Delay 'Wait
xor OUTA, Pin
Does #9 suffice?
Yes, in fact this is the case whithout any "wait" at all (5 ticks of WAITCNT only)!
Tick GetInstr empty GetDest GetSrc Operate StoreBack
+1 ADD ---
+2 --- Time
+5 WAITCNT add
+6 --- Time
+9 Wait Time
+15 OUTA -> Strope detectable
I am sure aempirei ("nomen est omen") checked this out http://forums.parallax.com/images/smilies/smile.gif