Jump to content
Sign in to follow this  
arun250691

my first Program

Recommended Posts

hello everyone

 

i am completely new to the MSP430 Architecture and as advised i have got some literature on the same including the book "MSP430 Microcontroller Basics"

i got the Launchpad and have made my first program of Blinking LED, which obvioulsy like the first time of everything didnt work out

 

whats wrong with the Program?, nothing happens on the Board, No LED's Glow

note: i have been seriously criticized for missing the Forest for the trees and im not so good at writing one line codes...my coding may seem silly most of the times

 

 

#include "msp430g2553.h"

 

void delay()

{

unsigned int i;

for(i=0;i<12000;i++);

}

 

void main()

{

WDTCTL = WDTPW + WDTHOLD;

 

P1DIR = 0x00;

while(1)

{

P1OUT=0x00;

delay();

P1OUT=0xFF;

delay();

}

}

 

any corrections..

Share this post


Link to post
Share on other sites

Hi looks like your port 1 directions wrong. Setting a P1DIR bit to 0 = input, 1 = output.

 

So changing your P1DIR setting to P1DIR = 0xFF; will set all of port 1 to output and your program should work.

 

Just a small tip but you really only want to change the pins connected to the LEDs so you should ideally be doing the following:

 

#include "msp430g2553.h"

void delay()
{
   unsigned int i;
   for(i=0;i<12000;i++);
}

void main()
{
   WDTCTL = WDTPW + WDTHOLD;

   P1DIR |= BIT0 | BIT6;

   while(1)
   {
       P1OUT &= ~(BIT0 | BIT6);
       delay();
       P1OUT |= BIT0 | BIT6;
       delay();
   }
}

 

Obviously this isn't too important for blinking the LEDs but its a good practise to get into :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...