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 (espressif.com) 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:
  dac_output_enable(DAC_CHANNEL_1);
}

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

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
    };

    dac_cw_generator_config(&dac_cw_config);
    dac_output_enable(DAC_CHANNEL_1);
    dac_cw_generator_enable();

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.