dac.rst 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. Digital To Analog Converter
  2. ===========================
  3. Overview
  4. --------
  5. ESP32 has two 8-bit DAC (digital to analog converter) channels, connected to GPIO25 (Channel 1) and GPIO26 (Channel 2).
  6. The DAC driver allows these channels to be set to arbitrary voltages.
  7. The DAC channels can also be driven with DMA-style written sample data, via the :doc:`I2S driver <i2s>` when using the "built-in DAC mode".
  8. For other analog output options, see the :doc:`Sigma-delta Modulation module <sigmadelta>` and the :doc:`LED Control module <ledc>`. Both these modules produce high frequency PWM output, which can be hardware low-pass filtered in order to generate a lower frequency analog output.
  9. Application Example
  10. -------------------
  11. Setting DAC channel 1 (GPIO 25) voltage to approx 0.78 of VDD_A voltage (VDD * 200 / 255). For VDD_A 3.3V, this is 2.59V::
  12. #include <driver/dac.h>
  13. ...
  14. dac_output_enable(DAC_CHANNEL_1);
  15. dac_output_voltage(DAC_CHANNEL_1, 200);
  16. API Reference
  17. -------------
  18. Header Files
  19. ^^^^^^^^^^^^
  20. * `components/driver/include/driver/dac.h`
  21. Enumerations
  22. ^^^^^^^^^^^^
  23. .. doxygenenum:: dac_channel_t
  24. Functions
  25. ^^^^^^^^^
  26. .. doxygenfunction:: dac_output_voltage
  27. .. doxygenfunction:: dac_output_enable
  28. .. doxygenfunction:: dac_output_disable
  29. .. doxygenfunction:: dac_i2s_enable
  30. .. doxygenfunction:: dac_i2s_disable