View previous topic :: View next topic |
Author |
Message |
rsegecin
Joined: 23 Aug 2011 Posts: 12
|
sleep() works only after wdt run out? |
Posted: Thu Sep 01, 2011 2:03 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Sep 01, 2011 2:11 pm |
|
|
Can't really give any help without a compilable test program and the
compiler version. |
|
![](templates/subSilver/images/spacer.gif) |
rsegecin
Joined: 23 Aug 2011 Posts: 12
|
|
Posted: Fri Sep 02, 2011 9:34 am |
|
|
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) { }
}
|
|
|
![](templates/subSilver/images/spacer.gif) |
rsegecin
Joined: 23 Aug 2011 Posts: 12
|
|
Posted: Fri Sep 02, 2011 12:43 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Sep 02, 2011 5:59 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
rsegecin
Joined: 23 Aug 2011 Posts: 12
|
|
Posted: Mon Sep 05, 2011 10:50 am |
|
|
Thank you. =D |
|
![](templates/subSilver/images/spacer.gif) |
|