Problem with configuring DAC on ESP32

Hi guys!

I'm just trying to use the DAC on an ESP32 (Pico) as a "PWM" source. The usage is defined here: Digital To Analog Converter - ESP32 - — ESP-IDF Programming Guide latest documentation ( with the Arduino IDE 2.0

Right now I have the following code which compiles properly (I was not able to test it on a device yet):

#include <driver/dac.h>

void setup() {
  // put your setup code here, to run once:

void loop() {
  // put your main code here, to run repeatedly:
  dacWrite(25, 200); // or dac_output_voltage(DAC_CHANNEL_1, 200);
  dac_output_voltage(DAC_CHANNEL_1, 100); // or dacWrite(25, 100); 

I tried this (which I found in the internet):

    dac_cw_config_t dac_cw_config = {
        .en_ch = DAC_CHANNEL_1,
        .scale = DAC_CW_SCALE_1,
        .phase = DAC_CW_PHASE_180,
        .freq = 25000,
        .offset = 127


but this throws an error that all the dac_cw_xxx function are not declared in that scope. Trying to include driver/include/driver/dac_common.h as defined on the documentation page linked above throws the error, that no such file could be found.

So my main question is: How can I configure the DAC, especially the frequency (and what is the default frequency)?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.