External Clock

Hello everyone,
I am trying to make a timer run by an external clock that will come from a generator, but I cannot make it work.
I post my code :

  pmc_set_writeprotect(false);
  pmc_enable_periph_clk(TC5_IRQn); // Set interrupt handler to TCLK5
  TC_Configure(TC1, 2, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_XC2); // Set external clock input
  TC_SetRC(TC1, 2, 100); // Every 100th clock will be invoked interrupt 
  TC1->TC_CHANNEL[2].TC_IER=TC_IER_CPCS;
  TC1->TC_CHANNEL[2].TC_IDR=~TC_IER_CPCS;
  NVIC_ClearPendingIRQ(TC5_IRQn);
  NVIC_EnableIRQ(TC5_IRQn);
  TC_Start(TC1, 2);  // Start the counter on DAC1 pin

this is something I found on the internet but i doesn't work...
If someone can help me please :slight_smile:

Did you read pages 901 and 858 of Sam3x datasheet for an External Clock signal selection ?

Yes actually I have but the code bellow is also not working...

TC0->TC_BMR = TC_BMR_TC0XC0S_TCLK0;
TC0->TC_CHANNEL[0].TC_CMR = TC_CMR_TCCLKS_XC0 
                              |TC_CMR_WAVE
                              |TC_CMR_WAVSEL_UP_RC        // UP mode with automatic trigger on RC Compare
                              |TC_CMR_ACPA_CLEAR          // Clear TIOA0 on RA compare match
                              |TC_CMR_ACPC_SET;           // Set TIOA0 on RC compare match

Don't post only a code snippet, this is useless.

Try first to blink an LED with a Timer Counter clocked with an external clock.

okay for the code

The problem comes from the fact that the setting are not good for the external clock. I have tried a lot and I cannot have a timer clocked by an external clock, this is where my problem is located actually ...
if you have an idea where it can be