STM32 gotchas
11.DAC output does not go rail-to-rail

Users sometimes observe, that they are unable to reach one of the rails (VREF-=VSSA and VREF+) or both, with setting the DAC to its extreme values.

In the older STM32 models, there's an inherent limitation - the DAC output, as per datasheet, can swing between 5mV and VREF+-1LSB (1LSB in 10-bit DAC with VREF around 3V is around 3mV). However, this limitation is not present on the newer 'Gx lines, and also users usually report more than that - sometimes up to tens of LSB, or tens of mV.

But reason for this is, that DAC in STM32 has a maybe surprisingly high output impedance. This is documented in the datasheet, the typical output impedances of DAC being around 15kΩ (exact value depending on particular STM32 model). The described effect is then just the consequence of excessive loading of the DAC towards some particular potential.

The STM32 DMA has also an optionally switchable output buffer. Those, who are aware of the high output impedance, might switch it on, just to find that it worsened the situation with reaching the rails. Indeed, according to datasheet, the output buffer's swing is within 0.2V of the rails. This is given by the limitation of used technology, which is primarily aimed at digital, rather than analog performance.

As an additional effect with this constraint, if the output buffer is overdriven, i.e. if DAC is set to output closer to rails than 0.2V, the buffer's opamp gets saturated, and coming out of this saturation results in a longer than expected transition.

So, if rail-to-rail operation of the DAC is desired, with higher loads, an external buffer has to be employed, or external DAC with desired parameters has to be used.