Shop OBEX P1 Docs P2 Docs Learn Events
waitcnt? — Parallax Forums

waitcnt?

LeonLeon Posts: 7,620
edited 2008-01-08 21:56 in Propeller 1
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.

Leon

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-01-08 21:15
    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
    Propeller Applications Engineer

    Parallax, Inc.
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-08 21:49
    see also deSilva's posting near the end http://forums.parallax.com/showthread.php?p=699845
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-08 21:56
    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"
    deSilva said...
    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
    -3     MOV
    -2                ---
    -1                      Time
    0                                CNT
    +1     ADD                                ---
    +2                ---                              Time
    +3                      Time
    +4                               #9
    +5     WAITCNT                            add
    +6                ---                              Time
    +7                      Time
    +8                               Delay
    +9                                        Wait     Time
    +10    XOR
    +11               ---
    +12                     OUTA
    +13                             Pin
    +14                                       xor
    +15                                               OUTA   -> Strope detectable
    


    I am sure aempirei ("nomen est omen") checked this out smile.gif
Sign In or Register to comment.