Can Due timers generate 42 MHz?

I am using a timer within Due to generate programmable clocks for a CPLD.
The highest clock frequency achieved up to now is 21 MHz. But I'd like to have 42 Mhz.

The highest available clock frequency a timer can get is TIMER_CLOCK1 which is MCK/2=42 MHz. Is it possible to feed this frequency to an output pin of the Due?

Hi @SupArdu

Yes, it's possible to get a 42MHz signal using the Due's PWM controller.

Here's some example code that outputs 42MHz on D9:

// Output a 42MHz PWM waveform on pin D9 (PWML4)
void setup() {
  PMC->PMC_PCER1 |= PMC_PCER1_PID36;                            // Enable the PWM Controller 
  PIOC->PIO_ABSR |= PIO_ABSR_P21;                               // Set PWM pin perhipheral type A or B, in this case B
  PIOC->PIO_PDR |= PIO_PDR_P21;                                 // Set PWM pin to an output
  PWM->PWM_CLK = PWM_CLK_PREA(0) | PWM_CLK_DIVA(1);             // Set the PWM clock rate to 84MHz (84MHz/1=84MHz) 
  PWM->PWM_CH_NUM[4].PWM_CMR = PWM_CMR_CPRE_CLKA;               // Enable single slope PWM and set the clock source as CLKA
  PWM->PWM_CH_NUM[4].PWM_CPRD = 2;                              // Set the PWM frequency 84MHz/48MHz = 2 
  PWM->PWM_CH_NUM[4].PWM_CDTY = 1;                              // Set the PWM duty cycle 
  PWM->PWM_ENA = PWM_ENA_CHID4;                                 // Enable the PWM channel 4 
}

void loop() {}

Hi,
It works, thank you very much.