cancel
Showing results for 
Search instead for 
Did you mean: 

Connect/disconnect DAC from pin on the fly for a diagnostic test?

KDesr.1
Associate II

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.

1 ACCEPTED SOLUTION

Accepted Solutions
KDesr.1
Associate II

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!

View solution in original post

5 REPLIES 5
LCE
Principal

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.

KDesr.1
Associate II

I believe the pin is higher impedance in analog mode, no?

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.

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.

KDesr.1
Associate II

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!