Saturday, November 19, 2011

MSP430 : Hello World LED Blink program

This is my first program to blink all LEDs connected on PORT3 of MSP430 onboard TI MSP430FR5739 experimenters board.

/******************************************************************
 * This is my first project on my MSP430FR5739 experimenter board.
 * In this project I will attempt to blink all onboard LEDs which 
 * are connected to Port 3.
 * Pseudo code as follows
 * 1. Initialise port 3 as an output port.
 * 2. Set Port 3 to digital low.
 * 3. Initialise Loop
 * 4. Set Port 3 to Digital High
 * 5. Delay (Hold State).
 * 6. Set Port 3 to Digital Low
 * 7. Delay (Hold State).
 * 8. Loop End
*******************************************************************/ 
#include "msp430fr5739.h"
#include "FR_EXP.h"
void delay(void);

void main(void) {
 WDTCTL = WDTPW + WDTHOLD;
 P3DIR = 0xFF;  // initialize Port 3 as output by ensuring bit 0 is 0.

 for (;;) {  // Initialise loop
  P3OUT=0xff;
  __delay_cycles(100000); // SW Delay of 10000 cycles at 1Mhz
  P3OUT=0x00;
  __delay_cycles(100000); // SW Delay of 10000 cycles at 1Mhz

  }//for loop
} // main


void delay(void) {
 int i;
 for (i=0; i<0xFF; i++) {
 } 
} // delay


No comments:

Post a Comment