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 CCS Technical Support

PIC16F676 can't get the WDT to wake it back up

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



Joined: 10 Mar 2005
Posts: 1

View user's profile Send private message

PIC16F676 can't get the WDT to wake it back up
PostPosted: Thu Mar 10, 2005 11:39 am     Reply with quote

Hello,

CCS PCM C Compiler, Version 3.218

I believe my WDT is not active even though I believe it is set. I can get the device to sleep, but the WDT does not wake it up. When I stop the debugger, I get an error message "Could not run program: The target was not haulted", which I assume happens because the micro is in sleep mode. If I mask the sleep command, and unmask the 500ms time delay, the program works. I just want the micro to sleep for the duration of the WDT, and wake up. Attached is the simplified code...Any ideas on what I'm doing wrong? Thanks for any input you can provide!!!

PROGRAM:

#include <prototype s.h>

#define low_voltage 268
#define high_voltage 403


CHECK_VOLTAGE();
long reading;


void main() {


setup_adc_ports(sAN0|sAN1|sAN2|sAN3|sAN4|sAN5|sAN6|sAN7|VSS_VDD);
setup_adc(adc_clock_internal);

setup_timer_0(RTCC_INTERNAL);
setup_wdt(WDT_1152MS);


while (true) {



output_high(charge_FET); //turn on charge FET
output_high(discharge_FET); //turn on discharge FET
delay_ms(30);

set_adc_channel(7);
CHECK_VOLTAGE();

// delay_ms(500); // remove "//" on this line and block the sleep command. The code works


sleep();

}
}


CHECK_VOLTAGE() {


reading = read_adc();

if(reading < low_voltage)
{
output_low(charge_FET); //turn off charge FET
output_low(discharge_FET); //turn off discharge FET
}

else if (reading > high_voltage)
{
output_low(charge_FET); //turn off charge FET
output_low(discharge_FET); //turn off discharge FET
}

else
{
output_high(charge_FET); //turn on charge FET
output_high(discharge_FET); //turn on discharge FET
}
}

phototype s.h file:

#include <16f676 s.h>
#device ICD=TRUE
#device adc=10

#fuses INTRC_IO,NOPROTECT,NOBROWNOUT,NOMCLR,NOCPD,PUT,WDT

#ROM 0x3ff = {0x3480} //use as last resort to restore cal. data

#use delay (clock=4000000)



#define charge_FET pin_C4
#define discharge_FET pin_C5
_________________
Thank you!
Randy:)

CCS PCM C Compiler, Version 3.218
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Thu Mar 10, 2005 12:02 pm     Reply with quote

The WDT cannot be enabled with the debugger! It won't let you.
Guest








PostPosted: Thu Mar 10, 2005 12:27 pm     Reply with quote

Thanks Mark!

So, I if I understand you correctly, I'll need to test this feature using a real device while monitoring the device current to make sure it is is in sleep mode?

Thanks!
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Thu Mar 10, 2005 1:33 pm     Reply with quote

Yep.
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