Skip to content

Commit b51d676

Browse files
committed
STM32: analog_out: Enable Buffer and switch
ADC1 channel2 and ADC2 of few targets only have an output switch and no buffer. This switch needs to be enabled, and also the buffer can be enabled in order to reduce the output impedance on output, and to drive external loads directly without having to add an external operational amplifier.
1 parent cdd581b commit b51d676

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

targets/TARGET_STM/TARGET_STM32F3/analogout_api.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,15 @@ void analogout_init(dac_t *obj, PinName pin) {
8787
obj->handle.Instance = (DAC_TypeDef *)(obj->dac);
8888

8989
sConfig.DAC_Trigger = DAC_TRIGGER_NONE;
90-
sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_DISABLE;
91-
90+
/* Enable both Buffer and Switch in the configuration,
91+
* letting HAL layer in charge of selecting either one
92+
* or the other depending on the actual DAC instance and
93+
* channel being configured.
94+
*/
95+
sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE;
96+
#if defined(DAC_OUTPUTSWITCH_ENABLE)
97+
sConfig.DAC_OutputSwitch = DAC_OUTPUTSWITCH_ENABLE;
98+
#endif
9299

93100
if (pin == PA_4) {
94101
pa4_used = 1;

0 commit comments

Comments
 (0)