Open flute2k3 opened 1 year ago
The DAC buffer is indeed turned on by default.
Sounds like we should disable the DAC altogether when analogWrite(0);
is called and output LOW as a GPIO pin? How bad is the offset at analogWrite(1);? is it a general offset that is always there as long as the buffer is enabled?
the output changes proportionally with 1, 2 ... etc, it is a constant offset as far as I tested.
So when you put
dac_output_buffer_disable(DAC0);
dac_output_buffer_disable(DAC1);
after every analogWrite()
call, the offset problem is mostly gone and the DAC output curve is more ideal?
I tested writing 0 on a standalone bluepill plus board, without dac_output_buffer_disable(DAC0); PA4 = 6.303 mV with dac_output_buffer_disable(DAC0); PA4 = 0.228 mV it makes notable difference at 0 output now.
We can definitely add an API for this but I'm not sure if this should be the default behavior. The datasheet says that the purpose of the buffer is to provide a low-impedence output that can directly drive stuff without needing an external opamp. I can't repredict the user's application for this, whether the drive capability or voltage accuracy is more important :( .
A static +6mV offset in a total voltage swing of 3300mV doesn't seem neck-breaking to me, but I'm also willing to be convinced of the opposite.
keep the default maxgerhardt, no action needed, I will use dac_output_buffer_disable(DAC0) for my application :-) cheers ~
I noticed that with analogWrite() function, even I put 0, the output is not zero, something around xx - xxx mV, I happened to find that it is due to DAC buffer on - maybe by default? refer to below link ... I have no negative power available so this non-zero output is a little bit disturbing.
Is that possible we can turn the buffer off to get the zero voltage output using Arduino way? I anyway have to connect a buffer using low drift opamp so it does not matter.
https://stcommunity.st.com/t5/stm32-mcu-products/minimum-dac-output-voltage-on-stm32f30x/m-p/410862