Forum Rule: Always post complete source code & details to reproduce any issue!
Page 8 of 8 FirstFirst ... 6 7 8
Results 176 to 189 of 189

Thread: TeensyTimerTool

  1. #176
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    935
    So that you can #define the YIELD_TYPE before you include the library.
    This pattern only works if you can make sure that all translation units have the define before including the header. The TeensyTimerTool supports project scope config files instead. See here https://github.com/luni64/TeensyTime.../Configuration for instructions

  2. #177
    Member
    Join Date
    Apr 2020
    Location
    Germany, NRW
    Posts
    70
    Ok, thanks, i will have a look.

  3. #178
    Member
    Join Date
    Jan 2015
    Location
    France
    Posts
    78
    Quote Originally Posted by luni View Post
    This is due to the new yield code in the beta. I'll fix that the next days. If you need an urgent solution and if you do not need SerialEvents or the EventResponder you can set the yield type to YIELD_OPTIMIZED. See here: https://github.com/luni64/TeensyTime...yield-settings for instructions.
    Thank you.
    I'm not in hurry with this. It was just a feedback.
    Manu

  4. #179
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    935
    Fixed by using the EventResponder to tick the software timers in YIELD_STANDARD mode. This is slightly less efficient than the old version but there always is YIELD_OPTIMIZED mode if you need high efficiency of the software timers. (See here https://forum.pjrc.com/threads/60333...l=1#post243706 for an explanation of the new yield strategy)

    @Manu: would be great if you could give it a quick try (v0.1.10)

  5. #180
    Member
    Join Date
    Jan 2015
    Location
    France
    Posts
    78
    Hello Luni,

    Thank you for this quick fix. I just downloaded the last release (v0.1.10) and it compile without error. Unfortunately my last project which use Teensy 4.x is at it very beginning and, while I know I'll use TeensyTimerTool, I haven't any current code which use it.
    Anyway, I tested the new release with a teensy 3.2 project and it operate very well.

    Thank you,
    Manu

  6. #181
    @luni:
    What is correct way if I want to stop timer for time being?

    Code:
      myTimer.begin(TimerFunction,10'000); // 10ms
    This used to init timer.

    I tried this to stop this timer but not working out. what is correct way to stop this timer?
    Code:
    myTimer.end(); //Timer Ends here.

  7. #182
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,884
    I have not played with this for awhile, but my guess would be to do: myTimer.stop();

    Which is defined in baseTimer... But again just a guess.

  8. #183
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    935
    Which is defined in baseTimer... But again just a guess.
    Valid guess, but actually this currently is only implemented for the TCK timers. The others silently ignore it. I'm currently working on filling in some missing functionality... As a workaround you can meanwhile simply call begin with a nullpointer as callback. This will effectively stop the timer.

  9. #184
    Quote Originally Posted by luni View Post
    Valid guess, but actually this currently is only implemented for the TCK timers. The others silently ignore it. I'm currently working on filling in some missing functionality... As a workaround you can meanwhile simply call begin with a nullpointer as callback. This will effectively stop the timer.
    Thanks luni,
    Code:
    myTimer.begin([]{int (*pfun) (void) = NULL;},10'000); // 10ms
    worked out.

  10. #185
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    935
    Yes that works, but your code is a bit complicated. You probably noticed that passing a nullptr as function argument compiles but doesn't work since the library catches this as error. So, instead of passing a nullptr you need to pass an empty function:

    Code:
    #include "TeensyTimerTool.h"
    using namespace TeensyTimerTool;
    
    void empty() {}  // empty function
    
    PeriodicTimer t1;
    
    void setup()
    {
        pinMode(13, OUTPUT);
    
        t1.begin([] { digitalWriteFast(13, !digitalReadFast(13)); }, 75'000); //Blink
        delay(3000);
        t1.begin(empty, 50'000); //stop timer
    }
    
    void loop()
    {
    }
    Or if you prefer lambdas you can define the empty function inline:

    Code:
    #include "TeensyTimerTool.h"
    using namespace TeensyTimerTool;
    
    PeriodicTimer t1;
    
    void setup()
    {
        pinMode(13, OUTPUT);
    
        t1.begin([] { digitalWriteFast(13, !digitalReadFast(13)); }, 75'000); //Blink
        delay(3000);
        t1.begin([]{}, 50'000); //stop timer
    }
    
    void loop(){}

  11. #186
    Yes,
    I tried with empty function as well. That code I shared also worked. Got it I think the one you suggested looks better.

  12. #187
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    935
    Quote Originally Posted by HallMark View Post
    @luni:
    What is correct way if I want to stop timer for time being?
    ...
    I just added the missing start/stop functionality for the TCK, TMR(QUAD), GPT and PIT timers to the TeensyTimerTool v0.1.11. See here for details and download https://github.com/luni64/TeensyTimerTool/releases

    Quick usage example:
    Code:
    #include "TeensyTimerTool.h"
    using namespace TeensyTimerTool;
    
    PeriodicTimer t1;
    
    void setup()
    {
        while (!Serial) {}
        TeensyTimerTool::attachErrFunc(ErrorHandler(Serial)); // optional, print errors on Serial
        pinMode(13, OUTPUT);
    
        t1.begin([] { digitalToggleFast(13); }, 50'000); //Blink
    
        delay(2000);  // stop timer after 2s
        t1.stop();
    
        delay(2000);  // restart after 2s
        t1.start();
    }
    
    void loop()
    {
    }
    Now working on a possibility to chain the TMR timers to get 16 / 32 / 48 and 64 bit wide timers.

  13. #188
    Quote Originally Posted by luni View Post
    I just added the missing start/stop functionality for the TCK, TMR(QUAD), GPT and PIT timers to the TeensyTimerTool v0.1.11. See here for details and download https://github.com/luni64/TeensyTimerTool/releases
    Great ! I just realize I am using too old version for this lib. I am using 0.1.7 version. Updating now and going to test this out.

  14. #189
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    935
    IIRC you are using the FTM timers. Forgot to add them in v0.1.11, just pushed v0.1.12 which should work for the FTMs as well

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •