Skip to content
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. NRF52 watchdog problem (myBoardNRF5)
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store

NRF52 watchdog problem (myBoardNRF5)

Scheduled Pinned Locked Moved Troubleshooting
10 Posts 4 Posters 613 Views 5 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • kisse66K Offline
    kisse66K Offline
    kisse66
    wrote on last edited by
    #1

    Have I missed something or is there an issue with watchdog on NRF52 - watchdog does not get suspended when sleeping ?

    Using mysensors 2.3.1 and NRF52832 (Ebyte module) with myboardNRF5. I finally took the time to simplify the code and seems you only need minimum sketch to replicate this, just sleep for longer than wdg period.

    Disabling it manually (wdg_disable) before entering sleep does not change this. I did read the disable is not working, but should set it for long period. Now testing with 20s sleep and 10s wdg period, reboots at every sleep after 10s.

    Ignore the TEST_PIN stuff, it's there to make it easier to re-program (STlink can't connect while sleeping).
    wait() seems to be calling wdg_reset since it doesn't boot there.

    #define MY_DEBUG
    #define MY_RADIO_NRF5_ESB
    #include <MySensors.h>
    
    #ifdef MY_DEBUG
    #define DBG_PRINT(...)    Serial.print(__VA_ARGS__)
    #define DBG_PRINTLN(...)    Serial.println(__VA_ARGS__)
    #else
    #define DBG_PRINT(...)    do {} while (0)
    #define DBG_PRINTLN(...)    do {} while (0)
    #endif
    
    
    #define REED_PIN	18
    #define TEST_PIN	29	// sleep -> wait
    
    
    
    void setup()
    {
    	hwPinMode(REED_PIN, INPUT_PULLUP);
    	hwPinMode(TEST_PIN, INPUT_PULLUP);
    	Serial.begin(115200);
    
    	DBG_PRINT("PART: ");
    	DBG_PRINTLN((uint32_t)NRF_FICR->INFO.PART, HEX);
    	DBG_PRINT("VARIANT: ");
    	DBG_PRINTLN((uint32_t)NRF_FICR->INFO.VARIANT, HEX);
    
    	wdt_enable(10000);
    }
    
    void loop()
    {
    	int8_t stat=0;
    
    	if (digitalRead(TEST_PIN)) {
    		DBG_PRINTLN("sleep");
    		//wdt_disable();
    
    		//int8_t stat = smartSleep(digitalPinToInterrupt(REED_PIN), FALLING, 20000);
    		//int8_t stat = sleep(digitalPinToInterrupt(REED_PIN), FALLING, 20000);
    		int8_t stat = sleep(20000);
    
    		//wdt_enable(10000);
    	}
    	else {
    		DBG_PRINTLN("wait");
    		wait(20000);
    	}
    
    	DBG_PRINT("Wakeup, stat ");
    	DBG_PRINTLN(stat);
    	wdt_reset();
    }
    
    YveauxY monteM 2 Replies Last reply
    0
    • kisse66K kisse66

      Have I missed something or is there an issue with watchdog on NRF52 - watchdog does not get suspended when sleeping ?

      Using mysensors 2.3.1 and NRF52832 (Ebyte module) with myboardNRF5. I finally took the time to simplify the code and seems you only need minimum sketch to replicate this, just sleep for longer than wdg period.

      Disabling it manually (wdg_disable) before entering sleep does not change this. I did read the disable is not working, but should set it for long period. Now testing with 20s sleep and 10s wdg period, reboots at every sleep after 10s.

      Ignore the TEST_PIN stuff, it's there to make it easier to re-program (STlink can't connect while sleeping).
      wait() seems to be calling wdg_reset since it doesn't boot there.

      #define MY_DEBUG
      #define MY_RADIO_NRF5_ESB
      #include <MySensors.h>
      
      #ifdef MY_DEBUG
      #define DBG_PRINT(...)    Serial.print(__VA_ARGS__)
      #define DBG_PRINTLN(...)    Serial.println(__VA_ARGS__)
      #else
      #define DBG_PRINT(...)    do {} while (0)
      #define DBG_PRINTLN(...)    do {} while (0)
      #endif
      
      
      #define REED_PIN	18
      #define TEST_PIN	29	// sleep -> wait
      
      
      
      void setup()
      {
      	hwPinMode(REED_PIN, INPUT_PULLUP);
      	hwPinMode(TEST_PIN, INPUT_PULLUP);
      	Serial.begin(115200);
      
      	DBG_PRINT("PART: ");
      	DBG_PRINTLN((uint32_t)NRF_FICR->INFO.PART, HEX);
      	DBG_PRINT("VARIANT: ");
      	DBG_PRINTLN((uint32_t)NRF_FICR->INFO.VARIANT, HEX);
      
      	wdt_enable(10000);
      }
      
      void loop()
      {
      	int8_t stat=0;
      
      	if (digitalRead(TEST_PIN)) {
      		DBG_PRINTLN("sleep");
      		//wdt_disable();
      
      		//int8_t stat = smartSleep(digitalPinToInterrupt(REED_PIN), FALLING, 20000);
      		//int8_t stat = sleep(digitalPinToInterrupt(REED_PIN), FALLING, 20000);
      		int8_t stat = sleep(20000);
      
      		//wdt_enable(10000);
      	}
      	else {
      		DBG_PRINTLN("wait");
      		wait(20000);
      	}
      
      	DBG_PRINT("Wakeup, stat ");
      	DBG_PRINTLN(stat);
      	wdt_reset();
      }
      
      YveauxY Offline
      YveauxY Offline
      Yveaux
      Mod
      wrote on last edited by
      #2

      @kisse66 I know @petewill is experimenting with Nrf52 and watchdogs; maybe he has some more info on the topic.

      http://yveaux.blogspot.nl

      1 Reply Last reply
      0
      • kisse66K kisse66

        Have I missed something or is there an issue with watchdog on NRF52 - watchdog does not get suspended when sleeping ?

        Using mysensors 2.3.1 and NRF52832 (Ebyte module) with myboardNRF5. I finally took the time to simplify the code and seems you only need minimum sketch to replicate this, just sleep for longer than wdg period.

        Disabling it manually (wdg_disable) before entering sleep does not change this. I did read the disable is not working, but should set it for long period. Now testing with 20s sleep and 10s wdg period, reboots at every sleep after 10s.

        Ignore the TEST_PIN stuff, it's there to make it easier to re-program (STlink can't connect while sleeping).
        wait() seems to be calling wdg_reset since it doesn't boot there.

        #define MY_DEBUG
        #define MY_RADIO_NRF5_ESB
        #include <MySensors.h>
        
        #ifdef MY_DEBUG
        #define DBG_PRINT(...)    Serial.print(__VA_ARGS__)
        #define DBG_PRINTLN(...)    Serial.println(__VA_ARGS__)
        #else
        #define DBG_PRINT(...)    do {} while (0)
        #define DBG_PRINTLN(...)    do {} while (0)
        #endif
        
        
        #define REED_PIN	18
        #define TEST_PIN	29	// sleep -> wait
        
        
        
        void setup()
        {
        	hwPinMode(REED_PIN, INPUT_PULLUP);
        	hwPinMode(TEST_PIN, INPUT_PULLUP);
        	Serial.begin(115200);
        
        	DBG_PRINT("PART: ");
        	DBG_PRINTLN((uint32_t)NRF_FICR->INFO.PART, HEX);
        	DBG_PRINT("VARIANT: ");
        	DBG_PRINTLN((uint32_t)NRF_FICR->INFO.VARIANT, HEX);
        
        	wdt_enable(10000);
        }
        
        void loop()
        {
        	int8_t stat=0;
        
        	if (digitalRead(TEST_PIN)) {
        		DBG_PRINTLN("sleep");
        		//wdt_disable();
        
        		//int8_t stat = smartSleep(digitalPinToInterrupt(REED_PIN), FALLING, 20000);
        		//int8_t stat = sleep(digitalPinToInterrupt(REED_PIN), FALLING, 20000);
        		int8_t stat = sleep(20000);
        
        		//wdt_enable(10000);
        	}
        	else {
        		DBG_PRINTLN("wait");
        		wait(20000);
        	}
        
        	DBG_PRINT("Wakeup, stat ");
        	DBG_PRINTLN(stat);
        	wdt_reset();
        }
        
        monteM Offline
        monteM Offline
        monte
        wrote on last edited by
        #3

        @kisse66 no, once watchdog is started it can't be disabled, until hard reset. It is deliberate design choice for some reason.
        https://devzone.nordicsemi.com/f/nordic-q-a/3143/how-to-disable-the-wdt-watchdog-timer

        kisse66K 1 Reply Last reply
        1
        • monteM monte

          @kisse66 no, once watchdog is started it can't be disabled, until hard reset. It is deliberate design choice for some reason.
          https://devzone.nordicsemi.com/f/nordic-q-a/3143/how-to-disable-the-wdt-watchdog-timer

          kisse66K Offline
          kisse66K Offline
          kisse66
          wrote on last edited by
          #4

          @monte understood, however the MySensorsNRF5 says

          "*The MySensors port for nRF5 supports using the Watchdog. You can use the same commands like defined in "avr/wdt.h" but disable cannot disable the watchdog. The watchdog is set to a period of 36h of CPU runtime.

          When the CPU is in a sleep mode, the watchdog timer is stopped*."

          Especially the suspend, or better lack of, under sleep is my problem. I could set it for >20 minutes (sleep time) perhaps, but if the CPU hangs the long period will use a lot of battery before recovering.

          monteM 1 Reply Last reply
          0
          • kisse66K kisse66

            @monte understood, however the MySensorsNRF5 says

            "*The MySensors port for nRF5 supports using the Watchdog. You can use the same commands like defined in "avr/wdt.h" but disable cannot disable the watchdog. The watchdog is set to a period of 36h of CPU runtime.

            When the CPU is in a sleep mode, the watchdog timer is stopped*."

            Especially the suspend, or better lack of, under sleep is my problem. I could set it for >20 minutes (sleep time) perhaps, but if the CPU hangs the long period will use a lot of battery before recovering.

            monteM Offline
            monteM Offline
            monte
            wrote on last edited by
            #5

            @kisse66 Mysensors can't alter the way the function is implemented in nrf chip. If you go to a link I've posted above, you will see that it is confirmed behavior that is expected by Nordic. Once you have set up and enabled watchdog on NRF5 chip it can't be disabled, nor changed to other settings, without reset via one o these: power, pin, brownout or watchdog.
            I guess the description you are referring to is simply wrong, which is confirmed by your experience. I think we need to ask someone capable to edit this part of the description. Can you specify, where exactly this quote is taken from?

            mfalkviddM 1 Reply Last reply
            1
            • monteM monte

              @kisse66 Mysensors can't alter the way the function is implemented in nrf chip. If you go to a link I've posted above, you will see that it is confirmed behavior that is expected by Nordic. Once you have set up and enabled watchdog on NRF5 chip it can't be disabled, nor changed to other settings, without reset via one o these: power, pin, brownout or watchdog.
              I guess the description you are referring to is simply wrong, which is confirmed by your experience. I think we need to ask someone capable to edit this part of the description. Can you specify, where exactly this quote is taken from?

              mfalkviddM Offline
              mfalkviddM Offline
              mfalkvidd
              Mod
              wrote on last edited by
              #6

              @monte the quote is probably from https://www.openhardware.io/view/376/MySensors-NRF5-Platform (section "Watchdog timer" near the end of the page)

              1 Reply Last reply
              0
              • kisse66K Offline
                kisse66K Offline
                kisse66
                wrote on last edited by
                #7

                yep.

                So if the description is wrong you can't really use WDG with sleeping sensors, unless the sleep period is less than WDG period ?

                monteM 1 Reply Last reply
                0
                • kisse66K kisse66

                  yep.

                  So if the description is wrong you can't really use WDG with sleeping sensors, unless the sleep period is less than WDG period ?

                  monteM Offline
                  monteM Offline
                  monte
                  wrote on last edited by
                  #8

                  @kisse66 try setting longest time period for watchdog and little less for sleep. Every wake up feed watchdog and if nothing happened sleep again. I guess it won't eat to much power, and you can keep your watchdog running.

                  kisse66K 1 Reply Last reply
                  0
                  • monteM monte

                    @kisse66 try setting longest time period for watchdog and little less for sleep. Every wake up feed watchdog and if nothing happened sleep again. I guess it won't eat to much power, and you can keep your watchdog running.

                    kisse66K Offline
                    kisse66K Offline
                    kisse66
                    wrote on last edited by
                    #9

                    @monte yes, makes sense. I know it takes quite a lot of energy to do one cycle due to multiple (slow) sensors and sending those, but have not really looked into a short wake, skip everything and back to sleep. Could easily count wakeups and only do the sensors every Nth wakeup. Maybe it's actually a good way.
                    I have some weird issues for which I need the WDG. Found and fixed one forever loop in I2C, but it did not fix all. Can't pinpoint the issue and now it drains the battery randomly by getting stuck somewhere after a week or a few months.

                    Now I remember one experiment over a year ago with NRF51 based small board I used as mysensors remote. It has just one push button. This silicon version had problem with high current draw if waiting for pin change, so I just made it wakeup every 750ms, poll the button and if not pressed go back to sleep. CR2032 lasted way over a year. Had already forgotten that, good that you reminded!

                    1 Reply Last reply
                    0
                    • mfalkviddM Offline
                      mfalkviddM Offline
                      mfalkvidd
                      Mod
                      wrote on last edited by
                      #10

                      The atmega328 implementation of MySensors sleep wakes up every 8 seconds and result in many years of battery life, so waking up on the nrf5 shouldn’t be much of a problem I think.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      15

                      Online

                      11.7k

                      Users

                      11.2k

                      Topics

                      113.0k

                      Posts


                      Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • OpenHardware.io
                      • Categories
                      • Recent
                      • Tags
                      • Popular