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

Can not debug with ICD-3 while using wdt

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



Joined: 17 Jul 2009
Posts: 21
Location: Kolkata, India

View user's profile Send private message

Can not debug with ICD-3 while using wdt
PostPosted: Sat Aug 03, 2013 4:08 am     Reply with quote

Hello All,

I am using ICD 3, with MPLAB IDE. I know the limitation.

Quote:

Debugger Limitations

The Watchdog Timer (WDT) cannot be used when debugging.


Now my question is what is the wayout? I have written a huge and complicated code with PIC18F452. Now it is really frustrating with out runtime debugging.

Any suggestion?

Amit
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Aug 03, 2013 1:43 pm     Reply with quote

You could possibly emulate the Watchdog with a Timer interrupt.
Just have a global variable and decrement it inside the Timer isr.
Let's say the Timer interrupt occurs every 1 ms. Then initialize
your global counter to 128 (let's say) for a 128 ms emulated WDT
timeout period.

Inside the Timer isr, when or if the global counter variable gets
decremented down to 0, then call the cpu_reset() function.
This will be your emulated WDT reset.

In the rest of your program, everywhere that you have a restart_wdt()
statement, you should add a statement to reload the global counter
with the initial value (128, for example).

It's possible that a fault in your program could stop the Timer interrupts.
In that case, the Watchdog reset emulation would fail. You could check
this by toggling an LED at a 2 Hz rate inside the isr. As long at the LED
is blinking, then you know you have Timer interrupts working, and your
WDT emulation is also probably still working.

You could surround all the WDT emulation lines with
Code:
#ifdef WDT_EMULATION

#endif

The #define WDT_EMULATION when you want to use the emulation code.

I've never done this, but it's just an idea I had right now.
temtronic



Joined: 01 Jul 2010
Posts: 9204
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Aug 03, 2013 1:54 pm     Reply with quote

hmm..
"I have written a huge and complicated code with PIC18F452"

Hopefully you started with small sections of code, debugged them,got them 100% working before you combined into a 'huge and complicated' program!
If not, you're in for a LOT of head scratching, trying to figure out why 'something' doesn't work correctly.
Enabling the WDT is probably the last step in any major program,after having verified all the other code works, as the WDT is a type of 'failsafe' feature.

Also, be aware that the WDT timing is NOT precise.Check the datasheet for the specs.



hth
jay
amit78



Joined: 17 Jul 2009
Posts: 21
Location: Kolkata, India

View user's profile Send private message

PostPosted: Mon Aug 05, 2013 11:07 pm     Reply with quote

Thank you all.

To PCM programmer

Got a simple and nice idea. It will definitely work.


To temtronic

Yea that is true. The code has small small modules. Each module has its own unit testing. so we do debug them without wdt. But now while we integrated the code, we need to test it with wdt. There are some requirement of restart the micro. But some are working some are not, thats why we need to debug.

Thank you all. I will suggest my team for software wdt.

Amit
Ttelmah



Joined: 11 Mar 2010
Posts: 19447

View user's profile Send private message

PostPosted: Tue Aug 06, 2013 1:11 am     Reply with quote

and for 'testing', you need to remember just how inaccurate the WDT is on most chips. We are not talking a +/-10% type error, but 400%+. Typically the '21mSec' watchdog, can trigger anywhere from perhaps 7mSec to 30mSec, on different chip examples. Nothing worse than debugging everything, then finding that there is one part of the code that does not refresh the watchdog, which leave 8mSec, so on just one chip in a thousand, the watchdog triggers....

If you have a spare pin, and the MCLR is enabled, you can implement a 'hardware' watchdog simulator breakout. Replace 'restart_wdt', with code to toggle the spare pin. Have a little timer (perhaps a PIC12F675 or similar), which if it doesn't see this toggle, pulses MCLR low. If you want to use 'restart_cause', so that you can implement watchdog recovery, then a second pin is needed, and have the little timer set a pin high/low according to whether it has triggered, so you can detect the simulated watchdog.

Best Wishes
amit78



Joined: 17 Jul 2009
Posts: 21
Location: Kolkata, India

View user's profile Send private message

PostPosted: Mon Aug 12, 2013 3:25 am     Reply with quote

My boss suggested me to use chip like MAX691 external watchdog timer .. I am checking it.
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