Teensy 3.x - I/O switching limitations?

Status
Not open for further replies.

dozy

Member
Hi Everyone,

I realize I could get laughed off the forum for asking this, but...

Is it okay to be using one of the digital I/O pins for both reading and writing, thousands of times per second, day after day?
I assume 'yes', I'm just wondering if there are known limitations to these specific devices.

Example: (not my actual code.. I'm just getting the point across)
loop()
{
pinMode(0,INPUT);
digitalRead(0);
pinMode(0,OUTPUT);
digitalWrite(0,someValue);
}


Thanks,
Dozy
 
I think it's OK. Sometime you need a short (few microseconds) delay after changing to input mode. You'd have to study the chip specs. And pay attention to pull-up/pull-down resistors, on-chip, enable options.

Doing this is a rather odd case- one that comes to mind is an R/C circuit on an I/O pin, and output=0 then repeatedly input until a threshold is crossed - as an integrator-based A/D. The time for the capacitor to recharge, using an external analog voltage, implies the magnitude of the voltage. Inexpensive multimeters often use this method.
 
Rapidly switching between input and output mode is perfectly fine.

However, what you physically connect to the pin matters. If it drives the pin strongly, in conflict with the output mode, you could have reliability problems.
 
Status
Not open for further replies.
Back
Top