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() works only after wdt run out?

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



Joined: 23 Aug 2011
Posts: 12

View user's profile Send private message

sleep() works only after wdt run out?
PostPosted: Thu Sep 01, 2011 2:03 pm     Reply with quote

Hi I'm trying to save power making the PIC sleep in my project, but as long as I give the command sleep to the PIC he waits the WDT run out of time to go and sleep and I'd like him to go "straight to bed" instead. Is there a command to the PIC sleep regardless the WDT still counting? or can I set the WDT's counter to a point right before he run out of time?
I tried to set another time to the WDT changing the prescaler to make him to count less or quicker after a long sleep but it doesn't work.

Thank you very much.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 01, 2011 2:11 pm     Reply with quote

Can't really give any help without a compilable test program and the
compiler version.
rsegecin



Joined: 23 Aug 2011
Posts: 12

View user's profile Send private message

PostPosted: Fri Sep 02, 2011 9:34 am     Reply with quote

Thank you the reply PCM. The compiler version is 4.3.0.225, product version 4 and here it's the code.

Code:

#include <16F688.h>

#fuses WDT, HS
#use delay (clock=20Mhz, restart_wdt)

void CheckToSleep()
   {
   int a;
   a = read_eeprom(0x01);

   if (a == 0)
      {
      write_eeprom(0x01, 1);
      output_high(PIN_A0);
      delay_ms(1000);
      output_low(PIN_A0);
      }
   else
      {
      write_eeprom(0x01, 0);
      }

   restart_wdt();
   setup_wdt(WDT_2304MS);
   sleep();
   }

void main()
   {   
   set_tris_a(0x04);
   output_a(0);

   CheckToSleep();

   while (true) {   }
   }
rsegecin



Joined: 23 Aug 2011
Posts: 12

View user's profile Send private message

PostPosted: Fri Sep 02, 2011 12:43 pm     Reply with quote

Hello guys. I've just got the code working. I had just to remove the while, somehow he was getting over there even though the sleep command was called before.

Thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Sep 02, 2011 5:59 pm     Reply with quote

Quote:
The compiler version is 4.3.0.225

For future reference, that's not the compiler version. The compiler
version is given at the start of the .LST file, which is in your project
directory after a successful compilation.

It's a 4-digit number (only) and looks like these examples:
http://www.ccsinfo.com/devices.php?page=versioninfo
rsegecin



Joined: 23 Aug 2011
Posts: 12

View user's profile Send private message

PostPosted: Mon Sep 05, 2011 10:50 am     Reply with quote

Thank you. =D
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