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

Watchdog enabled on power on #3

Open
CtrlC-Root opened this issue May 12, 2023 · 0 comments
Open

Watchdog enabled on power on #3

CtrlC-Root opened this issue May 12, 2023 · 0 comments

Comments

@CtrlC-Root
Copy link

According to the datasheet the watchdog timer is enabled by default after a power-on reset. It's set to ~ 16 seconds after which it will reset the board (section 15.4 on page 261). If you're just blinking an LED like in this example especially with a long period then you are unlikely to notice it fire and reset the board. I spent an hour debugging my own bare metal program trying to figure out why it was resetting at such a consistent uptime before I figured this out. You can disable it on boot with:

static uint32_t* const WDT_MR = (uint32_t*) 0x400E1A54;

void main() {
  // watchdog timer is actived on boot with a default timeout so disable it
  // note: you can only write to WDT_MR once after power on reset
  // Atmel SAM3X8E Datasheet, section 15.4, page 261
  *WDT_MR |= (1 << 15); // WDDIS (watchdog disable) bit, page 265

  // ... omitted ...
}

Hopefully this helps the next person who comes along and tries to use this project as a starting point from having to debug the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant