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.

CCS/MSP430F249: MSP430F249

Part Number: MSP430F249

Tool/software: Code Composer Studio

If I press the button(P1.3) after 1 sec the LED should be ON

If I again press the button then after 5 sec the LED should be OFF 

Can annyone help me with this ?

Thanks] 

  • Hello,

    You can refer to the GPIO examples in the TI Resource Explorer for examples of how to properly initialize and use the input and output pins on the MSP430F249. You will need to implement a way to count how long a button is being pressed. This can be done using a SW counter or using a timer on the device.

    Best regards,

    Matt

  • Yeah I have gone through that and I implemented the code using interrupt like the below shown but I dont know how to make a push button delay .I have  searched some examples in resource explorer  as all of them showed those examples are used to change the time speed of blinking LED.

    #include <msp430f249.h>
    int main(void)
    {
    WDTCTL = WDTPW | WDTHOLD;
    P1DIR|= BIT0 ;
    P1OUT&= ~(BIT0);

    //P1DIR&=~BIT3;
    P1REN|=BIT3;
    P1OUT|=BIT3;
    P1IE|=BIT3;
    P1IFG&=~BIT3;
    P1IES|=BIT3;
    __bis_SR_register(GIE);
    while(1)
    {}
    }
    #pragma vector=PORT1_VECTOR
    __interrupt void GPIO(void)
    {


    P1IFG&=~BIT3;
    P1IES^=BIT3;
    P1OUT^= BIT0;
    }

    Regards,

    SK

    Matt Calvo said:

    Hello,

    You can refer to the GPIO examples in the TI Resource Explorer for examples of how to properly initialize and use the input and output pins on the MSP430F249. You will need to implement a way to count how long a button is being pressed. This can be done using a SW counter or using a timer on the device.

    Best regards,

    Matt

  • SK,

    As I mentioned before, you will have to use some sort of SW counter or the HW Timer on the device in order to count how long the button has been pressed. You can find the state of the pin in the PxIN register so if you detect that it it being pressed then you can start incrementing a counter while continually checking the state of the pin to make sure that it is still being pressed. Once it reaches the time threshold you want you can then react accordingly. If you want a solution that is a little more robust which uses the HW timer module, you can refer to this example I was able to find on the web: https://github.com/alfy7/MSP430-Launchpad-Examples/blob/master/13_Timer_Capture.c

    A general search on the web should help you find for community projects which may show you other ways of determining the duration of a button press.

    Best regards,

    Matt