0
\$\begingroup\$

I have an application where I need to use one pin as a digital output and analog input. I switch between input and output at a "high" frequency (>1 kHz) and it takes to much time to disable and enable the ADC-Channel all the time. When the ADC-Channel is enabled, it's not possible to use the pin as output pin and set it ti low or high. The voltage level will be at (Vgnd - Vcc)/2.

This works with the AVR Arduino boards (like the Arduino Uno) but not with the ARM version (like the Arduino due).

asked Oct 29, 2013 at 9:54
\$\endgroup\$
5
  • \$\begingroup\$ Can you post a link to an application example of this please? I'd like to see how this is implimented. My first thoughts are the Arm is running faster and so would need longer in clock cycles/instructions before the ADC settles. The same would apply to the output being on/off. This depends on the external components (R/C network) and how much pull up pull down the pin is capable of. \$\endgroup\$ Commented Oct 29, 2013 at 13:34
  • \$\begingroup\$ The ADC itself works. But if you measure the voltage of the output-pin it will always be at (Vgnd - Vcc)/2. The only way I can get it to work is to disable the ADC channel and then enable it again if I want to measure. But this is does not work fast enough. \$\endgroup\$ Commented Oct 29, 2013 at 19:31
  • \$\begingroup\$ Do you have measurements to compare? Is the code the same? \$\endgroup\$ Commented Oct 30, 2013 at 8:01
  • \$\begingroup\$ On other microcontrollers (STM32 series), you can flip between multiple functions on a GPIO by setting the IO type (in this case, switching between analog input and digital output) without disabling the peripheral. So, in the case of the STM32, you could leave the ADC enabled and configured and just change the mux setting for the IO. Check your datasheet in the GPIO section and see if you can just change the mux. \$\endgroup\$ Commented Oct 31, 2013 at 2:49
  • \$\begingroup\$ Also, this sounds like a capacitive touch application. You might check and see if Atmel has any app notes on how to perform this function. \$\endgroup\$ Commented Oct 31, 2013 at 2:51

1 Answer 1

2
\$\begingroup\$

Here is a work around: Tie two pins electrically together.

  • One pin configured as digital tri-state output;
  • One configured as analog input.

Then use the digital pin to set a HIGH or LOW level and switch the digital pin to INPUT (tri-state) while you read the analog voltage from the analog pin.

answered Oct 29, 2013 at 21:12
\$\endgroup\$
1
  • \$\begingroup\$ I don't want to use multiple pins. \$\endgroup\$ Commented Oct 29, 2013 at 22:04

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.