cancel
Showing results for 
Search instead for 
Did you mean: 

GPIO Analog Mode vs Alternate Function ADC

SavasSahin
Associate II

Hello,

I am trying to do a voltage measurement, i know i can use ADC to do it.

What a gpio is capable of when it is configured as Analog Mode? Can it measure voltages? or Can it trigger an interrupt if a defined threshold exceeds?

I need a clarification for that since i could not figure it out from the datasheet or reference manual?

Thank you

3 REPLIES 3
TDK
Guru

What STM32?

If you want to measure voltages, you need to use the ADC with the pin in analog mode. If you're interested in when it crosses a threshold, the analog watchdog could be used to trigger an event based on the converted ADC value.

Some families have a comparator which can be used to detect a threshold, but won't give you a voltage reading.

https://www.st.com/resource/en/application_note/dm00074240-getting-started-with-analog-comparators-for-stm32f3-series-and-stm32g4-series-devices-stmicroelectronics.pdf

If you feel a post has answered your question, please click "Accept as Solution".
S.Ma
Principal

A GPIO pin put in "analog mode" just mean that. Analog could be ADC, DAC, comparator, etc.... it depends on what analog peripheral you activate.

ADC have channels, check the datasheet and reference manual (and errata sheet) to find which pin match which ADC channel.

Remember that most of the time, a pin that can be "analog" is up to 3.3V only (not 5V tolerant).

If you let the ADC keep scanning a channel, it most of the time have an analog watchdog feature to assist the core: It can generate a flag / interrupt when one ADC value has been out of user defined range...

Thank you, i understand now.