Close

Port Initialization

A project log for MSP430F5529 Interrupts, Timer, and 60 second Count

Using MSP430 to have a Seconds Counter with the help of inbuilt TIMER-A and Hardware interrupts to keep track on number of counts.

adi-vivekAdi Vivek 12/11/2018 at 19:570 Comments

Now lets look at how to use the pins for output.

There are many ports on the MSP430 (varies on version) , for example PORT-1  ( P1.0 to p1.7 ) & 

PORT-2 ( P2.0 to P2.7 ).

#include <msp430.h> 


/**
 * main.c
 */
void main(void)
{
	WDTCTL = WDTPW | WDTHOLD;	// stop watchdog timer

	 P3DIR=0xFF;                    // P3DIR=0x00;
         P6DIR=0xFF;

         P4DIR |=0x00;
         P4REN |=0xFF;
         P4OUT |=0xFF;

}

 P3DIR |=0x00 tells us that the whole of PORT-3 is initialized to take inputs.

P3DIR |=0xFF tells us that the whole of PORT-3 is initialized to give outputs.

P3DIR |=0x01 only the pin P3.0 is initialized to output in PORT-3.

This follows a Hexadecimal Port mapping.

The Major advantage with the higher versions of MSP430 are , they have inbuilt Pull -Up or Down resistors, so no need to connect externally.

P4REN |=0xFF , this indicates that the pins of PORT-4 have their pull up/down resistors enabled.

TO select them between Pull UP or Pull DOWN, the instruction P$OUT |=0xFF is used.

If 0xFF is used they configure as Pull UP resistors and if 0x00 they configure as Pull DOWN. 

Discussions