I needed lots of inline clrwdt instructions so I decided to try this:
#define CLEARDOG asm { clrwdt }
This does not work. The expanded code looks like this:
asm{ clrwdt } ; and the compiler rejects the next line as invalid assembler.
After much messing about it seems that the compiler requires a line end before the final braces. So the code that does work looks like this:
asm{clrwdt
};
This seems a little quirky to me. I cant seem to force an inline line end. Any ideas on a workaround for this?
A function call would work but the overhead is excessive as the compiler can't be forced to do an inline expansion.
#define of inline asm
#define of inline asm
Last edited by dgoadby on 04 Aug 2005 23:47, edited 1 time in total.
David Goadby
Have you tried to reset the WDT within an interupt
The above gives me an aprox 1 sec CPU pulse and reset the WDT at every pulse.
Andrew
Code: Select all
void interupt() {
cnt++; // Increment value of cnt on every interupt
TMR0L = 96;
INTCON = 0x20; // Set T0IE, clear T0IF
if (cnt == 400) {
PORTA.f3 = ~PORTA.f3; //CPU Led heart beat
cnt = 0; // Reset cnt
asm CLRWDT ; // Reset watch dog timer
}
}//~
Andrew
Thanks,
I have learnt something
I have added into my code
And WORKS
Andrew
I have learnt something
I have added into my code
Code: Select all
#define CLEARWDOG asm CLRWDT
#define CPU_Led PORTA.f3
...
CPU_Led = ~CPU_Led; //CPU Led heart beat
cnt = 0; // Reset cnt
CLEARWDOG ; // Reset watch dog timer
Andrew