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.

MSP430FR2422: Control getting hung in active mode

Part Number: MSP430FR2422
Other Parts Discussed in Thread: MSP430FR2433

 MSP430FR2422 used as RTC with 3.0v battery as backup.

System runs @ 5v supply during normal operation (AM).when no power (5v) system switches to 3.0v battery supply and controller switches 

to LPM3,5 with wakeup source as pin interrupt and RTC timer overflow interrupt .

Problem Case: when system running from 5v in active mode ,some time controller hangs and never recovers.  Only recovers on Power on reset.

Note : When controller hangs its observed that its always in active mode not in LPM. 

 

  • Hi Prashanth,

    You are not running the MSP430FR2422 from the 5V rail directly right? Based on your wording I would assume not, but I just want to be sure. Also, are you seeing this on multiple boards, or just a single one? 

    to LPM3,5 with wakeup source as pin interrupt and RTC timer overflow interrupt 

    How do you have your RTC Counter configured and what is the interval for your timer overflow? 

    If you decrease this interval, do you see the failure happens faster? 

    Problem Case: when system running from 5v in active mode ,some time controller hangs and never recovers.  Only recovers on Power on reset.

    Note : When controller hangs its observed that its always in active mode not in LPM. 

    How long does it normally take for a failure to occur? Also, how are you determining the power mode, is it by current measurement or through another method?

    Best Regards,
    Brandon Fisher

  • hi,

    MSP430FR2422  will get power from two sources 

    1. external 5v which will be converted to 3.1 v .

    2.onboard battery 3.1v in absence of external supply.

    How do you have your RTC Counter configured and what is the interval for your timer overflow? 

    RTC counter configured with external crystal(32768 hz which is further divided by   1024.

    under normal operation(AM) it overflows @34 min i.e 65279 counts

    during transition from AM to LPM3.5.

    RTC will be reconfigured to have a overflow at 2sec i.e 64 counts .This is done so that we can validate the 

    power transition and its not triggered due to noise. After validation RTC overflow is configured back to 34 min.

    Power down detection is done using ADC (which is configured with v ref internal 1.5v) .

     

    if(gAdcFltr>=10)       power down detected 
    {

        UCA0IE &= ~UCRXIE;     // diable UART interrupt
       gAdcFltr=0;
       *(unsigned int *)(BKMEM_BASE+2) = (*(unsigned int*)&timeStamp[0]);
       *(unsigned int *)(BKMEM_BASE+4) = (*(unsigned int*)&timeStamp[2]);

       SYSCFG2 &= ~(ADCPCTL3);
      P1SEL0 = 0;
      P1SEL1 = 0;

      P1DIR = (BIT0 |BIT1 |BIT2 | BIT3| BIT4| BIT5| BIT6| BIT7);
      P2DIR = (BIT2 | BIT3| BIT4| BIT5| BIT6| BIT7);

       P1OUT = 0;
       P2OUT = 0;

       P2IES = 0x00; // Low to High edge
       P2IFG = 0;
       P2IE = 0;
       //________________________

      ADCCTL0 &= ~(ADCSHT_2 | ADCON); // ADCON, S&H=16 ADC clks
       ADCCTL1 &= ~ADCSHP; // ADCCLK = MODOSC; sampling timer
       // ADCCTL2 |= ADCRES; // 10-bit conversion results
       ADCIE &= ~ADCIE0; // Enable ADC conv complete interrupt
        ADCMCTL0 &= ~(ADCINCH_3 | ADCSREF_1); // A1 ADC input select; Vref=1.5V
       

          // RTC OVERFLOW CHANGED TO 2SEC
        {
                 unsigned int temp;
                 RTCMOD = 64;
                 temp = RTCCNT;
                 RTCCTL = 0x2742;           // reset the RTC counter 
                gRtcTMRCntVal += temp;
                gRtcSecCounter += (gRtcTMRCntVal/32);
                gRtcTMRCntVal = gRtcTMRCntVal%32;
        }

    //_________entering LMP3.5______________

       PMMCTL0_H = PMMPW_H; // Open PMM Registers for write
        PMMCTL0_L |= PMMREGOFF; // and set PMMREGOFF
        PMMCTL2 &= ~INTREFEN; // disable internal reference
        PMMCTL0_H = 0; // Lock PMM Registers
         __no_operation();
         __no_operation();
         __no_operation();
         __bis_SR_register(LPM3_bits | GIE); // Go to LPM3 with interrupt
          __no_operation();
    }

  • Hi Prashanth,

    I assume this code is part of a larger control loop as well? What does your ISR look like? 

    Is this occurring on multiple boards and do boards which fail at 5V fail consistently? 

    Best Regards,
    Brandon Fisher

  • hi Brandon,

    following is my main uart iSR is missing(no such  hanging code present there ,but i am not clearing any flags there assuming flags are auto clear ) in this ,

    multiple board this issue is present,

    test condition :board is run with continuous 5v supply, rtc board it connected to another board from which the 5v is 

    supplied to our rtc board .Load like motor and solenoids are connected to other board so it could be noisy.

    some time board hangs in 10 min some time it takes even one day also.  

    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2014, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     *
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //   MSP430FR2422 Demo - RTC, device enter LPM3.5 and toggle P1.0 in RTC
    //                       interrupt handling every 1s
    //
    //
    //   Description: Device enter LPM3.5 after configuring the RTC. The RTC wakes
    //   the device up from LPM3.5 every second and toggles P1.0.
    //   It also stores the state of P0OUT in the Backup RAM Registers.
    //
    //   XT1 = 32kHz, ACLK = default, MCLK = SMCLK = default, DCODIV = ~1MHz.
    //
    //            MSP430FR2422
    //         -----------------
    //     /|\|                 |
    //      | |                 |
    //      | |        XIN(P2.0)|--
    //      --|RST              |  ~32768Hz
    //        |       XOUT(P2.1)|--
    //        |                 |
    //        |             P1.0|-->LED
    //
    //  Rui Ji
    //  Texas Instruments Inc.
    //  May 2017
    //  Built with IAR Embedded Workbench v6.50 & Code Composer Studio v7.0.0
    //******************************************************************************
    #include <msp430.h>
    #include <string.h>
    #include <stdlib.h>
    #include "app\sysDef.h"
    #include "app\SerialCom.h"
    #include "app\flashStorage.h"
    #include "app\dataFrames.h"
    #include "app\myRtc.h"
    #include "app\utility.h"
    
    
    
    
    //#pragma PERSISTENT (timeStamp)
    unsigned char timeStamp[4] = {0};
    #pragma PERSISTENT (gMemoryExtRtcAry)
    unsigned char gMemoryExtRtcAry[sizeof(EXT_RTC_STRUCT)] = {0};
    #pragma PERSISTENT (tst)
    unsigned char tst=0;
    
    
    extern unsigned char uartRcvdByte;
    extern void frameProcess(void);
    extern volatile unsigned char dataFrameFlg,dataIndex;
    extern   unsigned char uartDataFrame[];
    extern RTC_VALUE_STRUCT gRtc;
    //_____Function protos_____________________________________
    void adcInit(void);
    void sysInit(void);
    void uartInit(void);
     void enterLPM_3_5(void);
    unsigned char isFlashWrtRqd(void);
    void clearOCD(void);
    void dly1(unsigned int count);
    void dly_pump_check_at_powerup(void);
    void sysInit(void);
    void processFilterLife(void);
    void filter_life_update(void);
    void ResetFunctionality(void);
    unsigned char isTimeValid(RTC_VALUE_STRUCT* time);
    unsigned char rtcTimeValidation(void);
    void updateServiceDays(void);
    unsigned long getDateTimeInMin(RTC_VALUE_STRUCT date);
    unsigned int getAdc(void);
    //________________________Variables________________________
    
    unsigned char gCryptoCode1,gRand1;
    const unsigned int gMntToDays[13]={0,0,31,59,90,120,151,181,212,243,273,304,334};
    
    volatile Sflags  gFlags;
    volatile struct ProductStatus   productStatus;
    
    unsigned char gSecCounter;
    unsigned char rquestId=0,rqstReTry;
    EXT_RTC_STRUCT gExtRtcData,gStoredExtRtcData,gMemoryExtRtcData;
    volatile unsigned char  g_Mode=0,g_PowerOnDly,gRtcReady;
    volatile unsigned char  g_Mode11;
    unsigned int ADC_Result=0;
    volatile unsigned char gAdcReady=0;
    volatile unsigned char gAdcFltr=0;
    volatile unsigned char gTmOutCntr=0;
    //________________________________________________________
    
    int main(void)
    {
        WDTCTL = WDTPW | WDTHOLD;               // Stop WDT
      //  SFRRPCR  |= (SYSRSTUP__PULLUP|SYSRSTRE__ENABLE);
        SFRRPCR  |= (SYSRSTUP__PULLUP|SYSRSTRE__ENABLE|SYSNMI__NMI);
    
        P1DIR  =  (BIT0 |BIT1 |BIT2 | BIT3| BIT4| BIT5| BIT6| BIT7);        // make all port output and make it zero
        P2DIR = ( BIT3| BIT4| BIT5| BIT6| BIT7);
        P1OUT = 0;
        P2OUT = 0;
    
    
        //___ Initialize XT1 32kHz crystal______________________________________
        P2SEL1 |= BIT0 | BIT1;                  // set XT1 pin as second function
        do
        {
            CSCTL7 &= ~(XT1OFFG | DCOFFG);          // Clear XT1 and DCO fault flag
            SFRIFG1 &= ~OFIFG;
        }while (SFRIFG1 & OFIFG);                   // Test oscillator fault flag
    
        __bis_SR_register(SCG0);                    // disable FLL
        //CSCTL3 |= SELREF__XT1CLK;                 // Set XT1CLK as FLL reference source
        CSCTL3 |= SELREF__REFOCLK;                  // Set XT1CLK as FLL reference source
        //CSCTL4 = SELMS__XT1CLK | SELA__XT1CLK;    // set ACLK = XT1CLK = 32768Hz
        CSCTL4 = SELA__XT1CLK;                      // set ACLK = XT1CLK = 32768Hz
    
    
        //SFRIE1 |= OFIE;                           //enable interrupt for oscillator fault
        //______________________________________________________________________
    
    //    PM5CTL0 &= ~LOCKLPM5;                   // Disable the GPIO power-on default high-impedance mode to activate previously configured port settings
    
        // First determine whether we are coming out of an LPMx.5 or a regular RESET.
        if (SYSRSTIV == SYSRSTIV_LPM5WU)        // When woken up from LPM3.5, reinit
        {
           // RTCIV = 0;
    
            if(RTCIV)                           // code restarted with rtc overflow?
            {
    
    
                if(RTC_LPM_RELOAD != RTCMOD)    //rtc in normal(34min) or  its validating mode(2 sec)?
                {
                    unsigned int temp;
                    gRtcSecCounter+=2;
    
                    RTCMOD = RTC_LPM_RELOAD;    //  34 min overflow
                    temp  = RTCCNT;
                    RTCCTL = 0x2742;            // reset counter
                    gRtcTMRCntVal += temp;
    
                }else
                {
                               // overflow time keeping
                    RTC_TEMP_CNTR = (RTC_TEMP_CNTR+ 1);
                }
                RTCIV=0;                        // clear interrupt flag
            }
            else                // woke up due to power on wake up pin  so enter into lpm for validation 2 sec
            {
                //entering into rtc validation mode
                {
                     unsigned int temp;
                     RTCMOD = RTC_VALIDATION_RELOAD0;
    
                     temp  = RTCCNT;
                     RTCCTL = 0x2742; // reset counter
                     gRtcTMRCntVal += temp;
                     gRtcSecCounter += (gRtcTMRCntVal/32);
                     gRtcTMRCntVal = gRtcTMRCntVal%32;
                 }
    
                P2IFG = 0;
                P2IE   = 0;                             // disable pin wake up
                PM5CTL0 &= ~LOCKLPM5;
                PMMCTL0_H = PMMPW_H;                    // Open PMM Registers for write
                PMMCTL0_L |= PMMREGOFF;                 // and set PMMREGOFF
                PMMCTL0_H = 0;                          // Lock PMM Registers
                 __no_operation();
                 __no_operation();
                 __bis_SR_register(LPM3_bits | GIE); // Go to LPM3 with interrupt
                 __no_operation();
            }
    
            // code comes her only on rtc wake up RTC validation
    
            P2DIR &= ~BIT2;
            P1DIR &= ~BIT3;
            PM5CTL0 &= ~LOCKLPM5;
            P2IFG = 0;
    
            if(POWER_STATUS!=0)                         // chaeck power condition
            {                                           // powered
    
                (*(unsigned int*)&timeStamp[0])=*(unsigned int *)(BKMEM_BASE+2);
                (*(unsigned int*)&timeStamp[2])=*(unsigned int *)(BKMEM_BASE+4);
    
                uartInit();
                //______timer____________________
                TA0CCTL0 |= CCIE;                   //eNABLE INTERRUPT
                TA0CTL = TASSEL_1+MC_1+ID_3;        //TASSEL_1 -use ACLK,MC_1 upcount,ID_3 -divide by 3
                // TA0CTL = TASSEL_1+MC_0+ID_3;     //TASSEL_1 -use ACLK,MC_0 hALT,ID_3 -divide by 3
                TA0CCR0 = 2048;//;                  //500msec value
    
                //________________Port Pin Interrupt______________
    
                P2IE   = 0;         // disable interrupt
                //____________adc config_____________
                  {
    
    
                     adcInit();
    
                  }
    
                __enable_interrupt();
            }else                           // not powered  enter into LPM with pin interrupt
            {
    
               //Entering into Low power mode with wakeup interrupt
                P2DIR &= ~BIT2;
                P1SEL0 = 0;
                P2SEL1 = BIT0 | BIT1;
                P1OUT = 0;
                P2OUT = 0;
    
                P2IES  = 0x00;                          // 2.2 Low to High edge
                P2IFG = 0;
                P2IE   = BIT2;                          // enable pin interrupt
    
                PMMCTL0_H = PMMPW_H;                    // Open PMM Registers for write
                PMMCTL0_L |= PMMREGOFF;                 // and set PMMREGOFF
                PMMCTL0_H = 0;                          // Lock PMM Registers
                __no_operation();
                __no_operation();
                __bis_SR_register(LPM3_bits | GIE); // Go to LPM3 with interrupt
                __no_operation();
    
            }
    
    
    
    
    
    
        }
        else                // restart due to reset or power on reset
        {
            RTC_VALUE_STRUCT dd;            // load a default time value
            dd.min =0;
            dd.hr = 1;
            dd.day = 1;
            dd.month = 1;
            dd.year =22;
    
    
            // Device powered up from a cold start.
            uartInit();
    
            //PM5CTL0 &= ~LOCKLPM5;
            RTC_TEMP_CNTR = 0;
            gRtcTMRCntVal = 0;
            gPwrOffCount  = 0;
            gPwrOffCount_Dbg=0;
            gRtcSecCounter=0;
            gRtcVlidnReloadInex=0;
            // Initialize RTC
            SYSCFG2 = RTCCKSEL;                              // Set RTC CLK to ACLK
            RTCMOD = RTC_LPM_RELOAD;
            RTCCTL = RTCSS__XT1CLK | RTCSR | RTCPS__1024 | RTCIE;
    
    
              //______timer____________________
             TA0CCTL0 |= CCIE;                //eNABLE INTERRUPT
             TA0CTL = TASSEL_1+MC_1+ID_3;    //TASSEL_1 -use ACLK,MC_1 upcount,ID_3 -divide by 3
             // TA0CTL = TASSEL_1+MC_0+ID_3;  //TASSEL_1 -use ACLK,MC_0 hALT,ID_3 -divide by 3
             TA0CCR0 = 2048;//;                 //500msec value
    
             //________________Port Pin Interrupt______________
             P1OUT  = 0x00;
             P2IE   = 0;         // disable interrupt
             //____________adc config_____________
               {
                  adcInit();
    
               }
    
             (*(unsigned long*)timeStamp)=convertDateToTmStamp(&dd);
             __enable_interrupt();
        }
    
    //________________App start_______________________________________________
    
        P1DIR |= BIT2;              // enable TXT level conversion
        P1OUT |= BIT2;              // enable TXT level conversion mosfet turned on
        PM5CTL0 &= ~LOCKLPM5;
        initFlashData();
        gRtcReady=0;
        gAdcFltr =0;
    
    
    
    
        __bic_SR_register(SCG0);            // enable fll
    
        #ifdef _DEBUG
          uart1_put_value("Start",1);
        #endif
    
          //______________Init Variable______________________________________________
    
          memset((unsigned char*)&productStatus,0,sizeof(struct ProductStatus));
          memset((unsigned char*)&gFlags,0,(sizeof(Sflags)));
    
          SEC_LOOP_FLG = 0;
          gSecCounter = 0;
          g_Mode = 0;
          g_PowerOnDly = PWR_ON_DLY;
    
    
          // To out put aclk clk @ P11
    
          P1DIR  |=(BIT1|BIT2);
          P1SEL1 |= BIT1 ;
    
    
    
    
          while(1)
          {
    
    
             enterLPM_3_5();            // check power condition
    
              //___________Delay Timer_______________________________
            if(_500mSEC_TOGLE_STATUS)
            {
              _500mSEC_TOGLE_STATUS = 0;
              _500mSEC_LOOP_FLG     = 1;
              gSecCounter++;
              if(gSecCounter>1)
              {
                  SEC_LOOP_FLG = 1;
                  gSecCounter  = 0;
              }
            }
    
              //__________________data frames _____________________________________
    
    
          if(dataFrameFlg == 2 )                  // frames available for processing
          {
    
              frameProcess();
    
              dataFrameFlg =0;
              dataIndex =0;
          }
          else                    // periodic data frames
          {
              if(_500mSEC_LOOP_FLG==1)
              {
                 //if(rquestId == 0)
                  {
                      if(gRtcReady)   putDateTime(CMD_PERIODIC);
                  }
                 /*else
                  {
                     if(gRtcReady)
                      putDateTime(CMD_PERIODIC);
    
                  }*/
              }
    
    
          }
    
    
         //__________________1 Sec Section__________________________________________
    
          if(SEC_LOOP_FLG)
          {
    
    
            //  if(g_PowerOnDly == 0)
              {
                  readRTC();
                  gRtcReady = 1;
              }
    
    
    #ifdef _DEBUG
              {
                 // char str[30]={0};
    
               /* strcat(str, "Rtc ");
                itoa(gRtc.hr,(unsigned char*)&str[strlen(str)]);
                strcat(&str[strlen(str)], ":");
                itoa(gRtc.min,(unsigned char*)&str[strlen(str)]);
                strcat(&str[strlen(str)], ":");
                itoa(secRTC,(unsigned char*)&str[strlen(str)]);
                strcat(&str[strlen(str)], "  ");
                itoa(gRtc.day,(unsigned char*)&str[strlen(str)]);
                strcat(&str[strlen(str)], "/");
                itoa(gRtc.month,(unsigned char*)&str[strlen(str)]);
               strcat(&str[strlen(str)], "/");
                itoa(gRtc.year,(unsigned char*)&str[strlen(str)]);
                uart1_put_value((unsigned char*)str,0);
    */
                  // uart1_put_value("PC",gPwrOffCount_Dbg);
                   
    
    
    
              }
    #endif
    
    
              //___________________Flash Write___________________________________
              if(productStatus.status9.status9_bits.compStatus == 1)
              {
    
                  if(isFlashWrtRqd())
                  {
                     Write_DATAFLASH_ARRAY((unsigned char *)&gStoredExtRtcData,sizeof(EXT_RTC_STRUCT));
                     memcpy(&gMemoryExtRtcData,&gStoredExtRtcData,sizeof(EXT_RTC_STRUCT));
    //                      uart0_put_value("Flash Write  :",1);
                  }
    
              }
    
    
          }
    
          //__________________end of 1 Sec Section__________________________________________
    
    
          if(g_PowerOnDly)
          {
              g_Mode = MODE_POWER_ON;
              secDownCounter((unsigned char*)&g_PowerOnDly);
          }
          else
          {
             g_Mode = MODE_IDLE;
    
          }
    
              //______________________________________________________
              SEC_LOOP_FLG = 0;
              _500mSEC_LOOP_FLG = 0;
    
          }
    
    
    }
    
    
    
    #pragma vector = RTC_VECTOR
    __interrupt void RTC_ISR(void)
    {
        RTCIV = 0;
        RTC_TEMP_CNTR += 1;
    }
    
    #pragma vector=PORT2_VECTOR
    __interrupt void Port_2(void)
    {
             //Clear P1.3 IFG if no port1 pins are configured as interrupt
             //   uart1_put_value("int P2 ",P2IN);
                P2IFG = 0;
    
    }
    #pragma vector=PORT1_VECTOR
    __interrupt void Port_1(void)
    {
                P1IFG = 0;                            //Clear P1.3 IFG if no port1 pins are configured as interrupt
    
    }
    
    // TIMER A  interrupt service routine
    #pragma vector=TIMER0_A0_VECTOR
    __interrupt void TIMER0_A0_ISR(void)
    {
        _500mSEC_TOGLE_STATUS = 1;
        TA0CCTL0 &= ~CCIFG;
    
    }
    
    
    #pragma vector=UNMI_VECTOR
    __interrupt void UNMI_ISR(void)
    {
        /* do
           {
               // set a breakpoint on the line below to observe XT1 operating from VLO
               // when the breakpoint is hit during a crystal fault
               CSCTL7 &= ~XT1OFFG;                 // Clear XT1 fault flag
               SFRIFG1 &= ~OFIFG;
    
               __delay_cycles(25000);              // time for flag to get set again
           }while (SFRIFG1&OFIFG);                 // Test oscillator fault flag
       */
    
    
         //  SFRIFG1 &= ~NMIIFG;
    }
    
    
    unsigned char isFlashWrtRqd(void)
    {
    //  if(compRTC_DateTime())
    //  {
    //      //if(gExtRtcData.flags.RTC_startBit ==1)
    //      {
    //          gStoredExtRtcData.gRtcValue.year = gExtRtcData.gRtcValue.year;
    //          gStoredExtRtcData.gRtcValue.month = gExtRtcData.gRtcValue.month;
    //          gStoredExtRtcData.gRtcValue.day = gExtRtcData.gRtcValue.day;
    //          gStoredExtRtcData.gRtcValue.hr = gExtRtcData.gRtcValue.hr;
    //          gStoredExtRtcData.gRtcValue.min = gExtRtcData.gRtcValue.min;
    //          return 1;
    //      }
    //  }
    
        if(gStoredExtRtcData.flags.RTC_startBit != gMemoryExtRtcData.flags.RTC_startBit) return 1;
    //  if(gStoredExtRtcData.flags.RTC_tamperedBit != gMemoryExtRtcData.flags.RTC_tamperedBit) return 1;
    //  if(abs(gStoredExtRtcData.actualDays - gMemoryExtRtcData.actualDays) > 0) return 1;
    
        return 0;
    }
    
    unsigned char isTimeValid(RTC_VALUE_STRUCT* time)
    {
    
        if((time->min>59)||(time->hr>23)||(time->day>31)||(time->day<1)||(time->month>12)||(time->month<1)||(time->year<21)||(time->year>99))
        {
            return 0;
        }
        return 1;
    }
    //unsigned char rtcTimeValidation(void)
    //{
    //  unsigned long time1=0;
    //  unsigned char ret = 0;
    //  if(productStatus.status9.status9_bits.compStatus == 1)
    //  {
    
    
    //          time1 = getDateTimeInMin(gStoredExtRtcData.gRtcValue);
    ////            time1=((unsigned long)(gStoredExtRtcData.gRtcValue.year*365)*(24 *60));
    ////            time1+=((unsigned long)gMntToDays[gStoredExtRtcData.gRtcValue.month]*(24 *60));
    ////          time1+=(gStoredExtRtcData.gRtcValue.day*24*60);
    ////          time1+=((gStoredExtRtcData.gRtcValue.hr*60)+gStoredExtRtcData.gRtcValue.min);
    //
    //          currentTime = getDateTimeInMin(gRtc);
    ////            currentTime=((unsigned long)(gRtc.year*365)*(24 *60));
    ////          currentTime+=((unsigned long) gMntToDays[gRtc.month]*(24 *60));
    ////          currentTime+=(gRtc.day*24*60);
    ////          currentTime+=((gRtc.hr*60)+gRtc.min);
    //
    //
    
    
    //
    //          if(currentTime>=time1)
    //          {
    //
    //              ret= 0;
    //
    //          }
    //          else
    //          {
    //              ret= RTC_TAMPERED;
    //              //uart0_put_value("t set : ",2);
    //              //uart0_put_value("currentTime: ",currentTime);
    //              //uart0_put_value("time1: ",time1);
    
    //          }
    //
    //      //uart0_put_value("time1: ",time1);
    //      //uart0_put_value("time2: ",time2);
    //          //uart0_put_value("ret:",ret);
    //      if(ret == 0)
    //      {
    //          memcpy(&gStoredExtRtcData.gRtcValue,&gRtc,sizeof(RTC_VALUE_STRUCT));
    
    //      updateServiceDays();
    //      }
    //
    //  }
    //  if(ret ==1)
    //  {
    //      gStoredExtRtcData.flags.RTC_tamperedBit = 1;//uart0_put_value("t set : ",0);
    
    //  }else
    //  {
    //          gStoredExtRtcData.flags.RTC_tamperedBit =0;
    //      //uart0_put_value("t clr : ",0);
    //  }
    //
    //  return ret;
    //
    //}
    
    unsigned long getDateTimeInMin(RTC_VALUE_STRUCT date)
    {
        unsigned long ret;
    
        ret=((unsigned long)( date.year*365)*(24 *60));
        ret+=((unsigned long) gMntToDays[ date.month]*(24 *60));
        ret+=( date.day*24*60);
        ret+=(( date.hr*60)+ date.min);
    
        return ret;
    }
    
    
    void Write_DATAFLASH_ARRAY(unsigned char* wData,unsigned char length)
    {
        unsigned char i;
    
        for(i=0;i<length;i++)
        {
            SYSCFG0 = FRWPPW | DFWP;
            gMemoryExtRtcAry[i]=wData[i];
            SYSCFG0 = FRWPPW | PFWP | DFWP;
        }
    
    
    
    }
    
    void Read_DATAFLASH_ARRAY(unsigned char* rData,unsigned char length)
    {
        unsigned char i;
        for(i=0;i<length;i++)
        {
            rData[i] = gMemoryExtRtcAry[i];
    
        }
    
    
    }
    
    
     void enterLPM_3_5(void)
    {
       // uart1_put_value("Ent LPM3 : ",(*(unsigned long*)timeStamp));
    
    
         getAdc();
    
        if(ADC_Result<POWER_OFF_THLD)
         {
             do
             {
                 __delay_cycles(10);
                 getAdc();
                 if(gAdcReady == 0)
                 {
                    gAdcFltr =0;
                    break;
                  }
                 else
                 {
                     if(ADC_Result<POWER_OFF_THLD) gAdcFltr++;
                     else
                     {
                         gAdcFltr =0;
                         break;
                     }
                 }
    
             }while(gAdcFltr<10);
    
         }
    
    
        if(gAdcFltr>=10)
       // if(ADC_Result<POWER_OFF_THLD)
        {
            //P1SEL1 =0;
            UCA0IE &= ~UCRXIE;
            gAdcFltr=0;
            *(unsigned int *)(BKMEM_BASE+2) =  (*(unsigned int*)&timeStamp[0]);
            *(unsigned int *)(BKMEM_BASE+4) =  (*(unsigned int*)&timeStamp[2]);
    
            SYSCFG2 &= ~(ADCPCTL3);
            P1SEL0 = 0;
            P1SEL1 = 0;
    
            P1DIR  =  (BIT0 |BIT1 |BIT2 | BIT3| BIT4| BIT5| BIT6| BIT7);
            P2DIR = (BIT2 | BIT3| BIT4| BIT5| BIT6| BIT7);
            //P2DIR = (BIT3| BIT4| BIT5| BIT6| BIT7);
            P1OUT = 0;
            P2OUT = 0;
    
            P2IES  = 0x00;                    //  Low to High edge
            P2IFG = 0;
            P2IE   = 0;
            //________________________
    
            ADCCTL0 &= ~(ADCSHT_2 | ADCON);                             // ADCON, S&H=16 ADC clks
            ADCCTL1 &= ~ADCSHP;                                         // ADCCLK = MODOSC; sampling timer
            // ADCCTL2 |= ADCRES;                                       // 10-bit conversion results
            ADCIE &= ~ADCIE0;                                           // Enable ADC conv complete interrupt
            ADCMCTL0 &= ~(ADCINCH_3 | ADCSREF_1);                       // A1 ADC input select; Vref=1.5V
         //   PMMCTL0_H = PMMPW_H;                                        // Unlock the PMM registers
         //   PMMCTL2 &= ~INTREFEN;                                       // disable internal reference
    
            gPwrOffCount = (gPwrOffCount+1);
            gPwrOffCount_Dbg = gPwrOffCount_Dbg+1;
           {
               unsigned int temp;
    //           gRtcVlidnReloadInex=gRtcVlidnReloadInex+1;
    //            if(gRtcVlidnReloadInex > 10 ) gRtcVlidnReloadInex = 0;
    
                RTCMOD = RTC_VALIDATION_RELOAD0;//gRtcVlidnReloadVal[gRtcVlidnReloadInex];
               temp  = RTCCNT;
               RTCCTL = 0x2742; // reset counter
               gRtcTMRCntVal += temp;
               gRtcSecCounter += (gRtcTMRCntVal/32);
               gRtcTMRCntVal = gRtcTMRCntVal%32;
           }
    
            //_______________________
    
           PMMCTL0_H = PMMPW_H;                    // Open PMM Registers for write
           PMMCTL0_L |= PMMREGOFF;                 // and set PMMREGOFF
           PMMCTL2 &= ~INTREFEN;                   // disable internal reference
           PMMCTL0_H = 0;                          // Lock PMM Registers
           __no_operation();
           __no_operation();
           __no_operation();
           __bis_SR_register(LPM3_bits | GIE); // Go to LPM3 with interrupt
           __no_operation();
        }
    
    
    
    }
    
    
     // ADC interrupt service routine
    
     void __attribute__ ((interrupt(ADC_VECTOR))) ADC_ISR (void)
    
     {
         switch(__even_in_range(ADCIV,ADCIV_ADCIFG))
         {
             case ADCIV_NONE:
                 break;
             case ADCIV_ADCOVIFG:
                 break;
             case ADCIV_ADCTOVIFG:
                 break;
             case ADCIV_ADCHIIFG:
                 break;
             case ADCIV_ADCLOIFG:
                 break;
             case ADCIV_ADCINIFG:
                 break;
             case ADCIV_ADCIFG:
                 ADC_Result = ADCMEM0;
                 gAdcReady = 1;
                 break;
             default:
                 break;
         }
     }
    
     /*unsigned int getAdc(void)
     {
         gAdcReady=0;
         gTmOutCntr =0;
         ADCCTL0 |= ADCENC | ADCSC;                            // Sampling and conversion start
         while((gAdcReady==0) &&(gTmOutCntr < 200))
         {
             gTmOutCntr++;
             __delay_cycles(15);
    
         }
    
    
         return gAdcReady;
    
     }
     void adcInit(void)
     {
          SYSCFG2 |= ADCPCTL3;
          // Configure ADC10
          ADCCTL0 |= ADCSHT_2 | ADCON;                              // ADCON, S&H=16 ADC clks
          ADCCTL1 |= ADCSHP;                                        // ADCCLK = MODOSC; sampling timer
          ADCCTL2 |= ADCRES;                                        // 10-bit conversion results
          ADCIE |= ADCIE0;                                          // Enable ADC conv complete interrupt
          ADCMCTL0 |= ADCINCH_3 | ADCSREF_1;                        // A1 ADC input select; Vref=1.5V
    
          // Configure reference
          PMMCTL0_H = PMMPW_H;                                      // Unlock the PMM registers
          PMMCTL2 |= INTREFEN;                                      // Enable internal reference
          __delay_cycles(400);
    
     }
    
    
     */
     unsigned int getAdc(void)
     {
    
         ADCCTL0 |= ADCENC | ADCSC;                            // Sampling and conversion start
         gAdcReady=0;
         gTmOutCntr =0;
         while( (0!=(ADCCTL1 & 0x0001))&& (gTmOutCntr < 200))
         {
             gTmOutCntr++;
              __delay_cycles(15);
    
         }
         if((ADCCTL1 & 0x0001)==0)
         {
            gAdcReady =1;
            ADC_Result = ADCMEM0;
         }
         return gAdcReady;
    
     }
     void adcInit(void)
     {
          SYSCFG2 |= ADCPCTL3;
          // Configure ADC10
          ADCCTL0 |= ADCSHT_2 | ADCON;                              // ADCON, S&H=16 ADC clks
          ADCCTL1 |= ADCSHP;                                        // ADCCLK = MODOSC; sampling timer
          ADCCTL2 |= ADCRES;                                        // 10-bit conversion results
         // ADCIE |= ADCIE0;                                          // Enable ADC conv complete interrupt
          ADCMCTL0 |= ADCINCH_3 | ADCSREF_1;                        // A1 ADC input select; Vref=1.5V
    
          // Configure reference
          PMMCTL0_H = PMMPW_H;                                      // Unlock the PMM registers
          PMMCTL2 |= INTREFEN;                                      // Enable internal reference
          __delay_cycles(400);
    
     }
    
     /*
    void uartInit(void)
     {
         P1SEL0 = BIT4 | BIT5;       // UCA0 RXD and TXD
         UCA0CTLW0 = UCSWRST | UCSSEL__ACLK;
         UCA0BRW = 3;
         UCA0MCTLW = 0x9200;
         UCA0CTLW0 &= ~UCSWRST;                   // Initialize eUSCI
         UCA0IE = UCRXIE;                         // Enable USCI_A0 RX interrupt
     }
    
    */
     void uartInit(void)
      {
          P1SEL0 = BIT4 | BIT5;       // UCA0 RXD and TXD
          UCA0CTLW0 = UCSWRST ;
          UCA0CTLW0 |=  UCSSEL__SMCLK;
          UCA0BRW = 6;
    
        //  UCA0MCTLW = 0x2080|UCOS16;
          UCA0MCTLW = 0x22D0|UCOS16;
    
          UCA0CTLW0 &= ~UCSWRST;                   // Initialize eUSCI
          UCA0IE = UCRXIE;                         // Enable USCI_A0 RX interrupt
      }
    
    
     

  • hi,

    we  found that the code hangs because of TEST pin and RST pin is picking up noise(generated from power source and motors) and probably going in to JTAG mode .

    Is there any way i can disable JATAG functionality once code is flashed device. 

  • Hi Prashanth,

    You can try disabling JTAG by setting the JTAG E-Fuse in the MSP430FR2433. See section 2.2.3 of this document (SLAA685) and section 1.11.1 of the MSP430FRrxx and MSP430FR2xx family user's guide for more details. The User's Guide does specify that the JTAG and SBW interface remain functional, just that certain command access is restricted, so you may still see hanging, but it is worth a try. 

    Keep in mind that this process is only reversible by using BSL mode on the device. I would try it on just one of your boards first, if you dont currently have a straightforward setup to perform a BSL Mass Erase. 

    Best Regards,
    Brandon Fisher

**Attention** This is a public forum