ESP32 write to DAC very long (slow)


#1

Simple test:

import dac

pinMode(D2, OUTPUT)
my_dac = dac.DAC(D25.DAC)
my_dac.start()

while True:

my_dac.write(255)

digitalWrite(D2, HIGH)

my_dac.write(255)

digitalWrite(D2, LOW)

If you run this code, the LED flashes at a frequency of 1 second. Which makes the use of DAC completely useless.


#2

However, if you write “my_dac.write(255,0,0)” the speed works fine.

Perhaps it is necessary to specify in the documentation?


#3

Thanks for pointing that out, We will be working on the documentation of the DAC to illustrate that.


#4

Hi @trawen

I’ve taken a deeper look and there seems to be a little issue with the esp32 DAC code: could you try to open the vhal_dac.c file under ZERYNTH_INSTALLATION/dist/r2.1.2/vhal/xtensa-lx6/esp32 (where ZERYNTH_INSTALLATION is C:\Users\USERNAME\zerynth2 under Windows and /home/USERNAME/.zerynth2 under GNU/Linux and Mac) and place under

dac_output_voltage(ch,(uint8_t)data[i]);

the following line:

if (i == len-1) break;

We will fix officially with the next patch.
Let me know :slight_smile: