Digital I/O, such as the LED, is configured by modifying several registers pertaining to the port that they are attached to. Check the datasheet to find the respective port number of the peripheral you which to control. For more detailed information about Digital I/O on the MSP430 check Chapter 6: Digital I/O of the ez430's user guide. The basic logic behind seemingly trivial process of turning the LED on and off is the same behind the operation of every peripherial on the tool.
First, we must assign the direction of the corresponding I/O pins. This is done by setting the direction register, PxDIR, with the appropriate bit. By default, all I/O pins are assigned to be inputs.
- Bit = 0: The port pin is switched to input direction.
- Bit = 1: The port pin is switched to output direction.
On the ez430 the LED is located on port 1. The port number will correspond the to x value in registers such as PxIN, PxOUT, or PxDIR. Therefore, if we wanted to define the direction of a pin on port 1 we would write to P1DIR.









"This is a basic tutorial on how to program the basic digital peripherals on the ez430."