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

Add VREF, TEMPSENSOR, VBAT internal channels to the stm32 adc driver #17375

Closed
StefJar opened this issue Jul 5, 2019 · 15 comments
Closed

Add VREF, TEMPSENSOR, VBAT internal channels to the stm32 adc driver #17375

StefJar opened this issue Jul 5, 2019 · 15 comments
Assignees
Labels
Enhancement Changes/Updates/Additions to existing features platform: STM32 ST Micro STM32

Comments

@StefJar
Copy link

StefJar commented Jul 5, 2019

The current stm32 adc driver is missing the internal channels. Would be great to have at least VREF avaible to improve the reference of the measurement.

@StefJar StefJar added the Enhancement Changes/Updates/Additions to existing features label Jul 5, 2019
@cybertale
Copy link
Collaborator

Valuable suggestion, I'm currently busy on the dma driver of stm32 in Zephyr. Feel free to try to add it yourself or wait for me or some others to add this support later.

@erwango erwango added the platform: STM32 ST Micro STM32 label Jul 22, 2019
@StefJar
Copy link
Author

StefJar commented Sep 23, 2019

hey ho
@cybertale did do have any progress on that?

@cybertale
Copy link
Collaborator

@StefJar Sorry, the DMA driver is still not finished. 😥

@StefJar
Copy link
Author

StefJar commented Sep 30, 2019

I wrote a simple ADC1 DMA demo driver for the STM32F4 MCU. It works fine for my purposes. I put it on github: https://github.com/StefJar/zephyr_stm32_adc1_dma_driver
Maybe @cybertale it can be used as a blueprint for a async AD1 driver using DMA and internal channels ;)

@cybertale
Copy link
Collaborator

cybertale commented Sep 30, 2019

@StefJar Thanks for the code! The DMA driver is very close to be merged. I also wanted to add DMA support to the ADC driver, because in zephyr, interrupt is handled first by the OS then our thread, so it becomes a bit slower, thus measuring a sequence of ADC channels is not possible since we have to retrieve ADC result every end of conversion (irq thread in zephyr is slower as I mentioned but ADC conversion can be very fast). After the DMA driver is merged, the first thing I would do in zephyr would be adding DMA support for the ADC driver.
But I think I can help to add the support for internal channel since the DMA PR needs review now.

@martinjaeger
Copy link
Member

Is there any progress on this, as the DMA PR is merged now?

We are currently working on ADC + DMA for the STM32G4 and also need to read out the internal channels.

@StefJar
Copy link
Author

StefJar commented Jan 7, 2020

as far as I know the DMA driver got updated, but the ADC driver is not updated yet.

@cybertale
Copy link
Collaborator

So sorry guys, I'm busying on my graduation project these several months, what's worse is that my private local server just got attacked several days ago by ransomware and I lost 4TB data, I'm busying on recovering my files now. Have to working on this later.

@ikerperezdelpalomar
Copy link

ikerperezdelpalomar commented Aug 18, 2020

Hello. I was wondering how are you interested in approach this task. Are you interested on being able to use APIs like LL_ADC_CHANNEL_TEMPSENSOR and LL_ADC_CHANNEL_VREFINT to enable each of them? That would cause that if TEMPSENSOR is enabled VBAT can't be used and vice versa, other choice would be to actively switch between them, but that would involve more logic.

@erwango
Copy link
Member

erwango commented Jun 4, 2021

@ikerperezdelpalomar Can you check if this issue could be closed, following mege of #34673 ?
Txs

@StefJar
Copy link
Author

StefJar commented Jun 4, 2021

this issue was partially fixed through #34673.
@erwango it works for me with that stage. Lets close it for now

@StefJar StefJar closed this as completed Jun 4, 2021
@ycsin
Copy link
Collaborator

ycsin commented Jan 12, 2022

@StefJar #34673 solve the TEMPSENSOR part of this issue, but are you aware of anything that can read the VBAT?

@ycsin
Copy link
Collaborator

ycsin commented Jan 12, 2022

2a96cc0 added support for internal voltage reference source but left out the VBAT, I modified the code to include VBAT:

	if (__LL_ADC_CHANNEL_TO_DECIMAL_NB(ADC_CHANNEL_TEMPSENSOR) == channel_cfg->channel_id) {
		adc_stm32_set_common_path(dev, LL_ADC_PATH_INTERNAL_TEMPSENSOR);
	} else if (__LL_ADC_CHANNEL_TO_DECIMAL_NB(ADC_CHANNEL_VREFINT) == channel_cfg->channel_id) {
		adc_stm32_set_common_path(dev, LL_ADC_PATH_INTERNAL_VREFINT);
	} else if (__LL_ADC_CHANNEL_TO_DECIMAL_NB(ADC_CHANNEL_VBAT) == channel_cfg->channel_id) {
		adc_stm32_set_common_path(dev, LL_ADC_PATH_INTERNAL_VBAT);
	}

But the ADC value I got doesn't match the voltage on the VBAT.

@ycsin
Copy link
Collaborator

ycsin commented Jan 12, 2022

@erwango you have any idea bout this? Should I create a new issue or reopen this?

@erwango
Copy link
Member

erwango commented Jan 12, 2022

@ycsin Please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Changes/Updates/Additions to existing features platform: STM32 ST Micro STM32
Projects
None yet
Development

No branches or pull requests

6 participants