MSP430 io programming

In my previous post we saw how a led and a switch can be used.There is another way to use the individual bits of the pin.These are defined in the header file of the device.Suppose we’ve to check if a switch is pressed and switch on led then we can use the code similar to the one we wrote earlier where we did bitwise and on the P1IN register to find the value or do the following.

#include "io430.h"
#define           led             P1OUT_bit.P1OUT_0
 #define          switch       P1IN_bit.P1IN_3 
 #define          on               1
 #define          off               0
int main( void )
  // Stop watchdog timer to prevent time out reset
  P1DIR=BIT0+BIT6;               // make pin 0 and 6 output
  P1OUT=0x00;                         // switch off  led
  if(switch == 0)

In the above code we’ve defined macros which refer to the particular pin of a port and whether it is input or output.These are present in the file io430x202.h which gets added by default.If the file is not getting added then it can be added from the folder

C:\Program Files\IAR Systems\Embedded Workbench 5.4 Kickstart\430\inc\

select the required file and add it to the source.


One thought on “MSP430 io programming

  1. how to do single bit declaration.I think above answer is wrong because ,when i written in my program i am getting error like undeclared .if any body knows this topic can u define lcd pins to micro controller pins.those pins are lcd_rs,lcd_rw,lcd_en just enough.thank you

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s