Timer Library for Arduino DUE

Hi! As i like libraries, i have done one for Timers on the Arduino DUE.

You can check it out here: https://github.com/ivanseidel/DueTimer

All 6 9 timers are fully implemented, and ready to play with...

Wow, ill check them... Thanks...

Well done!

I also have a timer library I have been working on. It can be found here: https://github.com/SomeRandomGuy/DueTimer

ivanseidel's library is a very nice implementation!

I have a function that picks the clock that will produce the smallest error for the frequency entered by the user. I am curious how helpful that will be.

Would also appreciate some thoughts and feedback.



Can i add your implementation to the library? or, if you want, you can join me in the project! and you can add the implementation…
What do you preffer?

Obs.: This is very weird, because i didn't saw your project on github before doing my library, and the name is the SAME! =]

ivanseidel: Obs.: This is very weird, because i didn't saw your project on github before doing my library, and the name is the SAME! =]

Yea, I noticed that too. I don't know what happened there. I think our libraries do essentially the same thing. I think I like yours better because it follows the object oriented format that the timer libraries on the older Arduinos use. The only thing I would like to add to your library is the chunk that picks the best clock to use based on what frequency the user inputs. This was suggested to me by another user, and it results in a smaller clock error. That is the "pickClock" function in my code. Any thoughts on that?

Again, nice work on the library. I would be more than happy to join you on your library, if that is the format that everyone likes better. I did mine as purely functions, you did yours with timer objects, which I think is closer to the Arduino standard.

Does everyone generally agree on this??

Cheers! SRG

You are more than welcome... :)

Because you have included this line: TC_Configure(t.tc, t.channel, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK4); in your object constructor instead of your "setFrequency" function, there is no way to modify which clock is used for a given timer after the user has declared it. Here, you are using TC_CMR_TCCLKS_TIMER_CLOCK4 for every timer, which is the way cmaglie originally posted his example.

I am trying to figure out if this line can be moved down to your "setFrequency" function. If so, then adding in support for the dynamic clock selection will be really easy. :]

Cheers! SRG

I will create a branch to fix that. We could also include in the class, a static int[] containing each timer period, so that we can add "getPeriod()" and "getFrequency()".

Might i create it? (is there another place so that we can chat? Facebook maybe?)