This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

#cc2640r2f watchdog 问题



你好我开启watchdog

void Watchdog_Init(void)
{
    Watchdog_Params params;
    Watchdog_init();
    Watchdog_Params_init(&params);
    params.callbackFxn    = (Watchdog_Callback) watchdogCallback;
    params.debugStallMode = Watchdog_DEBUG_STALL_ON;
    params.resetMode      = Watchdog_RESET_ON;
    g_watchdogHandle = Watchdog_open(Board_WATCHDOG0, &params);
    if(g_watchdogHandle == NULL)
    {
        /* Error opening Watchdog */
        while (1) {}
    }
    Watchdog_setReload(g_watchdogHandle, 2500000); // 1sec (WDT runs always at 48MHz/32)

}
2s喂一次狗,但是我程序异常,想进入复位先保存一次数据:
void watchdogCallback(uintptr_t handle)
{
  static bool flag =false;
  uint8_t w25_buff[8];
  if(flag==false)
  {
//    if(flash_open())
   {
//        if(Flash_Address%4096 == 0)  //判断flash是否为空
//         {
//           ExtFlash_read(Flash_Address,8,w25_buff);
//           if(w25_buff[3]!=0xff||w25_buff[5]!=0xff||w25_buff[7]!=0xff)
//           ExtFlash_erase(Flash_Address,4096);
//         }
//       ExtFlash_write(Flash_Address,SIMPLEPROFILE_CHAR4_LEN,s_buff); //写入数据
//       Flash_Address+=256;
//       if(Flash_Address>= Finish_Flash_Address)//大于flash
//       Flash_Address = Start_Flash_Address;//重新开始
       BOARD_CONFIG&=~watchdog_rst;
       RTC_time = RTC_GetTime();//得到现在时间
       Save_BOARD_CONFIG(&BOARD_CONFIG,&Flash_Address,&RTC_time);   
   }
   flag = true;
  }  
}
但是断电打的时候调试,程序flash还没保存完就开启复位了
就是断电打在前面可以进入,但打在写flash后面进进不去了