Configuring and reading "GPIO Analog"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-15 12:52 PM - edited ‎2023-11-20 5:24 AM
Using the STM32MP157 development kit, I have configured two "GPIO Analog" lines that are exposed through CN13 (pins 1 and 2).
I am trying to set these up as such. From going down the rabbit trail of documentation:
https://wiki.st.com/stm32mpu/wiki/GPIO_internal_peripheral#Software_frameworks
https://wiki.stmicroelectronics.cn/stm32mpu/wiki/GPIOLib_overview
and then:
https://wiki.stmicroelectronics.cn/stm32mpu/wiki/Overview_of_GPIO_pins
https://wiki.stmicroelectronics.cn/stm32mpu/wiki/Pinctrl_overview
It seems to confirm that I need to use "pinctrl" technique to set these. Okay. I have configured them with CubeMX. However, my DTS file doesn't reference these pins at all.
I've gone through the exported DTS and I do not see anything referencing PG3, or PH6.
So, I feel like this has failed at the outset.
Is there a trick to this? I assume once I get these configured I can read the value using libgpio API functions.
Solved! Go to Solution.
- Labels:
-
STM32MP15 Lines
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-16 6:33 AM - edited ‎2023-11-20 5:25 AM
I agree ADC connections are quite complex to fully master.
Best for this ADC pin choice is to use CubeMX.
You could find information in Product Reference Manual, ADC section
e.g.
together with Product Datasheet pin list, looking in additional function column
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-15 11:29 PM
Hi @Community member​
I think CubeMX does not generate anything in pinctrl unless those pins are used by a peripheral.
If you want to keep GPIO in analog mode to save power (barely visible gain), you don't have to do anything as this is the default setting.
Does analog mean you are asking for ADC conversion ?
If yes, please had a look to
https://wiki.st.com/stm32mpu/wiki/ADC_device_tree_configuration
https://wiki.st.com/stm32mpu/wiki/ADC_OpenSTLinux_drivers
https://wiki.st.com/stm32mpu/wiki/IIO_overview
Regards,
In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-16 5:17 AM
Thank you for your answer. I want the GPIO in analog mode to read input from it. I have looked at all those pages. I am currently using the ADC channels for a few inputs. Following those readings I did not attempt to apply those to GPIO Analog inputs. I can. To this section, I could add:
adc_pins_mx: adc_mx-0 {
pinmux = <STM32_PINMUX('G', 3, ANALOG)>; /* GPIO Analog */
<STM32_PINMUX('H', 6, ANALOG)>; /* GPIO Analog */
}
(There are other items in this list, I just abbreviated it)
Then, if I go a bit down I've previously added input channels like so
adc1:adc@0{
status = "okay";
channel@0{
reg = <0>;
st,min-sample-time-ns = <5000>;
};
};
But these all reference "channel" which is the INP number on the ADC channel. The GPIO does not have an ADC channel ... I don't know how to expose it. The documentation makes sense - but not for the GPIO analog inputs. So I am looking to close that configuration/knowledge gap.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-16 5:33 AM
Hi,
Please refer to product datasheet pinout to see which GPIO have ADC capabilities.
All GPIOs have analog mode (for power saving in order to disable logic driver and receiver), but this does not mean there is an ADC connected to it.
There is no way to 'read' from GPIO analog unless using ADC to acquire the analog voltage on available ADC channels on specific GPIO pins.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-16 5:59 AM
Thank you. That actually makes perfect sense. They are all analog capable, as it's just a setting to lower power. However, to read actual analog signal they must be attached to an internal ADC peripheral. The datasheet is sparse. However, the Reference Manual has quite a bit of information about GPIOs. What I don't see is an indication about what GPIO inputs might have an ADC backend. But I'm not sure what exactly I am looking for in that regard.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-16 6:33 AM - edited ‎2023-11-20 5:25 AM
I agree ADC connections are quite complex to fully master.
Best for this ADC pin choice is to use CubeMX.
You could find information in Product Reference Manual, ADC section
e.g.
together with Product Datasheet pin list, looking in additional function column
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-16 6:40 AM
Thank you. That helped me determine what I was looking for in the datasheet!
