fix: implement WDT-driven sleep mode with debug toggle #41
No reviewers
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wait-to-fix
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
daru/PICsense!41
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/wdt-sleep-mode"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #40
Summary: Enables WDT as the wakeup source for deep sleep, replacing the
__delay_ms(4000)static delay. Adds aDEBUG_MODEdefine to toggle between WDT sleep and static delay.Changes:
#pragma config WDTE = ON— WDT always on, including during Sleepinit_wdt(0b10010)— 256s prescaler (1:8388608 from 31kHz LFINTOSC)static volatile uint8_t wdt_counter— persists across sleep cyclesgo_to_sleep()in normal mode;__delay_ms(4000)in debug modestop_fvr_tmp_adc()now called before sleep to minimize currentwdt_clear()called before delay in debug mode (WDT is always active with WDTE=ON)Verified against datasheet (PIC12LF1840T39A):
With MAX_COUNTER=3, effective update period ≈ 4×256s = 17.7 min