Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nRF52: watchdog timeout is not accurate #2635

Merged
merged 3 commits into from
Mar 28, 2023
Merged

Conversation

XuGuohui
Copy link
Member

@XuGuohui XuGuohui commented Mar 9, 2023

Problem

As the title describes. The method of calculating the watchdog reload value may cause the intermediate value overflow, which results in an incorrect reload value being loaded to register.

Solution

Recent nRF5 SDK has fixed this. The PR simply extracts the watchdog related files from the recent SDK and replace the existing files.

Example App

#include "application.h"

SYSTEM_MODE(MANUAL);
SerialLogHandler l(LOG_LEVEL_ALL);

void setup() {
    while (!Serial.isConnected());
    Watchdog.init(WatchdogConfiguration().timeout(240s));
    Watchdog.start();
}

void loop() {
    delay(1s);
    Log.info("Running...");
}

References

https://community.particle.io/t/hardware-watchdog-in-device-os-5-3-0/64031/16


Completeness

  • User is totes amazing for contributing!
  • Contributor has signed CLA (Info here)
  • Problem and Solution clearly stated
  • Run unit/integration/application tests on device
  • Added documentation
  • Added to CHANGELOG.md after merging (add links to docs and issues)

@XuGuohui XuGuohui requested a review from avtolstoy March 9, 2023 09:06
@@ -178,6 +178,34 @@ test(WATCHDOG_07_notify_2) {
assertEqual(magick, 0xdeadbeef);
}

#include "nrf_wdt.h"
test(WATCHDDOG_08_reload_value_is_calculated_correctly) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I'd generalize this test probably and just move the platform-dependent functionality to get current reload value etc into a separate function.

@XuGuohui XuGuohui force-pushed the fix/nrf52_watchdog/sc116493 branch from 074355b to af9470e Compare March 28, 2023 15:45
@XuGuohui XuGuohui merged commit f8ecea8 into develop Mar 28, 2023
@XuGuohui XuGuohui deleted the fix/nrf52_watchdog/sc116493 branch March 28, 2023 16:15
technobly pushed a commit that referenced this pull request May 24, 2023
technobly pushed a commit that referenced this pull request May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants