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.

MSP430 timer and interrupt not working

I want to simulate following code in IAR Embedded Workbench.But the timer not start to count and not going to ISR.

Plz give a replay

#include <msp430x20x3.h>

void main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  P1DIR |= 0x01;                            // P1.0 output
  CCTL0 = CCIE;                             // CCR0 interrupt enabled
  CCR0 = 50000;
  TACTL = TASSEL_2 + MC_2;                  // SMCLK, contmode

  _BIS_SR(GIE);                 // Enter LPM0 w/ interrupt

for(;;);
}

// Timer A0 interrupt service routine
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
  P1OUT ^= 0x01;                            // Toggle P1.0
  CCR0 += 50000;                            // Add Offset to CCR0
}

Regards

Aju

  • Am I correct in understanding that you are using the simulator mode in IAR? If so the hardware peripherals & interrupts will not operate automatically, since the software does not literally control the counting of the hardware timer. However if you want to simulate the interrupt, you can choose "forced interrupts" under the Simulator menu and double-click on the TimerA interrupt as desired to get the PC to enter the ISR.

  • Thanks for reply

    I am using simulator mode in IAR.What I can do to start the counting of hardware timer.(Timer register TAR always zero).

    Regards..

    Aju

  • I think what Brandon is indicating is that the Timer peripheral is not operational in simulator mode.  Essentially, IAR would need to creat a model of the Timer and include it in the simulator.
    If this capability is available in IAR, the IAR support team may be able to indicate how to do this.

**Attention** This is a public forum