请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
主题中讨论的其他器件:MSP430F5529尊敬的所有人:
我使用 MSP430F5529并在 RTOS 上运行并启用看门狗。
但是、如何验证器件何时崩溃、看门狗可以复位器件?
我按照如下所示的看门狗示例进行操作。
bool flag = false;
Task_Struct task0Struct;
Char task0Stack[TASKSTACKSIZE];
Watchdog_Handle watchdogHandle;
/*
* ======== watchdogCallback ========
* Watchdog interrupt callback function. It toggles and LED, and if a button
* has not been pressed, clears the watchdog interrupt flag.
*/
Void watchdogCallback(UArg unused)
{
GPIO_toggle(Board_LED0);
}
/*
* ======== gpioButtonFxn ========
* Callback function for the GPIO interrupt on Board_BUTTON0.
*/
void gpioButtonFxn(unsigned int index)
{
flag ^= true;
GPIO_write(Board_LED0, Board_LED_ON);
}
/*
* ======== taskFxn ========
* Sets a flag and clears the watchdog timer if the button has been pressed.
*/
Void taskFxn(UArg arg0, UArg arg1)
{
while (true) {
/* Prevent Watchdog ISR trigger if button was pushed */
if (flag) {
Watchdog_clear(watchdogHandle);
}
}
}
/*
* ======== main ========
*/
int main(void)
{
Task_Params taskParams;
Watchdog_Params params;
/* Call board init functions */
Board_initGeneral();
Board_initGPIO();
Board_initWatchdog();
/* Construct BIOS objects */
Task_Params_init(&taskParams);
taskParams.stackSize = TASKSTACKSIZE;
taskParams.stack = &task0Stack;
Task_construct(&task0Struct, taskFxn, &taskParams, NULL);
/* Turn on user LED */
GPIO_write(Board_LED0, Board_LED_ON);
/* Install Button callback */
GPIO_setCallback(Board_BUTTON0, gpioButtonFxn);
/* Enable interrupts */
GPIO_enableInt(Board_BUTTON0);
System_printf("Starting the Watchdog example\nSystem provider is set to "
"SysMin. Halt the target to view any SysMin contents in"
" ROV.\n");
/* SysMin will only print to the console when you call flush or exit */
System_flush();
/* Create and enable a Watchdog with resets disabled */
Watchdog_Params_init(¶ms);
params.resetMode = Watchdog_RESET_OFF;
watchdogHandle = Watchdog_open(Board_WATCHDOG0, ¶ms);
if (watchdogHandle == NULL) {
System_abort("Error opening Watchdog!\n");
}
/* Start BIOS */
BIOS_start();
return (0);
}
谢谢。
