How to exit a function

General discussion on mikroC.
Post Reply
Author
Message
ignis
Posts: 172
Joined: 24 Jan 2006 06:58
Location: Gardner, KS

How to exit a function

#1 Post by ignis » 26 Nov 2011 17:28

The stdlib.h file contains a exit() function, but my compiler complains when I try to use that.

How can I completely shut-off a MCU (from code) so that it consumes no more power?

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: How to exit a function

#2 Post by filip » 28 Nov 2011 11:48

Hi,

From code, you can put it in the Sleep mode, in which it will consume minimal power.

Regards,
Filip.

ignis
Posts: 172
Joined: 24 Jan 2006 06:58
Location: Gardner, KS

Re: How to exit a function

#3 Post by ignis » 30 Nov 2011 15:34

filip wrote: From code, you can put it in the Sleep mode, in which it will consume minimal power.

Filip.

Thanks, but I want to do better than sleep. I want to shut-down the MCU and consume no power. Is that possible?

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: How to exit a function

#4 Post by filip » 01 Dec 2011 09:23

Hi,

Unfortunately, this cannot be achieved from the code as far as I know.

Regards,
Filip.

Sparky1039
Posts: 1179
Joined: 24 Nov 2005 20:07
Location: Colorado, USA

Re: How to exit a function

#5 Post by Sparky1039 » 03 Dec 2011 02:06

Thanks, but I want to do better than sleep. I want to shut-down the MCU and consume no power. Is that possible?
If the MCU is completely shut down how do you expect to wake it back up?
What you should consider is using a PIC that offers the XLP capability. If done right the sleep current on some of these parts can be as low as 20-60nA, which in many cases is far lower than the self consumption rate of many battery technologies.
http://www.microchip.com/en_us/technolo ... ducts.html

ignis
Posts: 172
Joined: 24 Jan 2006 06:58
Location: Gardner, KS

Re: How to exit a function

#6 Post by ignis » 03 Dec 2011 05:39

Sparky1039 wrote:
Thanks, but I want to do better than sleep. I want to shut-down the MCU and consume no power. Is that possible?
If the MCU is completely shut down how do you expect to wake it back up?
What you should consider is using a PIC that offers the XLP capability. If done right the sleep current on some of these parts can be as low as 20-60nA, which in many cases is far lower than the self consumption rate of many battery technologies.
http://www.microchip.com/en_us/technolo ... ducts.html
For my application, I can re-power the unit to get it going again.

I think your solution may work here. I'll do some research and give it a try. Thanks.

Sparky1039
Posts: 1179
Joined: 24 Nov 2005 20:07
Location: Colorado, USA

Re: How to exit a function

#7 Post by Sparky1039 » 03 Dec 2011 09:12

If you are going to power cycle the device you might consider this circuit.
PIC switch.png
PIC switch.png (46.03 KiB) Viewed 2610 times
The push button initally routes power around the p-ch fets to get the PIC powered up. Once the PIC is running the first task is to clear the port tied to the p-ch fet gates (low). This will sustain VDD once the push button is opened. When the time comes to kill power the PIC sets the mosfet gates high. This shuts down everything and a button push is the only way to get it started again.
Using 2 mosfets reduces leakage in the off state.

Post Reply

Return to “mikroC General”