Instruction Manual
198 运动控制功能原理介绍
3. 不间断的重置定时器
在启动看门狗后,需要在设定的逾时时间内,去重置看门狗,
让定时器可以归零,并重新计时。若定时器逾时,会依据步
骤 1 的设定,去触发相关的事件。
使用 APS_wdt_reset_counter() 去重置看门狗。
• 例 :
void watchdog_example()
{
// This example shows how interrupt functions work.
I32 board_id = 0;
I32 timer_no = 0; // Only timer 0 to be used
I32 time_out = 10; // Time out is 10*100 ms = 1 sec
I32 EventByBit = 0x01; // Action event is defined by bit.
// Bit0: Motor servo off
// Bit1: Digital output off
// Bit2: PWM off
I32 ret = 0; // return code
//Step 1: 姕⭂妰㗪☐妠䘤⼴䘬ḳẞ
ret = APS_wdt_set_action_event( board_id, timer_no, EventByBit );
//Step 2: ┇≽䚳攨䉿ᾅ嬟㨇⇞
ret = APS_wdt_start( board_id, timer_no, time_out );
//ἧ䓐侭䘬timer炻while loop炻ㆾ侭㗗⎗⚆ㅱ溆
timer(500ms)//㭷500ms⍣慵伖ᶨ㫉妰㗪☐
{
//Step 3: ᶵ攻㕟䘬慵伖妰㗪☐
ret = APS_wdt_reset_counter( board_id, timer_no );
…Do Something
}
}
preliminary