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

ADC generic driver missing features: calibration, reference voltage value #11922

Closed
pabigot opened this issue Dec 7, 2018 · 4 comments
Closed
Assignees
Labels
area: ADC Analog-to-Digital Converter (ADC) area: Drivers Enhancement Changes/Updates/Additions to existing features

Comments

@pabigot
Copy link
Collaborator

pabigot commented Dec 7, 2018

The Nordic SAADC peripheral has a calibration feature that's supposed to be initiated before the first use. The existing generic ADC driver does not have a way to initiate this. Since configuring ADC through the "generic" API requires including the SOC headers anyway, I'm just calibrating manually.

Also there's an option to use the internal reference voltage, but no way to fetch the value of that voltage for whatever board you're running on so the measurement in ADC counts can be converted to a voltage. The value isn't even in the nrfx HAL as far as I can tell.

@carlescufi carlescufi added area: Drivers area: ADC Analog-to-Digital Converter (ADC) Enhancement Changes/Updates/Additions to existing features labels Dec 7, 2018
@carlescufi
Copy link
Member

@anangl was the person leading the ADC API rework that took place recently.

@Qbicz
Copy link
Collaborator

Qbicz commented Dec 10, 2018

Thumbs up, I would be happy to see SAADC calibration feature added.

@pabigot
Copy link
Collaborator Author

pabigot commented Dec 26, 2018

When somebody comes to support retrieving the internal reference voltage here's what I've found:

  • For CONFIG_ADC_NRFX_ADC it's 1200 mV
  • For CONFIG_ADC_NRFX_SAADC it's 600 mV
  • For ARC Designware ADC the information is not publicly available
  • For Intel Quark D2000 it's either 3.3V or the battery voltage
  • For Kinetis (MCUX_ADC16) there is no internal reference voltage, although ADC_REF_INTERNAL is the only permitted configuration. The actual reference voltage is selected from one of two external choices, possibly constrained by the PCB, and fixed via Kconfig.
  • For Atmel SAM AFEC it's either 3.3V or 5.0V. For sam_e70_xplained it appears to be 3300 mV.
  • No other platforms implement this API.

Looking at the huge variation in ADC support across just these few platforms I suspect it would be wiser to reduce the complexity of the ADC API to a bare-bones set of operations that do not attempt to provide a generic API for things like channel configuration, acquisition time, resolution, or sequencing.

Or just remove it and accept that doing ADC requires a platform-specific driver with no generic abstraction, which would probably be a more maintainable and simpler approach.

pabigot added a commit to pabigot/zephyr that referenced this issue Apr 29, 2019
Without this there's no point providing ADC_REF_INTERNAL as an option.

Relates-to: issue zephyrproject-rtos#11922
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
pabigot added a commit to pabigot/zephyr that referenced this issue Apr 29, 2019
Add a flag to the sequence structure that tells the driver it should
calibrate the ADC prior to initiating the sample.

Implement this for nRF SAADC.  The implementation supports the
workarounds for PAN-86 and PAN-178.

Relates-to: issue zephyrproject-rtos#11922
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
pabigot added a commit to pabigot/zephyr that referenced this issue May 11, 2019
Add a flag to the sequence structure that tells the driver it should
calibrate the ADC prior to initiating the sample.

Implement this for nRF SAADC.  The implementation supports the
workarounds for PAN-86 and PAN-178.

Relates-to: issue zephyrproject-rtos#11922
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
nashif pushed a commit that referenced this issue May 30, 2019
Add a flag to the sequence structure that tells the driver it should
calibrate the ADC prior to initiating the sample.

Implement this for nRF SAADC.  The implementation supports the
workarounds for PAN-86 and PAN-178.

Relates-to: issue #11922
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
pabigot added a commit to pabigot/zephyr that referenced this issue Jul 30, 2019
Required for any real-world use of ADC_REF_INTERNAL.

Relates-to: issue zephyrproject-rtos#11922
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
carlescufi pushed a commit that referenced this issue Aug 1, 2019
Required for any real-world use of ADC_REF_INTERNAL.

Relates-to: issue #11922
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
@pabigot
Copy link
Collaborator Author

pabigot commented Aug 1, 2019

Looks like calibration and reference voltage APIs are now both present, so if there's a problem with them that can be a new issue.

@pabigot pabigot closed this as completed Aug 1, 2019
LeiW000 pushed a commit to LeiW000/zephyr that referenced this issue Sep 2, 2019
Required for any real-world use of ADC_REF_INTERNAL.

Relates-to: issue zephyrproject-rtos#11922
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
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) area: Drivers Enhancement Changes/Updates/Additions to existing features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants