I am using an STM32F302C8 and while reading the datasheet I am unable to differentiate between analog and digital input pins I am on pages 34-42 of This datasheet.
I am porting over from Arduino Nano to STM32F302C8 and all I need are 3 Analog and 5 Digital Pins.
-
\$\begingroup\$ Can you be more specific? Do you need to read 3 analog signals with ADC? If not, any pin can be left unconfigured so they are not digital inputs. \$\endgroup\$Justme– Justme2021年02月18日 12:02:18 +00:00Commented Feb 18, 2021 at 12:02
-
\$\begingroup\$ @Justme See I have read the next column which says additional functions and some IO pins say that they are also ADCs but in which direction? \$\endgroup\$Shrie Sharma– Shrie Sharma2021年02月18日 12:14:52 +00:00Commented Feb 18, 2021 at 12:14
-
\$\begingroup\$ Only if the pin has ADC functionality as alternate function then it can be read by ADC. \$\endgroup\$Justme– Justme2021年02月18日 12:17:22 +00:00Commented Feb 18, 2021 at 12:17
-
\$\begingroup\$ @Justme So how do I know which are digital and which are analog? \$\endgroup\$Shrie Sharma– Shrie Sharma2021年02月18日 12:19:04 +00:00Commented Feb 18, 2021 at 12:19
-
\$\begingroup\$ Don't forget STM32 are 3.3V devices, you may want to scale down analog/digital inputs from 5V down to 3.3V (some digital input pins can be 5V-tolerant, but only if it's explicitly stated in the datasheet for every pin in question) \$\endgroup\$Ilya– Ilya2021年02月18日 13:49:36 +00:00Commented Feb 18, 2021 at 13:49
1 Answer 1
All the analog pins are in the ADDITIONAL FUNCTIONS listed on pages 36 and following. For example from page 36 of the datasheet at:
you have:
-
1\$\begingroup\$ No. Only certain pins can be read by the ADC, not all. Usually all pins can be digital outputs or inputs. \$\endgroup\$Justme– Justme2021年02月18日 12:19:04 +00:00Commented Feb 18, 2021 at 12:19
-
1\$\begingroup\$ Find the analog pins you are interested in by reading through the "Additional Functions" column in the table. They default to the function in the "Pin name" column. To get additional functions you need to program them that way. \$\endgroup\$jwh20– jwh202021年02月18日 12:27:14 +00:00Commented Feb 18, 2021 at 12:27
-
2\$\begingroup\$ The STM32 is a bit more complicated than the Arduino. You need to study the datasheet and understand how it works. \$\endgroup\$jwh20– jwh202021年02月18日 12:27:57 +00:00Commented Feb 18, 2021 at 12:27
-
2\$\begingroup\$ When it lists an 'Additional function' as ADCxINy it means that, in addition to being able to read or write this pin with a digital high/low through the GPIO registers, this pin can also be routed to the ADC module to read analog signals. It does not mean that everything presented to this pin is treated as analog and converted to digital before being processed - this is only the case if you configure the ADC to read that pin. \$\endgroup\$brhans– brhans2021年02月18日 13:30:03 +00:00Commented Feb 18, 2021 at 13:30
-
2\$\begingroup\$ When it says "ADC_IN" it means that the pin can be set up as an ADC input, or it can be set up as a digital I/O pin. You have to route analog signals to the correct pins, and you have to set them up in software. \$\endgroup\$TimWescott– TimWescott2021年02月18日 20:36:16 +00:00Commented Feb 18, 2021 at 20:36
Explore related questions
See similar questions with these tags.