How can I default an output pin to high immediately when power is applied?

Status
Not open for further replies.

sofakng

Active member
Sorry for so many questions, but I'm learning a lot and reading datasheets, searching, etc, before I ask anything.

Anyways, I'm connecting a Wiz850io to my Teensy 3.6. The Wiz850io has a reset pin (RSTn) that needs to stay high until a reset is called at which point it goes low for a few milliseconds and then returns to high.

How can I default this pin on my Teensy to high immediately after power is applied? It seems like the pins default to low and I need to digitalWrite them to high but this causes a brief low to high on the pin after power is applied.

I'm not even sure this is a problem but it seems like the correct thing is to keep this reset pin high immediately after power is applied to prevent any quick-resets?
 
You can use a pull up resistor for this. I usually use 10Ks but higher values should be fine. The resistor will keep the line high but if the Teensy asserts low it will override it.
 
Thanks for the reply. I'm still having some problems though.

Also, I've noticed my Wiz850io module has a built-in 4.7k pull-up resistor between RSTn and 3.3V. (according to the schematic).

Anyways, I've placed a 10k resistor between my pin and the RSTn pin.

When the Teensy boots, it's 3.3v (high), but when I change the pinMode to output, it drives it low. However, low is only reducing the voltage to 2.2v. Do I need a larger/smaller resistor?

I've tried to digitalWrite that pin to high before setting the pinMode, but when pinMode sets the pin to output, it seems to always go low requiring another call to set it high?
 
Last edited:
Thanks for the schematic, yes there's already a pullup resistor so you don't need to add another one.

It sounds like you put a 10K inline between the Teensy GPIO pin and the Wiz reset pin? If so then no you don't need that.

Sorry if I'm misunderstanding you but are you saying when you do this:

Code:
pinMode(WIZ_RESET_PIN, OUTPUT);
digitalWrite(WIZ_RESET_PIN, HIGH);

There's still a momentary blip that's resetting the Wiz? If so, try using digitalWriteFast() to see if that speeds it up enough to stop the reset.

Or are you saying you set pinMode() it's low until you set it high? Then yes that's the default.
 
OK - I'll remove the resistor.

I'm using a delay() between pinMode and digitalWrite to see what's happening so I'm not sure if this will cause a problem, but pinMode(WIZ_RESET_PIN, OUTPUT) definitely causes the pin to go low which I don't want.

Here is what I'm describing:

Code:
// boot-up, WIZ_RESET_PIN appears to high (3.3v);  because of the Wiz850io pull-up resistor?

// this will set WIZ_RESET_PIN to low
pinMode(WIZ_RESET_PIN, OUTPUT);
delay(1000);  // so I can read with my multimeter
// this time between pinMode and digitalWrite the pin is low which I don't want
digitalWrite(WIZ_RESET_PIN, HIGH);

Again, I'm not sure if that time is long enough to reset the chip and it might not cause any problems, but I was hoping to keep the pin high until I decided to set it low so I can control exactly how long (and when) it goes low.
 
// boot-up, WIZ_RESET_PIN appears to high (3.3v); because of the Wiz850io pull-up resistor?

Yes correct

[// this will set WIZ_RESET_PIN to low
pinMode(WIZ_RESET_PIN, OUTPUT);

The pin is pulled to ground immediately after your pinMode() statement

delay(1000); // so I can read with my multimeter

The pin will stay low for a full second

// this time between pinMode and digitalWrite the pin is low which I don't want
digitalWrite(WIZ_RESET_PIN, HIGH);

Move the digitalWrite() above the delay so it's not low for 1 second.
 
OK - Thanks. The delay was only there to illustrate the problem. I was hoping to avoid the very slight drop to low but it sounds like its not possible.

Thanks so much as always for the help!
 
One thing that you could do is move your pinMode() out of your setup() and in to the actual reset code, that way the Teensy pin would float (and thus the Wiz pin would stay high because of the pullup) until you explicitly set it. Something like this:

Code:
void ResetWiz(void) {
pinMode(WIZ_RESET_PIN, OUTPUT);
digitalWrite(WIZ_RESET_PIN,LOW); // this does nothing on the first call, but asserts low on subsequent calls
delay(WIZ_RESET_LENGTH);
digitalWrite(WIZ_RESET_PIN, HIGH);
}
 
In AVR stuff you could set the exerted pin state (low or high) before selecting exertion (pinmode OUTPUT) - I wonder if 'pinMode' clears the state if you digitalwrite[fast] a high and then set the pinMode? Pity if so - I can't check right now; I usually want the reset to occur, they are usually 'low to reset' and I do what potatotron offered mostly.

Sorry. Running late as ever and probably not considering as much as I should here :D
 
Status
Not open for further replies.
Back
Top