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.

RST/NMI pin as NMI interrupt on MSP430F5438A

Other Parts Discussed in Thread: MSP430F5438A, MSP430F5328

hi,
I want to write program of blinking led using NMI interrupt on RST/NMI pin. I kept breakpoint unmi_isr routine.
But controller is not coming into unmi_isr routine when RESET/NMI button is pressed on MSP430F5438A development kit.
Can any one help what I have to change in the code given below.
/***********************************************/
#include <msp430.h>
int main(void)
{
    WDTCTL = WDTPW + WDTHOLD ;                 // Stop WDT
        P1DIR |= 0x01;                            // Set P1.0 to output direction
    __bis_SR_register(GIE);
    SFRIFG1 &= ~0x10;                           // NMi IFG cleared
    SFRRPCR |=0x1;
    SFRIE1|=0x10; //NMIIE
    P1OUT &= ~0x01; // led is off
      while(1);

}

#pragma vector=UNMI_VECTOR
__interrupt void unmi_isr(void)
{
    P1OUT ^= 0x01;
    SFRRPCR |=0x0;

}

/*******************************************************/


regards,
y v subba rao

  • Hello there.

    I haven't use this chip myself, but maybe setting the SYSNMIIES field to 1 will help.

    SFRRPCR |= SYSNMIIES | SYSNMI

    This makes the interrupt to be called when a falling edge is detected on the RST/NMI pin. By default it is triggered on rising edge.

    Well, actually I'm not quite sure if this is right, since if you release the button, a rising edge event should be detected on that pin, but try it.

    Also I don't think that you need to call GIE, since NMI is a non-maskable interrupt, but CMIIW. You might need to clear the SFRIFG1 by software at the end of the ISR. I don't find anywhere at the datasheet that this register is cleared automatically.

  • subba rao y v said:
        SFRRPCR |=0x0;

    This line is a NOP: OR operation with 0 results in no change.

    I guess you wanted to clear the bit:

    SFRRPCR &= ~(SYSNMI);

    You should also clear the SFRIFG and/or teh SFRIE register. Clearing the SYSNMI bit in SFRRPCR will only make the NMI pin a reset pin again (and due to bouncing, this might cause an immediate reset as soon as you do so).

    But the NMI is still pending as you didn't 'handle' it - either by clearing the IFG bit, clearing the IE bit or reading the SYSUNIV register

    Anyway, in SBW mode, the RST pin is not available at all, and reprogramming RST to NMI will prohibit external resets or entering BSL mode. You should think of using one of the other interrupt-capable pins instead. Really. (not that you have lack of port pins on this MSP: it's the biggest MSP out there and there is almost NO REASON to (ab)use the RST pin for interrupts)

  • The Below Code Will works , I tested On MSP430F5438A...,

    #include <msp430.h>
     
    int main(void)
    {
     
      int len,jlen;
      WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog timer
      P1DIR |= 0x01; // Set P1.7 as output
        __bis_SR_register(GIE);
      //NMI Configuration
     SFRIFG1 &= ~0x10;                         // NMi IFG cleared
     SFRRPCR =0x3;
     SFRIE1|=0x10;                               //NMIIE
     
     
                                       // Test P1.4
      while(1){
           P1OUT = 0x01;
           for(len=0;len<200;len++)
                      {
                          for(jlen=0;jlen<500;jlen++);
                      }
              P1OUT = 0x00;
              //__bis_SR_register(LPM4_bits);   // Enter LPM3
              for(len=0;len<200;len++)
                                {
                                    for(jlen=0;jlen<500;jlen++);
     
                                }
      }
    }
     
    #pragma vector=UNMI_VECTOR
    __interrupt void unmi_isr(void)
    {
        unsigned int i;
         int len,jlen;
     
        
        P1OUT = 0x01;
             for(len=0;len<1000;len++)
             {for(jlen=0;jlen<700;jlen++);}
        do
        {
            SFRIFG1 &= ~0x10;                      // Clear NMI Fault flag
            for (i = 0xFFFF; i > 0; i--);           // Time for flag to set
         }while ( (SFRIFG1 & NMIIFG) );
     
    }

  • Jens-Michael Gross said:

    Anyway, in SBW mode, the RST pin is not available at all, and reprogramming RST to NMI will prohibit external resets or entering BSL mode. 

    I am not so sure that this is true. At least it doesn't seem to be in my case. I am using the MSP430F5328. I have a setup where, through an external bluetooth module, I can perform an OTA firmware update to the MCU by using the bluetooth module to toggle the MCU's RST and TEST pins in the specific sequence that puts it in BSL mode.

    I have a fleet of over a thousand units in the field and perform OTA updates on them regularly. Recently, we have noticed some  erratic behavior on a handful of units that has led us to believe that the RST pin is getting pulled low and causing the MCU to reset. This is causing undesired behavior. 

    In an attempt to clear up this problem, we are looking into changing the RST/NMI pin's functionality from RST to NMI with not interrupt enabled. That way, any transients on the line will be completely ignored.

    After changing the pin's functionality, we can program it using the 430-FET programmer in SBW mode. Additionally, our OTA functionality that relies on programming the MCU over BSL seems to work just fine after the RST pin has been reconfigured.

    Based on the results of our tests, we are planning on moving forward with the RST pin config change. Is there anything we are overlooking that might come back to bight us later?

      

  • That's not a contradiction. Once you programmed the RST pin for NMI, a signal on the pin won't trigger a reset anymore. So you can't reset the MSP and therefore cannot enter BSL mode (which requires a reset).
    The key is to NOT start the user code that switches to NMI after a power-cycle. E.g. by keeping RST low while power is applied, then perform the entry sequence. If the device is powered by the FET, this is no problem. If it is self-powered, it might become a problem.
    Also keep in mind that you'll need RST for SBW debugging.

**Attention** This is a public forum