SparkFun Forums 

Where electronics enthusiasts find answers.

Discussions on how to get your MSP JTAG programmer up and running.
By BurstCase
#49667
Dear programers,

I´ve got some fundamentally problems with the MSP430F2274 and the Code Composer vers3.
I thought I could make a quick changeover from the 1611 to 2274 to use USB and the code size from 16kB.
My question:

#include "msp430x22x4.h"

void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
P1DIR |= 0x03;

while (1)
{ unsigned char button=0x00;
if((BIT2 & P1IN)==0)
{button++;}
else
{button=0x0a;}
switch(button)
{
case 0x00: {P1OUT |= 0x00; break;}

case 0x01: {P1OUT ^= 0x02; break;}

default: {P1OUT |= 0x01;}
}



}
}
By OldCow
#49670
I agree that you got some fundamental problems. But I do not think they are caused by the MSP430F2274 or the Code Composer.

(1) The I/O Ports of any MSP430 are configured as input by default. You did not set up P1.0 or P1.1 to be output. Thus changing P1OUT will not do anything to these pins.

(2) "P1OUT |= 0x00" will not change P1OUT. Thus even if P1 pins are set up as output pins, nothing happens.

(3) If P1.2 is connected to a button to ground and a pull-up to Vcc, (BIT2 & P1IN)==0 will be true as long as the button is pushed. The while loop will repeat each ~20 usec. It is not humanly possible to control the button that fast. The button cannot handle that either. (The contact will bounce.)
By BurstCase
#49673
:D I should test a first the programs which are available at Ti

I wonder why my programs which function under other derivates are not similar to them of 2274.

I looked for a simple loop where I can test my Eval board.

I found it in a demo program which I changed a little:

//******************************************************************************
// MSP430F22x4 Demo - Poll P1 With Software with Internal Pull-up
//
// Description: Poll P1.3 in a loop, if hi P1.0 is set, if low, P1.0 reset.
// Internal pullup enabled on P1.3.
// ACLK = n/a, MCLK = SMCLK = default DCO
//
// MSP430F22x4
// -----------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// /|\ | R |
// --o--| P1.2-o P1.0|-->LED
// \|/
//
// A. Dannenberg
// Texas Instruments Inc.
// April 2006
// Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.41A
//******************************************************************************
#include "msp430x22x4.h"

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR = 0x01; // P1.0 output, else input
P1OUT = 0x04; // P1.2 pullup
P1REN |= 0x04; // P1.2 pullup

while (1) // Test P1.2
{
if (0x04 & P1IN)
P1OUT |= 0x01; // if P1.3 set, set P1.0
else
P1OUT &= ~0x01; // else reset
}
}




My mistake was that I forgot the Pull up resistor.
By BurstCase
#49678
#include "msp430x22x4.h"

void main (void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR = 0x01; // P1.0 output, else input
P1OUT = 0x04; // P1.2 pullup
P1REN |= 0x04; // P1.2 pullup

while (1) // Test P1.2
{
int i;
while(0x04 & P1IN);
for(i=0x0000;i<0x9000;i++);
P1OUT ^= 0x01;
}
}


I varied it even a bit more. The stop at the while loop was that I want to get.
Now the Eval board do switch on and off when I push the button.