Very funny uC...
There are some library, ofc from Microchip and you can find code:
#define ID_SSC (22) /**< \brief Synchronous Serial Controller (SSC) */
#define ID_TC0 (23) /**< \brief Timer/Counter 0 (TC0) */
#define ID_TC1 (24) /**< \brief Timer/Counter 1 (TC1) */
#define ID_TC2 (25) /**< \brief Timer/Counter 2 (TC2) */
[...]
#define ID_TC10 (51) /**< \brief Timer/Counter 10 (TC10) */
#define ID_TC11 (52) /**< \brief Timer/Counter 11 (TC11) */
#define ID_AES (56) /**< \brief AES (AES) */
[...]
#define TC0 (0x4000C000U) /**< \brief (TC0 ) Base Address */
#define TC1 (0x40010000U) /**< \brief (TC1 ) Base Address */
#define TC2 (0x40014000U) /**< \brief (TC2 ) Base Address */
[...]
#define TC3 (0x40054000U) /**< \brief (TC3 ) Base Address */
#define TC0 ((Tc *)0x4000C000U) /**< \brief (TC0 ) Base Address */
#define TC1 ((Tc *)0x40010000U) /**< \brief (TC1 ) Base Address */
#define TC2 ((Tc *)0x40014000U) /**< \brief (TC2 ) Base Address */
[...]
#define TC3 ((Tc *)0x40054000U) /**< \brief (TC3 ) Base Address */
So how much TC channels do you expect? from 0 to 11? I do. Even in 144 Lead package pinout you can find for example PD21 and PD22 which one can work as TIOA11 and TIOB11. Easy ye?
But i have some code:
pmc_enable_periph_clk(ID_PIOA);
pmc_enable_periph_clk(ID_PIOD);
pio_configure(PIOA, PIO_PERIPH_B, PIO_PA1, 0); // PWM0L TIOB0 per b
pio_configure(PIOA, PIO_PERIPH_B, PIO_PA0, 0); // PWM0L TIOA0 per b
pio_configure(PIOD, PIO_PERIPH_C, PIO_PD21, 0); // PWM1H (!) TIOA11 per c
pio_configure(PIOD, PIO_PERIPH_C, PIO_PD22, 0); // PWM1H (!) TIOB11 per c
pmc_enable_periph_clk(ID_TC0);
pmc_enable_periph_clk(ID_TC1);
pmc_enable_periph_clk(ID_TC2);
pmc_enable_periph_clk(ID_TC3); // (?)
// Configure TC0 Channel 0 in waveform mode
REG_TC0_CMR0 = TC_CMR_TCCLKS_TIMER_CLOCK2 | (1<<10) | // Timer clock = MCK/2
TC_CMR_WAVE | // Enable waveform mode
TC_CMR_WAVSEL_UP_RC | // Up mode with automatic reset on RC compare
TC_CMR_ACPA_SET | // Set TIOA on RA compare
TC_CMR_ACPC_CLEAR | // Clear TIOA on RC compare
TC_CMR_BCPB_SET | // Set TIOB on RB compare
TC_CMR_BCPC_CLEAR; // Clear TIOB on RC compare
// Set RA, RB, and RC values for PWM signal
REG_TC0_RA0 = 80; // TIOA high for 30% of the period
REG_TC0_RB0 = 80; // TIOB high for 70% of the period
REG_TC0_RC0 = 164; // Period of the waveform
// Enable and start the TC channel
REG_TC0_CCR0 = TC_CCR_CLKEN | TC_CCR_SWTRG;
// Configure TC3 Channel 2 in waveform mode
REG_TC3_CMR2 = TC_CMR_TCCLKS_TIMER_CLOCK2 | (2<<10) | // Timer clock = MCK/2
TC_CMR_WAVE | // Enable waveform mode
TC_CMR_WAVSEL_UP_RC | // Up mode with automatic reset on RC compare
TC_CMR_ACPA_SET | // Set TIOA on RA compare
TC_CMR_ACPC_CLEAR | // Clear TIOA on RC compare
TC_CMR_BCPB_SET | // Set TIOB on RB compare
TC_CMR_BCPC_CLEAR; // Clear TIOB on RC compare
// Set RA, RB, and RC values for PWM signal
REG_TC3_RA2 = 80; // TIOA high for 30% of the period
REG_TC3_RB2 = 80; // TIOB high for 70% of the period
REG_TC3_RC2 = 164; // Period of the waveform
// Enable and start the TC channel
REG_TC3_CCR2 = TC_CCR_CLKEN | TC_CCR_SWTRG;
And on o-scope i see PWM for channel 0, but for 11 don't. Where is the secret?
I study carefully registers summary for timer counter and what i find:
There is TC_CCR0, TC_CCR1, TC_CCR2 ... but TC_CCR3 is gone.
In the errata there are nothing about any problems with timer counter module.
In this moment i decide to use PSoC4 for my purpose, i can obtain this PWM signals with 4 line of code.
Another iritating moment is on my Xplained Board there is only TIOA0/B0 and TIOA11/B11 signals connetced to GPIO expansions. I have lost too much time.