Hi All,
I have a 128A1U running at 32MHz and I need to output synchronised pulses to any combination of pins on PORTC. I'm using TCC0 in SS mode to generate pulses on CCA, and AWEXC in both Pattern Generator Mode and Common Waveform Channel Mode to distribute those pulses across PORTC output pins.
Trouble is, I can't get PGM and CWCM working. All I can manage is one or more pairs of adjacent pins in DTI mode, which is not what I need.
The documentation for TCCx combined with AWEXx seems very limited. I did manage to get the combination working in a different project, in a different way, but it cost me a month of unpaid overrun. I eventually got it working by stepping through every register, bit by bit, testing the peripheral functionality until I filled in the cavernous gaps in the datasheet and app notes. But I can't afford to do that again on this project.
Has anyone here successfully used the AWEX in PGM and/or CWCM?
Here's my code:
// Initialise PORTC for pulse output PORTCFG.MPCMASK = 0xFF; // Configure all pins PORTC_PIN0CTRL = PINCTRL_TTLOUT; // Set TTL outputs PORTC_OUT = 0x00; // Preset all outputs off PORTC_DIR = 0xFF; // Set all pins as output // Configure TCC0 for pulse generation in SS mode. TCC0.CTRLA = 0x00; // Disable timer until setup complete TCC0.CTRLB = 0x03; // Set SS mode, all CCxENs disabled TCC0.CTRLC = 0x00; // Preset Compare Outputs to 0 TCC0.CTRLD = 0x00; // No events used TCC0.CTRLE = 0x00; // Leave the timer in 16-bit mode TCC0.INTCTRLA = 0x00; // Leave interrupts disabled TCC0.INTCTRLB = 0x00; // Leave interrupts disabled TCC0.CTRLFCLR = 0xFF; // Command nothing, set counting up TCC0.CNT = 0x0000; // Initialise counter value TCC0.PER = 62500; // Set period to 500ms in 8us units TCC0.CCA = 6250; // Set pulse to 50ms in 8us units TCC0.CCB = 0x0000; // unused in CWCM TCC0.CCC = 0x0000; // unused in CWCM TCC0.CCD = 0x0000; // unused in CWCM // Configure AWeX extension in PGM and CWCM AWEXC.CTRL = 0x3F; // Enable PGM, CWCM and all DTICCxENs AWEXC.FDEMASK = 0x00; // No fault protection AWEXC.FDCTRL = 0x00; // No fault protection AWEXC.DTLSBUF = 0x00; // Set OUTOVEN double buffer AWEXC.DTHSBUF = 0x00; // Clear OUT double buffer to ZERO AWEXC.OUTOVEN = 0x00; // Disable outputs until initialised // Start Timer TCC0.CTRLA = 0x06; // Start timere with prescaler DIV256 // Set output pulse pattern AWEXC.DTLSBUF = 0xFF; // Set OUTOVEN double buffer AWEXC.OUTOVEN = 0xFF; // Set OUTOVEN (unsure double buffer) TCC0.CTRLFSET = 0x04; // Command TCx0 to UPDATE