Re: "sleep" inside a loop
Posted: Sun Nov 24, 2024 5:02 pm
Power consumption - I'm intrigued how you got it so low...
So using a PIC12F1840 as per original question - I connected a (sensitive) ammeter. I set the code to use sleep (as above) with a 4s (0b1100) WDT timeout - and pulsed a4 for 1ms (again using a WDT with a prescaler of 0)
When a4 not pulsed - I set to an input.
I set the clock to 31KHz (LF IntOsc) and also in 'Sleep' do:
At 2.2V supply - I get a current draw of (average) 4.80mA - with a 'peak' of 4.85mA when the pulse is sent.
Below ~2V it fails to run (constantly restarting?) and at 5V - it's using 10.53mA.
These figures seem a bit 'high' (the PIC boasts nanoWatt technology?) - and I maybe should unplug the PicKit when testing?
I also tested using the standard 'clock' and a delay - and the results aren't dramatically different for example at 5V with 1s on / 1s off at 16MHz I get ~11.7mA (clock etc is correct as I get a nice 1s blinkie on the scope)
So - maybe my measurement technique is 'off' - I'd certainly hoped to see better savings using sleep... Testing 'sleep' (using a 256s WDT timeout and 1ms pulse averages 10.48mA at 5V
)
Martin
So using a PIC12F1840 as per original question - I connected a (sensitive) ammeter. I set the code to use sleep (as above) with a 4s (0b1100) WDT timeout - and pulsed a4 for 1ms (again using a WDT with a prescaler of 0)
When a4 not pulsed - I set to an input.
I set the clock to 31KHz (LF IntOsc) and also in 'Sleep' do:
Code: Select all
VREGCONbits.VREGPM = 1;
CLRWDT();
SLEEP();
Below ~2V it fails to run (constantly restarting?) and at 5V - it's using 10.53mA.
These figures seem a bit 'high' (the PIC boasts nanoWatt technology?) - and I maybe should unplug the PicKit when testing?
I also tested using the standard 'clock' and a delay - and the results aren't dramatically different for example at 5V with 1s on / 1s off at 16MHz I get ~11.7mA (clock etc is correct as I get a nice 1s blinkie on the scope)
So - maybe my measurement technique is 'off' - I'd certainly hoped to see better savings using sleep... Testing 'sleep' (using a 256s WDT timeout and 1ms pulse averages 10.48mA at 5V

Martin