2023-05-16 07:42 AM
I have an analog circuit that is read by an ADC input. I would like to have a self-diagnostic function where I inject a known signal to the input of that circuit with the DAC for a self test, then disconnect the DAC from the pin and leave the pin in analog mode for normal operation. I would like the pin to be in a high impedance state so as not to affect the circuit during normal use. What would be the best way to do this?
My thought is to switch from:
sConfig.DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_EXTERNAL;
to
sConfig.DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_INTERNAL;
with a HAL_DAC_ConfigChannel call after my diagnostic completes.
Solved! Go to Solution.
2023-05-17 10:25 AM
Well, it wasn't that complicated. The DAC doesn't interfere with the input until you execute the HAL_DAC_Start command. It stops interfering (i.e. the pin goes high impedance) when you execute the HAL_DAC_Stop command. Really easy!
2023-05-16 08:13 AM
I think you should also reset the GPIO to input, without pull-up and without alternate function.
But I don't know how high the input's impedance really is. So make sure that you have a low impedance source, BUT also make sure that the source is OFF or high Z while using the DAC.
2023-05-16 08:16 AM
I believe the pin is higher impedance in analog mode, no?
2023-05-16 08:25 AM
Good question, check the datasheet...
Edit: just checked the H723 RM, it looks like you are correct, so use analog mode.
At least the Schmitt-trigger is off, and so are the pull-* resistors.
2023-05-16 08:49 AM
That is what I surmised from the datasheet as well. Those set to off when the DAC is initialized by the HAL function, so I am thinking I can either just use the HAL function in the op or a direct write to the DAC_MCR register to disconnect the DAC from the pin.
2023-05-17 10:25 AM
Well, it wasn't that complicated. The DAC doesn't interfere with the input until you execute the HAL_DAC_Start command. It stops interfering (i.e. the pin goes high impedance) when you execute the HAL_DAC_Stop command. Really easy!