Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 10 of 10

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

Hybrid View

  1. #1

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

    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?

  2. #2
    Senior Member
    Join Date
    Jun 2013
    Location
    Torrance CA
    Posts
    397
    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.

  3. #3
    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 by sofakng; 02-17-2017 at 03:10 AM.

  4. #4
    Senior Member
    Join Date
    Jun 2013
    Location
    Torrance CA
    Posts
    397
    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.

  5. #5
    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.

  6. #6
    Senior Member
    Join Date
    Jun 2013
    Location
    Torrance CA
    Posts
    397
    // 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.

  7. #7
    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!

  8. #8
    Senior Member
    Join Date
    Jun 2013
    Location
    Torrance CA
    Posts
    397
    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);
    }

  9. #9
    Yeah, that's exactly what I was thinking about doing. Thank you so much for all of your help!

  10. #10
    Senior Member
    Join Date
    Nov 2013
    Posts
    719
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •