Jump to content
Sign in to follow this  

Port manipulation on msp-EXP430G2

Recommended Posts


I'm trying to read all the IO from a port (port 2) on my M430G255 MCU . On arduino I could have use the line

DDRB = B11111111; 
data = PINB;

I've read some posts but no one talks about port manipulation on energia and msp boards clearly.

can someone help me figure out how to woks with registers and msp boards ?




I found the register file on the energia installation folder, but every time that i try to charge e a register I get the error:

expected unqualified-id before numeric constant


Share this post

Link to post
Share on other sites

On MSP430 device you can access the port with mainly three registers:

PxIN   : read input from port x (8 Bit)

PxOUT   : set output level on port x (8 Bit) (only if direction set to output)

PxDIR   : set direction on port x (0:input  1: output)

where x is the port number


Read input

    inputvalue = P2IN;

Set port P2.0 to output high

   P2DIR = 0x01;

   P2OUT = 0x01;


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this