This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Output of an LED set using a pull-up resistor

I just started working with the NXP LPC1768 in class and I'm struggling to understand how the internal pullup/down resistors are utilized. We have a program that changes the status(on/off) of one of the LEDs at the push of a button. My question is why does the following line of code cause the LED to light up:

LPC_PINCON->PINMODE3 = LPC_PINCON->PINMODE3 & 0xFFFFFFCF;
LPC_GPIO1->FIOSET |= (1<<18);

When the program starts, the LED is on. However, since this pin is set to pull up, I expected it to be off. If setting the 18th bit to 1 is equivalent to closing the switch, then that means that this line:

LPC_GPIO1->FIOSET |= (1<<18);

would cause the current to flow to ground, turning the LED off. I must be misunderstanding something, since the LED is obviously on with the current code. Any insights?

Parents
  • You haven't told us how the LED is connected.

    It makes a difference if the LED is connected between VCC and the I/O pin, or between the I/O pin and GND.

    When you set the I/O pin with your command, the pin will go high and try to output 3.3V. So a LED connected between the I/O pin and ground will be lit (assuming the correct polarity of the LED).

    The internal pull-up or pull-down of the PIN is weak. And only applies when the pin is configured for input.

    What you don't show us is if your code will set the pin as output. The default is input, in which case the internal pull-up or pull-down will apply.

    The pull-up or pull-down isn't strong enough to get a LED to light up fully, but can get some LED to give a dimmer light. Many modern LED doesn't need much current until they glow enough that you can see them.

Reply
  • You haven't told us how the LED is connected.

    It makes a difference if the LED is connected between VCC and the I/O pin, or between the I/O pin and GND.

    When you set the I/O pin with your command, the pin will go high and try to output 3.3V. So a LED connected between the I/O pin and ground will be lit (assuming the correct polarity of the LED).

    The internal pull-up or pull-down of the PIN is weak. And only applies when the pin is configured for input.

    What you don't show us is if your code will set the pin as output. The default is input, in which case the internal pull-up or pull-down will apply.

    The pull-up or pull-down isn't strong enough to get a LED to light up fully, but can get some LED to give a dimmer light. Many modern LED doesn't need much current until they glow enough that you can see them.

Children