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

Using power Off/On as a Hard Reset on nrf51822

Hi There

I am developing a custom board on NRF51822.  I have a noticed that the chip is getting stuck every day and to run it again I need to press a button on/off to reset the system. After that all is working fine till next day..Is it because the WDT is configured for 36h? Can I use a GPIO and external hardware to pull down the main power from the chip and turn it on again and doing this process every 12h for example(self resetting) . Is this save process for microcontroller?

  • The utility in a WDT is to reset the device when normal operation has stopped.  Generally a cessation of normal function can be seen after a few seconds.  So, a 36 hour timeout doesn't really utilize the function of a WDT.

    You can do a chip reset any way you wish (eg, power cycle, reset pin, dedicated gpio, wdt timeout). The only thing you need to keep track of is if you are writing to flash. However, since your code is dead there is no hope of properly closing flash.

    You should start first by coming up with a realistic WDT number based on your code.  Think seconds not hours. Then find a critical function to put the WDT refresh into that is known to run more often than the timeout. Sometimes people put the wdt refresh in main with the power manage, I prefer putting it into code associated with radio activity.  Then I know if something went wrong with the Softdevice.

    Then you should debug your code.  There is no reason for embedded application to crash. You did something wrong in your code and it needs to be fixed.

  • Thank you for that quick reply. In therms of my code, I do not  thing that my code causes ble stuck as I turn off all function that been used and I only left the  function where the ble is advertising. The same thing, I could discover BLE on my phone that day but it gone day after. Once recycled the power the BLE back on. So my question is. if I recycle the power does it mean the WDT  is recycled as well? and also does the BLE like to be switch off/on every day?

  • For comparison, I have designed products that run continuously until the battery dies after nearly a year without once the BLE getting "stuck".  You have something wrong with your code or your custom board.

    If you are not going to fix your code or board you should at least fix your WDT. A correctly used WDT will trigger a reset when the product is not working.  That is the whole point of a WDT. You have not programmed your WDT correctly.  You should fix this.

    With regard to your question about the WDT, page 112 of the nRF51 Series Reference Manual CLEARLY states the state of the WDT after a reset or power cycle:

    "20.1.3 Watchdog reset
    A TIMEOUT event will automatically lead to a watchdog reset equivalent to a system reset, see POWER
    chapter for more information about reset sources. If the watchdog is configured to generate an interrupt
    on the TIMEOUT event, the watchdog reset will be postponed with two 32.768 kHz clock cycles after the
    TIMEOUT event has been generated. Once the TIMEOUT event has been generated, the impending
    watchdog reset will always be effectuated.
    The watchdog must be configured before it is started. After it is started, the watchdog’s configuration
    registers, which comprises registers CRV, RREN, and CONFIG, will be blocked for further configuration.
    The watchdog is reset when the device is put into System OFF mode. The watchdog is also reset when the
    whole system is reset, except for when the system is reset through a soft reset, see POWER chapter for
    more information about reset types.
    When the device starts running again, after a reset, or waking up from OFF mode, the watchdog
    configuration registers will be available for configuration again."

    And for the final question, the SoftDevice does not care if you power cycle constantly.  It is a computer and just runs. You as the designer only need to care if you are leaving flash open and not closing it correctly.

Related