Shop OBEX P1 Docs P2 Docs Learn Events
Assembly CTRA — Parallax Forums

Assembly CTRA

velocityxlrgvelocityxlrg Posts: 18
edited 2015-03-11 11:53 in Propeller 1
I have used counters in assembly cogs successfully, but why do all the examples have the waitcnt before the neg phsa in the loop?
... get stuff ready

loop   waitcnt   Timer, DelayTime
       neg       PHSA,  pwmHigh
       jmp       #loop


I was just wondering why you wouldn't set PHSA negative first, and then wait.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2015-03-11 10:10
    You could do that. Ideally, you would like to put the NEG as close as possible to the WAITCNT since you're using the WAITCNT completion as the synchronization point for the pulse generation. If the NEG were first, you'd have a JMP between the WAITCNT and the next NEG which adds 4 clock times' delay from the synchronization point to the next pulse. You can compensate for that in your initialization if you care for that sort of precision. It might be important if you're generating several different synchronized signals in different cogs.
  • velocityxlrgvelocityxlrg Posts: 18
    edited 2015-03-11 11:53
    Okay, thanks. That makes sense.
Sign In or Register to comment.