Skip to content

Commit f3bbab2

Browse files
committed
am26x: WDT: Fix WDT Example
- Update waiting code pre-reset - Clean Up - Update Docs Fixes: MCUSDK-14254 Signed-off-by: Subhranil Das <[email protected]>
1 parent c8328ec commit f3bbab2

File tree

2 files changed

+34
-25
lines changed

2 files changed

+34
-25
lines changed

docs_src/docs/api_guide/examples/drivers/watchdog_reset_mode.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,30 +57,28 @@ Please note that application prints in both CCS and UART console.
5757
CCS Console:
5858
\code
5959
[MAIN_Cortex_R5_0_0] Watchdog reset Mode Test Started ...
60-
Servicing WDT for few iterations
60+
Servicing WDT for 3 iterations
61+
Servicing WDT !!
62+
Servicing WDT !!
63+
Servicing WDT !!
6164
Watchdog triggers warm reset in 3000 (ms)
6265
All tests have passed!!
63-
Prints will be stopped after reset
64-
Prints will be stopped after reset
65-
Prints will be stopped after reset
66-
'' ''
67-
'' ''
68-
'' ''
69-
Prints will be stopped after reset
66+
3
67+
2
68+
1
7069
\endcode
7170

7271
UART Console:
7372
\code
7473
Watchdog reset Mode Test Started ...
75-
Servicing WDT for few iterations
74+
Servicing WDT for 3 iterations
75+
Servicing WDT !!
76+
Servicing WDT !!
77+
Servicing WDT !!
7678
Watchdog triggers warm reset in 3000 (ms)
7779
All tests have passed!!
78-
Prints will be stopped after reset
79-
Prints will be stopped after reset
80-
Prints will be stopped after reset
81-
'' ''
82-
'' ''
83-
'' ''
84-
Prints will be stopped after reset
80+
3
81+
2
82+
1
8583
\endcode
8684

examples/drivers/watchdog/watchdog_reset/watchdog_reset_mode.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2021 Texas Instruments Incorporated
2+
* Copyright (C) 2021-2025 Texas Instruments Incorporated
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -37,8 +37,12 @@
3737
#include "ti_drivers_config.h"
3838
#include "ti_drivers_open_close.h"
3939
#include "ti_board_open_close.h"
40+
#include "stdbool.h"
4041

41-
#define NUM_OF_ITERATIONS (3U)
42+
#define NUM_OF_ITERATIONS (3U)
43+
#define MILLISEC_PER_SEC (1000U)
44+
#define EXP_TIME_DIVIDER (2U)
45+
#define MILLISEC_TO_MICROSEC(msec) ((msec)*1000U)
4246

4347
/*
4448
* This example uses the WDT module in reset mode to trigger warm reset.
@@ -56,33 +60,40 @@ void watchdog_reset_mode_main(void *args)
5660
/* Watchdog timer expiry time in millisecond */
5761
uint32_t wdtExpiryTimeinMs = gWatchdogParams[CONFIG_WDT0].expirationTime;
5862
uint32_t index = 0;
63+
uint32_t countdown = wdtExpiryTimeinMs/MILLISEC_PER_SEC;
5964

6065
/* Open drivers to open the UART driver for console */
6166
Drivers_open();
6267
Board_driversOpen();
6368

6469
DebugP_log("Watchdog reset Mode Test Started ...\r\n");
6570

66-
DebugP_log("Servicing WDT for few iterations \r\n");
71+
DebugP_log("Servicing WDT for %d iterations \r\n", NUM_OF_ITERATIONS);
6772

6873
/* Service the WDT for more than expiry time */
6974
for(index = 0; index < NUM_OF_ITERATIONS; index++)
7075
{
7176
/* Need to service the WDT in open window */
7277
while(Watchdog_isClosedWindow(gWatchdogHandle[CONFIG_WDT0]) == true);
78+
/* wait for (expiry time/2 ) time */
79+
ClockP_usleep(MILLISEC_TO_MICROSEC(wdtExpiryTimeinMs)/EXP_TIME_DIVIDER);
80+
DebugP_log("Servicing WDT !! \r\n");
7381
/* Clear Watchdog timer */
7482
Watchdog_clear(gWatchdogHandle[CONFIG_WDT0]);
75-
/* wait for (expiry time/2 ) time */
76-
ClockP_usleep((wdtExpiryTimeinMs*100)/2);
7783
}
7884

79-
DebugP_log("Watchdog triggers warm reset in %d (ms)\r\n", wdtExpiryTimeinMs);
85+
DebugP_log("Watchdog triggers warm reset in %d (ms)\r\n",
86+
wdtExpiryTimeinMs);
8087
DebugP_log("All tests have passed!!\r\n");
88+
Watchdog_clear(gWatchdogHandle[CONFIG_WDT0]);
89+
90+
/* Wait for residual milli seconds */
91+
ClockP_usleep(MILLISEC_TO_MICROSEC(wdtExpiryTimeinMs%1000U));
8192

8293
/* Wait till WDT triggers the reset */
83-
while(1)
94+
while(true)
8495
{
85-
DebugP_log("Prints will be stopped after reset \r\n");
96+
DebugP_log("%d\r\n", countdown--);
97+
ClockP_usleep((MILLISEC_TO_MICROSEC(MILLISEC_PER_SEC)));
8698
}
87-
8899
}

0 commit comments

Comments
 (0)