Skip to content

Adds additional analog inputs: A6-A11 #267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed

Adds additional analog inputs: A6-A11 #267

wants to merge 5 commits into from

Conversation

Adminius
Copy link
Contributor

A6 ~ D0
A7 ~ D1
A8 ~ D3
A9 ~ D4
A10 ~ D8
A11 ~ D9

A6 ~ D0
A7 ~ D1
A8 ~ D3
A9 ~ D4
A10 ~ D8
A11~ D9
A6 ~ D0
A7 ~ D1
A8 ~ D3
A9 ~ D4
A10 ~ D8
A11 ~ D9
@mitchellpontague
Copy link
Contributor

Of those pins only PA06 and PA07 are referenced to analog ground and intended to be used as analog inputs.
The attribute PIN_ATTR_ANALOG is only used to enable the DAC on analog writes. As is it will break PWM when referenced as A6-A11
The analogInputToDigitalPin macro is being used backwards, not mapping correctly, and mapping unintended pins.
The PIN_A6-PIN_A11 macros and A6-A11 constants should be added.

changed pin definition for new A6-A11
better analogInputToDigitalPin(p) conditions
@Adminius
Copy link
Contributor Author

@mitchellpontague why only PA06 and PA07? Source of this statement?
analogInputToDigitalPin better?

@mitchellpontague
Copy link
Contributor

From the datasheet on page 27 lists which pins are intended to be analog. Page 33 shows the voltage sources for each pin. However the only difference between the analog and io voltages is extra filtering.
analogInputToDigitalPin looks good.

@Adminius
Copy link
Contributor Author

grafik
@mitchellpontague PA08-PA11 can also be analog pins, but, as you say, without filtering.

@Adminius
Copy link
Contributor Author

@facchinm, @cmaglie hi, i know, it's a not a main function. But i would like to know if this PR in general will be accepted or if I have to make it in another way (like a external lib).

@helmut64
Copy link
Contributor

helmut64 commented Jul 2, 2018

@Adminius important patch, I hope this gets merged soon.
I have also enabled the SWClock and SWData pins for the Arduino Zero which gives us two more pins when Debugging is not being used. As the two new Pins 44/45 belong to the same file, can you add them to your patch or should I do a separate patch:

Regards Helmut

The lines would be (at end, relaces 43, 44, 45 are new):
// 43..45 - Alternate use of A0 (DAC output), 44 SDC, 45, SWD
{ PORTA, 2, PIO_ANALOG, PIN_ATTR_ANALOG, DAC_Channel0, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // DAC/VOUT
{ PORTA, 30, PIO_PWM, PIN_ATTR_DIGITAL|PIO_SERCOM, No_ADC_Channel, NOT_ON_PWM, TCC1_CH0, EXTERNAL_INT_10 }, // SWC
{ PORTA, 31, PIO_PWM, PIN_ATTR_DIGITAL|PIO_SERCOM, No_ADC_Channel, NOT_ON_PWM, TCC1_CH1, EXTERNAL_INT_11 }, // SWD

@Adminius
Copy link
Contributor Author

Adminius commented Jul 2, 2018

i would say extra patch.
but there is/was a problem with SWCLK Pin:
Using the SWD pins SWDIO and SWCLK for general in / out

@helmut64
Copy link
Contributor

helmut64 commented Jul 3, 2018

I will do an extra patch, thank you for your advise.
My understanding is that the SWD/SWC pins are default connected to the debugger, switching them to GPIO is supported and works fine. I need extra simple GPIO pins that's why I do this. This is not a speciality on the D21 also STML4 can do this.

I still need to figure out who to check if a debugger is connect before using the pins. On STM there is a Debugger Interface active check available via (CoreDebug->DHCSR & 1)

On the SAMD/D21 I need need to figure out where the find the DHCSR address.

#define PIN_A8 (46ul)
#define PIN_A9 (47ul)
#define PIN_A10 (48ul)
#define PIN_A11 (49ul)
#define PIN_DAC0 (14ul)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this logic is for using analogRead function with 0-5 instead of A0-A5...
so that means:

 if (pin < A0) {
    pin += A0;
  }else if(pin > 5 && pin <= 11){
    pin += 38;
 }

@sandeepmistry is it ok for you?

update to last core version
@Adminius
Copy link
Contributor Author

this PR is outdated. new: #374

@Adminius Adminius closed this Nov 20, 2018
boseji pushed a commit to go-ut/combined-ArduinoCore-samd that referenced this pull request Nov 23, 2020
Adafruit Feather M4 CAN: Add support for board
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants