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.

MSP430G2553: Watch dog program not working

Part Number: MSP430G2553

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.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#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;
}
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Thanks in advance!!

Regards,

Aravinth K.

  • Hi,

    You do not need to add the while(1) to check your code. You can add breakpoints in the timer ISR like line 36 or line 39 to check the status.

    Best regards,

    Cash Hao

  • Hello, cash Hao11,

    Thanks for your reply, I just added a breakpoint at timer line 39 it's working, but how do I manually halt the controller and check WTD is resetting the controller?

    Thanks & Regards,

    Aravinth K

  • Hi,

    If you want to check the watchdog is resetting the controller. You need to block the feed dog code.

    You can refer to this example code for some ideas.

    https://dev.ti.com/tirex/explore/node?node=AEBlR0c40D8-.JOaN5u6sQ__IOGqZri__LATEST

    Best regards,

    Cash Hao

  • Hi, cash Hao11,

    Thanks for your reply, 

    The above-mentioned code works by some modifications, Every 200ms I am clearing the WDT counter, am setting a flag after 5000 counts so that timer can't able to reset the WDT counter so WDT expires and starts reset controller. I have mentioned the code below

    Thanks for your guidance 

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #include "msp430g2553.h"
    unsigned int Timer1ms=0;
    unsigned int count=0;
    unsigned int temp=0;
    void Timer_Init();
    void main(void)
    {
    WDTCTL = WDTPW + WDTHOLD;// Stop the WDT to prevent reset // Count value for delay
    Timer_Init(); // Initialize timer
    WDTCTL = WDT_ARST_1000; // 1 sec watchdog interval
    count=0;
    temp=0;//flag
    while(1)
    {
    count++;
    if(count>5000)
    {
    temp=1;// after 5000 count temp will set
    count=0;//clearing count
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Thanks & regards,

    Aravinth K.

**Attention** This is a public forum