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.

How do I enable a Pull Up

Other Parts Discussed in Thread: MSP430G2231

I've never been able to enable an internal pull up.  Must be something simple but it escapes me:

bic.b #08h, P1DIR ; Set P1.3 to Input

bis.b #08h, P1REN ; Enable pull up on P1.3

bis.b #08h, P1OUT ; Enable resistor

Works fine if I hang a 20K resistor on the pin, but the internal pull up just isn't there.

So, what am I missing.

  • Which chip are you using? Which Assembler are you using? What header files did you include?

    Some of the MSP430 chips do not have internal pull-up/down resistors. But the Assembler should have caught that unless you fooled it with a wrong header file.

  • I am using the IAR assembler that I just updated.

    #include  <msp430G2231.h>

    The device is MSP430G2231.

    Tom

  • #include <msp430G2231>
       RSEG  CODE
    main:
       mov   #5A80h, &WDTCTL
       bic.b #08h, P1DIR
       bis.b #08h, P1REN
       bis.b #08h, P1OUT
    forever:
       jmp   forever
       RSEG  RESET
       dw    main
       END

  • Yes, that is exactly what I have:

    bic.b   #08h, &P1DIR            ; Set P1.3 INPUT
    bis.b   #08h, &P1REN            ; Pull up on P1.3 input
    bis.b   #08h, &P1OUT            ; Enable pull up resistor

    bic.b   #0FFh, &P2DIR           ; Set P2 as INPUT Port

    The first line in my original post was copied in error. The above is a cut and paste. I do stop the watchdog timer.

    I checked with a scope and there is no pull up on the pin. Replaced the device, reprogrammed and checked the pin with a scope probe. Same result. There is no pull up on the pin.

    The program runs fine as long as there is an external pull up resistor.

    I assume that I am doing it wrong, but I can't figure out how.

     

    Tom

  • Tom Harper said:

    Yes, that is exactly what I have: ...

    Really exactly ? Was there a "forever: jmp forever" after those statements? The & in those statements are not that important. But what the CPU does afterwards is important. I suggest you try my code in its entirety and measure the P1.3 with a scope or even a DVM (Digital Volt Meter).

  • Old_cow,

    I put in the 'jump forever' and it worked! How about that.

    So, I examined the code further on and found a move.b.....P!OUT instruction that did not retain the Pull Up bit. Should have used bis.b.

    Removed the jump forever and it still works. Fixed.

    You are a genius, as usual, thanks!

     

    Tom

**Attention** This is a public forum