Teensy 3.2 Setting Output Pin to High Impedance (or blank)

Status
Not open for further replies.

PriyaL

New member
Hi, I am trying to use the Teensy 3.2 to output an analog voltage (using analogWrite on pin A14) then measure an impedance across two different pins. One problem I'm finding is that the way my design is mechanically set-up, there is interference from the A14 pin because its impedance is low. I tried setting the A14 pin as an input, but am finding that as a digital input, the A14 pin is actually still outputting low impedance. I was wondering if there's anyway I can "blank" the A14 pin so that it's back to its original high impedance state.

EDIT:
Source Code:
digitalWrite(A14, 3.1 * (4095 / 3.3)); //writes pin A14 to output 3.1V
pinMode(A14, INPUT); //sets A14 to input in order to try and switch pin to high impedance
digitalRead(A14); //fully sets A14 to input to try and get high impedance from pin

Output (from multimeter):
when A14 = 3.1V output => impedance = low
when A14 = input => impedance = low
what I want => impedance = high
 
Last edited:
I just realized that there was an error in the source code of my original post. I am using analogWrite, not digitalWrite (see corrected code below).

When I use the pinMode(pin,INPUT_DISABLE) function, I am still getting a low impedance. I think this may be because, I am trying to output an analog voltage signal, not a digital one. I think this is why the pinMode type functions are not working properly. Is there an analogous function similar to the pinMode(pin,INPUT_DISABLE) that would work for analog outputs?

Code:
//before code begins running, impedance = 19 MOhms
analogWrite(A14, 3.1 * (4095 / 3.3)); //impedance = 4 MOhms
pinMode(A14, INPUT_DISABLE); //impedance = 82 Ohms
//desired final impedance = 19 MOhms
 
The A14 pin has no link to the GPIO mux, so it can't be configured like a GPIO pin, but it is internally hardwired to the DAC output, the ADC mux input, and a comparator input. Thus, You'll most probably have to live with that stray impedance and modify your setup to take this into account.
 
If you've turned the DAC on using analogWrite(A14, someNumber), there isn't any Arduino style function to shut the DAC off. You'll need to do that by access the hardware register directly.

Try this:

Code:
  DAC0_C0 = 0;

This only applies to the DAC pins, A14 on Teensy 3.2, A21 & A22 on Teensy 3.5 & 3.6.

For all other pins with digital function, you would use pinMode(pin, INPUT_DISABLE);
 
Last edited:
Yes, that code snippet didn't agree with the Text - that is why Frank_B posted his note I think.

Not an EE - but to disable a digital capable pin back to HIGH impedance at any point : pinMode(pin,INPUT_DISABLE)

Once the pin is used as an analog in or out it is actively connected to the processor internals to facilitate that use - and will be configured appropriately.

<edit>:reading the cross posts that came up before I replied without refresh - A14 is not such a digital pin, like pin #14==A0
 
Status
Not open for further replies.
Back
Top