Hi there,
I'm playing arround with a custom Sam3 Board and have a little problem with variants.h/.ccp
I want to use as much as possible Pins and as much as possible functions with it. So I checked the Datasheet and Custom Boards to write my own variant files. Let's just play it over with one Pin:
From the Datasheet I know Pin 85 is known as PA2 with build in functions: Peripheral A TIOA1, Peripheral B NANDRDY, Extra AD0. (Atmel Page 53)
In Due_X variant.cpp:
* 61 TIOA1 | PA2 | "A7"
{ PIOA, PIO_PA2X1_AD0, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC7, ADC0, NOT_ON_PWM, TC0_CHA1 }, // AD7
I'm wondering about TIOA1, because this so similar to TIOA0 and used by D2 as PWM Port.
So I was wondering: If I need less Analog pins and more PWM, can I redifine some of the Pins like:
{ PIOA, PIO_PA2X1_AD0, ID_PIOA, PIO_INPUT, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), ADC7, ADC0, NOT_ON_PWM, TC0_CHA1 },
by typedef PinDescription from Arduino.h it should give me:
pPort =PIOA;
ulPin =PIO_PA2X1_AD0;
ulPeripheralId =ID_PIOA;
ulPinType =PIO_INPUT;
ulPinConfiguration =PIO_DEFAULT;
ulPinAttribute =(1UL<<2 |1UL<<4);
ulAnalogChannel= ADC7;
ulADCChannelNumber =ADC0;
ulPWMChannel =NOT_ON_PWM;
ulTCChannel =TC0_CHA1;
TC0_CHA1 if defined in Arduino.h ETCChannel's and I kinda can follow the logig and it might work, but can Somebody verify this before I burn my chip?
Also I wonder if it's possible to use PA20 as PWM (connected to D43) cause it has PWML2 as Peripheral B, Same as D9/PWML4.
EPWMChannel defines PWM_CH0=0, PWM_CH1, PWM_CH2, PWM_CH3, But they are not used in variants.cpp. So why not
{ PIOA, PIO_PA21B_PWML0, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, PWM_CH0, NOT_ON_TIMER }, //107 / PWML0
to enable PWM on PA21?
(looking at pio_sam3***.h Pio definition for PWM peripheral they are all in there. Also PC20B_PWMH4 and so on...)
Greetings Moritz