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.

MSP430F5529: Confusion with pull up/down

Part Number: MSP430F5529

Hi! I'm starting in microcontroller class and we made the LED (P1.0) light up when the push button (P2.1) is pressed. Everything works fine, I just have the doubt, why in "bis.b # BIT1, & P2OUT" the resistance is put in pull-up? At the beginning we had it in pull-down since as I understand it as long as the push is not pressed button the LED will be in a low state (0) and when we press it to turn on with a high state, I asked the teacher but he didn't even know what to answer me.             

             bis.b #BIT0, &P1DIR

             bic.b #BIT1, &P2DIR
             bis.b #BIT1, &P2REN 
             bis.b #BIT1, &P2OUT

inicio     bit.b #BIT1, &P2IN 
             jnz off 
             bis.b #BIT0, &P1OUT
             jmp inicio
             nop 
off         bic.b #BIT0, &P1OUT
             jmp inicio
             nop 

Thank you.

  • I'm not quite sure which of two possible questions you're asking, so I'll answer both:

    1) Why does setting the P2OUT bit control whether the pin is pulled up or down? Quite simply because that's the way the designers decided to do it. In some other MCUs, a separate register is used to control the pull up vs down state, but the MSP430 designers noticed that P2OUT is not generally useful for an input pin so they used that instead of a separate register.

    2) Why do we need a pullup for a button? A button is typically wired such that it closes a circuit to GND (low). When it is not pressed, the circuit is open, and so the pin voltage can "float" at some random fluctuating level, possibly indistinguishable from GND. Thus the circuit needs to have something which causes it to read VCC (high) when it's open. This could in theory be done by connecting it directly to VCC, but the problem with that is that when it is closed it creates a direct connection between VCC and GND, which passes enough current to damage something. The pullup introduces a current-limiting resistor into the path, which (as the name suggests) limits the current when the button is pushed.

    It may be instructive to look over the pin schematic in the data sheet (SLAS590P) Figure 9-3, which shows how the pullup/down resistor is connected.

**Attention** This is a public forum