Jump to content
Sign in to follow this  
mondo8205

MS430G2452 REV1.5 Issues

Recommended Posts

I'm trying to run this general code to blink the led and be able to turn it off and on with the following code.

#include "msp430g2452.h"
#define LED_0 BIT0 
#define LED_1 BIT6
#define LED_OUT P1OUT
#define LED_DIR P1DIR
#define BUTTON BIT3

unsigned int blink = 0;

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
LED_DIR |= (LED_0 + LED_1); // Set P1.0 and P1.6 to output direction
LED_OUT &= ~(LED_0 + LED_1); // Set the LEDs off
P1IE |= BUTTON;

__enable_interrupt();

for (;
{

if(blink > 0)
{
P1OUT ^= (LED_0 + LED_1); // Toggle P1.0 and P1.6 using exclusive-OR

__delay_cycles(100000); // SW Delay of 10000 cycles at 1Mhz

}
}

} 

// Port 1 interrupt service routine
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
blink ^= 0x01;
P1IFG &= ~BUTTON; // P1.3 IFG cleared
LED_OUT &= ~(LED_0 + LED_1); // Clear the LEDs so they start in OFF state

}

 

The button doesn't do anything because REV1.5 is missing the R34 and C24 which is connected to P1.3.

This website https://github.com/energia/Energia/wiki/Hardware states to add something like this to fix the problem.

pinMode(PUSH2, INPUT); becomes pinMode(PUSH2, INPUT_PULLUP); or pinMode(P1_3, INPUT); becomes pinMode(P1_3, INPUT_PULLUP);

 

How would I implement this into this existing code???

Share this post


Link to post
Share on other sites
Also what does volatile mean?

 

It's a way of forcing the compiler into not "optimizing" the variable "blink".

Sometimes the compiler becomes too smart, thinks that the variable isn't really used, so it codes around it.

By using Volatile, you are telling the compiler that the Blink variable can change on it's own, so it needs to always read the value of blink from memory instead.

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...