XIAO SAMD21 - PWM on pin A0

I am using a the XIAO SAM21D board, and I would like pin A0 to be a classic PWM. By default the libraries route the ADC to this pin and it outputs a true analog voltage. In my case I want a classic PWM like I get on pin A1 when I call analogWrite. Is there an easy way to change the behaviour of pin A0 from true analog back to classic PWM?

Hi lawrencek52,
According to “Table 7-1. PORT Function Multiplexing” in the Atmel SAMD21 datasheet, A0 (PA02) pin cannot be connected to a timer output, so I think A0 pin cannot be used for PWM. Please check.

I agree: I went into the Arduino driver source, and it looks like pin A0 is hard coded to only be analog in/out.

It would have made wiring my project easier, but I can use one of the other pins to get the two PWMs I need.

Thanks for your help.

I should further clarify my answer. The chip hardware is perfectly capable of outputting PWM on pin A0, but the Arduino initialization code provided with the chip has hard coded this pin to be an analog pin. After digging into the low layers of the source core I realized that it was way more work to make pin A0 a PWM than I wanted to do, and it involved changing the libraries distributed with the Arduino software.
My ‘workaround’ was to just use one of the other pins as the PWM and modify my wiring.