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