Hello everyone,
Greetings!!!
My task is to reset the microcontroller if it's halted, for that, I am using a watchdog timer,
I am setting the watchdog time period as 1sec and am clearing WTD every 200ms for that I am using a timer so that the WTD won't reset every 1sec,
I wrote code, I wish to check the program so I added while(1);, the program halted here, the WDT is not resetting the microcontroller,
my program holds on while(1);, what's the problem, am I doing anything wrong? please guide me on how to solve it. I have mentioned my code below for your reference.
#include "msp430g2553.h" unsigned int Timer1ms=0; unsigned int count=0; void Timer_Init(); void main(void) { WDTCTL = WDTPW + WDTHOLD;// Stop the WDT to prevent reset // Count value for delay Timer_Init(); WDTCTL = WDT_ARST_1000; // 1 sec watchdog interval while(1) { // WDTCTL = WDT_ARST_1000; count++; if(count>5000) { while(1); count=0; } } } void Timer_Init() { DCOCTL = CALDCO_8MHZ; BCSCTL1 = CALBC1_8MHZ; TA0CCTL0=CCIE; TA0CTL=TASSEL_2+MC_1+ID_3;//SMCLK, Up mode, Divider -->1 TA0CCR0=999;//from above calculation _BIS_SR(GIE);//off CPU until interrupt occurs } #pragma vector=TIMER0_A0_VECTOR __interrupt void TIMER0_A0_ISR(void) { Timer1ms++; if(Timer1ms>=200) { WDTCTL = WDTPW + WDTHOLD + WDTCNTCL;// Stop WDT WDTCTL = WDT_ARST_1000; //again 1sec reload Timer1ms=0; } }
Thanks in advance!!
Regards,
Aravinth K.