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.

No interrupt generation in MSP430f149

Other Parts Discussed in Thread: MSP430F149

Hi

 

I am using msp430f149 for an application which uses interrupt. I tried running a simple square wave generateion using timerb to test timer interrupt. But no interrupt is generated i made port 4 to toggle  the output every time but no output on the pins. I am using XT2(8MHz) crystal no XT1 present. Here is the code listing. Any suggestion...

#include  <msp430x14x.h>
#include  <stdio.h>
#include  <signal.h>

/////////////////timer clock 4MHZ to generate 50 hz 4MHZ/50=count(80000/2)
void main(void)
{

WDTCTL = WDTPW + WDTHOLD; // Stop watchdog
P4DIR |= 0x02;
P4OUT = 0x00;

BCSCTL1 &= ~XT2OFF; // XT2= HF XTAL switch master clock to XT2IN
int x;
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for ( x = 0xFF; x > 0; x--); // Time for flag to set
}

while ((IFG1 & OFIFG)); // OSCFault flag still set?
BCSCTL2 = SELM_2 + SELS; //+ DIVM_0 + DIVS_0;
TBCCTL0=CCIE;
TBCTL = TBSSEL_2 + MC_2 + ID_1;
TBCCR0=40000;


_BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/interrupt so CPU sleep and wait till 1s

}


interrupt (TIMERB0_VECTOR) ISRTimerB0 (void)
{
  P4OUT ^= 0xFF;                            // Toggle P4.0
TBCCTL0 &= ~CCIFG;
TBCCR0+= 40000;
                          
}
regards

arungk

  • Arun,

     

    A few suggestions. In the ISR don't do P4OUT ^= 0xFF;

    This toggles all the pins in that port. You should do:

    P4OUT ^= BIT0;

     

    It seems you have an error in the GPIO initialization. You don't specify what pin you're trying to toggle but:

    P4DIR |= 0x02;  <---- This sets P4.1 not P4.0 as output

    P4OUT = 0x00;

     

    You should do

    P4DIR |= BIT0;        // Set P4.0 as output

    P4OUT &= ~BIT0;  // Set P4.0 as low

     

    If your interrupt was being called (you can put a Breakpoint inside), then the only issue might have been this. Verify the clocks as well.

     

    Gustavo

  • Please check under the debugger if your execution reaches _BIS_SR() line, and after that try to run and stop debugger.
    Observe if the timer hardware register changes its value - you will be able to verify if the timer is set correctly and is counting.

    I advise also to add "while(1);" line on the end of main and set there a breakpoint.
    It should not be reached but it needs to be checked.

    You can also set a breakpoint in ISRTimerB0 and check if it is passed any time (you probably have already done this).

    Are you using IAR Work Bench?

    Regards,
    Piotr Romaniuk, Ph.D.
    ELESOFTROM

    PS
    Please try smaller value for the counter - it will be better under debugger.

**Attention** This is a public forum