Second TIOA & TIOB

I need three square wave signals. I found a good example here and am using this code to get two squares. But I can't get TIOA from another timer. I cannot understand how the timer channels and TIOA outputs are connected. If I change the channel, I don't get anything at the output. I tried to change channels and timers but only TIOA8 & TIOB8 works.
Can someone give an example of how to get signals from other timers or channels? I looked in the datasheet but did not find anything.

#include <Arduino.h>
volatile bool ledOn;
//TC1 ch 0
//uint32_t *TC_CV = (uint32_t *)(0x40084010);
uint32_t t_channel = 2;
void TC8_Handler()
  //TC_GetStatus(TC2, t_channel);
  //digitalWrite(13, ledOn = !ledOn);
  //digitalWrite(11, ledOn);
void TimerStart(Tc *tc, uint32_t channel, IRQn_Type irq)
  //PMC->PMC_PCER0 |= ID_TC2;
  TC_Configure(tc, channel, TC_CMR_TCCLKS_TIMER_CLOCK1 // MCK/2, clk on rising edge
                                | TC_CMR_WAVE          // Waveform mode
                                | TC_CMR_WAVSEL_UP_RC  // UP mode with automatic trigger on RC Compare
                                | TC_CMR_BCPC_SET      // Set TIOB on counter match with RC0
                                | TC_CMR_ACPC_SET      // Set TIOA on counter match with RC0
                                | TC_CMR_BCPB_CLEAR    // Clear TIOB on counter match with RB0
                                | TC_CMR_ACPA_CLEAR    // Clear TIOA on counter match with RA0
                                | TC_CMR_EEVT_XC0      // Set event selection to XC0 to make TIOB an output
  float freq = 1;
  uint32_t rc = VARIANT_MCK / 2 / freq;
  TC_SetRA(tc, channel, rc / 2); // 50% duty cycle square wave
  TC_SetRB(tc, channel, rc / 4);
  TC_SetRC(tc, channel, rc);
  tc->TC_CHANNEL[channel].TC_IDR = ~(TC_IER_CPCS | TC_IER_CPAS);
                  | PIO_PDR_P8;
  TC_Start(tc, channel);
void setup()
  //pinMode(13, OUTPUT);
  // pinMode(11, OUTPUT);
  TimerStart(TC2, t_channel, TC8_IRQn);
void loop()
  //char outputString[9];
  //itoa((unsigned int)TC_CV, outputString, 16);

Hi @losman

Have you tried kicking-off the timers with the TC's Blocking Control Register (TC_BCR) SYNC bit:

TC0->TC_BCR = TC_BCR_SYNC;   // Generate a software trigger on all of the TC timer's channels

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.