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.

CCS/MSP430F5529: Code under while(1) is not running

Part Number: MSP430F5529

Tool/software: Code Composer Studio

Hello Team,

This is the first time i am working on TI platform and CCS IDE. I am using MSP430F5529 MCU. Actually code written down under while(1) is not running if I am using  "__bis_SR_register(LPM0_bits + GIE);"

I checked this issue with three different type of interrupts  1.) With USCIB0 for I2C interrupt individually      2.) With UART interrupt individually        3.) with 4ms timer interrupt individually.   

By removing "__bis_SR_register(LPM0_bits + GIE);" my while(1) code is running. But this is not the actual use case. I need both execution while(1) and interrupt code.

Thanks

Deepak

  • Hi Deepak,

    Do you receive any error messages or symbols when attempting to run the code?

    Do you know how to  step through your code with Code Composer Studio? Please see section 7.4 of this Debug Overview on how to Debug your project in CCS.

    -Chris

  • I am not familiar with this MCU, but usually this happens when you have the interrupt set to put the MCU to sleep when it returns. When that happens it just waits for another interrupt and does not execute any other code.

    In driverlib you call:

    Interrupt_disableSleepOnIsrExit ( void )

  • Hi Chris,

    I am not getting any error message while debugging code.

    I am explaining my scenario below.

    Actually I put a small code of LED on/off by switch inside while(1) loop and on other side configure interrupts. 

    After running the code I couldn't control LED on/off through switch that was written inside while(1) loop.  

    On 2nd iteration I commented out    //__bis_SR_register(LPM0_bits + GIE); and checked again this time my code under while(1) loop started running and I could perform LED on/off by switch.

    Regards

    Deepak

  • Deepak,

    Apologies for the delayed response here.

    It sounds like you are entering LPM0 before executing the rest of your code. Do you mind posting a snippet of your code and your ISR to turn on the LED?

    -Chris

  • Hi Chris,

    I am attaching a file of my basic code of timer and GPIO inside while(1) loop. This I did when I started working on this MSP430F module.

    But in our product I am using I2C to read accelerometer + driving stepper motor + UART.. For I2C I have taken reference from ".....usci i2c standard master" which uses LPM0 at multiple locations.

    Regards

    Deepak

    #include <msp430.h>
    #include <msp430f5529.h>
    
    
    /**
     * main.c
     */
    unsigned int i = 0;
    int main(void)
    {
    	WDTCTL = WDTPW | WDTHOLD;	// stop watchdog timer
    	
    	P1DIR = 0x01;
    
    	P1OUT = 0x01;
    
    	 P2DIR &= ~0x02;                // P1.3 (SW2) -> Input
    
    	    P2REN |= 0x02;              // P1.3 Pull Up/Down Enable
    
    	    P2OUT |= 0x02;              // P1.3 Pull Up Enable
    
    	    TA0CCR0 = 20000;      //setting timeout value
    	    TA0CCTL0 |= CCIE ;        // Enabled overflow interrupt
    
    	    TA0CTL |= MC_1 + TASSEL_2 + TACLR;   // Set Mode -> Up Count, Clock -> ACLK, Clear Timer
    
    	    __bis_SR_register(LPM0_bits + GIE); // Goto LPM3 (Only ACLK active), Enable CPU Interrupt
            // __enable_interrupt();
    
    	while(1)
    	{
    	    if(P2IN & 0x02)
    	    {
    	        P1OUT |= 0x01;
    	    }
    	    else
    	    {
    	            P1OUT &=~ 0x01;
    	    }
    	  //  if(P2)
    	    /*P1OUT ^= 0x01;
    	    for(i=0; i< 10000; i++)
    	    {
    
    	    }*/
    	    return 0;
    	}
    
    }
    
    #pragma vector = TIMER0_A0_VECTOR       // CCR0 Interrupt Vector
    __interrupt void Timer0_A0_ISR(void)
    
    {
          P1OUT ^= 0x01;                       // Toggle LED
    
    }
    
     

  • Hey Deepak,

    As Keith mentioned, the issue is that you are putting the MSP430 to sleep and never waking up.  Basically, when you return to main, the MSP430 is instantly going back to LPM mode and forever saying in that loop.  

    To wake the MSP430 after returning from the ISR, you must add this to the your interrupt.  It tells the MSP430 to wake upon ISR exit.  

    _bic_SR_register_on_exit(LPM3_bits);

    Thanks,

    JD