Advertisement
Guest User

Untitled

a guest
Aug 17th, 2022
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.34 KB | None | 0 0
  1. // interval of calling do_stuff() in pru cycles
  2. #define INTERVAL 20000000
  3.  
  4. // make sure do_stuff() never takes more than INTERVAL cycles!
  5. void do_stuff() {
  6.     //...
  7. }
  8.  
  9. int main() {
  10.     timestamp_initialize();
  11.  
  12.     uint32_t next = timestamp();
  13.     for(;;) {
  14.         next += INTERVAL;
  15.         do_stuff();
  16.         while( (int)( timestamp() - next ) < 0 ) {}
  17.     }
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement