cancel
Showing results for 
Search instead for 
Did you mean: 

What pins can I use for Analog Input/Output? STM32CubeMX allows every GPIO to be set to ''GPIO_Analog''?

Matt Roybal
Associate II
Posted on February 21, 2018 at 00:12

Hello, I am currently using an STM32F301K6U. STM32CubeMX allows me to set pretty much any GPIO as a 'GPIOP_Analog'. However, when I go into the ADC1 under 'Peripherals' every single item is red because there is some conflict with another pin. The ST Micro rep told me I could set any GPIO as an analog input or output, so I am not understanding how this is supposed to work. How do I do an analog read on the GPIO I set as 'GPIO_Analog'? And similarly, do an analog out on these pins as well?

Thanks and any help/advice is greatly appreciated.

4 REPLIES 4
Posted on February 21, 2018 at 00:24

The data sheet breaks down those connected to an ADC, ie ADC123_IN4

The reason to turn ANY pin to analogue is to turn OFF the schmitt trigger on the input that feeds down stream digital logic and GPIOx->IDR, etc. This avoids noise, and potential oscillation.

Use the ADC to measure the supported pins, use the DAC to output to supported pins. Review the Data Sheet

http://www.st.com/content/ccc/resource/technical/document/datasheet/29/f7/28/76/14/ff/42/59/DM00093332.pdf/files/DM00093332.pdf/jcr:content/translations/en.DM00093332.pdf

 
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on February 21, 2018 at 01:26

Thank you

Turvey.Clive.002

for this answer. On the top of what you said I would like to add that switching off GPIO's Schmitt trigger also decreases a bit current consumption of MCU. That is why Analog Input is a recommended mode for all GPIOs, which are unused by application.

Analog Input is a default mode of GPIOs inlow-power STM32 MCUs: STM32L0 and STM32L4. For other STM32 familiesuser has to take care about configuring unused GPIOs in Analog Input mode. This task can be easily done with STM32CubeMX:

0690X00000609fwQAA.png

Regards

Szymon

Posted on February 21, 2018 at 01:28

Thank you for this info. Yeah I went over the datasheet before creating the PCB and this was not very clear to me. Do you mind mentioning which page you are referring to and possible a small explanation? The datasheet in regards to ADC and DAC is very confusing.

Posted on February 21, 2018 at 01:37

PA0 Channel1 of ADC1

PA1

Channel2 of ADC1

PA2

Channel3 of ADC1

PA3

Channel4 of ADC1

PA4 Channel5 of ADC1 or Channel 1 of DAC1

0690X00000604OzQAI.jpg
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..