This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Why isn't pull-up/down resistor automatically disabled when pin is set to output?

Expert 1140 points

Hi,

I'm aware this is a basic question as I'm a newbie to uC.

I've spent an hour trying to figure out why the first run of my program runs ok, while the subsequently triggerred loops don't. My P1.0 didn't want to drop to logical zero upon P1OUT &= ~BIT0, in the previous run I turned on the pull-up resistor:

Code:

P1DIR &= ~BIT0;     //set P1.0 as input
P1REN |= BIT0;        //enable pull-up
... P1DIR |= BIT0; //set P1.0 as output P1OUT &= ~BIT0; //here I'd expect the zero logical signal on the output,
//but it's reported by logic analyzer as 1 -
// - I guess it's pulled up to the Vcc with the P1REN |= BIT0, is that correct?

So I wonder, why isn't this pull-up resistor automatically disabled when the pin gets output mode? What is the real life use of such case?

  • Hi tml,

    The PxREN register enables the pull-up / pull-down resistor when the pin direction is input (according to PxDIR or module control of direction).

    When the integrated pull-up / pull-down resistor is enabled, the PxOUT register determines whether it pulls up or down.

    If you (or a module) changes the pin to be an output, the integrated pull-up / pull-down resistor deactivates.

    Jeff

  • Hi Jeff, 

    Thanks for your reply! It looks like my practice doesn't match the theory, or there is something fundamental I still don't understand.

    I use the MSP430G2 LaunchPad, and if we take the simplest scenario utilizing the LED, let's say LED blinking (P1.0), and before the loop where the LED is being toggled with P1OUT ^=BIT0 we put P1REN |= BIT0, then this LED will be blinking but dimmed. My theory, although not verified yet with the multimeter is that P1.0 has been pulled-down to gnd with resistor and the voltage dropped, thus LED is dimmed.

    Best Regards,

    tml

  • tml said:
    why isn't this pull-up resistor automatically disabled when the pin gets output mode

    On some MSPs, it is, on some it isn't. However, PxOUT determines the pullup direction. So if the pin is in output direction, the pullup puls into the same direction as the output driver. It actually doesn't make any difference whether the pullup is active or not.

    Also, the pullup is 30k to 50k. On VCC=3V, this makes a pullup/pulldown current of 100µA or less. The active output driver can sink or source several mA. So even if the pullup would try to pullt ehpin up, the output driver would have no problems driving the pin down with 100 times as much current as required to nullify the pullup.

    You don't write which MSP you use.
    Each datasheet contains a section where the full port schematic of every port pinis drawn. You can see yourself the logic behind PxDIR, PxOUT and PxREN. And also PxSEL and perhaps other effects.

    What is the external circuitry on this pin?

**Attention** This is a public forum