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.

MSP430FR2633: Controller gets restart

Part Number: MSP430FR2633

Hello,

While am trying to program MSP430FR2633, the  VMAIE -  Vacant Memory Interrupt Flag, and OFIE - Oscillator fault interrupt flag are enabled and the controller gets restart after sometime due to Watchdog timer.

Also it seems that program gets altered and it keep jumping at same memory location, not getting how to solve this error.

Kindly suggest any solution.

The screenshot for the same is shared below.

  • Hi,

    As I can see from the code, you have disable the watchdog timer. Why it work, I adise you can see SYSRSTIV to check the reset source.

    By the way, I check the assembly code, I can't find jump instruction.

    Can you put your code with a smallest case, I can check it for you.

    Eason

  • Hi Eason,

    Thank you for response,

    Herewith am sending you the code.

    And about JMP instruction, it not there in CS_initClockSignal, but it gets edited automatically when controller gets restart.

    Also VMAIE -  Vacant Memory Interrupt Flag is enabled.

    4251.main.c
    #include <msp430.h>                      // Generic MSP430 Device Include
    #include "driverlib.h"                   // MSPWare Driver Library
    #include "captivate.h"                   // CapTIvate Touch Software Library
    #include "CAPT_App.h"                    // CapTIvate Application Code
    #include "CAPT_BSP.h"                    // CapTIvate EVM Board Support Package
    
    #include "LCD_20x4.h"
    #include "CAPTIVATE_PHONE_Demo.h"        // CAPTIVATE-PHONE PCB Demo
    //#include "tm_stm32f4_mfrc522.h"
    //#include "cs.h"
    
    #define CS_FLLREF                 0x08
    #define SELMS__REFOCLK            (0x0001)
    #define CS_REFOCLK_SELECT         SELMS__REFOCLK
    const uint8_t ui8LFOsc=CS_REFOCLK_SELECT;
    CS_initFLLParam fllParams = {0};
    uint16_t faultflags=0;
    
    char LCD_Buff[21];
    uint8_t key=0xFF;
    uint16_t c=0,r=0;
    
    extern void Pin_Initialization(void);
    extern void TM_HD44780_InitPins(void);
    extern uint32_t CS_getMCLK(void);
    //extern unsigned long int Tick;
    //extern void SPI_INIT(void);
    //extern void TIMER_INIT(void);
    //extern TM_MFRC522_Status_t TM_MFRC522_Check(uint8_t* id);
    
    //uint8_t RFID[5];                //, store[5]
    //uint8_t sts,step_rf=0,status, store[5];
    //uint8_t EID[5],KeyDet,pge=0;
    //uint8_t RXData = 0;         /* Code Entered for SPI */
    //uint8_t TXData = 0;         /* Code Entered for SPI */
    
    
    void main(void)
    {
    	// Initialize the MCU
    	WDTCTL = WDTPW | WDTHOLD;       // Stop watch dog timer
    
    	Pin_Initialization();
    
        // Initialize Clock Signals
        CS_initClockSignal(CS_FLLREF, ui8LFOsc, CS_CLOCK_DIVIDER_1);
        //CS_initClockSignal(CS_ACLK, ui8LFOsc, CS_CLOCK_DIVIDER_1);
        CS_initClockSignal(CS_MCLK, CS_DCOCLKDIV_SELECT, CS_CLOCK_DIVIDER_1);  // CS_REFOCLK_SELECT, CS_DCOCLKDIV_SELECT
        CS_initClockSignal(CS_SMCLK, CS_DCOCLKDIV_SELECT, CS_CLOCK_DIVIDER_4); //CS_CLOCK_DIVIDER_4
    
        // Tune the DCO parameters
        faultflags = CS_initFLLCalculateTrim((MCLK_FREQ/1000), FLL_RATIO, &fllParams);
        faultflags = CS_clearAllOscFlagsWithTimeout(1000);
    
        //SPI_INIT();
        //BSP_configureMCU();       // BSP_configureMCU() sets up the device IO and clocking
        __bis_SR_register(GIE);     // The global interrupt enable is set to allow peripherals to wake the MCU.
        Demo_init();                // Buzzer will be on for each key pressed
    
       //TIMER_INIT();
       //TM_MFRC522_Init();
    
        // Start the CapTIvate application
        CAPT_appStart();
    
        LCD_Init(16,2);
        LCD_Puts(0,0,"Relcon Systems");    // Display characters on LCD
    
    	// Background Loop
    	while(1)
    	{
    	    CAPT_appHandler();
    	    //Demo_checkForValidTouch();
    	    //CAPT_appSleep();
    	    if(key != 0xFF)
    	    {
    	        memset(LCD_Buff,0x20,21);
    	        LCD_Buff[16]=0;
    	        //LCD_Clear();
    	        //LCD_Buff[0]=key;
    	        //LCD_Puts(0, 0, &LCD_Buff[0]);
    	        //key=0xFF;
    
    	        LCD_Buff[c]=key;
    	        LCD_Puts(c, r, &LCD_Buff[c]);
    	        c++;
    	        if (c>0x0F)
    	        {
    	            c=0x00;
    	            r++;
    	        }
    	        if (r>1)
    	        {
    	            r=0x00;
    	        }
    	        key=0xFF;
    	    }
    
    	     //TM_MFRC522_ReadRegister(0x37);
      	     //TM_MFRC522_Check(RFID);
    //	     if(TM_MFRC522_Check(&EID[0]) == MI_OK)         //checks whether the card is there...
    //	     {
    //	         memcpy(&store[0],&EID[0],4);
    //	         sts = TM_MFRC522_SelectTag(&EID[0]);
    //	     }
    
    	} // End background loop
    } // End main()
    
    /*---------- Code Entered for SPI starts ---------- */
    
    /*---------- Code Entered for SPI ends ------------*/
    
    functions.c
    /*
     * functions.c
     *
     *  Created on: 30-Sep-2019
     *      Author: admin
     */
    
    #include <msp430.h>
    #include "driverlib.h"
    
    //extern void EUSCI_A_SPI_enable (   uint16_t    baseAddress );
    void Pin_Initialization(void);
    
    
    void Pin_Initialization(void)
    {
            // P1.0: LCD_DATA_3                 (O/P)  (G)
            // P1.1: LCD_DATA_2                 (O/P)  (G)
            // P1.2: LCD_DATA_1                 (O/P)  (G)
            // P1.3: LCD_DATA_0                 (O/P)  (G)
            // P1.4: UCA0_TX                    (O/P)  (P)
            // P1.5: UCA0_RX                    (I/P)  (P)
            // P1.6: UCA0_EN                    (O/P)  (G)
            // P1.7: LCD_EN                     (O/P)  (G)
            P1DIR  = (GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3 | GPIO_PIN4 | GPIO_PIN6 |GPIO_PIN7);
            P1SEL0 = (GPIO_PIN4 | GPIO_PIN5);
            P1SEL1 = (0);
            P1OUT  = (0);
    
            // P2.0: Not connected                (O/P)  (G)
            // P2.1: Buzzer                       (O/P)  (G)
            // P2.2: LCD_RS                       (O/P)  (G)
            // P2.3: CAP_0.2_TX3                  (O/P)  (P)
            // P2.4: CLK                          (O/P)  (P)
            // P2.5: D0_HID_INPUT // SPI MOSI  // (O/P)  (P)
            // P2.6: D1_HID_INPUT // SPI MISO  // (I/P)  (P)
            // P2.7: CAP_3.0_RX4                  (O/P)  (P)
            P2OUT  =  (0);
            P2DIR  =  (GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3 | GPIO_PIN4 | GPIO_PIN5 | GPIO_PIN7);
            P2SEL0 =  (GPIO_PIN3 | GPIO_PIN4 | GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7);
            P2SEL1 =  (0);
    
            // P3.0: SDA_CS                     (O/P)
            // P3.1: CAP_1.0_TX1                (O/P)
            // P3.2: CAP_3.2_RX2                (O/P)
            P3OUT  =  (0);
            P3DIR  =  (GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2);
            P3SEL0 =  (GPIO_PIN2);
            P3SEL1 =  (GPIO_PIN1);
    
            PM5CTL0 &= ~LOCKLPM5;  // Disable the GPIO power-on default high-impedance mode
                                   // to activate previously configured port settings
    
    }
    
    void SPI_INIT(void)
    {
        UCA1CTLW0 = UCSWRST;
        UCA1CTLW0 |= UCCKPL |UCMSB | UCSYNC | UCMST | UCSSEL__SMCLK;
                  // UCCKPL | UCMSB | UCSYNC | UCMST | UCSSEL__SMCLK;
        //UCA1BRW = 0x20;
        //UCA1BRW = 0x0050;
        UCA1CTLW0 &= ~UCSWRST;
    //    UCA0IE |= UCRXIE;
    }
    
    
    
    //void SPI_INIT(void)
    //{
    
        /*---------- Code Entered for SPI starts ---------- */
       //CS_turnOnSMCLK(void);      // Initialize clock
    
    
        //Initialize Master
    
    //        EUSCI_A_SPI_initMasterParam param = {0};
    //        param.selectClockSource = EUSCI_A_SPI_CLOCKSOURCE_SMCLK;
    //        param.clockSourceFrequency = CS_getSMCLK();  //  CS_getSMCLK(); CS_turnOnSMCLK()
    //        param.desiredSpiClock = 500000;
    //        param.msbFirst = EUSCI_A_SPI_MSB_FIRST;
    //        param.clockPhase = EUSCI_A_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT; // EUSCI_A_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT;
    //        param.clockPolarity =  EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_LOW; //EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_HIGH; EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_LOW;
    //        param.spiMode = EUSCI_A_SPI_3PIN;
    //        EUSCI_A_SPI_initMaster(EUSCI_A1_BASE, &param);
        /*---------- Code Entered for SPI ends ---------- */
    
        //Enable SPI module
        //EUSCI_A_SPI_enable(EUSCI_A1_BASE);}
    //}
    
    Demo.c
    //*****************************************************************************
    // Includes
    //*****************************************************************************
    
    #include <msp430.h>
    #include "captivate.h"
    #include "CAPT_BSP.h"
    #include "I2CMaster.h"
    //#include "DRV26x.h"
    #include "CAPTIVATE_PHONE_Demo.h"
    #include "CAPT_Type.h"
    #include "CAPT_UserConfig.h"
    #include "key.h"
    
    
    extern tElement BTN00_E00;
    extern tElement BTN00_E01;
    extern tElement BTN00_E02;
    extern tElement BTN00_E03;
    extern tElement BTN00_E04;
    extern tElement BTN00_E05;
    extern tElement BTN00_E06;
    extern tElement BTN00_E07;
    extern tElement BTN00_E08;
    extern tElement BTN00_E09;
    extern tElement BTN00_E10;
    extern tElement BTN00_E11;
    extern tElement BTN00_E12;
    extern tElement BTN00_E13;
    extern tElement BTN00_E14;
    extern tElement BTN00_E15;
    extern tElement BTN00_E16;
    extern tElement BTN00_E17;
    extern tElement BTN00_E18;
    extern tElement BTN00_E19;
    extern tElement BTN00_E20;
    extern tElement BTN00_E21;
    extern tElement BTN00_E22;
    extern tElement BTN00_E23;
    extern tElement BTN00_E24;
    extern tElement BTN00_E25;
    extern tElement BTN00_E26;
    extern tElement BTN00_E27;
    extern tElement BTN00_E28;
    extern tElement BTN00_E29;
    extern tElement BTN00_E30;
    extern tElement BTN00_E31;
    //extern tElement BTN00_E32;
    //extern tElement BTN00_E33;
    //extern tElement BTN00_E34;
    //*****************************************************************************
    // Global Variables
    //*****************************************************************************
    extern uint8_t key;
    
    //! \brief Flag 
    //!
    volatile bool Demo_guardMaskActive = false;
    
    //*****************************************************************************
    // Function Prototypes
    //*****************************************************************************
    
    //! \brief The event handler for the numeric keypad sensor.
    //! \param pSensor is a pointer to the calling sensor.
    void Demo_KeypadHandler(tSensor* pSensor);
    
    
    //! \brief The event handler for the wheel button sensor.
    //! \param pSensor is a pointer to the calling sensor.
    //void Demo_wheelButtonHandler(tSensor* pSensor);
    
    //*****************************************************************************
    // Function Implementations
    //*****************************************************************************
    
    void Demo_init(void)
    {
        //
        // Associate the capacitive touch callback handlers with sensors.
        //
        MAP_CAPT_registerCallback(
                &BTN00,
                &Demo_KeypadHandler
            );
    }
    
    
    void Demo_KeypadHandler(tSensor* pSensor)
    {
        tElement* dominantElement;
    
        if ((pSensor->bSensorTouch == true)
                && (pSensor->bSensorPrevTouch == false))
        {
    
    //Button is pressed
            P2OUT  |= 0x02;
    //      P3OUT  |= 0x01;
    
          __delay_cycles(800000);
    
                         if ((pSensor->bSensorTouch==true) && (pSensor->bSensorPrevTouch==false))
                         {
                             dominantElement = CAPT_getDominantButtonAddr(pSensor);
                             if (dominantElement == &BTN00_E00)
                             {
                                     __delay_cycles(800000);
                                     P2OUT  &= ~0x02;
                                     key = P;
                             }
                             else if (dominantElement == &BTN00_E01)
                             {
                                     __delay_cycles(800000);
                                     P2OUT  &= ~0x02;
                                     key = L;
                             }
                             else if (dominantElement == &BTN00_E02)
                             {
                                     __delay_cycles(800000);
                                     P2OUT  &= ~0x02;
                                     key = O;
                             }
                             else if (dominantElement == &BTN00_E03)
                             {
                                     __delay_cycles(800000);
                                     P2OUT  &= ~0x02;
                                     key = K;
                             }
                             else if (dominantElement == &BTN00_E04)
                             {
                                      __delay_cycles(800000);
                                      P2OUT  &= ~0x02;
                                      key = N0;
                             }
                             else if (dominantElement == &BTN00_E05)
                             {
                                     __delay_cycles(800000);
                                     P2OUT  &= ~0x02;
                                     key = J;
                             }
                             else if (dominantElement == &BTN00_E06)
                             {
                                     __delay_cycles(800000);
                                     P2OUT  &= ~0x02;
                                     key = M;
                             }
                             else if (dominantElement == &BTN00_E07)
                             {
                                      __delay_cycles(800000);
                                      P2OUT  &= ~0x02;
                                      key = I;
                             }
                             else if (dominantElement == &BTN00_E08)
                             {
                                      __delay_cycles(800000);
                                      P2OUT  &= ~0x02;
                                      key = X;
                             }
                             else if (dominantElement == &BTN00_E09)
                             {
                                      __delay_cycles(800000);
                                      P2OUT  &= ~0x02;
                                      key = T;
                             }
                             else if (dominantElement == &BTN00_E10)
                             {
                                     __delay_cycles(800000);
                                     P3OUT  &= ~0x01;
                                     key = W;
                             }
                             else if (dominantElement == &BTN00_E11)
                             {
                                      __delay_cycles(800000);
                                      P2OUT  &= ~0x02;
                                      key = S;
                             }
                             else if (dominantElement == &BTN00_E12)
                             {
                                      __delay_cycles(800000);
                                      P2OUT  &= ~0x02;
                                      key = V0;
                             }
                             else if (dominantElement == &BTN00_E13)
                             {
                                      __delay_cycles(800000);
                                      P2OUT  &= ~0x02;
                                      key = R;
                             }
                             else if (dominantElement == &BTN00_E14)
                             {
                                      __delay_cycles(800000);
                                      P2OUT  &= ~0x02;
                                      key = U;
                             }
                             else if (dominantElement == &BTN00_E15)
                             {
                                      __delay_cycles(800000);
                                      P2OUT  &= ~0x02;
                                      key = Q;
                             }
                             else if (dominantElement == &BTN00_E16)
                             {
                                      __delay_cycles(800000);
                                      P2OUT  &= ~0x02;
                                      key = ENTER;
                             }
                             else if (dominantElement == &BTN00_E17)
                             {
                                      __delay_cycles(800000);
                                      P2OUT  &= ~0x02;
                                      key = ESC;
                             }
                             else if (dominantElement == &BTN00_E18)
                             {
                                      __delay_cycles(800000);
                                      P2OUT  &= ~0x02;
                                      key = A0;
                             }
                             else if (dominantElement == &BTN00_E19)
                             {
                                      __delay_cycles(800000);
                                      P2OUT  &= ~0x02;
                                      key = BACKSPACE;
                             }
                             else if (dominantElement == &BTN00_E20)
                             {
                                      __delay_cycles(800000);
                                      P2OUT  &= ~0x02;
                                      key = DECPOINT;
                             }
                             else if (dominantElement == &BTN00_E21)
                             {
                                      __delay_cycles(800000);
                                      P2OUT  &= ~0x02;
                                      key = Z0;
                             }
                             else if (dominantElement == &BTN00_E22)
                             {
                                      __delay_cycles(800000);
                                      P2OUT  &= ~0x02;
                                      key = SHIFT;
                             }
                             else if (dominantElement == &BTN00_E23)
                             {
                                      __delay_cycles(800000);
                                      P2OUT  &= ~0x02;
                                      key = Y;
                             }
                             else if (dominantElement == &BTN00_E24)
                             {
                                       __delay_cycles(800000);
                                       P2OUT  &= ~0x02;
                                       key = H;
                             }
                             else if (dominantElement == &BTN00_E25)
                             {
                                       __delay_cycles(800000);
                                       P2OUT  &= ~0x02;
                                       key = D;
                             }
                             else if (dominantElement == &BTN00_E26)
                             {
                                       __delay_cycles(800000);
                                       P2OUT  &= ~0x02;
                                       key = G;
                             }
                             else if (dominantElement == &BTN00_E27)
                             {
                                       __delay_cycles(800000);
                                       P2OUT  &= ~0x02;
                                       key = C0;
                             }
                             else if (dominantElement == &BTN00_E28)
                             {
                                       __delay_cycles(800000);
                                       P2OUT  &= ~0x02;
                                       key = F;
                             }
                             else if (dominantElement == &BTN00_E29)
                             {
                                       __delay_cycles(800000);
                                       P2OUT  &= ~0x02;
                                       key = B;
                             }
                             else if (dominantElement == &BTN00_E30)
                             {
                                       __delay_cycles(800000);
                                       P2OUT  &= ~0x02;
                                       key = E;
                             }
                             else if (dominantElement == &BTN00_E31)
                             {
                                       __delay_cycles(800000);
                                       P2OUT  &= ~0x02;
                                       key = A;
                             }
    
                         }
    
                         P2OUT  &= ~0x02;
                      // P3OUT  &= ~0x01;
        }
    }
    

    Regards,

    Himani 

  • As I  check, I can't run your code, so you need to debug it by yourself.

    Can you use step over function, and don't enable VMAIE and OFIE to find after run which code,OFIFG or VMAIFG is set.

    Eason

  • Ok, I'll try and let you know.

    Thank you.

    Regards,

    Himani

  • Wait for your good news

**Attention** This is a public forum