AnalogWrite / PWM on Feather/Metro M0
After looking through the SAMD21 datasheet, we've found that some of the options listed in the multiplexer table
don't exist on the specific chip used in the Feather M0.
For all SAMD21 chips, there are two peripherals that can generate PWM signals: The Timer/Counter (TC) and
Timer/Counter for Control Applications (TCC). Each SAMD21 has multiple copies of each, called 'instances'.
Each TC instance has one count register, one control register, and two output channels. Either channel can be
enabled and disabled, and either channel can be inverted. The pins connected to a TC instance can output identical
versions of the same PWM waveform, or complementary waveforms.
Each TCC instance has a single count register, but multiple compare registers and output channels. There are
options for different kinds of waveform, interleaved switching, programmable dead time, and so on.
The biggest members of the SAMD21 family have five TC instances with two 'waveform output' (WO) channels, and
three TCC instances with eight WO channels:
TC[0-4],WO[0-1]
TCC[0-2],WO[0-7]
And those are the ones shown in the datasheet's multiplexer tables.
The SAMD21G used in the Feather M0 only has three TC instances with two output channels, and three TCC
instances with eight output channels:
TC[3-5],WO[0-1]
TCC[0-2],WO[0-7]
Tracing the signals to the pins broken out on the Feather M0, the following pins can't do PWM at all:
Analog pin A5
The following pins can be configured for PWM without any signal conflicts as long as the SPI, I2C, and UART pins
keep their protocol functions:
Digital pins 5, 6, 9, 10, 11, 12, and 13
Analog pins A3 and A4
If only the SPI pins keep their protocol functions, you can also do PWM on the following pins:
TX and SDA (Digital pins 1 and 20)