Jump to content

Registros P1IN y P1OUT del MSP430g2152 (Registers) Help

Recommended Posts

Not so long ago i bougth the LaunchPad MSP-EXP430G2 and ordered some free samples of MSP430g2152, later when i was doing testing codes i checked that when i assign an output to the P1OUT register, the P1IN register take the same value that the P1OUT, This was odd to me, so i went to the datasheet of the msp430 family and as i was expecting the registers have two different address (P1IN 020h and P1OUT 021H), now i don't know if i have something wrong in my code or if in fact the microcontroller change both registers. Can anyone explain me what's going on or if it is normal? I'm using Code Composer Studio



Link to post
Share on other sites

Looking at the port schematic in the datasheet, you can see that PxIN.y (i.e. bit y of port x) is directly connected to the pad (via a buffer).


So I think by design P1IN always reflects the physical state of the pins, even for pins configured as output. However, changing the state of a pin via P1OUT is only possible when that pin is configured as output.

Link to post
Share on other sites

P1IN will always result in a value, depending on the pin configuration this value is either the intended value on that pin or the actual value on that pin. This means that unless you have set your pin to input mode (cleared the bit in PxDIR) your PxIN will reflect PxOUT, not the actual pin value.

setting PxREN will enable pull-up/down, clearing it will disable pull-up/down; the pin is floating or driven high/low.

To set a pin to be pull-down and allow you to read the actual value you should:

  • Set the PxREN bit to 1 (enable resistor)
  • Set the PxOUT bit to 0 (pin outputs low (pull-down))
  • Set the PxDIR bit to 0 (allow PxIN to reflect the pin instead of the PxOUT value)

After this PxIN will be 1 if an external circuit pulls the pin more high (short to Vcc) than the configured pull-down resistor pulls it down.

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.

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...