I’ve raised a discussion around the Analog pins definition:
https://github.com/stm32duino/Arduino_C … /issues/37
Hope I described my thought clearly
Any feedback are welcome and greatly appreciate in this topic or in the github issue.
So in answer to your first question
Is it required to define more than A0 to A5 by default ?
I would say no. Only the names A0 to A5 need to be defined, and only for Nucleo boards which have this on their silkscreen.
Sorry. Its been so long since I used AVR that I can’t answer the question about pin mapping of AnalogRead(A0) vs AnalogRead(0)
and AnalogWrite(0) == AnalogWrite(D0)
Apart from AnalogWrite gets tricky if the board has DAC, because AnalogWrite on AVR always means PWM and is not always used to convert to analogue voltage, e.g. Servo’s use the pulse width to set the position and probably do not convert to a voltage first.
[RogerClark – Fri Jun 23, 2017 10:09 am] –
I would say no. Only the names A0 to A5 need to be defined, and only for Nucleo boards which have this on their silkscreen.
My brain will explode
It’s sound good but I think lot of sketch will not compile as they use often A0.
I think to avoid any mismatch/confusion:
All pin defined as ADC in PinMap_ADC should be alias with Ax and NUM_ANALOG_INPUTS set to this number.
For example, some libs do a loop from 0 to NUM_ANALOG_INPUTS with analogRead(i).
[RogerClark – Fri Jun 23, 2017 10:09 am] – Sorry. Its been so long since I used AVR that I can’t answer the question about pin mapping of AnalogRead(A0) vs AnalogRead(0) and AnalogWrite(0) == AnalogWrite(D0)
This could be considering OK; I think. As Arduino guy told me this should be like this.
[RogerClark – Fri Jun 23, 2017 10:09 am] – Apart from AnalogWrite gets tricky if the board has DAC, because AnalogWrite on AVR always means PWM and is not always used to convert to analogue voltage, e.g. Servo’s use the pulse width to set the position and probably do not convert to a voltage first.
On STM32 core, if pin is DAC, it is used else we check if it is PWM and use it else it is only IO then we set high or low depending of the value.
I mean, to only define A0 to A5, and only do this for Nucleo variants.
No need to define A6 etc as no board has a pin labelled A6 on the PCB silk screen.
And for variants like the Discovery, I do not think you need to define A0 etc, as the pins are labelled In the style PAx, PBx etc
[RogerClark – Fri Jun 23, 2017 9:59 pm] –
Hi FredericI mean, to only define A0 to A5, and only do this for Nucleo variants.
No need to define A6 etc as no board has a pin labelled A6 on the PCB silk screen.
And for variants like the Discovery, I do not think you need to define A0 etc, as the pins are labelled In the style PAx, PBx etc
Ok this is not on PCB silk screen but for lot of sketches using a loop until the MAX ANALOG INPUT this will raise an error.
For Firmata also as it iterate over the pin number.
Sketches use the pin number not the Pin name PYx,…
As our goal is to reused as much as possible standard Arduino sketch even if the PCB silkscreen has no Ax, Ax should be defined.
Are the sketches that fail part of the examples that the IDE installs?
I dont think its practical to support all sketches that anyone has written for AVR.
Moreover, as I said Firmata need this.
That’s why I try to fit Arduino naming.
[fpiSTM – Fri Jun 23, 2017 10:49 pm] –
Yes and some other provided with libraries.
Moreover, as I said Firmata need this.That’s why I try to fit Arduino naming.
Ah OK.
I see I need for it ![]()
[RogerClark – Fri Jun 23, 2017 9:59 pm] –
No need to define A6 etc as no board has a pin labelled A6 on the PCB silk screen.
Arduino nano / Nucleo-32 has A6/A7 on silkscreen. Nucleo-144 has A6/A7/A8 on the paper thingie that comes with it.
I looked at my Nucleo boards but I don’t have either of those variants
I’ve made a pull request to manage analog pins definitions.
With this pull, firmata works well and all pins are correctly mapped.
