• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Microcontrollers » MSP430™ Microcontrollers » MSP430 Ultra-Low Power 16-bit Microcontroller Forum » Stuck with Button P1.3 on MSP430G2553
Share
MSP430™ Microcontrollers
  • Forum
  • Announcements
  • E2E Wiki
Options
  • Subscribe via RSS
MSP430 Resources
  • MSP430 Product Folder
  • MSP-EXP430G2 - MSP430 LaunchPad Value Line Development kit
  • MSP430 Getting Started Guide
  • MSP430 Microcontroller Projects
  • More Resources >
  • Stuck with Button P1.3 on MSP430G2553

    Stuck with Button P1.3 on MSP430G2553

    This question is answered
    Arcady Trembovler
    Posted by Arcady Trembovler
    on Aug 27 2012 11:38 AM
    Prodigy85 points

    To be honest, I am stuck in figuring out how to use the P1.3 button.

    I have MSP430G2553 just like you and allover the web people are talking about pullup resistors and other b-s.
    How should I use this button using my MCU? There is absolutely 0 help online on this topic..

    Please help me, would love it if you'd include a code sample..

    Thanks in advance from me and from all the other noobs out there ;-)

    Button MSP430g2553 P1.3
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • Marco
      Posted by Marco
      on Aug 27 2012 12:51 PM
      Expert1420 points

      Hello,

      I recommed to read (or better study)  the "digital I/O" section of your MSP430s userguide.

      Regards Marco

      MSP430 digital IO
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Jens-Michael Gross
      Posted by Jens-Michael Gross
      on Aug 27 2012 12:56 PM
      Guru139900 points

      Arcady Trembovler
      allover the web people are talking about pullup resistors and other b-s.

      There are some things you cannot do in software. If you want to only do software, a microcontroller definitely isn't your best target. Else you should try to understand what this means and why people are talking about this.

      _____________________________________
      Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.
      If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Arcady Trembovler
      Posted by Arcady Trembovler
      on Aug 27 2012 13:02 PM
      Prodigy85 points

      instead of mocking me, please take a look at this:

      #include "msp430g2553.h"

      void main(void)
      {
      WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
      P1DIR |= 0x01; // Set P1.0 to output direction
      P1IE |= 0x08; // P1.3 interrupt enabled
      P1IFG &= ~0x08; // P1.3 IFG cleared
      _BIS_SR(LPM4_bits + GIE); // Enter LPM4 w/interrupt
      }

      // Port 1 interrupt service routine
      #pragma vector=PORT1_VECTOR
      __interrupt void Port_1(void)
      {
      P1OUT ^= 0x01; // P1.0 = toggle
      P1IFG &= ~0x08; // P1.3 IFG cleared
      }

      why isn't it working for me?

      Thanks a bunch!

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Marco
      Posted by Marco
      on Aug 27 2012 13:11 PM
      Expert1420 points

      Hello,

      I would add "for (;;);" at the end of the main loop.

      Regards Marco

      MSP430 digital IO
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Stephan Goldenberg
      Posted by Stephan Goldenberg
      on Aug 27 2012 13:23 PM
      Intellectual310 points

      The button pulls down - does this generate an interrupt ?

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • old_cow_yellow
      Posted by old_cow_yellow
      on Aug 27 2012 13:31 PM
      Verified Answer
      Verified by Arcady Trembovler
      Guru25715 points

      Add two lines near the beginning of your void main(void);

      P1OUT |= 8;

      P1REN |= 8;

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Arcady Trembovler
      Posted by Arcady Trembovler
      on Aug 27 2012 13:48 PM
      Verified Answer
      Verified by Arcady Trembovler
      Prodigy85 points

      Now it works really okay:

      #include "msp430g2553.h"

      void main(void)
      {
      WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
      P1OUT |= 8;
      P1REN |= 8;
      P1DIR |= 0x01; // Set P1.0 to output direction
      P1IE |= 0x08; // P1.3 interrupt enabled
      P1IFG &= ~0x08; // P1.3 IFG cleared
      _BIS_SR(LPM4_bits + GIE); // Enter LPM4 w/interrupt

      //for(;;); //loop is unnecessary..
      }

      // Port 1 interrupt service routine
      #pragma vector=PORT1_VECTOR
      __interrupt void Port_1(void)
      {
      P1OUT ^= 0x01; // P1.0 = toggle
      P1IFG &= ~0x08; // P1.3 IFG cleared
      }

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • TonyKao
      Posted by TonyKao
      on Aug 27 2012 23:05 PM
      Verified Answer
      Verified by Arcady Trembovler
      Genius3770 points

      As far as I can tell JMG wasn't trying to mock you, Arcady. The code that OCY gave you enables the internal pull up resistor on the 4th pin, since an input by default "floats" with unpredictable logic level, hence it will not detect the button press (i.e. a high-low edge transition through pulling down the input pin to ground/logic 0).

      I agree that the details may seem unclear or non-obvious to a "newbie", but things like logic levels, edge transitions, and pulling up/down are fundamental to digital electronics. The exact implementation and mechanics may vary, but the principles are universal.

      Tony 

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Jens-Michael Gross
      Posted by Jens-Michael Gross
      on Aug 28 2012 12:48 PM
      Verified Answer
      Verified by Arcady Trembovler
      Guru139900 points

      Arcady Trembovler
      instead of mocking me

      As Tony already wrote, my intention wasn't to mock you but to tell you that you already got the answer - and declared it for b-s.

      Microcontroller programming is not only software but also hardware. If you don't want to take care of hardware requirements, you won't get far.
      A pushbutton is not a device with OS-provided API. It is a simple switch that connects a hardware port pin to GND signal level. And when you release it, the port pin will still be on GND level if there is nothing 'pulling it up' again. These are the pullups the people were talking about.

      You got the solution, but you didn't understand it and even didn't try to understand it and instead of asking for an explanation, you asked for a solution that you like better. That's the way managers operate, not engineers. And definitely the wrong approach in the microcontroller world.

      However, you already got a code fix posted above. But I guess you still do not understand why it was needed and how it works. And even though your program now may work as intended, it most likely hasn't helped you a single bit towards your first own project. And you'll likely need the same kind of help for the next component you want to use - a waste of our time and yours.

      _____________________________________
      Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.
      If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • old_cow_yellow
      Posted by old_cow_yellow
      on Aug 28 2012 13:54 PM
      Guru25715 points

      JMC,

      I am with you deep in my heart. And I admire what you did.

      But, observing the current trend here and elsewhere, I became very cynical. Most people do not want to know why or how. All they care about is “send me the c code”. I gave up on being Man of La Mancha.

      --OCY

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Arcady Trembovler
      Posted by Arcady Trembovler
      on Aug 28 2012 14:22 PM
      Verified Answer
      Verified by Arcady Trembovler
      Prodigy85 points

      First, fellas, big thanks to everybody..
      If you, JMC, would be so informative in the beginning, I would be very greatful. You told me to "go study" when there is nowhere to study from! 

      You spotted me right-on... I study computer science, not electronics, and that's why I decided to begin with the Launchpad, so I guess this is the reason why this "transformation" is not very intuitive for me. 
      There are no books about MSP430G2 Launchpad, and the only thing I got in this world is this forum (and other forums which aren't any different, so all I can do is learn from examples). If I could read it out somewhere I would. Maybe I don't know where to look, so if you have few favorite books/sites to recommend I'd gladly check them out.

      I noticed that the code used for MSP430G2231 isn't working on my MSP430G2553  and I had no idea why; Yes, people mentioned pull-up resistors but never bothered explaining..

      I hope you understand my point of view on things and where I am coming from - I wouldn't mind reading some theory - problem is - I don't know what to read!

      If you have any books to recommend - I'd be glad to check them out!

      Thanks again!

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • TonyKao
      Posted by TonyKao
      on Aug 28 2012 16:30 PM
      Verified Answer
      Verified by Arcady Trembovler
      Genius3770 points

      Hi Arcady,

      I remember stumbling upon "MSP430 Microcontroller Basics" by John H. Davie, which was written by the author to be used as the second half of a digital electronics course; from my brief skimming the book looked very well written so you may want to check it out.

      There is also the free "MSP430 Teaching ROM" by Texas Instruments which is meant for use in a university course.

      As for more general information on digital electronics, there's a plethora of resources available on the 'Net, just google for "digital logic", "digital circuits", and the like.

      Hope this helps. Happy learning!

      Tony

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Jens-Michael Gross
      Posted by Jens-Michael Gross
      on Aug 29 2012 05:59 AM
      Guru139900 points

      Arcady Trembovler
      If I could read it out somewhere I would

      A google search for 'pullup resistor' links to wikipedia with the very first hit. It gives a fairly complete description of what pullup resistors are and why they are needed and how they are used. Including lots of links explaining the different electronic parts.

      he only MSP-(and therefore LaunchPad-)related information regarding this issue is that most newer MSPs, including the G2 series, have internal pullup resistors that can be activated by software. This info is in the digital I/O chapter of the 2x family users guide that should be read by everyone whoo uses a 2xx family device including the G2. It can be downloaded form the LaunchPad product page, along with the device datasheet for the processors. And that earlier versions of the LaunchPad did have an external pullup-resistor soldered at the pushbutton, which has been removed on newer revisions to allow analog usage of teh pin (if the button isn't pressed, it is electrically invisible. The pullup, however, did influence analog signals)

      My own book about the MSP processors is far from being complete and not released yet.(and at the current pace, I doubt I'll ever finish it) But it won't cover basics of electronic circuitry too. Except a few things that are less commonly known by 'normal' electronic engineers but are important for the MSP.

      _____________________________________
      Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.
      If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • albert pormento
      Posted by albert pormento
      on Jan 31 2013 20:06 PM
      Prodigy10 points

      hey arcady,,

      in your code, add P1IES |= 0x08;

      arcady
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    TI E2E™ Community
    • Support Forums
    • Blogs
    • Videos
    • Groups
    • Site Support & Feedback
    • Settings
    TI E2E™ Community Groups
    • TI University Program
    • Make the Switch
    • Microcontroller Projects
    • Motor Drive & Control
    Other Communities
    • Deyisupport
    • Designsomething.org
    • beagleboard.org
    • TI on Element 14
    • TI on TechXchangeSM
    Other Technical & Support Resources
    • WEBENCH® Design Center
    • Product Information Centers
    • Technical Documents
    • TI Design Network
    • TI Technical Articles
    • TI Training

    All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

    Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

    Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
    TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

    TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
    embedded processors, along with software, tools and the industry’s largest sales/support staff.

    © Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
    Trademarks | Privacy Policy | Terms of Use