peripherals not shut down before sleep — current higher than necessary #15

Closed
opened 2026-07-26 22:47:58 +00:00 by time · 3 comments
Contributor

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.

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.
Owner

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.

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.
Author
Contributor

Fixed in PR #16. Three changes:

  1. Config words: BOREN=NSLEEP saves 300nA in sleep. MCLRE=OFF frees RA3. FCMEN/IESO=OFF removes unnecessary circuits.
  2. Comparator: comp_disable() added before sleep.
  3. FVR/ADC: stop_fvr_tmp_adc() added before sleep as defensive measure.

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.

Fixed in PR #16. Three changes: 1. **Config words:** BOREN=NSLEEP saves 300nA in sleep. MCLRE=OFF frees RA3. FCMEN/IESO=OFF removes unnecessary circuits. 2. **Comparator:** comp_disable() added before sleep. 3. **FVR/ADC:** stop_fvr_tmp_adc() added before sleep as defensive measure. 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.
Owner

build works, seems reasonable

build works, seems reasonable
daru closed this issue 2026-07-27 00:10:15 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
daru/PICsense#15
No description provided.