This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430F5529: Push button causes Error

Part Number: MSP430F5529

I've just began using the MSP430F5529LP. I'm trying to interface a button (tactile switch) with my MCU to power on an LED. However, whenever I push the button, I get a "USB malfunctioned error" from my PC. Any help regarding why this is happening and how to solve the problem would be very useful.

P.S. For the real life cct, I've connected my LED to P1.3 and the button to P2.3 and I'm making use of the 5V and GND pins to power the circuit.

Attached below is my code and a Fritzing sketch showing how I created my circuit:

#include <msp430.h> 
#include <driverlib.h>

#define ONE_SECOND 800000


/**
 * main.c
 */

volatile unsigned int button = 0;

int main(void)
{
    WDT_A_hold(WDT_A_BASE); 	// stop watchdog timer
    GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN3);
    GPIO_setAsInputPinWithPullDownResistor( GPIO_PORT_P2, GPIO_PIN3 );



    while (1){
        button = GPIO_getInputPinValue ( GPIO_PORT_P2, GPIO_PIN3 );

        if ( button == GPIO_INPUT_PIN_HIGH ) {

            // If button is down, turn on LED
            GPIO_setOutputHighOnPin( GPIO_PORT_P1, GPIO_PIN3 );
         }
        else {
             // If button is up, turn off LED
             GPIO_setOutputLowOnPin( GPIO_PORT_P1, GPIO_PIN3 );
         }
    }
	//return 0;
}

Here is a screenshot of the fritzing sketch:

  • Hi Akoji,

    Don't use the 5V rail.  Use the 3.3V rail.

  • Thanks, Dennis.

    I realized I made a terrible mistake in using the 5v and GND pin of the FET. Having corrected this, I noticed that whenever I push the button, the green led on the USB hub blinks and not my original LED. Could it be that the board has been damaged???

  • Hi Akoji,

    Are you in debug mode when this happens?  If so disconnect the launchpad and reconnect and push the button.  Green LED blinks?

    If you forget about the button for a moment and modify your code so it only blinks the LED, does that work?

    Next put the MSP430 into low power mode just after disabling the WDT as shown here.

    When you push the button does the green LED blink?

    main()

    {

    WDTCTL = WDTPW | WDTHOLD;
    __bis_SR_register(LPM3_bits);

    ...

    }

  • Hello Akoji,

    I haven’t heard from you for a while, so I’m assuming you were able to resolve your issue.
    For this reason I'm changing the status of this posting to RESOLVED.


    If this isn’t the case, please click the "This did NOT resolve my issue" button and reply to this thread with more information.
    If this thread locks, please click the "Ask a related question" button and in the new thread describe the current status of your issue and any additional details you may have to assist us in helping to solve your issues.

**Attention** This is a public forum