mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-10 04:43:33 +00:00
Merge branch 'bugfix/fix_adc_dac_driver_ut' into 'master'
Driver(adc): fix adc driver and UT See merge request espressif/esp-idf!8482
This commit is contained in:
@@ -22,15 +22,20 @@ Overview
|
||||
|
||||
.. only:: esp32s2
|
||||
|
||||
The {IDF_TARGET_NAME} integrates two 12-bit SAR (`Successive Approximation Register <https://en.wikipedia.org/wiki/Successive_approximation_ADC>`_) ADCs supporting a total of 20 measurement channels (analog enabled pins).
|
||||
The {IDF_TARGET_NAME} integrates two 13-bit SAR (`Successive Approximation Register <https://en.wikipedia.org/wiki/Successive_approximation_ADC>`_) ADCs supporting a total of 20 measurement channels (analog enabled pins).
|
||||
|
||||
The ADC driver API supports ADC1 (10 channels, attached to GPIOs 1 - 10), and ADC2 (10 channels, attached to GPIOs 11 - 20). However, the usage of ADC2 has some restrictions for the application:
|
||||
|
||||
1. ADC2 is used by the Wi-Fi driver. Therefore the application can only use ADC2 when the Wi-Fi driver has not started.
|
||||
1. Different from ADC1, the hardware arbiter function is added to ADC2, so when using the API of ADC2 to obtain the sampling voltage, you need to judge whether the result is successfully arbitrated.
|
||||
|
||||
Configuration and Reading ADC
|
||||
-----------------------------
|
||||
|
||||
Each ADC unit supports two work modes, ADC-RTC or ADC-DMA mode. ADC-RTC is controlled by the RTC controller and is suitable for low-frequency sampling operations. ADC-DMA is controlled by a digital controller and is suitable for high-frequency continuous sampling actions.
|
||||
|
||||
ADC-RTC mode
|
||||
^^^^^^^^^^^^
|
||||
|
||||
The ADC should be configured before reading is taken.
|
||||
|
||||
- For ADC1, configure desired precision and attenuation by calling functions :cpp:func:`adc1_config_width` and :cpp:func:`adc1_config_channel_atten`.
|
||||
@@ -50,6 +55,11 @@ This API provides convenient way to configure ADC1 for reading from :doc:`ULP <.
|
||||
|
||||
There is another specific function :cpp:func:`adc2_vref_to_gpio` used to route internal reference voltage to a GPIO pin. It comes handy to calibrate ADC reading and this is discussed in section :ref:`adc-api-adc-calibration`.
|
||||
|
||||
.. todo::
|
||||
|
||||
1. Add `ADC-DMA mode` configuration after ADC-DMA driver done.
|
||||
2. Add table for ADC-DMA clock system.
|
||||
|
||||
Application Examples
|
||||
--------------------
|
||||
|
||||
@@ -97,8 +107,13 @@ An example using the ADC2 driver to read the output of DAC is available in esp-i
|
||||
int val = hall_sensor_read();
|
||||
|
||||
|
||||
.. only:: esp32
|
||||
|
||||
The value read in both these examples is 12 bits wide (range 0-4095).
|
||||
The value read in both these examples is 12 bits wide (range 0-4095).
|
||||
|
||||
.. only:: esp32s2
|
||||
|
||||
The value read in both these examples is 13 bits wide (range 0-8191).
|
||||
|
||||
.. _adc-api-adc-calibration:
|
||||
|
||||
@@ -248,6 +263,8 @@ ADC driver
|
||||
|
||||
.. include-build-file:: inc/adc_types.inc
|
||||
|
||||
.. include-build-file:: inc/adc_common.inc
|
||||
|
||||
.. _adc-api-reference-adc-calibration:
|
||||
|
||||
ADC Calibration
|
||||
|
Reference in New Issue
Block a user