This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

ANCS add WDT

In the ANCS service to add wdt, the program has been reset, the use of the protocol stack is SDK9.0.0

  • You meant if you connect to the phone, then the device will crash and reset ?

    How do you feed the WDT ? Could you post your code ?

  • enter code here

    db_discovery_init();
        scheduler_init();
        gap_params_init();
        service_init();
        advertising_init();
        conn_params_init();
    	
        //Start execution.
        err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
        APP_ERROR_CHECK(err_code);
    	WDTconfig();
    
        //Enter main loop.
        for (;;)
        {
    		
            app_sched_execute();
    		wdt_feed();
            power_manage();
    		
        }
    
        void WDTconfig(void)
    {
    	uint32_t err_code;
    	//Configure WDT.
        nrf_drv_wdt_config_t config = NRF_DRV_WDT_DEAFULT_CONFIG;
        err_code = nrf_drv_wdt_init(&config, wdt_event_handler);
        APP_ERROR_CHECK(err_code);
        err_code = nrf_drv_wdt_channel_alloc(&m_channel_id);
        APP_ERROR_CHECK(err_code);
        nrf_drv_wdt_enable();
    }
    

    This is the watchdog initialization procedure

     void wdt_feed(void)
    {
    	nrf_drv_wdt_channel_feed(m_channel_id);
    }
    

    This is a feeding dog program

  • Hi Zhang,

    From your code I can see that if there is no application interrupt /BLE event occur the dog will not be fed. This is because power_manage() will put CPU to sleep and won't let the loop to get out if there is no event.

    You can try to remove power_manage(), this will allow wdt_feed() be called all the time. But this will cause the CPU to be active all the time, consuming current.

    You can replace power_manage() with __SEV();__WFE();__WFE();. This will put CPU to sleep, and still allow it to wake up and execute other command in the main loop when there is any BLE activity. Basically anytime the Softdevice is active.

  • Hi     After the experiment, use __SEV (); __WFE (); __WFE (); instead of power_manage (); the program can run normally, but I am not very clear about the difference and difference between the two. Use __SEV (); __WFE (); __WFE (); Will not cause 51822 standby power consumption is too high, or can not enter the low power mode it There is no relevant information or description, describe the use of the two methods, I hope you can help me, thank you

  • The main difference between __SEV (); __WFE (); __WFE (); and power_manage (); is when should it get out of the function and let the CPU continue the loop , so that wdt_feed() can be called. power_manager(); won't let the CPU to continue the loop if there is no application event or BLE event.

    __SEV (); __WFE (); __WFE (); let the CPU continue if it has to wake up for anything. This includes the BLE activity that the softdevice handle in the back ground. In other words, this solution let the wdt_feed() to be called every time you have a connection event or advertising event, when power_manager() doesn't.

    connection events and BLE events are not the same. BLE events are event that the softdevice send to application. Connection events is the event occurs on BLE interval even there is no data to send.

Related