correct use of GPIO_Analog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-02 1:02 PM - last edited on ‎2025-03-22 6:24 AM by Andrew Neil
Hello. I have a question about the correct use of GIPO_Analog.
wanted to read this value.
I also want to know if the value can vary between 0 to 4095 as when the ADC is used.
am I using an MCU that I use Nuclo-F446RE?
Solved! Go to Solution.
- Labels:
-
ADC
-
STM32F4 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-04 1:08 AM
Hola Breno,
well, I guess by value you mean the value of the ADC reading one of its analog channels which in turn is connected to a GPIO, right?
The ADC can be set to different resolutions between 6...12bit, corresponding to values between 0...63 (6bit) to 0...4095 (12bit). So yes, you will get an ADC value between 0...4095 if you set the ADC to 12bit.
But what does this value stand for?
Well, the ADC needs a reference to compare the measured voltage to it. Due to pin count limitation on your NUCLEO-F446RE, which uses a LQFP-64 package, this reference voltage is connected to the supply voltage of your NUCLEO, i.e. to about 3.3V. Therefore, in your case and with 12bit resolution, the ADC value corresponds to a voltage of: Vgpio = (VALUEadc / (2^12-1)) * VDD
The exact value of VDD is unfortunately unknown or is only estimated, which is why a so-called ratiometric measurement is often carried out. To do this, you need at least a second measurement of a known reference voltage - either the built-in or a high-precision external one.
I'd really recommend to read section 13 of the Reference Manual of the STM32F446, where you will find a detailed decription of the three ADCs of that microcontroller.
In addition you could have a look at some of our video tutorials, e.g.
- STM32CubeMX basics: 13.1 STM32Cube HAL labs ADC - Lab ADC IT
- STM32CubeMX basics: 13.2 STM32Cube HAL labs ADC - Lab ADC DMA
- STM32CubeIDE basics - 10 ADC DMA TIM HAL lab
When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.
Good luck!
/Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-03 4:34 AM
Unfortunately, it is not clear what you are asking for.
Maybe there is some way to use the Google Translator?
Regards
/Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-03 4:38 AM
It is also a good habit to have a not to long title and the question in the text with surrounding explanation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-03 2:05 PM
my friends, I made the correction, now the idea must be more elaborated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-04 1:08 AM
Hola Breno,
well, I guess by value you mean the value of the ADC reading one of its analog channels which in turn is connected to a GPIO, right?
The ADC can be set to different resolutions between 6...12bit, corresponding to values between 0...63 (6bit) to 0...4095 (12bit). So yes, you will get an ADC value between 0...4095 if you set the ADC to 12bit.
But what does this value stand for?
Well, the ADC needs a reference to compare the measured voltage to it. Due to pin count limitation on your NUCLEO-F446RE, which uses a LQFP-64 package, this reference voltage is connected to the supply voltage of your NUCLEO, i.e. to about 3.3V. Therefore, in your case and with 12bit resolution, the ADC value corresponds to a voltage of: Vgpio = (VALUEadc / (2^12-1)) * VDD
The exact value of VDD is unfortunately unknown or is only estimated, which is why a so-called ratiometric measurement is often carried out. To do this, you need at least a second measurement of a known reference voltage - either the built-in or a high-precision external one.
I'd really recommend to read section 13 of the Reference Manual of the STM32F446, where you will find a detailed decription of the three ADCs of that microcontroller.
In addition you could have a look at some of our video tutorials, e.g.
- STM32CubeMX basics: 13.1 STM32Cube HAL labs ADC - Lab ADC IT
- STM32CubeMX basics: 13.2 STM32Cube HAL labs ADC - Lab ADC DMA
- STM32CubeIDE basics - 10 ADC DMA TIM HAL lab
When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.
Good luck!
/Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-05 2:12 AM
@Peter BENSCH​ Thanks for the tip!
I will follow your directions. :beaming_face_with_smiling_eyes:
