Stopping a continuous while loop on MSP430

In my microprocessing class our teacher has made us program a MSP430G2553 to do light up 8 led's in a certain sequence when a button is pressed.  The micro is attached to a Breadboard that is then connected to two buttons and the 8 led's.  When the power is connected none of the lights will be lit.  When one button is pressed a sequence will begin and continue until the person presses both buttons at the same time.  The same goes for the second button.  I have been able to achieve two of the three parts.  The only part I have trouble is getting out of the while loop/pressing the 2 buttons at the same time.  I have tried multiple methods but with no results.  I have attached the code so you could help me out with this. 

p.s.  Teacher is horrible assumes everyone in class can already program / no book to read from.  Is there any websites/books that I could use to help me understand this material?

3482.Code.txt

6 Replies

  • Expert 2970 points

    Hi,

    In your code, I didn't see any attempts to detect when both buttons were pressed simultaneously.  What have you tried?

    Barry

  • Melbim Sanchez
    Teacher is horrible assumes everyone in class can already program

    Was that not stated as one of the course pre-requisites?

    If not, have you talked to the teacher about this? Or your personal tutor, or college staff, or whatever?

    Melbim Sanchez
    Is there any websites/books that I could use

    Of course - there are plenty!

    Some suggestions here: http://blog.antronics.co.uk/2011/08/08/

     

  • Expert 1530 points

    Hi,

    first of all, there are many tutorials out there for learning C and also C for microcontrollers like the MSP430. A starting point could be the lauchpad wiki (a TI development tool for the value line MSP430s):

    http://processors.wiki.ti.com/index.php/LaunchPad_Redirect?DCMP=launchpad&HQS=Other+OT+launchpadwiki

    For your question: in your code you start the blinking sequence in this line:

    if(P2IN&BIT3) or if(P2IN&BIT4) 

    but there is no escape from one of the while loops. You are looking for

    if((P2IN&BIT3) && (P2IN&BIT4)) {
    break;
    }

    This checks both input bits and is only true when both are pressed, the break quit's the while loop.

    Hope that helps ;-)

    --
    Regards,
    Jan

    Oxfam Trailwalker 2012 - Runner

    Found any horribly english mistakes? - Drop me a note as private conversation via my profile if you like ;-)

  • Hi Melbim,

    Melbim Sanchez
    Is there any websites/books

    1) MSP430 Microcontroller Basics by John Davies (the best)

    2)Embedded Systems Design using the TI MSP430 Series by Chris Nagy

    3) Analog and Digital Circuits for Electronic Control System Applications

    Using the TI MSP430 Microcontroller by Jerry Luecke

    Hope the above books help
    
    
    best wishes
    janmay
  • In reply to Andy Neil:

    I know how to program, sorry i didn't word it correctly.  I meant to say that he assumes we already know how to program the MSP430 already.  We are actually beginning where the class from the previous semester finished off

  • In reply to Melbim Sanchez:

    Hi,

    Go through any one of the MSP430 books, and you will be just fine :-).

    READING as much as possible is the only way forward.

    best wishes

    janmay