2022-04-28 05:12 AM
Hello,
I set one of GPIO to Analog mode and I want to read its value, by using HAL library.
Should I just use HAL_GPIO_ReadPin to read the value?
Thank you.
Solved! Go to Solution.
2022-04-28 06:24 AM
Yes, so it can only read a digital value (0 or 1) rather than an analog value.
2022-04-28 05:25 AM
In analog mode, the digital input circuit is turned off and the input value reads as 0 regardless of the voltage.
2022-04-28 05:32 AM
Thank you gbm
I am using STM32F105, and I connect an analog signal to PB10. In this case I want to monitor analog value. So base on you answer, I get 0 all time?
2022-04-28 06:14 AM
HAL_GPIO_ReadPin reads IDR which is disconnected in analog mode. You need to set the pin to input mode, or use the ADC to read the value.
2022-04-28 06:17 AM
Thank you TDK
there is no ADC mode for PB10
so I have to use GPIO_input mode?
2022-04-28 06:24 AM
Yes, so it can only read a digital value (0 or 1) rather than an analog value.
2022-04-28 06:32 AM
Just want to be sure that there is no way to read analog value (not digital value) from PB10 ?
2022-04-28 06:36 AM
2022-04-28 06:42 AM
Thank you @TDK
2024-01-09 11:30 PM
This pin does not allow ADC reading, but why is there an option called GPIO Analog?