Jump to content
43oh

Active high input?


Recommended Posts

So I have been trying to wrap my head around this for a while. Is there a way to configure inputs active high (on a G2211, currently socketed in a Launchpad, if that matters)? I have been searching high and low for the better part of the day, but this does not seem an oft-surfacing problem, so I guess I'm missing something quite fundamental.

 

I have some active high-output circuitry connecting to several pins of the G2211, and I am trying to get by connecting them directly.

 

Thanks in advance.

Link to post
Share on other sites

I basically want this:

 

           MSP430G2211
         +--------------+
+-/\/\/\--| VCC          |
|         |              |
+---------| P1.2         |
         |              |
         |              |

 

to have P1IN & BIT2 result in 1. So far, no amount of fiddling with P1REN seems to have gotten me anywhere. I am also a bit confused by slau144h chapter 8.2.4 (which I have based my attempts upon); it goes

 

Each bit in each PxREN register enables or disables the pullup/pulldown resistor of the corresponding I/O pin. The corresponding bit in the PxOUT register selects if the pin is pulled up or pulled down.

 

which to me would seem to mean that the pullup/down resistor and it's configuration affects the pin when it is configured as a input as well as when it is configured as an output; but so far I have failed to notice any effect when the pin is configured as input.

 

Not being experienced at this (to say the very least), but (my) common sense suggesting that active high input must not be such a rare bird to need additional components to work, I concluded I must be doing something really wrong. I certainly can invert the signals coming from the connecting circuitry, but that seems rather counterintuitive.

 

Thanks again.

Link to post
Share on other sites

There are two settings for internal resistor when PxDIR is 0 (input) and PxREN is 1 (enabled)

PxOUT = 0, resistor pulls down, input is active high

PxOUT = 1, resistor pulls up, input is active low

 

When PxDIR is 0 (input) and PxREN is 0 (disabled,) input will be floating and must be pulled externally or connected to push-pull output.

When PxDIR is 0, PxOUT has no effect on output, just the resistor.

 

PxDIR = 0, PxREN = 1, PxOUT = 1, input is active low

post-197-135135499992_thumb.png

 

PxDIR = 0, PxREN = 1, PxOUT = 0, input is active high

post-197-13513549999_thumb.png

Link to post
Share on other sites

Hm. This indeed appears to work quite well. The trouble I seem to be having is with pin#2. The following code blinks me the red LED continuously, thinking there is input on pin#2:

 

int main(void) {

 WDTCTL = WDTPW | WDTHOLD;

 P1DIR |= BIT0;
 P1OUT &= ~BIT0;

 P1DIR &= ~BIT2;
 P1REN |= BIT2;
 P1OUT &= ~BIT2;

 while( 1 )
 {
   if( ( P1IN & BIT2 ) )
     P1OUT ^= BIT0;
     __delay_cycles( 32767 );
 }

 return 0;
}

 

If, however, I change my button to be pin#5, everything goes according to plan (blink iff the button is being pressed). There is no such problem when the input is active low. Explicitly selecting the I/O function via P1SEL.1 := 0 does not seem to change this (so it's not some sort of stray setting or remnant of something or whatnot).

 

... apparently, it's time for a facepalm. Is this being caused by pin#2 having a nice long trace to the RXD header pin, and further?

 

Anyway, thank you for being with me, it is really appreciated, and it certainly has been a great help to me.

Link to post
Share on other sites
Hm. This indeed appears to work quite well. The trouble I seem to be having is with pin#2. The following code blinks me the red LED continuously, thinking there is input on pin#2...

Oh, forgot to add, remove RX jumper as it may interfere.

Link to post
Share on other sites
Sorry if the point of this thread has sailed over my head, but does this page explain things better?

No, it explains them differently. I was familiar with this already, and indeed my problems came from pin#2 being tied to RX.

 

But anyhow, thanks for your jumping in, it is much appreciated.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...