fix: IWDG reset during gyro recal — refresh at i=0 not i=39 (P0 #42) #172

Merged
sl-jetson merged 1 commits from sl-firmware/gyro-recal-button into main 2026-03-02 10:34:21 -05:00
Collaborator

Summary

  • Root cause: i%40==39 fired the first IWDG refresh only after 40ms of calibration. Combined with ~10ms of main loop overhead before entering calibrate(), total elapsed since last refresh could exceed the 50ms IWDG window → watchdog reset.
  • Fix: Change to i%40==0 — first refresh fires at i=0 (<1ms after entry), subsequent refreshes every 40ms, safely within the 50ms window.
  • One file changed: src/mpu6000.c (+4/-2)

Test plan

  • Flash and trigger gyro recal — confirm no watchdog reset during calibration
  • Verify IWDG refresh timing with logic analyser / SWD trace
  • Regression: normal operation loop still refreshes IWDG correctly

Closes #42

🤖 Generated with Claude Code

## Summary - **Root cause**: `i%40==39` fired the first IWDG refresh only after 40ms of calibration. Combined with ~10ms of main loop overhead before entering `calibrate()`, total elapsed since last refresh could exceed the 50ms IWDG window → watchdog reset. - **Fix**: Change to `i%40==0` — first refresh fires at i=0 (<1ms after entry), subsequent refreshes every 40ms, safely within the 50ms window. - One file changed: `src/mpu6000.c` (+4/-2) ## Test plan - [ ] Flash and trigger gyro recal — confirm no watchdog reset during calibration - [ ] Verify IWDG refresh timing with logic analyser / SWD trace - [ ] Regression: normal operation loop still refreshes IWDG correctly Closes #42 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sl-webui added 1 commit 2026-03-02 10:29:38 -05:00
i%40==39 fired the first IWDG refresh only after 40ms of calibration.
Combined with ~10ms of main loop overhead before entering calibrate(),
total elapsed since last refresh could exceed the 50ms IWDG window.

Change to i%40==0: first refresh fires at i=0 (<1ms after entry),
subsequent refreshes every 40ms — safely within the 50ms window.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sl-jetson merged commit 566cfc8811 into main 2026-03-02 10:34:21 -05:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: seb/saltylab-firmware#172
No description provided.