I have read the XMEGA E5 manual many times, but not everything is clearly explained there. I try to use TCC4 in byte mode, to double the number of PWM channels. Everything seems to be ok, except I cannot get any waveform on PC4. On PC0-PC3 the waveform is as expected. Maybe I have missed something? Here is my code:
void PWM_OUT_Init()
{
PORTC.DIRSET=0b00011111; //PWM outputs
TCC4.CTRLB=TC_BYTEM_BYTEMODE_gc | TC_WGMODE_SINGLESLOPE_gc; //8-bit mode, single slope
TCC4.PERL=255;
TCC4.CTRLE=TC_LCCAMODE_COMP_gc | TC_LCCBMODE_COMP_gc | TC_LCCCMODE_COMP_gc | TC_LCCDMODE_COMP_gc; //Compare for all channels (should be only 0-4, the rest is enabled for testing
TCC4.CTRLF=TC_HCCAMODE_COMP_gc | TC_HCCBMODE_COMP_gc | TC_HCCCMODE_COMP_gc | TC_HCCDMODE_COMP_gc;
TCC4.CCAL=0xc020;
TCC4.CCBL=64;
TCC4.CCCL=128;
TCC4.CCDL=192;
//TCC4.CCAH=224;
TCC4.CCBH=224;
TCC4.CCCH=224;
TCC4.CCDH=224;
TCC4.CTRLA=TC_CLKSEL_DIV4_gc; //f=2kHz
}
I've noticed, that higher 8-bits of CCx registers are cleared every timer overflow.