So I try to use DAC.write_timed() and in this case this wave is not generated.
Amplitude of this wave:
- is proportional to DAC output (around 100mV (peak to peak) when the DAC output is close to max, around 0 when and DAC output is close to min).
- do not depend on other DAC parameters (buffering, bits).
Does anyone face this issue? Any idea of the root cause?
Here are some pictures to illustrate and corresponding code:
case = 0: case = 1: case = 2: I notice also that similar waves are visible every one second when only the REPL is running and each time a key is pressed in the REPL terminal on PC.
Code: Select all
from array import array import micropython from pyb import DAC micropython.alloc_emergency_exception_buf(100) def timerCbk(timer): global dac global y dac.write(y) dac = DAC(1, bits=12, buffering=False) DacUpdateFreq = 1000 y = 0 #case = 0 case = 1 #case = 2 if case == 0: dac.write(y) elif case == 1: timer = pyb.Timer(4, freq=DacUpdateFreq) timer.callback(timerCbk) elif case == 2: buf = array('H', int(y) for i in range(128)) dac.write_timed(buf, DacUpdateFreq, mode=DAC.CIRCULAR)
Also when the file system is accessed (saving a file to SD card for example), DAC output is perturbated.
Also some other pins are perturbated along with the DAC output (similar shape, wave amplitude always the same whatever DAC value).