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/MSP432P401R: TimerTA0_0 interrupt goes to infinite loop (exit.c)!

Part Number: MSP432P401R

Tool/software: Code Composer Studio

Hello TI community

I plan to use timerA interrupt to toggle two LEDs at 44.1 kHz. But when I run my program, it goes to exit.c. Below is my code:

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

WDT_A->CTL = WDT_A_CTL_PW | WDT_A_CTL_HOLD; // stop watchdog timer


P2DIR |=BIT2+BIT1;  //LEDs
P2OUT |= (BIT1+BIT2);//LEDs

/***************************Configure Timer****************************************************************/

TIMER_A0->CCTL[0] = TIMER_A_CCTLN_CCIE; //Enable CC interrupt

TIMER_A0->CTL = TIMER_A_CTL_TASSEL_2 | //Select SMCLK as source for timer
TIMER_A_CTL_ID_3 | //Divide clock by 8 (this yields 6 MHz for the timer clock)
TIMER_A_CTL_MC_1 | //Up mode
TIMER_A_CTL_CLR ; //Clear timer count

TIMER_A0->CCR[0] = 136; // 6 MHz / 44.1 kHz = 136
// __enable_irq();
__enable_interrupt();


}
void TA0_0_IRQHandler(void)
{
P2->OUT ^= (BIT2+BIT1);

}

Any idea where the problem is?

Thanks

Saber

  • >__enable_interrupt();

    >}

    Unless you've left out some code here, the function main() is returning. It then goes off to exit() and (as I recall) spins. The spin loop is enabled, so you would continue to get interrupts, however, you haven't enabled the Timer0_A0 interrupt.

    1) If I run out of things to do at the end of main(), I add:

    > while (1) { __WFI();}

    to keep it from returning. (The "__WFI()" is optional, but makes it spin in low-ish power mode.) 

    2) You need to enable the Timer0_A0 interrupt with something like:

    > NVIC_ClearPendingIRQ(TA0_0_IRQn); // Clear any stale status

    > NVIC_EnableIRQ(TA0_0_IRQn);  // Enable TA0_0 in the interrupt controller

  • Hi Saber,

    I have not seen any activity on this thread for sometime, so I am assuming that what Bruce provided resolved your issue. I am going to go ahead and close this thread. If you are still having an issue, feel free to re-open the thread.

    Thanks,

    Riz

  • Thanks Riz

    Sorry for delayed response. 

    Yes, my issue was resolved. 

    Thanks

    Saber

**Attention** This is a public forum