![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
asterix
Joined: 02 Feb 2009 Posts: 4
|
Sleep mode Pic 12f508 |
Posted: Mon Feb 02, 2009 8:48 am |
|
|
Hi guys,
I am working with 3 different PICs, and I need to put them in sleep-mode when i am not using it, that is because the power source of the circuit is a small battery of 3V.
The Pic are: 12f508, 12c508 and 12f675.
(I am using now the 12f508 one)
The problem i have is that the pic enter in the sleep mode, but i cannot wake up it, i have a switch in the GP3 pin.
Do I need any special interruption?
Because I enter in the sleep-mode with the command Sleep();
Thank you very much. (and sorry for my english) |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Mon Feb 02, 2009 11:01 am |
|
|
Seriously, consider using the 675, for all the chips.
The 508, is probably about the 'nastiest' chip to use for sleep operations.
What you have to do, is add at the start of your code, a 'restart_cause' test. When the 508, wakes from sleep, it _resets_. This is because it doesn't actually have any support for 'interrupts' at all.
You need to write your code, so that all variables are not initialised on a reset (basically, make them 'local', and don't initialise them), and then if the 'restart_cause', is a power on reset, or MCLR reset, initialise them. Then your possible 'wake' conditions, are WDT timout (if this is enabled), or wake on pin change.
These days, chips like the 12F629, are both cheaper, and better featured...
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
asterix
Joined: 02 Feb 2009 Posts: 4
|
Thanks |
Posted: Tue Feb 03, 2009 1:39 am |
|
|
Hi Ttelmah,
Thank you very much for your answer, I think that I will use the pic 12f675 or 12f629, like you recommend me. In that case I was reading the datasheet but i had the same problem, I dont know how to wake it up from the sleep, because I saw the registers INTCON and IOC, but when I trying to use them, the program doesn´t work (doesn´t wake up from sleep-mode), can you tell me how to do it and if i need to use any interruption or special function?
This are some parts of my program and it will be more easy for you to help me.
Code: | #byte WAKEUP=0x96
#byte INTCON=0x0b
void main()
{
int data;
bit_clear(INTCON,0);
bit_set(INTCON,3);
modo_sleep=0;
if (modo_sleep=1)
{
modo_sleep=0;
delay_ms (500);
bit_set (PORTA,0);
delay_ms (500);
bit_clear (PORTA,0);
data=PORTA;
bit_set(INTCON,3);
sleep();
}
} |
Thank you very much to help me, I really appreciate it |
|
![](templates/subSilver/images/spacer.gif) |
asterix
Joined: 02 Feb 2009 Posts: 4
|
forgot |
Posted: Tue Feb 03, 2009 2:09 am |
|
|
Hi,
I forgot to tell you that i want to wake the pic up with a pin change, I have a switch in the pin 3.
Thanks again. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Tue Feb 03, 2009 3:23 am |
|
|
If you want to use the wake up on pin change, on the 508, this is enabled using the 'setup_wdt' function. As well as controlling the watchdog, this also controls weak pull-ups, and pin change wakeup. Look at the processor include file, for the values used.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
asterix
Joined: 02 Feb 2009 Posts: 4
|
thanks |
Posted: Tue Feb 03, 2009 6:26 am |
|
|
Thank you very much for your answer, It was really good and I could solve the problem, if I have another problem i will ask you because your are rellay good in it.
Thanks again. |
|
![](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
|