Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

And SLEEP.........

Status
Not open for further replies.

Scoobystu

New Member
Hi there

I am trying to figure out the SLEEP command on a PIC12f683.

It's really easy to get it to sleep but waking it up is proving to be a bit tricky. Well for me anyway.

According to the Data sheet it can be woken by an external Reset on MCLR, WDT wake-up or an Interrupt from GP2.

I am using the MCLR for a switch to run the program and is therefore turned off. GP2 is monitoring the voltage of the battery in the circuit using a Dallas Voltage monitor. Is there any other way I can get it to wake up?

I am fairly new so there may be an obvious answer to this. Reading the data sheet is still a bit daunting.

Thanks

Stu
 
The obvious answer is the WDT. There are also many interrupts that can wake it. Check section 12.7 of the data sheet.

Why do you want it to sleep and under what circumstances or for what reason do you need it to wake?

Mike.
 
It would seem that I am using quite an old Data sheet for the PIC. Just had a look at another one online. The one I am using does not have a section 12.

Anyway. The basic circuit simply turns a transistor and a couple of LED's on when the button is pressed. When the button is pressed again it reverts back. The batteries in the device are not easily accessable so I was hoping to use the SLEEP function to save some battery power.

Basically I am trying to use the SLEEP function as the master on/off switch. As soon as you put the batteries in the circuit I want it to automatically go to sleep until it is needed and wake if the button is pressed for 3 seconds or more.

Then run as normal until the user is finished and then press the button for 3 seconds again to switch it off i.e. go to SLEEP.

Is this possible?

I just read in another post that the Watchdog timer has to be disabled in the CONFIG but can be turned back on again in the software.
 
The 12F683 may be awoken from sleep by pins other than GP2 and GP3. Which of your devices' pins are available?

Clearify: "I am using the MCLR for a switch to run the program and is therefore turned off." is GP3 used in the program or does it actually pulls the PIC out of reset as MCLR?
 
first read the sleep section. see the part about gpio change interrupt waking the processor from sleep. Then read the interrupts/gpio section and see that the gpio change interrupt gets generated on any input change on the gpio pins.

then notice that you are using gp3 as a switch to run the program. Think about how you might change your use of that pin in your program. hint: you can still use it in polled mode and only have to enable ints when you go to sleep. further hint: you probably only have to add a handful of instructions to make it work.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top