Dears,
I have generated some sample code for watch dog timer.
In my program I have enabled 21Mhz SMCLK which generates 100KHz PWM with TACCR0 interrupt.
I tried to generate a watch dog interval timer interrupt for 32ms. But when I loaded the program to MSP430G2231 using Launch pad the program loaded for once but I doesn't worked and after that I cannot load program to the device. The launch pad is working as I programmed the MSP430G2211 device sample with other program. I have only one MSP430G2231 device and It is now, not able to reload the program. I have attached the program which I loaded to MSP430G223
#include <msp430g2231.h>
volatile unsigned char heart_beat = 0, loop_count = 0;
unsigned int i = 0, Duty = 0, count = 0;
void task(void);
void init_pwm(void);
void entry_point(void);
void main(void)
{
DCOCTL = 0xE0;
BCSCTL1 = 0xCF;
for (i = 0; i < 0xfffe; i++);
P1SEL = 0x44;
P1DIR |= 0x45;
init_pwm();
while(1)
{
while(!heart_beat);
switch(loop_count)
{
case 0: entry_point();
break;
case 1: task();
break;
default:break;
}
heart_beat = 0;
}
}
void init_pwm(void)
{
TACCTL0 = CCIE;
TACCTL1 = OUTMOD_7;
TACCR0 = 210;
TACTL = TASSEL_2 + MC_1;
_BIS_SR(GIE);
}
void entry_point(void)
{
WDTCTL = WDT_MDLY_32;
IE1 |= WDTIE;
_BIS_SR(LPM4_bits + GIE);
}
void task(void)
{
count++;
if(count > 25000)
{
Duty++;
count = 0;
}
if(Duty > 200)
Duty = 1;
}
// Timer A0 interrupt service routine
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
if(heart_beat)
{
while(1)
{
P1OUT |= 0x01;
}
}
TACCR1 = Duty;
heart_beat = 1;
}
// Watchdog Timer interrupt service routine
#pragma vector=WDT_VECTOR
__interrupt void watchdog_timer(void)
{
P1OUT ^= 0x01;
}
Kindly help me to identify what is the problem in my program. I amvery new to TI. So please help me.
With best regards
Yasin JI