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


  • 3 Comments sorted by Date Added Votes
  • 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: 5,665
    edited March 17 Vote Up0Vote Down
    SMH. I should have known that. Thanks!
    Jon McPhalen
Sign In or Register to comment.