PIC18F..K22 sleep mode
Posted: Fri Jun 05, 2015 8:29 am
I'm developing a battery powered application and I'm trying to understand how to best use sleep mode on the K22 series processors.
At the moment I'm using the PMD module to turn off all peripherals when I go in to sleep mode but it has just hit me, do I need to? Does this actually save any additional power in sleep, or is it just meant for use in Idle mode?
Conversely, does disabling the peripherals I don't use at all save any power in run mode?
The 18F26K22 datasheet isn't that clear on this, the manual for the PIC24 series has much more information but I don't know how this translates to the 18F series.
Also, I have implemented a mode where if the device hasn't been used for 10 minutes it shuts down and only a key press or plugging in the charger will wake it. However, I'm seeing the unit occasionally wake up for no apparent reason. Re-reading the datasheet I wonder if this could be due to interrupts? I'd assumed if I just use GIE to globally disable interrupts that would be enough, however, re-reading the manual it reads as if as interrupt that is enabled, regardless of the GIE bit will wake from sleep. Is this correct? I'm wondering that as I use Timer0 - which isn't affected by the PMD module - it will be incrementing each time the unit wakes from sleep to check the inputs. Therefore, eventually it will overflow and set the interrupt flag which will wake the processor.
Does this sound likely?
Is it good practice to clear all interrupt enable bits in INTCON/PIE registers before going to sleep and re-set them on wake if you don't want to wake by interrupt?
Is it similarly good practice to have a ClrWDT immediately on wake? (I'm wondering if the watchdog is waking the processor from sleep then resetting the unit)
On wake I do While Not FVSTR Went so nothing happens until the FVR is stable while - I'm assuming - will mean that should the battery have dropped very low the BOR will trigger. Can anyone see any issues with that?
I do that as I have a function on startup which looks for a brown-out reset and will lock the unit in sleep mode until the charger is connected. Am I just asking for trouble doing this as presumably once the oscillator kicks back up the brown-out module will be triggered anyway? (I runat 64MHz normally but kick down to 31KHz when in power-down mode)
I think using sleep modes is the sort of thing that could do with a wiki entry as it isn't as simple as it appears!
At the moment I'm using the PMD module to turn off all peripherals when I go in to sleep mode but it has just hit me, do I need to? Does this actually save any additional power in sleep, or is it just meant for use in Idle mode?
Conversely, does disabling the peripherals I don't use at all save any power in run mode?
The 18F26K22 datasheet isn't that clear on this, the manual for the PIC24 series has much more information but I don't know how this translates to the 18F series.
Also, I have implemented a mode where if the device hasn't been used for 10 minutes it shuts down and only a key press or plugging in the charger will wake it. However, I'm seeing the unit occasionally wake up for no apparent reason. Re-reading the datasheet I wonder if this could be due to interrupts? I'd assumed if I just use GIE to globally disable interrupts that would be enough, however, re-reading the manual it reads as if as interrupt that is enabled, regardless of the GIE bit will wake from sleep. Is this correct? I'm wondering that as I use Timer0 - which isn't affected by the PMD module - it will be incrementing each time the unit wakes from sleep to check the inputs. Therefore, eventually it will overflow and set the interrupt flag which will wake the processor.
Does this sound likely?
Is it good practice to clear all interrupt enable bits in INTCON/PIE registers before going to sleep and re-set them on wake if you don't want to wake by interrupt?
Is it similarly good practice to have a ClrWDT immediately on wake? (I'm wondering if the watchdog is waking the processor from sleep then resetting the unit)
On wake I do While Not FVSTR Went so nothing happens until the FVR is stable while - I'm assuming - will mean that should the battery have dropped very low the BOR will trigger. Can anyone see any issues with that?
I do that as I have a function on startup which looks for a brown-out reset and will lock the unit in sleep mode until the charger is connected. Am I just asking for trouble doing this as presumably once the oscillator kicks back up the brown-out module will be triggered anyway? (I runat 64MHz normally but kick down to 31KHz when in power-down mode)
I think using sleep modes is the sort of thing that could do with a wiki entry as it isn't as simple as it appears!