在调试CH573看门狗的代码中,本人在接收到串口指令后,启用开门狗我添加了以下两条代码:

WWDG_SetCounter(0x0);

WWDG_ResetCfg(ENABLE);

程序没有其它地方进行喂狗操作。但有时看门狗复位,有时不复位,请问是怎么回事?


代码片段如下:

void uart1_msgProcess(uint8_t* msg_ptr)

{

  uint8_t msg_len = msg_ptr[0];

  uint8_t *pMsg = msg_ptr+1;

  static bool cmd_test = false;


  if(strncmp((char *)pMsg,"#software_reset\r\n",strlen("#software_reset\r\n")) == 0){

    PRINT("software reset\n");

    sys_softReset();

  }

  else if(strncmp((char *)pMsg,"#test_wdog\r\n",strlen("#test_wdog\r\n")) == 0){

    PRINT("Test watch_dog\n");

    WWDG_SetCounter(0x0);

    WWDG_ResetCfg(ENABLE);

  }


调试信息如下: 启动了3次看门狗,前两次成功复位,第三次没起作用

Test watch_dog

1s count 553, systick:553030

uart1_init

VER_LIB: CH57x_BLE_LIB_V1.50

readChipId:0x01 0x36 0x39 0x34 0x41 0x30 0x50 0x42

UniqueID:0136393441305042

uartTask init

Initialized..

Advertising..

1s count 1, systick:991

1s count 2, systick:1991

1s count 3, systick:2991

1s count 4, systick:3991

RX 12B: #test_wdog


Test watch_dog

uart1_init

VER_LIB: CH57x_BLE_LIB_V1.50

readChipId:0x01 0x36 0x39 0x34 0x41 0x30 0x50 0x42

UniqueID:0136393441305042

uartTask init

Initialized..

Advertising..

1s count 1, systick:991

1s count 2, systick:1991

1s count 3, systick:2991

1s count 4, systick:3991

RX 12B: #test_wdog


Test watch_dog

1s count 5, systick:4991

1s count 6, systick:5991

1s count 7, systick:6991

1s count 8, systick:7991

1s count 9, systick:8991

1s count 10, systick:9991