Are Teensy3.2 Pins High Low and Tri State

Status
Not open for further replies.

Teenfor3

Well-known member
I want to connect a 100k resistor to a device but I want to use Teensy3.2 to switch the other end of it from GND, to open circuit, to 5 volt.
I was thinking to simply connect it to a pin and control as below.........wondering if that would work or be reliable.????

pinMode( pinNumber, OUTPUT ); // set as output
digitalWrite( pinNumber, LOW ); // set pin low

// code here to do something when pin is low

pinMode( pinNumber, INPUT ); // now set tri-stated.?.....Is this same as opencircuit or at least very high impedance well in access of 100k..??

//code here to do something when pin is open circuit

pinMode( pinNumber, OUTPUT ); // and set back to output
digitalWrite( pinNumber, HIGH ); // set pin high

//code here to do something when pin is high

...............................................................................................

Got this below from a search on the forum..................

That's why newer chips like the ARM chips from Freescale have a special disable mode, which is the default.

On AVR, the pins with ADC inputs also have a special disable mode. However, it's not the default. When you use analogRead(), the pin you're reading is placed in that mode (this is a Teensyduino feature - Arduino's version of analogRead does not do this) to prevent that pin you're using for analog voltages from consuming extra power. On Teensy 2.0, only the pins with analog input have this digital input disable feature
.................................................................................................

....................What command is used to set to disable mode ??...
 
PS I should have said I will not be doing anything else with this pin, just holding it either High, Low or Tri-state for a period of time while the code in between runs to do other functions
 
In the datasheet in section 5.2.3 (Page 13) the maximum leakage current is 1µA over the full temperature range and 0.025µA at room temp. Both measured at Vdd=3.6V.

Ohms law yields R = V/I = 3.6/(1E-6) = 3.6 Megaohms for 1µA and a whopping 3.6/25E-9 = 144 MOhms for 0.025µA.

AFAIK using pinMode( pinNumber, INPUT ); will be sufficient for tri-stating the pin to HiZ.

Remember that immediately after putting the pin to HiZ mode the pin capacitance will charge through your attached 100k resistor, so the system will need a certain settling time. Pin capacitance is 5pF typical plus line capacitance on the PCB plus whatever wires you attach.

-Ben
 
Most often, unused pins are programmed early in startup as GPIO Input, no pull-up. But some vendors recommend "analog" input. The internal pull-ups, if enabled, are on the order or 40K.
 
Thanks for replies. I have tried it out as per my example code outlined and it seems to work OK. the state of my other device changes to correspond with the pinmode settings
 
What command is used to set to disable mode ??...


Try this:

Code:
void pinDisable(const uint8_t pin) {
  volatile uint32_t *config;  
  if (pin >= CORE_NUM_TOTAL_PINS) return;
  config = portConfigRegister(pin);
  *config = 0;
}
 
Last edited:
Status
Not open for further replies.
Back
Top