Page 1 of 1

Unable to use analogRead() with pin PC3 and PC2

Posted: Mon Nov 21, 2022 3:26 pm
by alexandreviau
Hi,

I'm using a NUCLE-G431RB with the arduino framework and PlatformIO.

I'm trying to do an analogRead() on pin PC2 and PC3, but it doesn't work. The problem seems to be that the function analogInputToDigitalPin() return NC for those pin.

Is there someting that I missed ?

Thanks !

Re: Unable to use analogRead() with pin PC3 and PC2

Posted: Mon Nov 21, 2022 5:29 pm
by fpiSTM
Looking at the variant:
https://github.com/stm32duino/Arduino_C ... 31RB.h#L48

PC2 and PC3 are not defined as analog pins.
Don't know why as they have analog capabilities:
https://github.com/stm32duino/Arduino_C ... Pins.c#L59

Re: Unable to use analogRead() with pin PC3 and PC2

Posted: Tue Nov 22, 2022 10:45 am
by fpiSTM
I've added the missing analog pins.
Pay attention some of them are by default other functions (LED, VCP,...)
https://github.com/stm32duino/Arduino_C ... a43f72f0ff

Re: Unable to use analogRead() with pin PC3 and PC2

Posted: Tue Nov 22, 2022 8:24 pm
by alexandreviau
Hi @fpiSTM,

Thanks for your help !

I would like to test your change, but I don't konw how to set platformio to use the commit you make. Can you help me with that ?

Thanks !

Re: Unable to use analogRead() with pin PC3 and PC2

Posted: Tue Nov 22, 2022 8:33 pm
by fpiSTM
Unfortunately not. I do not use pio.

Re: Unable to use analogRead() with pin PC3 and PC2

Posted: Thu Nov 24, 2022 1:48 pm
by alexandreviau
Ok, adding this line forced platformio to clone the lattest commit :

Code: Select all

platform_packages = platformio/framework-arduinoststm32 @ https://github.com/stm32duino/Arduino_Core_STM32.git#main
Everything seems to be working fine now !

Thanks !

Re: Unable to use analogRead() with pin PC3 and PC2

Posted: Thu Nov 24, 2022 2:04 pm
by fpiSTM
Welcome ;)