Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is purpose of the CONFIG_ADC_X #24751

Closed
susundberg opened this issue Apr 28, 2020 · 3 comments
Closed

What is purpose of the CONFIG_ADC_X #24751

susundberg opened this issue Apr 28, 2020 · 3 comments
Assignees
Labels
area: ADC Analog-to-Digital Converter (ADC) platform: STM32 ST Micro STM32

Comments

@susundberg
Copy link
Contributor

Describe the bug
This probably issue in documentation / my understanding but i feel confused what is CONFIG_ADC_1 for example trying to do.

I am testing with stm32_min_dev_blue and the ADC seems to work just fine without enabling the CONFIG_ADC_1.

While grepping for CONFIG_ADC_xyz from boards/st/ directory it seems some variants have pin-muxing, for example ./nucleo_f103rb/pinmux.c:

#ifdef CONFIG_ADC_1
        {STM32_PIN_PA0, STM32F1_PINMUX_FUNC_PA0_ADC123_IN0},
#endif /* CONFIG_ADC_1 */

That apparantly pinmuxes channel 0 (to what is default-on-boot: analog). Then what about other channels? In my tests, for example PB0 that is ADC1_IN8 works just fine.

Expected behavior
ADC_1 does not work if the ADC_1 is not enabled.

Impact
No impact.

@susundberg susundberg added the bug The issue is a bug, or the PR is fixing a bug label Apr 28, 2020
@carlescufi carlescufi added question and removed bug The issue is a bug, or the PR is fixing a bug labels Apr 28, 2020
@erwango erwango added area: ADC Analog-to-Digital Converter (ADC) platform: STM32 ST Micro STM32 labels Apr 28, 2020
@ABOSTM
Copy link
Collaborator

ABOSTM commented Apr 28, 2020

Hi @susundberg,
You are right, CONFIG_ADC_1 is used to configure pinmux ADC channel to Analog,
but is is also used in drivers/adc/adc_shell.c.
Because Analog is the default mode after reset for this chip, your ADC works. even if you didn't activate CONFIG_ADC_1 and even if you didn't declare your PIN for channel8. So you are lucky.
But you may had trouble using adc shell.

Then what about other channels?

We declared only 1 channel as example and you can customize it depending on your needs.
But it would be a shame to declare all 16 channels when only 1 is needed, in some way it would reserve 16 pins.

@susundberg
Copy link
Contributor Author

susundberg commented Apr 29, 2020

I undestand this - and for my behalf one can close this issue.

But if its to enable ADC1 channel 0 should it not be called ADC1_CH0 ? I got confused by the name of ADC1 -- that surely to me seems like peripheral ADC1. And on the other hand, why should not there be ADC1_CH8 then? That would also document (i see the pinmux as documentation, of what pin is used but again, this is just me) the specific pin used in the pinmux.c.

(btw: checking another older project with stm32f4 seems to put the analog in pins to nopull, analog)

Ty for reply.

@erwango
Copy link
Member

erwango commented May 4, 2020

@susundberg We're closing this PR as CONFIG_ADC_X symbols are being removed and replaced by dts nodes.

But if its to enable ADC1 channel 0 should it not be called ADC1_CH0 ? I got confused by the name of ADC1 -- that surely to me seems like peripheral ADC1. And on the other hand, why should not there be ADC1_CH8 then? That would also document (i see the pinmux as documentation, of what pin is used but again, this is just me) the specific pin used in the pinmux.c.

We don't have this granularity.
But I agree current solution is not a prefect fit. Next step is to move pinmux.c to device tree. I hope this will help to make things clearer.

@erwango erwango closed this as completed May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ADC Analog-to-Digital Converter (ADC) platform: STM32 ST Micro STM32
Projects
None yet
Development

No branches or pull requests

6 participants