peripherals not shut down before sleep — current higher than necessary #15
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wait-to-fix
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
daru/PICsense#15
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
go_to_sleep() issues SLEEP without disabling peripherals that continue drawing current in Power-Down mode. The PIC12LF1840 datasheet (Section 9.0) lists current-sucking culprits: FVR/DAC modules, modules using 31kHz LFINTOSC, Timer1 oscillator, and floating I/O pins. Currently the comparator is never disabled, pull-ups aren't configured, and there's no explicit peripheral shutdown before sleep. The ~500nA target requires all these to be addressed.
Fix: add a pre-sleep routine that disables the comparator (CM1CON0), disables unused pull-ups, and ensures all I/O pins are driven or pulled to VSS/VDD before SLEEP.
For sure there are probably some settings that are incorrect here. We should make sure that the watchdog timer can still work in order to bring us out of sleep, or we'll need to get more creative.
Fixed in PR #16. Three changes:
Power-down target: ~530nA at 3.0V (30nA base + 500nA WDT). WDT stays on as wakeup source — switching to Timer1 would be the same current draw.
build works, seems reasonable