44.6.2.2 Initialization
- Recoverable Fault Control registers (FCTRLA and FCTRLB)
- Waveform Extension Control register (WEXCTRL)
- Drive Control register (DRVCTRL)
- Event Control register (EVCTRL)
Register Enable-protection is denoted by the 'Enable-Protected' property in the register description.
The following register bits are enable-protected, meaning that they can only be written when the TCC is disabled (CTRLA.ENABLE=0):
- Capture Channel x Enable bits in Control A register (CTRLA.CPTEN[CC_NUM-1:0])
- DMA One-shot Trigger Mode (CTRLA.DMAOS)
- Full Cycle (CTRLA.FCYCLE)
- Auto Lock (CTRLA.ALOCK)
- Prescaler and Counter Synchronization Selection (CTRLA.PRESCSYNC)
- Run in Standby (CTRLA.RUNSTDBY)
- Prescaler (CTRLA.PRESCALER)
- Enhanced Resolution (CTRLA.RESOLUTION)
When CTRLA.ENABLE bit (CTRLA <1>) is '0', Enable-protected bits in the CTRLA register can be written at the same time CTRLA.ENABLE bit (CTRLA <1>) is written to '1'. However, when CTRLA.ENABLE bit (CTRLA <1>) is '1' these bits can not be written at the same time CTRLA.ENABLE bit (CTRLA <1>) is written to '0'. Enable-protection is denoted by the “Enable-Protected” property in the register description.
- Configure the clock source for the TCC Instance in the Main Clock Controller (MCLK) and enable the APB BUS clock for the TCC Instance by writing a ‘1’ to the TCCx_ bit in the APB Mask register of the MCLK (i.e., enable CLK_TCC0_APB for TCC0 by setting TCC0_ bit (APBCMASK<3>), CLK_TCC1_APB for TCC1 by setting TCC1_ bit (APBCMASK<4>) etc.).
- If Capture mode is required, enable the channel in Capture mode by writing a '1' to the Capture Enable bit in the Control A register (i.e., for Channel 0 CTRLA.CPTEN0 bit (CTRLA <24>), for Channel 1 CTRLA.CPTEN1 bit (CTRLA <25>) etc.).
- Select PRESCALER setting in the Control A register (CTRLA.PRESCALER bits (CTRLA <10:8>)).
- Select Prescaler Synchronization setting in Control A register (CTRLA.PRESYNC bits (CTRLA <13:12>)).
- If down-counting operation is desired, write the Counter Direction bit in the Control B Set register (CTRLBSET.DIR bit (CTRLBSET <0>)) to '1'.
- Select the Waveform Generation operation in the WAVE register (WAVEGEN bits (WAVE <2:0>)).
- The output polarity for each individual channel can be changed by configuring the corresponding WAVE.POLy bit, where y=0,1,2,..7. For example, when the CC0 register is used for the duty cycle, the corresponding WAVE.POL0 bit (WAVE<16>) decides the polarity.
- The waveform output for each individual channel can be inverted by configuring corresponding Waveform Output Invert Enable bit DRVCTRL.INVENy bits where y = 0,1,2…7. For example, when CC0 register is used for the duty cycle, corresponding DRVCTRL.INVEN0 bit (DRVCTRL <16>) decides inversion.