Unable to use analogRead() with pin PC3 and PC2

Post here first, or if you can't find a relevant section!
Post Reply
alexandreviau
Posts: 3
Joined: Mon Nov 21, 2022 3:16 pm

Unable to use analogRead() with pin PC3 and PC2

Post 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 !
by fpiSTM » Tue Nov 22, 2022 10:45 am
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
Go to full post
User avatar
fpiSTM
Posts: 1456
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 73
Location: Le Mans
Contact:

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

Post 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
User avatar
fpiSTM
Posts: 1456
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 73
Location: Le Mans
Contact:

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

Post 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
alexandreviau
Posts: 3
Joined: Mon Nov 21, 2022 3:16 pm

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

Post 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 !
User avatar
fpiSTM
Posts: 1456
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 73
Location: Le Mans
Contact:

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

Post by fpiSTM »

Unfortunately not. I do not use pio.
alexandreviau
Posts: 3
Joined: Mon Nov 21, 2022 3:16 pm

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

Post 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 !
User avatar
fpiSTM
Posts: 1456
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 73
Location: Le Mans
Contact:

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

Post by fpiSTM »

Welcome ;)
Post Reply

Return to “General discussion”