Shop OBEX P1 Docs P2 Docs Learn Events
__builtin_propeller_waitcnt() — Parallax Forums

__builtin_propeller_waitcnt()

What is the purpose of param1 in __builtin_propeller_waitcnt(target, param1)?

Comments

  • It is the equivalent of waitcnt target, param1 in pasm.
    To get the same functionality, you need to use the return value of __builtin_propeller_waitcnt which is target+param1, since In C parameters are passed by value so any modification is local to the function.

    See also the waitcnt and waitcnt2 helper functions.
  • JonnyMac wrote: »
    What is the purpose of param1 in __builtin_propeller_waitcnt(target, param1)?

    It's used to update the target time for the next waitcnt:
      targetCnt = CNT + freq; // set up initial interval
      do {
          // do something useful that takes less than "freq" cycles
          ...
          // now sleep until interval is finished
          targetCnt = __builtin_propeller_waitcnt(targetCnt, freq);
          // targetCnt has been updated to the next CNT to wait for
       } while (condition);
    
  • JonnyMacJonnyMac Posts: 8,926
    edited 2017-03-17 22:24
    SMH. I should have known that. Thanks!
Sign In or Register to comment.