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.

Program freezing after GIE is run...

Other Parts Discussed in Thread: MSP430F2619

Here is code..

/*-----------------------------------------------------------------------------------------------

#include <msp430f2619.h>
#include <cstring>
#include "init_TIME.h"
#include "blink_LED.h"
#include "SCIA.h"

void SCI_Init(void){
RxFifo_Init();
TxFifo_Init();

//WDTCTL = WDTPW + WDTHOLD;
if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)
{
while(1); // If calibration constants erased
// do not load, trap CPU!!
}
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
P3SEL = 0x30; // P3.4,5 = USCI_A0 TXD/RXD
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 6; // 1MHz 9600
UCA0BR1 = 0; // 1MHz 9600
UCA0MCTL = UCBRF3 + UCOS16; // Modln UCBRSx=1, over sampling
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
//_EINT();
}

void init_TIMER(void){
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
TACCTL0 = CCIE; // CCR0 interrupt enabled
TACTL = TASSEL_2 + MC_2 + ID_3; // SMCLK/8, cont mode, divider 8
TACCR0 = 30000; // 1 Hz
_bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
}
void init_LED(void){
P1DIR |= BIT0; // P1.0 output
}
void main(void)
{
SCI_Init(); // Init Xbee
init_LED(); // Init LED
init_TIMER(); // Init timer

SCI_OutString("asdf");
}

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

I have no idea why its stopping when stepping through while debugging... 

if you would like to see full code here is a link... any help would be greatly appreciated

0268.proj.zip

  • Sorry because I'm seeing this on a mobile phone but... I think this code does what is expected to.

    LPM+GIE puts the MSP430 in sleep mode while still being able to be activated by an interruption.

    You use LPM0 which in theory allows for timer interruptions but, anyway, I do not see any timer interrupt service routine, even if you initialize it.

  • Problem is not with GIE try removing LPM0_bits. Or try to exit LPM0 from the timer interrupt.

  • Samuel Maciel said:
    if you would like to see full code here is a link... any help would be greatly appreciated

    0268.proj.zip

    The code didn't initially compile in CCS 5.2, due to errors in the asm directives in the RxFifo_Init and TxFifo_Init functions. To get the project to compile commented out the asm directives.

    Samuel Maciel said:
    I have no idea why its stopping when stepping through while debugging... 

    The init_TIMER functions ends with:

      _bis_SR_register(LPM0_bits + GIE);        // Enter LPM0 w/ interrupt

    The puts the CPU into Low Power Mode 0, which means the main program will not continue to run until an Interrupt Service Routine exits LPM0. None of the ISRs exits LPM0, so the main program never continues.

  • Also, USCI0TX_ISR disables the RX interrupt when the TxFifo is empty:

    #pragma vector=USCIAB0TX_VECTOR
    __interrupt void USCI0TX_ISR(void){
       char data;
       if((IFG2 & UCA0TXIFG)){
          if(TxFifo_Get(&data)){
             UCA0TXBUF = data;    // Sends Data
          }
        else{
         IE2 &= ~UCA0RXIE;      // disarm TDRE
        }
       }

    That means when the TxFifo becomes empty the Tx interrupt is still enabled, and the processor then spends all its time servicing the USCI0TX_ISR since there is nothing to clear the pending Tx interrupt.

    The line should be:

        IE2 &= ~UCA0TXIE;      // disarm TDRE

  • Samuel Maciel said:
    WDTCTL = WDTPW + WDTHOLD; // Stop WDT

    the WDT should be stopped right at the beginning of your code in the main as shown below:

    void main(void)
    {

    WDTCTL = WDTPW + WDTHOLD; // Stop WDT
    SCI_Init(); // Init Xbee
    init_LED(); // Init LED
    init_TIMER(); // Init timer

    SCI_OutString("asdf");
    }

  • Mo. said:
    the WDT should be stopped right at the beginning of your code in the main as shown below:

    In the attached code, the watchdog was being disabled at the start of the init_TIMER function. Running the code didn't show any evidence that a watchdog reset was occuring.

  • You guys are the BEST i cant believe it was something so stupid(on my part) .. Chester im currently working on the ISR so yes it should have been 

     IE2 &= ~UCA0TXIE;

    I guess i have to be a little more creative with my low power modes.. 

  • Samuel Maciel said:
    I have no idea why its stopping when stepping through while debugging... 

    Your program also highlighted a defect in the MSP-FET430UIF with MSP430.dll v3.2.4.5. I have added a cut-down example of the problem in the Debugger jumps to wrong interrupt vector thread.

**Attention** This is a public forum