![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Mar 26, 2010 5:45 pm |
|
|
The test program shown below works. If I press a switch which connects
pin B0 to ground, the PIC wakes up from sleep and flashes an LED.
Then it goes back to sleep. Internal pull-ups are enabled, so there is
no external pull-up on the switch. This was tested with PCB vs. 4.073
which comes with MPLAB for free. The code was tested in hardware.
If it doesn't work, make sure that you disconnect your ICD2 from the
board before you do the test. That's necessary. Also make sure that
you haven't accidently clobbered the Calibration Memory value at the
end of the PIC's ROM address. If you're using MPLAB, it will warn you
if this happened, and you can re-program the value back again. Also
be aware that when this PIC wakes up from Sleep, it does a reset.
It doesn't start running from where it went to sleep. It resets.
Code: |
#include <10F206.h>
#fuses NOMCLR
#use delay(clock=4000000)
#define SWITCH PIN_B0
#define LED PIN_B2
#define set_options(value) {#ASM \
MOVLW value \
OPTION \
#ENDASM}
//================================
void main()
{
setup_comparator(NC_NC);
// Enable pull-ups, wake-up on change, and Pin B2 for normal i/o.
set_options(0x1F);
output_high(LED); // Flash an LED
delay_ms(500);
output_low(LED);
sleep();
while(1);
}
|
|
|
![](templates/subSilver/images/spacer.gif) |
Jody
Joined: 08 Sep 2006 Posts: 182
|
|
Posted: Sat Mar 27, 2010 7:18 am |
|
|
THANK!!!
As soon I get back into the office I will test it..
Keep you informed!!! |
|
![](templates/subSilver/images/spacer.gif) |
Jody
Joined: 08 Sep 2006 Posts: 182
|
|
Posted: Mon Mar 29, 2010 6:14 am |
|
|
Great it works....
During sleep the uC draws abour 2mA..... is it possible to reduce this??
Regards,
Jody |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Mon Mar 29, 2010 8:25 am |
|
|
It depends on a lot of things.
First, and pin that is 'driving' something, will result in the chip drawing what it needs to drive this target. So you must turn all output pins to the state where they are drawing the least power.
Second, you need to be careful, to not to leave input pins 'floating'. They need to be either resistor biased to the supply rails, connected to something else that does this, or switched to being outputs, if this can be safely done.
Third, how is your power being generated?. Regulator IC?. If so, what does _this_ draw. Many draw several mA, even with no output load. You need to be looking at ultra low quiescent consumption regulators. However you then have a 'caveat', that many of these are more prone to oscillation than the traditional designs, meaning great care must be taken with the layout round these.
Then you need to turn off any peripherals in the PIC, that are still left running. Many go 'off' automatically, but some parts like the ADC, if running off it's own RC clock, still run, and will draw power. In your case, are you using the watchdog when asleep?. If not, then this needs to be switched off. Same applies to the comparator.
You should be able to get consumption of a very few uA.
Look at table 12.1.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|