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

nRF51822 feeding watchdog with softdevice

Where would be a good place to feed a watchdog when using a softdevice? My first guess was in main loop:

for (;;) { NRF_WDT->RR[RR_number] = 0x6E524635; power_manage(); }

But this doesn't seem to smart, as I'm not sure how often it will be called. For now I'm working with iBeacon example, but I would like to know in general where would be the best place to feed a watchdog.

Parents
  • FormerMember
    0 FormerMember

    The thing with watchdog is that the correct way of using it is to feed it in the low priority places where the code should run periodically. And definitely NOT to start a timer just to feed the watchdog, since this will make the watchdog happy even if all the other parts of the system are going to the dogs. ;)

    One option is to put the feeding in the main loop. What this can do is that if a system gets stuck in any interrupt or exception, it can be caught. This way will feed the watchdog whenever the system goes to sleep after doing something. What could happen is that this method can be tricked if just one periodic interrupt happens and everything else is not working.

    So, a more correct way of feeding the watchdog is in the places where the system goes periodically and is critical to the working. For this you could have a flag that is bit cleared in different parts of the program and later in main you can check if this flag is zero before sleeping to feed the watchdog (and revert the flag). This way is like an 'AND' operation that you have been in all the relevant parts of the program.

Reply
  • FormerMember
    0 FormerMember

    The thing with watchdog is that the correct way of using it is to feed it in the low priority places where the code should run periodically. And definitely NOT to start a timer just to feed the watchdog, since this will make the watchdog happy even if all the other parts of the system are going to the dogs. ;)

    One option is to put the feeding in the main loop. What this can do is that if a system gets stuck in any interrupt or exception, it can be caught. This way will feed the watchdog whenever the system goes to sleep after doing something. What could happen is that this method can be tricked if just one periodic interrupt happens and everything else is not working.

    So, a more correct way of feeding the watchdog is in the places where the system goes periodically and is critical to the working. For this you could have a flag that is bit cleared in different parts of the program and later in main you can check if this flag is zero before sleeping to feed the watchdog (and revert the flag). This way is like an 'AND' operation that you have been in all the relevant parts of the program.

Children
No Data
Related