1782 views|0 replies

6555

Posts

0

Resources
The OP
 

For CC2640R2f watchdog can be like this [Copy link]

In TI's official routines, there is a usage of watchdog, for example:

C:\ti\simplelink_cc2640r2_sdk_2_40_00_32\examples\rtos\CC2640R2_LAUNCHXL\drivers\watchdog

This is the watchdog project in my SDK directory.

Because the official code has been packaged, when we use the watchdog, we can call it directly.

Header Files

#include <ti/drivers/Watchdog.h>

function

Watchdog_init();

/* Open a Watchdog driver instance */
Watchdog_Params_init(ms);
params.callbackFxn = (Watchdog_Callback) watchdogCallback;
params.debugStallMode = Watchdog_DEBUG_STALL_ON;
params.resetMode = Watchdog_RESET_ON;

watchdogHandle = Watchdog_open(Board_WATCHDOG0, ms);
if (watchdogHandle == NULL) {
/* Error opening Watchdog */
while (1) {}
}

A watchdog callback function is also required

void watchdogCallback(uintptr_t watchdogHandle)
{
/*
* If the Watchdog Non-Maskable Interrupt (NMI) is called,
* loop until the device resets. Some devices will invoke
* this callback upon watchdog expiration while others will
* reset. See the device specific watchdog driver documentation
* for your device.
*/
while (1) {}
}

The above function turns on the watchdog, use:

Watchdog_clear(watchdogHandle);

Clear the watchdog counter. The watchdog in this mode is restarted.

For example, if you want the watchdog to alarm ten times before restarting the device, you can modify the parameters

params.resetMode = Watchdog_RESET_ON;

typedef enum Watchdog_ResetMode_ {
Watchdog_RESET_OFF, /*!< Timeouts generate interrupts only */
Watchdog_RESET_ON /*!< Generates reset after timeout */
} Watchdog_ResetMode;

Modified to

params.resetMode = Watchdog_RESET_OFF;

Then the watchdog becomes an interrupt function, and then add it to the watchdog callback function

Watchdog_init();
/* Create and enable a Watchdog with resets disabled */
Watchdog_Params_init(ms);
params.callbackFxn = (Watchdog_Callback)watchdogCallback;
params.resetMode = Watchdog_RESET_OFF;
watchdogHandle = Watchdog_open(Board_WATCHDOG0, ms);

//---------------Watchdog callback---------------

void watchdogCallback(uintptr_t unused)
{

/* Clear watchdog interrupt flag */
Watchdog_clear(watchdogHandle);

static int WDT_flag = 0;
if(WDT_flag++ > 10){
SystemReset();//Restart function
}
/* Insert timeout handling code here. */
}

This post is from Wireless Connectivity
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list