Arduino Zero TCC Capture

Hi MartinL

I have tested the above # 94 sketch (40 kHz via TCC1 on D9), but be obliged to do some adjustments to get it working (See attachement).

To summarise, I needed to do the 2 following modifications :

// Feed GCLK4 to TCC0 and TCC1
GCLK->CLKCTRL.reg = 0x441A; // Modified for IDE 1.7.11 by MartinL forum Arduino.cc (Changing Arduino Zero PWM Frequency - Arduino Zero - Arduino Forum)

and the following one :

// Dual slope PWM operation: timers countinuously count up to PER register value then down 0
REG_TCC1_WAVE |= TCC_WAVE_POL(0xF) | // Reverse the output polarity on all TCC1 outputs
TCC_WAVE_WAVEGEN_DSBOTH; // Setup dual slope PWM on TCC1
and following....

Since "Normal (single slope) PWM operation" seems not working.

Hopefuly I have now a sketch running under TCC1, but could you explain why these modifications are needed ?

Then I tried to change the pin output from 9 to 7...and I never got it working.

Could you please adjust the sketch to do this, so I can understand how to pass from D9 to D7 output pin ?

What I did ( but it's not working !) :

// Enable the port multiplexer for the PWM channel on pin D7
PORT->Group[g_APinDescription[7].ulPort].PINCFG[g_APinDescription[7].ulPin].bit.PMUXEN = 1;

And :
// Connect the TCC1 timer to the port outputs - port pins are paired odd PMUO and even PMUXE
// F & E peripherals specify the timers: TCC0, TCC1 and TCC2
PORT->Group[g_APinDescription[6].ulPort].PMUX[g_APinDescription[6].ulPin >> 1].reg |= PORT_PMUX_PMUXO_E;

I fear this last modification to be the pb since I don't understand which number needs to be put in ??
Many thanks again,
Kind Regards
Daniel
40kHz_TCC1.ino (2.88 KB)