Skip to main content
KDesr.1
Associate III
May 16, 2023
Solved

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

  • May 16, 2023
  • 3 replies
  • 1804 views

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.

This topic has been closed for replies.
Best answer by KDesr.1

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!

3 replies

LCE
Principal II
May 16, 2023

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
KDesr.1Author
Associate III
May 16, 2023

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

LCE
Principal II
May 16, 2023

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.

KDesr.1
KDesr.1Author
Associate III
May 16, 2023

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
KDesr.1AuthorBest answer
Associate III
May 17, 2023

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!