<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>How to use WDT to reset device in nRF52832</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/51283/how-to-use-wdt-to-reset-device-in-nrf52832</link><description>HI, 
 
 I am using &amp;quot;.\nRF5_SDK_15.3.0_59ac345\examples\peripheral\wdt&amp;quot; to test “watch dog timer function. 
 My use case is: 
 1. If the program is not execute over following pint (please find follow image) in some time, the system will reboot. 
 2. Otherwise</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 23 Aug 2019 06:26:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/51283/how-to-use-wdt-to-reset-device-in-nrf52832" /><item><title>RE: How to use WDT to reset device in nRF52832</title><link>https://devzone.nordicsemi.com/thread/205742?ContentTypeID=1</link><pubDate>Fri, 23 Aug 2019 06:26:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75821b2d-4e35-42b5-9e7b-5f55f6a46645</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Chianglin,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;These two instructions are used to clear the internal &amp;quot;event&amp;quot; register. I don&amp;#39;t think it&amp;#39;s strictly necessary here, it could have been just one __WFE instruction. Here&amp;#39;s another thread which provides more details:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/490/how-do-you-put-the-nrf51822-chip-to-sleep"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/490/how-do-you-put-the-nrf51822-chip-to-sleep&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use WDT to reset device in nRF52832</title><link>https://devzone.nordicsemi.com/thread/205510?ContentTypeID=1</link><pubDate>Thu, 22 Aug 2019 09:34:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:464c377b-4ef9-4561-af08-77cb8fe893d0</guid><dc:creator>chianglin</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi Vidar,,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It&amp;#39;s work now, thank you.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Can I ask an another question?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;What the purpose of &amp;quot;__SEV()&amp;quot; and &amp;quot;__WFE()&amp;ldquo;？&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thank you,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Chianglin&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use WDT to reset device in nRF52832</title><link>https://devzone.nordicsemi.com/thread/205493?ContentTypeID=1</link><pubDate>Thu, 22 Aug 2019 09:11:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:42b4bdc9-64c9-429f-ac8f-34d77cbabfc4</guid><dc:creator>chianglin</dc:creator><description>&lt;p&gt;Hi Vidar,,&lt;/p&gt;
&lt;p&gt;Please find the attach file.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;

#include &amp;quot;nrf.h&amp;quot;
#include &amp;quot;bsp.h&amp;quot;
#include &amp;quot;app_timer.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;nrf_drv_wdt.h&amp;quot;
#include &amp;quot;nrf_drv_clock.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;app_util_platform.h&amp;quot;

#define FEED_BUTTON_ID          0                           /**&amp;lt; Button for feeding the dog. */

nrf_drv_wdt_channel_id m_channel_id;

/**
 * @brief WDT events handler.
 */
void wdt_event_handler(void)
{
    bsp_board_leds_off();

    //NOTE: The max amount of time we can spend in WDT interrupt is two cycles of 32768[Hz] clock - after that, reset occurs
}

/**
 * @brief Assert callback.
 *
 * @param[in] id    Fault identifier. See @ref NRF_FAULT_IDS.
 * @param[in] pc    The program counter of the instruction that triggered the fault, or 0 if
 *                  unavailable.
 * @param[in] info  Optional additional information regarding the fault. Refer to each fault
 *                  identifier for details.
 */
void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
{
    bsp_board_leds_off();
    while (1);
}

/**
 * @brief BSP events callback.
 */
void bsp_event_callback(bsp_event_t event)
{
    switch (event)
    {
        case BSP_EVENT_KEY_0:
            nrf_drv_wdt_channel_feed(m_channel_id);
            break;

        default :
            //Do nothing.
            break;
    }
}

/**
 * @brief Function for main application entry.
 */
int main(void)
{
    uint32_t err_code = NRF_SUCCESS;

    //BSP configuration for button support: button pushing will feed the dog.
    err_code = nrf_drv_clock_init();
    APP_ERROR_CHECK(err_code);
    nrf_drv_clock_lfclk_request(NULL);

    err_code = app_timer_init();
    APP_ERROR_CHECK(err_code);

    err_code = bsp_init(BSP_INIT_BUTTONS, bsp_event_callback);
    APP_ERROR_CHECK(err_code);

    //Configure all LEDs on board.
    bsp_board_init(BSP_INIT_LEDS);

    //Configure WDT.
    nrf_drv_wdt_config_t config = NRF_DRV_WDT_DEAFULT_CONFIG;
    err_code = nrf_drv_wdt_init(&amp;amp;config, wdt_event_handler);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_wdt_channel_alloc(&amp;amp;m_channel_id);
    APP_ERROR_CHECK(err_code);
    nrf_drv_wdt_enable();

    //Indicate program start on LEDs.
    for (uint32_t i = 0; i &amp;lt; LEDS_NUMBER; i++)
    {   nrf_delay_ms(200);
        bsp_board_led_on(i);
    }
     err_code = bsp_buttons_enable();
     APP_ERROR_CHECK(err_code);

    while (1)
    {
    	nrf_drv_wdt_channel_feed(m_channel_id);
        __SEV();
        __WFE();
        __WFE();
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I have add &amp;quot;nrf_drv_wdt_channel_feed(m_channel_id);&amp;quot; in while loop.,&lt;/p&gt;
&lt;p&gt;But the program still execute &amp;quot;wdt_event_handler()&amp;quot; function.&lt;/p&gt;
&lt;p&gt;Would you please tell me how can I fix this problem?&lt;/p&gt;
&lt;p&gt;Thank you,&lt;/p&gt;
&lt;p&gt;Chianglin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use WDT to reset device in nRF52832</title><link>https://devzone.nordicsemi.com/thread/205468?ContentTypeID=1</link><pubDate>Thu, 22 Aug 2019 08:10:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a16fea6-7276-49db-9853-f2c32f5d43bc</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Chianglin,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You can call&amp;nbsp;nrf_drv_wdt_channel_feed() to reload the WD timer in your for loop. But&amp;nbsp;keep in mind that the WD will continue run in sleep with the default configuration so the WD timeout must be longer than expected the sleep time. The other alternative is to select the &amp;quot;&amp;lt;8=&amp;gt; Pause in SLEEP, Run in HALT &amp;quot; option&amp;nbsp;to pause the timer while asleep. You may be impacted by this errata if you go for the latter:&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/errata_nRF52832_Rev2/ERR/nRF52832/Rev2/latest/anomaly_832_88.html?cp=3_1_1_0_1_25"&gt;[88] WDT: Increased current consumption when configured to pause in System ON idle&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>