25.8.2 Quick Start Guide for TCC - Double Buffering and Circular

The supported board list:
  • SAM D21/R21/L21/L22/DA1/C21 Xplained Pro

In this use case, the TCC will be used to generate a PWM signal. Here the pulse width alters in one quarter and three quarter of the period. When connect PWM output to LED it makes the LED light. To see the waveform, you may need an oscilloscope.

The PWM output is set up as follows:

Board

Pin

Connect to

SAMD21 Xpro

PB30

LED0

SAMR21 Xpro

PA19

LED0

SAML21 Xpro

PB10

LED0

SAML22 Xpro

PC27

LED0

SAMDA1 Xpro

PB30

LED0

SAMC21 Xpro

PA15

LED0

The TCC module will be set up as follows:
  • GCLK generator 0 (GCLK main) clock source

  • Use double buffering write when set top, compare, or pattern through API

  • No dithering on the counter or compare

  • Prescaler is set to 1024

  • Single Slope PWM wave generation

  • GCLK reload action

  • Don't run in standby

  • No fault or waveform extensions

  • No inversion of waveform output

  • No capture enabled

  • Count upward

  • Don't perform one-shot operations

  • No event input enabled

  • No event action

  • No event generation enabled

  • Counter starts on 0

  • Counter top set to 8000

  • Capture compare channel set to 8000/4

  • Capture compare channel buffer set to 8000*3/4

  • Circular option for compare channel is enabled so that the compare values keep switching on update condition