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

NRF52 Watchdog not resetting

Hi,

Currently I am trying to implement Watchdog functionality into my Project.

I have the followowing problem:

I use the Nordic WatchdogTimer.h and instance the class with 1s in the constructor.

now, if I just do a 'while(1);' the code succesfuly resets after about 1 Second.

But If I dont use a while loop, it does not reset, even if I dont use the WDT::Kick() function..?!

I think I altered some of the nrf52_bitfields.h parameters, but I dont remember which ones, so maybe thats the cause, but what could it be?

Its really strange that it resets on a while loop, but not without it and without WDT::Kick()

Thanks,

jonas

Parents Reply Children
  • I didnt find an unmodified version of the bitfield.h, the only one I found had completly different defines in it..

    I am using SDK14 I think, so I guess thats not an option.. however, what does it do differently from the old WDT library?

  • it probably does the same functionality. have you double checked your registers in debug mode to verify the setup is correct? I would assume it is since while(1); triggers a reset. Are you sure there is nothing else feeding the dog?

  • Hi,

    The only way to prevent the watchdog from resetting is feeding it (or going to sleep if the WDT is configured to pause in that case - which is usually not a good idea). Can you upload the minimal code you are using to test this? That way we can see if we spot something odd.

  • yep, here I have the ultra minimal code, which still shows this strange behaviour.

    #include "RTT/SEGGER_RTT.h"
    #include "WatchdogTimer.h"
    int main() {
    SEGGER_RTT_Init();
    SEGGER_RTT_WriteString(0,"startup\n");
    WatchdogTimer WDT(3);
    
      while(1) {
        SEGGER_RTT_WriteString(0,"looping\n");
        Thread::wait(1000);
        while(1);
      }
    
    }

    when used exactly like this the code resets after some time (I noticed its not the WDT timeout, but rather random when it resets...)

    if you remove the while(1); the code will print "looping" all the time without restarting.

    my guess is still that it has something to do with the bitfields file, because thats the only thing I modified. But I dont find this file anywhere... only versions that are different from mine.

  • I just realized that my WatchdogTimer.h is for NRF51xx boards... here is the code:

    WatchdogTimer::WatchdogTimer(float seconds)
    {
        //Configure watchdog timer
        //HALT_Pause: Pause watchdog when debugger stops chip
        //Sleep_Run: Continue running watchdog when chip sleeps
        NRF_WDT->CONFIG = (WDT_CONFIG_HALT_Pause << WDT_CONFIG_HALT_Pos) | ( WDT_CONFIG_SLEEP_Run << WDT_CONFIG_SLEEP_Pos);
        
        //Set watchdog timeout (seconds * clock cycle)
        NRF_WDT->CRV = seconds * (float)NRF_CLK_RATE;
        
        //Enable reload register 0
        NRF_WDT->RREN = WDT_RREN_RR0_Enabled << WDT_RREN_RR0_Pos;
        
        //Start the watchdog timer
        NRF_WDT->TASKS_START = 1;
    }
    
    void WatchdogTimer::kick()
    {
        //Reload register 0
        NRF_WDT->RR[0] = WDT_RR_RR_Reload;
    }

    now im wondering what I have to change so it would work with my NRF52.. but I will do some research

Related