CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Sleep mode Pic 12f508

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
asterix



Joined: 02 Feb 2009
Posts: 4

View user's profile Send private message

Sleep mode Pic 12f508
PostPosted: Mon Feb 02, 2009 8:48 am     Reply with quote

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)
Ttelmah
Guest







PostPosted: Mon Feb 02, 2009 11:01 am     Reply with quote

Seriously, consider using the 675, for all the chips. Smile
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
asterix



Joined: 02 Feb 2009
Posts: 4

View user's profile Send private message

Thanks
PostPosted: Tue Feb 03, 2009 1:39 am     Reply with quote

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
asterix



Joined: 02 Feb 2009
Posts: 4

View user's profile Send private message

forgot
PostPosted: Tue Feb 03, 2009 2:09 am     Reply with quote

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.
Ttelmah
Guest







PostPosted: Tue Feb 03, 2009 3:23 am     Reply with quote

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
asterix



Joined: 02 Feb 2009
Posts: 4

View user's profile Send private message

thanks
PostPosted: Tue Feb 03, 2009 6:26 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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