DueTimer compatibility problem...

I want to use DueTimer.h library together with pwm_lib.h and tc_lib.h but the IDE compiler issue the error: ...DueTimer/DueTimer.cpp:268: multiple definition of `TC0_Handler' since the main program must define capture_tc0_declaration(); in order to use the mentioned pwm_lib.h and tc_lib.h. Does anybody already have this problem ? Thanks

pwm and tc lib from antodom should suffice, no need for another tc lib. Of course, if you are trying to use a TC timer, e.g. TCO_Handler() for 2 different purposes, you will encounter an issue with your libraries.

Select a different TC handler for each different usage.

You could use a single TC Handler for 2 different purposes if the 2 frequencies needed are a multiple one from the other and if you make a direct register programing of e.g. TC0 (numerous example sketches in this sub forum).

Thanks ard_newbie. The pwm and tc libraries are good for pwm generation and frequency capture but they are too complicate to do simple tasks such generate one interrupt each 1ms for instance... Thats why I chose DueTimer that seams to be much easier than pwm and tc libs...

AntonioTesta:
....generate one interrupt each 1ms for instance.

For that type of "mission", check micros() value in loop and you are done.

AntonioTesta:
Thanks ard_newbie. The pwm and tc libraries are good for pwm generation and frequency capture but they are too complicate to do simple tasks such generate one interrupt each 1ms for instance... Thats why I chose DueTimer that seams to be much easier than pwm and tc libs...

Hi there @AntonioTesta,

Have a look to example action_test.ino in tc_lib, this is precisely what you want, a periodic task using a tc_lib's action object. Change CALLBACK_PERIOD to the want you want, and voila!.

I hope it helps.

Thanks antodom. I am loking for something as simple as possible. Something like this:

#include "simple_int.h"
#define period 1000000
...
init simple_int(period, ISRroutine);
...
void ISRroutine()
{
executed each period of time
}

Is it possible to use tc_lib in that way ?

Thanks again

AntonioTesta:
Thanks antodom. I am loking for something as simple as possible. Something like this:

#include "simple_int.h"
#define period 1000000
...
init simple_int(period, ISRroutine);
...
void ISRroutine()
{
executed each period of time
}

Is it possible to use tc_lib in that way ?

Thanks again

Hi there again @AntonioTesta,

Example action_test.ino which comes with tc_lib does exactly what you want. In particular, example's function set_led_action:

void set_led_action(void* ...)
{
 ...
}

is the your ISRroutine() but tc_lib allows you to pass a void* argument to the function.

In order to have this function called periodically the code in the example is:

action_tc0.start(
        CALLBACK_PERIOD, // period in hundreths of usecs. (1e-8 secs.)
        set_led_action, // the ISR/timer routine
        &action_ctx // the extra argument (if not necessary, you pass NULL/nullptr)
     );

That's all.
I hope it helps.

antodom, invoking you lib as bellow:

int *p=NULL;
action_tc0.start(CALLBACK_PERIOD,set_led_action, &p);

causes the following error message:

invalid conversion from 'void ()()' to 'arduino_due::tc_lib::callback_t {aka void ()(void*)}' [-fpermissive]

Any idea ? Thanks