PDA

View Full Version : Selective generation of clrwdt?



HenrikOlsson
- 12th April 2010, 17:38
Hello everyone,

As part of an interrupt service routine I have the following code:

If AnalyzeMode THEN
If Trigger = 0 THEN
If Trigged = 0 THEN
Trigged = 1
ENDIF
ENDIF
ENDIF

If my examination of the LST file is correct this particular section generates a total of 12 instructions, out of which 3 is CLRWDT. Because this is an ISR and because I really want it to run as fast as I possible I don't want to spend 25% (or more depending on how the statements evaluates) of the time kicking the dog.

Is there a way to selectively turn off the insertion of CLRWDT, kind of like ENABLE DEBUG? I know you can DEFINE NO_CLRWDT 1 but that is a single shot thing and it would mean I either need to insert the CLRWDT manually (yuk) or kill the dog completely, which I'd prefer not to - if possible.

In this particular case there are a CLRWDT inserted both before AND after this section so doing it up to three more times in just a couple of microseconds seems like quite a waste of time.

Thanks!
/Henrik.

Acetronics2
- 12th April 2010, 18:13
Hi, Henrik

The good question is :

Do you really need the Watchdog to be enabled ??? ... as it's use is limited to SLEEP and NAP PbP commands ...

In other words ... do you use those two commands in your Program ???

Alain

HenrikOlsson
- 12th April 2010, 19:31
Hi Alain,
No, I'm not using Sleep or Nap. But as you know that's not only what the WDT is used for... However, AFIK the program has never locked up or anything like that so you may be right, perhaps I should simply kill it.

I'm still interested in an alternative solution though if anyone else has an idea!

/Henrik.

Acetronics2
- 12th April 2010, 19:34
Hi, Henrik

Could your test be replaced by :



If AnalyzeMode AND ! trigger THEN
trigged = 1
Endif



Alain

HenrikOlsson
- 12th April 2010, 20:02
Yep, that only produces a single clrwdt. On the other hand it produces CALLs to both LNOT and LAND, so two calls = 4 cycles + whatever code is actually in the LNOT and LAND routines. All in all I think it'll be slower than the previous version - unfortunately.

I know, I'm hard to please.... ;-)

/Henrik.

Art
- 12th April 2010, 22:03
Disassemble program, remove offending clrwdt commands, reassemble program.