User guide

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 );
//ἧ䓐侭䘬timerwhile loop炻ㆾ侭㗗⎗⚆ㅱ溆
timer(500ms)//500ms⍣慵伖ᶨ㫉妰
{
//Step 3: 攻㕟䘬慵伖妰
ret = APS_wdt_reset_counter( board_id, timer_no );
…Do Something
}
}
preliminary