Part Number: CC2640R2F
Other Parts Discussed in Thread: SYSBIOS
what is the code to hang a system if watchdog is expired and the message that system hang should be displayed in tera term app
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.
Christin Lee said:When the device hit while 1, the program will just stop and can't get out of the loop. (I assume that's what you meant by hang the system)
Yes, to simulate a hang.
-kel
Christin Lee said:Do you want to have a while 1 to simulate system hanging and then when that happens, you will to start watchdog and reset the device?
-kel
Hi M SPIM,
I will share my Watchdog code implementation later. But, for now I can tell you that I also implemented to kick the watchdog using a util clock and it was not a good idea. Because it will periodically wake up your device from standby mode and consume current.
-kel
Hi,
First you need to make sure that Watchdog is set at the board files including the Watchdog reload value.
watchdog_app.c
#include <ti/drivers/Watchdog.h>
#include "watchdog_app.h"
Watchdog_Handle WatchdogHandle;
void Watchdog_Callback(uintptr_t unused)
{
HAL_SYSTEM_RESET();
}
void Watchdog_Clear(void)
{
Watchdog_clear(WatchdogHandle);
}
void Watchdog_Init(void)
{
Watchdog_Params params;
Watchdog_init();
Watchdog_Params_init(¶ms);
params.callbackFxn = (Watchdog_Callback)Watchdog_Callback;
params.resetMode = Watchdog_RESET_ON;
WatchdogHandle = Watchdog_open(Board_WATCHDOG0, ¶ms);
if (WatchdogHandle == NULL) {
/* Error opening Watchdog */
while (1);
}
}
watchdog_app.h
#ifndef WATCHDOGAPP_H
#define WATCHDOGAPP_H
#ifdef __cplusplus
extern "C"
{
#endif
extern void Watchdog_Init(void);
extern void Watchdog_Clear(void);
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* WATCHDOGAPP_H */
simple_peripheral.c
static void SimpleBLEPeripheral_init(void)
{
Watchdog_Init();
}
static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1)
{
// Initialize application
SimpleBLEPeripheral_init();
// Application main loop
for (;;)
{
uint32_t events;
// Waits for an event to be posted associated with the calling thread.
// Note that an event associated with a thread is posted when a
// message is queued to the message receive queue of the thread
events = Event_pend(syncEvent, Event_Id_NONE, SBP_ALL_EVENTS,
ICALL_TIMEOUT_FOREVER);
Watchdog_Clear();
if (events)
{
}
}
}
-kel