• 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 » NMI won't work in my code or example code
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 >
  • NMI won't work in my code or example code

    NMI won't work in my code or example code

    This question is answered
    Steven Mills
    Posted by Steven Mills
    on Aug 03 2012 12:22 PM
    Prodigy140 points

    I've configured the RST/NMI pin to be a non-maskable interrupt.

    The voltage on the RST/NMI pin is pulled down when I press switch S2, but the interrupt never occurs. I have set NMIIE.

    Here is the example code which is pretty much the same thing I tried to implement in my code. Neither work.

    Any ideas?

    Thanks

    //******************************************************************************
    //  MSP430G2xx2 Demo - Basic Clock, Configure RST/NMI as NMI
    //
    //  Description: Configure RST/NMI as NMI, hi/lo edge. Flash P1.0  inside of
    //  NMI_ISR if NMI occurs. General enable interrupt in status register does
    //  not need to be set for NMI. NMIIE does need to be reset, as NMI_ISR
    //  automatically clears NMI enable to prevent unintentional stack overflow
    //  that could result from, bounce or uncontrolled NMI's.
    //  ACLK = n/a, MCLK = SMCLK = DCO ~ 800k
    //
    //               MSP430G2xx2
    //            -----------------
    //        /|\|              XIN|-
    //         | |                 |
    //         --|RST          XOUT|-
    //           |                 |
    //
    //  D. Dang
    //  Texas Instruments Inc.
    //  December 2010
    //  Built with CCS Version 4.2.0 and IAR Embedded Workbench Version: 5.10
    //******************************************************************************

    #include  <msp430g2452.h>

    void main(void)
    {
      WDTCTL = WDTPW + WDTHOLD + WDTNMI + WDTNMIES;  // WDT off NMI hi/lo
      P1DIR |= 0x01;                            // Set P1.0 to output direction
      P1OUT &= ~0x01;                           // Clear P1.0 LED off
      IE1 |= NMIIE;                             // Enable NMI

      _BIS_SR(LPM0_bits);                       // Enter LPM0
    }

    #pragma vector=NMI_VECTOR
    __interrupt void nmi_ (void)
    {
      volatile unsigned int i;
      P1OUT |= 0x01;                            // Set P1.0 LED on
      for (i = 20000; i > 0; i--);              // Delay
      P1OUT &= ~0x01;                           // Clear P1.0 LED off
      IFG1 &= ~NMIIFG;                          // Reclear NMI flag in case bounce
      IE1 |= NMIIE;                             // Enable NMI
    }

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • Steven Mills
      Posted by Steven Mills
      on Aug 03 2012 12:51 PM
      Prodigy140 points

      OK, so it seems to work if I'm not using the debugger. The red LED came on if I just plugged the board in and pressed the switch, but if the program is running in the debugger then it never lights up.

      This is going to make it difficult to work on my code... I don't understand why it would happen like this.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Tony Philipsson
      Posted by Tony Philipsson
      on Aug 03 2012 13:02 PM
      Intellectual760 points

      Are you using the launchpad?
      Are you still in debug mode when running code?, may have to unplug RST jumper while testing.

       

      Warning:
      Only use the NMI as a last resort, and only if it can be added last in development.
      You can not debug your code once it's set.

      You can not read its current state, your interupt routine would have to set flags etc.
      And noise on a mechinical switch will trigger false low-high-low signals,
      So use a hardware debouncer like this instead of the 47k pull-up resistor.
      (R1 & R2 = 20k, C = 2nF)
       http://www.ganssle.com/images/debouncerrc.jpg

       

       


       

       

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Mo.
      Posted by Mo.
      on Aug 07 2012 08:17 AM
      Verified Answer
      Verified by Steven Mills
      Genius10245 points

      Steven Mills
      OK, so it seems to work if I'm not using the debugger.

      That is a correct behavior. You will not get the external NMI interrupt when the debugger is connected to the Target. This is because the debugger will have full control over the Target device and will effectively disable the external Reset/NMI.

      Steven Mills
      This is going to make it difficult to work on my code...

      On way to get the NMI interrupt while the Target is attached to the debugger, is by manually setting the NMI interrupt Flag bit in the IDE.

      Hope this helps, otherwise please let me know.

      BR,

      Mo.

      Make The Switch to TI MCUs

      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