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

WDT question... debugging

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



Joined: 04 Jun 2009
Posts: 107

View user's profile Send private message

WDT question... debugging
PostPosted: Tue Sep 29, 2009 1:30 pm     Reply with quote

Crap, I posted this a couple days ago and I was wondering why nobody was answering... now I see my post must not have taken :(


Anyway. I have a WDT issure.

PIC 18F4480

When I set WDT_OFF (first line of main()) then everything works good. Setting it to WDT_ON and my device doesn't work - it appears to "stall". I presume then that this means the watchdog isn't getting reset in time. I do have restart_wdt() in my main() code and it was working before I made some changes to my code. So obviously the changes I made are slowing down the system to the point that the WDT can't be reset fast enough.

So that's my issue... is there a way to "time audit" to figure out what routine(s) is/are taking too long?

If it helps, here's the top of my header file:

Code:
#include <18F4480.h>

#DEVICE HIGH_INTS=TRUE, ADC=8, WRITE_EEPROM=ASYNC
#use delay(clock=40000000)
#fuses HS,NOWDT,WDT128,BROWNOUT,BORV28
//PROTECT,CPB,CPD,NOEBTR
#ZERO_RAM


Thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 29, 2009 2:12 pm     Reply with quote

To measure the time required for a block of code, you can use the
MPLAB Simulator's Stopwatch feature. This thread has instructions on
how to use it:
http://www.ccsinfo.com/forum/viewtopic.php?t=38351

You can also set an i/o pin high at the start of a routine and low at the
end, and use an oscilloscope or a logic analyzer to see the pulse length,
and thus find the length of the routine.

On a more global scale, you could output a pulse just after the line that
calls restart_wdt() in your program. Then use a scope or logic analyzer
to see the time between pulses. (Or, just toggle an i/o pin at that line).
This assumes you have only one line that calls restart_wdt().
s_mack



Joined: 04 Jun 2009
Posts: 107

View user's profile Send private message

PostPosted: Tue Sep 29, 2009 2:16 pm     Reply with quote

Thanks for the link. I'll check out the simulator.
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