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

Watchdog for MESH s132

Is there any example for using the Watchdog with the BLE Mesh?

Experiencing some asserts, and would like to restart the device if it happens.

There is an example for the watchdog in the SDK, but it is using 32kHz clock, which is possibly used also by the softdevice 132 - do not want to create conflicts.

Parents
  • There is no dependencies or conflicts here. You are right that both softdevice, watchdog and very likely you have some app_timer() in your application that all require an LFCLK source running (either external 32kHz or internal 32kHz RC), however there are no dependencies or conflicts between them, they (softdevice, watchdog and app_timer) will simply (and automatically) use whatever LFCLK source that is active.

    Kenneth

  • I have a problem with wdt. If I enable wdt with WDT_ENABLED as below, my serial rx data is getting corrupted. If I put it back to 0 (disabled), aand rebuild , serial data is OK. I am doing full rebuild on each change.

    I am sending througvh the UART command 0x20, len 9:

    oprtx2 10: 09 20 00 0C 00 00 00 02 03 04

    My callback function is receiving following data:

    seconsole.c,  429, RX 8[420]:  00 0C 00 00 09 20 00 0C

    Looks like the second part of rx data is getting overwritten with the start.

    I will try to run it on the plain eval board - this is just UART comm, not dependent on our design, I have just 832 + SPI EEPROM.

    // <e> WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver - legacy layer
    //==========================================================
    #ifndef WDT_ENABLED
    #define WDT_ENABLED 1
    #endif
    // <o> WDT_CONFIG_BEHAVIOUR - WDT behavior in CPU SLEEP or HALT mode

    // <1=> Run in SLEEP, Pause in HALT
    // <8=> Pause in SLEEP, Run in HALT
    // <9=> Run in SLEEP and HALT
    // <0=> Pause in SLEEP and HALT

    #ifndef WDT_CONFIG_BEHAVIOUR
    #define WDT_CONFIG_BEHAVIOUR 1
    #endif

    // <o> WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295>


    #ifndef WDT_CONFIG_RELOAD_VALUE
    #define WDT_CONFIG_RELOAD_VALUE 2000
    #endif

Reply
  • I have a problem with wdt. If I enable wdt with WDT_ENABLED as below, my serial rx data is getting corrupted. If I put it back to 0 (disabled), aand rebuild , serial data is OK. I am doing full rebuild on each change.

    I am sending througvh the UART command 0x20, len 9:

    oprtx2 10: 09 20 00 0C 00 00 00 02 03 04

    My callback function is receiving following data:

    seconsole.c,  429, RX 8[420]:  00 0C 00 00 09 20 00 0C

    Looks like the second part of rx data is getting overwritten with the start.

    I will try to run it on the plain eval board - this is just UART comm, not dependent on our design, I have just 832 + SPI EEPROM.

    // <e> WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver - legacy layer
    //==========================================================
    #ifndef WDT_ENABLED
    #define WDT_ENABLED 1
    #endif
    // <o> WDT_CONFIG_BEHAVIOUR - WDT behavior in CPU SLEEP or HALT mode

    // <1=> Run in SLEEP, Pause in HALT
    // <8=> Pause in SLEEP, Run in HALT
    // <9=> Run in SLEEP and HALT
    // <0=> Pause in SLEEP and HALT

    #ifndef WDT_CONFIG_BEHAVIOUR
    #define WDT_CONFIG_BEHAVIOUR 1
    #endif

    // <o> WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295>


    #ifndef WDT_CONFIG_RELOAD_VALUE
    #define WDT_CONFIG_RELOAD_VALUE 2000
    #endif

Children
  • I am not familiar with how the mesh project may have implemented this, but can you compare with the peripheral/wdt example in nRF5 SDK, e.g:

        //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();

    In addition you should feed the watchdog somewhere to avoid watchdog reset:

    nrf_drv_wdt_channel_feed(m_channel_id);

    I can't really see how any of this should affect the uart communication. Though you may check if you are affected by this issue in nRF5 SDKv17 (even though I don't understand how that should impact the UART):

    https://devzone.nordicsemi.com/f/nordic-q-a/63998/freertos-wdt-sdk17-problem/263131#263131 

    Best regards,
    Kenneth

  • Looks like I got rid of it, by moving wdt enable to another place.

    Somehow UART int was getting the RX ready flag cleared for bytes after first 6 - this is hard to debug, but at the moment it is gone. I was able to store rx data in the buffer - but could not figure out, why the rx flag was getting cleared.

    Regarding your sample wdt code, why do you have in the main loop? Is it really needed, or the call to

    nrf_drv_wdt_channel_feed(m_channel_id);

    is sufficient?

    __SEV();
    __WFE();
    __WFE();

  • pkoenig said:
    __SEV();
    __WFE();
    __WFE();

    This is used to go to sleep/idle when there is no CPU processing, it is not related to watchdog. These 3 lines should be replaced with the sd_app_wait() if the softdevice is enabled.

    Best regards,
    Kenneth

Related